Files
dvcp_v2_webapp/project/pingchang/apps/AppGeneralElection/components/electionAdd.vue

271 lines
11 KiB
Vue
Raw Normal View History

2022-10-13 14:42:24 +08:00
<template>
<section class="electionAdd">
2022-10-21 17:22:38 +08:00
<ai-detail v-show="id && !isEdit">
2022-10-17 15:59:19 +08:00
<template slot="title">
<ai-title title="换届选举详情" isShowBack isShowBottomBorder @onBackClick="cancel(false)"></ai-title>
</template>
<template slot="content">
2022-10-21 14:43:15 +08:00
<ai-card :title="info.title">
2022-10-17 15:59:19 +08:00
<template #right>
2022-10-21 15:20:09 +08:00
<span style="color:#2266FF;cursor: pointer;font-size: 12px;" class="iconfont iconEdit" v-if="isEdit==false && info.status==0" @click="update">修改</span>
2022-10-17 15:59:19 +08:00
</template>
<template #content v-if="isEdit == false">
<ai-wrapper>
<ai-info-item label="投票说明" :value="info.votingInstructions"></ai-info-item>
<ai-info-item label="单位名称" :value="info.organizationName"></ai-info-item>
2022-10-17 16:56:42 +08:00
<ai-info-item label="选举方式">
{{ info.electionMethod==0? '等额':'差额'}}
2022-10-18 15:56:46 +08:00
<el-tooltip class="item" effect="dark" content="差额选举候选人数多于应选人数的选举方式
等额选举候选人数与应选人数相等的选举方式" placement="top">
<i class="el-icon-info" style="margin-right: 8px"></i>
</el-tooltip>
2022-10-17 16:56:42 +08:00
</ai-info-item>
2022-10-17 15:59:19 +08:00
<ai-info-item label="应选人数" :value="info.candidatesNumber"></ai-info-item>
<ai-info-item label="投票日期" :value="info.votingDate"></ai-info-item>
2022-10-21 14:43:15 +08:00
</ai-wrapper>
</template>
</ai-card>
<ai-card title="参会人员信息">
<template #content v-if="isEdit == false">
<ai-wrapper>
2022-10-17 15:59:19 +08:00
<ai-info-item label="候选人" isLine>
<span v-for="(item,index) in candidateUsersList" :key="index">
{{ item }}
2022-10-17 16:56:42 +08:00
<span v-if="index < candidateUsersList.length - 1"></span>
2022-10-17 15:59:19 +08:00
</span>
</ai-info-item>
2022-10-21 14:43:15 +08:00
<ai-info-item label="投票人" isLine>
2022-10-17 15:59:19 +08:00
<span v-for="(item,index) in voteUsersList" :key="index">
{{ item }}
2022-10-17 16:56:42 +08:00
<span v-if="index < voteUsersList.length - 1"></span>
2022-10-17 15:59:19 +08:00
</span>
</ai-info-item>
</ai-wrapper>
</template>
</ai-card>
</template>
</ai-detail>
2022-10-21 15:20:09 +08:00
<ai-detail v-show="!id || isEdit==true">
2022-10-17 15:59:19 +08:00
<ai-title slot="title" :title="id? '编辑换届选举':'添加换届选举'" isShowBottomBorder isShowBack @onBackClick="cancel(true)"/>
2022-10-13 14:42:24 +08:00
<template slot="content">
<ai-card title="基本信息">
<template #content>
<div class="add-form">
<el-form ref="form" :model="form" :rules="formRules" size="small" label-width="150px">
2022-10-17 11:09:47 +08:00
<el-form-item label="标题" prop="title">
<el-input v-model="form.title" placeholder="请输入" show-word-limit maxlength="100"></el-input>
2022-10-13 14:42:24 +08:00
</el-form-item>
2022-10-17 11:09:47 +08:00
<el-form-item label="投票说明">
<el-input type="textarea" :rows="5" v-model="form.votingInstructions" placeholder="请输入" show-word-limit maxlength="500"></el-input>
2022-10-13 14:42:24 +08:00
</el-form-item>
2022-10-17 11:09:47 +08:00
<el-form-item label="单位名称" prop="organizationName">
<el-input size="small" disabled placeholder="请选择所属党组织" v-model="form.organizationName">
2022-10-13 14:42:24 +08:00
<template slot="append">
<ai-party :instance="instance" size="small" :value="form.partyOrgId" @origin="handlePartyOrgSelect"/>
</template>
</el-input>
</el-form-item>
2022-10-17 11:09:47 +08:00
<el-form-item label="选举方式" prop="electionMethod">
2022-10-17 14:18:32 +08:00
<el-tooltip class="item" effect="dark" content="差额选举候选人数多于应选人数的选举方式
等额选举候选人数与应选人数相等的选举方式" placement="top">
<i class="el-icon-info" style="margin-right: 8px"></i>
</el-tooltip>
2022-10-17 16:56:42 +08:00
<el-radio v-model="form.electionMethod" label="0">等额</el-radio>
<el-radio v-model="form.electionMethod" label="1">差额</el-radio>
2022-10-13 14:42:24 +08:00
</el-form-item>
<el-row type="flex">
<el-col :span="20">
2022-10-17 16:56:42 +08:00
<el-form-item label="应选人数" prop="chooseNumber">
<el-input type="number" v-model="form.chooseNumber" placeholder="请输入"></el-input>
2022-10-13 14:42:24 +08:00
</el-form-item>
</el-col>
<el-col :span="20">
2022-10-17 11:09:47 +08:00
<el-form-item label="投票日期" prop="votingDate">
2022-10-17 14:18:32 +08:00
<el-date-picker v-model="form.votingDate" value-format="yyyy-MM-dd HH:mm:ss" type="date" placeholder="选择日期" style="width:338px">
2022-10-13 14:42:24 +08:00
</el-date-picker>
</el-form-item>
</el-col>
</el-row>
2022-10-17 11:09:47 +08:00
<el-form-item label="候选人" prop="candidateUsers">
2022-10-17 17:35:03 +08:00
<ai-person-select :instance="instance" :customClicker="true" :chooseUserList="chooseCandidateList"
2022-10-17 18:03:38 +08:00
:url="`/app/appparty/list?partyOrgId=${form.partyOrgId}`" headerTitle="党员列表"
2022-10-17 11:38:11 +08:00
:isMultiple="true" dialogTitle="选择" @selectPerson="selectCandidate" class="aipersonselect">
2022-10-13 14:42:24 +08:00
<template name="option" v-slot:option="{ item }">
<span class="iconfont iconProlife">{{ item.name }}</span>
<span>{{ item.phone }}</span>
2022-10-17 16:56:42 +08:00
<span>{{ item}}</span>
2022-10-13 14:42:24 +08:00
</template>
</ai-person-select>
</el-form-item>
2022-10-17 11:09:47 +08:00
<el-form-item label="投票人" prop="voteUsers">
2022-10-17 17:35:03 +08:00
<ai-person-select :instance="instance" :customClicker="true" :chooseUserList="chooseVoteList"
2022-10-17 18:03:38 +08:00
:url="`/app/appparty/list?partyOrgId=${form.partyOrgId}`" headerTitle="党员列表"
2022-10-17 11:38:11 +08:00
:isMultiple="true" dialogTitle="选择" @selectPerson="selectVote" class="aipersonselect">
2022-10-13 14:42:24 +08:00
<template name="option" v-slot:option="{ item }">
<span class="iconfont iconProlife">{{ item.name }}</span>
<ai-id mode="show" :show-eyes="false" :value="item.idNumber"/>
</template>
</ai-person-select>
</el-form-item>
</el-form>
</div>
</template>
</ai-card>
</template>
2022-10-21 15:20:09 +08:00
<template #footer>
2022-10-13 14:42:24 +08:00
<el-button class="delete-btn footer-btn" @click="cancel(false)">取消</el-button>
<el-button class="footer-btn" type="primary" @click="confirm()">保存</el-button>
</template>
</ai-detail>
</section>
</template>
<script>
export default {
name: "electionAdd",
props: {
instance: Function,
dict: Object,
2022-10-17 15:59:19 +08:00
params: Object,
2022-10-13 14:42:24 +08:00
},
2022-10-17 15:59:19 +08:00
2022-10-13 14:42:24 +08:00
data() {
2022-10-17 11:38:11 +08:00
let validCandidate = (rule, value, callback) => {
if (!value.length) {
return callback(new Error('请选择候选人'));
} else {
callback();
}
};
let validVote = (rule, value, callback) => {
if (!value.length) {
return callback(new Error('请选择投票人'));
} else {
callback();
2022-10-17 11:09:47 +08:00
}
};
2022-10-13 14:42:24 +08:00
return {
form: {
2022-10-17 11:09:47 +08:00
title: '',
2022-10-17 11:38:11 +08:00
votingInstructions: '',
organizationName: '',
electionMethod: '',
2022-10-17 16:56:42 +08:00
chooseNumber: '',
2022-10-17 11:38:11 +08:00
votingDate: '',
candidateUsers: [],
voteUsers: [],
2022-10-17 18:03:38 +08:00
partyOrganizations: [],
partyOrgId: ''
2022-10-13 14:42:24 +08:00
},
2022-10-17 11:38:11 +08:00
formRules: {
2022-10-17 11:09:47 +08:00
title: [{required: true, message: "请输入标题", trigger: "blur"}],
organizationName: [{required: true, message: "请选择党组织", trigger: "blur"}],
electionMethod: [{required: true, message: "请选择选举方式", trigger: "blur"}],
2022-10-17 16:56:42 +08:00
chooseNumber: [{required: true, message: "请输入应选人数", trigger: "blur"}],
2022-10-17 11:09:47 +08:00
votingDate: [{required: true, message: "请选择投票日期", trigger: "blur"}],
2022-10-17 11:38:11 +08:00
candidateUsers: [{required: true,validator: validCandidate, trigger: "blur"}],
voteUsers: [{required: true,validator: validVote, trigger: "blur"}],
2022-10-17 14:18:32 +08:00
},
id: '',
isEdit: false,
2022-10-17 15:59:19 +08:00
info: {},
candidateUsersList: '',
voteUsersList: '',
2022-10-17 17:35:03 +08:00
chooseCandidateList: [],
chooseVoteList: [],
2022-10-13 14:42:24 +08:00
}
},
2022-10-17 15:59:19 +08:00
created() {
if(this.params && this.params.id) {
this.id = this.params.id
this.getDetail()
}
},
2022-10-13 14:42:24 +08:00
methods: {
cancel (isRefresh) {
this.$emit('change', {
type: 'electionList',
isRefresh: !!isRefresh
})
2022-10-17 11:09:47 +08:00
},
2022-10-21 15:20:09 +08:00
update() {
this.isEdit = true
this.getDetail()
},
2022-10-17 15:59:19 +08:00
getDetail() {
this.instance.post(`/app/appgeneralelectioninfo/queryDetailById`,null, {
params: {id:this.id}
}).then((res) => {
if(res?.data) {
2022-10-17 16:56:42 +08:00
this.form = res.data
this.form.organizationName = res.data.partyOrganizations[0].name
2022-10-17 15:59:19 +08:00
this.info = res.data
this.candidateUsersList = res.data.candidateUsers.map(v=> v.name)
this.voteUsersList = res.data.voteUsers.map(v=> v.name)
2022-10-17 17:35:03 +08:00
this.chooseCandidateList = res.data.candidateUsers
this.chooseVoteList = res.data.voteUsers
2022-10-17 15:59:19 +08:00
}
})
},
2022-10-17 11:38:11 +08:00
selectCandidate(v) {
this.form.candidateUsers = v
},
selectVote(e) {
this.form.voteUsers = e
},
2022-10-17 14:18:32 +08:00
handlePartyOrgSelect(v) {
if(v) {
2022-10-17 17:35:03 +08:00
this.form.organizationName = v[0]?.name
2022-10-17 14:18:32 +08:00
this.form.partyOrganizations = [v[0]]
2022-10-17 18:03:38 +08:00
this.form.partyOrgId = v[0]?.id
2022-10-17 15:59:19 +08:00
} else {
2022-10-17 17:35:03 +08:00
this.form.organizationName = this.chooseUserList[0]?.name
2022-10-17 15:59:19 +08:00
this.form.partyOrganizations = this.chooseUserList
2022-10-17 14:18:32 +08:00
}
},
2022-10-17 11:09:47 +08:00
confirm() {
2022-10-17 11:38:11 +08:00
this.$refs.form.validate((valid) => {
if (valid) {
2022-10-24 14:47:23 +08:00
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('候选人数应多于应选人数')
}
}
2022-10-17 14:18:32 +08:00
this.instance.post(`/app/appgeneralelectioninfo/addOrUpdate`,{
...this.form
}).then(res => {
if(res.code == 0) {
2022-10-17 16:56:42 +08:00
this.$message.success(this.id ? '编辑成功' : '新增成功')
this.cancel(true)
2022-10-17 14:18:32 +08:00
}
}).catch((err) => {
console.log(err);
})
2022-10-17 11:38:11 +08:00
}
})
2022-10-17 11:09:47 +08:00
},
2022-10-13 14:42:24 +08:00
},
}
</script>
<style lang="scss" scope>
.electionAdd {
height: 100%;
::v-deep .el-date-editor .el-input {
width: 100%;
}
}
</style>