| | |
| | | <template> |
| | | <div class="home-container"> |
| | | <el-dialog v-model="showDialog" title="修改申报" @close="clearFile" width="80%" :close-on-click-modal="false"> |
| | | <el-form :model="form" label-width="180px" :rules="applyRules" ref="ruleFormRef"> |
| | | <!-- <div class="home-container">--> |
| | | <el-dialog v-model="showDialog" :title="title" @close="clearFile" width="80%" :close-on-click-modal="false"> |
| | | <el-form :model="form" label-width="180px" :disabled="isDisabled" :rules="applyRules" ref="ruleFormRef"> |
| | | <div class="homeCard"> |
| | | <el-row> |
| | | <el-col :span="12"> |
| | |
| | | </el-col> |
| | | <el-col :span="12"> |
| | | <el-form-item label="作业人" prop="operatorUids"> |
| | | <el-select v-model="form.operatorUids" multiple clearable> |
| | | <el-option |
| | | v-for="item in zyList" |
| | | :key="item.uid" |
| | | :label="item.realName" |
| | | :value="item.uid" |
| | | /> |
| | | </el-select> |
| | | <!-- <el-cascader style="width: 100%" v-model="form.operatorUids" :options="lists.spList.opList" :props="cas2Props" @change="singleSelect($event,'作业人')" filterable :show-all-levels="false"/>--> |
| | | <!-- <el-select v-model="form.operatorUids" multiple clearable>--> |
| | | <!-- <el-option--> |
| | | <!-- v-for="item in zyList"--> |
| | | <!-- :key="item.uid"--> |
| | | <!-- :label="item.realName"--> |
| | | <!-- :value="item.uid"--> |
| | | <!-- />--> |
| | | <!-- </el-select>--> |
| | | <el-cascader style="width: 100%" v-model="form.operatorUids" :options="zyList?zyList:lists.spList.opList" :props="cas2Props" @change="singleSelect($event,'作业人')" filterable :show-all-levels="false"/> |
| | | </el-form-item> |
| | | </el-col> |
| | | </el-row> |
| | |
| | | </el-form-item> |
| | | </el-col> |
| | | </el-row> |
| | | <!-- <el-row>--> |
| | | <!-- <el-col :span="12">--> |
| | | <!-- <el-form-item label="最终审批人" prop="lastApprover">--> |
| | | <!-- <el-select v-model="form.lastApprover" filterable clearable>--> |
| | | <!-- <el-option--> |
| | | <!-- v-for="item in lists.workerList"--> |
| | | <!-- :key="item.uid"--> |
| | | <!-- :label="item.username"--> |
| | | <!-- :value="item.uid"--> |
| | | <!-- />--> |
| | | <!-- </el-select>--> |
| | | <!-- </el-form-item>--> |
| | | <!-- </el-col>--> |
| | | <!-- </el-row>--> |
| | | </div> |
| | | </el-form> |
| | | <div class="applyBtn"> |
| | | <el-button type="primary" size="large" v-throttle plain @click="submitForm(ruleFormRef)">提交申报</el-button> |
| | | <el-button v-if="title == '修改'" type="primary" size="large" plain v-throttle @click="submitForm(ruleFormRef)">提交修改</el-button> |
| | | <el-button v-if="title == '续票'" type="primary" size="large" plain v-throttle @click="submitForm(ruleFormRef)">一键续票</el-button> |
| | | </div> |
| | | <el-dialog v-model="qpVisible" @open="startAdd"> |
| | | <el-form :model="qpForm" label-width="170px" ref="qpFormRef" :rules="qpFormRules"> |
| | |
| | | <img w-full :src="dialogImageUrl" alt="Preview Image" /> |
| | | </el-dialog> |
| | | </el-dialog> |
| | | </div> |
| | | <!-- </div>--> |
| | | </template> |
| | | |
| | | <script lang="ts"> |
| | |
| | | interface stateType { |
| | | showDialog: boolean |
| | | form: Object, |
| | | isDisabled: boolean |
| | | title: string |
| | | qpForm: Object, |
| | | equipmentDialog: boolean, |
| | | qpVisible: boolean |
| | |
| | | props1:{}, |
| | | depProps:{}, |
| | | casProps:{} |
| | | cas2Props:{} |
| | | safetyMeasureBasicList: [], |
| | | fileList: Array<file>, |
| | | uploadUrl: string, |
| | |
| | | qpVisible: false, |
| | | safetyMeasureBasicList: [], |
| | | zyList: [], |
| | | isDisabled: false, |
| | | title: '修改', |
| | | form: { |
| | | id: null, |
| | | workType: 9, |
| | |
| | | multiple: true, |
| | | checkStrictly: true, |
| | | emitPath: false |
| | | }, |
| | | cas2Props: { |
| | | value: 'uid', |
| | | label: 'realName', |
| | | multiple: true, |
| | | checkStrictly: true, |
| | | children: 'certList' |
| | | }, |
| | | casProps: { |
| | | expandTrigger: 'hover', |
| | |
| | | getBasicData() |
| | | }); |
| | | |
| | | const openDialog = (row)=>{ |
| | | const openDialog = (row,type)=>{ |
| | | state.zyList = props.lists.spList.opList |
| | | getBasicData() |
| | | Object.keys(state.form).forEach(key => { |
| | |
| | | state.form[key] = JSON.parse(JSON.stringify(row))[key] |
| | | } |
| | | }) |
| | | state.form.operatorUids = row.operatorList.map(i=>i.userId) |
| | | state.form.operatorUids = row.operatorList.map(i=>{ |
| | | if(i.certExpiredAt && i.certExpiredAt !==''){ |
| | | return [i.userId,i.certificate + ',' + i.certExpiredAt] |
| | | }else{ |
| | | return [i.userId] |
| | | } |
| | | }) |
| | | state.form.headUids = row.headList.map(i=>i.userId) |
| | | state.form.analystUids = row.analystList.map(i=>i.userId) |
| | | state.form.guardianUids = row.guardianList.map(i=>i.userId) |
| | |
| | | state.form.workDepIds = row.workDepList.map(i=>i.workDepId) |
| | | }else{ |
| | | state.form.workDepIds.push(row.workDepId) |
| | | } |
| | | if(type == 'edit'){ |
| | | state.isDisabled = false |
| | | state.title = '修改' |
| | | }else{ |
| | | if(!state.form.id){ |
| | | state.form.id = row.workApplyId |
| | | } |
| | | state.isDisabled = true |
| | | state.title = '续票' |
| | | } |
| | | getWorkerList() |
| | | state.showDialog = true |
| | |
| | | } |
| | | |
| | | const getWorkerList = ()=>{ |
| | | const filteredList = props.lists.spList.opList.filter(i => state.form.workDepIds.includes(i.depId)); |
| | | let idList:Array<any> = [] |
| | | for(let i of state.form.workDepIds){ |
| | | idList = idList.concat(getListFromDep(getIdListsFormDepId(props.lists.departList,i))) |
| | | } |
| | | const depLists = [...new Set(idList)] |
| | | const filteredList = props.lists.spList.opList.filter(i => depLists.includes(i.depId)); |
| | | if(filteredList && filteredList.length>0){ |
| | | state.zyList = filteredList |
| | | }else{ |
| | | state.zyList = props.lists.spList.opList |
| | | } |
| | | } |
| | | |
| | | const getListFromDep = (dep) =>{ |
| | | let depIds = [] |
| | | depIds.push(dep.depId) |
| | | if (Array.isArray(dep.children)) { |
| | | for (let child of dep.children) { |
| | | depIds = depIds.concat(getListFromDep(child)); |
| | | } |
| | | } |
| | | return depIds; |
| | | } |
| | | |
| | | const getIdListsFormDepId=(DepList:Array<any>,id:number)=>{ |
| | | for(const i of DepList){ |
| | | if(i.depId === id){ |
| | | return i |
| | | } |
| | | if(Array.isArray(i.children)){ |
| | | const node:any = getIdListsFormDepId(i.children,id) |
| | | if(node){ |
| | | return node |
| | | } |
| | | } |
| | | } |
| | | return null |
| | | } |
| | | |
| | | const getSelected = ()=>{ |
| | |
| | | return index === 0; |
| | | } |
| | | |
| | | const singleSelect=(value,type)=>{ |
| | | let selected = value |
| | | if(selected.length>1){ |
| | | const temp = [] |
| | | for(let i of selected){ |
| | | const index = temp.findIndex(item => item[0] === i[0]); |
| | | if (index !== -1) { |
| | | temp[index] = i |
| | | }else{ |
| | | temp.push(i) |
| | | } |
| | | } |
| | | if(type == '作业人'){state.form.operatorUids = JSON.parse(JSON.stringify(temp))} |
| | | // if(type == '分析人'){state.form.analystUids = temp} |
| | | if(type == '监护人'){state.form.guardianUids = temp} |
| | | if(type == '确认人'){state.form.safetyMeasureUids = temp} |
| | | if(type == '结束人'){state.form.startOrEndUids = temp} |
| | | } |
| | | } |
| | | |
| | | const transformArr = (arr: Array<any>)=>{ |
| | | return arr.map((i)=>{ |
| | | return { |
| | | uid: i[0], |
| | | certificate: i[1].split(',')[0], |
| | | certExpiredAt: i[1].split(',')[1], |
| | | certTypeName: i[1].split(',')[2] |
| | | certificate: i[1]?i[1].split(',')[0]:'', |
| | | certExpiredAt: i[1]?i[1].split(',')[1]:'', |
| | | certTypeName: '' |
| | | } |
| | | }) |
| | | } |
| | |
| | | certificate: '', |
| | | certExpiredAt: '', |
| | | certTypeName: '' |
| | | } |
| | | } |
| | | |
| | | const singleSelect=(value,type)=>{ |
| | | let selected = value |
| | | if(selected.length>1){ |
| | | const temp = [] |
| | | for(let i of selected){ |
| | | const index = temp.findIndex(item => item[0] === i[0]); |
| | | if (index !== -1) { |
| | | temp[index] = i |
| | | }else{ |
| | | temp.push(i) |
| | | } |
| | | } |
| | | if(type == '作业人'){state.form.operatorUids = temp} |
| | | if(type == '监护人'){state.form.guardianUids = temp} |
| | | if(type == '确认人'){state.form.safetyMeasureUids = temp} |
| | | if(type == '结束人'){state.form.startOrEndUids = temp} |
| | | } |
| | | } |
| | | |
| | |
| | | state.form.workDetail.sketchMapPath = state.form.workDetail.sketchMapPath.join(',') |
| | | state.form.riskIdentification = state.form.riskIdentification.join(',') |
| | | const {depIdList,...data} = state.form |
| | | data.operatorUids = transform2Arr(data.operatorUids) |
| | | data.operatorUids = transformArr(data.operatorUids) |
| | | data.headUids = transform2Arr(data.headUids) |
| | | data.guardianUids = transform2Arr(data.guardianUids) |
| | | data.safetyMeasureUids = transform2Arr(data.safetyMeasureUids) |
| | | data.startOrEndUids = transform2Arr(data.startOrEndUids) |
| | | data.acceptUids = transform2Arr(data.acceptUids) |
| | | data.lastApprover = transform2Obj(data.lastApprover) |
| | | const res = await workApplyApi().modOpenApply(data) |
| | | if (res.data.code === '200') { |
| | | ElMessage({ |
| | | type: 'success', |
| | | message: '提交成功!' |
| | | }) |
| | | formEl.resetFields() |
| | | state.form.guardianUids = [] |
| | | state.form.involveOtherWork = [] |
| | | getBasicData() |
| | | state.form.workDetail.sketchMapPath = [] |
| | | state.fileList = [] |
| | | state.form.workDetail.qpDetailList = [] |
| | | clearFile() |
| | | context.emit('refresh') |
| | | } else { |
| | | ElMessage({ |
| | | type: 'warning', |
| | | message: res.data.msg |
| | | }); |
| | | // state.form.involveOtherWork = state.form.involveOtherWork.split(',') |
| | | state.form.workDetail.sketchMapPath = state.form.workDetail.sketchMapPath.split(',') |
| | | state.form.riskIdentification = state.form.riskIdentification.split(',') |
| | | if(state.title == '修改'){ |
| | | const res = await workApplyApi().modOpenApply(data) |
| | | if (res.data.code === '200') { |
| | | ElMessage({ |
| | | type: 'success', |
| | | message: '提交成功!' |
| | | }) |
| | | formEl.resetFields() |
| | | state.form.guardianUids = [] |
| | | state.form.involveOtherWork = [] |
| | | getBasicData() |
| | | state.form.workDetail.sketchMapPath = [] |
| | | state.fileList = [] |
| | | state.form.workDetail.qpDetailList = [] |
| | | clearFile() |
| | | context.emit('refresh') |
| | | } else { |
| | | ElMessage({ |
| | | type: 'warning', |
| | | message: res.data.msg |
| | | }); |
| | | // state.form.involveOtherWork = state.form.involveOtherWork.split(',') |
| | | state.form.workDetail.sketchMapPath = state.form.workDetail.sketchMapPath.split(',') |
| | | state.form.riskIdentification = state.form.riskIdentification.split(',') |
| | | } |
| | | }else{ |
| | | const res = await workApplyApi().renewalOpenJob(data) |
| | | if (res.data.code === '200') { |
| | | ElMessage({ |
| | | type: 'success', |
| | | message: '续票成功!' |
| | | }) |
| | | formEl.resetFields() |
| | | state.form.guardianUids = [] |
| | | state.form.involveOtherWork = [] |
| | | getBasicData() |
| | | state.form.workDetail.sketchMapPath = [] |
| | | state.fileList = [] |
| | | state.form.workDetail.qpDetailList = [] |
| | | clearFile() |
| | | context.emit('refresh') |
| | | } else { |
| | | ElMessage({ |
| | | type: 'warning', |
| | | message: res.data.msg |
| | | }); |
| | | // state.form.involveOtherWork = state.form.involveOtherWork.split(',') |
| | | state.form.workDetail.sketchMapPath = state.form.workDetail.sketchMapPath.split(',') |
| | | state.form.riskIdentification = state.form.riskIdentification.split(',') |
| | | } |
| | | } |
| | | } else { |
| | | ElMessage({ |