From 7c2cdcbc7f5585b96fba76a07b0e4417a09c4d7e Mon Sep 17 00:00:00 2001
From: gaoluyang <2820782392@qq.com>
Date: 星期二, 02 六月 2026 11:06:10 +0800
Subject: [PATCH] 新疆马铃薯 1.过程检验下载添加3个模版

---
 src/views/officeProcessAutomation/ApproveManage/approve-list/useApproveList.js |  242 ++++++++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 233 insertions(+), 9 deletions(-)

diff --git a/src/views/officeProcessAutomation/ApproveManage/approve-list/useApproveList.js b/src/views/officeProcessAutomation/ApproveManage/approve-list/useApproveList.js
index 3523ef4..ae568b3 100644
--- a/src/views/officeProcessAutomation/ApproveManage/approve-list/useApproveList.js
+++ b/src/views/officeProcessAutomation/ApproveManage/approve-list/useApproveList.js
@@ -10,10 +10,19 @@
   saveApprovalInstance,
   updateApprovalInstance,
 } from "@/api/officeProcessAutomation/approvalInstance.js";
+import { getQuotationList } from "@/api/salesManagement/salesQuotation.js";
+import { getPurchaseByCode } from "@/api/procurementManagement/procurementLedger.js";
+import { getDeliveryDetailByShippingNo } from "@/api/salesManagement/deliveryLedger.js";
 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,
@@ -43,6 +52,7 @@
 } from "./approveListConstants.js";
 
 export function useApproveList() {
+  const { proxy } = getCurrentInstance() || {};
   const userStore = useUserStore();
 
   const tableData = ref([]);
@@ -70,10 +80,26 @@
 
   const detailDialog = reactive({ visible: false });
   const detailRow = ref({});
+  const detailData = ref({});
 
-  const approveDialog = reactive({ visible: false, row: null });
+  const approveDialog = reactive({ visible: false, row: null, warehouse: ''});
   const approveOpinion = ref("");
   const approveSubmitting = ref(false);
+
+  /** 鎶ヤ环/閲囪喘/鍙戣揣璇︽儏鍔犺浇鐘舵�� */
+  const quotationLoading = ref(false);
+  const purchaseLoading = ref(false);
+  const deliveryLoading = 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);
@@ -118,7 +144,7 @@
   }));
 
   const tableColumn = ref([
-    { label: "鐢宠浜虹紪鍙�", prop: "applicantNo", width: 110 },
+    // { label: "鐢宠浜虹紪鍙�", prop: "applicantNo", width: 110 },
     { label: "鐢宠浜哄悕绉�", prop: "applicantName", minWidth: 100 },
     { label: "妯℃澘绫诲瀷", prop: "businessName", minWidth: 120 },
     {
@@ -203,7 +229,7 @@
         fetchBusinessTypeOptions(),
         listApprovalTemplate(TEMPLATE_TYPE_CUSTOM),
       ]);
-      submitBusinessTypeOptions.value = typeOptions;
+      submitBusinessTypeOptions.value = typeOptions.filter((x) => ![5, 6, 7].includes(x.value));
       allSubmitTemplates.value = unwrapTemplateList(customRes)
         .filter((row) => mapEnabledFromApi(row.enabled))
         .map(mapSubmitTemplateCard);
@@ -242,15 +268,164 @@
     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 };
+    const bizType = Number(row.businessType);
+    // 鎶ヤ环瀹℃壒锛氱敤瀹℃壒浜嬬敱瀛楁鎵胯浇鐨�"鎶ヤ环鍗曞彿"鍘绘煡鎶ヤ环鍒楄〃
+    if (bizType === 6) {
+      const quotationNo = row?.quotationNo;
+      if (quotationNo) {
+        quotationLoading.value = true;
+        try {
+          const res = await getQuotationList({ quotationNo });
+          const records = res?.data?.records || [];
+          detailData.value = records[0] || {};
+        } finally {
+          quotationLoading.value = false;
+        }
+      } else {
+        detailData.value = {};
+      }
+    }
+    
+    // 閲囪喘瀹℃壒锛氱敤瀹℃壒浜嬬敱瀛楁鎵胯浇鐨�"閲囪喘鍚堝悓鍙�"鍘绘煡閲囪喘璇︽儏
+    else if (bizType === 5) {
+      const purchaseContractNumber = row?.purchaseContractNumber;
+      if (purchaseContractNumber) {
+        purchaseLoading.value = true;
+        try {
+          const res = await getPurchaseByCode({ purchaseContractNumber });
+          detailData.value = res || {};
+        } finally {
+          purchaseLoading.value = false;
+        }
+      } else {
+        detailData.value = {};
+      }
+    }
+    
+    // 鍙戣揣瀹℃壒锛氱敤瀹℃壒浜嬬敱瀛楁鎵胯浇鐨�"鍙戣揣鍗曞彿"鍘绘煡鍙戣揣璇︽儏
+    else if (bizType === 7) {
+      const shippingNo = row?.shippingNo;
+      if (shippingNo) {
+        deliveryLoading.value = true;
+        try {
+          const res = await getDeliveryDetailByShippingNo({ shippingNo });
+          detailData.value = res?.data || res || {};
+        } finally {
+          deliveryLoading.value = false;
+        }
+      } else {
+        detailData.value = {};
+      }
+    }
+    
+    // 鍏朵粬瀹℃壒绫诲瀷
+    else {
+      detailData.value = {};
+    }
+    
     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.warehouse = row?.warehouse || '';
+    const bizType = Number(row.businessType);
+    // 鎶ヤ环瀹℃壒锛氱敤瀹℃壒浜嬬敱瀛楁鎵胯浇鐨�"鎶ヤ环鍗曞彿"鍘绘煡鎶ヤ环鍒楄〃
+    if (bizType === 6) {
+      const quotationNo = row?.quotationNo;
+      if (quotationNo) {
+        quotationLoading.value = true;
+        try {
+          const res = await getQuotationList({ quotationNo });
+          const records = res?.data?.records || [];
+          detailData.value = records[0] || {};
+        } finally {
+          quotationLoading.value = false;
+        }
+      } else {
+        detailData.value = {};
+      }
+    }
+
+    // 閲囪喘瀹℃壒锛氱敤瀹℃壒浜嬬敱瀛楁鎵胯浇鐨�"閲囪喘鍚堝悓鍙�"鍘绘煡閲囪喘璇︽儏
+    else if (bizType === 5) {
+      const purchaseContractNumber = row?.purchaseContractNumber;
+      if (purchaseContractNumber) {
+        purchaseLoading.value = true;
+        try {
+          const res = await getPurchaseByCode({ purchaseContractNumber });
+          detailData.value = res || {};
+        } finally {
+          purchaseLoading.value = false;
+        }
+      } else {
+        detailData.value = {};
+      }
+    }
+
+    // 鍙戣揣瀹℃壒锛氱敤瀹℃壒浜嬬敱瀛楁鎵胯浇鐨�"鍙戣揣鍗曞彿"鍘绘煡鍙戣揣璇︽儏
+    else if (bizType === 7) {
+      const shippingNo = row?.shippingNo;
+      if (shippingNo) {
+        deliveryLoading.value = true;
+        try {
+          const res = await getDeliveryDetailByShippingNo({ shippingNo });
+          detailData.value = res?.data || res || {};
+        } finally {
+          deliveryLoading.value = false;
+        }
+      } else {
+        detailData.value = {};
+      }
+    }
+
+    // 鍏朵粬瀹℃壒绫诲瀷
+    else {
+      detailData.value = {};
+    }
     approveDialog.visible = true;
+  }
+
+  function isReimburseApprovalInstance(row) {
+    return Boolean(inferReimburseModuleKeyFromInstance(row));
   }
 
   function resetSubmitDialogState() {
@@ -267,9 +442,23 @@
     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) {
@@ -444,6 +633,29 @@
     }
   }
 
+  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, approveDialog.warehouse)
+      );
+      reimburseDialog.visible = false;
+      await fetchApprovalList();
+      return { ok: true, result };
+    } catch {
+      ElMessage.error("瀹℃壒鎿嶄綔澶辫触");
+      return { ok: false };
+    } finally {
+      approveSubmitting.value = false;
+    }
+  }
+
   async function submitApprove(result) {
     const row = approveDialog.row;
     if (!row?.id) return { ok: false };
@@ -453,8 +665,13 @@
     if (approveSubmitting.value) return { ok: false };
     approveSubmitting.value = true;
     try {
+      // 鍙戣揣瀹℃壒鏃朵紶閫掑嚭搴撴壒鍙�
+      const extraData = {};
+      if (Number(row.businessType) === 7 && detailData.value?.shippingInfo?.outboundBatches) {
+        extraData.outboundBatches = detailData.value.shippingInfo.outboundBatches;
+      }
       await approveApprovalInstance(
-        buildApproveInstanceDto(row, result, approveOpinion.value)
+        buildApproveInstanceDto(row, result, approveOpinion.value, approveDialog.warehouse, extraData)
       );
       approveDialog.visible = false;
       await fetchApprovalList();
@@ -495,9 +712,16 @@
     tableColumn,
     detailDialog,
     detailRow,
+    detailData,
+    quotationLoading,
+    purchaseLoading,
+    deliveryLoading,
+    reimburseDialog,
     approveDialog,
     approveOpinion,
     approveSubmitting,
+    submitReimburseApprove,
+    isReimburseApprovalInstance,
     submitDialog,
     isSubmitEdit,
     submitDialogTitle,
@@ -531,4 +755,4 @@
     openApprove,
     fetchApprovalList,
   };
-}
+}
\ No newline at end of file

--
Gitblit v1.9.3