feat: 载具扩展表
This commit is contained in:
@@ -0,0 +1,67 @@
|
||||
import type { PageParam, PageResult } from '@vben/request';
|
||||
|
||||
import { requestClient } from '#/api/request';
|
||||
|
||||
export namespace WmsStorageVehicleExtApi {
|
||||
/** 载具扩展属性信息信息 */
|
||||
export interface StorageVehicleExt {
|
||||
storageVehicleExtId?: number;
|
||||
storageVehicleId?: number; // 载具标识
|
||||
storageVehicleCode?: string; // 载具编码
|
||||
storageVehicleType?: string; // 载具类型
|
||||
materialId: number; // 物料标识
|
||||
pcsn: string; // 批次
|
||||
boxNo: string; // 木箱号
|
||||
qtyUnitId: number; // 数量计量单位标识
|
||||
qtyUnitName: string; // 数量计量单位名称
|
||||
qty: number; // 物料数量
|
||||
vehicleWeight?: number; // 托盘重量
|
||||
weightUnitId: number; // 重量计量单位标识
|
||||
weightUnitName: string; // 重量计量单位名称
|
||||
remark: string; // 备注
|
||||
}
|
||||
}
|
||||
|
||||
/** 查询载具扩展属性信息分页 */
|
||||
export function getStorageVehicleExtPage(params: PageParam) {
|
||||
return requestClient.get<PageResult<WmsStorageVehicleExtApi.StorageVehicleExt>>(
|
||||
'/wms/storage-vehicle-ext/page',
|
||||
{ params },
|
||||
);
|
||||
}
|
||||
|
||||
/** 查询载具扩展属性信息详情 */
|
||||
export function getStorageVehicleExt(id: number) {
|
||||
return requestClient.get<WmsStorageVehicleExtApi.StorageVehicleExt>(
|
||||
`/wms/storage-vehicle-ext/get?id=${id}`,
|
||||
);
|
||||
}
|
||||
|
||||
/** 新增载具扩展属性信息 */
|
||||
export function createStorageVehicleExt(data: WmsStorageVehicleExtApi.StorageVehicleExt) {
|
||||
return requestClient.post('/wms/storage-vehicle-ext/create', data);
|
||||
}
|
||||
|
||||
/** 修改载具扩展属性信息 */
|
||||
export function updateStorageVehicleExt(data: WmsStorageVehicleExtApi.StorageVehicleExt) {
|
||||
return requestClient.put('/wms/storage-vehicle-ext/update', data);
|
||||
}
|
||||
|
||||
/** 删除载具扩展属性信息 */
|
||||
export function deleteStorageVehicleExt(id: number) {
|
||||
return requestClient.delete(`/wms/storage-vehicle-ext/delete?id=${id}`);
|
||||
}
|
||||
|
||||
/** 批量删除载具扩展属性信息 */
|
||||
export function deleteStorageVehicleExtList(ids: number[]) {
|
||||
return requestClient.delete(
|
||||
`/wms/storage-vehicle-ext/delete-list?ids=${ids.join(',')}`,
|
||||
);
|
||||
}
|
||||
|
||||
/** 导出载具扩展属性信息 */
|
||||
export function exportStorageVehicleExt(params: any) {
|
||||
return requestClient.download('/wms/storage-vehicle-ext/export-excel', { params });
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,295 @@
|
||||
import type { VbenFormSchema } from '#/adapter/form';
|
||||
import type { VxeTableGridOptions } from '#/adapter/vxe-table';
|
||||
import type { WmsStorageVehicleExtApi } from '#/api/wms/storagevehicleext';
|
||||
|
||||
import { getRangePickerDefaultProps } from '#/utils';
|
||||
import {getDictOptions} from "@vben/hooks";
|
||||
import {DICT_TYPE} from "@vben/constants";
|
||||
|
||||
/** 新增/修改的表单 */
|
||||
export function useFormSchema(): VbenFormSchema[] {
|
||||
return [
|
||||
{
|
||||
fieldName: 'storageVehicleExtId',
|
||||
component: 'Input',
|
||||
dependencies: {
|
||||
triggerFields: [''],
|
||||
show: () => false,
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldName: 'storageVehicleId',
|
||||
label: '载具标识',
|
||||
rules: 'required',
|
||||
component: 'Input',
|
||||
componentProps: {
|
||||
placeholder: '请输入载具标识',
|
||||
},
|
||||
dependencies: {
|
||||
triggerFields: [''],
|
||||
show: () => false,
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldName: 'storageVehicleCode',
|
||||
label: '载具编码',
|
||||
rules: 'required',
|
||||
component: 'Input',
|
||||
componentProps: {
|
||||
placeholder: '请输入载具编码',
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldName: 'storageVehicleType',
|
||||
label: '载具类型',
|
||||
rules: 'required',
|
||||
component: 'Select',
|
||||
componentProps: {
|
||||
options: getDictOptions(DICT_TYPE.WMS_VEHICLE_TYPE),
|
||||
placeholder: '请选择载具类型',
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldName: 'materialId',
|
||||
label: '物料标识',
|
||||
component: 'Input',
|
||||
componentProps: {
|
||||
placeholder: '请输入物料标识',
|
||||
},
|
||||
dependencies: {
|
||||
triggerFields: [''],
|
||||
show: () => false,
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldName: 'materialName',
|
||||
label: '物料名称',
|
||||
component: 'Input',
|
||||
componentProps: {
|
||||
placeholder: '请选择物料',
|
||||
readonly: true,
|
||||
style: 'cursor: pointer',
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldName: 'pcsn',
|
||||
label: '批次',
|
||||
component: 'Input',
|
||||
componentProps: {
|
||||
placeholder: '请输入批次',
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldName: 'boxNo',
|
||||
label: '木箱号',
|
||||
component: 'Input',
|
||||
componentProps: {
|
||||
placeholder: '请输入木箱号',
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldName: 'qtyUnitId',
|
||||
label: '数量单位',
|
||||
component: 'Input',
|
||||
componentProps: {
|
||||
placeholder: '请输入数量计量单位标识',
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldName: 'qtyUnitName',
|
||||
label: '数量单位',
|
||||
component: 'Input',
|
||||
componentProps: {
|
||||
placeholder: '请输入数量计量单位名称',
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldName: 'qty',
|
||||
label: '物料数量',
|
||||
component: 'Input',
|
||||
componentProps: {
|
||||
placeholder: '请输入物料数量',
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldName: 'vehicleWeight',
|
||||
label: '托盘重量',
|
||||
rules: 'required',
|
||||
component: 'Input',
|
||||
componentProps: {
|
||||
placeholder: '请输入托盘重量',
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldName: 'weightUnitId',
|
||||
label: '重量单位',
|
||||
component: 'Input',
|
||||
componentProps: {
|
||||
placeholder: '请输入重量计量单位标识',
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldName: 'weightUnitName',
|
||||
label: '重量单位',
|
||||
component: 'Input',
|
||||
componentProps: {
|
||||
placeholder: '请输入重量计量单位名称',
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldName: 'remark',
|
||||
label: '备注',
|
||||
component: 'Input',
|
||||
componentProps: {
|
||||
placeholder: '请输入备注',
|
||||
},
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
/** 列表的搜索表单 */
|
||||
export function useGridFormSchema(): VbenFormSchema[] {
|
||||
return [
|
||||
{
|
||||
fieldName: 'storageVehicleCode',
|
||||
label: '载具编码',
|
||||
component: 'Input',
|
||||
componentProps: {
|
||||
allowClear: true,
|
||||
placeholder: '请输入载具编码',
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldName: 'storageVehicleType',
|
||||
label: '载具类型',
|
||||
component: 'Select',
|
||||
componentProps: {
|
||||
allowClear: true,
|
||||
options: [],
|
||||
placeholder: '请选择载具类型',
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldName: 'materialId',
|
||||
label: '物料标识',
|
||||
component: 'Input',
|
||||
componentProps: {
|
||||
allowClear: true,
|
||||
placeholder: '请输入物料标识',
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldName: 'pcsn',
|
||||
label: '批次',
|
||||
component: 'Input',
|
||||
componentProps: {
|
||||
allowClear: true,
|
||||
placeholder: '请输入批次',
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldName: 'boxNo',
|
||||
label: '木箱号',
|
||||
component: 'Input',
|
||||
componentProps: {
|
||||
allowClear: true,
|
||||
placeholder: '请输入木箱号',
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldName: 'createTime',
|
||||
label: '创建时间',
|
||||
component: 'RangePicker',
|
||||
componentProps: {
|
||||
...getRangePickerDefaultProps(),
|
||||
allowClear: true,
|
||||
},
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
/** 列表的字段 */
|
||||
export function useGridColumns(): VxeTableGridOptions<WmsStorageVehicleExtApi.StorageVehicleExt>['columns'] {
|
||||
return [
|
||||
{ type: 'checkbox', width: 40 },
|
||||
{
|
||||
field: 'storageVehicleCode',
|
||||
title: '载具编码',
|
||||
minWidth: 120,
|
||||
},
|
||||
{
|
||||
field: 'storageVehicleType',
|
||||
title: '载具类型',
|
||||
minWidth: 120,
|
||||
},
|
||||
{
|
||||
field: 'materialId',
|
||||
title: '物料标识',
|
||||
minWidth: 120,
|
||||
},
|
||||
{
|
||||
field: 'pcsn',
|
||||
title: '批次',
|
||||
minWidth: 120,
|
||||
},
|
||||
{
|
||||
field: 'boxNo',
|
||||
title: '木箱号',
|
||||
minWidth: 120,
|
||||
},
|
||||
{
|
||||
field: 'qtyUnitId',
|
||||
title: '数量计量单位标识',
|
||||
minWidth: 120,
|
||||
},
|
||||
{
|
||||
field: 'qtyUnitName',
|
||||
title: '数量计量单位名称',
|
||||
minWidth: 120,
|
||||
},
|
||||
{
|
||||
field: 'qty',
|
||||
title: '物料数量',
|
||||
minWidth: 120,
|
||||
},
|
||||
{
|
||||
field: 'vehicleWeight',
|
||||
title: '托盘重量',
|
||||
minWidth: 120,
|
||||
},
|
||||
{
|
||||
field: 'weightUnitId',
|
||||
title: '重量计量单位标识',
|
||||
minWidth: 120,
|
||||
},
|
||||
{
|
||||
field: 'weightUnitName',
|
||||
title: '重量计量单位名称',
|
||||
minWidth: 120,
|
||||
},
|
||||
{
|
||||
field: 'remark',
|
||||
title: '备注',
|
||||
minWidth: 120,
|
||||
},
|
||||
{
|
||||
field: 'createTime',
|
||||
title: '创建时间',
|
||||
minWidth: 120,
|
||||
formatter: 'formatDateTime',
|
||||
},
|
||||
{
|
||||
field: 'updateTime',
|
||||
title: '更新时间',
|
||||
minWidth: 120,
|
||||
formatter: 'formatDateTime',
|
||||
},
|
||||
{
|
||||
title: '操作',
|
||||
width: 200,
|
||||
fixed: 'right',
|
||||
slots: { default: 'actions' },
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
@@ -0,0 +1,186 @@
|
||||
<script lang="ts" setup>
|
||||
import type { VxeTableGridOptions } from '#/adapter/vxe-table';
|
||||
import type { WmsStorageVehicleExtApi } from '#/api/wms/storagevehicleext';
|
||||
|
||||
import { ref } from 'vue';
|
||||
|
||||
import { confirm, Page, useVbenModal } from '@vben/common-ui';
|
||||
import { downloadFileFromBlobPart, isEmpty } from '@vben/utils';
|
||||
|
||||
import { message } from 'antdv-next';
|
||||
|
||||
import { ACTION_ICON, TableAction, useVbenVxeGrid } from '#/adapter/vxe-table';
|
||||
import {
|
||||
deleteStorageVehicleExt,
|
||||
deleteStorageVehicleExtList,
|
||||
exportStorageVehicleExt,
|
||||
getStorageVehicleExtPage,
|
||||
} from '#/api/wms/storagevehicleext';
|
||||
import { $t } from '#/locales';
|
||||
|
||||
import { useGridColumns, useGridFormSchema } from './data';
|
||||
import Form from './modules/form.vue';
|
||||
|
||||
const [FormModal, formModalApi] = useVbenModal({
|
||||
connectedComponent: Form,
|
||||
destroyOnClose: true,
|
||||
});
|
||||
|
||||
/** 刷新表格 */
|
||||
function handleRefresh() {
|
||||
gridApi.query();
|
||||
}
|
||||
|
||||
/** 创建载具扩展属性信息 */
|
||||
function handleCreate() {
|
||||
formModalApi.setData(null).open();
|
||||
}
|
||||
|
||||
/** 编辑载具扩展属性信息 */
|
||||
function handleEdit(row: WmsStorageVehicleExtApi.StorageVehicleExt) {
|
||||
formModalApi.setData(row).open();
|
||||
}
|
||||
|
||||
/** 删除载具扩展属性信息 */
|
||||
async function handleDelete(row: WmsStorageVehicleExtApi.StorageVehicleExt) {
|
||||
const hideLoading = message.loading({
|
||||
content: $t('ui.actionMessage.deleting', [row.id]),
|
||||
duration: 0,
|
||||
});
|
||||
try {
|
||||
await deleteStorageVehicleExt(row.id!);
|
||||
message.success($t('ui.actionMessage.deleteSuccess', [row.id]));
|
||||
handleRefresh();
|
||||
} finally {
|
||||
hideLoading();
|
||||
}
|
||||
}
|
||||
|
||||
/** 批量删除载具扩展属性信息 */
|
||||
async function handleDeleteBatch() {
|
||||
await confirm($t('ui.actionMessage.deleteBatchConfirm'));
|
||||
const hideLoading = message.loading({
|
||||
content: $t('ui.actionMessage.deletingBatch'),
|
||||
duration: 0,
|
||||
});
|
||||
try {
|
||||
await deleteStorageVehicleExtList(checkedIds.value);
|
||||
checkedIds.value = [];
|
||||
message.success($t('ui.actionMessage.deleteSuccess'));
|
||||
handleRefresh();
|
||||
} finally {
|
||||
hideLoading();
|
||||
}
|
||||
}
|
||||
|
||||
const checkedIds = ref<number[]>([]);
|
||||
function handleRowCheckboxChange({
|
||||
records,
|
||||
}: {
|
||||
records: WmsStorageVehicleExtApi.StorageVehicleExt[];
|
||||
}) {
|
||||
checkedIds.value = records.map((item) => item.id!);
|
||||
}
|
||||
|
||||
/** 导出表格 */
|
||||
async function handleExport() {
|
||||
const data = await exportStorageVehicleExt(await gridApi.formApi.getValues());
|
||||
downloadFileFromBlobPart({ fileName: '载具扩展属性信息.xls', source: data });
|
||||
}
|
||||
|
||||
|
||||
const [Grid, gridApi] = useVbenVxeGrid({
|
||||
formOptions: {
|
||||
schema: useGridFormSchema(),
|
||||
},
|
||||
gridOptions: {
|
||||
columns: useGridColumns(),
|
||||
height: 'auto',
|
||||
keepSource: true,
|
||||
proxyConfig: {
|
||||
ajax: {
|
||||
query: async ({ page }, formValues) => {
|
||||
return await getStorageVehicleExtPage({
|
||||
pageNo: page.currentPage,
|
||||
pageSize: page.pageSize,
|
||||
...formValues,
|
||||
});
|
||||
},
|
||||
},
|
||||
},
|
||||
rowConfig: {
|
||||
keyField: 'storageVehicleExtId',
|
||||
isHover: true,
|
||||
},
|
||||
toolbarConfig: {
|
||||
refresh: true,
|
||||
search: true,
|
||||
},
|
||||
} as VxeTableGridOptions<WmsStorageVehicleExtApi.StorageVehicleExt>,
|
||||
gridEvents: {
|
||||
checkboxAll: handleRowCheckboxChange,
|
||||
checkboxChange: handleRowCheckboxChange,
|
||||
},
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Page auto-content-height>
|
||||
<FormModal @success="handleRefresh" />
|
||||
<Grid table-title="载具扩展属性信息列表">
|
||||
<template #toolbar-tools>
|
||||
<TableAction
|
||||
:actions="[
|
||||
{
|
||||
label: $t('ui.actionTitle.create', ['载具扩展属性信息']),
|
||||
type: 'primary',
|
||||
icon: ACTION_ICON.ADD,
|
||||
auth: ['wms:storage-vehicle-ext:create'],
|
||||
onClick: handleCreate,
|
||||
},
|
||||
{
|
||||
label: $t('ui.actionTitle.export'),
|
||||
type: 'primary',
|
||||
icon: ACTION_ICON.DOWNLOAD,
|
||||
auth: ['wms:storage-vehicle-ext:export'],
|
||||
onClick: handleExport,
|
||||
},
|
||||
{
|
||||
label: $t('ui.actionTitle.deleteBatch'),
|
||||
type: 'primary',
|
||||
danger: true,
|
||||
icon: ACTION_ICON.DELETE,
|
||||
auth: ['wms:storage-vehicle-ext:delete'],
|
||||
disabled: isEmpty(checkedIds),
|
||||
onClick: handleDeleteBatch,
|
||||
},
|
||||
]"
|
||||
/>
|
||||
</template>
|
||||
<template #actions="{ row }">
|
||||
<TableAction
|
||||
:actions="[
|
||||
{
|
||||
label: $t('common.edit'),
|
||||
type: 'link',
|
||||
icon: ACTION_ICON.EDIT,
|
||||
auth: ['wms:storage-vehicle-ext:update'],
|
||||
onClick: handleEdit.bind(null, row),
|
||||
},
|
||||
{
|
||||
label: $t('common.delete'),
|
||||
type: 'link',
|
||||
danger: true,
|
||||
icon: ACTION_ICON.DELETE,
|
||||
auth: ['wms:storage-vehicle-ext:delete'],
|
||||
popConfirm: {
|
||||
title: $t('ui.actionMessage.deleteConfirm', [row.id]),
|
||||
confirm: handleDelete.bind(null, row),
|
||||
},
|
||||
},
|
||||
]"
|
||||
/>
|
||||
</template>
|
||||
</Grid>
|
||||
</Page>
|
||||
</template>
|
||||
@@ -0,0 +1,119 @@
|
||||
<script lang="ts" setup>
|
||||
import type { WmsStorageVehicleExtApi } from '#/api/wms/storagevehicleext';
|
||||
|
||||
import { computed, ref } from 'vue';
|
||||
|
||||
import { useVbenModal } from '@vben/common-ui';
|
||||
|
||||
import { message } from 'antdv-next';
|
||||
|
||||
import { useVbenForm } from '#/adapter/form';
|
||||
import { createStorageVehicleExt, getStorageVehicleExt, updateStorageVehicleExt } from '#/api/wms/storagevehicleext';
|
||||
import { $t } from '#/locales';
|
||||
|
||||
import { useFormSchema } from '../data';
|
||||
import MaterialSelectModalComponent from '../../../base/materialbase/components/MaterialSelectModal.vue';
|
||||
|
||||
const emit = defineEmits(['success']);
|
||||
const formData = ref<WmsStorageVehicleExtApi.StorageVehicleExt>();
|
||||
const getTitle = computed(() => {
|
||||
return formData.value?.storageVehicleExtId
|
||||
? $t('ui.actionTitle.edit', ['载具扩展属性信息'])
|
||||
: $t('ui.actionTitle.create', ['载具扩展属性信息']);
|
||||
});
|
||||
|
||||
/** 物料选择弹窗 */
|
||||
const [MaterialSelectModal, materialSelectModalApi] = useVbenModal({
|
||||
connectedComponent: MaterialSelectModalComponent,
|
||||
});
|
||||
|
||||
function openMaterialSelect() {
|
||||
materialSelectModalApi.setData({ multiple: false }).open();
|
||||
}
|
||||
|
||||
function handleMaterialSelect(rows: any[]) {
|
||||
if (rows.length > 0) {
|
||||
const row = rows[0];
|
||||
const currentValues = formApi.getValues();
|
||||
formApi.setValues({
|
||||
...currentValues,
|
||||
materialId: row.materialId,
|
||||
materialName: row.materialName,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// 覆盖物料名称字段:只读,点击弹出选择窗
|
||||
const schema = useFormSchema().map((field) => {
|
||||
if (field.fieldName === 'materialName') {
|
||||
return {
|
||||
...field,
|
||||
componentProps: {
|
||||
...field.componentProps,
|
||||
onClick: openMaterialSelect,
|
||||
},
|
||||
};
|
||||
}
|
||||
return field;
|
||||
});
|
||||
|
||||
const [Form, formApi] = useVbenForm({
|
||||
commonConfig: {
|
||||
componentProps: {
|
||||
class: 'w-full',
|
||||
},
|
||||
formItemClass: 'col-span-2',
|
||||
labelWidth: 80,
|
||||
},
|
||||
layout: 'horizontal',
|
||||
schema,
|
||||
showDefaultActions: false,
|
||||
});
|
||||
|
||||
const [Modal, modalApi] = useVbenModal({
|
||||
async onConfirm() {
|
||||
const { valid } = await formApi.validate();
|
||||
if (!valid) {
|
||||
return;
|
||||
}
|
||||
modalApi.lock();
|
||||
// 提交表单
|
||||
const data = (await formApi.getValues()) as WmsStorageVehicleExtApi.StorageVehicleExt;
|
||||
try {
|
||||
await (formData.value?.storageVehicleExtId ? updateStorageVehicleExt(data) : createStorageVehicleExt(data));
|
||||
// 关闭并提示
|
||||
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<WmsStorageVehicleExtApi.StorageVehicleExt>();
|
||||
if (!data || !data.storageVehicleExtId) {
|
||||
return;
|
||||
}
|
||||
modalApi.lock();
|
||||
try {
|
||||
formData.value = await getStorageVehicleExt(data.storageVehicleExtId);
|
||||
// 设置到 values
|
||||
await formApi.setValues(formData.value);
|
||||
} finally {
|
||||
modalApi.unlock();
|
||||
}
|
||||
},
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Modal :title="getTitle">
|
||||
<Form class="mx-4" />
|
||||
<MaterialSelectModal @select="handleMaterialSelect" />
|
||||
</Modal>
|
||||
</template>
|
||||
Reference in New Issue
Block a user