251 lines
		
	
	
		
			9.8 KiB
		
	
	
	
		
			Vue
		
	
	
	
	
	
			
		
		
	
	
			251 lines
		
	
	
		
			9.8 KiB
		
	
	
	
		
			Vue
		
	
	
	
	
	
| <template>
 | |
|   <section class="electionAdd">
 | |
|     <ai-detail class="add" v-if="id && !isEdit">
 | |
|       <template slot="title">
 | |
|         <ai-title title="换届选举详情" isShowBack isShowBottomBorder @onBackClick="cancel(false)"></ai-title>
 | |
|       </template>
 | |
|       <template slot="content">
 | |
|         <ai-card title="基本信息">
 | |
|           <template #right>
 | |
|             <span style="color:#2266FF;cursor: pointer;font-size: 12px;" class="iconfont iconEdit" v-if="isEdit==false" @click="isEdit = true">修改</span>
 | |
|           </template>
 | |
|           <template #content v-if="isEdit == false">
 | |
|             <ai-wrapper>
 | |
|               <ai-info-item label="标题" :value="info.title"></ai-info-item>
 | |
|               <ai-info-item label="投票说明" :value="info.votingInstructions"></ai-info-item>
 | |
|               <ai-info-item label="单位名称" :value="info.organizationName"></ai-info-item>
 | |
|               <ai-info-item label="选举方式">
 | |
|                 {{ info.electionMethod==0? '等额':'差额'}}
 | |
|               </ai-info-item>
 | |
|               <ai-info-item label="应选人数" :value="info.candidatesNumber"></ai-info-item>
 | |
|               <ai-info-item label="投票日期" :value="info.votingDate"></ai-info-item>
 | |
|               <ai-info-item label="候选人" isLine>
 | |
|                 <span v-for="(item,index) in candidateUsersList" :key="index">
 | |
|                   {{ item }}
 | |
|                   <span v-if="index < candidateUsersList.length - 1">、</span>
 | |
|                 </span>
 | |
|               </ai-info-item>
 | |
|               <ai-info-item label="投票人" isLine :value="info.voteUsers">
 | |
|                 <span v-for="(item,index) in voteUsersList" :key="index">
 | |
|                   {{ item }}
 | |
|                   <span v-if="index < voteUsersList.length - 1">、</span>
 | |
|                 </span>
 | |
|               </ai-info-item>
 | |
|             </ai-wrapper>
 | |
|           </template>
 | |
|         </ai-card>
 | |
|       </template>
 | |
|     </ai-detail>
 | |
|     <ai-detail v-if="!id || isEdit">
 | |
|       <ai-title slot="title" :title="id? '编辑换届选举':'添加换届选举'" isShowBottomBorder isShowBack @onBackClick="cancel(true)"/>
 | |
|       <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">
 | |
| 
 | |
|                 <el-form-item label="标题" prop="title">
 | |
|                   <el-input v-model="form.title" placeholder="请输入" show-word-limit maxlength="100"></el-input>
 | |
|                 </el-form-item>
 | |
| 
 | |
|                 <el-form-item label="投票说明">
 | |
|                   <el-input type="textarea" :rows="5" v-model="form.votingInstructions" placeholder="请输入" show-word-limit maxlength="500"></el-input>
 | |
|                 </el-form-item>
 | |
| 
 | |
|                 <el-form-item label="单位名称" prop="organizationName">
 | |
|                   <el-input size="small" disabled placeholder="请选择所属党组织" v-model="form.organizationName">
 | |
|                     <template slot="append">
 | |
|                       <ai-party :instance="instance" size="small" :value="form.partyOrgId" @origin="handlePartyOrgSelect"/>
 | |
|                     </template>
 | |
|                   </el-input>
 | |
|                 </el-form-item>
 | |
| 
 | |
|                 <el-form-item label="选举方式" prop="electionMethod">
 | |
|                   <el-tooltip class="item" effect="dark" content="差额选举:候选人数多于应选人数的选举方式;
 | |
|                    等额选举:候选人数与应选人数相等的选举方式。" placement="top">
 | |
|                     <i class="el-icon-info" style="margin-right: 8px"></i>
 | |
|                   </el-tooltip>
 | |
|                   
 | |
|                   <el-radio v-model="form.electionMethod" label="0">等额</el-radio>
 | |
|                   <el-radio v-model="form.electionMethod" label="1">差额</el-radio>
 | |
|                 </el-form-item>
 | |
|                 
 | |
|                 <el-row type="flex">
 | |
|                   <el-col :span="20">
 | |
|                     <el-form-item label="应选人数" prop="chooseNumber">
 | |
|                       <el-input type="number" v-model="form.chooseNumber" placeholder="请输入"></el-input>
 | |
|                     </el-form-item>
 | |
|                   </el-col>
 | |
|                   <el-col :span="20">
 | |
|                     <el-form-item label="投票日期" prop="votingDate">
 | |
|                       <el-date-picker v-model="form.votingDate" value-format="yyyy-MM-dd HH:mm:ss" type="date" placeholder="选择日期" style="width:338px">
 | |
|                       </el-date-picker>
 | |
|                     </el-form-item>
 | |
|                   </el-col>
 | |
|                 </el-row>
 | |
| 
 | |
|                 <el-form-item label="候选人" prop="candidateUsers">
 | |
|                   <ai-person-select :instance="instance" :customClicker="true" :chooseUserList="chooseCandidateList"
 | |
|                       url="/app/appgirdmemberinfo/list" headerTitle="党员列表"
 | |
|                       :isMultiple="true" dialogTitle="选择" @selectPerson="selectCandidate" class="aipersonselect">
 | |
|                     <template name="option" v-slot:option="{ item }">
 | |
|                       <span class="iconfont iconProlife">{{ item.name }}</span>
 | |
|                       <span>{{ item.phone }}</span>
 | |
|                       <span>{{ item}}</span>
 | |
|                     </template>
 | |
|                   </ai-person-select>
 | |
|                 </el-form-item>
 | |
| 
 | |
|                 <el-form-item label="投票人" prop="voteUsers">
 | |
|                   <ai-person-select :instance="instance" :customClicker="true" :chooseUserList="chooseVoteList"
 | |
|                       url="/app/appgirdmemberinfo/list" headerTitle="党员列表"
 | |
|                       :isMultiple="true" dialogTitle="选择" @selectPerson="selectVote" class="aipersonselect">
 | |
|                     <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>
 | |
|       <template slot="footer" class="footer">
 | |
|         <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,
 | |
|     params: Object,
 | |
|   },
 | |
| 
 | |
|   data() {
 | |
|     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();
 | |
|       }
 | |
|     };
 | |
|     return {
 | |
|       form: {
 | |
|         title: '',
 | |
|         votingInstructions: '',
 | |
|         organizationName: '',
 | |
|         electionMethod: '',
 | |
|         chooseNumber: '',
 | |
|         votingDate: '',
 | |
|         candidateUsers: [],
 | |
|         voteUsers: [],
 | |
|         partyOrganizations: []
 | |
|       },
 | |
|       formRules: {
 | |
|         title: [{required: true, message: "请输入标题", trigger: "blur"}],
 | |
|         organizationName: [{required: true, message: "请选择党组织", trigger: "blur"}],
 | |
|         electionMethod: [{required: true, message: "请选择选举方式", trigger: "blur"}],
 | |
|         chooseNumber: [{required: true, message: "请输入应选人数", trigger: "blur"}],
 | |
|         votingDate: [{required: true, message: "请选择投票日期", trigger: "blur"}],
 | |
|         candidateUsers: [{required: true,validator: validCandidate, trigger: "blur"}],
 | |
|         voteUsers: [{required: true,validator: validVote, trigger: "blur"}],
 | |
|       },
 | |
|       id: '',
 | |
|       isEdit: false,
 | |
|       info: {},
 | |
|       candidateUsersList: '',
 | |
|       voteUsersList: '',
 | |
|       chooseCandidateList: [],
 | |
|       chooseVoteList: [],
 | |
|     }
 | |
|   },
 | |
|   computed: {
 | |
|   },
 | |
|   created() {
 | |
|     if(this.params && this.params.id) {
 | |
|       this.id = this.params.id
 | |
|       this.isEdit = this.params.isEdit
 | |
|       this.getDetail()
 | |
|     }
 | |
|   },
 | |
|   methods: {
 | |
|     cancel (isRefresh) {
 | |
|       this.$emit('change', {
 | |
|         type: 'electionList',
 | |
|         isRefresh: !!isRefresh
 | |
|       })
 | |
|     },
 | |
|     getDetail() {
 | |
|       this.instance.post(`/app/appgeneralelectioninfo/queryDetailById`,null, {
 | |
|         params: {id:this.id}
 | |
|       }).then((res) => {
 | |
|         if(res?.data) {
 | |
|           this.form = res.data
 | |
|           this.form.organizationName = res.data.partyOrganizations[0].name
 | |
|           this.info = res.data
 | |
|           this.candidateUsersList = res.data.candidateUsers.map(v=> v.name)
 | |
|           this.voteUsersList = res.data.voteUsers.map(v=> v.name)
 | |
|           this.chooseCandidateList = res.data.candidateUsers
 | |
|           this.chooseVoteList = res.data.voteUsers
 | |
|         }
 | |
|       })
 | |
|     },
 | |
|     selectCandidate(v) {
 | |
|       this.form.candidateUsers = v
 | |
|     },
 | |
|     selectVote(e) {
 | |
|       this.form.voteUsers = e
 | |
|     },
 | |
|     handlePartyOrgSelect(v) {
 | |
|       if(v) {
 | |
|         this.form.organizationName = v[0]?.name
 | |
|         this.form.partyOrganizations = [v[0]]
 | |
|       } else {
 | |
|         this.form.organizationName = this.chooseUserList[0]?.name
 | |
|         this.form.partyOrganizations = this.chooseUserList
 | |
|       }
 | |
|     },
 | |
|     confirm() {
 | |
|       this.$refs.form.validate((valid) => {
 | |
|           if (valid) {
 | |
|             this.instance.post(`/app/appgeneralelectioninfo/addOrUpdate`,{
 | |
|               ...this.form
 | |
|             }).then(res => {
 | |
|               if(res.code == 0) {
 | |
|                 this.$message.success(this.id ? '编辑成功' : '新增成功')
 | |
|                 this.cancel(true)
 | |
|               }
 | |
|             }).catch((err) => {
 | |
|               console.log(err);
 | |
|             })
 | |
|           }
 | |
|       })
 | |
|     },
 | |
|   },
 | |
| }
 | |
| </script>
 | |
| 
 | |
| <style lang="scss" scope>
 | |
| .electionAdd {
 | |
|   height: 100%;
 | |
| 
 | |
|   ::v-deep .el-date-editor .el-input {
 | |
|     width: 100%;
 | |
|   }
 | |
| }
 | |
| </style> |