| | |
| | | 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_TYPE_OPTIONS, |
| | | approvalStatusLabel, |
| | |
| | | mapInstanceFromApi, |
| | | mapSubmitTemplateCard, |
| | | matchBusinessTypeValue, |
| | | validateSubmitFlowNodes, |
| | | unwrapInstancePage, |
| | | } from "./approveListConstants.js"; |
| | | |
| | |
| | | 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 }, |
| | |
| | | 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 { |
| | |
| | | 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) { |
| | |
| | | submitForm, |
| | | activeTemplate: activeTemplate.value, |
| | | userStore, |
| | | flowNodes: flowCheck.nodes, |
| | | flowNodes: bindingCheck.nodes, |
| | | }) |
| | | ); |
| | | submitDialog.visible = false; |
| | |
| | | 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) { |
| | |
| | | buildInstanceDto({ |
| | | submitForm, |
| | | activeTemplate: activeTemplate.value, |
| | | flowNodes: flowCheck.nodes, |
| | | flowNodes: bindingCheck.nodes, |
| | | existingRow: submitEditRow.value, |
| | | }) |
| | | ); |