| | |
| | | :title="dialogTitle" |
| | | :width="step === formStep ? 720 : 640" |
| | | append-to-body |
| | | destroy-on-close |
| | | class="approval-template-bind-dialog" |
| | | @closed="onClosed" |
| | | > |
| | | <template v-if="step === 1"> |
| | | <ApprovalTemplatePicker |
| | | :cards="templateCards" |
| | | :loading="templatesLoading" |
| | | :hint="pickerHint" |
| | | @pick="onPickTemplate" |
| | | /> |
| | | <div v-loading="templatesLoading || confirming"> |
| | | <ApprovalTemplatePicker |
| | | :cards="templateCards" |
| | | :loading="false" |
| | | :hint="pickerHint" |
| | | @pick="onPickTemplate" |
| | | /> |
| | | </div> |
| | | </template> |
| | | |
| | | <template v-else> |
| | |
| | | visible: { type: Boolean, default: false }, |
| | | /** approvalModuleRegistry 中的 moduleKey */ |
| | | moduleKey: { type: String, required: true }, |
| | | /** 为 true 时选模板后直接确认,跳过「确认审批信息」填报步骤 */ |
| | | skipFormConfirm: { type: Boolean, default: false }, |
| | | }); |
| | | |
| | | const emit = defineEmits(["update:visible", "confirm"]); |
| | | const emit = defineEmits(["update:visible", "confirm", "closed"]); |
| | | |
| | | const dialogVisible = computed({ |
| | | get: () => props.visible, |
| | |
| | | step.value = 1; |
| | | await Promise.all([loadTemplates(), loadFlowUsers()]); |
| | | const cfg = getApprovalModuleConfig(props.moduleKey); |
| | | if (!cfg) ElMessage.warning(`未配置模块「${props.moduleKey}」,请检查 approvalModuleRegistry`); |
| | | if (!cfg) { |
| | | ElMessage.warning(`未配置模块「${props.moduleKey}」,请检查 approvalModuleRegistry`); |
| | | return; |
| | | } |
| | | if (!templateCards.value.length) { |
| | | ElMessage.warning( |
| | | `「${cfg.label}」下暂无已启用的审批模板,请先在审批模板管理中创建并启用对应类型的模板` |
| | | ); |
| | | } |
| | | } |
| | | ); |
| | | |
| | | async function onPickTemplate(card) { |
| | | const ok = await pickTemplate(card); |
| | | if (ok) step.value = formStep; |
| | | if (!ok) return; |
| | | if (props.skipFormConfirm) { |
| | | step.value = 1; |
| | | await onConfirm(); |
| | | return; |
| | | } |
| | | step.value = formStep; |
| | | } |
| | | |
| | | async function onConfirm() { |
| | | confirming.value = true; |
| | | try { |
| | | const check = await validateBinding(formRef.value); |
| | | const check = await validateBinding(props.skipFormConfirm ? null : formRef.value); |
| | | if (!check.ok) { |
| | | if (check.message) ElMessage.warning(check.message); |
| | | return; |
| | |
| | | |
| | | function onClosed() { |
| | | resetBinding(); |
| | | emit("closed"); |
| | | } |
| | | </script> |
| | | |