| | |
| | | }); |
| | | |
| | | /** 重新挂载 schema 并按表单态控制底部按钮 */ |
| | | const mainActionText = computed(() => { |
| | | if (isConfirm.value) return '确认'; |
| | | if (isFinish.value) return '完成'; |
| | | return '提交'; |
| | | }); |
| | | |
| | | const showMainBtn = computed(() => isEditable.value || isConfirm.value || isFinish.value); |
| | | |
| | | function applySchema() { |
| | | formApi.setState({ schema: useFormSchema(formType.value, formApi) }); |
| | | const showBtn = isEditable.value || isConfirm.value || isFinish.value; |
| | | modalApi.setState({ |
| | | showConfirmButton: showBtn, |
| | | confirmText: isConfirm.value || canConfirm.value |
| | | ? '确认' |
| | | : isFinish.value |
| | | ? '完成' |
| | | : isCreateMode.value |
| | | ? '新增' |
| | | : '保存', |
| | | }); |
| | | modalApi.setState({ showCancelButton: false, showConfirmButton: false }); |
| | | } |
| | | |
| | | /** 仅保存(不改变状态) */ |
| | |
| | | </Tabs> |
| | | </template> |
| | | <template #prepend-footer> |
| | | <Button v-if="canConfirm" |
| | | @click="handleSave"> |
| | | 保存 |
| | | </Button> |
| | | <Button v-if="formType === 'detail' && formData?.id" |
| | | @click="handleBarcode"> |
| | | 查看条码 |
| | | </Button> |
| | | <div class="flex flex-auto items-center"> |
| | | <Button v-if="showMainBtn" |
| | | type="primary" |
| | | @click="modalApi.onConfirm()"> |
| | | {{ mainActionText }} |
| | | </Button> |
| | | </div> |
| | | </template> |
| | | <template #append-footer> |
| | | <div class="flex gap-2"> |
| | | <Button v-if="canConfirm" |
| | | @click="handleSave"> |
| | | 保存修改 |
| | | </Button> |
| | | <Button v-if="formType === 'detail' && formData?.id" |
| | | @click="handleBarcode"> |
| | | 查看条码 |
| | | </Button> |
| | | <Button @click="modalApi.close()">取消</Button> |
| | | </div> |
| | | </template> |
| | | </Modal> |
| | | <BarcodeDetail ref="barcodeDetailRef" /> |