feat(mes): 迁移 SN 码并补齐条码业务选择器、修复库存台账
- 新增 wm/sn 模块(antd/ele):SN 码分组列表、生成弹窗、导出分组/明细、删除批次; api 补 generate/group-page/delete-batch/export 系列 - 补齐条码管理 USER/BATCH/PROCARD/PACKAGE 业务选择器并按源回填 bizCode/bizName - 新增 wm/batch 选择器与详情:WmBatchSelect/Dialog(搜索补齐生产任务、模具、 生产/有效/入库日期)、WmBatchDetail(useDescription);getBatchPage 收紧 PageParams - 新增 pro/card 共享 API 与 ProCardSelect/Dialog - 新增 system/user UserSelect/UserSelectDialog,部门树抽为 system/dept 共用 DeptTreeSelect,user 列表页改用共享组件 - 修复 wm/materialstock 冻结开关 beforeChange(newFrozen, row) 签名 bug、 批次号列可点开 WmBatchDetail、选择弹窗按 multiple 切 radio/checkbox - 选择器 resolveItemById 去掉 try/catch+console.error,清理 TODO @AIpull/350/head
parent
e313de09c4
commit
753fd0e506
|
|
@ -0,0 +1,68 @@
|
|||
import type { PageParam, PageResult } from '@vben/request';
|
||||
|
||||
import { requestClient } from '#/api/request';
|
||||
|
||||
export namespace MesWmSnApi {
|
||||
/** MES SN 码分组 */
|
||||
export interface SnGroup {
|
||||
uuid?: string; // 批次 UUID
|
||||
count?: number; // SN 码数量
|
||||
itemId?: number; // 物料编号
|
||||
itemCode?: string; // 物料编码
|
||||
itemName?: string; // 物料名称
|
||||
specification?: string; // 规格型号
|
||||
unitName?: string; // 单位名称
|
||||
batchCode?: string; // 批次号
|
||||
workOrderId?: number; // 生产工单编号
|
||||
createTime?: Date; // 生成时间
|
||||
}
|
||||
|
||||
/** MES SN 码生成参数 */
|
||||
export interface SnGenerate {
|
||||
itemId?: number; // 物料编号
|
||||
batchCode?: string; // 批次号
|
||||
workOrderId?: number; // 生产工单编号
|
||||
count?: number; // 生成数量
|
||||
}
|
||||
|
||||
/** MES SN 码分组分页查询参数 */
|
||||
export interface PageParams extends PageParam {
|
||||
uuid?: string;
|
||||
code?: string;
|
||||
itemId?: number;
|
||||
batchCode?: string;
|
||||
createTime?: string[];
|
||||
}
|
||||
}
|
||||
|
||||
/** 生成 SN 码 */
|
||||
export function generateSnCodes(data: MesWmSnApi.SnGenerate) {
|
||||
return requestClient.post('/mes/wm/sn/generate', data);
|
||||
}
|
||||
|
||||
/** 查询 SN 码分组分页 */
|
||||
export function getSnGroupPage(params: MesWmSnApi.PageParams) {
|
||||
return requestClient.get<PageResult<MesWmSnApi.SnGroup>>(
|
||||
'/mes/wm/sn/group-page',
|
||||
{ params },
|
||||
);
|
||||
}
|
||||
|
||||
/** 批量删除 SN 码(按批次 UUID) */
|
||||
export function deleteSnBatch(uuid: string) {
|
||||
return requestClient.delete('/mes/wm/sn/delete-batch', {
|
||||
params: { uuid },
|
||||
});
|
||||
}
|
||||
|
||||
/** 导出 SN 码分组 Excel */
|
||||
export function exportSnGroupExcel(params: MesWmSnApi.PageParams) {
|
||||
return requestClient.download('/mes/wm/sn/group-export-excel', { params });
|
||||
}
|
||||
|
||||
/** 导出批次 SN 码明细 Excel */
|
||||
export function exportSnDetailExcel(uuid: string) {
|
||||
return requestClient.download('/mes/wm/sn/export-excel', {
|
||||
params: { uuid },
|
||||
});
|
||||
}
|
||||
|
|
@ -72,7 +72,6 @@ export function useGridFormSchema(): VbenFormSchema[] {
|
|||
}
|
||||
|
||||
/** 列表的字段 */
|
||||
// TODO @AI:看看别的模块,是不是会叫 onFrozenChange?还是一般叫什么梗合适???
|
||||
export function useGridColumns(
|
||||
onFrozenChange: (
|
||||
newFrozen: boolean,
|
||||
|
|
|
|||
|
|
@ -0,0 +1,134 @@
|
|||
import type { VbenFormSchema } from '#/adapter/form';
|
||||
import type { VxeTableGridOptions } from '#/adapter/vxe-table';
|
||||
import type { MesWmSnApi } from '#/api/mes/wm/sn';
|
||||
|
||||
import { markRaw } from 'vue';
|
||||
|
||||
import { getRangePickerDefaultProps } from '#/utils';
|
||||
import MdItemSelect from '#/views/mes/md/item/components/md-item-select.vue';
|
||||
|
||||
/** 生成 SN 码的表单 */
|
||||
export function useFormSchema(): VbenFormSchema[] {
|
||||
return [
|
||||
{
|
||||
fieldName: 'itemId',
|
||||
label: '物料',
|
||||
component: markRaw(MdItemSelect),
|
||||
componentProps: {
|
||||
placeholder: '请选择物料',
|
||||
},
|
||||
rules: 'required',
|
||||
},
|
||||
{
|
||||
fieldName: 'batchCode',
|
||||
label: '批次号',
|
||||
component: 'Input',
|
||||
componentProps: {
|
||||
allowClear: true,
|
||||
maxlength: 100,
|
||||
placeholder: '请输入批次号',
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldName: 'count',
|
||||
label: '生成数量',
|
||||
component: 'InputNumber',
|
||||
componentProps: {
|
||||
class: '!w-full',
|
||||
max: 1000,
|
||||
min: 1,
|
||||
placeholder: '请输入生成数量',
|
||||
},
|
||||
rules: 'required',
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
/** 列表的搜索表单 */
|
||||
export function useGridFormSchema(): VbenFormSchema[] {
|
||||
return [
|
||||
{
|
||||
fieldName: 'code',
|
||||
label: 'SN 码',
|
||||
component: 'Input',
|
||||
componentProps: {
|
||||
allowClear: true,
|
||||
placeholder: '请输入 SN 码',
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldName: 'itemId',
|
||||
label: '物料',
|
||||
component: markRaw(MdItemSelect),
|
||||
componentProps: {
|
||||
placeholder: '请选择物料',
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldName: 'batchCode',
|
||||
label: '批次号',
|
||||
component: 'Input',
|
||||
componentProps: {
|
||||
allowClear: true,
|
||||
placeholder: '请输入批次号',
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldName: 'createTime',
|
||||
label: '创建时间',
|
||||
component: 'RangePicker',
|
||||
componentProps: {
|
||||
...getRangePickerDefaultProps(),
|
||||
allowClear: true,
|
||||
},
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
/** 列表的字段 */
|
||||
export function useGridColumns(): VxeTableGridOptions<MesWmSnApi.SnGroup>['columns'] {
|
||||
return [
|
||||
{
|
||||
field: 'itemCode',
|
||||
title: '物料编码',
|
||||
minWidth: 120,
|
||||
},
|
||||
{
|
||||
field: 'itemName',
|
||||
title: '物料名称',
|
||||
minWidth: 150,
|
||||
},
|
||||
{
|
||||
field: 'specification',
|
||||
title: '规格型号',
|
||||
minWidth: 120,
|
||||
},
|
||||
{
|
||||
field: 'unitName',
|
||||
title: '单位',
|
||||
width: 80,
|
||||
},
|
||||
{
|
||||
field: 'batchCode',
|
||||
title: '批次号',
|
||||
minWidth: 120,
|
||||
},
|
||||
{
|
||||
field: 'count',
|
||||
title: 'SN 码数量',
|
||||
width: 100,
|
||||
},
|
||||
{
|
||||
field: 'createTime',
|
||||
title: '生成时间',
|
||||
width: 180,
|
||||
formatter: 'formatDateTime',
|
||||
},
|
||||
{
|
||||
title: '操作',
|
||||
width: 180,
|
||||
fixed: 'right',
|
||||
slots: { default: 'actions' },
|
||||
},
|
||||
];
|
||||
}
|
||||
|
|
@ -0,0 +1,153 @@
|
|||
<script lang="ts" setup>
|
||||
import type { VxeTableGridOptions } from '#/adapter/vxe-table';
|
||||
import type { MesWmSnApi } from '#/api/mes/wm/sn';
|
||||
|
||||
import { DocAlert, Page, useVbenModal } from '@vben/common-ui';
|
||||
import { downloadFileFromBlobPart } from '@vben/utils';
|
||||
|
||||
import { message } from 'ant-design-vue';
|
||||
|
||||
import { ACTION_ICON, TableAction, useVbenVxeGrid } from '#/adapter/vxe-table';
|
||||
import {
|
||||
deleteSnBatch,
|
||||
exportSnDetailExcel,
|
||||
exportSnGroupExcel,
|
||||
getSnGroupPage,
|
||||
} from '#/api/mes/wm/sn';
|
||||
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();
|
||||
}
|
||||
|
||||
/** 生成 SN 码 */
|
||||
function handleCreate() {
|
||||
formModalApi.setData(null).open();
|
||||
}
|
||||
|
||||
/** 导出分组表格 */
|
||||
async function handleExport() {
|
||||
const data = await exportSnGroupExcel(await gridApi.formApi.getValues());
|
||||
downloadFileFromBlobPart({ fileName: 'SN码分组.xls', source: data });
|
||||
}
|
||||
|
||||
/** 导出批次明细 */
|
||||
async function handleExportDetail(row: MesWmSnApi.SnGroup) {
|
||||
const data = await exportSnDetailExcel(row.uuid!);
|
||||
downloadFileFromBlobPart({ fileName: 'SN码明细.xls', source: data });
|
||||
}
|
||||
|
||||
/** 删除 SN 码批次 */
|
||||
async function handleDelete(row: MesWmSnApi.SnGroup) {
|
||||
const hideLoading = message.loading({
|
||||
content: $t('ui.actionMessage.deleting', [row.batchCode || row.itemName]),
|
||||
duration: 0,
|
||||
});
|
||||
try {
|
||||
await deleteSnBatch(row.uuid!);
|
||||
message.success($t('ui.actionMessage.deleteSuccess', [row.batchCode || '']));
|
||||
handleRefresh();
|
||||
} finally {
|
||||
hideLoading();
|
||||
}
|
||||
}
|
||||
|
||||
const [Grid, gridApi] = useVbenVxeGrid({
|
||||
formOptions: {
|
||||
schema: useGridFormSchema(),
|
||||
},
|
||||
gridOptions: {
|
||||
columns: useGridColumns(),
|
||||
height: 'auto',
|
||||
keepSource: true,
|
||||
proxyConfig: {
|
||||
ajax: {
|
||||
query: async ({ page }, formValues) => {
|
||||
return await getSnGroupPage({
|
||||
pageNo: page.currentPage,
|
||||
pageSize: page.pageSize,
|
||||
...formValues,
|
||||
});
|
||||
},
|
||||
},
|
||||
},
|
||||
rowConfig: {
|
||||
keyField: 'uuid',
|
||||
isHover: true,
|
||||
},
|
||||
toolbarConfig: {
|
||||
refresh: true,
|
||||
search: true,
|
||||
},
|
||||
} as VxeTableGridOptions<MesWmSnApi.SnGroup>,
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Page auto-content-height>
|
||||
<template #doc>
|
||||
<DocAlert
|
||||
title="【仓库】仓库与库区库位、条码赋码、SN码"
|
||||
url="https://doc.iocoder.cn/mes/wm/warehouse-setup/"
|
||||
/>
|
||||
</template>
|
||||
|
||||
<FormModal @success="handleRefresh" />
|
||||
|
||||
<Grid table-title="SN 码列表">
|
||||
<template #toolbar-tools>
|
||||
<TableAction
|
||||
:actions="[
|
||||
{
|
||||
label: '生成 SN 码',
|
||||
type: 'primary',
|
||||
icon: ACTION_ICON.ADD,
|
||||
auth: ['mes:wm-sn:create'],
|
||||
onClick: handleCreate,
|
||||
},
|
||||
{
|
||||
label: $t('ui.actionTitle.export'),
|
||||
type: 'primary',
|
||||
icon: ACTION_ICON.DOWNLOAD,
|
||||
auth: ['mes:wm-sn:export'],
|
||||
onClick: handleExport,
|
||||
},
|
||||
]"
|
||||
/>
|
||||
</template>
|
||||
<template #actions="{ row }">
|
||||
<TableAction
|
||||
:actions="[
|
||||
{
|
||||
label: '导出明细',
|
||||
type: 'link',
|
||||
auth: ['mes:wm-sn:export'],
|
||||
onClick: handleExportDetail.bind(null, row),
|
||||
},
|
||||
{
|
||||
label: $t('common.delete'),
|
||||
type: 'link',
|
||||
danger: true,
|
||||
auth: ['mes:wm-sn:delete'],
|
||||
popConfirm: {
|
||||
title: $t('ui.actionMessage.deleteConfirm', [
|
||||
row.batchCode || row.itemName,
|
||||
]),
|
||||
confirm: handleDelete.bind(null, row),
|
||||
},
|
||||
},
|
||||
]"
|
||||
/>
|
||||
</template>
|
||||
</Grid>
|
||||
</Page>
|
||||
</template>
|
||||
|
|
@ -0,0 +1,62 @@
|
|||
<script lang="ts" setup>
|
||||
import type { MesWmSnApi } from '#/api/mes/wm/sn';
|
||||
|
||||
import { useVbenModal } from '@vben/common-ui';
|
||||
|
||||
import { message } from 'ant-design-vue';
|
||||
|
||||
import { useVbenForm } from '#/adapter/form';
|
||||
import { generateSnCodes } from '#/api/mes/wm/sn';
|
||||
import { $t } from '#/locales';
|
||||
|
||||
import { useFormSchema } from '../data';
|
||||
|
||||
const emit = defineEmits(['success']);
|
||||
|
||||
const [Form, formApi] = useVbenForm({
|
||||
commonConfig: {
|
||||
componentProps: {
|
||||
class: 'w-full',
|
||||
},
|
||||
formItemClass: 'col-span-2',
|
||||
labelWidth: 100,
|
||||
},
|
||||
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 MesWmSnApi.SnGenerate;
|
||||
try {
|
||||
await generateSnCodes(data);
|
||||
// 关闭并提示
|
||||
await modalApi.close();
|
||||
emit('success');
|
||||
message.success('生成成功');
|
||||
} finally {
|
||||
modalApi.unlock();
|
||||
}
|
||||
},
|
||||
async onOpenChange(isOpen: boolean) {
|
||||
if (!isOpen) {
|
||||
return;
|
||||
}
|
||||
await formApi.resetForm();
|
||||
await formApi.setValues({ count: 100 });
|
||||
},
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Modal :title="$t('ui.actionTitle.create', ['SN 码'])" class="w-1/2">
|
||||
<Form class="mx-4" />
|
||||
</Modal>
|
||||
</template>
|
||||
|
|
@ -0,0 +1,68 @@
|
|||
import type { PageParam, PageResult } from '@vben/request';
|
||||
|
||||
import { requestClient } from '#/api/request';
|
||||
|
||||
export namespace MesWmSnApi {
|
||||
/** MES SN 码分组 */
|
||||
export interface SnGroup {
|
||||
uuid?: string; // 批次 UUID
|
||||
count?: number; // SN 码数量
|
||||
itemId?: number; // 物料编号
|
||||
itemCode?: string; // 物料编码
|
||||
itemName?: string; // 物料名称
|
||||
specification?: string; // 规格型号
|
||||
unitName?: string; // 单位名称
|
||||
batchCode?: string; // 批次号
|
||||
workOrderId?: number; // 生产工单编号
|
||||
createTime?: Date; // 生成时间
|
||||
}
|
||||
|
||||
/** MES SN 码生成参数 */
|
||||
export interface SnGenerate {
|
||||
itemId?: number; // 物料编号
|
||||
batchCode?: string; // 批次号
|
||||
workOrderId?: number; // 生产工单编号
|
||||
count?: number; // 生成数量
|
||||
}
|
||||
|
||||
/** MES SN 码分组分页查询参数 */
|
||||
export interface PageParams extends PageParam {
|
||||
uuid?: string;
|
||||
code?: string;
|
||||
itemId?: number;
|
||||
batchCode?: string;
|
||||
createTime?: string[];
|
||||
}
|
||||
}
|
||||
|
||||
/** 生成 SN 码 */
|
||||
export function generateSnCodes(data: MesWmSnApi.SnGenerate) {
|
||||
return requestClient.post('/mes/wm/sn/generate', data);
|
||||
}
|
||||
|
||||
/** 查询 SN 码分组分页 */
|
||||
export function getSnGroupPage(params: MesWmSnApi.PageParams) {
|
||||
return requestClient.get<PageResult<MesWmSnApi.SnGroup>>(
|
||||
'/mes/wm/sn/group-page',
|
||||
{ params },
|
||||
);
|
||||
}
|
||||
|
||||
/** 批量删除 SN 码(按批次 UUID) */
|
||||
export function deleteSnBatch(uuid: string) {
|
||||
return requestClient.delete('/mes/wm/sn/delete-batch', {
|
||||
params: { uuid },
|
||||
});
|
||||
}
|
||||
|
||||
/** 导出 SN 码分组 Excel */
|
||||
export function exportSnGroupExcel(params: MesWmSnApi.PageParams) {
|
||||
return requestClient.download('/mes/wm/sn/group-export-excel', { params });
|
||||
}
|
||||
|
||||
/** 导出批次 SN 码明细 Excel */
|
||||
export function exportSnDetailExcel(uuid: string) {
|
||||
return requestClient.download('/mes/wm/sn/export-excel', {
|
||||
params: { uuid },
|
||||
});
|
||||
}
|
||||
|
|
@ -0,0 +1,135 @@
|
|||
import type { VbenFormSchema } from '#/adapter/form';
|
||||
import type { VxeTableGridOptions } from '#/adapter/vxe-table';
|
||||
import type { MesWmSnApi } from '#/api/mes/wm/sn';
|
||||
|
||||
import { markRaw } from 'vue';
|
||||
|
||||
import { getRangePickerDefaultProps } from '#/utils';
|
||||
import MdItemSelect from '#/views/mes/md/item/components/md-item-select.vue';
|
||||
|
||||
/** 生成 SN 码的表单 */
|
||||
export function useFormSchema(): VbenFormSchema[] {
|
||||
return [
|
||||
{
|
||||
fieldName: 'itemId',
|
||||
label: '物料',
|
||||
component: markRaw(MdItemSelect),
|
||||
componentProps: {
|
||||
placeholder: '请选择物料',
|
||||
},
|
||||
rules: 'required',
|
||||
},
|
||||
{
|
||||
fieldName: 'batchCode',
|
||||
label: '批次号',
|
||||
component: 'Input',
|
||||
componentProps: {
|
||||
clearable: true,
|
||||
maxlength: 100,
|
||||
placeholder: '请输入批次号',
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldName: 'count',
|
||||
label: '生成数量',
|
||||
component: 'InputNumber',
|
||||
componentProps: {
|
||||
class: '!w-full',
|
||||
controlsPosition: 'right',
|
||||
max: 1000,
|
||||
min: 1,
|
||||
placeholder: '请输入生成数量',
|
||||
},
|
||||
rules: 'required',
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
/** 列表的搜索表单 */
|
||||
export function useGridFormSchema(): VbenFormSchema[] {
|
||||
return [
|
||||
{
|
||||
fieldName: 'code',
|
||||
label: 'SN 码',
|
||||
component: 'Input',
|
||||
componentProps: {
|
||||
clearable: true,
|
||||
placeholder: '请输入 SN 码',
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldName: 'itemId',
|
||||
label: '物料',
|
||||
component: markRaw(MdItemSelect),
|
||||
componentProps: {
|
||||
placeholder: '请选择物料',
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldName: 'batchCode',
|
||||
label: '批次号',
|
||||
component: 'Input',
|
||||
componentProps: {
|
||||
clearable: true,
|
||||
placeholder: '请输入批次号',
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldName: 'createTime',
|
||||
label: '创建时间',
|
||||
component: 'RangePicker',
|
||||
componentProps: {
|
||||
...getRangePickerDefaultProps(),
|
||||
clearable: true,
|
||||
},
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
/** 列表的字段 */
|
||||
export function useGridColumns(): VxeTableGridOptions<MesWmSnApi.SnGroup>['columns'] {
|
||||
return [
|
||||
{
|
||||
field: 'itemCode',
|
||||
title: '物料编码',
|
||||
minWidth: 120,
|
||||
},
|
||||
{
|
||||
field: 'itemName',
|
||||
title: '物料名称',
|
||||
minWidth: 150,
|
||||
},
|
||||
{
|
||||
field: 'specification',
|
||||
title: '规格型号',
|
||||
minWidth: 120,
|
||||
},
|
||||
{
|
||||
field: 'unitName',
|
||||
title: '单位',
|
||||
width: 80,
|
||||
},
|
||||
{
|
||||
field: 'batchCode',
|
||||
title: '批次号',
|
||||
minWidth: 120,
|
||||
},
|
||||
{
|
||||
field: 'count',
|
||||
title: 'SN 码数量',
|
||||
width: 100,
|
||||
},
|
||||
{
|
||||
field: 'createTime',
|
||||
title: '生成时间',
|
||||
width: 180,
|
||||
formatter: 'formatDateTime',
|
||||
},
|
||||
{
|
||||
title: '操作',
|
||||
width: 180,
|
||||
fixed: 'right',
|
||||
slots: { default: 'actions' },
|
||||
},
|
||||
];
|
||||
}
|
||||
|
|
@ -0,0 +1,155 @@
|
|||
<script lang="ts" setup>
|
||||
import type { VxeTableGridOptions } from '#/adapter/vxe-table';
|
||||
import type { MesWmSnApi } from '#/api/mes/wm/sn';
|
||||
|
||||
import { DocAlert, Page, useVbenModal } from '@vben/common-ui';
|
||||
import { downloadFileFromBlobPart } from '@vben/utils';
|
||||
|
||||
import { ElLoading, ElMessage } from 'element-plus';
|
||||
|
||||
import { ACTION_ICON, TableAction, useVbenVxeGrid } from '#/adapter/vxe-table';
|
||||
import {
|
||||
deleteSnBatch,
|
||||
exportSnDetailExcel,
|
||||
exportSnGroupExcel,
|
||||
getSnGroupPage,
|
||||
} from '#/api/mes/wm/sn';
|
||||
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();
|
||||
}
|
||||
|
||||
/** 生成 SN 码 */
|
||||
function handleCreate() {
|
||||
formModalApi.setData(null).open();
|
||||
}
|
||||
|
||||
/** 导出分组表格 */
|
||||
async function handleExport() {
|
||||
const data = await exportSnGroupExcel(await gridApi.formApi.getValues());
|
||||
downloadFileFromBlobPart({ fileName: 'SN码分组.xls', source: data });
|
||||
}
|
||||
|
||||
/** 导出批次明细 */
|
||||
async function handleExportDetail(row: MesWmSnApi.SnGroup) {
|
||||
const data = await exportSnDetailExcel(row.uuid!);
|
||||
downloadFileFromBlobPart({ fileName: 'SN码明细.xls', source: data });
|
||||
}
|
||||
|
||||
/** 删除 SN 码批次 */
|
||||
async function handleDelete(row: MesWmSnApi.SnGroup) {
|
||||
const loadingInstance = ElLoading.service({
|
||||
text: $t('ui.actionMessage.deleting', [row.batchCode || row.itemName]),
|
||||
});
|
||||
try {
|
||||
await deleteSnBatch(row.uuid!);
|
||||
ElMessage.success(
|
||||
$t('ui.actionMessage.deleteSuccess', [row.batchCode || '']),
|
||||
);
|
||||
handleRefresh();
|
||||
} finally {
|
||||
loadingInstance.close();
|
||||
}
|
||||
}
|
||||
|
||||
const [Grid, gridApi] = useVbenVxeGrid({
|
||||
formOptions: {
|
||||
schema: useGridFormSchema(),
|
||||
},
|
||||
gridOptions: {
|
||||
columns: useGridColumns(),
|
||||
height: 'auto',
|
||||
keepSource: true,
|
||||
proxyConfig: {
|
||||
ajax: {
|
||||
query: async ({ page }, formValues) => {
|
||||
return await getSnGroupPage({
|
||||
pageNo: page.currentPage,
|
||||
pageSize: page.pageSize,
|
||||
...formValues,
|
||||
});
|
||||
},
|
||||
},
|
||||
},
|
||||
rowConfig: {
|
||||
keyField: 'uuid',
|
||||
isHover: true,
|
||||
},
|
||||
toolbarConfig: {
|
||||
refresh: true,
|
||||
search: true,
|
||||
},
|
||||
} as VxeTableGridOptions<MesWmSnApi.SnGroup>,
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Page auto-content-height>
|
||||
<template #doc>
|
||||
<DocAlert
|
||||
title="【仓库】仓库与库区库位、条码赋码、SN码"
|
||||
url="https://doc.iocoder.cn/mes/wm/warehouse-setup/"
|
||||
/>
|
||||
</template>
|
||||
|
||||
<FormModal @success="handleRefresh" />
|
||||
|
||||
<Grid table-title="SN 码列表">
|
||||
<template #toolbar-tools>
|
||||
<TableAction
|
||||
:actions="[
|
||||
{
|
||||
label: '生成 SN 码',
|
||||
type: 'primary',
|
||||
icon: ACTION_ICON.ADD,
|
||||
auth: ['mes:wm-sn:create'],
|
||||
onClick: handleCreate,
|
||||
},
|
||||
{
|
||||
label: $t('ui.actionTitle.export'),
|
||||
type: 'primary',
|
||||
icon: ACTION_ICON.DOWNLOAD,
|
||||
auth: ['mes:wm-sn:export'],
|
||||
onClick: handleExport,
|
||||
},
|
||||
]"
|
||||
/>
|
||||
</template>
|
||||
<template #actions="{ row }">
|
||||
<TableAction
|
||||
:actions="[
|
||||
{
|
||||
label: '导出明细',
|
||||
type: 'primary',
|
||||
link: true,
|
||||
auth: ['mes:wm-sn:export'],
|
||||
onClick: handleExportDetail.bind(null, row),
|
||||
},
|
||||
{
|
||||
label: $t('common.delete'),
|
||||
type: 'danger',
|
||||
link: true,
|
||||
auth: ['mes:wm-sn:delete'],
|
||||
popConfirm: {
|
||||
title: $t('ui.actionMessage.deleteConfirm', [
|
||||
row.batchCode || row.itemName,
|
||||
]),
|
||||
confirm: handleDelete.bind(null, row),
|
||||
},
|
||||
},
|
||||
]"
|
||||
/>
|
||||
</template>
|
||||
</Grid>
|
||||
</Page>
|
||||
</template>
|
||||
|
|
@ -0,0 +1,62 @@
|
|||
<script lang="ts" setup>
|
||||
import type { MesWmSnApi } from '#/api/mes/wm/sn';
|
||||
|
||||
import { useVbenModal } from '@vben/common-ui';
|
||||
|
||||
import { ElMessage } from 'element-plus';
|
||||
|
||||
import { useVbenForm } from '#/adapter/form';
|
||||
import { generateSnCodes } from '#/api/mes/wm/sn';
|
||||
import { $t } from '#/locales';
|
||||
|
||||
import { useFormSchema } from '../data';
|
||||
|
||||
const emit = defineEmits(['success']);
|
||||
|
||||
const [Form, formApi] = useVbenForm({
|
||||
commonConfig: {
|
||||
componentProps: {
|
||||
class: 'w-full',
|
||||
},
|
||||
formItemClass: 'col-span-2',
|
||||
labelWidth: 100,
|
||||
},
|
||||
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 MesWmSnApi.SnGenerate;
|
||||
try {
|
||||
await generateSnCodes(data);
|
||||
// 关闭并提示
|
||||
await modalApi.close();
|
||||
emit('success');
|
||||
ElMessage.success('生成成功');
|
||||
} finally {
|
||||
modalApi.unlock();
|
||||
}
|
||||
},
|
||||
async onOpenChange(isOpen: boolean) {
|
||||
if (!isOpen) {
|
||||
return;
|
||||
}
|
||||
await formApi.resetForm();
|
||||
await formApi.setValues({ count: 100 });
|
||||
},
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Modal :title="$t('ui.actionTitle.create', ['SN 码'])" class="w-1/2">
|
||||
<Form class="mx-4" />
|
||||
</Modal>
|
||||
</template>
|
||||
Loading…
Reference in New Issue