diff --git a/components/index.js b/components/index.js index 32334ef7..7cca617a 100644 --- a/components/index.js +++ b/components/index.js @@ -5,6 +5,15 @@ let components = []; // 定义 install 方法,接收 Vue 作为参数。如果使用 use 注册插件,则所有的组件都将被注册 const install = function (Vue) { if (install.installed) return; + // 声明全局业务对象类 + const models = require.context('./model', true, /\.js$/) + if (models) { + const model = {} + models.keys().map(e => { + model[e.replace(/\.[\/\\]([^\\\/]+)\.js$/, '$1')] = models(e).default + }) + Vue.prototype.MODEL = model + } // 遍历注册全局组件 let contexts = require.context('.', true, /[\\\/]Ai([^\\\/]+)\.vue$/); if (contexts) { diff --git a/components/model/Party.js b/components/model/Party.js new file mode 100644 index 00000000..e69de29b diff --git a/components/model/PartyOrg.js b/components/model/PartyOrg.js new file mode 100644 index 00000000..c853d293 --- /dev/null +++ b/components/model/PartyOrg.js @@ -0,0 +1,25 @@ +import http from "dvcp-ui/lib/js/request"; + +export default class PartyOrg { + constructor(id) { + this.id = id + this.loaded = false + this.init().finally(() => this.loaded = true) + } + + init() { + return PartyOrg.getInfo(this.id).then(data => { + Object.entries(data).map(([k, v]) => this[k] = v) + }) + } + + static getInfo(id) { + return http.post("/app/partyOrganization/queryOrgById", null, { + params: {id} + }).then(res => { + if (res?.data) { + return res.data + } + }) + } +} diff --git a/project/pingchang/apps/AppGeneralElection/components/electionAdd.vue b/project/pingchang/apps/AppGeneralElection/components/electionAdd.vue index a8053e4f..edaf3e15 100644 --- a/project/pingchang/apps/AppGeneralElection/components/electionAdd.vue +++ b/project/pingchang/apps/AppGeneralElection/components/electionAdd.vue @@ -234,6 +234,15 @@ export default { confirm() { this.$refs.form.validate((valid) => { if (valid) { + if(this.form.electionMethod == 0) { + if(this.form.chooseNumber != this.form.candidateUsers.length) { + return this.$message.error('候选人数与应选人数应相等') + } + } else if(this.form.electionMethod == 1) { + if(this.form.chooseNumber >= this.form.candidateUsers.length) { + return this.$message.error('候选人数应多于应选人数') + } + } this.instance.post(`/app/appgeneralelectioninfo/addOrUpdate`,{ ...this.form }).then(res => { diff --git a/project/pingchang/apps/AppGeneralElection/components/electionList.vue b/project/pingchang/apps/AppGeneralElection/components/electionList.vue index faf2b651..3139fa2d 100644 --- a/project/pingchang/apps/AppGeneralElection/components/electionList.vue +++ b/project/pingchang/apps/AppGeneralElection/components/electionList.vue @@ -17,10 +17,9 @@ @@ -82,7 +81,7 @@ export default { } }) }, - toAdd(id,flag) { + toAdd(id) { this.$emit('change', { type: 'electionAdd', params: { @@ -107,12 +106,24 @@ export default { } this.getList() }, - // 结束 + // 开启、结束 startEnd(id, status) { - this.$confirm('投票正在进行中,确定要提前结束吗?').then(() => { - this.instance.post(`/app/appgeneralelectioninfo/start-end?id=${id}&start=${status}`).then(res=>{ + let title = '' + let bool = null + let tips = '' + if(status == 0) { + title = '未到投票开始时间,确定要提前开始吗?' + bool = true + tips = '开启成功' + } else if(status == 1) { + title = '投票正在进行中,确定要提前结束吗?' + bool = false + tips = '结束成功' + } + this.$confirm(title).then(() => { + this.instance.post(`/app/appgeneralelectioninfo/start-end?id=${id}&start=${bool}`).then(res=>{ if(res.code == 0) { - this.$message.success('结束成功') + this.$message.success(tips) this.getList() } }) diff --git a/project/pingchang/apps/AppOrganizationChange/AppOrganizationChange.vue b/project/pingchang/apps/AppOrganizationChange/AppOrganizationChange.vue index fb79d1fd..5f104e68 100644 --- a/project/pingchang/apps/AppOrganizationChange/AppOrganizationChange.vue +++ b/project/pingchang/apps/AppOrganizationChange/AppOrganizationChange.vue @@ -15,9 +15,15 @@ import organizationSetting from "./components/organizationSetting.vue"; export default { name: "AppOrganizationChange", label: "组织换届", + provide() { + return { + ...this.$props + } + }, props: { instance: Function, dict: Object, + permissions: Function }, components: { List, @@ -36,7 +42,6 @@ export default { }, data() { return { - component: "List", params: {}, include: [], selected: {}, @@ -47,10 +52,6 @@ export default { this.params = data.params; }, }, - created() { - let {organizationId: id, organizationName: name} = this.user.info - this.selected = {id, name} - } } diff --git a/project/pingchang/apps/AppOrganizationChange/components/List.vue b/project/pingchang/apps/AppOrganizationChange/components/List.vue index bdff762a..78f43c61 100644 --- a/project/pingchang/apps/AppOrganizationChange/components/List.vue +++ b/project/pingchang/apps/AppOrganizationChange/components/List.vue @@ -1,11 +1,7 @@ @@ -39,12 +36,7 @@ import history from './history.vue' export default { name: 'List', - props: { - instance: Function, - permissions: Function, - dict: Object, - selected: Object - }, + inject: ['permissions', 'instance', 'dict'], data() { return { tabs: [ @@ -52,6 +44,7 @@ export default { {label: '历史届次', name: 'history', comp: history, permission: ''} ], currIndex: '0', + selected: null } }, components: { @@ -60,25 +53,15 @@ export default { }, computed: { ...mapState(['user']), - - orgTree() { - return this.$refs.tree?.$refs?.partyTree - }, }, - methods: { - showNeighbourSetting(id) { - this.$router.push({query: {id}, hash: "#ns"}) - }, onTreeChange(e) { - this.$emit("update:selected", e) + this.selected = e this.$refs[this.tabs[Number(this.currIndex)].name][0].getList(e.id) }, - onSearch(v) { - this.orgTree.filter(v) + this.$refs.tree?.$refs?.partyTree?.filter(v) }, - filterNode(value, data) { if (!value) return true return data.name.indexOf(value) !== -1 @@ -86,9 +69,13 @@ export default { toAdd(id) { this.$router.push({hash: "#add", query: {id}}) }, - toSetting(id) { - this.$router.push({hash: "#setting", query: {id}}) + toSetting(oid) { + this.$router.push({hash: "#setting", query: {oid}}) } + }, + created() { + const {organizationId: id, organizationName: name} = this.user.info + this.selected = {id, name} } } @@ -135,6 +122,7 @@ export default { .ai-list__content--right-wrapper { width: 100%; + padding-top: 0; } } diff --git a/project/pingchang/apps/AppOrganizationChange/components/addChange.vue b/project/pingchang/apps/AppOrganizationChange/components/addChange.vue index 18dbaa47..c67d6d17 100644 --- a/project/pingchang/apps/AppOrganizationChange/components/addChange.vue +++ b/project/pingchang/apps/AppOrganizationChange/components/addChange.vue @@ -99,6 +99,16 @@ export default { } }, methods: { + // getDetail() { + // const {id: organizationId} = this.$route.query + // organizationId && this.instance.post(`/app/apporganizationgeneralelection/queryDetailByOrganizationId`, null, { + // params: {organizationId} + // }).then(res => { + // if (res?.data) { + // this.form = res.data + // } + // }) + // }, cancel() { this.$router.push({}) }, diff --git a/project/pingchang/apps/AppOrganizationChange/components/moment.vue b/project/pingchang/apps/AppOrganizationChange/components/moment.vue index 62212705..8f6dfb30 100644 --- a/project/pingchang/apps/AppOrganizationChange/components/moment.vue +++ b/project/pingchang/apps/AppOrganizationChange/components/moment.vue @@ -1,56 +1,64 @@