Browse Source

fix: 提交代码

sunqijun 3 months ago
parent
commit
5857e42506

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

@@ -34,11 +34,7 @@
         </el-select>
         </el-select>
       </el-form-item>
       </el-form-item>
 
 
-      <el-form-item
-        label="多人签署设置"
-        prop="signConfig"
-        v-if="currentDepartmentKey === 'B' || currentDepartmentKey === 'C'"
-      >
+      <el-form-item label="多人签署设置" prop="signConfig" v-if="currentDepartmentKey !== 'C'">
         <el-radio-group v-model="formData.signConfig">
         <el-radio-group v-model="formData.signConfig">
           <el-radio :value="0">否</el-radio>
           <el-radio :value="0">否</el-radio>
           <el-radio :value="1">是</el-radio>
           <el-radio :value="1">是</el-radio>
@@ -201,7 +197,6 @@
   import type { FormInstance } from 'element-plus';
   import type { FormInstance } from 'element-plus';
   import dayjs from 'dayjs';
   import dayjs from 'dayjs';
   import { queryAvailableUserList } from '@/api/production-safety/responsibility-implementation';
   import { queryAvailableUserList } from '@/api/production-safety/responsibility-implementation';
-  import { de } from 'element-plus/es/locale';
 
 
   const props = defineProps<{
   const props = defineProps<{
     modelValue: boolean;
     modelValue: boolean;
@@ -239,7 +234,7 @@
     checkStrictly: false,
     checkStrictly: false,
     value: 'id',
     value: 'id',
     label: 'deptName',
     label: 'deptName',
-    multiple: true,
+    multiple: !/A|B/.test(props.currentDepartmentKey),
   };
   };
 
 
   watch(
   watch(

+ 1 - 1
src/views/production-safety/implement-safety-duty/responsibility-agree-manage.vue

@@ -335,7 +335,7 @@
       userGroupId: formData.userGroupId.join(','),
       userGroupId: formData.userGroupId.join(','),
       deptId: JSON.stringify(formData.deptId),
       deptId: JSON.stringify(formData.deptId),
       signPerson: formData.signPerson.join(','),
       signPerson: formData.signPerson.join(','),
-      departmentId: formData.deptId.map((item) => item[item.length - 1]).join(','),
+      departmentId: formData.deptId.map((item) => (Array.isArray(item) ? item[item.length - 1] : item)).join(','),
     })
     })
       .then(() => {
       .then(() => {
         queryTableList();
         queryTableList();

+ 220 - 79
src/views/production-safety/implement-safety-duty/sign-agree-dept.vue

@@ -76,61 +76,109 @@
           </div>
           </div>
         </div>
         </div>
         <template v-if="signRecords.level1.length">
         <template v-if="signRecords.level1.length">
-          <h3 v-if="currentDepartmentKey === 'A'"> 副院长签署 </h3>
-          <h3 v-if="currentDepartmentKey === 'B'"> 负责人签署 </h3>
-          <h3 v-if="currentDepartmentKey === 'C'"> 负责人签署 </h3>
-          <h3 v-if="currentDepartmentKey === 'D'"> 科室负责人签署 </h3>
-          <div class="table table-level1" v-for="item in signRecords.level1" :key="item.id">
-            <div class="label">签名:</div>
-            <div class="value">
-              <el-form-item prop="signer">
-                <UploadFiles
-                  :disabled="!item.signFlag"
-                  label="上传文件"
-                  ref="uploadFilesRef"
-                  :fileList="item.attachment"
-                  @upload-success="(fileList) => handleUploadSignsUploadSuccess(item, fileList)"
-                />
-              </el-form-item>
+          <h4 v-if="currentDepartmentKey === 'A'"> 副院长签署 </h4>
+          <h4 v-if="currentDepartmentKey === 'B'"> 负责人签署 </h4>
+          <h4 v-if="currentDepartmentKey === 'C'"> 负责人签署 </h4>
+          <h4 v-if="currentDepartmentKey === 'D'"> 科室负责人签署 </h4>
+          <div class="detail-ct">
+            <div class="row" v-for="item in signRecords.level1" :key="item.id">
+              <div class="col">
+                <div class="label">签名:</div>
+                <div class="value value-s1">
+                  <el-form-item>
+                    <UploadFiles
+                      :disabled="!item.signFlag"
+                      label="上传文件"
+                      :fileList="item.attachment"
+                      @upload-success="(fileList) => handleUploadSignsUploadSuccess(item, fileList)"
+                    />
+                  </el-form-item>
+                  <!-- <div class="file-list">
+                    <div class="file-item" v-for="file in item.attachment" :key="file.fileId">
+                      <span class="file-item--name">{{ file.fileName }}</span>
+                      <div class="file-item--footer">
+                        <el-button link type="primary" @click="previewOnline(file.fileUrl, file.fileType)"
+                          >预览</el-button
+                        >
+                        <el-button link type="primary" @click.stop="downloadFile(file.fileUrl, file.fileName)"
+                          >下载</el-button
+                        >
+                      </div>
+                    </div>
+                  </div> -->
+                </div>
+              </div>
             </div>
             </div>
           </div>
           </div>
         </template>
         </template>
         <template v-if="signRecords.level2.length">
         <template v-if="signRecords.level2.length">
-          <h3 v-if="currentDepartmentKey === 'A'"> 党委书记签署 </h3>
-          <h3 v-if="currentDepartmentKey === 'B'"> 党委书记签署 </h3>
-          <h3 v-if="currentDepartmentKey === 'C'"> 党委书记签署</h3>
-          <h3 v-if="currentDepartmentKey === 'D'"> 部门负责人签署 </h3>
-          <div class="table table-level2" v-for="item in signRecords.level2" :key="item.id">
-            <div class="label">签名:</div>
-            <div class="value">
-              <el-form-item prop="signer">
-                <UploadFiles
-                  :disabled="!item.signFlag"
-                  label="上传文件"
-                  ref="uploadFilesRef"
-                  :fileList="item.attachment"
-                  @upload-success="handleUploadSignsUploadSuccess"
-                />
-              </el-form-item>
+          <h4 v-if="currentDepartmentKey === 'A'"> 党委书记签署 </h4>
+          <h4 v-if="currentDepartmentKey === 'B'"> 党委书记签署 </h4>
+          <h4 v-if="currentDepartmentKey === 'C'"> 党委书记签署</h4>
+          <h4 v-if="currentDepartmentKey === 'D'"> 部门负责人签署 </h4>
+          <div class="detail-ct">
+            <div class="row" v-for="item in signRecords.level2" :key="item.id">
+              <div class="col">
+                <div class="label">签名:</div>
+                <div class="value value-s1">
+                  <el-form-item>
+                    <UploadFiles
+                      :disabled="!item.signFlag"
+                      label="上传文件"
+                      :fileList="item.attachment"
+                      @upload-success="(fileList) => handleUploadSignsUploadSuccess(item, fileList)"
+                    />
+                  </el-form-item>
+                  <!-- <div class="file-list">
+                    <div class="file-item" v-for="file in item.attachment" :key="file.fileId">
+                      <span class="file-item--name">{{ file.fileName }}</span>
+                      <div class="file-item--footer">
+                        <el-button link type="primary" @click="previewOnline(file.fileUrl, file.fileType)"
+                          >预览</el-button
+                        >
+                        <el-button link type="primary" @click.stop="downloadFile(file.fileUrl, file.fileName)"
+                          >下载</el-button
+                        >
+                      </div>
+                    </div>
+                  </div> -->
+                </div>
+              </div>
             </div>
             </div>
           </div>
           </div>
         </template>
         </template>
         <template v-if="signRecords.level3.length">
         <template v-if="signRecords.level3.length">
-          <h3 v-if="currentDepartmentKey === 'A'"> 院长签署 </h3>
-          <h3 v-if="currentDepartmentKey === 'B'"> 院长签署 </h3>
-          <h3 v-if="currentDepartmentKey === 'C'"> 所长签署 </h3>
-          <div class="table table-level3" v-for="item in signRecords.level3" :key="item.id">
-            <div class="label">签名:</div>
-            <div class="value">
-              <el-form-item prop="signer">
-                <UploadFiles
-                  :disabled="item.signFlag"
-                  label="上传文件"
-                  ref="uploadFilesRef"
-                  :fileList="item.attachment"
-                  @upload-success="handleUploadSignsUploadSuccess"
-                />
-              </el-form-item>
+          <h4 v-if="currentDepartmentKey === 'A'"> 院长签署 </h4>
+          <h4 v-if="currentDepartmentKey === 'B'"> 院长签署 </h4>
+          <h4 v-if="currentDepartmentKey === 'C'"> 所长签署 </h4>
+          <div class="detail-ct">
+            <div class="row" v-for="item in signRecords.level3" :key="item.id">
+              <div class="col">
+                <div class="label">签名:</div>
+                <div class="value value-s1">
+                  <el-form-item>
+                    <UploadFiles
+                      :disabled="!item.signFlag"
+                      label="上传文件"
+                      :fileList="item.attachment"
+                      @upload-success="(fileList) => handleUploadSignsUploadSuccess(item, fileList)"
+                    />
+                  </el-form-item>
+                  <!-- <div class="file-list">
+                    <div class="file-item" v-for="file in item.attachment" :key="file.fileId">
+                      <span class="file-item--name">{{ file.fileName }}</span>
+                      <div class="file-item--footer">
+                        <el-button link type="primary" @click="previewOnline(file.fileUrl, file.fileType)"
+                          >预览</el-button
+                        >
+                        <el-button link type="primary" @click.stop="downloadFile(file.fileUrl, file.fileName)"
+                          >下载</el-button
+                        >
+                      </div>
+                    </div>
+                  </div> -->
+                </div>
+              </div>
             </div>
             </div>
           </div>
           </div>
         </template>
         </template>
@@ -142,6 +190,19 @@
     </footer>
     </footer>
   </div>
   </div>
   <PreviewOnline ref="previewOnlineRef" />
   <PreviewOnline ref="previewOnlineRef" />
+  <el-dialog v-model="dialogVisible" title="Tips" width="500">
+    <el-form-item :label="currentLabel">
+      <el-select v-model="signerId" placeholder="请选择" size="large" style="width: 100%" filterable>
+        <el-option v-for="item in userOptions" :key="item.value" :label="item.label" :value="item.value" />
+      </el-select>
+    </el-form-item>
+    <template #footer>
+      <div class="dialog-footer">
+        <el-button @click="handleDialogCancel">取消</el-button>
+        <el-button type="primary" @click="handleDialogConfirm"> 确认 </el-button>
+      </div>
+    </template>
+  </el-dialog>
 </template>
 </template>
 <script lang="ts" setup>
 <script lang="ts" setup>
   import { onMounted, ref, computed, reactive } from 'vue';
   import { onMounted, ref, computed, reactive } from 'vue';
@@ -153,16 +214,20 @@
   import UploadFiles from '@/components/UploadFiles/UploadFiles.vue';
   import UploadFiles from '@/components/UploadFiles/UploadFiles.vue';
   import {
   import {
     safetyResponsibilityDeptQueryDetail,
     safetyResponsibilityDeptQueryDetail,
-    safetyResponsibilityDeptSignOrFeedback,
+    // safetyResponsibilityDeptSignOrFeedback,
+    safetyResponsibilityDeptBatchSign,
+    queryAvailableUserList,
   } from '@/api/production-safety/responsibility-implementation';
   } from '@/api/production-safety/responsibility-implementation';
 
 
   import { unformatAttachment, formatAttachmentList } from '@/components/UploadFiles/utils';
   import { unformatAttachment, formatAttachmentList } from '@/components/UploadFiles/utils';
   import PreviewOnline from '@/views/disaster/components/PreviewOnline.vue';
   import PreviewOnline from '@/views/disaster/components/PreviewOnline.vue';
+  import { sign } from 'crypto';
 
 
   const router = useRouter();
   const router = useRouter();
   const route = useRoute();
   const route = useRoute();
   const formRef = ref<any>(null);
   const formRef = ref<any>(null);
   const submiting = ref(false);
   const submiting = ref(false);
+  const dialogVisible = ref(false);
 
 
   const formData = reactive<any>({
   const formData = reactive<any>({
     departmentName: '',
     departmentName: '',
@@ -173,7 +238,7 @@
     signsUpload: [],
     signsUpload: [],
     responsibilityName: '',
     responsibilityName: '',
     statusName: '',
     statusName: '',
-    signedQuantity: 0,
+    signedQuantity: '',
     userGroupName: '',
     userGroupName: '',
     planStartTime: null,
     planStartTime: null,
     planEndTime: null,
     planEndTime: null,
@@ -212,10 +277,12 @@
       case '常驻供应商':
       case '常驻供应商':
         return 'E';
         return 'E';
       default:
       default:
-        return 'default';
+        return '';
     }
     }
   });
   });
 
 
+  const userOptions = ref<any[]>([]);
+
   const showAlertBar = computed(() => {
   const showAlertBar = computed(() => {
     if (!formData.rejection) {
     if (!formData.rejection) {
       return false;
       return false;
@@ -224,7 +291,8 @@
   });
   });
   const previewOnlineRef = ref<InstanceType<typeof PreviewOnline>>();
   const previewOnlineRef = ref<InstanceType<typeof PreviewOnline>>();
   const isSignsUpload = computed(() => route.query.status === '2');
   const isSignsUpload = computed(() => route.query.status === '2');
-
+  const signerId = ref('');
+  const currentLabel = ref('');
   const previewOnline = (url: string | undefined, type) => {
   const previewOnline = (url: string | undefined, type) => {
     if (url) {
     if (url) {
       previewOnlineRef.value?.open(url, type);
       previewOnlineRef.value?.open(url, type);
@@ -232,41 +300,101 @@
   };
   };
   const handleUploadSignsUploadSuccess = (item, fileList) => {
   const handleUploadSignsUploadSuccess = (item, fileList) => {
     item.attachment = fileList;
     item.attachment = fileList;
-    console.log('@@@', signRecords.value.level1);
+    formData.signRecords = [...signRecords.value.level1, ...signRecords.value.level2, ...signRecords.value.level3];
   };
   };
 
 
   const handleSubmit = () => {
   const handleSubmit = () => {
-    let signsUpload: any[] = [];
-    let feedback: any[] = [];
-
     formRef.value?.validate(async (valid) => {
     formRef.value?.validate(async (valid) => {
       if (valid) {
       if (valid) {
-        submiting.value = true;
-        if (isSignsUpload.value) {
-          signsUpload = await formatAttachmentList(formData.signsUpload);
-        } else {
-          feedback = await formatAttachmentList(formData.feedback);
+        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 nextLevel = Math.min(currentLevel + 1, 3);
+        const nextOrder = currentOrder + 1;
+
+        //需要弹框选择用户的部门类型
+        const specialDeptKey = /C|D/.test(currentDepartmentKey.value);
+
+        if (specialDeptKey) {
+          if (!fullAttachment) {
+            ElMessage.warning('请上传签署材料');
+            return;
+          }
+          if (currentDepartmentKey.value === 'C') {
+            if (currentLevel < 3) {
+              dialogVisible.value = true;
+            }
+            currentLabel.value = currentLevel === 1 ? '党委书记' : '所长';
+          } else if (currentDepartmentKey.value === 'D') {
+            if (currentLevel < 2) {
+              dialogVisible.value = true;
+            }
+            currentLabel.value = '部门负责人';
+          }
+        }
+        // 非C和D的部门类型
+        else {
+          if (isEmptyAttachment) {
+            ElMessage.warning('请上传签署材料');
+            return;
+          }
         }
         }
-        const params = {
-          id: route.query.id,
-          updateType: isSignsUpload.value ? 0 : 1,
-          signsUpload: isSignsUpload.value ? JSON.stringify(signsUpload) : undefined,
-          feedback: !isSignsUpload.value ? JSON.stringify(feedback) : undefined,
-        };
-        safetyResponsibilityDeptSignOrFeedback(params)
-          .then(() => {
-            ElMessage.success('责任书签署成功');
-            router.push({
-              name: 'responsibilityAgreeManageDept',
+        // 通过后就走批量签署逻辑
+        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,
             });
             });
-          })
-          .finally(() => {
-            submiting.value = false;
-          });
+          }
+          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;
+        }
       }
       }
     });
     });
   };
   };
 
 
+  const handleDialogConfirm = () => {
+    if (signerId.value) {
+      dialogVisible.value = false;
+    } else {
+      ElMessage.warning('请选择签署人');
+    }
+  };
+
+  const handleDialogCancel = () => {
+    dialogVisible.value = false;
+    signerId.value = '';
+  };
+
   const handleQueryDetail = () => {
   const handleQueryDetail = () => {
     safetyResponsibilityDeptQueryDetail({
     safetyResponsibilityDeptQueryDetail({
       id: route.query.id,
       id: route.query.id,
@@ -275,22 +403,35 @@
         if (name in res) {
         if (name in res) {
           Object.assign(formData, {
           Object.assign(formData, {
             [name]: res[name],
             [name]: res[name],
-
             attachment: unformatAttachment(res.attachment),
             attachment: unformatAttachment(res.attachment),
             signsUpload: unformatAttachment(res.signsUpload),
             signsUpload: unformatAttachment(res.signsUpload),
             feedback: unformatAttachment(res.feedback),
             feedback: unformatAttachment(res.feedback),
-            signRecords: res.signRecords.map((item) => ({
+            signRecords: res.signRecords?.map((item) => ({
               ...item,
               ...item,
               attachment: unformatAttachment(item.attachment),
               attachment: unformatAttachment(item.attachment),
             })),
             })),
           });
           });
         }
         }
       });
       });
-      console.log('@formData:', formData);
     });
     });
   };
   };
 
 
-  onMounted(() => {
+  const getUserData = (realname = '') => {
+    queryAvailableUserList({
+      pageNumber: 1,
+      pageSize: 300,
+      queryParam: { realname },
+    }).then((res: any) => {
+      userOptions.value = (res.records || [])?.map((u: any) => ({
+        value: u.id,
+        label: u.realname,
+      }));
+      console.log('userData:', userOptions.value);
+    });
+  };
+
+  onMounted(async () => {
+    await getUserData('');
     handleQueryDetail();
     handleQueryDetail();
   });
   });
 </script>
 </script>