| | |
| | | |
| | | type CancellationFormModalData = { |
| | | cancellation?: Pick<CrmCancellationApi.Cancellation, 'id'>; |
| | | /** 只读模式:审核通过的销户申请仅允许查看详情 */ |
| | | readonly?: boolean; |
| | | }; |
| | | |
| | | const emit = defineEmits(['success']); |
| | | const formData = ref<Partial<CrmCancellationApi.Cancellation>>(); |
| | | const readonly = ref(false); |
| | | const getTitle = computed(() => { |
| | | if (readonly.value) { |
| | | return '销户申请详情'; |
| | | } |
| | | return formData.value?.id |
| | | ? $t('ui.actionTitle.edit', ['销户申请']) |
| | | : $t('ui.actionTitle.create', ['销户申请']); |
| | |
| | | async onOpenChange(isOpen: boolean) { |
| | | if (!isOpen) { |
| | | formData.value = undefined; |
| | | readonly.value = false; |
| | | return; |
| | | } |
| | | formApi.setState({ schema: useFormSchema(formApi) }); |
| | | await formApi.resetForm(); |
| | | const data = modalApi.getData() as null | CancellationFormModalData; |
| | | // 只读详情:禁用全部字段并隐藏「确定」按钮;编辑/新增则恢复可操作 |
| | | readonly.value = !!data?.readonly; |
| | | formApi.setDisabled(readonly.value); |
| | | modalApi.setState({ showConfirmButton: !readonly.value }); |
| | | if (!data?.cancellation?.id) { |
| | | return; |
| | | } |