feat(mes): 迁移 wm transfer 模块
parent
dd4b7e045a
commit
c8deb9e91e
|
|
@ -0,0 +1,645 @@
|
|||
import type { VbenFormApi, VbenFormSchema } from '#/adapter/form';
|
||||
import type { VxeTableGridOptions } from '#/adapter/vxe-table';
|
||||
import type { MesWmMaterialStockApi } from '#/api/mes/wm/materialstock';
|
||||
import type { MesWmTransferApi } from '#/api/mes/wm/transfer';
|
||||
import type { MesWmTransferDetailApi } from '#/api/mes/wm/transfer/detail';
|
||||
import type { MesWmTransferLineApi } from '#/api/mes/wm/transfer/line';
|
||||
|
||||
import { h, markRaw } from 'vue';
|
||||
|
||||
import { DICT_TYPE } from '@vben/constants';
|
||||
import { getDictOptions } from '@vben/hooks';
|
||||
|
||||
import { Button } from 'ant-design-vue';
|
||||
|
||||
import { generateAutoCode } from '#/api/mes/md/autocode/record';
|
||||
import { MdItemSelect } from '#/views/mes/md/item/components';
|
||||
import {
|
||||
MesAutoCodeRuleCode,
|
||||
MesWmTransferTypeEnum,
|
||||
} from '#/views/mes/utils/constants';
|
||||
import { WmMaterialStockSelect } from '#/views/mes/wm/materialstock/components';
|
||||
import {
|
||||
WmWarehouseAreaSelect,
|
||||
WmWarehouseLocationSelect,
|
||||
WmWarehouseSelect,
|
||||
} from '#/views/mes/wm/warehouse/components';
|
||||
|
||||
/** 表单类型 */
|
||||
export type FormType =
|
||||
| 'confirm'
|
||||
| 'create'
|
||||
| 'detail'
|
||||
| 'finish'
|
||||
| 'stock'
|
||||
| 'update';
|
||||
|
||||
/** 表头是否只读(上架、确认、执行、详情态) */
|
||||
function isHeaderReadonly(formType: FormType): boolean {
|
||||
return ['confirm', 'detail', 'finish', 'stock'].includes(formType);
|
||||
}
|
||||
|
||||
/** 新增/修改的表单 */
|
||||
export function useFormSchema(
|
||||
formType: FormType,
|
||||
formApi?: VbenFormApi,
|
||||
): VbenFormSchema[] {
|
||||
const headerReadonly = isHeaderReadonly(formType);
|
||||
return [
|
||||
{
|
||||
fieldName: 'id',
|
||||
component: 'Input',
|
||||
dependencies: {
|
||||
triggerFields: [''],
|
||||
show: () => false,
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldName: 'status',
|
||||
component: 'Input',
|
||||
dependencies: {
|
||||
triggerFields: [''],
|
||||
show: () => false,
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldName: 'code',
|
||||
label: '转移单编号',
|
||||
component: 'Input',
|
||||
componentProps: {
|
||||
disabled: headerReadonly,
|
||||
placeholder: '请输入转移单编号',
|
||||
},
|
||||
rules: 'required',
|
||||
suffix:
|
||||
formType === 'create' || formType === 'update'
|
||||
? () =>
|
||||
h(
|
||||
Button,
|
||||
{
|
||||
type: 'default',
|
||||
onClick: async () => {
|
||||
const code = await generateAutoCode(
|
||||
MesAutoCodeRuleCode.TRANSFER_CODE,
|
||||
);
|
||||
await formApi?.setFieldValue('code', code);
|
||||
},
|
||||
},
|
||||
{ default: () => '生成' },
|
||||
)
|
||||
: undefined,
|
||||
},
|
||||
{
|
||||
fieldName: 'name',
|
||||
label: '转移单名称',
|
||||
component: 'Input',
|
||||
componentProps: {
|
||||
disabled: headerReadonly,
|
||||
placeholder: '请输入转移单名称',
|
||||
},
|
||||
rules: 'required',
|
||||
},
|
||||
{
|
||||
fieldName: 'type',
|
||||
label: '转移单类型',
|
||||
component: 'Select',
|
||||
componentProps: {
|
||||
disabled: headerReadonly,
|
||||
options: getDictOptions(DICT_TYPE.MES_WM_TRANSFER_TYPE, 'number'),
|
||||
placeholder: '请选择转移单类型',
|
||||
},
|
||||
rules: 'selectRequired',
|
||||
},
|
||||
{
|
||||
fieldName: 'transferDate',
|
||||
label: '转移日期',
|
||||
component: 'DatePicker',
|
||||
componentProps: {
|
||||
class: '!w-full',
|
||||
disabled: headerReadonly,
|
||||
format: 'YYYY-MM-DD',
|
||||
placeholder: '请选择转移日期',
|
||||
valueFormat: 'YYYY-MM-DD 00:00:00',
|
||||
},
|
||||
rules: 'required',
|
||||
},
|
||||
{
|
||||
fieldName: 'deliveryFlag',
|
||||
label: '是否配送',
|
||||
component: 'Switch',
|
||||
componentProps: {
|
||||
disabled: headerReadonly,
|
||||
},
|
||||
dependencies: {
|
||||
triggerFields: ['type'],
|
||||
show: (values) => values.type === MesWmTransferTypeEnum.OUTER,
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldName: 'confirmFlag',
|
||||
label: '是否确认',
|
||||
component: 'Switch',
|
||||
componentProps: {
|
||||
disabled: true,
|
||||
},
|
||||
dependencies: {
|
||||
triggerFields: ['type'],
|
||||
show: (values) => values.type === MesWmTransferTypeEnum.OUTER,
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldName: 'recipientName',
|
||||
label: '收货人',
|
||||
component: 'Input',
|
||||
componentProps: {
|
||||
disabled: headerReadonly,
|
||||
placeholder: '请输入收货人',
|
||||
},
|
||||
dependencies: {
|
||||
triggerFields: ['type', 'deliveryFlag'],
|
||||
show: (values) =>
|
||||
values.type === MesWmTransferTypeEnum.OUTER && !!values.deliveryFlag,
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldName: 'recipientTelephone',
|
||||
label: '联系电话',
|
||||
component: 'Input',
|
||||
componentProps: {
|
||||
disabled: headerReadonly,
|
||||
placeholder: '请输入联系电话',
|
||||
},
|
||||
dependencies: {
|
||||
triggerFields: ['type', 'deliveryFlag'],
|
||||
show: (values) =>
|
||||
values.type === MesWmTransferTypeEnum.OUTER && !!values.deliveryFlag,
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldName: 'carrier',
|
||||
label: '承运商',
|
||||
component: 'Input',
|
||||
componentProps: {
|
||||
disabled: headerReadonly,
|
||||
placeholder: '请输入承运商',
|
||||
},
|
||||
dependencies: {
|
||||
triggerFields: ['type', 'deliveryFlag'],
|
||||
show: (values) =>
|
||||
values.type === MesWmTransferTypeEnum.OUTER && !!values.deliveryFlag,
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldName: 'shippingNumber',
|
||||
label: '运输单号',
|
||||
component: 'Input',
|
||||
componentProps: {
|
||||
disabled: headerReadonly,
|
||||
placeholder: '请输入运输单号',
|
||||
},
|
||||
dependencies: {
|
||||
triggerFields: ['type', 'deliveryFlag'],
|
||||
show: (values) =>
|
||||
values.type === MesWmTransferTypeEnum.OUTER && !!values.deliveryFlag,
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldName: 'destinationAddress',
|
||||
label: '目的地',
|
||||
component: 'Input',
|
||||
formItemClass: 'col-span-2',
|
||||
componentProps: {
|
||||
disabled: headerReadonly,
|
||||
placeholder: '请输入目的地',
|
||||
},
|
||||
dependencies: {
|
||||
triggerFields: ['type', 'deliveryFlag'],
|
||||
show: (values) =>
|
||||
values.type === MesWmTransferTypeEnum.OUTER && !!values.deliveryFlag,
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldName: 'remark',
|
||||
label: '备注',
|
||||
component: 'Textarea',
|
||||
formItemClass: 'col-span-3',
|
||||
componentProps: {
|
||||
disabled: headerReadonly,
|
||||
placeholder: '请输入备注',
|
||||
rows: 3,
|
||||
},
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
/** 列表的搜索表单 */
|
||||
export function useGridFormSchema(): VbenFormSchema[] {
|
||||
return [
|
||||
{
|
||||
fieldName: 'code',
|
||||
label: '转移单编号',
|
||||
component: 'Input',
|
||||
componentProps: {
|
||||
allowClear: true,
|
||||
placeholder: '请输入转移单编号',
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldName: 'name',
|
||||
label: '转移单名称',
|
||||
component: 'Input',
|
||||
componentProps: {
|
||||
allowClear: true,
|
||||
placeholder: '请输入转移单名称',
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldName: 'type',
|
||||
label: '转移单类型',
|
||||
component: 'Select',
|
||||
componentProps: {
|
||||
allowClear: true,
|
||||
options: getDictOptions(DICT_TYPE.MES_WM_TRANSFER_TYPE, 'number'),
|
||||
placeholder: '请选择转移单类型',
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldName: 'status',
|
||||
label: '单据状态',
|
||||
component: 'Select',
|
||||
componentProps: {
|
||||
allowClear: true,
|
||||
options: getDictOptions(DICT_TYPE.MES_WM_TRANSFER_STATUS, 'number'),
|
||||
placeholder: '请选择单据状态',
|
||||
},
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
/** 列表的字段 */
|
||||
export function useGridColumns(): VxeTableGridOptions<MesWmTransferApi.Transfer>['columns'] {
|
||||
return [
|
||||
{
|
||||
field: 'code',
|
||||
title: '转移单编号',
|
||||
minWidth: 160,
|
||||
slots: { default: 'code' },
|
||||
},
|
||||
{
|
||||
field: 'name',
|
||||
title: '转移单名称',
|
||||
minWidth: 160,
|
||||
},
|
||||
{
|
||||
field: 'type',
|
||||
title: '转移单类型',
|
||||
minWidth: 100,
|
||||
cellRender: {
|
||||
name: 'CellDict',
|
||||
props: { type: DICT_TYPE.MES_WM_TRANSFER_TYPE },
|
||||
},
|
||||
},
|
||||
{
|
||||
field: 'deliveryFlag',
|
||||
title: '是否配送',
|
||||
width: 100,
|
||||
cellRender: {
|
||||
name: 'CellDict',
|
||||
props: { type: DICT_TYPE.INFRA_BOOLEAN_STRING },
|
||||
},
|
||||
},
|
||||
{
|
||||
field: 'transferDate',
|
||||
title: '转移日期',
|
||||
width: 180,
|
||||
formatter: 'formatDate',
|
||||
},
|
||||
{
|
||||
field: 'status',
|
||||
title: '单据状态',
|
||||
minWidth: 110,
|
||||
cellRender: {
|
||||
name: 'CellDict',
|
||||
props: { type: DICT_TYPE.MES_WM_TRANSFER_STATUS },
|
||||
},
|
||||
},
|
||||
{
|
||||
title: '操作',
|
||||
width: 240,
|
||||
fixed: 'right',
|
||||
slots: { default: 'actions' },
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
/** 转移单行子表的字段 */
|
||||
export function useLineGridColumns(
|
||||
editable: boolean,
|
||||
stockable: boolean,
|
||||
): VxeTableGridOptions<MesWmTransferLineApi.TransferLine>['columns'] {
|
||||
return [
|
||||
{
|
||||
type: 'expand',
|
||||
width: 48,
|
||||
slots: { content: 'detail' },
|
||||
},
|
||||
{
|
||||
field: 'itemCode',
|
||||
title: '物料编码',
|
||||
minWidth: 120,
|
||||
},
|
||||
{
|
||||
field: 'itemName',
|
||||
title: '物料名称',
|
||||
minWidth: 140,
|
||||
},
|
||||
{
|
||||
field: 'specification',
|
||||
title: '规格型号',
|
||||
minWidth: 120,
|
||||
},
|
||||
{
|
||||
field: 'unitMeasureName',
|
||||
title: '单位',
|
||||
width: 80,
|
||||
},
|
||||
{
|
||||
field: 'quantity',
|
||||
title: '转移数量',
|
||||
width: 100,
|
||||
},
|
||||
{
|
||||
field: 'batchCode',
|
||||
title: '批次号',
|
||||
minWidth: 120,
|
||||
},
|
||||
{
|
||||
field: 'fromWarehouseName',
|
||||
title: '移出仓库',
|
||||
minWidth: 120,
|
||||
},
|
||||
{
|
||||
field: 'fromLocationName',
|
||||
title: '移出库区',
|
||||
minWidth: 120,
|
||||
},
|
||||
{
|
||||
field: 'fromAreaName',
|
||||
title: '移出库位',
|
||||
minWidth: 120,
|
||||
},
|
||||
...(editable || stockable
|
||||
? [
|
||||
{
|
||||
title: '操作',
|
||||
width: 180,
|
||||
fixed: 'right',
|
||||
slots: { default: 'actions' },
|
||||
} as const,
|
||||
]
|
||||
: []),
|
||||
];
|
||||
}
|
||||
|
||||
/** 转移单行新增/修改的表单 */
|
||||
export function useLineFormSchema(formApi?: VbenFormApi): VbenFormSchema[] {
|
||||
return [
|
||||
{
|
||||
fieldName: 'quantityMax',
|
||||
component: 'Input',
|
||||
dependencies: {
|
||||
triggerFields: [''],
|
||||
show: () => false,
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldName: 'batchId',
|
||||
component: 'Input',
|
||||
dependencies: {
|
||||
triggerFields: [''],
|
||||
show: () => false,
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldName: 'materialStockId',
|
||||
label: '选择库存',
|
||||
component: markRaw(WmMaterialStockSelect),
|
||||
componentProps: {
|
||||
// 选择库存后,自动回填物料/仓库位置/批次/数量
|
||||
onChange: async (stock?: MesWmMaterialStockApi.MaterialStock) => {
|
||||
await formApi?.setValues({
|
||||
batchCode: stock?.batchCode,
|
||||
batchId: stock?.batchId,
|
||||
fromAreaId: stock?.areaId,
|
||||
fromLocationId: stock?.locationId,
|
||||
fromWarehouseId: stock?.warehouseId,
|
||||
itemId: stock?.itemId,
|
||||
quantity: stock?.quantity,
|
||||
quantityMax: stock?.quantity,
|
||||
});
|
||||
},
|
||||
},
|
||||
rules: 'selectRequired',
|
||||
},
|
||||
{
|
||||
fieldName: 'itemId',
|
||||
label: '物料',
|
||||
component: markRaw(MdItemSelect),
|
||||
componentProps: {
|
||||
disabled: true,
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldName: 'quantity',
|
||||
label: '转移数量',
|
||||
component: 'InputNumber',
|
||||
componentProps: {
|
||||
class: '!w-full',
|
||||
min: 0,
|
||||
placeholder: '请输入转移数量',
|
||||
precision: 2,
|
||||
},
|
||||
rules: 'required',
|
||||
dependencies: {
|
||||
triggerFields: ['quantityMax'],
|
||||
componentProps: (values) => ({
|
||||
class: '!w-full',
|
||||
max: values.quantityMax,
|
||||
min: 0,
|
||||
placeholder: '请输入转移数量',
|
||||
precision: 2,
|
||||
}),
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldName: 'batchCode',
|
||||
label: '批次号',
|
||||
component: 'Input',
|
||||
componentProps: {
|
||||
disabled: true,
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldName: 'fromWarehouseId',
|
||||
label: '移出仓库',
|
||||
component: markRaw(WmWarehouseSelect),
|
||||
componentProps: {
|
||||
disabled: true,
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldName: 'fromLocationId',
|
||||
label: '移出库区',
|
||||
component: markRaw(WmWarehouseLocationSelect),
|
||||
componentProps: {
|
||||
disabled: true,
|
||||
},
|
||||
dependencies: {
|
||||
triggerFields: ['fromWarehouseId'],
|
||||
componentProps: (values) => ({
|
||||
disabled: true,
|
||||
warehouseId: values.fromWarehouseId,
|
||||
}),
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldName: 'fromAreaId',
|
||||
label: '移出库位',
|
||||
component: markRaw(WmWarehouseAreaSelect),
|
||||
componentProps: {
|
||||
disabled: true,
|
||||
},
|
||||
dependencies: {
|
||||
triggerFields: ['fromLocationId'],
|
||||
componentProps: (values) => ({
|
||||
disabled: true,
|
||||
locationId: values.fromLocationId,
|
||||
}),
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldName: 'remark',
|
||||
label: '备注',
|
||||
component: 'Textarea',
|
||||
formItemClass: 'col-span-3',
|
||||
componentProps: {
|
||||
placeholder: '请输入备注',
|
||||
rows: 3,
|
||||
},
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
/** 调拨明细子表的字段 */
|
||||
export function useDetailGridColumns(
|
||||
stockable: boolean,
|
||||
): VxeTableGridOptions<MesWmTransferDetailApi.TransferDetail>['columns'] {
|
||||
return [
|
||||
{
|
||||
field: 'toWarehouseName',
|
||||
title: '移入仓库',
|
||||
minWidth: 100,
|
||||
},
|
||||
{
|
||||
field: 'toLocationName',
|
||||
title: '移入库区',
|
||||
minWidth: 100,
|
||||
},
|
||||
{
|
||||
field: 'toAreaName',
|
||||
title: '移入库位',
|
||||
minWidth: 100,
|
||||
},
|
||||
{
|
||||
field: 'quantity',
|
||||
title: '数量',
|
||||
width: 100,
|
||||
},
|
||||
...(stockable
|
||||
? [
|
||||
{
|
||||
title: '操作',
|
||||
width: 120,
|
||||
fixed: 'right',
|
||||
slots: { default: 'actions' },
|
||||
} as const,
|
||||
]
|
||||
: []),
|
||||
];
|
||||
}
|
||||
|
||||
/** 调拨明细新增/修改的表单 */
|
||||
export function useDetailFormSchema(): VbenFormSchema[] {
|
||||
return [
|
||||
{
|
||||
fieldName: 'itemId',
|
||||
label: '物料',
|
||||
component: markRaw(MdItemSelect),
|
||||
componentProps: {
|
||||
disabled: true,
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldName: 'toWarehouseId',
|
||||
label: '移入仓库',
|
||||
component: markRaw(WmWarehouseSelect),
|
||||
componentProps: {
|
||||
placeholder: '请选择移入仓库',
|
||||
},
|
||||
rules: 'selectRequired',
|
||||
},
|
||||
{
|
||||
fieldName: 'toLocationId',
|
||||
label: '移入库区',
|
||||
component: markRaw(WmWarehouseLocationSelect),
|
||||
componentProps: {
|
||||
placeholder: '请选择移入库区',
|
||||
},
|
||||
rules: 'selectRequired',
|
||||
dependencies: {
|
||||
triggerFields: ['toWarehouseId'],
|
||||
componentProps: (values) => ({
|
||||
placeholder: '请选择移入库区',
|
||||
warehouseId: values.toWarehouseId,
|
||||
}),
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldName: 'toAreaId',
|
||||
label: '移入库位',
|
||||
component: markRaw(WmWarehouseAreaSelect),
|
||||
componentProps: {
|
||||
placeholder: '请选择移入库位',
|
||||
},
|
||||
rules: 'selectRequired',
|
||||
dependencies: {
|
||||
triggerFields: ['toLocationId'],
|
||||
componentProps: (values) => ({
|
||||
locationId: values.toLocationId,
|
||||
placeholder: '请选择移入库位',
|
||||
}),
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldName: 'quantity',
|
||||
label: '数量',
|
||||
component: 'InputNumber',
|
||||
componentProps: {
|
||||
class: '!w-full',
|
||||
min: 0,
|
||||
placeholder: '请输入数量',
|
||||
precision: 2,
|
||||
},
|
||||
rules: 'required',
|
||||
},
|
||||
{
|
||||
fieldName: 'remark',
|
||||
label: '备注',
|
||||
component: 'Textarea',
|
||||
componentProps: {
|
||||
placeholder: '请输入备注',
|
||||
rows: 3,
|
||||
},
|
||||
},
|
||||
];
|
||||
}
|
||||
|
|
@ -0,0 +1,223 @@
|
|||
<script lang="ts" setup>
|
||||
import type { VxeTableGridOptions } from '#/adapter/vxe-table';
|
||||
import type { MesWmTransferApi } from '#/api/mes/wm/transfer';
|
||||
|
||||
import { DocAlert, Page, useVbenModal } from '@vben/common-ui';
|
||||
import { downloadFileFromBlobPart } from '@vben/utils';
|
||||
|
||||
import { Button, message } from 'ant-design-vue';
|
||||
|
||||
import { ACTION_ICON, TableAction, useVbenVxeGrid } from '#/adapter/vxe-table';
|
||||
import {
|
||||
cancelTransfer,
|
||||
deleteTransfer,
|
||||
exportTransfer,
|
||||
getTransferPage,
|
||||
} from '#/api/mes/wm/transfer';
|
||||
import { $t } from '#/locales';
|
||||
import { MesWmTransferStatusEnum } from '#/views/mes/utils/constants';
|
||||
|
||||
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({ formType: 'create' }).open();
|
||||
}
|
||||
|
||||
/** 查看转移单详情 */
|
||||
function handleDetail(row: MesWmTransferApi.Transfer) {
|
||||
formModalApi.setData({ formType: 'detail', id: row.id }).open();
|
||||
}
|
||||
|
||||
/** 编辑转移单 */
|
||||
function handleEdit(row: MesWmTransferApi.Transfer) {
|
||||
formModalApi.setData({ formType: 'update', id: row.id }).open();
|
||||
}
|
||||
|
||||
/** 到货确认 */
|
||||
function handleConfirm(row: MesWmTransferApi.Transfer) {
|
||||
formModalApi.setData({ formType: 'confirm', id: row.id }).open();
|
||||
}
|
||||
|
||||
/** 执行上架 */
|
||||
function handleStock(row: MesWmTransferApi.Transfer) {
|
||||
formModalApi.setData({ formType: 'stock', id: row.id }).open();
|
||||
}
|
||||
|
||||
/** 执行转移 */
|
||||
function handleFinish(row: MesWmTransferApi.Transfer) {
|
||||
formModalApi.setData({ formType: 'finish', id: row.id }).open();
|
||||
}
|
||||
|
||||
/** 删除转移单 */
|
||||
async function handleDelete(row: MesWmTransferApi.Transfer) {
|
||||
const hideLoading = message.loading({
|
||||
content: $t('ui.actionMessage.deleting', [row.code]),
|
||||
duration: 0,
|
||||
});
|
||||
try {
|
||||
await deleteTransfer(row.id!);
|
||||
message.success($t('ui.actionMessage.deleteSuccess', [row.code]));
|
||||
handleRefresh();
|
||||
} finally {
|
||||
hideLoading();
|
||||
}
|
||||
}
|
||||
|
||||
/** 取消转移单 */
|
||||
async function handleCancel(row: MesWmTransferApi.Transfer) {
|
||||
await cancelTransfer(row.id!);
|
||||
message.success('取消成功');
|
||||
handleRefresh();
|
||||
}
|
||||
|
||||
/** 导出表格 */
|
||||
async function handleExport() {
|
||||
const data = await exportTransfer(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 getTransferPage({
|
||||
pageNo: page.currentPage,
|
||||
pageSize: page.pageSize,
|
||||
...formValues,
|
||||
});
|
||||
},
|
||||
},
|
||||
},
|
||||
rowConfig: {
|
||||
keyField: 'id',
|
||||
isHover: true,
|
||||
},
|
||||
toolbarConfig: {
|
||||
refresh: true,
|
||||
search: true,
|
||||
},
|
||||
} as VxeTableGridOptions<MesWmTransferApi.Transfer>,
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Page auto-content-height>
|
||||
<template #doc>
|
||||
<DocAlert
|
||||
title="【仓库】调拨单、装箱管理"
|
||||
url="https://doc.iocoder.cn/mes/wm/transfer/"
|
||||
/>
|
||||
</template>
|
||||
|
||||
<FormModal @success="handleRefresh" />
|
||||
|
||||
<Grid table-title="转移单列表">
|
||||
<template #toolbar-tools>
|
||||
<TableAction
|
||||
:actions="[
|
||||
{
|
||||
label: $t('ui.actionTitle.create', ['转移单']),
|
||||
type: 'primary',
|
||||
icon: ACTION_ICON.ADD,
|
||||
auth: ['mes:wm-transfer:create'],
|
||||
onClick: handleCreate,
|
||||
},
|
||||
{
|
||||
label: $t('ui.actionTitle.export'),
|
||||
type: 'primary',
|
||||
icon: ACTION_ICON.DOWNLOAD,
|
||||
auth: ['mes:wm-transfer:export'],
|
||||
onClick: handleExport,
|
||||
},
|
||||
]"
|
||||
/>
|
||||
</template>
|
||||
<template #code="{ row }">
|
||||
<Button type="link" @click="handleDetail(row)">
|
||||
{{ row.code }}
|
||||
</Button>
|
||||
</template>
|
||||
<template #actions="{ row }">
|
||||
<TableAction
|
||||
:actions="[
|
||||
{
|
||||
label: $t('common.edit'),
|
||||
type: 'link',
|
||||
icon: ACTION_ICON.EDIT,
|
||||
auth: ['mes:wm-transfer:update'],
|
||||
ifShow: row.status === MesWmTransferStatusEnum.PREPARE,
|
||||
onClick: handleEdit.bind(null, row),
|
||||
},
|
||||
{
|
||||
label: $t('common.delete'),
|
||||
type: 'link',
|
||||
danger: true,
|
||||
icon: ACTION_ICON.DELETE,
|
||||
auth: ['mes:wm-transfer:delete'],
|
||||
ifShow: row.status === MesWmTransferStatusEnum.PREPARE,
|
||||
popConfirm: {
|
||||
title: $t('ui.actionMessage.deleteConfirm', [row.code]),
|
||||
confirm: handleDelete.bind(null, row),
|
||||
},
|
||||
},
|
||||
{
|
||||
label: '到货确认',
|
||||
type: 'link',
|
||||
auth: ['mes:wm-transfer:update'],
|
||||
ifShow: row.status === MesWmTransferStatusEnum.UNCONFIRMED,
|
||||
onClick: handleConfirm.bind(null, row),
|
||||
},
|
||||
{
|
||||
label: '执行上架',
|
||||
type: 'link',
|
||||
auth: ['mes:wm-transfer:update'],
|
||||
ifShow: row.status === MesWmTransferStatusEnum.APPROVING,
|
||||
onClick: handleStock.bind(null, row),
|
||||
},
|
||||
{
|
||||
label: '执行转移',
|
||||
type: 'link',
|
||||
auth: ['mes:wm-transfer:finish'],
|
||||
ifShow: row.status === MesWmTransferStatusEnum.APPROVED,
|
||||
onClick: handleFinish.bind(null, row),
|
||||
},
|
||||
{
|
||||
label: '取消',
|
||||
type: 'link',
|
||||
danger: true,
|
||||
auth: ['mes:wm-transfer:update'],
|
||||
ifShow: [
|
||||
MesWmTransferStatusEnum.UNCONFIRMED,
|
||||
MesWmTransferStatusEnum.APPROVING,
|
||||
MesWmTransferStatusEnum.APPROVED,
|
||||
].includes(row.status),
|
||||
popConfirm: {
|
||||
title: '确认取消该转移单?取消后不可恢复。',
|
||||
confirm: handleCancel.bind(null, row),
|
||||
},
|
||||
},
|
||||
]"
|
||||
/>
|
||||
</template>
|
||||
</Grid>
|
||||
</Page>
|
||||
</template>
|
||||
|
|
@ -0,0 +1,103 @@
|
|||
<script lang="ts" setup>
|
||||
import type { MesWmTransferDetailApi } from '#/api/mes/wm/transfer/detail';
|
||||
|
||||
import { computed, ref } from 'vue';
|
||||
|
||||
import { useVbenModal } from '@vben/common-ui';
|
||||
|
||||
import { message } from 'ant-design-vue';
|
||||
|
||||
import { useVbenForm } from '#/adapter/form';
|
||||
import {
|
||||
createTransferDetail,
|
||||
getTransferDetail,
|
||||
updateTransferDetail,
|
||||
} from '#/api/mes/wm/transfer/detail';
|
||||
import { $t } from '#/locales';
|
||||
|
||||
import { useDetailFormSchema } from '../data';
|
||||
|
||||
const emit = defineEmits<{ success: [lineId: number] }>();
|
||||
const formData = ref<MesWmTransferDetailApi.TransferDetail>();
|
||||
const transferId = ref<number>(); // 所属转移单编号
|
||||
const lineId = ref<number>(); // 所属转移单行编号
|
||||
|
||||
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: 90,
|
||||
},
|
||||
layout: 'horizontal',
|
||||
schema: useDetailFormSchema(),
|
||||
showDefaultActions: false,
|
||||
wrapperClass: 'grid-cols-2',
|
||||
});
|
||||
|
||||
const [Modal, modalApi] = useVbenModal({
|
||||
async onConfirm() {
|
||||
const { valid } = await formApi.validate();
|
||||
if (!valid) {
|
||||
return;
|
||||
}
|
||||
modalApi.lock();
|
||||
// 提交表单
|
||||
const data =
|
||||
(await formApi.getValues()) as MesWmTransferDetailApi.TransferDetail;
|
||||
data.transferId = transferId.value;
|
||||
data.lineId = lineId.value;
|
||||
try {
|
||||
await (formData.value?.id
|
||||
? updateTransferDetail({ ...data, id: formData.value.id })
|
||||
: createTransferDetail(data));
|
||||
// 关闭并提示
|
||||
await modalApi.close();
|
||||
emit('success', lineId.value!);
|
||||
message.success($t('ui.actionMessage.operationSuccess'));
|
||||
} finally {
|
||||
modalApi.unlock();
|
||||
}
|
||||
},
|
||||
async onOpenChange(isOpen: boolean) {
|
||||
if (!isOpen) {
|
||||
formData.value = undefined;
|
||||
return;
|
||||
}
|
||||
// 加载数据
|
||||
const data = modalApi.getData<{
|
||||
detailId?: number;
|
||||
itemId?: number;
|
||||
lineId: number;
|
||||
transferId: number;
|
||||
}>();
|
||||
transferId.value = data.transferId;
|
||||
lineId.value = data.lineId;
|
||||
if (data.detailId) {
|
||||
modalApi.lock();
|
||||
try {
|
||||
formData.value = await getTransferDetail(data.detailId);
|
||||
// 设置到 values
|
||||
await formApi.setValues(formData.value);
|
||||
} finally {
|
||||
modalApi.unlock();
|
||||
}
|
||||
} else if (data.itemId) {
|
||||
await formApi.setFieldValue('itemId', data.itemId);
|
||||
}
|
||||
},
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Modal :title="getTitle" class="w-2/5">
|
||||
<Form class="mx-4" />
|
||||
</Modal>
|
||||
</template>
|
||||
|
|
@ -0,0 +1,101 @@
|
|||
<script lang="ts" setup>
|
||||
import type { VxeTableGridOptions } from '#/adapter/vxe-table';
|
||||
import type { MesWmTransferDetailApi } from '#/api/mes/wm/transfer/detail';
|
||||
|
||||
import { computed, watch } from 'vue';
|
||||
|
||||
import { message } from 'ant-design-vue';
|
||||
|
||||
import { ACTION_ICON, TableAction, useVbenVxeGrid } from '#/adapter/vxe-table';
|
||||
import { deleteTransferDetail } from '#/api/mes/wm/transfer/detail';
|
||||
import { $t } from '#/locales';
|
||||
|
||||
import { type FormType, useDetailGridColumns } from '../data';
|
||||
|
||||
const props = defineProps<{
|
||||
details: MesWmTransferDetailApi.TransferDetail[];
|
||||
formType: FormType;
|
||||
}>();
|
||||
|
||||
const emit = defineEmits<{
|
||||
edit: [detailId: number];
|
||||
refresh: [];
|
||||
}>();
|
||||
|
||||
const isStock = computed(() => props.formType === 'stock'); // 是否为上架模式
|
||||
|
||||
/** 编辑调拨明细 */
|
||||
function handleEdit(row: MesWmTransferDetailApi.TransferDetail) {
|
||||
emit('edit', row.id!);
|
||||
}
|
||||
|
||||
/** 删除调拨明细 */
|
||||
async function handleDelete(row: MesWmTransferDetailApi.TransferDetail) {
|
||||
const hideLoading = message.loading({
|
||||
content: $t('ui.actionMessage.deleting', [row.toWarehouseName]),
|
||||
duration: 0,
|
||||
});
|
||||
try {
|
||||
await deleteTransferDetail(row.id!);
|
||||
message.success($t('ui.actionMessage.deleteSuccess', [row.toWarehouseName]));
|
||||
emit('refresh');
|
||||
} finally {
|
||||
hideLoading();
|
||||
}
|
||||
}
|
||||
|
||||
const [Grid, gridApi] = useVbenVxeGrid({
|
||||
gridOptions: {
|
||||
border: true,
|
||||
columns: useDetailGridColumns(isStock.value),
|
||||
data: props.details,
|
||||
pagerConfig: {
|
||||
enabled: false,
|
||||
},
|
||||
rowConfig: {
|
||||
keyField: 'id',
|
||||
isHover: true,
|
||||
},
|
||||
size: 'small',
|
||||
toolbarConfig: {
|
||||
enabled: false,
|
||||
},
|
||||
} as VxeTableGridOptions<MesWmTransferDetailApi.TransferDetail>,
|
||||
});
|
||||
|
||||
watch(
|
||||
() => props.details,
|
||||
(details) => gridApi.setGridOptions({ data: details }),
|
||||
);
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="px-4 py-2">
|
||||
<Grid>
|
||||
<template #actions="{ row }">
|
||||
<TableAction
|
||||
:actions="[
|
||||
{
|
||||
label: $t('common.edit'),
|
||||
type: 'link',
|
||||
icon: ACTION_ICON.EDIT,
|
||||
onClick: handleEdit.bind(null, row),
|
||||
},
|
||||
{
|
||||
label: $t('common.delete'),
|
||||
type: 'link',
|
||||
danger: true,
|
||||
icon: ACTION_ICON.DELETE,
|
||||
popConfirm: {
|
||||
title: $t('ui.actionMessage.deleteConfirm', [
|
||||
row.toWarehouseName,
|
||||
]),
|
||||
confirm: handleDelete.bind(null, row),
|
||||
},
|
||||
},
|
||||
]"
|
||||
/>
|
||||
</template>
|
||||
</Grid>
|
||||
</div>
|
||||
</template>
|
||||
|
|
@ -0,0 +1,255 @@
|
|||
<script lang="ts" setup>
|
||||
import type { FormType } from '../data';
|
||||
|
||||
import type { MesWmTransferApi } from '#/api/mes/wm/transfer';
|
||||
|
||||
import { computed, ref } from 'vue';
|
||||
|
||||
import { useVbenModal } from '@vben/common-ui';
|
||||
|
||||
import { Button, Divider, message, Popconfirm } from 'ant-design-vue';
|
||||
|
||||
import { useVbenForm } from '#/adapter/form';
|
||||
import {
|
||||
confirmTransfer,
|
||||
createTransfer,
|
||||
finishTransfer,
|
||||
getTransfer,
|
||||
stockTransfer,
|
||||
submitTransfer,
|
||||
updateTransfer,
|
||||
} from '#/api/mes/wm/transfer';
|
||||
import { $t } from '#/locales';
|
||||
import { MesWmTransferStatusEnum } from '#/views/mes/utils/constants';
|
||||
|
||||
import { useFormSchema } from '../data';
|
||||
import LineList from './line-list.vue';
|
||||
|
||||
const emit = defineEmits(['success']);
|
||||
const formType = ref<FormType>('create');
|
||||
const formData = ref<MesWmTransferApi.Transfer>();
|
||||
const originalSnapshot = ref(''); // 表单原始数据快照,用于提交时跳过未变更的保存请求
|
||||
const isEditable = computed(() => // 是否为编辑模式(可保存)
|
||||
['create', 'update'].includes(formType.value),
|
||||
);
|
||||
const isConfirm = computed(() => formType.value === 'confirm'); // 是否为到货确认模式
|
||||
const isStock = computed(() => formType.value === 'stock'); // 是否为上架模式
|
||||
const isFinish = computed(() => formType.value === 'finish'); // 是否为执行转移模式
|
||||
const canSubmit = computed(() => // 编辑态草稿可提交
|
||||
formType.value === 'update' &&
|
||||
formData.value?.status === MesWmTransferStatusEnum.PREPARE,
|
||||
);
|
||||
const getTitle = computed(() => {
|
||||
switch (formType.value) {
|
||||
case 'confirm': {
|
||||
return '到货确认';
|
||||
}
|
||||
case 'detail': {
|
||||
return $t('ui.actionTitle.view', ['转移单']);
|
||||
}
|
||||
case 'finish': {
|
||||
return '执行转移';
|
||||
}
|
||||
case 'stock': {
|
||||
return '执行上架';
|
||||
}
|
||||
case 'update': {
|
||||
return $t('ui.actionTitle.edit', ['转移单']);
|
||||
}
|
||||
default: {
|
||||
return $t('ui.actionTitle.create', ['转移单']);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
const [Form, formApi] = useVbenForm({
|
||||
commonConfig: {
|
||||
componentProps: {
|
||||
class: 'w-full',
|
||||
},
|
||||
formItemClass: 'col-span-1',
|
||||
labelWidth: 110,
|
||||
},
|
||||
layout: 'horizontal',
|
||||
schema: [],
|
||||
showDefaultActions: false,
|
||||
wrapperClass: 'grid-cols-3',
|
||||
});
|
||||
|
||||
/** 提交转移单:表单有修改时先保存,再调用提交接口 */
|
||||
async function handleSubmit() {
|
||||
const { valid } = await formApi.validate();
|
||||
if (!valid || !formData.value?.id) {
|
||||
return;
|
||||
}
|
||||
modalApi.lock();
|
||||
try {
|
||||
const current = JSON.stringify(await formApi.getValues());
|
||||
if (current !== originalSnapshot.value) {
|
||||
const data = (await formApi.getValues()) as MesWmTransferApi.Transfer;
|
||||
await updateTransfer({ ...formData.value, ...data });
|
||||
originalSnapshot.value = current;
|
||||
}
|
||||
await submitTransfer(formData.value.id);
|
||||
message.success('提交成功');
|
||||
await modalApi.close();
|
||||
emit('success');
|
||||
} finally {
|
||||
modalApi.unlock();
|
||||
}
|
||||
}
|
||||
|
||||
/** 到货确认 */
|
||||
async function handleConfirm() {
|
||||
if (!formData.value?.id) {
|
||||
return;
|
||||
}
|
||||
modalApi.lock();
|
||||
try {
|
||||
await confirmTransfer(formData.value.id);
|
||||
message.success('确认成功');
|
||||
await modalApi.close();
|
||||
emit('success');
|
||||
} finally {
|
||||
modalApi.unlock();
|
||||
}
|
||||
}
|
||||
|
||||
/** 执行上架 */
|
||||
async function handleStock() {
|
||||
if (!formData.value?.id) {
|
||||
return;
|
||||
}
|
||||
modalApi.lock();
|
||||
try {
|
||||
await stockTransfer(formData.value.id);
|
||||
message.success('上架成功');
|
||||
await modalApi.close();
|
||||
emit('success');
|
||||
} finally {
|
||||
modalApi.unlock();
|
||||
}
|
||||
}
|
||||
|
||||
/** 执行转移 */
|
||||
async function handleFinish() {
|
||||
if (!formData.value?.id) {
|
||||
return;
|
||||
}
|
||||
modalApi.lock();
|
||||
try {
|
||||
await finishTransfer(formData.value.id);
|
||||
message.success('执行成功');
|
||||
await modalApi.close();
|
||||
emit('success');
|
||||
} finally {
|
||||
modalApi.unlock();
|
||||
}
|
||||
}
|
||||
|
||||
const [Modal, modalApi] = useVbenModal({
|
||||
async onConfirm() {
|
||||
if (!isEditable.value) {
|
||||
await modalApi.close();
|
||||
return;
|
||||
}
|
||||
const { valid } = await formApi.validate();
|
||||
if (!valid) {
|
||||
return;
|
||||
}
|
||||
modalApi.lock();
|
||||
// 提交表单
|
||||
const data = (await formApi.getValues()) as MesWmTransferApi.Transfer;
|
||||
try {
|
||||
if (formData.value?.id) {
|
||||
await updateTransfer({ ...formData.value, ...data });
|
||||
formData.value = { ...formData.value, ...data };
|
||||
} else {
|
||||
const id = await createTransfer(data);
|
||||
formData.value = {
|
||||
...data,
|
||||
id,
|
||||
status: MesWmTransferStatusEnum.PREPARE,
|
||||
};
|
||||
formType.value = 'update';
|
||||
// 创建成功后切换编辑态,重挂 schema 并回填主键 / 状态
|
||||
formApi.setState({ schema: useFormSchema(formType.value, formApi) });
|
||||
await formApi.setValues(formData.value);
|
||||
}
|
||||
originalSnapshot.value = JSON.stringify(await formApi.getValues());
|
||||
emit('success');
|
||||
message.success($t('ui.actionMessage.operationSuccess'));
|
||||
} finally {
|
||||
modalApi.unlock();
|
||||
}
|
||||
},
|
||||
async onOpenChange(isOpen: boolean) {
|
||||
if (!isOpen) {
|
||||
formData.value = undefined;
|
||||
originalSnapshot.value = '';
|
||||
return;
|
||||
}
|
||||
// 加载数据
|
||||
const data = modalApi.getData<{ formType: FormType; id?: number }>();
|
||||
formType.value = data.formType;
|
||||
formApi.setState({ schema: useFormSchema(formType.value, formApi) });
|
||||
modalApi.setState({ showConfirmButton: isEditable.value });
|
||||
if (data?.id) {
|
||||
modalApi.lock();
|
||||
try {
|
||||
formData.value = await getTransfer(data.id);
|
||||
// 设置到 values
|
||||
await formApi.setValues(formData.value);
|
||||
} finally {
|
||||
modalApi.unlock();
|
||||
}
|
||||
}
|
||||
originalSnapshot.value = JSON.stringify(await formApi.getValues());
|
||||
},
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Modal :title="getTitle" class="w-3/5">
|
||||
<Form class="mx-4" />
|
||||
<!-- 非新建模式展示物料信息 -->
|
||||
<template v-if="formData?.id">
|
||||
<Divider>物料信息</Divider>
|
||||
<div class="mx-4">
|
||||
<LineList :form-type="formType" :transfer-id="formData.id" />
|
||||
</div>
|
||||
</template>
|
||||
<template #prepend-footer>
|
||||
<div class="flex flex-auto items-center gap-2">
|
||||
<Popconfirm
|
||||
v-if="canSubmit"
|
||||
title="确认提交该转移单?【提交后将不能修改】"
|
||||
@confirm="handleSubmit"
|
||||
>
|
||||
<Button type="primary">提交</Button>
|
||||
</Popconfirm>
|
||||
<Popconfirm
|
||||
v-if="isConfirm"
|
||||
title="确认到货后,将进入待上架状态,是否继续?"
|
||||
@confirm="handleConfirm"
|
||||
>
|
||||
<Button type="primary">到货确认</Button>
|
||||
</Popconfirm>
|
||||
<Popconfirm
|
||||
v-if="isStock"
|
||||
title="确认执行上架?"
|
||||
@confirm="handleStock"
|
||||
>
|
||||
<Button type="primary">执行上架</Button>
|
||||
</Popconfirm>
|
||||
<Popconfirm
|
||||
v-if="isFinish"
|
||||
title="确认执行调拨?执行后将更新库存。"
|
||||
@confirm="handleFinish"
|
||||
>
|
||||
<Button type="primary">执行转移</Button>
|
||||
</Popconfirm>
|
||||
</div>
|
||||
</template>
|
||||
</Modal>
|
||||
</template>
|
||||
|
|
@ -0,0 +1,102 @@
|
|||
<script lang="ts" setup>
|
||||
import type { MesWmTransferLineApi } from '#/api/mes/wm/transfer/line';
|
||||
|
||||
import { computed, ref } from 'vue';
|
||||
|
||||
import { useVbenModal } from '@vben/common-ui';
|
||||
|
||||
import { message } from 'ant-design-vue';
|
||||
|
||||
import { useVbenForm } from '#/adapter/form';
|
||||
import { getMaterialStock } from '#/api/mes/wm/materialstock';
|
||||
import {
|
||||
createTransferLine,
|
||||
getTransferLine,
|
||||
updateTransferLine,
|
||||
} from '#/api/mes/wm/transfer/line';
|
||||
import { $t } from '#/locales';
|
||||
|
||||
import { useLineFormSchema } from '../data';
|
||||
|
||||
const emit = defineEmits(['success']);
|
||||
const formData = ref<MesWmTransferLineApi.TransferLine>();
|
||||
const transferId = ref<number>(); // 所属转移单编号
|
||||
|
||||
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-1',
|
||||
labelWidth: 90,
|
||||
},
|
||||
layout: 'horizontal',
|
||||
schema: [],
|
||||
showDefaultActions: false,
|
||||
wrapperClass: 'grid-cols-3',
|
||||
});
|
||||
|
||||
const [Modal, modalApi] = useVbenModal({
|
||||
async onConfirm() {
|
||||
const { valid } = await formApi.validate();
|
||||
if (!valid) {
|
||||
return;
|
||||
}
|
||||
modalApi.lock();
|
||||
// 提交表单
|
||||
const data =
|
||||
(await formApi.getValues()) as MesWmTransferLineApi.TransferLine;
|
||||
data.transferId = transferId.value;
|
||||
try {
|
||||
await (formData.value?.id
|
||||
? updateTransferLine({ ...data, id: formData.value.id })
|
||||
: createTransferLine(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;
|
||||
}
|
||||
formApi.setState({ schema: useLineFormSchema(formApi) });
|
||||
// 加载数据
|
||||
const data = modalApi.getData<{ id?: number; transferId: number }>();
|
||||
transferId.value = data.transferId;
|
||||
if (!data.id) {
|
||||
return;
|
||||
}
|
||||
modalApi.lock();
|
||||
try {
|
||||
formData.value = await getTransferLine(data.id);
|
||||
// 编辑时按当前库存在库量作为数量上限
|
||||
let quantityMax: number | undefined;
|
||||
if (formData.value.materialStockId) {
|
||||
const stock = await getMaterialStock(formData.value.materialStockId);
|
||||
quantityMax = stock?.quantity;
|
||||
}
|
||||
// 设置到 values
|
||||
await formApi.setValues({ ...formData.value, quantityMax });
|
||||
} finally {
|
||||
modalApi.unlock();
|
||||
}
|
||||
},
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Modal :title="getTitle" class="w-3/5">
|
||||
<Form class="mx-4" />
|
||||
</Modal>
|
||||
</template>
|
||||
|
|
@ -0,0 +1,226 @@
|
|||
<script lang="ts" setup>
|
||||
import type { VxeTableGridOptions } from '#/adapter/vxe-table';
|
||||
import type { MesWmTransferDetailApi } from '#/api/mes/wm/transfer/detail';
|
||||
import type { MesWmTransferLineApi } from '#/api/mes/wm/transfer/line';
|
||||
|
||||
import { computed, reactive } from 'vue';
|
||||
|
||||
import { useVbenModal } from '@vben/common-ui';
|
||||
|
||||
import { message } from 'ant-design-vue';
|
||||
|
||||
import { ACTION_ICON, TableAction, useVbenVxeGrid } from '#/adapter/vxe-table';
|
||||
import { getTransferDetailListByLineId } from '#/api/mes/wm/transfer/detail';
|
||||
import {
|
||||
deleteTransferLine,
|
||||
getTransferLineList,
|
||||
} from '#/api/mes/wm/transfer/line';
|
||||
import { $t } from '#/locales';
|
||||
import { PrinterLabel } from '#/views/mes/wm/barcode/components';
|
||||
|
||||
import { type FormType, useLineGridColumns } from '../data';
|
||||
import DetailForm from './detail-form.vue';
|
||||
import DetailList from './detail-list.vue';
|
||||
import LineForm from './line-form.vue';
|
||||
|
||||
const props = defineProps<{
|
||||
formType: FormType;
|
||||
transferId: number;
|
||||
}>();
|
||||
|
||||
const isEditable = computed(() =>
|
||||
['create', 'update'].includes(props.formType),
|
||||
); // 是否可编辑调拨物料行
|
||||
const isStock = computed(() => props.formType === 'stock'); // 是否为上架模式
|
||||
const detailMap = reactive<
|
||||
Record<number, MesWmTransferDetailApi.TransferDetail[]>
|
||||
>({}); // 已展开行的调拨明细缓存
|
||||
|
||||
const [LineFormModal, lineFormModalApi] = useVbenModal({
|
||||
connectedComponent: LineForm,
|
||||
destroyOnClose: true,
|
||||
});
|
||||
|
||||
const [DetailFormModal, detailFormModalApi] = useVbenModal({
|
||||
connectedComponent: DetailForm,
|
||||
destroyOnClose: true,
|
||||
});
|
||||
|
||||
/** 刷新表格 */
|
||||
function handleRefresh() {
|
||||
for (const id of Object.keys(detailMap)) {
|
||||
delete detailMap[Number(id)];
|
||||
}
|
||||
gridApi.query();
|
||||
}
|
||||
|
||||
/** 添加调拨物料 */
|
||||
function handleCreate() {
|
||||
lineFormModalApi.setData({ transferId: props.transferId }).open();
|
||||
}
|
||||
|
||||
/** 编辑调拨物料 */
|
||||
function handleEdit(row: MesWmTransferLineApi.TransferLine) {
|
||||
lineFormModalApi.setData({ id: row.id, transferId: props.transferId }).open();
|
||||
}
|
||||
|
||||
/** 删除调拨物料 */
|
||||
async function handleDelete(row: MesWmTransferLineApi.TransferLine) {
|
||||
const hideLoading = message.loading({
|
||||
content: $t('ui.actionMessage.deleting', [row.itemName]),
|
||||
duration: 0,
|
||||
});
|
||||
try {
|
||||
await deleteTransferLine(row.id!);
|
||||
message.success($t('ui.actionMessage.deleteSuccess', [row.itemName]));
|
||||
handleRefresh();
|
||||
} finally {
|
||||
hideLoading();
|
||||
}
|
||||
}
|
||||
|
||||
/** 上架:直接打开明细新增表单 */
|
||||
function handleStock(row: MesWmTransferLineApi.TransferLine) {
|
||||
openDetailForm(row.id!, row.itemId);
|
||||
}
|
||||
|
||||
/** 打开调拨明细表单 */
|
||||
function openDetailForm(lineId: number, itemId?: number, detailId?: number) {
|
||||
detailFormModalApi
|
||||
.setData({ detailId, itemId, lineId, transferId: props.transferId })
|
||||
.open();
|
||||
}
|
||||
|
||||
/** 获取已展开行的调拨明细 */
|
||||
function getExpandedDetails(row: MesWmTransferLineApi.TransferLine) {
|
||||
return detailMap[row.id!] || [];
|
||||
}
|
||||
|
||||
/** 加载指定行的调拨明细 */
|
||||
async function loadLineDetails(lineId: number) {
|
||||
detailMap[lineId] = await getTransferDetailListByLineId(lineId);
|
||||
}
|
||||
|
||||
/** 展开行时懒加载调拨明细 */
|
||||
async function handleExpandChange(
|
||||
row: MesWmTransferLineApi.TransferLine,
|
||||
expanded: boolean,
|
||||
) {
|
||||
if (!expanded) {
|
||||
return;
|
||||
}
|
||||
await loadLineDetails(row.id!);
|
||||
}
|
||||
|
||||
/** 明细表单提交成功后,刷新对应行已展开的明细 */
|
||||
async function handleDetailSuccess(lineId: number) {
|
||||
await loadLineDetails(lineId);
|
||||
}
|
||||
|
||||
const [Grid, gridApi] = useVbenVxeGrid({
|
||||
gridOptions: {
|
||||
columns: useLineGridColumns(isEditable.value, isStock.value),
|
||||
expandConfig: {
|
||||
padding: true,
|
||||
},
|
||||
height: 400,
|
||||
keepSource: true,
|
||||
proxyConfig: {
|
||||
ajax: {
|
||||
query: async () => {
|
||||
if (!props.transferId) {
|
||||
return [];
|
||||
}
|
||||
return await getTransferLineList(props.transferId);
|
||||
},
|
||||
},
|
||||
},
|
||||
pagerConfig: {
|
||||
enabled: false,
|
||||
},
|
||||
rowConfig: {
|
||||
keyField: 'id',
|
||||
isHover: true,
|
||||
},
|
||||
toolbarConfig: {
|
||||
refresh: true,
|
||||
},
|
||||
} as VxeTableGridOptions<MesWmTransferLineApi.TransferLine>,
|
||||
gridEvents: {
|
||||
toggleRowExpand: ({
|
||||
expanded,
|
||||
row,
|
||||
}: {
|
||||
expanded: boolean;
|
||||
row: MesWmTransferLineApi.TransferLine;
|
||||
}) => {
|
||||
handleExpandChange(row, expanded);
|
||||
},
|
||||
},
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div>
|
||||
<LineFormModal @success="handleRefresh" />
|
||||
<DetailFormModal @success="handleDetailSuccess" />
|
||||
<Grid table-title="物料信息">
|
||||
<template v-if="isEditable" #toolbar-tools>
|
||||
<TableAction
|
||||
:actions="[
|
||||
{
|
||||
label: '添加调拨物料',
|
||||
type: 'primary',
|
||||
icon: ACTION_ICON.ADD,
|
||||
onClick: handleCreate,
|
||||
},
|
||||
]"
|
||||
/>
|
||||
</template>
|
||||
<template #detail="{ row }">
|
||||
<DetailList
|
||||
:details="getExpandedDetails(row)"
|
||||
:form-type="formType"
|
||||
@edit="(detailId) => openDetailForm(row.id!, row.itemId, detailId)"
|
||||
@refresh="loadLineDetails(row.id!)"
|
||||
/>
|
||||
</template>
|
||||
<template #actions="{ row }">
|
||||
<TableAction
|
||||
:actions="[
|
||||
{
|
||||
label: $t('common.edit'),
|
||||
type: 'link',
|
||||
icon: ACTION_ICON.EDIT,
|
||||
ifShow: isEditable,
|
||||
onClick: handleEdit.bind(null, row),
|
||||
},
|
||||
{
|
||||
label: $t('common.delete'),
|
||||
type: 'link',
|
||||
danger: true,
|
||||
icon: ACTION_ICON.DELETE,
|
||||
ifShow: isEditable,
|
||||
popConfirm: {
|
||||
title: $t('ui.actionMessage.deleteConfirm', [row.itemName]),
|
||||
confirm: handleDelete.bind(null, row),
|
||||
},
|
||||
},
|
||||
{
|
||||
label: '上架',
|
||||
type: 'link',
|
||||
ifShow: isStock,
|
||||
onClick: handleStock.bind(null, row),
|
||||
},
|
||||
]"
|
||||
/>
|
||||
<PrinterLabel
|
||||
v-if="isStock"
|
||||
:biz-code="row.batchCode"
|
||||
:biz-id="row.batchId"
|
||||
biz-type="BATCH"
|
||||
/>
|
||||
</template>
|
||||
</Grid>
|
||||
</div>
|
||||
</template>
|
||||
|
|
@ -0,0 +1,647 @@
|
|||
import type { VbenFormApi, VbenFormSchema } from '#/adapter/form';
|
||||
import type { VxeTableGridOptions } from '#/adapter/vxe-table';
|
||||
import type { MesWmMaterialStockApi } from '#/api/mes/wm/materialstock';
|
||||
import type { MesWmTransferApi } from '#/api/mes/wm/transfer';
|
||||
import type { MesWmTransferDetailApi } from '#/api/mes/wm/transfer/detail';
|
||||
import type { MesWmTransferLineApi } from '#/api/mes/wm/transfer/line';
|
||||
|
||||
import { h, markRaw } from 'vue';
|
||||
|
||||
import { DICT_TYPE } from '@vben/constants';
|
||||
import { getDictOptions } from '@vben/hooks';
|
||||
|
||||
import { ElButton } from 'element-plus';
|
||||
|
||||
import { generateAutoCode } from '#/api/mes/md/autocode/record';
|
||||
import { MdItemSelect } from '#/views/mes/md/item/components';
|
||||
import {
|
||||
MesAutoCodeRuleCode,
|
||||
MesWmTransferTypeEnum,
|
||||
} from '#/views/mes/utils/constants';
|
||||
import { WmMaterialStockSelect } from '#/views/mes/wm/materialstock/components';
|
||||
import {
|
||||
WmWarehouseAreaSelect,
|
||||
WmWarehouseLocationSelect,
|
||||
WmWarehouseSelect,
|
||||
} from '#/views/mes/wm/warehouse/components';
|
||||
|
||||
/** 表单类型 */
|
||||
export type FormType =
|
||||
| 'confirm'
|
||||
| 'create'
|
||||
| 'detail'
|
||||
| 'finish'
|
||||
| 'stock'
|
||||
| 'update';
|
||||
|
||||
/** 表头是否只读(上架、确认、执行、详情态) */
|
||||
function isHeaderReadonly(formType: FormType): boolean {
|
||||
return ['confirm', 'detail', 'finish', 'stock'].includes(formType);
|
||||
}
|
||||
|
||||
/** 新增/修改的表单 */
|
||||
export function useFormSchema(
|
||||
formType: FormType,
|
||||
formApi?: VbenFormApi,
|
||||
): VbenFormSchema[] {
|
||||
const headerReadonly = isHeaderReadonly(formType);
|
||||
return [
|
||||
{
|
||||
fieldName: 'id',
|
||||
component: 'Input',
|
||||
dependencies: {
|
||||
triggerFields: [''],
|
||||
show: () => false,
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldName: 'status',
|
||||
component: 'Input',
|
||||
dependencies: {
|
||||
triggerFields: [''],
|
||||
show: () => false,
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldName: 'code',
|
||||
label: '转移单编号',
|
||||
component: 'Input',
|
||||
componentProps: {
|
||||
disabled: headerReadonly,
|
||||
placeholder: '请输入转移单编号',
|
||||
},
|
||||
rules: 'required',
|
||||
suffix:
|
||||
formType === 'create' || formType === 'update'
|
||||
? () =>
|
||||
h(
|
||||
ElButton,
|
||||
{
|
||||
onClick: async () => {
|
||||
const code = await generateAutoCode(
|
||||
MesAutoCodeRuleCode.TRANSFER_CODE,
|
||||
);
|
||||
await formApi?.setFieldValue('code', code);
|
||||
},
|
||||
},
|
||||
{ default: () => '生成' },
|
||||
)
|
||||
: undefined,
|
||||
},
|
||||
{
|
||||
fieldName: 'name',
|
||||
label: '转移单名称',
|
||||
component: 'Input',
|
||||
componentProps: {
|
||||
disabled: headerReadonly,
|
||||
placeholder: '请输入转移单名称',
|
||||
},
|
||||
rules: 'required',
|
||||
},
|
||||
{
|
||||
fieldName: 'type',
|
||||
label: '转移单类型',
|
||||
component: 'Select',
|
||||
componentProps: {
|
||||
disabled: headerReadonly,
|
||||
options: getDictOptions(DICT_TYPE.MES_WM_TRANSFER_TYPE, 'number'),
|
||||
placeholder: '请选择转移单类型',
|
||||
},
|
||||
rules: 'selectRequired',
|
||||
},
|
||||
{
|
||||
fieldName: 'transferDate',
|
||||
label: '转移日期',
|
||||
component: 'DatePicker',
|
||||
componentProps: {
|
||||
class: '!w-full',
|
||||
disabled: headerReadonly,
|
||||
placeholder: '请选择转移日期',
|
||||
type: 'date',
|
||||
valueFormat: 'YYYY-MM-DD 00:00:00',
|
||||
},
|
||||
rules: 'required',
|
||||
},
|
||||
{
|
||||
fieldName: 'deliveryFlag',
|
||||
label: '是否配送',
|
||||
component: 'Switch',
|
||||
componentProps: {
|
||||
disabled: headerReadonly,
|
||||
},
|
||||
dependencies: {
|
||||
triggerFields: ['type'],
|
||||
show: (values) => values.type === MesWmTransferTypeEnum.OUTER,
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldName: 'confirmFlag',
|
||||
label: '是否确认',
|
||||
component: 'Switch',
|
||||
componentProps: {
|
||||
disabled: true,
|
||||
},
|
||||
dependencies: {
|
||||
triggerFields: ['type'],
|
||||
show: (values) => values.type === MesWmTransferTypeEnum.OUTER,
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldName: 'recipientName',
|
||||
label: '收货人',
|
||||
component: 'Input',
|
||||
componentProps: {
|
||||
disabled: headerReadonly,
|
||||
placeholder: '请输入收货人',
|
||||
},
|
||||
dependencies: {
|
||||
triggerFields: ['type', 'deliveryFlag'],
|
||||
show: (values) =>
|
||||
values.type === MesWmTransferTypeEnum.OUTER && !!values.deliveryFlag,
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldName: 'recipientTelephone',
|
||||
label: '联系电话',
|
||||
component: 'Input',
|
||||
componentProps: {
|
||||
disabled: headerReadonly,
|
||||
placeholder: '请输入联系电话',
|
||||
},
|
||||
dependencies: {
|
||||
triggerFields: ['type', 'deliveryFlag'],
|
||||
show: (values) =>
|
||||
values.type === MesWmTransferTypeEnum.OUTER && !!values.deliveryFlag,
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldName: 'carrier',
|
||||
label: '承运商',
|
||||
component: 'Input',
|
||||
componentProps: {
|
||||
disabled: headerReadonly,
|
||||
placeholder: '请输入承运商',
|
||||
},
|
||||
dependencies: {
|
||||
triggerFields: ['type', 'deliveryFlag'],
|
||||
show: (values) =>
|
||||
values.type === MesWmTransferTypeEnum.OUTER && !!values.deliveryFlag,
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldName: 'shippingNumber',
|
||||
label: '运输单号',
|
||||
component: 'Input',
|
||||
componentProps: {
|
||||
disabled: headerReadonly,
|
||||
placeholder: '请输入运输单号',
|
||||
},
|
||||
dependencies: {
|
||||
triggerFields: ['type', 'deliveryFlag'],
|
||||
show: (values) =>
|
||||
values.type === MesWmTransferTypeEnum.OUTER && !!values.deliveryFlag,
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldName: 'destinationAddress',
|
||||
label: '目的地',
|
||||
component: 'Input',
|
||||
formItemClass: 'col-span-2',
|
||||
componentProps: {
|
||||
disabled: headerReadonly,
|
||||
placeholder: '请输入目的地',
|
||||
},
|
||||
dependencies: {
|
||||
triggerFields: ['type', 'deliveryFlag'],
|
||||
show: (values) =>
|
||||
values.type === MesWmTransferTypeEnum.OUTER && !!values.deliveryFlag,
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldName: 'remark',
|
||||
label: '备注',
|
||||
component: 'Textarea',
|
||||
formItemClass: 'col-span-3',
|
||||
componentProps: {
|
||||
disabled: headerReadonly,
|
||||
placeholder: '请输入备注',
|
||||
rows: 3,
|
||||
},
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
/** 列表的搜索表单 */
|
||||
export function useGridFormSchema(): VbenFormSchema[] {
|
||||
return [
|
||||
{
|
||||
fieldName: 'code',
|
||||
label: '转移单编号',
|
||||
component: 'Input',
|
||||
componentProps: {
|
||||
clearable: true,
|
||||
placeholder: '请输入转移单编号',
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldName: 'name',
|
||||
label: '转移单名称',
|
||||
component: 'Input',
|
||||
componentProps: {
|
||||
clearable: true,
|
||||
placeholder: '请输入转移单名称',
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldName: 'type',
|
||||
label: '转移单类型',
|
||||
component: 'Select',
|
||||
componentProps: {
|
||||
clearable: true,
|
||||
options: getDictOptions(DICT_TYPE.MES_WM_TRANSFER_TYPE, 'number'),
|
||||
placeholder: '请选择转移单类型',
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldName: 'status',
|
||||
label: '单据状态',
|
||||
component: 'Select',
|
||||
componentProps: {
|
||||
clearable: true,
|
||||
options: getDictOptions(DICT_TYPE.MES_WM_TRANSFER_STATUS, 'number'),
|
||||
placeholder: '请选择单据状态',
|
||||
},
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
/** 列表的字段 */
|
||||
export function useGridColumns(): VxeTableGridOptions<MesWmTransferApi.Transfer>['columns'] {
|
||||
return [
|
||||
{
|
||||
field: 'code',
|
||||
title: '转移单编号',
|
||||
minWidth: 160,
|
||||
slots: { default: 'code' },
|
||||
},
|
||||
{
|
||||
field: 'name',
|
||||
title: '转移单名称',
|
||||
minWidth: 160,
|
||||
},
|
||||
{
|
||||
field: 'type',
|
||||
title: '转移单类型',
|
||||
minWidth: 100,
|
||||
cellRender: {
|
||||
name: 'CellDict',
|
||||
props: { type: DICT_TYPE.MES_WM_TRANSFER_TYPE },
|
||||
},
|
||||
},
|
||||
{
|
||||
field: 'deliveryFlag',
|
||||
title: '是否配送',
|
||||
width: 100,
|
||||
cellRender: {
|
||||
name: 'CellDict',
|
||||
props: { type: DICT_TYPE.INFRA_BOOLEAN_STRING },
|
||||
},
|
||||
},
|
||||
{
|
||||
field: 'transferDate',
|
||||
title: '转移日期',
|
||||
width: 180,
|
||||
formatter: 'formatDate',
|
||||
},
|
||||
{
|
||||
field: 'status',
|
||||
title: '单据状态',
|
||||
minWidth: 110,
|
||||
cellRender: {
|
||||
name: 'CellDict',
|
||||
props: { type: DICT_TYPE.MES_WM_TRANSFER_STATUS },
|
||||
},
|
||||
},
|
||||
{
|
||||
title: '操作',
|
||||
width: 240,
|
||||
fixed: 'right',
|
||||
slots: { default: 'actions' },
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
/** 转移单行子表的字段 */
|
||||
export function useLineGridColumns(
|
||||
editable: boolean,
|
||||
stockable: boolean,
|
||||
): VxeTableGridOptions<MesWmTransferLineApi.TransferLine>['columns'] {
|
||||
return [
|
||||
{
|
||||
type: 'expand',
|
||||
width: 48,
|
||||
slots: { content: 'detail' },
|
||||
},
|
||||
{
|
||||
field: 'itemCode',
|
||||
title: '物料编码',
|
||||
minWidth: 120,
|
||||
},
|
||||
{
|
||||
field: 'itemName',
|
||||
title: '物料名称',
|
||||
minWidth: 140,
|
||||
},
|
||||
{
|
||||
field: 'specification',
|
||||
title: '规格型号',
|
||||
minWidth: 120,
|
||||
},
|
||||
{
|
||||
field: 'unitMeasureName',
|
||||
title: '单位',
|
||||
width: 80,
|
||||
},
|
||||
{
|
||||
field: 'quantity',
|
||||
title: '转移数量',
|
||||
width: 100,
|
||||
},
|
||||
{
|
||||
field: 'batchCode',
|
||||
title: '批次号',
|
||||
minWidth: 120,
|
||||
},
|
||||
{
|
||||
field: 'fromWarehouseName',
|
||||
title: '移出仓库',
|
||||
minWidth: 120,
|
||||
},
|
||||
{
|
||||
field: 'fromLocationName',
|
||||
title: '移出库区',
|
||||
minWidth: 120,
|
||||
},
|
||||
{
|
||||
field: 'fromAreaName',
|
||||
title: '移出库位',
|
||||
minWidth: 120,
|
||||
},
|
||||
...(editable || stockable
|
||||
? [
|
||||
{
|
||||
title: '操作',
|
||||
width: 180,
|
||||
fixed: 'right',
|
||||
slots: { default: 'actions' },
|
||||
} as const,
|
||||
]
|
||||
: []),
|
||||
];
|
||||
}
|
||||
|
||||
/** 转移单行新增/修改的表单 */
|
||||
export function useLineFormSchema(formApi?: VbenFormApi): VbenFormSchema[] {
|
||||
return [
|
||||
{
|
||||
fieldName: 'quantityMax',
|
||||
component: 'Input',
|
||||
dependencies: {
|
||||
triggerFields: [''],
|
||||
show: () => false,
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldName: 'batchId',
|
||||
component: 'Input',
|
||||
dependencies: {
|
||||
triggerFields: [''],
|
||||
show: () => false,
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldName: 'materialStockId',
|
||||
label: '选择库存',
|
||||
component: markRaw(WmMaterialStockSelect),
|
||||
componentProps: {
|
||||
// 选择库存后,自动回填物料/仓库位置/批次/数量
|
||||
onChange: async (stock?: MesWmMaterialStockApi.MaterialStock) => {
|
||||
await formApi?.setValues({
|
||||
batchCode: stock?.batchCode,
|
||||
batchId: stock?.batchId,
|
||||
fromAreaId: stock?.areaId,
|
||||
fromLocationId: stock?.locationId,
|
||||
fromWarehouseId: stock?.warehouseId,
|
||||
itemId: stock?.itemId,
|
||||
quantity: stock?.quantity,
|
||||
quantityMax: stock?.quantity,
|
||||
});
|
||||
},
|
||||
},
|
||||
rules: 'selectRequired',
|
||||
},
|
||||
{
|
||||
fieldName: 'itemId',
|
||||
label: '物料',
|
||||
component: markRaw(MdItemSelect),
|
||||
componentProps: {
|
||||
disabled: true,
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldName: 'quantity',
|
||||
label: '转移数量',
|
||||
component: 'InputNumber',
|
||||
componentProps: {
|
||||
class: '!w-full',
|
||||
controlsPosition: 'right',
|
||||
min: 0,
|
||||
placeholder: '请输入转移数量',
|
||||
precision: 2,
|
||||
},
|
||||
rules: 'required',
|
||||
dependencies: {
|
||||
triggerFields: ['quantityMax'],
|
||||
componentProps: (values) => ({
|
||||
class: '!w-full',
|
||||
controlsPosition: 'right',
|
||||
max: values.quantityMax,
|
||||
min: 0,
|
||||
placeholder: '请输入转移数量',
|
||||
precision: 2,
|
||||
}),
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldName: 'batchCode',
|
||||
label: '批次号',
|
||||
component: 'Input',
|
||||
componentProps: {
|
||||
disabled: true,
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldName: 'fromWarehouseId',
|
||||
label: '移出仓库',
|
||||
component: markRaw(WmWarehouseSelect),
|
||||
componentProps: {
|
||||
disabled: true,
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldName: 'fromLocationId',
|
||||
label: '移出库区',
|
||||
component: markRaw(WmWarehouseLocationSelect),
|
||||
componentProps: {
|
||||
disabled: true,
|
||||
},
|
||||
dependencies: {
|
||||
triggerFields: ['fromWarehouseId'],
|
||||
componentProps: (values) => ({
|
||||
disabled: true,
|
||||
warehouseId: values.fromWarehouseId,
|
||||
}),
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldName: 'fromAreaId',
|
||||
label: '移出库位',
|
||||
component: markRaw(WmWarehouseAreaSelect),
|
||||
componentProps: {
|
||||
disabled: true,
|
||||
},
|
||||
dependencies: {
|
||||
triggerFields: ['fromLocationId'],
|
||||
componentProps: (values) => ({
|
||||
disabled: true,
|
||||
locationId: values.fromLocationId,
|
||||
}),
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldName: 'remark',
|
||||
label: '备注',
|
||||
component: 'Textarea',
|
||||
formItemClass: 'col-span-3',
|
||||
componentProps: {
|
||||
placeholder: '请输入备注',
|
||||
rows: 3,
|
||||
},
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
/** 调拨明细子表的字段 */
|
||||
export function useDetailGridColumns(
|
||||
stockable: boolean,
|
||||
): VxeTableGridOptions<MesWmTransferDetailApi.TransferDetail>['columns'] {
|
||||
return [
|
||||
{
|
||||
field: 'toWarehouseName',
|
||||
title: '移入仓库',
|
||||
minWidth: 100,
|
||||
},
|
||||
{
|
||||
field: 'toLocationName',
|
||||
title: '移入库区',
|
||||
minWidth: 100,
|
||||
},
|
||||
{
|
||||
field: 'toAreaName',
|
||||
title: '移入库位',
|
||||
minWidth: 100,
|
||||
},
|
||||
{
|
||||
field: 'quantity',
|
||||
title: '数量',
|
||||
width: 100,
|
||||
},
|
||||
...(stockable
|
||||
? [
|
||||
{
|
||||
title: '操作',
|
||||
width: 120,
|
||||
fixed: 'right',
|
||||
slots: { default: 'actions' },
|
||||
} as const,
|
||||
]
|
||||
: []),
|
||||
];
|
||||
}
|
||||
|
||||
/** 调拨明细新增/修改的表单 */
|
||||
export function useDetailFormSchema(): VbenFormSchema[] {
|
||||
return [
|
||||
{
|
||||
fieldName: 'itemId',
|
||||
label: '物料',
|
||||
component: markRaw(MdItemSelect),
|
||||
componentProps: {
|
||||
disabled: true,
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldName: 'toWarehouseId',
|
||||
label: '移入仓库',
|
||||
component: markRaw(WmWarehouseSelect),
|
||||
componentProps: {
|
||||
placeholder: '请选择移入仓库',
|
||||
},
|
||||
rules: 'selectRequired',
|
||||
},
|
||||
{
|
||||
fieldName: 'toLocationId',
|
||||
label: '移入库区',
|
||||
component: markRaw(WmWarehouseLocationSelect),
|
||||
componentProps: {
|
||||
placeholder: '请选择移入库区',
|
||||
},
|
||||
rules: 'selectRequired',
|
||||
dependencies: {
|
||||
triggerFields: ['toWarehouseId'],
|
||||
componentProps: (values) => ({
|
||||
placeholder: '请选择移入库区',
|
||||
warehouseId: values.toWarehouseId,
|
||||
}),
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldName: 'toAreaId',
|
||||
label: '移入库位',
|
||||
component: markRaw(WmWarehouseAreaSelect),
|
||||
componentProps: {
|
||||
placeholder: '请选择移入库位',
|
||||
},
|
||||
rules: 'selectRequired',
|
||||
dependencies: {
|
||||
triggerFields: ['toLocationId'],
|
||||
componentProps: (values) => ({
|
||||
locationId: values.toLocationId,
|
||||
placeholder: '请选择移入库位',
|
||||
}),
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldName: 'quantity',
|
||||
label: '数量',
|
||||
component: 'InputNumber',
|
||||
componentProps: {
|
||||
class: '!w-full',
|
||||
controlsPosition: 'right',
|
||||
min: 0,
|
||||
placeholder: '请输入数量',
|
||||
precision: 2,
|
||||
},
|
||||
rules: 'required',
|
||||
},
|
||||
{
|
||||
fieldName: 'remark',
|
||||
label: '备注',
|
||||
component: 'Textarea',
|
||||
componentProps: {
|
||||
placeholder: '请输入备注',
|
||||
rows: 3,
|
||||
},
|
||||
},
|
||||
];
|
||||
}
|
||||
|
|
@ -0,0 +1,103 @@
|
|||
<script lang="ts" setup>
|
||||
import type { MesWmTransferDetailApi } from '#/api/mes/wm/transfer/detail';
|
||||
|
||||
import { computed, ref } from 'vue';
|
||||
|
||||
import { useVbenModal } from '@vben/common-ui';
|
||||
|
||||
import { ElMessage } from 'element-plus';
|
||||
|
||||
import { useVbenForm } from '#/adapter/form';
|
||||
import {
|
||||
createTransferDetail,
|
||||
getTransferDetail,
|
||||
updateTransferDetail,
|
||||
} from '#/api/mes/wm/transfer/detail';
|
||||
import { $t } from '#/locales';
|
||||
|
||||
import { useDetailFormSchema } from '../data';
|
||||
|
||||
const emit = defineEmits<{ success: [lineId: number] }>();
|
||||
const formData = ref<MesWmTransferDetailApi.TransferDetail>();
|
||||
const transferId = ref<number>(); // 所属转移单编号
|
||||
const lineId = ref<number>(); // 所属转移单行编号
|
||||
|
||||
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: 90,
|
||||
},
|
||||
layout: 'horizontal',
|
||||
schema: useDetailFormSchema(),
|
||||
showDefaultActions: false,
|
||||
wrapperClass: 'grid-cols-2',
|
||||
});
|
||||
|
||||
const [Modal, modalApi] = useVbenModal({
|
||||
async onConfirm() {
|
||||
const { valid } = await formApi.validate();
|
||||
if (!valid) {
|
||||
return;
|
||||
}
|
||||
modalApi.lock();
|
||||
// 提交表单
|
||||
const data =
|
||||
(await formApi.getValues()) as MesWmTransferDetailApi.TransferDetail;
|
||||
data.transferId = transferId.value;
|
||||
data.lineId = lineId.value;
|
||||
try {
|
||||
await (formData.value?.id
|
||||
? updateTransferDetail({ ...data, id: formData.value.id })
|
||||
: createTransferDetail(data));
|
||||
// 关闭并提示
|
||||
await modalApi.close();
|
||||
emit('success', lineId.value!);
|
||||
ElMessage.success($t('ui.actionMessage.operationSuccess'));
|
||||
} finally {
|
||||
modalApi.unlock();
|
||||
}
|
||||
},
|
||||
async onOpenChange(isOpen: boolean) {
|
||||
if (!isOpen) {
|
||||
formData.value = undefined;
|
||||
return;
|
||||
}
|
||||
// 加载数据
|
||||
const data = modalApi.getData<{
|
||||
detailId?: number;
|
||||
itemId?: number;
|
||||
lineId: number;
|
||||
transferId: number;
|
||||
}>();
|
||||
transferId.value = data.transferId;
|
||||
lineId.value = data.lineId;
|
||||
if (data.detailId) {
|
||||
modalApi.lock();
|
||||
try {
|
||||
formData.value = await getTransferDetail(data.detailId);
|
||||
// 设置到 values
|
||||
await formApi.setValues(formData.value);
|
||||
} finally {
|
||||
modalApi.unlock();
|
||||
}
|
||||
} else if (data.itemId) {
|
||||
await formApi.setFieldValue('itemId', data.itemId);
|
||||
}
|
||||
},
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Modal :title="getTitle" class="w-2/5">
|
||||
<Form class="mx-4" />
|
||||
</Modal>
|
||||
</template>
|
||||
|
|
@ -0,0 +1,103 @@
|
|||
<script lang="ts" setup>
|
||||
import type { VxeTableGridOptions } from '#/adapter/vxe-table';
|
||||
import type { MesWmTransferDetailApi } from '#/api/mes/wm/transfer/detail';
|
||||
|
||||
import { computed, watch } from 'vue';
|
||||
|
||||
import { ElLoading, ElMessage } from 'element-plus';
|
||||
|
||||
import { ACTION_ICON, TableAction, useVbenVxeGrid } from '#/adapter/vxe-table';
|
||||
import { deleteTransferDetail } from '#/api/mes/wm/transfer/detail';
|
||||
import { $t } from '#/locales';
|
||||
|
||||
import { type FormType, useDetailGridColumns } from '../data';
|
||||
|
||||
const props = defineProps<{
|
||||
details: MesWmTransferDetailApi.TransferDetail[];
|
||||
formType: FormType;
|
||||
}>();
|
||||
|
||||
const emit = defineEmits<{
|
||||
edit: [detailId: number];
|
||||
refresh: [];
|
||||
}>();
|
||||
|
||||
const isStock = computed(() => props.formType === 'stock'); // 是否为上架模式
|
||||
|
||||
/** 编辑调拨明细 */
|
||||
function handleEdit(row: MesWmTransferDetailApi.TransferDetail) {
|
||||
emit('edit', row.id!);
|
||||
}
|
||||
|
||||
/** 删除调拨明细 */
|
||||
async function handleDelete(row: MesWmTransferDetailApi.TransferDetail) {
|
||||
const loadingInstance = ElLoading.service({
|
||||
text: $t('ui.actionMessage.deleting', [row.toWarehouseName]),
|
||||
});
|
||||
try {
|
||||
await deleteTransferDetail(row.id!);
|
||||
ElMessage.success(
|
||||
$t('ui.actionMessage.deleteSuccess', [row.toWarehouseName]),
|
||||
);
|
||||
emit('refresh');
|
||||
} finally {
|
||||
loadingInstance.close();
|
||||
}
|
||||
}
|
||||
|
||||
const [Grid, gridApi] = useVbenVxeGrid({
|
||||
gridOptions: {
|
||||
border: true,
|
||||
columns: useDetailGridColumns(isStock.value),
|
||||
data: props.details,
|
||||
pagerConfig: {
|
||||
enabled: false,
|
||||
},
|
||||
rowConfig: {
|
||||
keyField: 'id',
|
||||
isHover: true,
|
||||
},
|
||||
size: 'small',
|
||||
toolbarConfig: {
|
||||
enabled: false,
|
||||
},
|
||||
} as VxeTableGridOptions<MesWmTransferDetailApi.TransferDetail>,
|
||||
});
|
||||
|
||||
watch(
|
||||
() => props.details,
|
||||
(details) => gridApi.setGridOptions({ data: details }),
|
||||
);
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="px-4 py-2">
|
||||
<Grid>
|
||||
<template #actions="{ row }">
|
||||
<TableAction
|
||||
:actions="[
|
||||
{
|
||||
label: $t('common.edit'),
|
||||
type: 'primary',
|
||||
link: true,
|
||||
icon: ACTION_ICON.EDIT,
|
||||
onClick: handleEdit.bind(null, row),
|
||||
},
|
||||
{
|
||||
label: $t('common.delete'),
|
||||
type: 'danger',
|
||||
link: true,
|
||||
icon: ACTION_ICON.DELETE,
|
||||
popConfirm: {
|
||||
title: $t('ui.actionMessage.deleteConfirm', [
|
||||
row.toWarehouseName,
|
||||
]),
|
||||
confirm: handleDelete.bind(null, row),
|
||||
},
|
||||
},
|
||||
]"
|
||||
/>
|
||||
</template>
|
||||
</Grid>
|
||||
</div>
|
||||
</template>
|
||||
|
|
@ -0,0 +1,102 @@
|
|||
<script lang="ts" setup>
|
||||
import type { MesWmTransferLineApi } from '#/api/mes/wm/transfer/line';
|
||||
|
||||
import { computed, ref } from 'vue';
|
||||
|
||||
import { useVbenModal } from '@vben/common-ui';
|
||||
|
||||
import { ElMessage } from 'element-plus';
|
||||
|
||||
import { useVbenForm } from '#/adapter/form';
|
||||
import { getMaterialStock } from '#/api/mes/wm/materialstock';
|
||||
import {
|
||||
createTransferLine,
|
||||
getTransferLine,
|
||||
updateTransferLine,
|
||||
} from '#/api/mes/wm/transfer/line';
|
||||
import { $t } from '#/locales';
|
||||
|
||||
import { useLineFormSchema } from '../data';
|
||||
|
||||
const emit = defineEmits(['success']);
|
||||
const formData = ref<MesWmTransferLineApi.TransferLine>();
|
||||
const transferId = ref<number>(); // 所属转移单编号
|
||||
|
||||
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-1',
|
||||
labelWidth: 90,
|
||||
},
|
||||
layout: 'horizontal',
|
||||
schema: [],
|
||||
showDefaultActions: false,
|
||||
wrapperClass: 'grid-cols-3',
|
||||
});
|
||||
|
||||
const [Modal, modalApi] = useVbenModal({
|
||||
async onConfirm() {
|
||||
const { valid } = await formApi.validate();
|
||||
if (!valid) {
|
||||
return;
|
||||
}
|
||||
modalApi.lock();
|
||||
// 提交表单
|
||||
const data =
|
||||
(await formApi.getValues()) as MesWmTransferLineApi.TransferLine;
|
||||
data.transferId = transferId.value;
|
||||
try {
|
||||
await (formData.value?.id
|
||||
? updateTransferLine({ ...data, id: formData.value.id })
|
||||
: createTransferLine(data));
|
||||
// 关闭并提示
|
||||
await modalApi.close();
|
||||
emit('success');
|
||||
ElMessage.success($t('ui.actionMessage.operationSuccess'));
|
||||
} finally {
|
||||
modalApi.unlock();
|
||||
}
|
||||
},
|
||||
async onOpenChange(isOpen: boolean) {
|
||||
if (!isOpen) {
|
||||
formData.value = undefined;
|
||||
return;
|
||||
}
|
||||
formApi.setState({ schema: useLineFormSchema(formApi) });
|
||||
// 加载数据
|
||||
const data = modalApi.getData<{ id?: number; transferId: number }>();
|
||||
transferId.value = data.transferId;
|
||||
if (!data.id) {
|
||||
return;
|
||||
}
|
||||
modalApi.lock();
|
||||
try {
|
||||
formData.value = await getTransferLine(data.id);
|
||||
// 编辑时按当前库存在库量作为数量上限
|
||||
let quantityMax: number | undefined;
|
||||
if (formData.value.materialStockId) {
|
||||
const stock = await getMaterialStock(formData.value.materialStockId);
|
||||
quantityMax = stock?.quantity;
|
||||
}
|
||||
// 设置到 values
|
||||
await formApi.setValues({ ...formData.value, quantityMax });
|
||||
} finally {
|
||||
modalApi.unlock();
|
||||
}
|
||||
},
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Modal :title="getTitle" class="w-3/5">
|
||||
<Form class="mx-4" />
|
||||
</Modal>
|
||||
</template>
|
||||
|
|
@ -0,0 +1,227 @@
|
|||
<script lang="ts" setup>
|
||||
import type { VxeTableGridOptions } from '#/adapter/vxe-table';
|
||||
import type { MesWmTransferDetailApi } from '#/api/mes/wm/transfer/detail';
|
||||
import type { MesWmTransferLineApi } from '#/api/mes/wm/transfer/line';
|
||||
|
||||
import { computed, reactive } from 'vue';
|
||||
|
||||
import { useVbenModal } from '@vben/common-ui';
|
||||
|
||||
import { ElLoading, ElMessage } from 'element-plus';
|
||||
|
||||
import { ACTION_ICON, TableAction, useVbenVxeGrid } from '#/adapter/vxe-table';
|
||||
import { getTransferDetailListByLineId } from '#/api/mes/wm/transfer/detail';
|
||||
import {
|
||||
deleteTransferLine,
|
||||
getTransferLineList,
|
||||
} from '#/api/mes/wm/transfer/line';
|
||||
import { $t } from '#/locales';
|
||||
import { PrinterLabel } from '#/views/mes/wm/barcode/components';
|
||||
|
||||
import { type FormType, useLineGridColumns } from '../data';
|
||||
import DetailForm from './detail-form.vue';
|
||||
import DetailList from './detail-list.vue';
|
||||
import LineForm from './line-form.vue';
|
||||
|
||||
const props = defineProps<{
|
||||
formType: FormType;
|
||||
transferId: number;
|
||||
}>();
|
||||
|
||||
const isEditable = computed(() =>
|
||||
['create', 'update'].includes(props.formType),
|
||||
); // 是否可编辑调拨物料行
|
||||
const isStock = computed(() => props.formType === 'stock'); // 是否为上架模式
|
||||
const detailMap = reactive<
|
||||
Record<number, MesWmTransferDetailApi.TransferDetail[]>
|
||||
>({}); // 已展开行的调拨明细缓存
|
||||
|
||||
const [LineFormModal, lineFormModalApi] = useVbenModal({
|
||||
connectedComponent: LineForm,
|
||||
destroyOnClose: true,
|
||||
});
|
||||
|
||||
const [DetailFormModal, detailFormModalApi] = useVbenModal({
|
||||
connectedComponent: DetailForm,
|
||||
destroyOnClose: true,
|
||||
});
|
||||
|
||||
/** 刷新表格 */
|
||||
function handleRefresh() {
|
||||
for (const id of Object.keys(detailMap)) {
|
||||
delete detailMap[Number(id)];
|
||||
}
|
||||
gridApi.query();
|
||||
}
|
||||
|
||||
/** 添加调拨物料 */
|
||||
function handleCreate() {
|
||||
lineFormModalApi.setData({ transferId: props.transferId }).open();
|
||||
}
|
||||
|
||||
/** 编辑调拨物料 */
|
||||
function handleEdit(row: MesWmTransferLineApi.TransferLine) {
|
||||
lineFormModalApi.setData({ id: row.id, transferId: props.transferId }).open();
|
||||
}
|
||||
|
||||
/** 删除调拨物料 */
|
||||
async function handleDelete(row: MesWmTransferLineApi.TransferLine) {
|
||||
const loadingInstance = ElLoading.service({
|
||||
text: $t('ui.actionMessage.deleting', [row.itemName]),
|
||||
});
|
||||
try {
|
||||
await deleteTransferLine(row.id!);
|
||||
ElMessage.success($t('ui.actionMessage.deleteSuccess', [row.itemName]));
|
||||
handleRefresh();
|
||||
} finally {
|
||||
loadingInstance.close();
|
||||
}
|
||||
}
|
||||
|
||||
/** 上架:直接打开明细新增表单 */
|
||||
function handleStock(row: MesWmTransferLineApi.TransferLine) {
|
||||
openDetailForm(row.id!, row.itemId);
|
||||
}
|
||||
|
||||
/** 打开调拨明细表单 */
|
||||
function openDetailForm(lineId: number, itemId?: number, detailId?: number) {
|
||||
detailFormModalApi
|
||||
.setData({ detailId, itemId, lineId, transferId: props.transferId })
|
||||
.open();
|
||||
}
|
||||
|
||||
/** 获取已展开行的调拨明细 */
|
||||
function getExpandedDetails(row: MesWmTransferLineApi.TransferLine) {
|
||||
return detailMap[row.id!] || [];
|
||||
}
|
||||
|
||||
/** 加载指定行的调拨明细 */
|
||||
async function loadLineDetails(lineId: number) {
|
||||
detailMap[lineId] = await getTransferDetailListByLineId(lineId);
|
||||
}
|
||||
|
||||
/** 展开行时懒加载调拨明细 */
|
||||
async function handleExpandChange(
|
||||
row: MesWmTransferLineApi.TransferLine,
|
||||
expanded: boolean,
|
||||
) {
|
||||
if (!expanded) {
|
||||
return;
|
||||
}
|
||||
await loadLineDetails(row.id!);
|
||||
}
|
||||
|
||||
/** 明细表单提交成功后,刷新对应行已展开的明细 */
|
||||
async function handleDetailSuccess(lineId: number) {
|
||||
await loadLineDetails(lineId);
|
||||
}
|
||||
|
||||
const [Grid, gridApi] = useVbenVxeGrid({
|
||||
gridOptions: {
|
||||
columns: useLineGridColumns(isEditable.value, isStock.value),
|
||||
expandConfig: {
|
||||
padding: true,
|
||||
},
|
||||
height: 400,
|
||||
keepSource: true,
|
||||
proxyConfig: {
|
||||
ajax: {
|
||||
query: async () => {
|
||||
if (!props.transferId) {
|
||||
return [];
|
||||
}
|
||||
return await getTransferLineList(props.transferId);
|
||||
},
|
||||
},
|
||||
},
|
||||
pagerConfig: {
|
||||
enabled: false,
|
||||
},
|
||||
rowConfig: {
|
||||
keyField: 'id',
|
||||
isHover: true,
|
||||
},
|
||||
toolbarConfig: {
|
||||
refresh: true,
|
||||
},
|
||||
} as VxeTableGridOptions<MesWmTransferLineApi.TransferLine>,
|
||||
gridEvents: {
|
||||
toggleRowExpand: ({
|
||||
expanded,
|
||||
row,
|
||||
}: {
|
||||
expanded: boolean;
|
||||
row: MesWmTransferLineApi.TransferLine;
|
||||
}) => {
|
||||
handleExpandChange(row, expanded);
|
||||
},
|
||||
},
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div>
|
||||
<LineFormModal @success="handleRefresh" />
|
||||
<DetailFormModal @success="handleDetailSuccess" />
|
||||
<Grid table-title="物料信息">
|
||||
<template v-if="isEditable" #toolbar-tools>
|
||||
<TableAction
|
||||
:actions="[
|
||||
{
|
||||
label: '添加调拨物料',
|
||||
type: 'primary',
|
||||
icon: ACTION_ICON.ADD,
|
||||
onClick: handleCreate,
|
||||
},
|
||||
]"
|
||||
/>
|
||||
</template>
|
||||
<template #detail="{ row }">
|
||||
<DetailList
|
||||
:details="getExpandedDetails(row)"
|
||||
:form-type="formType"
|
||||
@edit="(detailId) => openDetailForm(row.id!, row.itemId, detailId)"
|
||||
@refresh="loadLineDetails(row.id!)"
|
||||
/>
|
||||
</template>
|
||||
<template #actions="{ row }">
|
||||
<TableAction
|
||||
:actions="[
|
||||
{
|
||||
label: $t('common.edit'),
|
||||
type: 'primary',
|
||||
link: true,
|
||||
icon: ACTION_ICON.EDIT,
|
||||
ifShow: isEditable,
|
||||
onClick: handleEdit.bind(null, row),
|
||||
},
|
||||
{
|
||||
label: $t('common.delete'),
|
||||
type: 'danger',
|
||||
link: true,
|
||||
icon: ACTION_ICON.DELETE,
|
||||
ifShow: isEditable,
|
||||
popConfirm: {
|
||||
title: $t('ui.actionMessage.deleteConfirm', [row.itemName]),
|
||||
confirm: handleDelete.bind(null, row),
|
||||
},
|
||||
},
|
||||
{
|
||||
label: '上架',
|
||||
type: 'primary',
|
||||
link: true,
|
||||
ifShow: isStock,
|
||||
onClick: handleStock.bind(null, row),
|
||||
},
|
||||
]"
|
||||
/>
|
||||
<PrinterLabel
|
||||
v-if="isStock"
|
||||
:biz-code="row.batchCode"
|
||||
:biz-id="row.batchId"
|
||||
biz-type="BATCH"
|
||||
/>
|
||||
</template>
|
||||
</Grid>
|
||||
</div>
|
||||
</template>
|
||||
Loading…
Reference in New Issue