feat:新增WMS模块。新增仓储CRUD

This commit is contained in:
zhouz
2026-07-17 09:26:34 +08:00
parent 012f792b22
commit 5b643a44b4
24 changed files with 2505 additions and 0 deletions

View File

@@ -0,0 +1,82 @@
import type { PageParam, PageResult } from '@vben/request';
import { requestClient } from '#/api/request';
export namespace WmsBsrealStorAttrApi {
/** 实物库属性信息 */
export interface BsrealStorAttr {
storId: string; // 仓库标识
storCode?: string; // 仓库编码
storName?: string; // 仓库名称
simpleName: string; // 仓库简称
storCapacity: number; // 仓库容量
totalArea: number; // 总面积
storTypeScode?: string; // 仓库性质
isVirtualstore?: string; // 是否虚拟库
isSemiFinished?: string; // 是否半成品库
isMaterialstore?: string; // 是否原料库
isProductstore?: string; // 是否成品库
isAttachment?: string; // 是否备件库
isReversed?: string; // 是否允许红冲
isMvoutAutoCfm?: string; // 是否移出业务自动确认
isMvinAutoCfm?: string; // 是否移入业务自动确认
area: string; // 地区
storeaDdress: string; // 仓库地址
principal: string; // 负责人
officePhone: string; // 办公电话
mobileNo: string; // 负责人手机
remark: string; // 备注
orderIndex: number; // 显示顺序
whstateScode?: string; // 状态
isUsed?: string; // 是否启用
baseClassId: string; // 物料基本分类
sysownerid: string; // 拥有者ID
sysdeptid?: string; // 部门ID
syscompanyid?: string; // 公司ID
extId: string; // 外部标识
departName: string; // 部门名称
companyName: string; // 公司名称
}
}
/** 查询实物库属性分页 */
export function getBsrealStorAttrPage(params: PageParam) {
return requestClient.get<PageResult<WmsBsrealStorAttrApi.BsrealStorAttr>>(
'/wms/bsreal-stor-attr/page',
{ params },
);
}
/** 查询实物库属性详情 */
export function getBsrealStorAttr(id: number) {
return requestClient.get<WmsBsrealStorAttrApi.BsrealStorAttr>(
`/wms/bsreal-stor-attr/get?id=${id}`,
);
}
/** 新增实物库属性 */
export function createBsrealStorAttr(data: WmsBsrealStorAttrApi.BsrealStorAttr) {
return requestClient.post('/wms/bsreal-stor-attr/create', data);
}
/** 修改实物库属性 */
export function updateBsrealStorAttr(data: WmsBsrealStorAttrApi.BsrealStorAttr) {
return requestClient.put('/wms/bsreal-stor-attr/update', data);
}
/** 删除实物库属性 */
export function deleteBsrealStorAttr(id: number) {
return requestClient.delete(`/wms/bsreal-stor-attr/delete?id=${id}`);
}
/** 批量删除实物库属性 */
export function deleteBsrealStorAttrList(ids: number[]) {
return requestClient.delete(
`/wms/bsreal-stor-attr/delete-list?ids=${ids.join(',')}`,
);
}
/** 导出实物库属性 */
export function exportBsrealStorAttr(params: any) {
return requestClient.download('/wms/bsreal-stor-attr/export-excel', { params });
}

View File

@@ -0,0 +1,566 @@
import type { VbenFormSchema } from '#/adapter/form';
import type { VxeTableGridOptions } from '#/adapter/vxe-table';
import type { WmsBsrealStorAttrApi } from '#/api/wms/bsrealstorattr';
import { DICT_TYPE } from '@vben/constants';
import { getDictOptions } from '@vben/hooks';
import { getRangePickerDefaultProps } from '#/utils';
/** 新增/修改的表单 */
export function useFormSchema(): VbenFormSchema[] {
return [
{
fieldName: 'id',
component: 'Input',
dependencies: {
triggerFields: [''],
show: () => false,
},
},
{
fieldName: 'storCode',
label: '仓库编码',
rules: 'required',
component: 'Input',
componentProps: {
placeholder: '请输入仓库编码',
},
},
{
fieldName: 'storName',
label: '仓库名称',
rules: 'required',
component: 'Input',
componentProps: {
placeholder: '请输入仓库名称',
},
},
{
fieldName: 'simpleName',
label: '仓库简称',
component: 'Input',
componentProps: {
placeholder: '请输入仓库简称',
},
},
{
fieldName: 'storCapacity',
label: '仓库容量',
component: 'Input',
componentProps: {
placeholder: '请输入仓库容量',
},
},
{
fieldName: 'totalArea',
label: '总面积',
component: 'Input',
componentProps: {
placeholder: '请输入总面积',
},
},
{
fieldName: 'storTypeScode',
label: '仓库性质',
rules: 'required',
component: 'Input',
componentProps: {
placeholder: '请输入仓库性质',
},
},
{
fieldName: 'isVirtualstore',
label: '是否虚拟库',
component: 'RadioGroup',
componentProps: {
options: getDictOptions(DICT_TYPE.INFRA_BOOLEAN_STRING, 'boolean'),
buttonStyle: 'solid',
optionType: 'button',
},
},
{
fieldName: 'isSemiFinished',
label: '是否半成品库',
component: 'RadioGroup',
componentProps: {
options: getDictOptions(DICT_TYPE.INFRA_BOOLEAN_STRING, 'boolean'),
buttonStyle: 'solid',
optionType: 'button',
},
},
{
fieldName: 'isMaterialstore',
label: '是否原料库',
component: 'RadioGroup',
componentProps: {
options: getDictOptions(DICT_TYPE.INFRA_BOOLEAN_STRING, 'boolean'),
buttonStyle: 'solid',
optionType: 'button',
},
},
{
fieldName: 'isProductstore',
label: '是否成品库',
component: 'RadioGroup',
componentProps: {
options: getDictOptions(DICT_TYPE.INFRA_BOOLEAN_STRING, 'boolean'),
buttonStyle: 'solid',
optionType: 'button',
},
},
{
fieldName: 'isAttachment',
label: '是否备件库',
component: 'RadioGroup',
componentProps: {
options: getDictOptions(DICT_TYPE.INFRA_BOOLEAN_STRING, 'boolean'),
buttonStyle: 'solid',
optionType: 'button',
},
},
{
fieldName: 'isReversed',
label: '是否允许红冲',
component: 'RadioGroup',
componentProps: {
options: getDictOptions(DICT_TYPE.INFRA_BOOLEAN_STRING, 'boolean'),
buttonStyle: 'solid',
optionType: 'button',
},
},
{
fieldName: 'isMvoutAutoCfm',
label: '是否移出业务自动确认',
component: 'RadioGroup',
componentProps: {
options: getDictOptions(DICT_TYPE.INFRA_BOOLEAN_STRING, 'boolean'),
buttonStyle: 'solid',
optionType: 'button',
},
},
{
fieldName: 'isMvinAutoCfm',
label: '是否移入业务自动确认',
component: 'RadioGroup',
componentProps: {
options: getDictOptions(DICT_TYPE.INFRA_BOOLEAN_STRING, 'boolean'),
buttonStyle: 'solid',
optionType: 'button',
},
},
{
fieldName: 'area',
label: '地区',
component: 'Input',
componentProps: {
placeholder: '请输入地区',
},
},
{
fieldName: 'storeaDdress',
label: '仓库地址',
component: 'Input',
componentProps: {
placeholder: '请输入仓库地址',
},
},
{
fieldName: 'principal',
label: '负责人',
component: 'Input',
componentProps: {
placeholder: '请输入负责人',
},
},
{
fieldName: 'officePhone',
label: '办公电话',
component: 'Input',
componentProps: {
placeholder: '请输入办公电话',
},
},
{
fieldName: 'mobileNo',
label: '负责人手机',
component: 'Input',
componentProps: {
placeholder: '请输入负责人手机',
},
},
{
fieldName: 'remark',
label: '备注',
component: 'Input',
componentProps: {
placeholder: '请输入备注',
},
},
{
fieldName: 'orderIndex',
label: '显示顺序',
component: 'Input',
componentProps: {
placeholder: '请输入显示顺序',
},
},
{
fieldName: 'whstateScode',
label: '状态',
rules: 'required',
component: 'Select',
componentProps: {
options: getDictOptions(DICT_TYPE.COMMON_STATUS, 'number'),
placeholder: '请选择状态',
allowClear: true,
},
},
{
fieldName: 'isUsed',
label: '是否启用',
rules: 'required',
component: 'RadioGroup',
componentProps: {
options: getDictOptions(DICT_TYPE.INFRA_BOOLEAN_STRING, 'boolean'),
buttonStyle: 'solid',
optionType: 'button',
},
},
{
fieldName: 'baseClassId',
label: '物料基本分类',
component: 'Input',
componentProps: {
placeholder: '请输入物料基本分类',
},
},
{
fieldName: 'sysownerid',
label: '拥有者ID',
component: 'Input',
componentProps: {
placeholder: '请输入拥有者ID',
},
},
{
fieldName: 'sysdeptid',
label: '部门ID',
component: 'Input',
componentProps: {
placeholder: '请输入部门ID',
},
},
{
fieldName: 'syscompanyid',
label: '公司ID',
component: 'Input',
componentProps: {
placeholder: '请输入公司ID',
},
},
{
fieldName: 'extId',
label: '外部标识',
component: 'Input',
componentProps: {
placeholder: '请输入外部标识',
},
},
{
fieldName: 'departName',
label: '部门名称',
component: 'Input',
componentProps: {
placeholder: '请输入部门名称',
},
},
{
fieldName: 'companyName',
label: '公司名称',
component: 'Input',
componentProps: {
placeholder: '请输入公司名称',
},
},
];
}
/** 列表的搜索表单 */
export function useGridFormSchema(): VbenFormSchema[] {
return [
{
fieldName: 'storCode',
label: '仓库编码',
component: 'Input',
componentProps: {
allowClear: true,
placeholder: '请输入仓库编码',
},
},
{
fieldName: 'storName',
label: '仓库名称',
component: 'Input',
componentProps: {
allowClear: true,
placeholder: '请输入仓库名称',
},
},
{
fieldName: 'simpleName',
label: '仓库简称',
component: 'Input',
componentProps: {
allowClear: true,
placeholder: '请输入仓库简称',
},
},
{
fieldName: 'storTypeScode',
label: '仓库性质',
component: 'Input',
componentProps: {
allowClear: true,
placeholder: '请输入仓库性质',
},
},
{
fieldName: 'area',
label: '地区',
component: 'Input',
componentProps: {
allowClear: true,
placeholder: '请输入地区',
},
},
{
fieldName: 'isUsed',
label: '是否启用',
component: 'Select',
componentProps: {
options: getDictOptions(DICT_TYPE.INFRA_BOOLEAN_STRING, 'boolean'),
placeholder: '请选择是否启用',
allowClear: true,
},
},
{
fieldName: 'createTime',
label: '创建时间',
component: 'RangePicker',
componentProps: {
...getRangePickerDefaultProps(),
allowClear: true,
},
},
];
}
/** 列表的字段 */
export function useGridColumns(): VxeTableGridOptions<WmsBsrealStorAttrApi.BsrealStorAttr>['columns'] {
return [
{ type: 'checkbox', width: 40 },
{
field: 'storCode',
title: '仓库编码',
minWidth: 120,
},
{
field: 'storName',
title: '仓库名称',
minWidth: 120,
},
{
field: 'simpleName',
title: '仓库简称',
minWidth: 120,
},
{
field: 'storCapacity',
title: '仓库容量',
minWidth: 120,
},
{
field: 'totalArea',
title: '总面积',
minWidth: 120,
},
{
field: 'storTypeScode',
title: '仓库性质',
minWidth: 120,
},
{
field: 'isVirtualstore',
title: '是否虚拟库',
minWidth: 120,
cellRender: {
name: 'CellDict',
props: { type: DICT_TYPE.INFRA_BOOLEAN_STRING },
},
},
{
field: 'isSemiFinished',
title: '是否半成品库',
minWidth: 120,
cellRender: {
name: 'CellDict',
props: { type: DICT_TYPE.INFRA_BOOLEAN_STRING },
},
},
{
field: 'isMaterialstore',
title: '是否原料库',
minWidth: 120,
cellRender: {
name: 'CellDict',
props: { type: DICT_TYPE.INFRA_BOOLEAN_STRING },
},
},
{
field: 'isProductstore',
title: '是否成品库',
minWidth: 120,
cellRender: {
name: 'CellDict',
props: { type: DICT_TYPE.INFRA_BOOLEAN_STRING },
},
},
{
field: 'isAttachment',
title: '是否备件库',
minWidth: 120,
cellRender: {
name: 'CellDict',
props: { type: DICT_TYPE.INFRA_BOOLEAN_STRING },
},
},
{
field: 'isReversed',
title: '是否允许红冲',
minWidth: 120,
cellRender: {
name: 'CellDict',
props: { type: DICT_TYPE.INFRA_BOOLEAN_STRING },
},
},
{
field: 'isMvoutAutoCfm',
title: '是否移出业务自动确认',
minWidth: 120,
cellRender: {
name: 'CellDict',
props: { type: DICT_TYPE.INFRA_BOOLEAN_STRING },
},
},
{
field: 'isMvinAutoCfm',
title: '是否移入业务自动确认',
minWidth: 120,
cellRender: {
name: 'CellDict',
props: { type: DICT_TYPE.INFRA_BOOLEAN_STRING },
},
},
{
field: 'area',
title: '地区',
minWidth: 120,
},
{
field: 'storeaDdress',
title: '仓库地址',
minWidth: 120,
},
{
field: 'principal',
title: '负责人',
minWidth: 120,
},
{
field: 'officePhone',
title: '办公电话',
minWidth: 120,
},
{
field: 'mobileNo',
title: '负责人手机',
minWidth: 120,
},
{
field: 'remark',
title: '备注',
minWidth: 120,
},
{
field: 'orderIndex',
title: '显示顺序',
minWidth: 120,
},
{
field: 'whstateScode',
title: '状态',
minWidth: 120,
cellRender: {
name: 'CellDict',
props: { type: DICT_TYPE.COMMON_STATUS },
},
},
{
field: 'isUsed',
title: '是否启用',
minWidth: 120,
cellRender: {
name: 'CellDict',
props: { type: DICT_TYPE.INFRA_BOOLEAN_STRING },
},
},
{
field: 'baseClassId',
title: '物料基本分类',
minWidth: 120,
},
{
field: 'createTime',
title: '创建时间',
minWidth: 120,
formatter: 'formatDateTime',
},
{
field: 'sysownerid',
title: '拥有者ID',
minWidth: 120,
},
{
field: 'sysdeptid',
title: '部门ID',
minWidth: 120,
},
{
field: 'syscompanyid',
title: '公司ID',
minWidth: 120,
},
{
field: 'extId',
title: '外部标识',
minWidth: 120,
},
{
field: 'departName',
title: '部门名称',
minWidth: 120,
},
{
field: 'companyName',
title: '公司名称',
minWidth: 120,
},
{
title: '操作',
width: 200,
fixed: 'right',
slots: { default: 'actions' },
},
];
}

View File

@@ -0,0 +1,186 @@
<script lang="ts" setup>
import type { VxeTableGridOptions } from '#/adapter/vxe-table';
import type { WmsBsrealStorAttrApi } from '#/api/wms/bsrealstorattr';
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 {
deleteBsrealStorAttr,
deleteBsrealStorAttrList,
exportBsrealStorAttr,
getBsrealStorAttrPage,
} from '#/api/wms/bsrealstorattr';
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: WmsBsrealStorAttrApi.BsrealStorAttr) {
formModalApi.setData(row).open();
}
/** 删除实物库属性 */
async function handleDelete(row: WmsBsrealStorAttrApi.BsrealStorAttr) {
const hideLoading = message.loading({
content: $t('ui.actionMessage.deleting', [row.id]),
duration: 0,
});
try {
await deleteBsrealStorAttr(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 deleteBsrealStorAttrList(checkedIds.value);
checkedIds.value = [];
message.success($t('ui.actionMessage.deleteSuccess'));
handleRefresh();
} finally {
hideLoading();
}
}
const checkedIds = ref<number[]>([]);
function handleRowCheckboxChange({
records,
}: {
records: WmsBsrealStorAttrApi.BsrealStorAttr[];
}) {
checkedIds.value = records.map((item) => item.id!);
}
/** 导出表格 */
async function handleExport() {
const data = await exportBsrealStorAttr(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 getBsrealStorAttrPage({
pageNo: page.currentPage,
pageSize: page.pageSize,
...formValues,
});
},
},
},
rowConfig: {
keyField: 'id',
isHover: true,
},
toolbarConfig: {
refresh: true,
search: true,
},
} as VxeTableGridOptions<WmsBsrealStorAttrApi.BsrealStorAttr>,
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:bsreal-stor-attr:create'],
onClick: handleCreate,
},
{
label: $t('ui.actionTitle.export'),
type: 'primary',
icon: ACTION_ICON.DOWNLOAD,
auth: ['wms:bsreal-stor-attr:export'],
onClick: handleExport,
},
{
label: $t('ui.actionTitle.deleteBatch'),
type: 'primary',
danger: true,
icon: ACTION_ICON.DELETE,
auth: ['wms:bsreal-stor-attr:delete'],
disabled: isEmpty(checkedIds),
onClick: handleDeleteBatch,
},
]"
/>
</template>
<template #actions="{ row }">
<TableAction
:actions="[
{
label: $t('common.edit'),
type: 'link',
icon: ACTION_ICON.EDIT,
auth: ['wms:bsreal-stor-attr:update'],
onClick: handleEdit.bind(null, row),
},
{
label: $t('common.delete'),
type: 'link',
danger: true,
icon: ACTION_ICON.DELETE,
auth: ['wms:bsreal-stor-attr:delete'],
popConfirm: {
title: $t('ui.actionMessage.deleteConfirm', [row.id]),
confirm: handleDelete.bind(null, row),
},
},
]"
/>
</template>
</Grid>
</Page>
</template>

View File

@@ -0,0 +1,82 @@
<script lang="ts" setup>
import type { WmsBsrealStorAttrApi } from '#/api/wms/bsrealstorattr';
import { computed, ref } from 'vue';
import { useVbenModal } from '@vben/common-ui';
import { message } from 'antdv-next';
import { useVbenForm } from '#/adapter/form';
import { createBsrealStorAttr, getBsrealStorAttr, updateBsrealStorAttr } from '#/api/wms/bsrealstorattr';
import { $t } from '#/locales';
import { useFormSchema } from '../data';
const emit = defineEmits(['success']);
const formData = ref<WmsBsrealStorAttrApi.BsrealStorAttr>();
const getTitle = computed(() => {
return formData.value?.id
? $t('ui.actionTitle.edit', ['实物库属性'])
: $t('ui.actionTitle.create', ['实物库属性']);
});
const [Form, formApi] = useVbenForm({
commonConfig: {
componentProps: {
class: 'w-full',
},
formItemClass: 'col-span-2',
labelWidth: 80,
},
layout: 'horizontal',
schema: useFormSchema(),
showDefaultActions: false,
});
const [Modal, modalApi] = useVbenModal({
async onConfirm() {
const { valid } = await formApi.validate();
if (!valid) {
return;
}
modalApi.lock();
// 提交表单
const data = (await formApi.getValues()) as WmsBsrealStorAttrApi.BsrealStorAttr;
try {
await (formData.value?.id ? updateBsrealStorAttr(data) : createBsrealStorAttr(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<WmsBsrealStorAttrApi.BsrealStorAttr>();
if (!data || !data.id) {
return;
}
modalApi.lock();
try {
formData.value = await getBsrealStorAttr(data.id);
// 设置到 values
await formApi.setValues(formData.value);
} finally {
modalApi.unlock();
}
},
});
</script>
<template>
<Modal :title="getTitle">
<Form class="mx-4" />
</Modal>
</template>