You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
52 lines
1.4 KiB
52 lines
1.4 KiB
<template> |
|
<BasicModal v-bind="$attrs" @register="registerModal" :title="getTitle" @ok="handleSubmit"> |
|
<BasicForm @register="registerForm"/> |
|
</BasicModal> |
|
</template> |
|
|
|
<script lang="ts" setup> |
|
import {ref, computed, unref} from 'vue'; |
|
import {BasicModal, useModalInner} from '/@/components/Modal'; |
|
import {doctorFormSchema} from './doctor.data'; |
|
import {BasicForm, useForm} from '/@/components/Form'; |
|
import {set} from '/@/api/platform/system/controller/doctor'; |
|
const isUpdate = ref(true); |
|
// 定义emit |
|
const emit = defineEmits(['success', 'register']); |
|
/** |
|
* 表单 |
|
*/ |
|
const [registerForm, {resetFields, setFieldsValue, validate}] = useForm({ |
|
labelWidth: 100, |
|
schemas: doctorFormSchema, |
|
showActionButtonGroup: false, |
|
actionColOptions: { |
|
span: 23, |
|
}, |
|
}); |
|
/** |
|
* 表单参数 |
|
*/ |
|
const [registerModal, {setModalProps, closeModal}] = useModalInner(async (data) => { |
|
resetFields(); |
|
setModalProps({confirmLoading: false}); |
|
isUpdate.value = !!data?.isUpdate; |
|
console.log(data.record); |
|
if (unref(isUpdate)) { |
|
setFieldsValue(data.record); |
|
} |
|
}) |
|
//表单标题 |
|
const getTitle = computed(() => (!unref(isUpdate) ? '新增医生' : '编辑医生')); |
|
async function handleSubmit() { |
|
try { |
|
const values = await validate(); |
|
setModalProps({confirmLoading: true}); |
|
await set(values);//保存网卡 |
|
closeModal(); |
|
emit('success'); |
|
} finally { |
|
setModalProps({confirmLoading: false}); |
|
} |
|
} |
|
</script> |