From d7a446d3f9ae84329d02fe33695cb1075cb2a5a1 Mon Sep 17 00:00:00 2001 From: lq Date: Thu, 8 May 2025 16:28:06 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BB=93=E5=BA=93=E8=8D=AF=E5=93=81?= =?UTF-8?q?=E7=AE=A1=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../admin/api/index.ts | 66 ++++++ .../admin/components/ExcelUpload.vue | 131 +++++++++++ .../admin/components/modal.vue | 132 +++++++++++ .../admin/config/form.ts | 222 ++++++++++++++++++ .../admin/config/search.ts | 60 +++++ .../admin/config/table.ts | 77 ++++++ .../warehouse-drug-management/admin/index.vue | 204 ++++++++++++++++ 7 files changed, 892 insertions(+) create mode 100644 apps/web-antd/src/views/business/warehouse-drug-management/admin/api/index.ts create mode 100644 apps/web-antd/src/views/business/warehouse-drug-management/admin/components/ExcelUpload.vue create mode 100644 apps/web-antd/src/views/business/warehouse-drug-management/admin/components/modal.vue create mode 100644 apps/web-antd/src/views/business/warehouse-drug-management/admin/config/form.ts create mode 100644 apps/web-antd/src/views/business/warehouse-drug-management/admin/config/search.ts create mode 100644 apps/web-antd/src/views/business/warehouse-drug-management/admin/config/table.ts create mode 100644 apps/web-antd/src/views/business/warehouse-drug-management/admin/index.vue diff --git a/apps/web-antd/src/views/business/warehouse-drug-management/admin/api/index.ts b/apps/web-antd/src/views/business/warehouse-drug-management/admin/api/index.ts new file mode 100644 index 00000000..2b2904d1 --- /dev/null +++ b/apps/web-antd/src/views/business/warehouse-drug-management/admin/api/index.ts @@ -0,0 +1,66 @@ +import { requestClient } from '#/api/request'; + +const prefix = 'warehouse-drug-management/'; + +/** + * 分页查询用户列表 + * @param data + */ +export async function getWesternMedicineList(data: any) { + return requestClient.get(`${prefix}list`, { params: data }); +} + +/** + * 分页查询用户列表 + * @param data + */ +export async function getWesternMedicineOption(data: any) { + return requestClient.get(`${prefix}option`, { params: data }); +} + +/** + * 获取西(中成)药详情 + * @param id + */ +export async function getWesternMedicineInfo(id: number) { + return requestClient.get(`${prefix}detail`, { params: { id } }); +} + +/** + * 导出西药药品 + */ +export async function exportWesternMedicineApi() { + return requestClient.download(`${prefix}export`); +} + +/** + * 新增西(中成)药 + * @param data + */ +export async function createWesternMedicine(data: Record) { + return requestClient.post(`${prefix}create`, data); +} + +/** + * 编辑西(中成)药 + * @param data + */ +export async function updateWesternMedicine(data: Record) { + return requestClient.post(`${prefix}update`, data); +} + +/** + * 删除西(中成)药 + * @param data + */ +export async function deleteWesternMedicine(data: Record) { + return requestClient.post(`${prefix}delete`, data); +} + +/** + * 导入西药 + * @param data + */ +export async function importWesternMedicineApi(data: Record) { + return requestClient.upload(`${prefix}import`, data); +} diff --git a/apps/web-antd/src/views/business/warehouse-drug-management/admin/components/ExcelUpload.vue b/apps/web-antd/src/views/business/warehouse-drug-management/admin/components/ExcelUpload.vue new file mode 100644 index 00000000..79597eea --- /dev/null +++ b/apps/web-antd/src/views/business/warehouse-drug-management/admin/components/ExcelUpload.vue @@ -0,0 +1,131 @@ + + diff --git a/apps/web-antd/src/views/business/warehouse-drug-management/admin/components/modal.vue b/apps/web-antd/src/views/business/warehouse-drug-management/admin/components/modal.vue new file mode 100644 index 00000000..ecd3f877 --- /dev/null +++ b/apps/web-antd/src/views/business/warehouse-drug-management/admin/components/modal.vue @@ -0,0 +1,132 @@ + + diff --git a/apps/web-antd/src/views/business/warehouse-drug-management/admin/config/form.ts b/apps/web-antd/src/views/business/warehouse-drug-management/admin/config/form.ts new file mode 100644 index 00000000..6646ed74 --- /dev/null +++ b/apps/web-antd/src/views/business/warehouse-drug-management/admin/config/form.ts @@ -0,0 +1,222 @@ +import type {VbenFormProps} from '#/adapter/form'; + +import {getSupplierOption} from '#/views/system/supplier/api'; + + +export const modalFormProps: VbenFormProps = { + wrapperClass: 'grid-cols-12', // 24栅格, + commonConfig: { + formItemClass: 'col-span-12', + // 所有表单项 + componentProps: { + class: 'w-full', + }, + }, + // handleSubmit: onSubmit, + layout: 'horizontal', + schema: [ + { + component: 'VbenInput', + fieldName: 'id', + label: 'ID', + formItemClass: 'col-span-6', + dependencies: { + show: false, + 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', + componentProps: { + allowClear: true, + showSearch: true, + filterOption: (input: string, option: any) => { + // 自定义过滤逻辑,确保可以根据 name 进行搜索 + return option?.label.toLowerCase().indexOf(input.toLowerCase()) >= 0; + }, + // 菜单接口转options格式 + afterFetch: (data: { id: number; name: string }[]) => { + return data.map((item: any) => ({ + label: item.name, + value: item.id, + })); + }, + api: getSupplierOption, + placeholder: '请选择', + }, + fieldName: 'supplier_id', + formItemClass: 'col-span-6', + label: '所属供应商', + rules: 'required', + }, + { + component: 'VbenInput', + componentProps: { + 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, + formItemClass: 'col-span-12', + fieldName: 'status', + label: '商品状态', + rules: 'required', + }, + { + component: 'Textarea', + componentProps: { + placeholder: '请输入药品主治功能', + }, + fieldName: 'function', + label: '药品主治功能', + rules: 'required', + }, + { + component: 'Avatar', + fieldName: 'instruction', + label: '产品说明书', + rules: 'required', + formItemClass: 'col-span-6', + }, + ], + showDefaultActions: false, +}; +export const uploadExcelProps: VbenFormProps = { + wrapperClass: 'grid-cols-12', // 24栅格, + commonConfig: { + formItemClass: 'col-span-12', + // 所有表单项 + componentProps: { + class: 'w-full', + }, + }, + // handleSubmit: onSubmit, + layout: 'horizontal', + schema: [ + { + component: 'Upload', + componentProps: { + placeholder: '请选择', + multiple: true, + }, + fieldName: 'frequency_id', + formItemClass: 'col-span-12', + label: '导入excel', + rules: 'file', + }, + ], + showDefaultActions: false, +}; diff --git a/apps/web-antd/src/views/business/warehouse-drug-management/admin/config/search.ts b/apps/web-antd/src/views/business/warehouse-drug-management/admin/config/search.ts new file mode 100644 index 00000000..14217fe7 --- /dev/null +++ b/apps/web-antd/src/views/business/warehouse-drug-management/admin/config/search.ts @@ -0,0 +1,60 @@ +import type { VbenFormProps } from '#/adapter/form'; + +// import dayjs from 'dayjs'; + +export const formOptions: VbenFormProps = { + // 默认展开 + collapsed: false, + schema: [ + { + component: 'VbenInput', + componentProps: { + placeholder: '输入名称', + }, + defaultValue: '', + fieldName: 'name', + label: '药名称', + }, + { + component: 'VbenSelect', + componentProps: { + placeholder: '输入名称', + options: [ + { + label: '中药', + value: 1, + }, + { + label: '西药', + value: 2, + }, + { + label: '服务包', + value: 5, + }, + ], + }, + defaultValue: 1, + fieldName: 'type', + label: '类型', + } + // { + // component: 'RangePicker', + // componentProps: { + // format: 'YYYY-MM-DD', // 确保格式与你需要的一致 + // }, + // // defaultValue: [dayjs().startOf('month'), dayjs()], + // fieldName: 'search_time', + // label: '时间范围', + // }, + ], + // 控制表单是否显示折叠按钮 + showCollapseButton: true, + submitButtonOptions: { + content: '查询', + }, + // 是否在字段值改变时提交表单 + submitOnChange: true, + // 按下回车时是否提交表单 + submitOnEnter: false, +}; diff --git a/apps/web-antd/src/views/business/warehouse-drug-management/admin/config/table.ts b/apps/web-antd/src/views/business/warehouse-drug-management/admin/config/table.ts new file mode 100644 index 00000000..8c48faab --- /dev/null +++ b/apps/web-antd/src/views/business/warehouse-drug-management/admin/config/table.ts @@ -0,0 +1,77 @@ +import type { VxeGridProps } from '#/adapter/vxe-table'; + +import { getWesternMedicineList } from '../api'; + +interface RowType { + id: string; + name: string; + logo: string; + introduce: string; + created_at: string; +} + +export const gridOptions: VxeGridProps = { + checkboxConfig: { + highlight: true, + labelField: '', + }, + columnConfig: { + useKey: true, + }, + rowConfig: { + useKey: true, + }, + columns: [ + { type: 'checkbox', width: 60 }, + { field: 'id', align: 'left', title: 'ID', width: 100 }, + { field: 'drug.drug_name', align: 'left', title: '药品名称' }, + { field: 'drug.pinyin_simple', title: '拼音' }, + { + field: 'image', + align: 'left', + title: '产品图片', + slots: { default: 'image' }, + width: 130, + }, + { field: 'status', title: '状态', slots: { default: 'status' } }, + { field: 'created_at', title: '创建时间' }, + { type: 'html', title: '操作', slots: { default: 'action' } }, + ], + keepSource: true, + pagerConfig: {}, + proxyConfig: { + ajax: { + // 请求后端接口方法 + query: async ({ page }, formValues) => { + return await getWesternMedicineList({ + page: page.currentPage, + pageSize: page.pageSize, + ...formValues, + }); + }, + }, + }, + // exportConfig: { + // api: passApplicationApi, + // }, + height: 'auto', + border: false, + toolbarConfig: { + // 是否显示搜索表单控制按钮 + // @ts-ignore 正式环境时有完整的类型声明 + search: true, + refresh: true, // 刷新 + print: false, // 打印 + export: false, // 导出 + // custom: true, // 自定义列 + zoom: true, // 最大化最小化 + slots: { + buttons: 'toolbar-buttons', + }, + custom: { + // 自定义列-图标 + icon: 'vxe-icon-menu', + }, + }, + showOverflow: false, +}; diff --git a/apps/web-antd/src/views/business/warehouse-drug-management/admin/index.vue b/apps/web-antd/src/views/business/warehouse-drug-management/admin/index.vue new file mode 100644 index 00000000..213a5f5e --- /dev/null +++ b/apps/web-antd/src/views/business/warehouse-drug-management/admin/index.vue @@ -0,0 +1,204 @@ + + +