From 6d6e3204f92d763e5df11d26702f6642a993e49e Mon Sep 17 00:00:00 2001
From: yyb <995253665@qq.com>
Date: 星期四, 21 五月 2026 10:21:40 +0800
Subject: [PATCH] 增强审批模板功能,新增内置模板类型支持,优化模板编辑和导入逻辑,确保内置模板不可编辑和删除,提升用户体验和代码可维护性。
---
src/views/officeProcessAutomation/ApproveManage/approve-template/useApproveTemplate.js | 40 +++++++++++++++++++++++-----------------
1 files changed, 23 insertions(+), 17 deletions(-)
diff --git a/src/views/officeProcessAutomation/ApproveManage/approve-template/useApproveTemplate.js b/src/views/officeProcessAutomation/ApproveManage/approve-template/useApproveTemplate.js
index 95eac7b..61aa6c0 100644
--- a/src/views/officeProcessAutomation/ApproveManage/approve-template/useApproveTemplate.js
+++ b/src/views/officeProcessAutomation/ApproveManage/approve-template/useApproveTemplate.js
@@ -3,17 +3,18 @@
deleteApprovalTemplate,
getApprovalTemplateDetail,
listApprovalTemplatePage,
- TEMPLATE_TYPE_CUSTOM,
+ TEMPLATE_TYPE_BUILTIN,
updateApprovalTemplate,
} from "@/api/officeProcessAutomation/approvalTemplate.js";
import { Search } from "@element-plus/icons-vue";
import { ElMessage, ElMessageBox } from "element-plus";
-import { reactive, ref } from "vue";
+import { computed, reactive, ref } from "vue";
import {
buildApprovalTemplateListParams,
createEmptyTemplateForm,
fetchBusinessTypeOptions,
flowNodesSummary,
+ isBuiltinTemplate,
mapTemplateFromApi,
mapTemplateToApi,
nodeSignModeLabel,
@@ -22,8 +23,6 @@
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: "绯荤粺鍐呯疆" },
@@ -37,17 +36,7 @@
);
}
-function clearLegacyStorage() {
- try {
- localStorage.removeItem(LEGACY_STORAGE_KEY);
- } catch {
- /* ignore */
- }
-}
-
export function useApproveTemplate() {
- clearLegacyStorage();
-
const templateTypeOptions = ref([...FALLBACK_TEMPLATE_TYPE_OPTIONS]);
function templateTypeLabel(type) {
@@ -70,6 +59,10 @@
const formDialog = reactive({ visible: false, title: "", mode: "add" });
const form = reactive(createEmptyTemplateForm());
const formRef = ref();
+
+ const isEditingBuiltin = computed(
+ () => formDialog.mode === "edit" && Number(form.templateType) === TEMPLATE_TYPE_BUILTIN
+ );
async function loadTemplateTypeOptions() {
try {
@@ -152,6 +145,7 @@
name: "鍒犻櫎",
type: "danger",
link: true,
+ disabled: (row) => isBuiltinTemplate(row),
clickFun: (row) => removeTemplate(row),
},
],
@@ -198,18 +192,25 @@
Object.assign(form, base);
return;
}
+ const formConfigData = JSON.parse(
+ JSON.stringify(row.formConfigData || parseFormConfigToData(row.formConfig))
+ );
+ const builtin = isBuiltinTemplate(row);
Object.assign(form, {
...base,
id: row.id,
templateName: row.templateName || "",
description: row.description || "",
+ templateType: row.templateType != null ? Number(row.templateType) : base.templateType,
businessType: row.businessType ?? "",
formConfig: row.formConfig || "",
- formConfigData: JSON.parse(
- JSON.stringify(row.formConfigData || parseFormConfigToData(row.formConfig))
- ),
+ formConfigData,
+ lockedFormFieldUids: builtin
+ ? (formConfigData.fields || []).map((f) => f._uid).filter(Boolean)
+ : [],
enabled: row.enabled !== false,
flowNodes: JSON.parse(JSON.stringify(row.flowNodes || [base.flowNodes[0]])),
+ storageBlobDTOs: JSON.parse(JSON.stringify(row.storageBlobDTOs || [])),
});
}
@@ -269,6 +270,10 @@
}
async function removeTemplate(row) {
+ if (isBuiltinTemplate(row)) {
+ ElMessage.warning("绯荤粺鍐呯疆妯℃澘涓嶅厑璁稿垹闄�");
+ return;
+ }
if (row?.id == null || row.id === "") {
ElMessage.warning("鏃犳硶鍒犻櫎锛氱己灏戞ā鏉� ID");
return;
@@ -315,6 +320,7 @@
form,
formRef,
formRules,
+ isEditingBuiltin,
detailDialog,
detailRow,
detailLoading,
--
Gitblit v1.9.3