From ca030ea1f083821afada9c6badf472897c52815e Mon Sep 17 00:00:00 2001
From: yuan <123@>
Date: 星期日, 09 八月 2026 23:46:46 +0800
Subject: [PATCH] fix: 优化页面显示

---
 src/views/officeProcessAutomation/ApproveManage/approve-list/useApproveList.js |  165 +++++++++++++++++++++++++++++++++++++++++++++++-------
 1 files changed, 143 insertions(+), 22 deletions(-)

diff --git a/src/views/officeProcessAutomation/ApproveManage/approve-list/useApproveList.js b/src/views/officeProcessAutomation/ApproveManage/approve-list/useApproveList.js
index 3523ef4..9264253 100644
--- a/src/views/officeProcessAutomation/ApproveManage/approve-list/useApproveList.js
+++ b/src/views/officeProcessAutomation/ApproveManage/approve-list/useApproveList.js
@@ -13,10 +13,16 @@
 import useUserStore from "@/store/modules/user";
 import { Search } from "@element-plus/icons-vue";
 import { ElMessage, ElMessageBox } from "element-plus";
-import { computed, reactive, ref } from "vue";
+import { computed, getCurrentInstance, reactive, ref } from "vue";
+import {
+  inferReimburseModuleKeyFromInstance,
+  loadReimburseDetailForInstance,
+  navigateToReimburseManageForEdit,
+  resolveFinReimbursementIdFromInstance,
+} from "../../ReimburseManage/shared/reimburseApproveBridge.js";
 import {
   fetchBusinessTypeOptions,
-  formatDisplayTime,
+  formatDisplayDate,
   mapEnabledFromApi,
   unwrapTemplateList,
 } from "../approve-template/approveTemplateConstants.js";
@@ -43,6 +49,7 @@
 } from "./approveListConstants.js";
 
 export function useApproveList() {
+  const { proxy } = getCurrentInstance() || {};
   const userStore = useUserStore();
 
   const tableData = ref([]);
@@ -53,7 +60,8 @@
   const submitTemplatesLoading = ref(false);
 
   const submitTemplateCards = computed(() => {
-    if (selectedBusinessType.value == null || selectedBusinessType.value === "") return [];
+    if (selectedBusinessType.value == null || selectedBusinessType.value === "")
+      return [];
     return allSubmitTemplates.value.filter((card) =>
       matchBusinessTypeValue(card.businessType, selectedBusinessType.value)
     );
@@ -75,6 +83,16 @@
   const approveOpinion = ref("");
   const approveSubmitting = ref(false);
 
+  /** 宸梾/璐圭敤鎶ラ攢涓撶敤璇︽儏銆佸鎵瑰脊绐� */
+  const reimburseDialog = reactive({
+    visible: false,
+    mode: "detail",
+    moduleKey: "",
+    loading: false,
+    reimburseRow: {},
+    instanceRow: null,
+  });
+
   const submitDialog = reactive({ visible: false, step: 1, mode: "add" });
   const submitEditRow = ref(null);
   const submitForm = reactive(createEmptySubmitForm(""));
@@ -84,23 +102,36 @@
   const isSubmitEdit = computed(() => submitDialog.mode === "edit");
   const submitDialogTitle = computed(() => {
     if (submitDialog.mode === "edit") {
-      return `淇敼${activeTemplate.value?.label || submitForm.templateName || "瀹℃壒"}`;
+      return `淇敼${
+        activeTemplate.value?.label || submitForm.templateName || "瀹℃壒"
+      }`;
     }
     if (submitDialog.step === 1) return "閫夋嫨妯℃澘绫诲瀷";
-    if (submitDialog.step === 2) return `閫夋嫨瀹℃壒妯℃澘${businessTypeLabel(selectedBusinessType.value) ? `锛�${businessTypeLabel(selectedBusinessType.value)}锛塦 : ""}`;
+    if (submitDialog.step === 2)
+      return `閫夋嫨瀹℃壒妯℃澘${
+        businessTypeLabel(selectedBusinessType.value)
+          ? `锛�${businessTypeLabel(selectedBusinessType.value)}锛塦
+          : ""
+      }`;
     return `鎻愪氦${activeTemplate.value?.label || "瀹℃壒"}`;
   });
 
-  const selectedBusinessTypeLabel = computed(() => businessTypeLabel(selectedBusinessType.value));
+  const selectedBusinessTypeLabel = computed(() =>
+    businessTypeLabel(selectedBusinessType.value)
+  );
 
   function businessTypeLabel(type) {
     if (type == null || type === "") return "";
-    const hit = submitBusinessTypeOptions.value.find((x) => matchBusinessTypeValue(x.value, type));
+    const hit = submitBusinessTypeOptions.value.find((x) =>
+      matchBusinessTypeValue(x.value, type)
+    );
     return hit?.label || "";
   }
 
   function countTemplatesByBusinessType(type) {
-    return allSubmitTemplates.value.filter((card) => matchBusinessTypeValue(card.businessType, type)).length;
+    return allSubmitTemplates.value.filter((card) =>
+      matchBusinessTypeValue(card.businessType, type)
+    ).length;
   }
 
   const activeTemplate = computed(() => submitForm.templateSnapshot || null);
@@ -113,7 +144,9 @@
   });
 
   const submitFormRules = computed(() => ({
-    templateKey: [{ required: true, message: "璇烽�夋嫨瀹℃壒绫诲瀷", trigger: "change" }],
+    templateKey: [
+      { required: true, message: "璇烽�夋嫨瀹℃壒绫诲瀷", trigger: "change" },
+    ],
     ...buildFormPayloadRules(submitFormFields.value),
   }));
 
@@ -147,7 +180,7 @@
       label: "鍒涘缓鏃堕棿",
       prop: "createTime",
       width: 170,
-      formatData: (v) => formatDisplayTime(v),
+      formatData: (v) => formatDisplayDate(v),
     },
     {
       dataType: "action",
@@ -169,11 +202,11 @@
           disabled: (row) => row.approvalStatus !== "pending" || !row.isApprove,
           clickFun: (row) => openApprove(row),
         },
-        {
-          name: "鍒犻櫎",
-          type: "danger",
-          clickFun: (row) => removeInstance(row),
-        },
+        // {
+        //   name: "鍒犻櫎",
+        //   type: "danger",
+        //   clickFun: (row) => removeInstance(row),
+        // },
       ],
     },
   ]);
@@ -242,15 +275,52 @@
     fetchApprovalList();
   }
 
-  function openDetail(row) {
+  async function openReimburseDetail(row, mode) {
+    const moduleKey = inferReimburseModuleKeyFromInstance(row);
+    if (!moduleKey) return false;
+    reimburseDialog.mode = mode;
+    reimburseDialog.moduleKey = moduleKey;
+    reimburseDialog.instanceRow = row;
+    reimburseDialog.visible = true;
+    reimburseDialog.loading = true;
+    reimburseDialog.reimburseRow = {};
+    try {
+      const { reimburseRow, moduleKey: resolvedMk } =
+        await loadReimburseDetailForInstance(row, moduleKey);
+      reimburseDialog.moduleKey = resolvedMk || moduleKey;
+      reimburseDialog.reimburseRow = reimburseRow;
+      return true;
+    } catch {
+      ElMessage.error("鍔犺浇鎶ラ攢璇︽儏澶辫触");
+      reimburseDialog.visible = false;
+      return false;
+    } finally {
+      reimburseDialog.loading = false;
+    }
+  }
+
+  async function openDetail(row) {
+    if (isReimburseApprovalInstance(row)) {
+      await openReimburseDetail(row, "detail");
+      return;
+    }
     detailRow.value = { ...row };
     detailDialog.visible = true;
   }
 
-  function openApprove(row) {
+  async function openApprove(row) {
+    if (inferReimburseModuleKeyFromInstance(row)) {
+      approveOpinion.value = "";
+      await openReimburseDetail(row, "approve");
+      return;
+    }
     approveDialog.row = { ...row };
     approveOpinion.value = "";
     approveDialog.visible = true;
+  }
+
+  function isReimburseApprovalInstance(row) {
+    return Boolean(inferReimburseModuleKeyFromInstance(row));
   }
 
   function resetSubmitDialogState() {
@@ -267,9 +337,25 @@
     loadSubmitTemplates();
   }
 
-  function openEditDialog(row) {
+  async function openEditDialog(row) {
     if (row?.approvalStatus !== "pending") {
       ElMessage.warning("浠呭鏍镐腑鐨勫鎵瑰彲淇敼");
+      return;
+    }
+    const moduleKey = inferReimburseModuleKeyFromInstance(row);
+    if (moduleKey) {
+      const rid = resolveFinReimbursementIdFromInstance(row);
+      if (rid == null) {
+        ElMessage.warning("鏃犳硶淇敼锛氱己灏戞姤閿�鍗� ID");
+        return;
+      }
+      try {
+        await navigateToReimburseManageForEdit(proxy?.$router, moduleKey, rid);
+      } catch {
+        ElMessage.warning(
+          "鏈壘鍒板樊鏃�/璐圭敤鎶ラ攢鑿滃崟璺敱锛岃浠庡乏渚ц彍鍗曡繘鍏ュ悗鍐嶇紪杈�"
+        );
+      }
       return;
     }
     if (!row?.id) {
@@ -293,7 +379,9 @@
         templateKey: String(card.id),
         ...applied,
         businessType:
-          applied.businessType ?? card.businessType ?? selectedBusinessType.value,
+          applied.businessType ??
+          card.businessType ??
+          selectedBusinessType.value,
       });
       submitDialog.step = 3;
     } catch {
@@ -334,7 +422,9 @@
       return false;
     }
     if (!activeTemplate.value) return false;
-    const bindingCheck = validateTemplateBinding({ flowNodes: submitForm.flowNodes });
+    const bindingCheck = validateTemplateBinding({
+      flowNodes: submitForm.flowNodes,
+    });
     if (!bindingCheck.ok) {
       ElMessage.warning(bindingCheck.message);
       return false;
@@ -373,7 +463,9 @@
       return false;
     }
     if (!activeTemplate.value) return false;
-    const bindingCheck = validateTemplateBinding({ flowNodes: submitForm.flowNodes });
+    const bindingCheck = validateTemplateBinding({
+      flowNodes: submitForm.flowNodes,
+    });
     if (!bindingCheck.ok) {
       ElMessage.warning(bindingCheck.message);
       return false;
@@ -395,7 +487,10 @@
       );
       submitDialog.visible = false;
       await fetchApprovalList();
-      if (detailDialog.visible && detailRow.value?.id === submitForm.instanceId) {
+      if (
+        detailDialog.visible &&
+        detailRow.value?.id === submitForm.instanceId
+      ) {
         const hit = tableData.value.find((r) => r.id === submitForm.instanceId);
         if (hit) detailRow.value = { ...hit };
         else detailDialog.visible = false;
@@ -441,6 +536,29 @@
       await fetchApprovalList();
     } catch {
       /* 閿欒鐢辨嫤鎴櫒鎻愮ず */
+    }
+  }
+
+  async function submitReimburseApprove(result) {
+    const row = reimburseDialog.instanceRow;
+    if (!row?.id) return { ok: false };
+    if (result === "rejected" && !(approveOpinion.value || "").trim()) {
+      return { needOpinion: true };
+    }
+    if (approveSubmitting.value) return { ok: false };
+    approveSubmitting.value = true;
+    try {
+      await approveApprovalInstance(
+        buildApproveInstanceDto(row, result, approveOpinion.value)
+      );
+      reimburseDialog.visible = false;
+      await fetchApprovalList();
+      return { ok: true, result };
+    } catch {
+      ElMessage.error("瀹℃壒鎿嶄綔澶辫触");
+      return { ok: false };
+    } finally {
+      approveSubmitting.value = false;
     }
   }
 
@@ -495,9 +613,12 @@
     tableColumn,
     detailDialog,
     detailRow,
+    reimburseDialog,
     approveDialog,
     approveOpinion,
     approveSubmitting,
+    submitReimburseApprove,
+    isReimburseApprovalInstance,
     submitDialog,
     isSubmitEdit,
     submitDialogTitle,

--
Gitblit v1.9.3