feat:仓库页面优化

This commit is contained in:
zhouz
2026-07-17 11:10:36 +08:00
parent 9753d88079
commit ad1eef8a54
4 changed files with 46 additions and 62 deletions

View File

@@ -48,7 +48,7 @@ export function getBsrealStorAttrPage(params: PageParam) {
}
/** 查询实物库属性详情 */
export function getBsrealStorAttr(id: number) {
export function getBsrealStorAttr(id: string) {
return requestClient.get<WmsBsrealStorAttrApi.BsrealStorAttr>(
`/wms/bsreal-stor-attr/get?id=${id}`,
);
@@ -65,12 +65,12 @@ export function updateBsrealStorAttr(data: WmsBsrealStorAttrApi.BsrealStorAttr)
}
/** 删除实物库属性 */
export function deleteBsrealStorAttr(id: number) {
export function deleteBsrealStorAttr(id: string) {
return requestClient.delete(`/wms/bsreal-stor-attr/delete?id=${id}`);
}
/** 批量删除实物库属性 */
export function deleteBsrealStorAttrList(ids: number[]) {
export function deleteBsrealStorAttrList(ids: string[]) {
return requestClient.delete(
`/wms/bsreal-stor-attr/delete-list?ids=${ids.join(',')}`,
);

View File

@@ -7,11 +7,22 @@ import { getDictOptions } from '@vben/hooks';
import { getRangePickerDefaultProps } from '#/utils';
/** 是/否 选项(值为 '1' / '0',对应后端数据库存储) */
const BOOLEAN_OPTIONS = [
{ label: '是', value: '1' },
{ label: '否', value: '0' },
];
/** 是/否 列表格式化('1' → '是''0' → '否' */
function boolFormatter({ cellValue }: { cellValue: string }) {
return cellValue === '1' ? '是' : '否';
}
/** 新增/修改的表单 */
export function useFormSchema(): VbenFormSchema[] {
return [
{
fieldName: 'id',
fieldName: 'storId',
component: 'Input',
dependencies: {
triggerFields: [''],
@@ -74,7 +85,7 @@ export function useFormSchema(): VbenFormSchema[] {
label: '是否虚拟库',
component: 'RadioGroup',
componentProps: {
options: getDictOptions(DICT_TYPE.INFRA_BOOLEAN_STRING, 'boolean'),
options: BOOLEAN_OPTIONS,
buttonStyle: 'solid',
optionType: 'button',
},
@@ -84,7 +95,7 @@ export function useFormSchema(): VbenFormSchema[] {
label: '是否半成品库',
component: 'RadioGroup',
componentProps: {
options: getDictOptions(DICT_TYPE.INFRA_BOOLEAN_STRING, 'boolean'),
options: BOOLEAN_OPTIONS,
buttonStyle: 'solid',
optionType: 'button',
},
@@ -94,7 +105,7 @@ export function useFormSchema(): VbenFormSchema[] {
label: '是否原料库',
component: 'RadioGroup',
componentProps: {
options: getDictOptions(DICT_TYPE.INFRA_BOOLEAN_STRING, 'boolean'),
options: BOOLEAN_OPTIONS,
buttonStyle: 'solid',
optionType: 'button',
},
@@ -104,7 +115,7 @@ export function useFormSchema(): VbenFormSchema[] {
label: '是否成品库',
component: 'RadioGroup',
componentProps: {
options: getDictOptions(DICT_TYPE.INFRA_BOOLEAN_STRING, 'boolean'),
options: BOOLEAN_OPTIONS,
buttonStyle: 'solid',
optionType: 'button',
},
@@ -114,7 +125,7 @@ export function useFormSchema(): VbenFormSchema[] {
label: '是否备件库',
component: 'RadioGroup',
componentProps: {
options: getDictOptions(DICT_TYPE.INFRA_BOOLEAN_STRING, 'boolean'),
options: BOOLEAN_OPTIONS,
buttonStyle: 'solid',
optionType: 'button',
},
@@ -124,7 +135,7 @@ export function useFormSchema(): VbenFormSchema[] {
label: '是否允许红冲',
component: 'RadioGroup',
componentProps: {
options: getDictOptions(DICT_TYPE.INFRA_BOOLEAN_STRING, 'boolean'),
options: BOOLEAN_OPTIONS,
buttonStyle: 'solid',
optionType: 'button',
},
@@ -134,7 +145,7 @@ export function useFormSchema(): VbenFormSchema[] {
label: '是否移出业务自动确认',
component: 'RadioGroup',
componentProps: {
options: getDictOptions(DICT_TYPE.INFRA_BOOLEAN_STRING, 'boolean'),
options: BOOLEAN_OPTIONS,
buttonStyle: 'solid',
optionType: 'button',
},
@@ -144,7 +155,7 @@ export function useFormSchema(): VbenFormSchema[] {
label: '是否移入业务自动确认',
component: 'RadioGroup',
componentProps: {
options: getDictOptions(DICT_TYPE.INFRA_BOOLEAN_STRING, 'boolean'),
options: BOOLEAN_OPTIONS,
buttonStyle: 'solid',
optionType: 'button',
},
@@ -211,7 +222,7 @@ export function useFormSchema(): VbenFormSchema[] {
rules: 'required',
component: 'Select',
componentProps: {
options: getDictOptions(DICT_TYPE.COMMON_STATUS, 'number'),
options: getDictOptions(DICT_TYPE.COMMON_STATUS, 'string'),
placeholder: '请选择状态',
allowClear: true,
},
@@ -222,7 +233,7 @@ export function useFormSchema(): VbenFormSchema[] {
rules: 'required',
component: 'RadioGroup',
componentProps: {
options: getDictOptions(DICT_TYPE.INFRA_BOOLEAN_STRING, 'boolean'),
options: BOOLEAN_OPTIONS,
buttonStyle: 'solid',
optionType: 'button',
},
@@ -339,7 +350,7 @@ export function useGridFormSchema(): VbenFormSchema[] {
label: '是否启用',
component: 'Select',
componentProps: {
options: getDictOptions(DICT_TYPE.INFRA_BOOLEAN_STRING, 'boolean'),
options: BOOLEAN_OPTIONS,
placeholder: '请选择是否启用',
allowClear: true,
},
@@ -394,73 +405,49 @@ export function useGridColumns(): VxeTableGridOptions<WmsBsrealStorAttrApi.Bsrea
field: 'isVirtualstore',
title: '是否虚拟库',
minWidth: 120,
cellRender: {
name: 'CellDict',
props: { type: DICT_TYPE.INFRA_BOOLEAN_STRING },
},
formatter: boolFormatter,
},
{
field: 'isSemiFinished',
title: '是否半成品库',
minWidth: 120,
cellRender: {
name: 'CellDict',
props: { type: DICT_TYPE.INFRA_BOOLEAN_STRING },
},
formatter: boolFormatter,
},
{
field: 'isMaterialstore',
title: '是否原料库',
minWidth: 120,
cellRender: {
name: 'CellDict',
props: { type: DICT_TYPE.INFRA_BOOLEAN_STRING },
},
formatter: boolFormatter,
},
{
field: 'isProductstore',
title: '是否成品库',
minWidth: 120,
cellRender: {
name: 'CellDict',
props: { type: DICT_TYPE.INFRA_BOOLEAN_STRING },
},
formatter: boolFormatter,
},
{
field: 'isAttachment',
title: '是否备件库',
minWidth: 120,
cellRender: {
name: 'CellDict',
props: { type: DICT_TYPE.INFRA_BOOLEAN_STRING },
},
formatter: boolFormatter,
},
{
field: 'isReversed',
title: '是否允许红冲',
minWidth: 120,
cellRender: {
name: 'CellDict',
props: { type: DICT_TYPE.INFRA_BOOLEAN_STRING },
},
formatter: boolFormatter,
},
{
field: 'isMvoutAutoCfm',
title: '是否移出业务自动确认',
minWidth: 120,
cellRender: {
name: 'CellDict',
props: { type: DICT_TYPE.INFRA_BOOLEAN_STRING },
},
formatter: boolFormatter,
},
{
field: 'isMvinAutoCfm',
title: '是否移入业务自动确认',
minWidth: 120,
cellRender: {
name: 'CellDict',
props: { type: DICT_TYPE.INFRA_BOOLEAN_STRING },
},
formatter: boolFormatter,
},
{
field: 'area',
@@ -510,10 +497,7 @@ export function useGridColumns(): VxeTableGridOptions<WmsBsrealStorAttrApi.Bsrea
field: 'isUsed',
title: '是否启用',
minWidth: 120,
cellRender: {
name: 'CellDict',
props: { type: DICT_TYPE.INFRA_BOOLEAN_STRING },
},
formatter: boolFormatter,
},
{
field: 'baseClassId',

View File

@@ -44,12 +44,12 @@ function handleEdit(row: WmsBsrealStorAttrApi.BsrealStorAttr) {
/** 删除实物库属性 */
async function handleDelete(row: WmsBsrealStorAttrApi.BsrealStorAttr) {
const hideLoading = message.loading({
content: $t('ui.actionMessage.deleting', [row.id]),
content: $t('ui.actionMessage.deleting', [row.storId]),
duration: 0,
});
try {
await deleteBsrealStorAttr(row.id!);
message.success($t('ui.actionMessage.deleteSuccess', [row.id]));
await deleteBsrealStorAttr(row.storId!);
message.success($t('ui.actionMessage.deleteSuccess', [row.storId]));
handleRefresh();
} finally {
hideLoading();
@@ -73,13 +73,13 @@ async function handleDeleteBatch() {
}
}
const checkedIds = ref<number[]>([]);
const checkedIds = ref<string[]>([]);
function handleRowCheckboxChange({
records,
}: {
records: WmsBsrealStorAttrApi.BsrealStorAttr[];
}) {
checkedIds.value = records.map((item) => item.id!);
checkedIds.value = records.map((item) => item.storId!);
}
/** 导出表格 */
@@ -109,7 +109,7 @@ const [Grid, gridApi] = useVbenVxeGrid({
},
},
rowConfig: {
keyField: 'id',
keyField: 'storId',
isHover: true,
},
toolbarConfig: {
@@ -174,7 +174,7 @@ const [Grid, gridApi] = useVbenVxeGrid({
icon: ACTION_ICON.DELETE,
auth: ['wms:bsreal-stor-attr:delete'],
popConfirm: {
title: $t('ui.actionMessage.deleteConfirm', [row.id]),
title: $t('ui.actionMessage.deleteConfirm', [row.storId]),
confirm: handleDelete.bind(null, row),
},
},

View File

@@ -16,7 +16,7 @@ import { useFormSchema } from '../data';
const emit = defineEmits(['success']);
const formData = ref<WmsBsrealStorAttrApi.BsrealStorAttr>();
const getTitle = computed(() => {
return formData.value?.id
return formData.value?.storId
? $t('ui.actionTitle.edit', ['实物库属性'])
: $t('ui.actionTitle.create', ['实物库属性']);
});
@@ -44,7 +44,7 @@ const [Modal, modalApi] = useVbenModal({
// 提交表单
const data = (await formApi.getValues()) as WmsBsrealStorAttrApi.BsrealStorAttr;
try {
await (formData.value?.id ? updateBsrealStorAttr(data) : createBsrealStorAttr(data));
await (formData.value?.storId ? updateBsrealStorAttr(data) : createBsrealStorAttr(data));
// 关闭并提示
await modalApi.close();
emit('success');
@@ -60,12 +60,12 @@ const [Modal, modalApi] = useVbenModal({
}
// 加载数据
const data = modalApi.getData<WmsBsrealStorAttrApi.BsrealStorAttr>();
if (!data || !data.id) {
if (!data || !data.storId) {
return;
}
modalApi.lock();
try {
formData.value = await getBsrealStorAttr(data.id);
formData.value = await getBsrealStorAttr(data.storId);
// 设置到 values
await formApi.setValues(formData.value);
} finally {