fix: 仓库药品管理
This commit is contained in:
@@ -6,7 +6,7 @@ const prefix = 'warehouse-drug-management/';
|
||||
* 分页查询用户列表
|
||||
* @param data
|
||||
*/
|
||||
export async function getWesternMedicineList(data: any) {
|
||||
export async function getWarehouseDrugManagementList(data: any) {
|
||||
return requestClient.get<any>(`${prefix}list`, { params: data });
|
||||
}
|
||||
|
||||
@@ -14,7 +14,7 @@ export async function getWesternMedicineList(data: any) {
|
||||
* 分页查询用户列表
|
||||
* @param data
|
||||
*/
|
||||
export async function getWesternMedicineOption(data: any) {
|
||||
export async function getWarehouseDrugManagementOption(data: any) {
|
||||
return requestClient.get<any>(`${prefix}option`, { params: data });
|
||||
}
|
||||
|
||||
@@ -22,22 +22,28 @@ export async function getWesternMedicineOption(data: any) {
|
||||
* 获取西(中成)药详情
|
||||
* @param id
|
||||
*/
|
||||
export async function getWesternMedicineInfo(id: number) {
|
||||
export async function getWarehouseDrugManagementInfo(id: number) {
|
||||
return requestClient.get<any>(`${prefix}detail`, { params: { id } });
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出西药药品
|
||||
* 导出仓库药品药品
|
||||
*/
|
||||
export async function exportWesternMedicineApi() {
|
||||
export async function exportWarehouseDrugManagementApi() {
|
||||
return requestClient.download(`${prefix}export`);
|
||||
}
|
||||
/**
|
||||
* 导出仓库药品药品 - 模板
|
||||
*/
|
||||
export async function exportWarehouseDrugManagementTemplateApi() {
|
||||
return requestClient.download(`${prefix}export-template`);
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增西(中成)药
|
||||
* @param data
|
||||
*/
|
||||
export async function createWesternMedicine(data: Record<string, any>) {
|
||||
export async function createWarehouseDrugManagement(data: Record<string, any>) {
|
||||
return requestClient.post<any>(`${prefix}create`, data);
|
||||
}
|
||||
|
||||
@@ -45,7 +51,7 @@ export async function createWesternMedicine(data: Record<string, any>) {
|
||||
* 编辑西(中成)药
|
||||
* @param data
|
||||
*/
|
||||
export async function updateWesternMedicine(data: Record<string, any>) {
|
||||
export async function updateWarehouseDrugManagement(data: Record<string, any>) {
|
||||
return requestClient.post<any>(`${prefix}update`, data);
|
||||
}
|
||||
|
||||
@@ -53,14 +59,22 @@ export async function updateWesternMedicine(data: Record<string, any>) {
|
||||
* 删除西(中成)药
|
||||
* @param data
|
||||
*/
|
||||
export async function deleteWesternMedicine(data: Record<string, any>) {
|
||||
export async function deleteWarehouseDrugManagement(data: Record<string, any>) {
|
||||
return requestClient.post<any>(`${prefix}delete`, data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 导入西药
|
||||
* 导入仓库药品
|
||||
* @param data
|
||||
*/
|
||||
export async function importWesternMedicineApi(data: Record<string, any>) {
|
||||
export async function importWarehouseDrugManagementApi(data: Record<string, any>) {
|
||||
return requestClient.upload(`${prefix}import`, data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 导入仓库药品修改价格
|
||||
* @param data
|
||||
*/
|
||||
export async function importUpdatePriceApi(data: Record<string, any>) {
|
||||
return requestClient.upload(`${prefix}import-update-price`, data);
|
||||
}
|
||||
|
||||
@@ -3,28 +3,26 @@ import { ref } from 'vue';
|
||||
|
||||
import { useVbenModal } from '@vben/common-ui';
|
||||
|
||||
import { message, UploadDragger } from 'ant-design-vue';
|
||||
import {
|
||||
Button,
|
||||
message,
|
||||
type UploadChangeParam,
|
||||
UploadDragger,
|
||||
} from 'ant-design-vue';
|
||||
|
||||
import { importWesternMedicineApi } from '../api';
|
||||
import { downloadByData } from '#/util/tool';
|
||||
|
||||
import {
|
||||
exportWarehouseDrugManagementTemplateApi,
|
||||
importUpdatePriceApi,
|
||||
importWarehouseDrugManagementApi,
|
||||
} from '../api';
|
||||
|
||||
const gridApi = ref();
|
||||
const passApplication = ref();
|
||||
const importType = ref(1);
|
||||
const fileList = ref([]);
|
||||
|
||||
const importWesternMedicine = (file) => {
|
||||
const submitApi = importWesternMedicineApi;
|
||||
submitApi({
|
||||
file: file.file,
|
||||
})
|
||||
.then(() => {
|
||||
message.success('导入成功');
|
||||
gridApi.value?.reload();
|
||||
modalApi.close();
|
||||
})
|
||||
.finally(() => {
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
const [Modal, modalApi] = useVbenModal({
|
||||
fullscreenButton: false,
|
||||
draggable: true,
|
||||
@@ -33,30 +31,73 @@ const [Modal, modalApi] = useVbenModal({
|
||||
},
|
||||
onConfirm: async () => {
|
||||
modalApi.setState({ loading: true, confirmLoading: true });
|
||||
const submitApi = importWesternMedicineApi;
|
||||
submitApi({
|
||||
file: fileList.value,
|
||||
})
|
||||
.then(() => {
|
||||
message.success('导入成功');
|
||||
gridApi.value?.reload();
|
||||
modalApi.close();
|
||||
})
|
||||
.finally(() => {
|
||||
modalApi.setState({ loading: false, confirmLoading: false });
|
||||
});
|
||||
gridApi.value?.reload();
|
||||
modalApi.close();
|
||||
},
|
||||
onOpenChange(isOpen: boolean) {
|
||||
gridApi.value = isOpen ? modalApi.getData()?.gridApi : null;
|
||||
passApplication.value = isOpen ? modalApi.getData()?.passApplication : null;
|
||||
importType.value = isOpen ? modalApi.getData()?.type : 1;
|
||||
fileList.value = [];
|
||||
},
|
||||
});
|
||||
|
||||
const importWarehouseDrugManagement = ({ file, onSuccess }) => {
|
||||
modalApi.setState({ loading: true, confirmLoading: true });
|
||||
const submitApi =
|
||||
importType.value === 1
|
||||
? importWarehouseDrugManagementApi
|
||||
: importUpdatePriceApi;
|
||||
submitApi({
|
||||
file,
|
||||
})
|
||||
.then(() => {
|
||||
onSuccess('ok', { status: 'done' });
|
||||
})
|
||||
.catch(() => {
|
||||
onSuccess('error', { status: 'error' });
|
||||
})
|
||||
.finally(() => {
|
||||
modalApi.setState({ loading: false, confirmLoading: false });
|
||||
});
|
||||
};
|
||||
const handleChange = (info: UploadChangeParam) => {
|
||||
if (info.file.status === 'uploading') {
|
||||
return;
|
||||
}
|
||||
if (info.file.status === 'done') {
|
||||
message.success('上传成功');
|
||||
}
|
||||
if (info.file.status === 'error') {
|
||||
message.error('upload error');
|
||||
}
|
||||
};
|
||||
|
||||
const exportWarehouseDrugManagementTemplate = () => {
|
||||
exportWarehouseDrugManagementTemplateApi().then((res) => {
|
||||
// 创建新的URL表示指定的File对象或者Blob对象。
|
||||
downloadByData(
|
||||
res.data,
|
||||
'萧康云医-仓库商品导入模板结果导出(只包含未导入的药品).xlsx',
|
||||
);
|
||||
message.success('导出成功!');
|
||||
});
|
||||
};
|
||||
</script>
|
||||
<template>
|
||||
<Modal class="w-[30%]" title="上传Excel">
|
||||
<Modal class="w-[30%]" :title="importType === 1 ? '上传Excel' : '批量修改价格'">
|
||||
<Button v-if="importType === 1" type="link" @click="exportWarehouseDrugManagementTemplate">
|
||||
下载位同步到仓库药品的导入模板
|
||||
</Button>
|
||||
<Button v-if="importType === 2" type="link" @click="passApplication">
|
||||
下载修改价格模板
|
||||
</Button>
|
||||
<UploadDragger
|
||||
class="mt-6"
|
||||
v-model:file-list="fileList"
|
||||
:custom-request="importWesternMedicine"
|
||||
:custom-request="importWarehouseDrugManagement"
|
||||
:max-count="1"
|
||||
:on-change="handleChange"
|
||||
name="file"
|
||||
>
|
||||
<p class="flex justify-center">
|
||||
|
||||
@@ -8,7 +8,10 @@ import { message } from 'ant-design-vue';
|
||||
|
||||
import { useVbenForm } from '#/adapter/form';
|
||||
|
||||
import { createWesternMedicine, updateWesternMedicine } from '../api';
|
||||
import {
|
||||
createWarehouseDrugManagement,
|
||||
updateWarehouseDrugManagement,
|
||||
} from '../api';
|
||||
import { modalFormProps } from '../config/form';
|
||||
import {getDrugUseList} from "#/views/doctor/doctor-reception/api";
|
||||
|
||||
@@ -67,8 +70,8 @@ const [Modal, modalApi] = useVbenModal({
|
||||
const values = await formApi.getValues();
|
||||
modalApi.setState({ loading: true, confirmLoading: true });
|
||||
const submitApi = isUpdate.value
|
||||
? updateWesternMedicine
|
||||
: createWesternMedicine;
|
||||
? updateWarehouseDrugManagement
|
||||
: createWarehouseDrugManagement;
|
||||
submitApi(values)
|
||||
.then(() => {
|
||||
message.success('保存成功');
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
import type {VbenFormProps} from '#/adapter/form';
|
||||
|
||||
import {getSupplierOption} from '#/views/system/supplier/api';
|
||||
import {
|
||||
getWarehouseDrugManagementOption
|
||||
} from "#/views/business/warehouse-drug-management/admin/api";
|
||||
|
||||
|
||||
export const modalFormProps: VbenFormProps = {
|
||||
@@ -25,26 +28,14 @@ export const modalFormProps: VbenFormProps = {
|
||||
triggerFields: ['id'],
|
||||
},
|
||||
},
|
||||
{
|
||||
component: 'VbenInput',
|
||||
fieldName: 'showSelect',
|
||||
label: 'ID',
|
||||
formItemClass: 'col-span-6',
|
||||
dependencies: {
|
||||
show: false,
|
||||
triggerFields: ['id'],
|
||||
},
|
||||
},
|
||||
{
|
||||
component: 'Avatar',
|
||||
fieldName: 'image',
|
||||
label: '产品图片',
|
||||
rules: 'required',
|
||||
formItemClass: 'col-span-6',
|
||||
},
|
||||
{
|
||||
component: 'ApiSelect',
|
||||
fieldName: 'drug_id',
|
||||
label: '选择加入的药品',
|
||||
formItemClass: 'col-span-12',
|
||||
rules: 'required',
|
||||
componentProps: {
|
||||
api: getWarehouseDrugManagementOption,
|
||||
allowClear: true,
|
||||
showSearch: true,
|
||||
filterOption: (input: string, option: any) => {
|
||||
@@ -52,145 +43,40 @@ export const modalFormProps: VbenFormProps = {
|
||||
return option?.label.toLowerCase().indexOf(input.toLowerCase()) >= 0;
|
||||
},
|
||||
// 菜单接口转options格式
|
||||
afterFetch: (data: { id: number; name: string }[]) => {
|
||||
afterFetch: (data: { drug_name: string; id: number }[]) => {
|
||||
return data.map((item: any) => ({
|
||||
label: item.name,
|
||||
label: `${item.drug_name}【${item.pinyin_simple}】`,
|
||||
value: item.id,
|
||||
}));
|
||||
},
|
||||
api: getSupplierOption,
|
||||
placeholder: '请选择',
|
||||
},
|
||||
fieldName: 'supplier_id',
|
||||
formItemClass: 'col-span-6',
|
||||
label: '所属供应商',
|
||||
rules: 'required',
|
||||
dependencies: {
|
||||
show(formValues: any) {
|
||||
return !formValues.id;
|
||||
},
|
||||
triggerFields: ['id'],
|
||||
},
|
||||
},
|
||||
{
|
||||
component: 'VbenInput',
|
||||
componentProps: {
|
||||
placeholder: '请输入药品昵称',
|
||||
placeholder: '请输入供货价格',
|
||||
},
|
||||
fieldName: 'drug_name',
|
||||
formItemClass: 'col-span-6',
|
||||
label: '药品昵称',
|
||||
rules: 'required',
|
||||
},
|
||||
{
|
||||
component: 'VbenInput',
|
||||
componentProps: {
|
||||
placeholder: '请输入药品别名',
|
||||
},
|
||||
fieldName: 'drug_alias',
|
||||
formItemClass: 'col-span-6',
|
||||
label: '药品别名',
|
||||
rules: 'required',
|
||||
},
|
||||
{
|
||||
component: 'VbenInput',
|
||||
componentProps: {
|
||||
placeholder: '请输入药品编号',
|
||||
},
|
||||
fieldName: 'drug_number',
|
||||
formItemClass: 'col-span-6',
|
||||
label: '药品编号',
|
||||
rules: 'required',
|
||||
},
|
||||
{
|
||||
component: 'VbenInput',
|
||||
componentProps: {
|
||||
placeholder: '请输入规格',
|
||||
},
|
||||
fieldName: 'specification',
|
||||
formItemClass: 'col-span-6',
|
||||
label: '规格',
|
||||
rules: 'required',
|
||||
},
|
||||
{
|
||||
component: 'VbenSelect',
|
||||
componentProps: {
|
||||
options: [],
|
||||
placeholder: '请选择',
|
||||
},
|
||||
fieldName: 'time_id',
|
||||
formItemClass: 'col-span-6',
|
||||
label: '使用时间',
|
||||
rules: 'required',
|
||||
},
|
||||
{
|
||||
component: 'VbenSelect',
|
||||
componentProps: {
|
||||
options: [],
|
||||
placeholder: '请选择',
|
||||
},
|
||||
fieldName: 'type_id',
|
||||
formItemClass: 'col-span-6',
|
||||
label: '使用方法',
|
||||
rules: 'required',
|
||||
},
|
||||
{
|
||||
component: 'VbenSelect',
|
||||
componentProps: {
|
||||
options: [],
|
||||
placeholder: '请选择',
|
||||
},
|
||||
fieldName: 'unit_id',
|
||||
formItemClass: 'col-span-6',
|
||||
label: '单位',
|
||||
rules: 'required',
|
||||
},
|
||||
{
|
||||
component: 'VbenSelect',
|
||||
componentProps: {
|
||||
options: [],
|
||||
placeholder: '请选择',
|
||||
},
|
||||
fieldName: 'frequency_id',
|
||||
formItemClass: 'col-span-6',
|
||||
label: '频率',
|
||||
rules: 'required',
|
||||
},
|
||||
{
|
||||
component: 'RadioGroup',
|
||||
componentProps: {
|
||||
placeholder: '请选择',
|
||||
options: [
|
||||
{
|
||||
label: '草稿',
|
||||
value: 1,
|
||||
},
|
||||
{
|
||||
label: '下架',
|
||||
value: 2,
|
||||
},
|
||||
{
|
||||
label: '上架',
|
||||
value: 3,
|
||||
},
|
||||
],
|
||||
},
|
||||
defaultValue: 1,
|
||||
fieldName: 'market_price',
|
||||
formItemClass: 'col-span-12',
|
||||
fieldName: 'status',
|
||||
label: '商品状态',
|
||||
label: '供货价格',
|
||||
rules: 'required',
|
||||
},
|
||||
{
|
||||
component: 'Textarea',
|
||||
component: 'VbenInput',
|
||||
componentProps: {
|
||||
placeholder: '请输入药品主治功能',
|
||||
placeholder: '请输入价格',
|
||||
},
|
||||
fieldName: 'function',
|
||||
label: '药品主治功能',
|
||||
fieldName: 'price',
|
||||
formItemClass: 'col-span-12',
|
||||
label: '价格',
|
||||
rules: 'required',
|
||||
},
|
||||
{
|
||||
component: 'Avatar',
|
||||
fieldName: 'instruction',
|
||||
label: '产品说明书',
|
||||
rules: 'required',
|
||||
formItemClass: 'col-span-6',
|
||||
},
|
||||
],
|
||||
showDefaultActions: false,
|
||||
};
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import type { VxeGridProps } from '#/adapter/vxe-table';
|
||||
|
||||
import { getWesternMedicineList } from '../api';
|
||||
import {getWarehouseDrugManagementList} from '../api';
|
||||
|
||||
interface RowType {
|
||||
id: string;
|
||||
@@ -33,6 +33,8 @@ export const gridOptions: VxeGridProps<RowType> = {
|
||||
slots: { default: 'image' },
|
||||
width: 130,
|
||||
},
|
||||
{ field: 'market_price', title: '供货价' },
|
||||
{ field: 'price', title: '建议售价' },
|
||||
{ field: 'status', title: '状态', slots: { default: 'status' } },
|
||||
{ field: 'created_at', title: '创建时间' },
|
||||
{ type: 'html', title: '操作', slots: { default: 'action' } },
|
||||
@@ -43,7 +45,7 @@ export const gridOptions: VxeGridProps<RowType> = {
|
||||
ajax: {
|
||||
// 请求后端接口方法
|
||||
query: async ({ page }, formValues) => {
|
||||
return await getWesternMedicineList({
|
||||
return await getWarehouseDrugManagementList({
|
||||
page: page.currentPage,
|
||||
pageSize: page.pageSize,
|
||||
...formValues,
|
||||
|
||||
@@ -11,7 +11,7 @@ import { useVbenVxeGrid } from '#/adapter/vxe-table';
|
||||
import { TableAction } from '#/components/table-action';
|
||||
import { downloadByData } from '#/util/tool';
|
||||
|
||||
import { deleteWesternMedicine, exportWesternMedicineApi } from './api';
|
||||
import { deleteWarehouseDrugManagement, exportWarehouseDrugManagementApi } from './api';
|
||||
import FormModalDemo from './components/modal.vue';
|
||||
import ExcelUpload from './components/ExcelUpload.vue';
|
||||
import { formOptions } from './config/search';
|
||||
@@ -63,26 +63,28 @@ const deleteApi = (row: any) => {
|
||||
} else {
|
||||
ids = gridApi.grid.getCheckboxRecords().map((item) => item.id);
|
||||
}
|
||||
deleteWesternMedicine({ ids }).then(() => {
|
||||
deleteWarehouseDrugManagement({ ids }).then(() => {
|
||||
message.success('删除成功!');
|
||||
gridApi.reload();
|
||||
});
|
||||
};
|
||||
/**
|
||||
* 西药导出
|
||||
* 导出
|
||||
*/
|
||||
const passApplication = () => {
|
||||
// 新标签跳转到 exportWesternMedicineApi
|
||||
exportWesternMedicineApi().then((res) => {
|
||||
// 新标签跳转到 exportWarehouseDrugManagementApi
|
||||
exportWarehouseDrugManagementApi().then((res) => {
|
||||
// 创建新的URL表示指定的File对象或者Blob对象。
|
||||
downloadByData(res.data, '萧康云医-西药导出.xlsx');
|
||||
downloadByData(res.data, '萧康云医-仓库商品导出.xlsx');
|
||||
message.success('导出成功!');
|
||||
});
|
||||
};
|
||||
|
||||
const openExcelUploadModal = () => {
|
||||
const openExcelUploadModal = (type = 1) => {
|
||||
ExcelUploadModalApi.setData({
|
||||
gridApi,
|
||||
type,
|
||||
passApplication,
|
||||
});
|
||||
ExcelUploadModalApi.open();
|
||||
};
|
||||
@@ -108,7 +110,14 @@ const openExcelUploadModal = () => {
|
||||
type: 'primary',
|
||||
icon: 'ix:export-check',
|
||||
// auth: ['超级西(中成)药', 'sys:user:save'],
|
||||
onClick: openExcelUploadModal.bind(null),
|
||||
onClick: openExcelUploadModal.bind(null, 1),
|
||||
},
|
||||
{
|
||||
label: '批量修改价格',
|
||||
type: 'primary',
|
||||
icon: 'ix:export-check',
|
||||
// auth: ['超级西(中成)药', 'sys:user:save'],
|
||||
onClick: openExcelUploadModal.bind(null, 2),
|
||||
},
|
||||
{
|
||||
label: '导出',
|
||||
|
||||
Reference in New Issue
Block a user