From 3aedad63dd01f1fc5154cb520af32edab967d6e0 Mon Sep 17 00:00:00 2001
From: schangxiang@126.com <schangxiang@126.com>
Date: 周一, 12 5月 2025 09:15:26 +0800
Subject: [PATCH] Merge branch 'master' of http://222.71.245.114:9086/r/HIA24016N_PipeLineDemo

---
 PipeLineLems/pipelinelems_web/src/widgets/WorkPlan/Controllers/WorkPlanDrawer.tsx |  623 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 623 insertions(+), 0 deletions(-)

diff --git a/PipeLineLems/pipelinelems_web/src/widgets/WorkPlan/Controllers/WorkPlanDrawer.tsx b/PipeLineLems/pipelinelems_web/src/widgets/WorkPlan/Controllers/WorkPlanDrawer.tsx
new file mode 100644
index 0000000..f3fb82f
--- /dev/null
+++ b/PipeLineLems/pipelinelems_web/src/widgets/WorkPlan/Controllers/WorkPlanDrawer.tsx
@@ -0,0 +1,623 @@
+import { 
+  ref, 
+  onMounted, 
+  reactive, 
+  computed, 
+  Ref, 
+  watch, 
+  SetupContext, 
+  h, 
+} from 'vue' 
+import { injectModel } from '@/libs/Provider/Provider' 
+import { WorkPlanDrawer } from '../Models/WorkPlanDrawer' 
+import { ElMessage } from 'element-plus' 
+import isEqual from 'lodash/isEqual' 
+import { ConfirmBox } from '@/components/ConfirmBox/ConfirmBox' 
+import { cloneDeep } from 'lodash' 
+ 
+export const useWorkPlanDrawer = (props: any, ctx?: any) => { 
+  const workPlanDrawer = injectModel<WorkPlanDrawer>('workPlanDrawer') 
+  /** 
+   * 鐢ㄦ潵瀵规瘮鐨勫垵濮嬪寲鏁版嵁 
+   */ 
+  const initiateData: Ref<Record<string, any>> = ref({}) 
+  const formData = ref<Record<string, any>>({}) 
+  // ref 
+  const formRef = ref() 
+ 
+  const disabled = ref(false) 
+ 
+  const current = computed(() => { 
+    return props.row || null 
+  }) 
+ 
+   
+  const datePicker = (attrs) => { 
+    return ( 
+      <el-date-picker 
+        type="date" 
+        format="YYYY-MM-DD HH:mm:ss" 
+        formatValue="YYYY-MM-DD HH:mm:ss" 
+        {...attrs} 
+      ></el-date-picker> 
+    ) 
+  } 
+  const inputNumber = (attrs) => { 
+    return ( 
+      <el-input-number 
+        min="1" 
+        step="1" 
+        precision="0" 
+        {...attrs} 
+      ></el-input-number> 
+    ) 
+  } 
+ 
+  const dateTimePicker = (attrs) => { 
+    return ( 
+      <el-date-picker 
+        type="datetime" 
+        format="YYYY-MM-DD HH:mm:ss" 
+        formatValue="YYYY-MM-DD HH:mm:ss" 
+        {...attrs} 
+      ></el-date-picker> 
+    ) 
+  } 
+ 
+  const visible = computed({ 
+    get() { 
+      return props.modelValue 
+    }, 
+    set(val) { 
+      ctx.emit('update:modelValue', val) 
+    }, 
+  }) 
+  /** 
+   * 娣诲姞鐨刦orm瀛楁 
+   */ 
+  const formItems = reactive([ 
+                    { 
+                   label: '浠诲姟缂栫爜', 
+                   prop: 'taskCode', 
+                   el: 'input', 
+                   //disabled: disabled, 
+                   placeholder: '璇疯緭鍏ヤ换鍔$紪鐮�', 
+              rules: [{required: true, message: '浠诲姟缂栫爜涓嶈兘涓虹┖', trigger: 'blur' }], 
+                }, 
+                { 
+                   label: '璁″垝鐘舵��', 
+                   prop: 'workPlanStatus', 
+                   el: 'select', 
+                   clearable:true, 
+                   options: [], 
+                   //disabled: disabled, 
+                   placeholder: '璇疯緭鍏ヨ鍒掔姸鎬�', 
+              rules: [{required: true, message: '璁″垝鐘舵�佷笉鑳戒负绌�', trigger: 'blur' }], 
+                }, 
+                { 
+                   label: '鍙枡鐘舵��', 
+                   prop: 'callMaterialStatus', 
+                   el: 'select', 
+                   clearable:true, 
+                   options: [], 
+                   //disabled: disabled, 
+                   placeholder: '璇疯緭鍏ュ彨鏂欑姸鎬�', 
+              rules: [{required: true, message: '鍙枡鐘舵�佷笉鑳戒负绌�', trigger: 'blur' }], 
+                }, 
+                { 
+                   label: '鍘熸枡鏍囪瘑', 
+                   prop: 'dataIdentifier', 
+                   el: 'input', 
+                   //disabled: disabled, 
+                   placeholder: '璇疯緭鍏ュ師鏂欐爣璇�', 
+                }, 
+                { 
+                   label: '鍘熸枡鍨嬪彿', 
+                   prop: 'materialMode', 
+                   el: 'input', 
+                   //disabled: disabled, 
+                   placeholder: '璇疯緭鍏ュ師鏂欏瀷鍙�', 
+                }, 
+                { 
+                   label: '闀垮害(mm)', 
+                   prop: 'length', 
+                   el: (props: any, { attrs }: SetupContext) => { 
+                     return h(inputNumber, {  
+                       ...props,  
+                       clearable: true,  
+                       ...attrs,  
+                     })  
+                   },
+                   width: '100%',
+                   step: 0.01,
+                   precision: 2, 
+                   //disabled: disabled, 
+                   placeholder: '璇疯緭鍏ラ暱搴�(mm)', 
+              rules: [{required: true, message: '闀垮害(mm)涓嶈兘涓虹┖', trigger: 'blur' }], 
+                }, 
+                { 
+                   label: '鎵撶爜鍐呭', 
+                   prop: 'markingContent', 
+                   el: 'input', 
+                   //disabled: disabled, 
+                   placeholder: '璇疯緭鍏ユ墦鐮佸唴瀹�', 
+                }, 
+                { 
+                   label: '鎵撶爜浣嶇疆', 
+                   prop: 'markingPosition', 
+                   el: (props: any, { attrs }: SetupContext) => { 
+                     return h(inputNumber, {  
+                       ...props,  
+                       clearable: true,  
+                       ...attrs,  
+                     })  
+                   },
+                   width: '100%',
+                   step: 0.01,
+                   precision: 2, 
+                   //disabled: disabled, 
+                   placeholder: '璇疯緭鍏ユ墦鐮佷綅缃�', 
+              rules: [{required: true, message: '鎵撶爜浣嶇疆涓嶈兘涓虹┖', trigger: 'blur' }], 
+                }, 
+                { 
+                   label: '鍒囧壊浣嶇疆', 
+                   prop: 'cuttingPosition', 
+                   el: (props: any, { attrs }: SetupContext) => { 
+                     return h(inputNumber, {  
+                       ...props,  
+                       clearable: true,  
+                       ...attrs,  
+                     })  
+                   },
+                   width: '100%',
+                   step: 0.01,
+                   precision: 2, 
+                   //disabled: disabled, 
+                   placeholder: '璇疯緭鍏ュ垏鍓蹭綅缃�', 
+              rules: [{required: true, message: '鍒囧壊浣嶇疆涓嶈兘涓虹┖', trigger: 'blur' }], 
+                }, 
+                { 
+                   label: '绠℃鏁伴噺', 
+                   prop: 'quantity', 
+                   el: (props: any, { attrs }: SetupContext) => { 
+                     return h(inputNumber, {  
+                       ...props,  
+                       clearable: true, 
+                       ...attrs,  
+                     })  
+                   },
+                   width: '100%',
+                   step: 1,
+                   precision: 0, 
+                   //disabled: disabled, 
+                   placeholder: '璇疯緭鍏ョ娈垫暟閲�', 
+              rules: [{required: true, message: '绠℃鏁伴噺涓嶈兘涓虹┖', trigger: 'blur' }], 
+                }, 
+                { 
+                   label: '娉曞叞鍘氬害(mm)', 
+                   prop: 'flangeThickness', 
+                   el: (props: any, { attrs }: SetupContext) => { 
+                     return h(inputNumber, {  
+                       ...props,  
+                       clearable: true,  
+                       ...attrs,  
+                     })  
+                   },
+                   width: '100%',
+                   step: 0.01,
+                   precision: 2, 
+                   //disabled: disabled, 
+                   placeholder: '璇疯緭鍏ユ硶鍏板帤搴�(mm)', 
+              rules: [{required: true, message: '娉曞叞鍘氬害(mm)涓嶈兘涓虹┖', trigger: 'blur' }], 
+                }, 
+                { 
+                   label: '娉曞叞鐩村緞(mm)', 
+                   prop: 'flangeInnerDiameter', 
+                   el: (props: any, { attrs }: SetupContext) => { 
+                     return h(inputNumber, {  
+                       ...props,  
+                       clearable: true,  
+                       ...attrs,  
+                     })  
+                   },
+                   width: '100%',
+                   step: 0.01,
+                   precision: 2, 
+                   //disabled: disabled, 
+                   placeholder: '璇疯緭鍏ユ硶鍏扮洿寰�(mm)', 
+              rules: [{required: true, message: '娉曞叞鐩村緞(mm)涓嶈兘涓虹┖', trigger: 'blur' }], 
+                }, 
+                { 
+                   label: '娉曞叞鍏О鍘嬪姏', 
+                   prop: 'weldingHeatInput', 
+                   el: 'input', 
+                   //disabled: disabled, 
+                   placeholder: '璇疯緭鍏ユ硶鍏板叕绉板帇鍔�', 
+                }, 
+                { 
+                   label: '娉曞叞鍐茬爜鍐呭', 
+                   prop: 'pipeAllowableStress', 
+                   el: 'input', 
+                   //disabled: disabled, 
+                   placeholder: '璇疯緭鍏ユ硶鍏板啿鐮佸唴瀹�', 
+                }, 
+                { 
+                   label: '濂楃闀垮害(mm)', 
+                   prop: 'pipeDiameter', 
+                   el: (props: any, { attrs }: SetupContext) => { 
+                     return h(inputNumber, {  
+                       ...props,  
+                       clearable: true,  
+                       ...attrs,  
+                     })  
+                   },
+                   width: '100%',
+                   step: 0.01,
+                   precision: 2, 
+                   //disabled: disabled, 
+                   placeholder: '璇疯緭鍏ュ绠¢暱搴�(mm)', 
+              rules: [{required: true, message: '濂楃闀垮害(mm)涓嶈兘涓虹┖', trigger: 'blur' }], 
+                }, 
+                { 
+                   label: '濂楃鐩村緞(mm)', 
+                   prop: 'pipeWallThickness', 
+                   el: (props: any, { attrs }: SetupContext) => { 
+                     return h(inputNumber, {  
+                       ...props,  
+                       clearable: true,  
+                       ...attrs,  
+                     })  
+                   },
+                   width: '100%',
+                   step: 0.01,
+                   precision: 2, 
+                   //disabled: disabled, 
+                   placeholder: '璇疯緭鍏ュ绠$洿寰�(mm)', 
+              rules: [{required: true, message: '濂楃鐩村緞(mm)涓嶈兘涓虹┖', trigger: 'blur' }], 
+                }, 
+                { 
+                   label: '宸ュ巶浠g爜', 
+                   prop: 'factoryCode', 
+                   el: 'input', 
+                   //disabled: disabled, 
+                   placeholder: '璇疯緭鍏ュ伐鍘備唬鐮�', 
+                }, 
+                { 
+                   label: '浜у搧浠g爜', 
+                   prop: 'productCode', 
+                   el: 'input', 
+                   //disabled: disabled, 
+                   placeholder: '璇疯緭鍏ヤ骇鍝佷唬鐮�', 
+                }, 
+                { 
+                   label: '宸ヤ綅浠g爜', 
+                   prop: 'workstationCode', 
+                   el: 'input', 
+                   //disabled: disabled, 
+                   placeholder: '璇疯緭鍏ュ伐浣嶄唬鐮�', 
+                }, 
+                { 
+                   label: '璁惧浠g爜', 
+                   prop: 'equipmentCode', 
+                   el: 'input', 
+                   //disabled: disabled, 
+                   placeholder: '璇疯緭鍏ヨ澶囦唬鐮�', 
+                }, 
+                { 
+                   label: '宸ヤ欢鍚嶇О', 
+                   prop: 'workpieceName', 
+                   el: 'input', 
+                   //disabled: disabled, 
+                   placeholder: '璇疯緭鍏ュ伐浠跺悕绉�', 
+                }, 
+                { 
+                   label: '宸ュ簭鍚嶇О', 
+                   prop: 'processName', 
+                   el: 'input', 
+                   //disabled: disabled, 
+                   placeholder: '璇疯緭鍏ュ伐搴忓悕绉�', 
+                }, 
+                { 
+                   label: '绠′欢缂栫爜', 
+                   prop: 'pipeFittingCode', 
+                   el: 'input', 
+                   //disabled: disabled, 
+                   placeholder: '璇疯緭鍏ョ浠剁紪鐮�', 
+                }, 
+                { 
+                   label: '椤哄簭鍙�', 
+                   prop: 'preSerialNumber', 
+                   el: 'input', 
+                   //disabled: disabled, 
+                   placeholder: '璇疯緭鍏ラ『搴忓彿', 
+                }, 
+                { 
+                   label: '绠℃缂栫爜', 
+                   prop: 'pipeSpecCode', 
+                   el: 'input', 
+                   //disabled: disabled, 
+                   placeholder: '璇疯緭鍏ョ娈电紪鐮�', 
+                }, 
+                { 
+                   label: '绠℃鍚嶇О', 
+                   prop: 'pipeSectionName', 
+                   el: 'input', 
+                   //disabled: disabled, 
+                   placeholder: '璇疯緭鍏ョ娈靛悕绉�', 
+                }, 
+                { 
+                   label: '澶栧緞(mm)', 
+                   prop: 'outerDiameter', 
+                   el: (props: any, { attrs }: SetupContext) => { 
+                     return h(inputNumber, {  
+                       ...props,  
+                       clearable: true,  
+                       ...attrs,  
+                     })  
+                   },
+                   width: '100%',
+                   step: 0.01,
+                   precision: 2, 
+                   //disabled: disabled, 
+                   placeholder: '璇疯緭鍏ュ寰�(mm)', 
+              rules: [{required: true, message: '澶栧緞(mm)涓嶈兘涓虹┖', trigger: 'blur' }], 
+                }, 
+                { 
+                   label: '澹佸帤(mm)', 
+                   prop: 'thickness', 
+                   el: (props: any, { attrs }: SetupContext) => { 
+                     return h(inputNumber, {  
+                       ...props,  
+                       clearable: true,  
+                       ...attrs,  
+                     })  
+                   },
+                   width: '100%',
+                   step: 0.01,
+                   precision: 2, 
+                   //disabled: disabled, 
+                   placeholder: '璇疯緭鍏ュ鍘�(mm)', 
+              rules: [{required: true, message: '澹佸帤(mm)涓嶈兘涓虹┖', trigger: 'blur' }], 
+                }, 
+                { 
+                   label: '鏉愯川', 
+                   prop: 'material', 
+                   el: 'input', 
+                   //disabled: disabled, 
+                   placeholder: '璇疯緭鍏ユ潗璐�', 
+                }, 
+                { 
+                   label: '宸ヨ壓娴佸悜缂栧彿', 
+                   prop: 'processRouteNumber', 
+                   el: 'input', 
+                   //disabled: disabled, 
+                   placeholder: '璇疯緭鍏ュ伐鑹烘祦鍚戠紪鍙�', 
+                }, 
+                { 
+                   label: '璁″垝寮�濮嬫椂闂�', 
+                   prop: 'plannedStartTime', 
+                   el: (props: any, { attrs }: SetupContext) => { 
+                     return h(datePicker, {  
+                       ...props,  
+                       clearable: true,  
+                       ...attrs,  
+                     })  
+                   },
+                   width: '100%',
+                   //disabled: disabled, 
+                   placeholder: '璇疯緭鍏ヨ鍒掑紑濮嬫椂闂�', 
+                }, 
+                { 
+                   label: '璁″垝瀹屾垚鏃堕棿', 
+                   prop: 'plannedEndTime', 
+                   el: (props: any, { attrs }: SetupContext) => { 
+                     return h(datePicker, {  
+                       ...props,  
+                       clearable: true,  
+                       ...attrs,  
+                     })  
+                   },
+                   width: '100%',
+                   //disabled: disabled, 
+                   placeholder: '璇疯緭鍏ヨ鍒掑畬鎴愭椂闂�', 
+                }, 
+                { 
+                   label: '鐝粍淇℃伅', 
+                   prop: 'teamInfo', 
+                   el: 'input', 
+                   //disabled: disabled, 
+                   placeholder: '璇疯緭鍏ョ彮缁勪俊鎭�', 
+                }, 
+                { 
+                   label: '鏃堕棿鎴�', 
+                   prop: 'timestamp', 
+                   el: 'input', 
+                   //disabled: disabled, 
+                   placeholder: '璇疯緭鍏ユ椂闂存埑', 
+                }, 
+                { 
+                   label: '澶囨敞', 
+                   prop: 'remark', 
+                   el: 'input', 
+                   //disabled: disabled, 
+                   placeholder: '璇疯緭鍏ュ娉�', 
+                },  
+  ]) 
+  /** 
+   * 鏍¢獙鏄惁鏈夋暟鎹彉鍖� 
+   */ 
+  const checkIsEqualObject = () => { 
+    const data = { 
+      formData: formData.value, 
+    } 
+    const check = isEqual(initiateData.value, data) 
+    return check 
+  } 
+ 
+  const onClose = (done: () => void) => { 
+    if (visible.value) { 
+      if (checkIsEqualObject()) { 
+        visible.value = false 
+        done && done() 
+      } else { 
+        ConfirmBox('鏄惁淇濆瓨璁剧疆锛�') 
+          .then(() => { 
+            onConfirm() 
+          }) 
+          .catch(() => { 
+            visible.value = false 
+            done && done() 
+          }) 
+      } 
+    } 
+  } 
+  /** 
+   * 淇濆瓨 
+   */ 
+  const onConfirm = async () => { 
+    await formRef.value?.validate() 
+    const data = { 
+      taskCode: formData.value.taskCode, 
+workPlanStatus: formData.value.workPlanStatus, 
+callMaterialStatus: formData.value.callMaterialStatus, 
+dataIdentifier: formData.value.dataIdentifier, 
+materialMode: formData.value.materialMode, 
+length: formData.value.length, 
+markingContent: formData.value.markingContent, 
+markingPosition: formData.value.markingPosition, 
+cuttingPosition: formData.value.cuttingPosition, 
+quantity: formData.value.quantity, 
+flangeThickness: formData.value.flangeThickness, 
+flangeInnerDiameter: formData.value.flangeInnerDiameter, 
+weldingHeatInput: formData.value.weldingHeatInput, 
+pipeAllowableStress: formData.value.pipeAllowableStress, 
+pipeDiameter: formData.value.pipeDiameter, 
+pipeWallThickness: formData.value.pipeWallThickness, 
+factoryCode: formData.value.factoryCode, 
+productCode: formData.value.productCode, 
+workstationCode: formData.value.workstationCode, 
+equipmentCode: formData.value.equipmentCode, 
+workpieceName: formData.value.workpieceName, 
+processName: formData.value.processName, 
+pipeFittingCode: formData.value.pipeFittingCode, 
+preSerialNumber: formData.value.preSerialNumber, 
+pipeSpecCode: formData.value.pipeSpecCode, 
+pipeSectionName: formData.value.pipeSectionName, 
+outerDiameter: formData.value.outerDiameter, 
+thickness: formData.value.thickness, 
+material: formData.value.material, 
+processRouteNumber: formData.value.processRouteNumber, 
+plannedStartTime: formData.value.plannedStartTime, 
+plannedEndTime: formData.value.plannedEndTime, 
+teamInfo: formData.value.teamInfo, 
+timestamp: formData.value.timestamp, 
+remark: formData.value.remark,  
+    } 
+    if (!current.value) { 
+      await workPlanDrawer.addWorkPlan(data) 
+    } else { 
+      const id = current.value.id 
+      await workPlanDrawer.updateWorkPlan(id, data) 
+    } 
+    ElMessage.success('淇濆瓨鎴愬姛') 
+    ctx.emit('confirm') 
+  } 
+ 
+  const updateCheckData = () => { 
+    initiateData.value = { 
+      formData: { 
+        ...formData.value, 
+      }, 
+    } 
+  } 
+  const updateFormItemOptions = (propName: string, enumData: any[]) => { 
+    const item = formItems.find((item) => item.prop === propName) 
+    if (item && enumData) { 
+      item.options = enumData.map((item) => ({ 
+        label: item.description, 
+        value: item.value, 
+      })) 
+    } 
+  } 
+  /** 
+   * 閫氱敤鏌ヨ鏋氫妇 
+   */ 
+  const commonQueryEnumForFrom = async () => { 
+    const workPlanStatusEnumEnum = await workPlanDrawer.getWmsEnumData({ 
+ EnumName: 'WorkPlanStatusEnum', 
+}) 
+updateFormItemOptions('workPlanStatus', workPlanStatusEnumEnum) 
+const callMaterialStatusEnumEnum = await workPlanDrawer.getWmsEnumData({ 
+ EnumName: 'CallMaterialStatusEnum', 
+}) 
+updateFormItemOptions('callMaterialStatus', callMaterialStatusEnumEnum) 
+ 
+  } 
+  commonQueryEnumForFrom() 
+  /** 
+   * 寮圭獥鎵撳紑鑾峰彇璇︽儏 
+   */ 
+  const onOpen = async () => { 
+    if (current.value) { 
+      const res = await workPlanDrawer.getWorkPlanDetail(current.value) 
+ 
+      formData.value = { 
+        taskCode: res.taskCode, 
+workPlanStatus: res.workPlanStatus, 
+callMaterialStatus: res.callMaterialStatus, 
+dataIdentifier: res.dataIdentifier, 
+materialMode: res.materialMode, 
+length: res.length, 
+markingContent: res.markingContent, 
+markingPosition: res.markingPosition, 
+cuttingPosition: res.cuttingPosition, 
+quantity: res.quantity, 
+flangeThickness: res.flangeThickness, 
+flangeInnerDiameter: res.flangeInnerDiameter, 
+weldingHeatInput: res.weldingHeatInput, 
+pipeAllowableStress: res.pipeAllowableStress, 
+pipeDiameter: res.pipeDiameter, 
+pipeWallThickness: res.pipeWallThickness, 
+factoryCode: res.factoryCode, 
+productCode: res.productCode, 
+workstationCode: res.workstationCode, 
+equipmentCode: res.equipmentCode, 
+workpieceName: res.workpieceName, 
+processName: res.processName, 
+pipeFittingCode: res.pipeFittingCode, 
+preSerialNumber: res.preSerialNumber, 
+pipeSpecCode: res.pipeSpecCode, 
+pipeSectionName: res.pipeSectionName, 
+outerDiameter: res.outerDiameter, 
+thickness: res.thickness, 
+material: res.material, 
+processRouteNumber: res.processRouteNumber, 
+plannedStartTime: res.plannedStartTime, 
+plannedEndTime: res.plannedEndTime, 
+teamInfo: res.teamInfo, 
+timestamp: res.timestamp, 
+remark: res.remark,  
+        id: res.id, 
+      } 
+      disabled.value = true 
+      updateCheckData() 
+    } else { 
+      formData.value = {} 
+ 
+      disabled.value = false 
+      updateCheckData() 
+    } 
+  } 
+ 
+  watch(() => current.value, onOpen) 
+ 
+  return { 
+    formItems, 
+    formData, 
+    visible, 
+    formRef, 
+    onOpen, 
+    onClose, 
+    onConfirm, 
+  } 
+} 

--
Gitblit v1.9.3