| ¶Ô±ÈÐÂÎļþ |
| | |
| | | <template> |
| | | <GlobalWindow |
| | | :title="title" |
| | | width="100%" |
| | | :visible.sync="visible" |
| | | :confirm-working="isWorking" |
| | | @confirm="confirm" |
| | | > |
| | | <el-form :inline="true" class="demo-form-inline"> |
| | | <div v-for="(item, index) in list" :key="index"> |
| | | <el-form-item label="å§å" required> |
| | | <el-input v-model="item.memberName" placeholder="请è¾å
¥"></el-input> |
| | | </el-form-item> |
| | | <el-form-item label="身份è¯å·" required> |
| | | <el-input v-model="item.idCard" maxlength="18" placeholder="请è¾å
¥"></el-input> |
| | | </el-form-item> |
| | | <el-form-item label="æ´¾é£åä½" > |
| | | <el-select v-model="item.duId" @change="selectChange(index)" placeholder="è¯·éæ©" clearable> |
| | | <el-option |
| | | v-for="item in dispatching" |
| | | :key="item.id" |
| | | :label="item.name" |
| | | :value="item.id"> |
| | | </el-option> |
| | | </el-select> |
| | | </el-form-item> |
| | | <el-form-item label="æå±å·¥ç§" > |
| | | <el-select v-model="item.worktypeId" @change="selectChangeWT(index)" placeholder="è¯·éæ©" clearable> |
| | | <el-option |
| | | v-for="item1 in item.options" |
| | | :key="item1.id" |
| | | :label="item1.name" |
| | | :value="item1.id"> |
| | | </el-option> |
| | | </el-select> |
| | | </el-form-item> |
| | | <el-form-item> |
| | | <el-button type="primary" v-if="index === 0" @click="add">æ·»å </el-button> |
| | | <el-button type="danger" v-else @click="dele(index)">å é¤</el-button> |
| | | </el-form-item> |
| | | </div> |
| | | </el-form> |
| | | </GlobalWindow> |
| | | </template> |
| | | |
| | | <script> |
| | | import BaseOpera from '@/components/base/BaseOpera' |
| | | import GlobalWindow from '@/components/common/GlobalWindow' |
| | | import { findListByDTO } from '@/api/business/dispatchUnit' |
| | | import { findListByDTO as worktype } from '@/api/business/worktype' |
| | | export default { |
| | | name: 'addEmployee', |
| | | extends: BaseOpera, |
| | | components: { GlobalWindow }, |
| | | data () { |
| | | return { |
| | | tempIndex: -1, |
| | | dispatching: [], |
| | | solutionId: null, |
| | | list: [ |
| | | { |
| | | memberName: '', |
| | | idCard: '', |
| | | workTypeName: '', |
| | | worktypeId: '', |
| | | duName: '', |
| | | options: [], |
| | | duId: '', |
| | | fee: '' |
| | | } |
| | | ], |
| | | price: 0, |
| | | arr: [] |
| | | } |
| | | }, |
| | | methods: { |
| | | open (title, obj, tempIndex) { |
| | | this.title = title |
| | | this.visible = true |
| | | this.tempIndex = tempIndex |
| | | this.solutionId = obj.solutionId |
| | | this.dispatching = [] |
| | | this.list = [ |
| | | { |
| | | memberName: '', |
| | | idCard: '', |
| | | workTypeName: '', |
| | | worktypeId: '', |
| | | duName: '', |
| | | options: [], |
| | | duId: '', |
| | | fee: '' |
| | | } |
| | | ] |
| | | this.arr = obj.arr |
| | | this.price = obj.price |
| | | this.getFindListByDTO() |
| | | }, |
| | | getFindListByDTO () { |
| | | findListByDTO({ |
| | | solutionId: this.solutionId |
| | | // dataType: 0 |
| | | }).then(res => { |
| | | this.dispatching = res |
| | | }) |
| | | }, |
| | | selectChange (index) { |
| | | this.list[index].options = [] |
| | | let duSolutionId = '' |
| | | this.list[index].duName = null |
| | | this.dispatching.forEach(item => { |
| | | if (item.id === this.list[index].duId) { |
| | | duSolutionId = item.duSolutionId |
| | | this.list[index].duName = item.name |
| | | } |
| | | }) |
| | | worktype({ id: duSolutionId, queryType: 1 }) |
| | | .then(res => { |
| | | this.list[index].options = res |
| | | }) |
| | | }, |
| | | selectChangeWT (index) { |
| | | this.list[index].workTypeName = null |
| | | this.list[index].options.forEach(item => { |
| | | if (item.id === this.list[index].worktypeId) { |
| | | this.list[index].workTypeName = item.name |
| | | } |
| | | }) |
| | | }, |
| | | add () { |
| | | this.list.push({ |
| | | memberName: '', |
| | | idCard: '', |
| | | workTypeName: '', |
| | | worktypeId: '', |
| | | duName: '', |
| | | duId: '', |
| | | options: [], |
| | | fee: '', |
| | | id: this.tempIndex - 1 |
| | | }) |
| | | }, |
| | | dele (index) { |
| | | this.list.splice(index, 1) |
| | | }, |
| | | hasDuplicates (arr) { |
| | | return arr.some((value, index) => arr.indexOf(value) !== index) |
| | | }, |
| | | confirm () { |
| | | // 夿åè¡¨å¦æ¯æç©ºå¼ |
| | | // for (let i = 0; this.list.length; i++) { |
| | | // if (!this.list[i].memberName || !this.list[i].idCard) { |
| | | // this.$message.warning('请å
å®åä¿¡æ¯ååæäº¤') |
| | | // return |
| | | // } |
| | | // } |
| | | // 夿æ°å½å
¥æ°æ®èº«ä»½è¯æ¯å¦æéå¤ |
| | | const idcardList = this.list.map(item => item.idCard) |
| | | if (this.hasDuplicates(idcardList)) { |
| | | this.$message.warning('èº«ä»½è¯æéå¤') |
| | | return |
| | | } |
| | | // å¤æèº«ä»½è¯æ¯å¦ææ |
| | | for (let i = 0; i < this.list.length; i++) { |
| | | const regExp = /^[1-9]\d{5}(18|19|([23]\d))\d{2}((0[1-9])|(10|11|12))(([0-2][1-9])|10|20|30|31)\d{3}[0-9Xx]$/ |
| | | if (!regExp.test(this.list[i].idCard)) { |
| | | this.$message.warning(`第${i + 1}项å工身份è¯ä¸åæ³`) |
| | | return |
| | | } |
| | | const s=parseInt(this.list[i].idCard.substring(16,17)) |
| | | // const s = parseInt(this.list[i].idCard.slice(16, 1)) |
| | | if (s % 2 === 0) { |
| | | this.list[i].sex = 1 |
| | | } else { |
| | | this.list[i].sex = 0 |
| | | } |
| | | } |
| | | // å¤æè¯¦æ
åè¡¨æ°æ®èº«ä»½è¯æ¯å¦æéå¤ |
| | | let next = true |
| | | this.list.forEach(item => { |
| | | this.arr.forEach(child => { |
| | | if (item.idCard === child.idCard) { |
| | | next = false |
| | | } |
| | | }) |
| | | }) |
| | | if (next) { |
| | | this.list.forEach(item => { |
| | | item.fee = this.price |
| | | }) |
| | | console.log(this.list) |
| | | this.$emit('result', this.list) |
| | | this.visible = false |
| | | } else { |
| | | this.$message.warning('身份è¯å·ä¸è½éå¤ï¼') |
| | | } |
| | | } |
| | | } |
| | | } |
| | | </script> |
| | | |
| | | <style lang="scss" scoped> |
| | | |
| | | </style> |