From 6689bfb1c2f0638e8493adfa058d57d86e473eac Mon Sep 17 00:00:00 2001
From: yyb <995253665@qq.com>
Date: 星期二, 19 五月 2026 17:21:10 +0800
Subject: [PATCH] 审批列表得提交审批根据模板类型区分
---
src/views/officeProcessAutomation/ApproveManage/approve-list/useApproveList.js | 75 ++++++++++++++++++++++++++++++-------
1 files changed, 61 insertions(+), 14 deletions(-)
diff --git a/src/views/officeProcessAutomation/ApproveManage/approve-list/useApproveList.js b/src/views/officeProcessAutomation/ApproveManage/approve-list/useApproveList.js
index fa9fade..4b8510a 100644
--- a/src/views/officeProcessAutomation/ApproveManage/approve-list/useApproveList.js
+++ b/src/views/officeProcessAutomation/ApproveManage/approve-list/useApproveList.js
@@ -1,7 +1,6 @@
import {
getApprovalTemplateDetail,
listApprovalTemplate,
- TEMPLATE_TYPE_BUILTIN,
TEMPLATE_TYPE_CUSTOM,
} from "@/api/officeProcessAutomation/approvalTemplate.js";
import {
@@ -16,6 +15,7 @@
import { ElMessage, ElMessageBox } from "element-plus";
import { computed, reactive, ref } from "vue";
import {
+ fetchBusinessTypeOptions,
formatDisplayTime,
mapEnabledFromApi,
mapTemplateFromApi,
@@ -36,6 +36,7 @@
createEmptySubmitForm,
mapInstanceFromApi,
mapSubmitTemplateCard,
+ matchBusinessTypeValue,
validateSubmitFlowNodes,
unwrapInstancePage,
} from "./approveListConstants.js";
@@ -45,8 +46,17 @@
const userStore = useUserStore();
const tableData = ref([]);
- const submitTemplateCards = ref([]);
+ const submitBusinessTypeOptions = ref([]);
+ const allSubmitTemplates = ref([]);
+ const selectedBusinessType = ref("");
const submitTemplatesLoading = ref(false);
+
+ const submitTemplateCards = computed(() => {
+ if (selectedBusinessType.value == null || selectedBusinessType.value === "") return [];
+ return allSubmitTemplates.value.filter((card) =>
+ matchBusinessTypeValue(card.businessType, selectedBusinessType.value)
+ );
+ });
const searchForm = reactive({
approvalType: "",
@@ -75,9 +85,22 @@
if (submitDialog.mode === "edit") {
return `淇敼${activeTemplate.value?.label || submitForm.templateName || "瀹℃壒"}`;
}
- if (submitDialog.step === 1) return "閫夋嫨瀹℃壒妯℃澘";
+ if (submitDialog.step === 1) return "閫夋嫨妯℃澘绫诲瀷";
+ if (submitDialog.step === 2) return `閫夋嫨瀹℃壒妯℃澘${businessTypeLabel(selectedBusinessType.value) ? `锛�${businessTypeLabel(selectedBusinessType.value)}锛塦 : ""}`;
return `鎻愪氦${activeTemplate.value?.label || "瀹℃壒"}`;
});
+
+ const selectedBusinessTypeLabel = computed(() => businessTypeLabel(selectedBusinessType.value));
+
+ function businessTypeLabel(type) {
+ if (type == null || type === "") return "";
+ 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;
+ }
const activeTemplate = computed(() => submitForm.templateSnapshot || null);
@@ -108,6 +131,7 @@
const tableColumn = ref([
{ label: "鐢宠浜虹紪鍙�", prop: "applicantNo", width: 110 },
{ label: "鐢宠浜哄悕绉�", prop: "applicantName", minWidth: 100 },
+ { label: "涓氬姟绫诲瀷", prop: "businessName", minWidth: 120 },
{
label: "瀹℃壒绫诲瀷",
prop: "approvalType",
@@ -186,17 +210,17 @@
async function loadSubmitTemplates() {
submitTemplatesLoading.value = true;
try {
- const [builtinRes, customRes] = await Promise.all([
- listApprovalTemplate(TEMPLATE_TYPE_BUILTIN),
+ const [typeOptions, customRes] = await Promise.all([
+ fetchBusinessTypeOptions(),
listApprovalTemplate(TEMPLATE_TYPE_CUSTOM),
]);
- const merged = [
- ...unwrapTemplateList(builtinRes),
- ...unwrapTemplateList(customRes),
- ].filter((row) => mapEnabledFromApi(row.enabled));
- submitTemplateCards.value = merged.map(mapSubmitTemplateCard);
+ submitBusinessTypeOptions.value = typeOptions;
+ allSubmitTemplates.value = unwrapTemplateList(customRes)
+ .filter((row) => mapEnabledFromApi(row.enabled))
+ .map(mapSubmitTemplateCard);
} catch {
- submitTemplateCards.value = [];
+ submitBusinessTypeOptions.value = [];
+ allSubmitTemplates.value = [];
ElMessage.error("鍔犺浇瀹℃壒妯℃澘澶辫触");
} finally {
submitTemplatesLoading.value = false;
@@ -235,6 +259,7 @@
function resetSubmitDialogState() {
submitDialog.mode = "add";
submitDialog.step = 1;
+ selectedBusinessType.value = "";
submitEditRow.value = null;
Object.assign(submitForm, createEmptySubmitForm(""));
}
@@ -255,7 +280,7 @@
return;
}
submitDialog.mode = "edit";
- submitDialog.step = 2;
+ submitDialog.step = 3;
submitEditRow.value = { ...row };
Object.assign(submitForm, buildEditFormFromInstanceRow(row));
submitDialog.visible = true;
@@ -275,10 +300,11 @@
Object.assign(submitForm, {
...base,
templateName: mapped.templateName || tpl.label || "",
+ businessType: mapped.businessType ?? card.businessType ?? selectedBusinessType.value,
templateSnapshot: tpl,
formFieldDefs: tpl.fields || [],
});
- submitDialog.step = 2;
+ submitDialog.step = 3;
} catch {
ElMessage.error("鍔犺浇妯℃澘璇︽儏澶辫触");
} finally {
@@ -286,8 +312,22 @@
}
}
- function backToTemplatePick() {
+ function onBusinessTypePick(type) {
+ if (!countTemplatesByBusinessType(type)) {
+ ElMessage.warning("璇ョ被鍨嬩笅鏆傛棤鍙敤瀹℃壒妯℃澘");
+ return;
+ }
+ selectedBusinessType.value = type;
+ submitDialog.step = 2;
+ }
+
+ function backToBusinessTypePick() {
+ selectedBusinessType.value = "";
submitDialog.step = 1;
+ }
+
+ function backToTemplatePick() {
+ submitDialog.step = 2;
}
async function submitInstanceForm() {
@@ -473,7 +513,12 @@
activeTemplate,
submitFormFields,
submitFormRules,
+ submitBusinessTypeOptions,
submitTemplateCards,
+ selectedBusinessType,
+ selectedBusinessTypeLabel,
+ businessTypeLabel,
+ countTemplatesByBusinessType,
submitTemplatesLoading,
handleQuery,
resetSearch,
@@ -481,7 +526,9 @@
resetSubmitDialogState,
openSubmitDialog,
openEditDialog,
+ onBusinessTypePick,
onTemplatePick,
+ backToBusinessTypePick,
backToTemplatePick,
submitInstanceForm,
submitNewApproval,
--
Gitblit v1.9.3