zouyu
2 天以前 db42d47f5692ef64e5436c5a6d29dcb537b44596
src/views/collaborativeApproval/approvalProcess/components/approvalDia.vue
@@ -6,7 +6,7 @@
      width="700px"
      @close="closeDia"
    >
         <el-form :model="form" label-width="140px" label-position="top" ref="formRef">
         <el-form :model="form" :rules="rules" label-width="140px" label-position="top" ref="formRef">
            <el-row>
               <el-col :span="24">
                  <el-form-item label="流程编号:" prop="approveId">
@@ -178,7 +178,7 @@
</template>
<script setup>
import { computed, getCurrentInstance, reactive, ref, toRefs } from "vue";
import { computed, getCurrentInstance, nextTick, reactive, ref, toRefs } from "vue";
import {
   approveProcessDetails,
   getDept,
@@ -218,8 +218,12 @@
      approveReason: "",
      checkResult: "",
   },
  rules: {
    // 使用部门ID做必填校验,避免名称未同步导致误报
    approveDeptId: [{ required: true, message: "请选择申请部门", trigger: "change" }],
  },
});
const { form } = toRefs(data);
const { form, rules } = toRefs(data);
// 节点标题
const getNodeTitle = (index, len) => {
@@ -251,7 +255,31 @@
      userList.value = res.data;
   });
   form.value = {...row}
   getProductOptions()
   // 立即清除表单验证状态(因为字段是disabled的,不需要验证)
   nextTick(() => {
      if (formRef.value) {
         formRef.value.clearValidate();
      }
   });
   // 确保选项加载完成后再匹配值类型
   getProductOptions().then(() => {
      // 确保值类型匹配(如果选项已加载)
      if (productOptions.value.length > 0 && form.value.approveDeptId) {
         const matchedOption = productOptions.value.find(opt =>
            opt.deptId == form.value.approveDeptId ||
            String(opt.deptId) === String(form.value.approveDeptId)
         );
         if (matchedOption) {
            form.value.approveDeptId = matchedOption.deptId;
         }
      }
      // 再次清除验证,确保选项加载后值匹配正确
      nextTick(() => {
         if (formRef.value) {
            formRef.value.clearValidate();
         }
      });
   });
  // 报价审批:用审批事由字段承载的“报价单号”去查报价列表
  if (isQuotationApproval.value) {
@@ -287,17 +315,26 @@
  })
}
const getProductOptions = () => {
   getDept().then((res) => {
   return getDept().then((res) => {
      productOptions.value = res.data;
   });
};
// 提交审批
const submitForm = (status) => {
  const filteredActivities = activities.value.filter(activity => activity.isShen);
  filteredActivities[0].approveNodeStatus = status;
  if (!filteredActivities || filteredActivities.length === 0) {
    proxy.$modal.msgError("未找到待审批的节点");
    return;
  }
  const currentActivity = filteredActivities[0];
  if (!currentActivity) {
    proxy.$modal.msgError("未找到待审批的节点");
    return;
  }
  currentActivity.approveNodeStatus = status;
  // 判断是否为最后一步
  const isLast = activities.value.findIndex(a => a.isShen) === activities.value.length-1;
  updateApproveNode({ ...filteredActivities[0], isLast }).then(() => {
  updateApproveNode({ ...currentActivity, isLast }).then(() => {
    proxy.$modal.msgSuccess("提交成功");
    closeDia();
  });
@@ -346,4 +383,4 @@
   width: 200px;
   height: 60px;
}
</style>
</style>