From efc0c3a697969503634138d7881543f4099b81ca Mon Sep 17 00:00:00 2001
From: yyb <995253665@qq.com>
Date: 星期三, 20 五月 2026 13:32:09 +0800
Subject: [PATCH] 审批模板导入只能从已有模板导入
---
src/views/officeProcessAutomation/ApproveManage/approve-template/useApproveTemplate.js | 80 ++++++++++++++++++----------------------
1 files changed, 36 insertions(+), 44 deletions(-)
diff --git a/src/views/officeProcessAutomation/ApproveManage/approve-template/useApproveTemplate.js b/src/views/officeProcessAutomation/ApproveManage/approve-template/useApproveTemplate.js
index 8489e13..0dbf2ca 100644
--- a/src/views/officeProcessAutomation/ApproveManage/approve-template/useApproveTemplate.js
+++ b/src/views/officeProcessAutomation/ApproveManage/approve-template/useApproveTemplate.js
@@ -2,11 +2,8 @@
addApprovalTemplate,
deleteApprovalTemplate,
getApprovalTemplateDetail,
- listApprovalTemplate,
listApprovalTemplatePage,
- TEMPLATE_TYPE_BUILTIN,
TEMPLATE_TYPE_CUSTOM,
- TEMPLATE_TYPE_OPTIONS,
updateApprovalTemplate,
} from "@/api/officeProcessAutomation/approvalTemplate.js";
import { Search } from "@element-plus/icons-vue";
@@ -15,35 +12,39 @@
import {
buildApprovalTemplateListParams,
createEmptyTemplateForm,
+ fetchBusinessTypeOptions,
flowNodesSummary,
- mapBuiltinCardFromApi,
mapTemplateFromApi,
mapTemplateToApi,
nodeSignModeLabel,
- templateTypeLabel,
- unwrapTemplateList,
formatDisplayTime,
unwrapTemplateDetail,
validateTemplateForm,
} from "./approveTemplateConstants.js";
import { parseFormConfigToData } from "./formConfigUtils.js";
-const LEGACY_STORAGE_KEY = "oa_approve_template_custom_v1";
+const FALLBACK_TEMPLATE_TYPE_OPTIONS = [
+ { value: 0, label: "绯荤粺鍐呯疆" },
+ { value: 1, label: "鑷畾涔�" },
+];
-function clearLegacyStorage() {
- try {
- localStorage.removeItem(LEGACY_STORAGE_KEY);
- } catch {
- /* ignore */
- }
+function matchTemplateTypeValue(options, type) {
+ if (type == null || type === "") return false;
+ return options.some(
+ (x) => x.value === type || x.value === Number(type) || String(x.value) === String(type)
+ );
}
export function useApproveTemplate() {
- clearLegacyStorage();
+ const templateTypeOptions = ref([...FALLBACK_TEMPLATE_TYPE_OPTIONS]);
- const activeTab = ref("custom");
- const builtinTemplates = ref([]);
- const builtinLoading = ref(false);
+ function templateTypeLabel(type) {
+ if (type == null || type === "") return "鈥�";
+ const hit = templateTypeOptions.value.find(
+ (x) => x.value === type || x.value === Number(type) || String(x.value) === String(type)
+ );
+ return hit?.label || "鈥�";
+ }
const searchForm = reactive({
keyword: "",
@@ -58,20 +59,32 @@
const form = reactive(createEmptyTemplateForm());
const formRef = ref();
+ async function loadTemplateTypeOptions() {
+ try {
+ const list = await fetchBusinessTypeOptions();
+ templateTypeOptions.value = list.length ? list : [...FALLBACK_TEMPLATE_TYPE_OPTIONS];
+ } catch {
+ templateTypeOptions.value = [...FALLBACK_TEMPLATE_TYPE_OPTIONS];
+ }
+ if (!matchTemplateTypeValue(templateTypeOptions.value, form.businessType)) {
+ form.businessType = templateTypeOptions.value[0]?.value ?? "";
+ }
+ }
+
const detailDialog = reactive({ visible: false });
const detailRow = ref({});
const detailLoading = ref(false);
const formRules = {
templateName: [{ required: true, message: "璇疯緭鍏ユā鏉垮悕绉�", trigger: "blur" }],
- templateType: [{ required: true, message: "璇烽�夋嫨妯℃澘绫诲瀷", trigger: "change" }],
+ businessType: [{ required: true, message: "璇烽�夋嫨妯℃澘绫诲瀷", trigger: "change" }],
};
const tableColumn = ref([
{ label: "妯℃澘鍚嶇О", prop: "templateName", minWidth: 140 },
{
label: "妯℃澘绫诲瀷",
- prop: "templateType",
+ prop: "businessType",
width: 100,
align: "center",
formatData: (v) => templateTypeLabel(v),
@@ -133,19 +146,6 @@
},
]);
- async function loadBuiltinTemplates() {
- builtinLoading.value = true;
- try {
- const res = await listApprovalTemplate(TEMPLATE_TYPE_BUILTIN);
- builtinTemplates.value = unwrapTemplateList(res).map(mapBuiltinCardFromApi);
- } catch {
- builtinTemplates.value = [];
- ElMessage.warning("绯荤粺甯哥敤瀹℃壒鍔犺浇澶辫触");
- } finally {
- builtinLoading.value = false;
- }
- }
-
async function fetchTemplateList() {
tableLoading.value = true;
try {
@@ -191,13 +191,14 @@
id: row.id,
templateName: row.templateName || "",
description: row.description || "",
- templateType: row.templateType ?? TEMPLATE_TYPE_CUSTOM,
+ businessType: row.businessType ?? "",
formConfig: row.formConfig || "",
formConfigData: JSON.parse(
JSON.stringify(row.formConfigData || parseFormConfigToData(row.formConfig))
),
enabled: row.enabled !== false,
flowNodes: JSON.parse(JSON.stringify(row.flowNodes || [base.flowNodes[0]])),
+ storageBlobDTOs: JSON.parse(JSON.stringify(row.storageBlobDTOs || [])),
});
}
@@ -253,9 +254,6 @@
formDialog.visible = false;
page.current = 1;
await fetchTemplateList();
- if (dto.templateType === TEMPLATE_TYPE_BUILTIN) {
- await loadBuiltinTemplates();
- }
return { ok: true };
}
@@ -284,9 +282,6 @@
await deleteApprovalTemplate([row.id]);
ElMessage.success("鍒犻櫎鎴愬姛");
await fetchTemplateList();
- if (row.templateType === TEMPLATE_TYPE_BUILTIN) {
- await loadBuiltinTemplates();
- }
} catch {
/* 閿欒鐢辨嫤鎴櫒鎻愮ず */
}
@@ -294,12 +289,9 @@
return {
Search,
- TEMPLATE_TYPE_OPTIONS,
+ templateTypeOptions,
+ loadTemplateTypeOptions,
templateTypeLabel,
- activeTab,
- builtinTemplates,
- builtinLoading,
- loadBuiltinTemplates,
fetchTemplateList,
nodeSignModeLabel,
flowNodesSummary,
--
Gitblit v1.9.3