| | |
| | | } from "../approve-list/approveListConstants.js"; |
| | | import { |
| | | getApprovalModuleConfig, |
| | | getModuleMatchingBusinessTypes, |
| | | resolveModuleBusinessType, |
| | | } from "./approvalModuleRegistry.js"; |
| | | import { |
| | |
| | | return ""; |
| | | }); |
| | | |
| | | const matchingBusinessTypes = computed(() => { |
| | | if (fixedBusinessType != null && fixedBusinessType !== "") return [fixedBusinessType]; |
| | | if (isUniversal) { |
| | | const t = selectedBusinessType.value; |
| | | return t != null && t !== "" ? [t] : []; |
| | | } |
| | | if (moduleKey) { |
| | | return getModuleMatchingBusinessTypes(moduleKey, businessTypeOptions.value); |
| | | } |
| | | const t = resolvedBusinessType.value; |
| | | return t != null && t !== "" ? [t] : []; |
| | | }); |
| | | |
| | | const templateCards = computed(() => { |
| | | const type = resolvedBusinessType.value; |
| | | if (type == null || type === "") return []; |
| | | return allTemplates.value.filter((card) => matchBusinessTypeValue(card.businessType, type)); |
| | | const types = matchingBusinessTypes.value; |
| | | if (!types.length) return []; |
| | | return allTemplates.value.filter((card) => |
| | | types.some( |
| | | (t) => |
| | | matchBusinessTypeValue(card.businessType, t) || |
| | | matchBusinessTypeValue(card.approvalType, t) |
| | | ) |
| | | ); |
| | | }); |
| | | |
| | | const activeTemplate = computed(() => bindingForm.templateSnapshot || null); |
| | |
| | | const selectedBusinessTypeLabel = computed(() => businessTypeLabel(resolvedBusinessType.value)); |
| | | |
| | | function countTemplatesByBusinessType(type) { |
| | | return allTemplates.value.filter((card) => matchBusinessTypeValue(card.businessType, type)).length; |
| | | const types = |
| | | moduleKey && !fixedBusinessType |
| | | ? getModuleMatchingBusinessTypes(moduleKey, businessTypeOptions.value) |
| | | : [type]; |
| | | return allTemplates.value.filter((card) => |
| | | types.some( |
| | | (t) => |
| | | matchBusinessTypeValue(card.businessType, t) || |
| | | matchBusinessTypeValue(card.approvalType, t) |
| | | ) |
| | | ).length; |
| | | } |
| | | |
| | | async function loadTemplates() { |