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/plateDialog.vue |  195 +++++++++++++++++++++++++++++++++++++-----------
 1 files changed, 150 insertions(+), 45 deletions(-)

diff --git a/src/views/newSpecialWorkSystem/workTicket/wdsq/components/plateDialog.vue b/src/views/newSpecialWorkSystem/workTicket/wdsq/components/plateDialog.vue
index 16ee8a3..653ebfc 100644
--- a/src/views/newSpecialWorkSystem/workTicket/wdsq/components/plateDialog.vue
+++ b/src/views/newSpecialWorkSystem/workTicket/wdsq/components/plateDialog.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">
@@ -181,15 +181,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>
@@ -383,11 +383,12 @@
 			</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>
     <work-select ref="workSelectRef" @refreshWorks="getSelected()"></work-select>
     </el-dialog>
-	</div>
+<!--	</div>-->
 </template>
 
 <script lang="ts">
@@ -406,11 +407,14 @@
   import {userApi} from "/@/api/systemManage/user";
 	interface stateType {
 		form: Object,
+    isDisabled: boolean
+    title: string
 		workLevelList: Array<any>,
 		equipmentDialog: boolean,
     showDialog: boolean,
     props1:{},
     depProps:{},
+    cas2Props:{}
     safetyMeasureBasicList: [],
     zyList: []
     fileList: Array<file>,
@@ -434,6 +438,8 @@
 				equipmentDialog: false,
         safetyMeasureBasicList: [],
         zyList: [],
+        isDisabled: false,
+        title: '修改',
 				form: {
           id: null,
           workType: 8,
@@ -495,6 +501,13 @@
           checkStrictly: true,
           emitPath: false
         },
+        cas2Props: {
+          value: 'uid',
+          label: 'realName',
+          multiple: true,
+          checkStrictly: true,
+          children: 'certList'
+        },
         fileList: [],
         imgLimit: 3,
         uploadUrl: '',
@@ -538,18 +551,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()
@@ -558,7 +602,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)
@@ -574,7 +624,6 @@
         }))
         state.form.acceptUids = row.acceptUserList.map(i=>i.userId)
         state.form.startOrEndUids = row.startOrEndList.map(i=>i.userId)
-        // state.form.lastApprover = row.lastApprover.userId
         state.fileList = row.workDetail.bpLocationMapPath.split(',').map(item => {
           return {
             url:  item,
@@ -582,11 +631,20 @@
           }
         })
         state.form.workDetail.bpLocationMapPath = row.workDetail.bpLocationMapPath.split(',').map(item => item.match(/specialWork9step\/(.*?)\?/)[1])
-        console.log(state.fileList,state.form.workDetail.bpLocationMapPath,'854')
         if(row.workDepList && row.workDepList.length>0){
           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
@@ -701,13 +759,33 @@
         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: ''
           }
         })
       }
@@ -751,35 +829,61 @@
             state.form.workDetail.bpLocationMapPath = state.form.workDetail.bpLocationMapPath.join(',')
             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.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().modPlateApply(data)
-            if (res.data.code === '200') {
-              ElMessage({
-                type: 'success',
-                message: '提交成功!'
-              });
-              formEl.resetFields()
-              state.form.guardianUids = []
-              state.form.involveOtherWork = []
-              getBasicData()
-              state.form.workDetail.bpLocationMapPath = []
-              state.fileList = []
-              clearFile()
-              context.emit('refresh')
-            } else {
-              ElMessage({
-                type: 'warning',
-                message: res.data.msg
-              });
-              // state.form.involveOtherWork = state.form.involveOtherWork.split(',')
-              state.form.workDetail.bpLocationMapPath = state.form.workDetail.bpLocationMapPath.split(',')
-              state.form.riskIdentification = state.form.riskIdentification.split(',')
+            if(state.title == '修改'){
+              const res = await workApplyApi().modPlateApply(data)
+              if (res.data.code === '200') {
+                ElMessage({
+                  type: 'success',
+                  message: '提交成功!'
+                });
+                formEl.resetFields()
+                state.form.guardianUids = []
+                state.form.involveOtherWork = []
+                getBasicData()
+                state.form.workDetail.bpLocationMapPath = []
+                state.fileList = []
+                clearFile()
+                context.emit('refresh')
+              } else {
+                ElMessage({
+                  type: 'warning',
+                  message: res.data.msg
+                });
+                // state.form.involveOtherWork = state.form.involveOtherWork.split(',')
+                state.form.workDetail.bpLocationMapPath = state.form.workDetail.bpLocationMapPath.split(',')
+                state.form.riskIdentification = state.form.riskIdentification.split(',')
+              }
+            }else{
+              const res = await workApplyApi().renewalBlindPlatePlugging(data)
+              if (res.data.code === '200') {
+                ElMessage({
+                  type: 'success',
+                  message: '续票成功!'
+                });
+                formEl.resetFields()
+                state.form.guardianUids = []
+                state.form.involveOtherWork = []
+                getBasicData()
+                state.form.workDetail.bpLocationMapPath = []
+                state.fileList = []
+                clearFile()
+                context.emit('refresh')
+              } else {
+                ElMessage({
+                  type: 'warning',
+                  message: res.data.msg
+                });
+                // state.form.involveOtherWork = state.form.involveOtherWork.split(',')
+                state.form.workDetail.bpLocationMapPath = state.form.workDetail.bpLocationMapPath.split(',')
+                state.form.riskIdentification = state.form.riskIdentification.split(',')
+              }
             }
           } else {
             console.log('error submit!', fields)
@@ -884,6 +988,7 @@
 				await initBackEndControlRoutes();
 			};
 			return {
+        singleSelect,
 				renderMenu,
         getBasicData,
         getWorkerList,

--
Gitblit v1.9.2