From 77737f4e73f7267170b9b06fc73d1610c29c0661 Mon Sep 17 00:00:00 2001 From: 马宇豪 <978517621@qq.com> Date: 星期二, 12 十一月 2024 13:18:35 +0800 Subject: [PATCH] 新增 --- src/views/newSpecialWorkSystem/workTicket/wdsq/components/spaceDialog.vue | 191 ++++++++++++++++++++++++++++++++++++++--------- 1 files changed, 153 insertions(+), 38 deletions(-) diff --git a/src/views/newSpecialWorkSystem/workTicket/wdsq/components/spaceDialog.vue b/src/views/newSpecialWorkSystem/workTicket/wdsq/components/spaceDialog.vue index d5e9798..c810af8 100644 --- a/src/views/newSpecialWorkSystem/workTicket/wdsq/components/spaceDialog.vue +++ b/src/views/newSpecialWorkSystem/workTicket/wdsq/components/spaceDialog.vue @@ -1,7 +1,7 @@ <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"> @@ -77,15 +77,15 @@ </el-col> <el-col :span="12"> <el-form-item label="作业人" prop="operatorUids"> - <el-select v-model="form.operatorUids" filterable 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" filterable 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> @@ -294,11 +294,12 @@ </div> </el-form> <div class="applyBtn"> - <el-button type="primary" size="large" plain @click="submitForm(ruleFormRef)" v-throttle>提交申报</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> <work-select ref="workSelectRef" @refreshWorks="getSelected()"></work-select> </el-dialog> - </div> +<!-- </div>--> </template> <script lang="ts"> @@ -315,10 +316,13 @@ import {userApi} from "/@/api/systemManage/user"; interface stateType { form: Object, + isDisabled: boolean + title: string equipmentDialog: boolean, showDialog: boolean props1:{}, depProps:{}, + cas2Props: {} safetyMeasureBasicList: [] zyList: [] tabLoading: boolean @@ -336,6 +340,8 @@ equipmentDialog: false, safetyMeasureBasicList: [], zyList: [], + isDisabled: false, + title: '修改', form: { id: null, workType: 2, @@ -378,7 +384,14 @@ multiple: true, checkStrictly: true, emitPath: false - } + }, + cas2Props: { + value: 'uid', + label: 'realName', + multiple: true, + checkStrictly: true, + children: 'certList' + }, }); const ruleFormRef = ref<FormInstance>() const applyRules = reactive<FormRules>({ @@ -412,18 +425,49 @@ workSelectRef.value.openDialog(state.form.involveOtherWork) } 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 = ()=>{ state.form.involveOtherWork = workSelectRef.value.selected } - const openDialog = (row)=>{ + const openDialog = (row,type)=>{ clearFile() state.zyList = props.lists.spList.opList getBasicData() @@ -432,7 +476,13 @@ 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) @@ -453,6 +503,16 @@ 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 @@ -554,6 +614,37 @@ 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]?i[1].split(',')[0]:'', + certExpiredAt: i[1]?i[1].split(',')[1]:'', + certTypeName: '' + } + }) + } + const transform2Arr = (arr: Array<any>)=>{ return arr.map((i)=>{ return { @@ -592,7 +683,7 @@ // } state.form.riskIdentification = state.form.riskIdentification.join(',') const {...data} = state.form - data.operatorUids = transform2Arr(data.operatorUids) + data.operatorUids = transformArr(data.operatorUids) data.headUids = transform2Arr(data.headUids) // data.analystUids = transformArr(data.analystUids) data.guardianUids = transform2Arr(data.guardianUids) @@ -600,25 +691,48 @@ data.startOrEndUids = transform2Arr(data.startOrEndUids) data.acceptUids = transform2Arr(data.acceptUids) data.lastApprover = transform2Obj(data.lastApprover) - const res = await workApplyApi().modSpaceApply(data) - if (res.data.code === '200') { - ElMessage({ - type: 'success', - message: '提交成功!' - }); - formEl.resetFields() - state.form.guardianUids = [] - state.form.involveOtherWork = [] - getBasicData() - clearFile() - context.emit('refresh') - } else { - ElMessage({ - type: 'warning', - message: res.data.msg - }); - // state.form.involveOtherWork = state.form.involveOtherWork.split(',') - state.form.riskIdentification = state.form.riskIdentification.split(',') + if(state.title == '修改'){ + const res = await workApplyApi().modSpaceApply(data) + if (res.data.code === '200') { + ElMessage({ + type: 'success', + message: '提交成功!' + }); + formEl.resetFields() + state.form.guardianUids = [] + state.form.involveOtherWork = [] + getBasicData() + clearFile() + context.emit('refresh') + } else { + ElMessage({ + type: 'warning', + message: res.data.msg + }); + // state.form.involveOtherWork = state.form.involveOtherWork.split(',') + state.form.riskIdentification = state.form.riskIdentification.split(',') + } + }else{ + const res = await workApplyApi().renewalConfinedspace(data) + if (res.data.code === '200') { + ElMessage({ + type: 'success', + message: '续票成功!' + }); + formEl.resetFields() + state.form.guardianUids = [] + state.form.involveOtherWork = [] + getBasicData() + clearFile() + context.emit('refresh') + } else { + ElMessage({ + type: 'warning', + message: res.data.msg + }); + // state.form.involveOtherWork = state.form.involveOtherWork.split(',') + state.form.riskIdentification = state.form.riskIdentification.split(',') + } } } else { console.log('error submit!', fields) @@ -637,6 +751,7 @@ await initBackEndControlRoutes(); }; return { + singleSelect, renderMenu, getBasicData, getWorkerList, -- Gitblit v1.9.2