sunqijun 3 kuukautta sitten
vanhempi
commit
018f4c43e5

+ 14 - 1
src/api/production-safety/responsibility-implementation/index.ts

@@ -762,4 +762,17 @@ export function safetyResponsibilityAdminQueryUserByGroup(params) {
     method: 'post',
     params
   });
-}
+}
+
+/**
+ * 部门签署安全责任书   
+ * @param params - 签署参数,包含签署人 ID、签署时间、签署内容等
+ * @returns Promise<void>
+ */
+export function safetyResponsibilityDeptSaveSign(params) {
+  return http.request({
+    url: `/safetyResponsibility/dept/saveSign`,     
+    method: 'post',
+    params
+  });
+}

+ 1 - 1
src/views/production-safety/implement-safety-duty/components/IssueSafetyResponsibility.vue

@@ -34,7 +34,7 @@
         </el-select>
       </el-form-item>
 
-      <el-form-item label="多人签署设置" prop="signConfig" v-if="currentDepartmentKey !== 'C'">
+      <el-form-item label="多人签署设置" prop="signConfig" v-if="currentDepartmentKey !== 'D'">
         <el-radio-group v-model="formData.signConfig">
           <el-radio :value="0">否</el-radio>
           <el-radio :value="1">是</el-radio>

+ 97 - 54
src/views/production-safety/implement-safety-duty/sign-agree-dept.vue

@@ -33,10 +33,10 @@
               <div class="label">签署人数:</div>
               <div class="value">{{ formData.signedQuantity }}</div>
             </div>
-            <div class="col">
+            <!-- <div class="col">
               <div class="label">下发对象:</div>
               <div class="value">{{ formData.userGroupName }}</div>
-            </div>
+            </div> -->
           </div>
           <div class="row">
             <div class="col">
@@ -216,6 +216,7 @@
     safetyResponsibilityDeptQueryDetail,
     // safetyResponsibilityDeptSignOrFeedback,
     safetyResponsibilityDeptBatchSign,
+    safetyResponsibilityDeptSaveSign,
     queryAvailableUserList,
   } from '@/api/production-safety/responsibility-implementation';
 
@@ -306,35 +307,68 @@
   const handleSubmit = () => {
     formRef.value?.validate(async (valid) => {
       if (valid) {
-        const fullAttachment = formData.signRecords.every((item) => item.attachment && item.attachment.length > 0);
-        const filterList = formData.signRecords.filter((item) => item.signFlag && item.signStatus === 0);
-        const firstItem = filterList?.[0];
-        const lastItem = filterList?.[filterList.length - 1];
-
-        const isEmptyAttachment = !firstItem?.attachment || firstItem?.attachment?.length === 0;
-        const currentLevel = lastItem?.signLevel;
-        const currentOrder = lastItem?.order;
+        const fullAttachment = formData.signRecords.every((item) => item.attachment || item.attachment?.length > 0);
+        const signList = formData.signRecords.filter((item) => item.signFlag && item.signStatus === 0);
+        const firstSignItem = signList?.[0] ?? {};
+        const lastSignItem = signList?.[signList.length - 1] ?? {};
+        const isEmptyAttachment = !firstSignItem?.attachment || firstSignItem?.attachment?.length === 0;
+        const currentLevel = lastSignItem?.signLevel;
+        const currentOrder = lastSignItem?.signOrder;
         const nextLevel = Math.min(currentLevel + 1, 3);
         const nextOrder = currentOrder + 1;
 
-        //需要弹框选择用户的部门类型
+        //需要弹框选择用户的部门类型(C和D)
         const specialDeptKey = /C|D/.test(currentDepartmentKey.value);
 
         if (specialDeptKey) {
-          if (!fullAttachment) {
+          if (!fullAttachment || isEmptyAttachment) {
             ElMessage.warning('请上传签署材料');
             return;
           }
-          if (currentDepartmentKey.value === 'C') {
-            if (currentLevel < 3) {
-              dialogVisible.value = true;
+          // if (currentDepartmentKey.value === 'C') {
+          //   if (currentLevel < 3) {
+          //     if (!signerId.value) {
+          //       currentLabel.value = currentLevel === 1 ? '党委书记' : '所长';
+          //       dialogVisible.value = true;
+          //       return;
+          //     }
+          //     else {
+
+          //     }
+          //   } else {
+          //   }
+          // }
+          // if (currentDepartmentKey.value === 'D') {
+          //   if (currentLevel < 2) {
+          //     currentLabel.value = '部门负责人';
+          //     dialogVisible.value = true;
+          //     return;
+          //   }
+          // }
+          if (signerId.value) {
+            handleSubmitSign(firstSignItem).then(() => {
+              handleSafetyResponsibilityDeptSaveSign(signerId.value, nextLevel, nextOrder);
+            });
+          } else if (currentLevel === 2 && currentDepartmentKey.value === 'D') {
+            handleSubmitSign(firstSignItem);
+          } else if (currentLevel === 3 && currentDepartmentKey.value === 'C') {
+            handleSubmitSign(firstSignItem);
+          } else {
+            // if (isEmptyAttachment) {
+            //   ElMessage.warning('请上传签署材料');
+            //   return;
+            // }
+            if (currentDepartmentKey.value === 'C') {
+              if (currentLevel < 3) {
+                currentLabel.value = currentLevel === 1 ? '党委书记' : '所长';
+              }
             }
-            currentLabel.value = currentLevel === 1 ? '党委书记' : '所长';
-          } else if (currentDepartmentKey.value === 'D') {
-            if (currentLevel < 2) {
-              dialogVisible.value = true;
+            if (currentDepartmentKey.value === 'D') {
+              if (currentLevel < 2) {
+                currentLabel.value = '部门负责人';
+              }
             }
-            currentLabel.value = '部门负责人';
+            dialogVisible.value = true;
           }
         }
         // 非C和D的部门类型
@@ -343,45 +377,54 @@
             ElMessage.warning('请上传签署材料');
             return;
           }
-        }
-        // 通过后就走批量签署逻辑
-        submiting.value = true;
-
-        try {
-          const attachment = await formatAttachmentList(firstItem.attachment);
-          const params = {
-            ids: [route.query.id],
-            attachment: JSON.stringify(attachment),
-          };
-          if (specialDeptKey) {
-            Object.assign(params, {
-              signStatus: 0,
-              signLevel: nextLevel,
-              contractId: route.query.id,
-              signerId: signerId.value,
-              signOrder: nextOrder,
-            });
-          }
-          console.log('params:', params);
-          return;
-          safetyResponsibilityDeptBatchSign(params)
-            .then((res) => {
-              router.push({
-                name: 'responsibilityAgreeManageDept',
-              });
-              ElMessage.success('责任书签署成功');
-            })
-            .finally(() => {
-              submiting.value = false;
-            });
-        } catch (e: Error | any) {
-          ElMessage.error(e.message);
-          submiting.value = false;
+          handleSubmitSign(firstSignItem);
         }
       }
     });
   };
 
+  const handleSafetyResponsibilityDeptSaveSign = (signerId, nextLevel, nextOrder) => {
+    submiting.value = true;
+    const params = {
+      signStatus: 0,
+      signLevel: nextLevel,
+      contractId: route.query.id,
+      signerId,
+      signOrder: nextOrder,
+    };
+    return safetyResponsibilityDeptSaveSign(params)
+      .then(() => {})
+      .catch(() => {})
+      .finally(() => {
+        submiting.value = false;
+      });
+  };
+
+  const handleSubmitSign = async (firstItem) => {
+    submiting.value = true;
+    try {
+      const attachment = await formatAttachmentList(firstItem?.attachment);
+      const params = {
+        ids: [route.query.id],
+        attachment: JSON.stringify(attachment),
+      };
+
+      safetyResponsibilityDeptBatchSign(params)
+        .then((res) => {
+          router.push({
+            name: 'responsibilityAgreeManageDept',
+          });
+          ElMessage.success('责任书签署成功');
+        })
+        .finally(() => {
+          submiting.value = false;
+        });
+    } catch (e: Error | any) {
+      ElMessage.error(e.message);
+      submiting.value = false;
+    }
+  };
+
   const handleDialogConfirm = () => {
     if (signerId.value) {
       dialogVisible.value = false;