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>( return requestClient.get<WmsBsrealStorAttrApi.BsrealStorAttr>(
`/wms/bsreal-stor-attr/get?id=${id}`, `/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}`); return requestClient.delete(`/wms/bsreal-stor-attr/delete?id=${id}`);
} }
/** 批量删除实物库属性 */ /** 批量删除实物库属性 */
export function deleteBsrealStorAttrList(ids: number[]) { export function deleteBsrealStorAttrList(ids: string[]) {
return requestClient.delete( return requestClient.delete(
`/wms/bsreal-stor-attr/delete-list?ids=${ids.join(',')}`, `/wms/bsreal-stor-attr/delete-list?ids=${ids.join(',')}`,
); );

View File

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

View File

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

View File

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