2025-05-08 16:28:06 +08:00
|
|
|
<script lang="ts" setup>
|
|
|
|
|
import { ref } from 'vue';
|
|
|
|
|
|
|
|
|
|
import { useVbenModal } from '@vben/common-ui';
|
|
|
|
|
import { useUserStore } from '@vben/stores';
|
|
|
|
|
|
|
|
|
|
import { message } from 'ant-design-vue';
|
|
|
|
|
|
|
|
|
|
import { useVbenForm } from '#/adapter/form';
|
|
|
|
|
|
2025-05-09 13:17:42 +08:00
|
|
|
import {
|
|
|
|
|
createWarehouseDrugManagement,
|
|
|
|
|
updateWarehouseDrugManagement,
|
|
|
|
|
} from '../api';
|
2025-05-08 16:28:06 +08:00
|
|
|
import { modalFormProps } from '../config/form';
|
|
|
|
|
import {getDrugUseList} from "#/views/doctor/doctor-reception/api";
|
|
|
|
|
|
2025-08-28 11:00:39 +08:00
|
|
|
|
2025-05-08 16:28:06 +08:00
|
|
|
const userStore = useUserStore();
|
|
|
|
|
|
|
|
|
|
const drugTime = ref([]);
|
|
|
|
|
const drugType = ref([]);
|
|
|
|
|
const drugUnit = ref([]);
|
|
|
|
|
const drugFrequency = ref([]);
|
|
|
|
|
getDrugUseList().then((res) => {
|
|
|
|
|
drugTime.value = res.drug_time.map((item) => {
|
|
|
|
|
return {
|
|
|
|
|
label: item.name,
|
|
|
|
|
value: item.id,
|
|
|
|
|
};
|
|
|
|
|
});
|
|
|
|
|
drugType.value = res.drug_use_type.map((item) => {
|
|
|
|
|
return {
|
|
|
|
|
label: item.name,
|
|
|
|
|
value: item.id,
|
|
|
|
|
};
|
|
|
|
|
});
|
|
|
|
|
drugUnit.value = res.drug_unit.map((item) => {
|
|
|
|
|
return {
|
|
|
|
|
label: item.name,
|
|
|
|
|
value: item.id,
|
|
|
|
|
};
|
|
|
|
|
});
|
|
|
|
|
drugFrequency.value = res.drug_use_frequency.map((item) => {
|
|
|
|
|
return {
|
|
|
|
|
label: item.name,
|
|
|
|
|
value: item.id,
|
|
|
|
|
};
|
|
|
|
|
});
|
|
|
|
|
return res;
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
const isUpdate = ref(false);
|
|
|
|
|
const gridApi = ref();
|
|
|
|
|
|
|
|
|
|
const [Form, formApi] = useVbenForm(modalFormProps);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const [Modal, modalApi] = useVbenModal({
|
|
|
|
|
fullscreenButton: false,
|
|
|
|
|
draggable: true,
|
|
|
|
|
onCancel() {
|
|
|
|
|
modalApi.close();
|
|
|
|
|
},
|
|
|
|
|
onConfirm: async () => {
|
|
|
|
|
formApi.validate().then(async (e: any) => {
|
|
|
|
|
if (e.valid) {
|
|
|
|
|
const values = await formApi.getValues();
|
|
|
|
|
modalApi.setState({ loading: true, confirmLoading: true });
|
|
|
|
|
const submitApi = isUpdate.value
|
2025-05-09 13:17:42 +08:00
|
|
|
? updateWarehouseDrugManagement
|
|
|
|
|
: createWarehouseDrugManagement;
|
2025-05-08 16:28:06 +08:00
|
|
|
submitApi(values)
|
|
|
|
|
.then(() => {
|
|
|
|
|
message.success('保存成功');
|
|
|
|
|
gridApi.value?.reload();
|
|
|
|
|
modalApi.close();
|
|
|
|
|
})
|
|
|
|
|
.finally(() => {
|
|
|
|
|
modalApi.setState({ loading: false, confirmLoading: false });
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
await formApi.validateAndSubmitForm();
|
|
|
|
|
},
|
|
|
|
|
onOpenChange(isOpen: boolean) {
|
|
|
|
|
gridApi.value = isOpen ? modalApi.getData()?.gridApi : null;
|
|
|
|
|
if (isOpen) {
|
|
|
|
|
|
|
|
|
|
formApi.updateSchema([
|
|
|
|
|
{
|
|
|
|
|
componentProps: {
|
|
|
|
|
options: drugTime.value,
|
|
|
|
|
},
|
|
|
|
|
fieldName: 'time_id',
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
componentProps: {
|
|
|
|
|
options: drugUnit.value,
|
|
|
|
|
},
|
|
|
|
|
fieldName: 'unit_id',
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
componentProps: {
|
|
|
|
|
options: drugType.value,
|
|
|
|
|
},
|
|
|
|
|
fieldName: 'type_id',
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
componentProps: {
|
|
|
|
|
options: drugFrequency.value,
|
|
|
|
|
},
|
|
|
|
|
fieldName: 'frequency_id',
|
|
|
|
|
},
|
|
|
|
|
]);
|
|
|
|
|
const { values, update } = modalApi.getData<Record<string, any>>();
|
|
|
|
|
if (values) {
|
|
|
|
|
console.log(values, 'sssssssssssss')
|
|
|
|
|
isUpdate.value = update;
|
|
|
|
|
formApi.setValues(values);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
});
|
|
|
|
|
</script>
|
|
|
|
|
<template>
|
|
|
|
|
<Modal
|
|
|
|
|
:title="`${isUpdate === true ? '编辑' : '新增'}西(中成)药`"
|
|
|
|
|
class="w-[30%]"
|
|
|
|
|
>
|
|
|
|
|
<Form />
|
|
|
|
|
</Modal>
|
|
|
|
|
</template>
|