feat: 中药导入模块修复、部门财务的优化

This commit is contained in:
李琦
2026-08-06 20:15:42 +08:00
parent 174693f6db
commit cfc8390573
85 changed files with 4405 additions and 377 deletions

View File

@@ -177,7 +177,7 @@ const [FormModal, formModalApi] = useVbenModal({
},
onOpenChange(isOpen: boolean) {
if (!isOpen) {
formApi.resetFields();
formApi.resetForm();
return;
}
const data = formModalApi.getData<{ values?: any; update?: boolean }>();
@@ -185,7 +185,7 @@ const [FormModal, formModalApi] = useVbenModal({
if (data?.values && data.update) {
formApi.setValues({ ...data.values });
} else {
formApi.resetFields();
formApi.resetForm();
}
},
});

View File

@@ -0,0 +1,28 @@
/**
* 药品计量单位字典 API(yii_west_unit)
*/
import { requestClient } from '#/api/request';
const prefix = 'west-unit-dict/';
export async function getWestUnitDictList(data: any) {
return requestClient.get<any>(`${prefix}list`, { params: data });
}
export async function getWestUnitDictOption() {
return requestClient.get<{ value: number; label: string }[]>(
`${prefix}option`,
);
}
export async function createWestUnitDict(data: Record<string, any>) {
return requestClient.post<any>(`${prefix}create`, data);
}
export async function updateWestUnitDict(data: Record<string, any>) {
return requestClient.post<any>(`${prefix}update`, data);
}
export async function deleteWestUnitDict(data: { ids: number[] }) {
return requestClient.post<any>(`${prefix}delete`, data);
}

View File

@@ -0,0 +1,214 @@
<script lang="ts" setup>
/**
* 药品计量单位字典(yii_west_unit)
* 挂在字典管理下,供开方/仓库导入复用
*/
import type { VxeGridListeners } from '#/adapter/vxe-table';
import { ref } from 'vue';
import { Page, useVbenModal } from '@vben/common-ui';
import { message } from 'ant-design-vue';
import { useVbenForm } from '#/adapter/form';
import { useVbenVxeGrid } from '#/adapter/vxe-table';
import { TableAction } from '#/components/table-action';
import {
createWestUnitDict,
deleteWestUnitDict,
getWestUnitDictList,
updateWestUnitDict,
} from './api';
defineOptions({ name: 'WestUnitDict' });
const hasTopTableDropDownActions = ref(false);
const isUpdate = ref(false);
const formOptions = {
schema: [
{
component: 'VbenInput',
fieldName: 'keyword',
label: '关键字',
componentProps: { placeholder: '单位名称' },
},
],
};
const gridOptions = {
checkboxConfig: { highlight: true, labelField: '' },
columns: [
{ type: 'checkbox', width: 60 },
{ field: 'id', title: 'ID', width: 80 },
{ field: 'name', title: '单位名称', minWidth: 180 },
{ field: 'created_at', title: '创建时间', width: 170 },
{ field: 'updated_at', title: '更新时间', width: 170 },
{ title: '操作', slots: { default: 'action' }, width: 140, fixed: 'right' },
],
keepSource: true,
pagerConfig: {},
proxyConfig: {
ajax: {
query: async ({ page }: any, formValues: any) => {
return await getWestUnitDictList({
page: page.currentPage,
pageSize: page.pageSize,
...formValues,
});
},
},
},
height: 'auto',
toolbarConfig: {
search: true,
refresh: true,
slots: { buttons: 'toolbar-buttons' },
},
};
const gridEvents: VxeGridListeners<any> = {
checkboxChange() {
hasTopTableDropDownActions.value =
gridApi.grid.getCheckboxRecords().length > 0;
},
checkboxAll() {
hasTopTableDropDownActions.value =
gridApi.grid.getCheckboxRecords().length > 0;
},
};
const [Grid, gridApi] = useVbenVxeGrid({
formOptions,
gridOptions: gridOptions as any,
gridEvents,
});
const [Form, formApi] = useVbenForm({
wrapperClass: 'grid-cols-12',
commonConfig: {
formItemClass: 'col-span-12',
componentProps: { class: 'w-full' },
},
layout: 'horizontal',
schema: [
{
component: 'VbenInput',
fieldName: 'id',
label: 'ID',
dependencies: { show: false, triggerFields: ['id'] },
},
{
component: 'VbenInput',
fieldName: 'name',
label: '单位名称',
rules: 'required',
componentProps: { placeholder: '如:盒、瓶、g、袋', maxlength: 20 },
},
],
showDefaultActions: false,
});
const [FormModal, formModalApi] = useVbenModal({
class: 'w-[480px]',
draggable: true,
onConfirm: async () => {
const e = await formApi.validate();
if (!e.valid) return;
const values = await formApi.getValues();
formModalApi.setState({ confirmLoading: true });
try {
if (isUpdate.value) {
await updateWestUnitDict(values);
} else {
await createWestUnitDict(values);
}
message.success('保存成功');
gridApi.query();
formModalApi.close();
} finally {
formModalApi.setState({ confirmLoading: false });
}
},
onOpenChange(isOpen: boolean) {
if (!isOpen) {
formApi.resetForm();
return;
}
const data = formModalApi.getData<{ values?: any; update?: boolean }>();
isUpdate.value = !!data?.update;
if (data?.values && data.update) {
formApi.setValues({ ...data.values });
} else {
formApi.resetForm();
}
},
});
function showModal(row: any = {}, update = false) {
formModalApi.setData({ values: row, update });
formModalApi.open();
}
async function handleDelete(ids: number[]) {
await deleteWestUnitDict({ ids });
message.success('删除成功');
gridApi.query();
}
</script>
<template>
<Page auto-content-height title="单位管理">
<FormModal :title="`${isUpdate ? '编辑' : '新增'}单位`">
<Form />
</FormModal>
<Grid>
<template #toolbar-buttons>
<TableAction
:actions="[
{
label: '新增',
type: 'primary',
onClick: () => showModal({}, false),
},
{
label: '批量删除',
danger: true,
ifShow: () => hasTopTableDropDownActions,
popConfirm: {
title: '确认删除所选?被药品引用的单位无法删除。',
confirm: () => {
const ids = gridApi.grid
.getCheckboxRecords()
.map((r: any) => r.id);
handleDelete(ids);
},
},
},
]"
/>
</template>
<template #action="{ row }">
<TableAction
:actions="[
{
label: '编辑',
type: 'link',
onClick: () => showModal(row, true),
},
{
label: '删除',
type: 'link',
danger: true,
popConfirm: {
title: '确认删除该单位?',
confirm: () => handleDelete([row.id]),
},
},
]"
/>
</template>
</Grid>
</Page>
</template>