From df5efb2ca2b0cf74d9160ffe2b6c215c4ddc9c99 Mon Sep 17 00:00:00 2001
From: yyb <995253665@qq.com>
Date: 星期四, 21 五月 2026 17:48:17 +0800
Subject: [PATCH] 差旅报销费用报销
---
src/views/officeProcessAutomation/ApproveManage/approve-list/useApproveList.js | 188 ++++++++++++++++++++++++++++++++++------------
1 files changed, 138 insertions(+), 50 deletions(-)
diff --git a/src/views/officeProcessAutomation/ApproveManage/approve-list/useApproveList.js b/src/views/officeProcessAutomation/ApproveManage/approve-list/useApproveList.js
index 4b8510a..67b9213 100644
--- a/src/views/officeProcessAutomation/ApproveManage/approve-list/useApproveList.js
+++ b/src/views/officeProcessAutomation/ApproveManage/approve-list/useApproveList.js
@@ -13,17 +13,26 @@
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,
mapEnabledFromApi,
- mapTemplateFromApi,
- unwrapTemplateDetail,
unwrapTemplateList,
} from "../approve-template/approveTemplateConstants.js";
-import { buildSubmitTemplateFromRow } from "../approve-template/formConfigUtils.js";
import {
+ buildFormPayloadRules,
+ buildTemplateBindingFromDetail,
+ validateTemplateBinding,
+} from "../approve-shared/approvalTemplateBindingUtils.js";
+import {
+ APPROVAL_STATUS_SEARCH_OPTIONS,
APPROVAL_TYPE_OPTIONS,
approvalStatusLabel,
approvalStatusTagType,
@@ -32,20 +41,19 @@
buildApproveInstanceDto,
buildEditFormFromInstanceRow,
buildInstanceDto,
- clearLegacyApproveListStorage,
createEmptySubmitForm,
mapInstanceFromApi,
mapSubmitTemplateCard,
matchBusinessTypeValue,
- validateSubmitFlowNodes,
unwrapInstancePage,
} from "./approveListConstants.js";
export function useApproveList() {
- clearLegacyApproveListStorage();
+ const { proxy } = getCurrentInstance() || {};
const userStore = useUserStore();
const tableData = ref([]);
+ const searchBusinessTypeOptions = ref([]);
const submitBusinessTypeOptions = ref([]);
const allSubmitTemplates = ref([]);
const selectedBusinessType = ref("");
@@ -59,8 +67,8 @@
});
const searchForm = reactive({
- approvalType: "",
- applicantKeyword: "",
+ businessType: "",
+ status: "",
createTimeRange: [],
});
@@ -73,6 +81,16 @@
const approveDialog = reactive({ visible: false, row: null });
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);
@@ -111,27 +129,15 @@
return submitForm.formFieldDefs || [];
});
- const submitFormRules = computed(() => {
- const rules = {
- templateKey: [{ required: true, message: "璇烽�夋嫨瀹℃壒绫诲瀷", trigger: "change" }],
- };
- submitFormFields.value.forEach((f) => {
- if (!f.required) return;
- if (f.type === "number") {
- rules[`formPayload.${f.key}`] = [{ required: true, message: `璇峰~鍐�${f.label}`, trigger: "blur" }];
- } else if (f.type === "datetimerange") {
- rules[`formPayload.${f.key}`] = [{ required: true, message: `璇烽�夋嫨${f.label}`, trigger: "change" }];
- } else {
- rules[`formPayload.${f.key}`] = [{ required: true, message: `璇峰~鍐�${f.label}`, trigger: "blur" }];
- }
- });
- return rules;
- });
+ const submitFormRules = computed(() => ({
+ templateKey: [{ required: true, message: "璇烽�夋嫨瀹℃壒绫诲瀷", trigger: "change" }],
+ ...buildFormPayloadRules(submitFormFields.value),
+ }));
const tableColumn = ref([
{ label: "鐢宠浜虹紪鍙�", prop: "applicantNo", width: 110 },
{ label: "鐢宠浜哄悕绉�", prop: "applicantName", minWidth: 100 },
- { label: "涓氬姟绫诲瀷", prop: "businessName", minWidth: 120 },
+ { label: "妯℃澘绫诲瀷", prop: "businessName", minWidth: 120 },
{
label: "瀹℃壒绫诲瀷",
prop: "approvalType",
@@ -233,10 +239,18 @@
}
function resetSearch() {
- searchForm.approvalType = "";
- searchForm.applicantKeyword = "";
+ searchForm.businessType = "";
+ searchForm.status = "";
searchForm.createTimeRange = [];
handleQuery();
+ }
+
+ async function loadSearchBusinessTypeOptions() {
+ try {
+ searchBusinessTypeOptions.value = await fetchBusinessTypeOptions();
+ } catch {
+ searchBusinessTypeOptions.value = [];
+ }
}
function pagination({ page: p, limit }) {
@@ -245,15 +259,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() {
@@ -270,9 +321,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) {
@@ -291,18 +356,12 @@
submitTemplatesLoading.value = true;
try {
const res = await getApprovalTemplateDetail(card.id);
- const mapped = mapTemplateFromApi(unwrapTemplateDetail(res));
- const tpl = {
- ...buildSubmitTemplateFromRow(mapped),
- templateId: mapped.id,
- };
- const base = createEmptySubmitForm(String(card.id), tpl, mapped.flowNodes);
+ const applied = buildTemplateBindingFromDetail(res);
Object.assign(submitForm, {
- ...base,
- templateName: mapped.templateName || tpl.label || "",
- businessType: mapped.businessType ?? card.businessType ?? selectedBusinessType.value,
- templateSnapshot: tpl,
- formFieldDefs: tpl.fields || [],
+ templateKey: String(card.id),
+ ...applied,
+ businessType:
+ applied.businessType ?? card.businessType ?? selectedBusinessType.value,
});
submitDialog.step = 3;
} catch {
@@ -343,9 +402,9 @@
return false;
}
if (!activeTemplate.value) return false;
- const flowCheck = validateSubmitFlowNodes(submitForm.flowNodes);
- if (!flowCheck.ok) {
- ElMessage.warning(flowCheck.message);
+ const bindingCheck = validateTemplateBinding({ flowNodes: submitForm.flowNodes });
+ if (!bindingCheck.ok) {
+ ElMessage.warning(bindingCheck.message);
return false;
}
if (!submitForm.templateId) {
@@ -360,7 +419,7 @@
submitForm,
activeTemplate: activeTemplate.value,
userStore,
- flowNodes: flowCheck.nodes,
+ flowNodes: bindingCheck.nodes,
})
);
submitDialog.visible = false;
@@ -382,9 +441,9 @@
return false;
}
if (!activeTemplate.value) return false;
- const flowCheck = validateSubmitFlowNodes(submitForm.flowNodes);
- if (!flowCheck.ok) {
- ElMessage.warning(flowCheck.message);
+ const bindingCheck = validateTemplateBinding({ flowNodes: submitForm.flowNodes });
+ if (!bindingCheck.ok) {
+ ElMessage.warning(bindingCheck.message);
return false;
}
if (!submitForm.instanceId) {
@@ -398,7 +457,7 @@
buildInstanceDto({
submitForm,
activeTemplate: activeTemplate.value,
- flowNodes: flowCheck.nodes,
+ flowNodes: bindingCheck.nodes,
existingRow: submitEditRow.value,
})
);
@@ -453,6 +512,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)
+ );
+ 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 };
@@ -490,6 +572,9 @@
return {
Search,
APPROVAL_TYPE_OPTIONS,
+ APPROVAL_STATUS_SEARCH_OPTIONS,
+ searchBusinessTypeOptions,
+ loadSearchBusinessTypeOptions,
approvalTypeLabel,
approvalStatusLabel,
approvalStatusTagType,
@@ -501,9 +586,12 @@
tableColumn,
detailDialog,
detailRow,
+ reimburseDialog,
approveDialog,
approveOpinion,
approveSubmitting,
+ submitReimburseApprove,
+ isReimburseApprovalInstance,
submitDialog,
isSubmitEdit,
submitDialogTitle,
--
Gitblit v1.9.3