feat: 新增备货区域查询修改页面(任务5)

This commit is contained in:
zhouz
2026-08-08 15:22:42 +08:00
parent 30e3582e19
commit ec1aca6a35
3 changed files with 368 additions and 0 deletions

View File

@@ -0,0 +1,198 @@
import type { VbenFormSchema } from '#/adapter/form';
import type { VxeTableGridOptions } from '#/adapter/vxe-table';
import type { LmsStockingIvtApi } from '#/api/lms/stockingivt';
import { getDictOptions } from '@vben/hooks';
import { DICT_TYPE } from '@vben/constants';
/** 修改表单。 */
export function useFormSchema(): VbenFormSchema[] {
return [
{
fieldName: 'ivtId',
component: 'Input',
dependencies: {
triggerFields: [''],
show: () => false,
},
},
{
fieldName: 'pointCode',
label: '点位编码',
component: 'Input',
componentProps: { disabled: true },
},
{
fieldName: 'pointName',
label: '点位名称',
component: 'Input',
componentProps: { disabled: true },
},
{
fieldName: 'vehicleCode',
label: '托盘号',
component: 'Input',
componentProps: { placeholder: '请输入托盘号' },
},
{
fieldName: 'pointType',
label: '点位类型',
rules: 'required',
component: 'Select',
componentProps: {
options: getDictOptions(DICT_TYPE.LMS_STOCKING_IVT_POINT_TYPE),
placeholder: '请选择点位类型',
},
},
{
fieldName: 'ivtStatus',
label: '点位状态',
rules: 'required',
component: 'Select',
componentProps: {
options: getDictOptions(DICT_TYPE.LMS_STOCKING_IVT_STATUS),
placeholder: '请选择点位状态',
},
},
{
fieldName: 'pointLocation',
label: '位置',
component: 'Input',
componentProps: { placeholder: '请输入位置' },
},
{
fieldName: 'sortSeq',
label: '顺序号',
rules: 'required',
component: 'InputNumber',
componentProps: { min: 0, placeholder: '请输入顺序号' },
},
{
fieldName: 'isUsed',
label: '是否启用',
rules: 'required',
component: 'Select',
componentProps: {
options: getDictOptions(DICT_TYPE.COMMON_STATUS),
placeholder: '请选择是否启用',
},
},
{
fieldName: 'remark',
label: '备注',
component: 'Textarea',
componentProps: { maxlength: 1000, placeholder: '请输入备注', showCount: true },
},
];
}
/** 列表查询表单。 */
export function useGridFormSchema(): VbenFormSchema[] {
return [
{
fieldName: 'pointCode',
label: '点位编码',
component: 'Input',
componentProps: { allowClear: true, placeholder: '请输入点位编码' },
},
{
fieldName: 'pointName',
label: '点位名称',
component: 'Input',
componentProps: { allowClear: true, placeholder: '请输入点位名称' },
},
{
fieldName: 'vehicleCode',
label: '托盘号',
component: 'Input',
componentProps: { allowClear: true, placeholder: '请输入托盘号' },
},
{
fieldName: 'pointType',
label: '点位类型',
component: 'Select',
componentProps: {
allowClear: true,
options: getDictOptions(DICT_TYPE.LMS_STOCKING_IVT_POINT_TYPE),
placeholder: '请选择点位类型',
},
},
{
fieldName: 'ivtStatus',
label: '点位状态',
component: 'Select',
componentProps: {
allowClear: true,
options: getDictOptions(DICT_TYPE.LMS_STOCKING_IVT_STATUS),
placeholder: '请选择点位状态',
},
},
{
fieldName: 'isUsed',
label: '是否启用',
component: 'Select',
componentProps: {
allowClear: true,
options: getDictOptions(DICT_TYPE.COMMON_STATUS),
placeholder: '请选择是否启用',
},
},
];
}
/** 列表字段。 */
export function useGridColumns(): VxeTableGridOptions<LmsStockingIvtApi.StockingIvt>['columns'] {
return [
{ field: 'pointCode', title: '点位编码', minWidth: 120 },
{ field: 'pointName', title: '点位名称', minWidth: 120 },
{
field: 'vehicleCode',
title: '托盘号',
minWidth: 120,
slots: { default: 'vehicleCode' },
},
{
field: 'pointType',
title: '点位类型',
minWidth: 110,
cellRender: {
name: 'CellDict',
props: { type: DICT_TYPE.LMS_STOCKING_IVT_POINT_TYPE },
},
},
{
field: 'ivtStatus',
title: '点位状态',
minWidth: 110,
cellRender: {
name: 'CellDict',
props: { type: DICT_TYPE.LMS_STOCKING_IVT_STATUS },
},
},
{ field: 'pointLocation', title: '位置', minWidth: 100 },
{ field: 'sortSeq', title: '顺序号', minWidth: 90 },
{
field: 'isUsed',
title: '是否启用',
minWidth: 100,
cellRender: {
name: 'CellDict',
props: { type: DICT_TYPE.COMMON_STATUS },
},
},
{ field: 'remark', title: '备注', minWidth: 160 },
{ field: 'updater', title: '修改人', minWidth: 120 },
{
field: 'updateTime',
title: '修改时间',
minWidth: 170,
formatter: 'formatDateTime',
},
{
title: '操作',
width: 100,
fixed: 'right',
slots: { default: 'actions' },
},
];
}

View File

@@ -0,0 +1,103 @@
<script lang="ts" setup>
import type { VxeTableGridOptions } from '#/adapter/vxe-table';
import type { LmsStockingIvtApi } from '#/api/lms/stockingivt';
import { Page, useVbenModal } from '@vben/common-ui';
import { Button } from 'antdv-next';
import { ACTION_ICON, TableAction, useVbenVxeGrid } from '#/adapter/vxe-table';
import { getStockingIvtPage } from '#/api/lms/stockingivt';
import { $t } from '#/locales';
import { useGridColumns, useGridFormSchema } from './data';
import Form from './modules/form.vue';
import PalletInventory from './modules/pallet-inventory.vue';
const [FormModal, formModalApi] = useVbenModal({
connectedComponent: Form,
destroyOnClose: true,
});
const [PalletInventoryModal, palletInventoryModalApi] = useVbenModal({
connectedComponent: PalletInventory,
destroyOnClose: true,
});
/** 刷新表格。 */
function handleRefresh() {
gridApi.query();
}
/** 打开修改弹窗。 */
function handleEdit(row: LmsStockingIvtApi.StockingIvt) {
formModalApi.setData(row).open();
}
/** 打开托盘库存弹窗。 */
function handleOpenPallet(vehicleCode: string) {
palletInventoryModalApi.setData({ vehicleCode }).open();
}
const [Grid, gridApi] = useVbenVxeGrid({
formOptions: {
schema: useGridFormSchema(),
},
gridOptions: {
columns: useGridColumns(),
height: 'auto',
keepSource: true,
proxyConfig: {
ajax: {
query: async ({ page }, formValues) => {
return await getStockingIvtPage({
pageNo: page.currentPage,
pageSize: page.pageSize,
...formValues,
});
},
},
},
rowConfig: {
keyField: 'ivtId',
isHover: true,
},
toolbarConfig: {
refresh: true,
search: true,
},
} as VxeTableGridOptions<LmsStockingIvtApi.StockingIvt>,
});
</script>
<template>
<Page auto-content-height>
<FormModal @success="handleRefresh" />
<PalletInventoryModal />
<Grid table-title="备货区域列表">
<template #vehicleCode="{ row }">
<Button
v-if="row.vehicleCode"
type="link"
@click="handleOpenPallet(row.vehicleCode)"
>
{{ row.vehicleCode }}
</Button>
<span v-else>-</span>
</template>
<template #actions="{ row }">
<TableAction
:actions="[
{
label: $t('common.edit'),
type: 'link',
icon: ACTION_ICON.EDIT,
auth: ['lms:stocking-ivt:update'],
onClick: handleEdit.bind(null, row),
},
]"
/>
</template>
</Grid>
</Page>
</template>

View File

@@ -0,0 +1,67 @@
<script lang="ts" setup>
import type { LmsStockingIvtApi } from '#/api/lms/stockingivt';
import { ref } from 'vue';
import { useVbenModal } from '@vben/common-ui';
import { message } from 'antdv-next';
import { useVbenForm } from '#/adapter/form';
import { getStockingIvt, updateStockingIvt } from '#/api/lms/stockingivt';
import { $t } from '#/locales';
import { useFormSchema } from '../data';
const emit = defineEmits(['success']);
const formData = ref<LmsStockingIvtApi.StockingIvt>();
const [Form, formApi] = useVbenForm({
commonConfig: {
componentProps: { class: 'w-full' },
formItemClass: 'col-span-2',
labelWidth: 90,
},
layout: 'horizontal',
schema: useFormSchema(),
showDefaultActions: false,
});
const [Modal, modalApi] = useVbenModal({
async onConfirm() {
const { valid } = await formApi.validate();
if (!valid) return;
modalApi.lock();
try {
const values = await formApi.getValues();
await updateStockingIvt(values as LmsStockingIvtApi.StockingIvtUpdateReq);
await modalApi.close();
emit('success');
message.success($t('ui.actionMessage.operationSuccess'));
} finally {
modalApi.unlock();
}
},
async onOpenChange(isOpen: boolean) {
if (!isOpen) {
formData.value = undefined;
return;
}
const data = modalApi.getData<LmsStockingIvtApi.StockingIvt>();
if (!data?.ivtId) return;
modalApi.lock();
try {
formData.value = await getStockingIvt(data.ivtId);
await formApi.setValues(formData.value);
} finally {
modalApi.unlock();
}
},
});
</script>
<template>
<Modal class="w-[620px]" title="修改备货区域">
<Form class="mx-4" />
</Modal>
</template>