feat(mes): 迁移 wm 里的 return-* 系列
parent
3ef3f246c2
commit
2fd44246f8
|
|
@ -0,0 +1,568 @@
|
|||
import type { VbenFormApi, VbenFormSchema } from '#/adapter/form';
|
||||
import type { VxeTableGridOptions } from '#/adapter/vxe-table';
|
||||
import type { MesWmMaterialStockApi } from '#/api/mes/wm/materialstock';
|
||||
import type { MesWmReturnIssueApi } from '#/api/mes/wm/returnissue';
|
||||
import type { MesWmReturnIssueDetailApi } from '#/api/mes/wm/returnissue/detail';
|
||||
import type { MesWmReturnIssueLineApi } from '#/api/mes/wm/returnissue/line';
|
||||
|
||||
import { h, markRaw } from 'vue';
|
||||
|
||||
import { DICT_TYPE } from '@vben/constants';
|
||||
import { getDictOptions } from '@vben/hooks';
|
||||
|
||||
import { Button } from 'ant-design-vue';
|
||||
|
||||
import { z } from '#/adapter/form';
|
||||
import { generateAutoCode } from '#/api/mes/md/autocode/record';
|
||||
import MdItemSelect from '#/views/mes/md/item/components/md-item-select.vue';
|
||||
import MdWorkstationSelect from '#/views/mes/md/workstation/components/md-workstation-select.vue';
|
||||
import ProWorkOrderSelect from '#/views/mes/pro/workorder/components/pro-work-order-select.vue';
|
||||
import {
|
||||
MesAutoCodeRuleCode,
|
||||
MesProWorkOrderStatusEnum,
|
||||
} 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 = 'create' | 'detail' | 'finish' | 'stock' | 'update';
|
||||
|
||||
/** 表单头部是否只读(上架、详情、执行退料态) */
|
||||
function isHeaderReadonly(formType: FormType): boolean {
|
||||
return (
|
||||
formType === 'detail' || formType === 'finish' || formType === 'stock'
|
||||
);
|
||||
}
|
||||
|
||||
/** 新增/修改的表单 */
|
||||
export function useFormSchema(
|
||||
formType: FormType,
|
||||
formApi?: VbenFormApi,
|
||||
): VbenFormSchema[] {
|
||||
return [
|
||||
{
|
||||
fieldName: 'id',
|
||||
component: 'Input',
|
||||
dependencies: {
|
||||
triggerFields: [''],
|
||||
show: () => false,
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldName: 'status',
|
||||
component: 'Input',
|
||||
dependencies: {
|
||||
triggerFields: [''],
|
||||
show: () => false,
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldName: 'code',
|
||||
label: '退料单编号',
|
||||
component: 'Input',
|
||||
componentProps: {
|
||||
placeholder: '请输入退料单编号',
|
||||
},
|
||||
rules: 'required',
|
||||
suffix: isHeaderReadonly(formType)
|
||||
? undefined
|
||||
: () =>
|
||||
h(
|
||||
Button,
|
||||
{
|
||||
type: 'default',
|
||||
onClick: async () => {
|
||||
const code = await generateAutoCode(
|
||||
MesAutoCodeRuleCode.WM_RETURN_ISSUE_CODE,
|
||||
);
|
||||
await formApi?.setFieldValue('code', code);
|
||||
},
|
||||
},
|
||||
{ default: () => '生成' },
|
||||
),
|
||||
},
|
||||
{
|
||||
fieldName: 'name',
|
||||
label: '退料单名称',
|
||||
component: 'Input',
|
||||
componentProps: {
|
||||
placeholder: '请输入退料单名称',
|
||||
},
|
||||
rules: 'required',
|
||||
},
|
||||
{
|
||||
fieldName: 'type',
|
||||
label: '退料类型',
|
||||
component: 'Select',
|
||||
componentProps: {
|
||||
allowClear: true,
|
||||
options: getDictOptions(DICT_TYPE.MES_WM_RETURN_ISSUE_TYPE, 'number'),
|
||||
placeholder: '请选择退料类型',
|
||||
},
|
||||
rules: 'required',
|
||||
},
|
||||
{
|
||||
fieldName: 'workOrderId',
|
||||
label: '生产工单',
|
||||
component: markRaw(ProWorkOrderSelect),
|
||||
componentProps: {
|
||||
status: MesProWorkOrderStatusEnum.CONFIRMED,
|
||||
},
|
||||
rules: 'selectRequired',
|
||||
},
|
||||
{
|
||||
fieldName: 'workstationId',
|
||||
label: '工作站',
|
||||
component: markRaw(MdWorkstationSelect),
|
||||
componentProps: {
|
||||
placeholder: '请选择工作站',
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldName: 'returnDate',
|
||||
label: '退料日期',
|
||||
component: 'DatePicker',
|
||||
componentProps: {
|
||||
class: '!w-full',
|
||||
format: 'YYYY-MM-DD HH:mm:ss',
|
||||
placeholder: '请选择退料日期',
|
||||
showTime: true,
|
||||
valueFormat: 'x',
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldName: 'remark',
|
||||
label: '备注',
|
||||
component: 'Textarea',
|
||||
formItemClass: 'col-span-3',
|
||||
componentProps: {
|
||||
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: 'workOrderId',
|
||||
label: '生产工单',
|
||||
component: markRaw(ProWorkOrderSelect),
|
||||
componentProps: {
|
||||
placeholder: '请选择生产工单',
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldName: 'type',
|
||||
label: '退料类型',
|
||||
component: 'Select',
|
||||
componentProps: {
|
||||
allowClear: true,
|
||||
options: getDictOptions(DICT_TYPE.MES_WM_RETURN_ISSUE_TYPE, 'number'),
|
||||
placeholder: '请选择退料类型',
|
||||
},
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
/** 列表的字段 */
|
||||
export function useGridColumns(): VxeTableGridOptions<MesWmReturnIssueApi.ReturnIssue>['columns'] {
|
||||
return [
|
||||
{
|
||||
field: 'code',
|
||||
title: '退料单编号',
|
||||
minWidth: 160,
|
||||
slots: { default: 'code' },
|
||||
},
|
||||
{
|
||||
field: 'name',
|
||||
title: '退料单名称',
|
||||
minWidth: 150,
|
||||
},
|
||||
{
|
||||
field: 'type',
|
||||
title: '退料类型',
|
||||
minWidth: 110,
|
||||
cellRender: {
|
||||
name: 'CellDict',
|
||||
props: { type: DICT_TYPE.MES_WM_RETURN_ISSUE_TYPE },
|
||||
},
|
||||
},
|
||||
{
|
||||
field: 'workOrderCode',
|
||||
title: '生产工单',
|
||||
minWidth: 140,
|
||||
},
|
||||
{
|
||||
field: 'workstationName',
|
||||
title: '工作站',
|
||||
minWidth: 120,
|
||||
},
|
||||
{
|
||||
field: 'returnDate',
|
||||
title: '退料日期',
|
||||
width: 180,
|
||||
formatter: 'formatDateTime',
|
||||
},
|
||||
{
|
||||
field: 'status',
|
||||
title: '单据状态',
|
||||
minWidth: 110,
|
||||
cellRender: {
|
||||
name: 'CellDict',
|
||||
props: { type: DICT_TYPE.MES_WM_RETURN_ISSUE_STATUS },
|
||||
},
|
||||
},
|
||||
{
|
||||
title: '操作',
|
||||
width: 240,
|
||||
fixed: 'right',
|
||||
slots: { default: 'actions' },
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
/** 退料单行子表的字段 */
|
||||
export function useLineGridColumns(
|
||||
editable: boolean,
|
||||
stockable: boolean,
|
||||
): VxeTableGridOptions<MesWmReturnIssueLineApi.ReturnIssueLine>['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: 'rqcCheckFlag',
|
||||
title: '是否检测',
|
||||
width: 100,
|
||||
cellRender: {
|
||||
name: 'CellDict',
|
||||
props: { type: DICT_TYPE.INFRA_BOOLEAN_STRING },
|
||||
},
|
||||
},
|
||||
{
|
||||
field: 'qualityStatus',
|
||||
title: '质量状态',
|
||||
width: 100,
|
||||
cellRender: {
|
||||
name: 'CellDict',
|
||||
props: { type: DICT_TYPE.MES_WM_QUALITY_STATUS },
|
||||
},
|
||||
},
|
||||
...(editable || stockable
|
||||
? [
|
||||
{
|
||||
title: '操作',
|
||||
width: 200,
|
||||
fixed: 'right',
|
||||
slots: { default: 'actions' },
|
||||
} as const,
|
||||
]
|
||||
: []),
|
||||
];
|
||||
}
|
||||
|
||||
/** 退料单行新增/修改的表单 */
|
||||
export function useLineFormSchema(formApi?: VbenFormApi): VbenFormSchema[] {
|
||||
return [
|
||||
{
|
||||
fieldName: 'materialStockId',
|
||||
label: '库存记录',
|
||||
component: markRaw(WmMaterialStockSelect),
|
||||
componentProps: {
|
||||
// 选择库存记录后,自动回填物料/批次/数量
|
||||
onChange: async (stock?: MesWmMaterialStockApi.MaterialStock) => {
|
||||
await formApi?.setValues({
|
||||
batchCode: stock?.batchCode,
|
||||
batchId: stock?.batchId,
|
||||
itemId: stock?.itemId,
|
||||
quantity: stock?.quantity,
|
||||
quantityMax: stock?.quantity,
|
||||
});
|
||||
},
|
||||
virtualFilter: 'only',
|
||||
},
|
||||
rules: 'selectRequired',
|
||||
},
|
||||
{
|
||||
fieldName: 'quantityMax',
|
||||
component: 'Input',
|
||||
dependencies: {
|
||||
triggerFields: [''],
|
||||
show: () => false,
|
||||
},
|
||||
},
|
||||
{
|
||||
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: 'rqcCheckFlag',
|
||||
label: '需要质检',
|
||||
component: 'Switch',
|
||||
rules: z.boolean().default(false),
|
||||
},
|
||||
{
|
||||
fieldName: 'itemId',
|
||||
label: '物料',
|
||||
component: markRaw(MdItemSelect),
|
||||
componentProps: {
|
||||
disabled: true,
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldName: 'batchCode',
|
||||
label: '批次号',
|
||||
component: 'Input',
|
||||
componentProps: {
|
||||
disabled: true,
|
||||
placeholder: '选择库存后自动带出',
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldName: 'remark',
|
||||
label: '备注',
|
||||
component: 'Textarea',
|
||||
formItemClass: 'col-span-3',
|
||||
componentProps: {
|
||||
placeholder: '请输入备注',
|
||||
rows: 3,
|
||||
},
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
/** 上架明细子表的字段 */
|
||||
export function useDetailGridColumns(
|
||||
stockable: boolean,
|
||||
): VxeTableGridOptions<MesWmReturnIssueDetailApi.ReturnIssueDetail>['columns'] {
|
||||
return [
|
||||
{
|
||||
field: 'batchCode',
|
||||
title: '批次号',
|
||||
minWidth: 120,
|
||||
},
|
||||
{
|
||||
field: 'warehouseName',
|
||||
title: '仓库名称',
|
||||
minWidth: 100,
|
||||
},
|
||||
{
|
||||
field: 'locationName',
|
||||
title: '库区名称',
|
||||
minWidth: 100,
|
||||
},
|
||||
{
|
||||
field: 'areaName',
|
||||
title: '库位名称',
|
||||
minWidth: 100,
|
||||
},
|
||||
{
|
||||
field: 'quantity',
|
||||
title: '数量',
|
||||
width: 100,
|
||||
},
|
||||
...(stockable
|
||||
? [
|
||||
{
|
||||
title: '操作',
|
||||
width: 120,
|
||||
fixed: 'right',
|
||||
slots: { default: 'actions' },
|
||||
} as const,
|
||||
]
|
||||
: []),
|
||||
];
|
||||
}
|
||||
|
||||
/** 上架明细新增/修改的表单 */
|
||||
export function useDetailFormSchema(formApi?: VbenFormApi): VbenFormSchema[] {
|
||||
return [
|
||||
{
|
||||
fieldName: 'quantityMax',
|
||||
component: 'Input',
|
||||
dependencies: {
|
||||
triggerFields: [''],
|
||||
show: () => false,
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldName: 'itemId',
|
||||
label: '物料',
|
||||
component: markRaw(MdItemSelect),
|
||||
componentProps: {
|
||||
disabled: true,
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldName: 'materialStockId',
|
||||
label: '库存记录',
|
||||
component: markRaw(WmMaterialStockSelect),
|
||||
componentProps: {
|
||||
// 选择库存记录后,自动回填仓库/库区/库位/批次/数量
|
||||
onChange: async (stock?: MesWmMaterialStockApi.MaterialStock) => {
|
||||
await formApi?.setValues({
|
||||
areaId: stock?.areaId,
|
||||
batchCode: stock?.batchCode,
|
||||
batchId: stock?.batchId,
|
||||
locationId: stock?.locationId,
|
||||
quantity: stock?.quantity,
|
||||
quantityMax: stock?.quantity,
|
||||
warehouseId: stock?.warehouseId,
|
||||
});
|
||||
},
|
||||
virtualFilter: 'only',
|
||||
},
|
||||
rules: 'selectRequired',
|
||||
dependencies: {
|
||||
triggerFields: ['itemId'],
|
||||
componentProps: (values) => ({
|
||||
itemId: values.itemId,
|
||||
virtualFilter: 'only',
|
||||
}),
|
||||
},
|
||||
},
|
||||
{
|
||||
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: 'warehouseId',
|
||||
label: '入库仓库',
|
||||
component: markRaw(WmWarehouseSelect),
|
||||
componentProps: {
|
||||
disabled: true,
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldName: 'locationId',
|
||||
label: '库区',
|
||||
component: markRaw(WmWarehouseLocationSelect),
|
||||
componentProps: {
|
||||
disabled: true,
|
||||
},
|
||||
dependencies: {
|
||||
triggerFields: ['warehouseId'],
|
||||
componentProps: (values) => ({
|
||||
disabled: true,
|
||||
warehouseId: values.warehouseId,
|
||||
}),
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldName: 'areaId',
|
||||
label: '库位',
|
||||
component: markRaw(WmWarehouseAreaSelect),
|
||||
componentProps: {
|
||||
disabled: true,
|
||||
},
|
||||
dependencies: {
|
||||
triggerFields: ['locationId'],
|
||||
componentProps: (values) => ({
|
||||
disabled: true,
|
||||
locationId: values.locationId,
|
||||
}),
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldName: 'batchCode',
|
||||
label: '批次号',
|
||||
component: 'Input',
|
||||
componentProps: {
|
||||
disabled: true,
|
||||
},
|
||||
},
|
||||
];
|
||||
}
|
||||
|
|
@ -0,0 +1,221 @@
|
|||
<script lang="ts" setup>
|
||||
import type { VxeTableGridOptions } from '#/adapter/vxe-table';
|
||||
import type { MesWmReturnIssueApi } from '#/api/mes/wm/returnissue';
|
||||
|
||||
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 {
|
||||
cancelReturnIssue,
|
||||
deleteReturnIssue,
|
||||
exportReturnIssue,
|
||||
getReturnIssuePage,
|
||||
} from '#/api/mes/wm/returnissue';
|
||||
import { $t } from '#/locales';
|
||||
import { MesWmReturnIssueStatusEnum } 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: MesWmReturnIssueApi.ReturnIssue) {
|
||||
formModalApi.setData({ formType: 'detail', id: row.id }).open();
|
||||
}
|
||||
|
||||
/** 编辑生产退料单 */
|
||||
function handleEdit(row: MesWmReturnIssueApi.ReturnIssue) {
|
||||
formModalApi.setData({ formType: 'update', id: row.id }).open();
|
||||
}
|
||||
|
||||
/** 执行上架 */
|
||||
function handleStock(row: MesWmReturnIssueApi.ReturnIssue) {
|
||||
formModalApi.setData({ formType: 'stock', id: row.id }).open();
|
||||
}
|
||||
|
||||
/** 执行退料 */
|
||||
function handleFinish(row: MesWmReturnIssueApi.ReturnIssue) {
|
||||
formModalApi.setData({ formType: 'finish', id: row.id }).open();
|
||||
}
|
||||
|
||||
/** 提示前往质检模块 */
|
||||
function handleQc() {
|
||||
message.info('请前往【质量管理 - 退货检验(RQC)】中进行退料检验操作');
|
||||
}
|
||||
|
||||
/** 删除生产退料单 */
|
||||
async function handleDelete(row: MesWmReturnIssueApi.ReturnIssue) {
|
||||
const hideLoading = message.loading({
|
||||
content: $t('ui.actionMessage.deleting', [row.code]),
|
||||
duration: 0,
|
||||
});
|
||||
try {
|
||||
await deleteReturnIssue(row.id!);
|
||||
message.success($t('ui.actionMessage.deleteSuccess', [row.code]));
|
||||
handleRefresh();
|
||||
} finally {
|
||||
hideLoading();
|
||||
}
|
||||
}
|
||||
|
||||
/** 取消生产退料单 */
|
||||
async function handleCancel(row: MesWmReturnIssueApi.ReturnIssue) {
|
||||
await cancelReturnIssue(row.id!);
|
||||
message.success('取消成功');
|
||||
handleRefresh();
|
||||
}
|
||||
|
||||
/** 导出表格 */
|
||||
async function handleExport() {
|
||||
const data = await exportReturnIssue(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 getReturnIssuePage({
|
||||
pageNo: page.currentPage,
|
||||
pageSize: page.pageSize,
|
||||
...formValues,
|
||||
});
|
||||
},
|
||||
},
|
||||
},
|
||||
rowConfig: {
|
||||
keyField: 'id',
|
||||
isHover: true,
|
||||
},
|
||||
toolbarConfig: {
|
||||
refresh: true,
|
||||
search: true,
|
||||
},
|
||||
} as VxeTableGridOptions<MesWmReturnIssueApi.ReturnIssue>,
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Page auto-content-height>
|
||||
<template #doc>
|
||||
<DocAlert
|
||||
title="【仓库】生产领料、生产退料、物料消耗"
|
||||
url="https://doc.iocoder.cn/mes/wm/issue-return/"
|
||||
/>
|
||||
</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-return-issue:create'],
|
||||
onClick: handleCreate,
|
||||
},
|
||||
{
|
||||
label: $t('ui.actionTitle.export'),
|
||||
type: 'primary',
|
||||
icon: ACTION_ICON.DOWNLOAD,
|
||||
auth: ['mes:wm-return-issue: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-return-issue:update'],
|
||||
ifShow: row.status === MesWmReturnIssueStatusEnum.PREPARE,
|
||||
onClick: handleEdit.bind(null, row),
|
||||
},
|
||||
{
|
||||
label: $t('common.delete'),
|
||||
type: 'link',
|
||||
danger: true,
|
||||
icon: ACTION_ICON.DELETE,
|
||||
auth: ['mes:wm-return-issue:delete'],
|
||||
ifShow: row.status === MesWmReturnIssueStatusEnum.PREPARE,
|
||||
popConfirm: {
|
||||
title: $t('ui.actionMessage.deleteConfirm', [row.code]),
|
||||
confirm: handleDelete.bind(null, row),
|
||||
},
|
||||
},
|
||||
{
|
||||
label: '执行质检',
|
||||
type: 'link',
|
||||
ifShow: row.status === MesWmReturnIssueStatusEnum.CONFIRMED,
|
||||
onClick: handleQc,
|
||||
},
|
||||
{
|
||||
label: '执行上架',
|
||||
type: 'link',
|
||||
auth: ['mes:wm-return-issue:update'],
|
||||
ifShow: row.status === MesWmReturnIssueStatusEnum.APPROVING,
|
||||
onClick: handleStock.bind(null, row),
|
||||
},
|
||||
{
|
||||
label: '执行退料',
|
||||
type: 'link',
|
||||
auth: ['mes:wm-return-issue:finish'],
|
||||
ifShow: row.status === MesWmReturnIssueStatusEnum.APPROVED,
|
||||
onClick: handleFinish.bind(null, row),
|
||||
},
|
||||
{
|
||||
label: '取消',
|
||||
type: 'link',
|
||||
danger: true,
|
||||
auth: ['mes:wm-return-issue:update'],
|
||||
ifShow:
|
||||
row.status === MesWmReturnIssueStatusEnum.CONFIRMED ||
|
||||
row.status === MesWmReturnIssueStatusEnum.APPROVING ||
|
||||
row.status === MesWmReturnIssueStatusEnum.APPROVED,
|
||||
popConfirm: {
|
||||
title: '确认取消该生产退料单?取消后不可恢复。',
|
||||
confirm: handleCancel.bind(null, row),
|
||||
},
|
||||
},
|
||||
]"
|
||||
/>
|
||||
</template>
|
||||
</Grid>
|
||||
</Page>
|
||||
</template>
|
||||
|
|
@ -0,0 +1,104 @@
|
|||
<script lang="ts" setup>
|
||||
import type { MesWmReturnIssueDetailApi } from '#/api/mes/wm/returnissue/detail';
|
||||
|
||||
import { computed, ref } from 'vue';
|
||||
|
||||
import { useVbenModal } from '@vben/common-ui';
|
||||
|
||||
import { message } from 'ant-design-vue';
|
||||
|
||||
import { useVbenForm } from '#/adapter/form';
|
||||
import {
|
||||
createReturnIssueDetail,
|
||||
getReturnIssueDetail,
|
||||
updateReturnIssueDetail,
|
||||
} from '#/api/mes/wm/returnissue/detail';
|
||||
import { $t } from '#/locales';
|
||||
|
||||
import { useDetailFormSchema } from '../data';
|
||||
|
||||
const emit = defineEmits<{ success: [lineId: number] }>();
|
||||
const formData = ref<MesWmReturnIssueDetailApi.ReturnIssueDetail>();
|
||||
const issueId = 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-1',
|
||||
labelWidth: 90,
|
||||
},
|
||||
layout: 'horizontal',
|
||||
schema: useDetailFormSchema(),
|
||||
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 MesWmReturnIssueDetailApi.ReturnIssueDetail;
|
||||
data.issueId = issueId.value;
|
||||
data.lineId = lineId.value;
|
||||
try {
|
||||
await (formData.value?.id
|
||||
? updateReturnIssueDetail({ ...data, id: formData.value.id })
|
||||
: createReturnIssueDetail(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;
|
||||
}
|
||||
formApi.setState({ schema: useDetailFormSchema(formApi) });
|
||||
// 加载数据
|
||||
const data = modalApi.getData<{
|
||||
detailId?: number;
|
||||
issueId: number;
|
||||
itemId?: number;
|
||||
lineId: number;
|
||||
}>();
|
||||
issueId.value = data.issueId;
|
||||
lineId.value = data.lineId;
|
||||
if (data.detailId) {
|
||||
modalApi.lock();
|
||||
try {
|
||||
formData.value = await getReturnIssueDetail(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-3/5">
|
||||
<Form class="mx-4" />
|
||||
</Modal>
|
||||
</template>
|
||||
|
|
@ -0,0 +1,103 @@
|
|||
<script lang="ts" setup>
|
||||
import type { VxeTableGridOptions } from '#/adapter/vxe-table';
|
||||
import type { MesWmReturnIssueDetailApi } from '#/api/mes/wm/returnissue/detail';
|
||||
|
||||
import { computed, watch } from 'vue';
|
||||
|
||||
import { message } from 'ant-design-vue';
|
||||
|
||||
import { ACTION_ICON, TableAction, useVbenVxeGrid } from '#/adapter/vxe-table';
|
||||
import { deleteReturnIssueDetail } from '#/api/mes/wm/returnissue/detail';
|
||||
import { $t } from '#/locales';
|
||||
|
||||
import { type FormType, useDetailGridColumns } from '../data';
|
||||
|
||||
const props = defineProps<{
|
||||
details: MesWmReturnIssueDetailApi.ReturnIssueDetail[];
|
||||
formType: FormType;
|
||||
}>();
|
||||
|
||||
const emit = defineEmits<{
|
||||
edit: [detailId: number];
|
||||
refresh: [];
|
||||
}>();
|
||||
|
||||
const isStock = computed(() => props.formType === 'stock'); // 是否为入库上架模式
|
||||
|
||||
/** 编辑上架明细 */
|
||||
function handleEdit(row: MesWmReturnIssueDetailApi.ReturnIssueDetail) {
|
||||
emit('edit', row.id!);
|
||||
}
|
||||
|
||||
/** 删除上架明细 */
|
||||
async function handleDelete(
|
||||
row: MesWmReturnIssueDetailApi.ReturnIssueDetail,
|
||||
) {
|
||||
const hideLoading = message.loading({
|
||||
content: $t('ui.actionMessage.deleting', [row.warehouseName]),
|
||||
duration: 0,
|
||||
});
|
||||
try {
|
||||
await deleteReturnIssueDetail(row.id!);
|
||||
message.success($t('ui.actionMessage.deleteSuccess', [row.warehouseName]));
|
||||
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<MesWmReturnIssueDetailApi.ReturnIssueDetail>,
|
||||
});
|
||||
|
||||
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.warehouseName,
|
||||
]),
|
||||
confirm: handleDelete.bind(null, row),
|
||||
},
|
||||
},
|
||||
]"
|
||||
/>
|
||||
</template>
|
||||
</Grid>
|
||||
</div>
|
||||
</template>
|
||||
|
|
@ -0,0 +1,225 @@
|
|||
<script lang="ts" setup>
|
||||
import type { FormType } from '../data';
|
||||
|
||||
import type { MesWmReturnIssueApi } from '#/api/mes/wm/returnissue';
|
||||
|
||||
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 {
|
||||
createReturnIssue,
|
||||
finishReturnIssue,
|
||||
getReturnIssue,
|
||||
stockReturnIssue,
|
||||
submitReturnIssue,
|
||||
updateReturnIssue,
|
||||
} from '#/api/mes/wm/returnissue';
|
||||
import { $t } from '#/locales';
|
||||
import { MesWmReturnIssueStatusEnum } 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<MesWmReturnIssueApi.ReturnIssue>();
|
||||
const originalSnapshot = ref(''); // 表单原始数据快照,用于提交时跳过未变更的保存请求
|
||||
const isEditable = computed(() => // 是否为编辑模式(可保存)
|
||||
['create', 'update'].includes(formType.value),
|
||||
);
|
||||
const isStock = computed(() => formType.value === 'stock'); // 是否为入库上架模式
|
||||
const isFinish = computed(() => formType.value === 'finish'); // 是否为执行退料模式
|
||||
const canSubmit = computed(() => // 是否可提交
|
||||
formType.value === 'update' &&
|
||||
formData.value?.status === MesWmReturnIssueStatusEnum.PREPARE,
|
||||
);
|
||||
// TODO @AI:这种标题风格,需要调整对齐
|
||||
const getTitle = computed(() => {
|
||||
switch (formType.value) {
|
||||
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 MesWmReturnIssueApi.ReturnIssue;
|
||||
await updateReturnIssue({ ...formData.value, ...data });
|
||||
originalSnapshot.value = current;
|
||||
}
|
||||
await submitReturnIssue(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 stockReturnIssue(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 finishReturnIssue(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 MesWmReturnIssueApi.ReturnIssue;
|
||||
try {
|
||||
if (formData.value?.id) {
|
||||
await updateReturnIssue({ ...formData.value, ...data });
|
||||
formData.value = { ...formData.value, ...data };
|
||||
} else {
|
||||
const id = await createReturnIssue(data);
|
||||
formData.value = {
|
||||
...data,
|
||||
id,
|
||||
status: MesWmReturnIssueStatusEnum.PREPARE,
|
||||
};
|
||||
await formApi.setFieldValue('id', id);
|
||||
await formApi.setFieldValue('status', formData.value.status);
|
||||
formType.value = 'update';
|
||||
}
|
||||
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) });
|
||||
formApi.setDisabled(!isEditable.value);
|
||||
modalApi.setState({ showConfirmButton: isEditable.value });
|
||||
if (data?.id) {
|
||||
modalApi.lock();
|
||||
try {
|
||||
formData.value = await getReturnIssue(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" :issue-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>
|
||||
<Button v-if="isStock" type="primary" @click="handleStock">
|
||||
入库上架
|
||||
</Button>
|
||||
<Popconfirm
|
||||
v-if="isFinish"
|
||||
title="确认完成该退料单并执行入库吗?"
|
||||
@confirm="handleFinish"
|
||||
>
|
||||
<Button type="primary">执行退料</Button>
|
||||
</Popconfirm>
|
||||
</div>
|
||||
</template>
|
||||
</Modal>
|
||||
</template>
|
||||
|
|
@ -0,0 +1,95 @@
|
|||
<script lang="ts" setup>
|
||||
import type { MesWmReturnIssueLineApi } from '#/api/mes/wm/returnissue/line';
|
||||
|
||||
import { computed, ref } from 'vue';
|
||||
|
||||
import { useVbenModal } from '@vben/common-ui';
|
||||
|
||||
import { message } from 'ant-design-vue';
|
||||
|
||||
import { useVbenForm } from '#/adapter/form';
|
||||
import {
|
||||
createReturnIssueLine,
|
||||
getReturnIssueLine,
|
||||
updateReturnIssueLine,
|
||||
} from '#/api/mes/wm/returnissue/line';
|
||||
import { $t } from '#/locales';
|
||||
|
||||
import { useLineFormSchema } from '../data';
|
||||
|
||||
const emit = defineEmits(['success']);
|
||||
const formData = ref<MesWmReturnIssueLineApi.ReturnIssueLine>();
|
||||
const issueId = 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 MesWmReturnIssueLineApi.ReturnIssueLine;
|
||||
data.issueId = issueId.value;
|
||||
try {
|
||||
await (formData.value?.id
|
||||
? updateReturnIssueLine({ ...data, id: formData.value.id })
|
||||
: createReturnIssueLine(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; issueId: number }>();
|
||||
issueId.value = data.issueId;
|
||||
if (!data.id) {
|
||||
return;
|
||||
}
|
||||
modalApi.lock();
|
||||
try {
|
||||
formData.value = await getReturnIssueLine(data.id);
|
||||
// 设置到 values
|
||||
await formApi.setValues(formData.value);
|
||||
} finally {
|
||||
modalApi.unlock();
|
||||
}
|
||||
},
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Modal :title="getTitle" class="w-3/5">
|
||||
<Form class="mx-4" />
|
||||
</Modal>
|
||||
</template>
|
||||
|
|
@ -0,0 +1,247 @@
|
|||
<script lang="ts" setup>
|
||||
import type { VxeTableGridOptions } from '#/adapter/vxe-table';
|
||||
import type { MesWmReturnIssueDetailApi } from '#/api/mes/wm/returnissue/detail';
|
||||
import type { MesWmReturnIssueLineApi } from '#/api/mes/wm/returnissue/line';
|
||||
|
||||
import { computed, reactive, ref } from 'vue';
|
||||
|
||||
import { useVbenModal } from '@vben/common-ui';
|
||||
|
||||
import { message } from 'ant-design-vue';
|
||||
|
||||
import { ACTION_ICON, TableAction, useVbenVxeGrid } from '#/adapter/vxe-table';
|
||||
import { getReturnIssueDetailListByLineId } from '#/api/mes/wm/returnissue/detail';
|
||||
import {
|
||||
deleteReturnIssueLine,
|
||||
getReturnIssueLinePage,
|
||||
} from '#/api/mes/wm/returnissue/line';
|
||||
import { $t } from '#/locales';
|
||||
import { BarcodeBizTypeEnum } from '#/views/mes/utils/constants';
|
||||
import { BarcodeDetail, 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;
|
||||
issueId: number;
|
||||
}>();
|
||||
|
||||
const isEditable = computed(() => // 是否可编辑明细行
|
||||
['create', 'update'].includes(props.formType),
|
||||
);
|
||||
const isStock = computed(() => props.formType === 'stock'); // 是否为入库上架模式
|
||||
const detailMap = reactive<
|
||||
Record<number, MesWmReturnIssueDetailApi.ReturnIssueDetail[]>
|
||||
>({}); // 已展开行的上架明细缓存
|
||||
const barcodeDetailRef = ref(); // 条码详情弹窗实例
|
||||
|
||||
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({ issueId: props.issueId }).open();
|
||||
}
|
||||
|
||||
/** 编辑物料 */
|
||||
function handleEdit(row: MesWmReturnIssueLineApi.ReturnIssueLine) {
|
||||
lineFormModalApi.setData({ id: row.id, issueId: props.issueId }).open();
|
||||
}
|
||||
|
||||
/** 删除物料 */
|
||||
async function handleDelete(row: MesWmReturnIssueLineApi.ReturnIssueLine) {
|
||||
const hideLoading = message.loading({
|
||||
content: $t('ui.actionMessage.deleting', [row.itemName]),
|
||||
duration: 0,
|
||||
});
|
||||
try {
|
||||
await deleteReturnIssueLine(row.id!);
|
||||
message.success($t('ui.actionMessage.deleteSuccess', [row.itemName]));
|
||||
handleRefresh();
|
||||
} finally {
|
||||
hideLoading();
|
||||
}
|
||||
}
|
||||
|
||||
/** 上架:直接打开明细创建表单 */
|
||||
function handlePicking(row: MesWmReturnIssueLineApi.ReturnIssueLine) {
|
||||
openDetailForm(row.id!, row.itemId);
|
||||
}
|
||||
|
||||
/** 查看物料条码 */
|
||||
function handleBarcode(row: MesWmReturnIssueLineApi.ReturnIssueLine) {
|
||||
barcodeDetailRef.value?.openByBusiness(
|
||||
row.itemId,
|
||||
BarcodeBizTypeEnum.ITEM,
|
||||
row.itemCode,
|
||||
row.itemName,
|
||||
);
|
||||
}
|
||||
|
||||
/** 打开上架明细表单 */
|
||||
function openDetailForm(lineId: number, itemId?: number, detailId?: number) {
|
||||
detailFormModalApi
|
||||
.setData({ detailId, issueId: props.issueId, itemId, lineId })
|
||||
.open();
|
||||
}
|
||||
|
||||
/** 获取已展开行的上架明细 */
|
||||
function getExpandedDetails(row: MesWmReturnIssueLineApi.ReturnIssueLine) {
|
||||
return detailMap[row.id!] || [];
|
||||
}
|
||||
|
||||
/** 加载指定行的上架明细 */
|
||||
async function loadLineDetails(lineId: number) {
|
||||
detailMap[lineId] = await getReturnIssueDetailListByLineId(lineId);
|
||||
}
|
||||
|
||||
/** 展开行时懒加载上架明细 */
|
||||
async function handleExpandChange(
|
||||
row: MesWmReturnIssueLineApi.ReturnIssueLine,
|
||||
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 ({ page }) => {
|
||||
if (!props.issueId) {
|
||||
return { list: [], total: 0 };
|
||||
}
|
||||
return await getReturnIssueLinePage({
|
||||
issueId: props.issueId,
|
||||
pageNo: page.currentPage,
|
||||
pageSize: page.pageSize,
|
||||
});
|
||||
},
|
||||
},
|
||||
},
|
||||
rowConfig: {
|
||||
keyField: 'id',
|
||||
isHover: true,
|
||||
},
|
||||
toolbarConfig: {
|
||||
refresh: true,
|
||||
},
|
||||
} as VxeTableGridOptions<MesWmReturnIssueLineApi.ReturnIssueLine>,
|
||||
gridEvents: {
|
||||
toggleRowExpand: ({
|
||||
expanded,
|
||||
row,
|
||||
}: {
|
||||
expanded: boolean;
|
||||
row: MesWmReturnIssueLineApi.ReturnIssueLine;
|
||||
}) => {
|
||||
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 }">
|
||||
<div class="flex items-center justify-center">
|
||||
<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: handlePicking.bind(null, row),
|
||||
},
|
||||
{
|
||||
label: '条码',
|
||||
type: 'link',
|
||||
onClick: handleBarcode.bind(null, row),
|
||||
},
|
||||
]"
|
||||
/>
|
||||
<PrinterLabel
|
||||
v-if="isStock"
|
||||
:biz-code="row.batchCode"
|
||||
:biz-id="row.batchId"
|
||||
biz-type="BATCH"
|
||||
/>
|
||||
</div>
|
||||
</template>
|
||||
</Grid>
|
||||
<BarcodeDetail ref="barcodeDetailRef" />
|
||||
</div>
|
||||
</template>
|
||||
|
|
@ -0,0 +1,519 @@
|
|||
import type { VbenFormApi, VbenFormSchema } from '#/adapter/form';
|
||||
import type { VxeTableGridOptions } from '#/adapter/vxe-table';
|
||||
import type { MesWmReturnSalesApi } from '#/api/mes/wm/returnsales';
|
||||
import type { MesWmReturnSalesDetailApi } from '#/api/mes/wm/returnsales/detail';
|
||||
import type { MesWmReturnSalesLineApi } from '#/api/mes/wm/returnsales/line';
|
||||
|
||||
import { h, markRaw } from 'vue';
|
||||
|
||||
import { DICT_TYPE } from '@vben/constants';
|
||||
import { getDictOptions } from '@vben/hooks';
|
||||
|
||||
import { Button } from 'ant-design-vue';
|
||||
|
||||
import { z } from '#/adapter/form';
|
||||
import { generateAutoCode } from '#/api/mes/md/autocode/record';
|
||||
import MdClientSelect from '#/views/mes/md/client/components/md-client-select.vue';
|
||||
import MdItemSelect from '#/views/mes/md/item/components/md-item-select.vue';
|
||||
import { MesAutoCodeRuleCode } from '#/views/mes/utils/constants';
|
||||
import { WmBatchSelect } from '#/views/mes/wm/batch/components';
|
||||
import {
|
||||
WmWarehouseAreaSelect,
|
||||
WmWarehouseLocationSelect,
|
||||
WmWarehouseSelect,
|
||||
} from '#/views/mes/wm/warehouse/components';
|
||||
|
||||
/** 表单类型 */
|
||||
export type FormType = 'create' | 'detail' | 'finish' | 'stock' | 'update';
|
||||
|
||||
/** 表单头部是否只读(上架、详情、执行退货态) */
|
||||
function isHeaderReadonly(formType: FormType): boolean {
|
||||
return (
|
||||
formType === 'detail' || formType === 'finish' || formType === 'stock'
|
||||
);
|
||||
}
|
||||
|
||||
/** 新增/修改的表单 */
|
||||
export function useFormSchema(
|
||||
formType: FormType,
|
||||
formApi?: VbenFormApi,
|
||||
): VbenFormSchema[] {
|
||||
return [
|
||||
{
|
||||
fieldName: 'id',
|
||||
component: 'Input',
|
||||
dependencies: {
|
||||
triggerFields: [''],
|
||||
show: () => false,
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldName: 'status',
|
||||
component: 'Input',
|
||||
dependencies: {
|
||||
triggerFields: [''],
|
||||
show: () => false,
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldName: 'code',
|
||||
label: '退货单编号',
|
||||
component: 'Input',
|
||||
componentProps: {
|
||||
placeholder: '请输入退货单编号',
|
||||
},
|
||||
rules: 'required',
|
||||
suffix: isHeaderReadonly(formType)
|
||||
? undefined
|
||||
: () =>
|
||||
h(
|
||||
Button,
|
||||
{
|
||||
type: 'default',
|
||||
onClick: async () => {
|
||||
const code = await generateAutoCode(
|
||||
MesAutoCodeRuleCode.WM_RETURN_SALES_CODE,
|
||||
);
|
||||
await formApi?.setFieldValue('code', code);
|
||||
},
|
||||
},
|
||||
{ default: () => '生成' },
|
||||
),
|
||||
},
|
||||
{
|
||||
fieldName: 'name',
|
||||
label: '退货单名称',
|
||||
component: 'Input',
|
||||
componentProps: {
|
||||
placeholder: '请输入退货单名称',
|
||||
},
|
||||
rules: 'required',
|
||||
},
|
||||
{
|
||||
fieldName: 'salesOrderCode',
|
||||
label: '销售订单号',
|
||||
component: 'Input',
|
||||
componentProps: {
|
||||
placeholder: '请输入销售订单号',
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldName: 'clientId',
|
||||
label: '客户',
|
||||
component: markRaw(MdClientSelect),
|
||||
componentProps: {
|
||||
placeholder: '请选择客户',
|
||||
},
|
||||
rules: 'selectRequired',
|
||||
},
|
||||
{
|
||||
fieldName: 'returnDate',
|
||||
label: '退货日期',
|
||||
component: 'DatePicker',
|
||||
componentProps: {
|
||||
class: '!w-full',
|
||||
format: 'YYYY-MM-DD',
|
||||
placeholder: '请选择退货日期',
|
||||
valueFormat: 'x',
|
||||
},
|
||||
rules: 'required',
|
||||
},
|
||||
{
|
||||
fieldName: 'returnReason',
|
||||
label: '退货原因',
|
||||
component: 'Textarea',
|
||||
formItemClass: 'col-span-3',
|
||||
componentProps: {
|
||||
placeholder: '请输入退货原因',
|
||||
rows: 2,
|
||||
},
|
||||
rules: 'required',
|
||||
},
|
||||
{
|
||||
fieldName: 'remark',
|
||||
label: '备注',
|
||||
component: 'Textarea',
|
||||
formItemClass: 'col-span-3',
|
||||
componentProps: {
|
||||
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: 'salesOrderCode',
|
||||
label: '销售订单号',
|
||||
component: 'Input',
|
||||
componentProps: {
|
||||
allowClear: true,
|
||||
placeholder: '请输入销售订单号',
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldName: 'clientId',
|
||||
label: '客户',
|
||||
component: markRaw(MdClientSelect),
|
||||
componentProps: {
|
||||
placeholder: '请选择客户',
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldName: 'status',
|
||||
label: '单据状态',
|
||||
component: 'Select',
|
||||
componentProps: {
|
||||
allowClear: true,
|
||||
options: getDictOptions(DICT_TYPE.MES_WM_RETURN_SALES_STATUS, 'number'),
|
||||
placeholder: '请选择单据状态',
|
||||
},
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
/** 列表的字段 */
|
||||
export function useGridColumns(): VxeTableGridOptions<MesWmReturnSalesApi.ReturnSales>['columns'] {
|
||||
return [
|
||||
{
|
||||
field: 'code',
|
||||
title: '退货单编号',
|
||||
minWidth: 160,
|
||||
slots: { default: 'code' },
|
||||
},
|
||||
{
|
||||
field: 'name',
|
||||
title: '退货单名称',
|
||||
minWidth: 150,
|
||||
},
|
||||
{
|
||||
field: 'salesOrderCode',
|
||||
title: '销售订单号',
|
||||
minWidth: 140,
|
||||
},
|
||||
{
|
||||
field: 'clientCode',
|
||||
title: '客户编码',
|
||||
minWidth: 120,
|
||||
},
|
||||
{
|
||||
field: 'clientName',
|
||||
title: '客户名称',
|
||||
minWidth: 150,
|
||||
},
|
||||
{
|
||||
field: 'returnReason',
|
||||
title: '退货原因',
|
||||
minWidth: 150,
|
||||
},
|
||||
{
|
||||
field: 'returnDate',
|
||||
title: '退货日期',
|
||||
width: 180,
|
||||
formatter: 'formatDate',
|
||||
},
|
||||
{
|
||||
field: 'status',
|
||||
title: '单据状态',
|
||||
minWidth: 110,
|
||||
cellRender: {
|
||||
name: 'CellDict',
|
||||
props: { type: DICT_TYPE.MES_WM_RETURN_SALES_STATUS },
|
||||
},
|
||||
},
|
||||
{
|
||||
title: '操作',
|
||||
width: 240,
|
||||
fixed: 'right',
|
||||
slots: { default: 'actions' },
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
/** 退货单行子表的字段 */
|
||||
export function useLineGridColumns(
|
||||
editable: boolean,
|
||||
stockable: boolean,
|
||||
): VxeTableGridOptions<MesWmReturnSalesLineApi.ReturnSalesLine>['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: 'rqcCheckFlag',
|
||||
title: '是否需要质检',
|
||||
width: 120,
|
||||
cellRender: {
|
||||
name: 'CellDict',
|
||||
props: { type: DICT_TYPE.INFRA_BOOLEAN_STRING },
|
||||
},
|
||||
},
|
||||
{
|
||||
field: 'qualityStatus',
|
||||
title: '质量状态',
|
||||
width: 100,
|
||||
cellRender: {
|
||||
name: 'CellDict',
|
||||
props: { type: DICT_TYPE.MES_WM_QUALITY_STATUS },
|
||||
},
|
||||
},
|
||||
...(editable || stockable
|
||||
? [
|
||||
{
|
||||
title: '操作',
|
||||
width: 160,
|
||||
fixed: 'right',
|
||||
slots: { default: 'actions' },
|
||||
} as const,
|
||||
]
|
||||
: []),
|
||||
];
|
||||
}
|
||||
|
||||
/** 退货单行新增/修改的表单 */
|
||||
export function useLineFormSchema(
|
||||
clientId?: number,
|
||||
salesOrderCode?: string,
|
||||
): VbenFormSchema[] {
|
||||
return [
|
||||
{
|
||||
fieldName: 'itemId',
|
||||
label: '物料',
|
||||
component: markRaw(MdItemSelect),
|
||||
componentProps: {
|
||||
placeholder: '请选择物料',
|
||||
},
|
||||
rules: 'selectRequired',
|
||||
},
|
||||
{
|
||||
fieldName: 'quantity',
|
||||
label: '退货数量',
|
||||
component: 'InputNumber',
|
||||
componentProps: {
|
||||
class: '!w-full',
|
||||
min: 0,
|
||||
placeholder: '请输入退货数量',
|
||||
precision: 2,
|
||||
},
|
||||
rules: 'required',
|
||||
},
|
||||
{
|
||||
fieldName: 'batchId',
|
||||
label: '批次',
|
||||
component: markRaw(WmBatchSelect),
|
||||
componentProps: {
|
||||
clientId,
|
||||
placeholder: '请选择批次',
|
||||
salesOrderCode,
|
||||
},
|
||||
dependencies: {
|
||||
triggerFields: ['itemId'],
|
||||
componentProps: (values) => ({
|
||||
clientId,
|
||||
itemId: values.itemId,
|
||||
placeholder: '请选择批次',
|
||||
salesOrderCode,
|
||||
}),
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldName: 'rqcCheckFlag',
|
||||
label: '需要质检',
|
||||
component: 'Switch',
|
||||
rules: z.boolean().default(true),
|
||||
},
|
||||
{
|
||||
fieldName: 'remark',
|
||||
label: '备注',
|
||||
component: 'Textarea',
|
||||
formItemClass: 'col-span-3',
|
||||
componentProps: {
|
||||
placeholder: '请输入备注',
|
||||
rows: 3,
|
||||
},
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
/** 上架明细子表的字段 */
|
||||
export function useDetailGridColumns(
|
||||
stockable: boolean,
|
||||
): VxeTableGridOptions<MesWmReturnSalesDetailApi.ReturnSalesDetail>['columns'] {
|
||||
return [
|
||||
{
|
||||
field: 'batchCode',
|
||||
title: '批次号',
|
||||
minWidth: 120,
|
||||
},
|
||||
{
|
||||
field: 'warehouseName',
|
||||
title: '仓库名称',
|
||||
minWidth: 100,
|
||||
},
|
||||
{
|
||||
field: 'locationName',
|
||||
title: '库区名称',
|
||||
minWidth: 100,
|
||||
},
|
||||
{
|
||||
field: 'areaName',
|
||||
title: '库位名称',
|
||||
minWidth: 100,
|
||||
},
|
||||
{
|
||||
field: 'quantity',
|
||||
title: '数量',
|
||||
width: 100,
|
||||
},
|
||||
...(stockable
|
||||
? [
|
||||
{
|
||||
title: '操作',
|
||||
width: 120,
|
||||
fixed: 'right',
|
||||
slots: { default: 'actions' },
|
||||
} as const,
|
||||
]
|
||||
: []),
|
||||
];
|
||||
}
|
||||
|
||||
/** 上架明细新增/修改的表单 */
|
||||
export function useDetailFormSchema(formApi?: VbenFormApi): VbenFormSchema[] {
|
||||
return [
|
||||
{
|
||||
fieldName: 'itemId',
|
||||
label: '物料',
|
||||
component: markRaw(MdItemSelect),
|
||||
componentProps: {
|
||||
disabled: true,
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldName: 'warehouseId',
|
||||
label: '入库仓库',
|
||||
component: markRaw(WmWarehouseSelect),
|
||||
componentProps: {
|
||||
// 切换仓库后清空库区和库位
|
||||
onChange: async () => {
|
||||
await formApi?.setValues({
|
||||
areaId: undefined,
|
||||
locationId: undefined,
|
||||
});
|
||||
},
|
||||
placeholder: '请选择仓库',
|
||||
},
|
||||
rules: 'selectRequired',
|
||||
},
|
||||
{
|
||||
fieldName: 'locationId',
|
||||
label: '库区',
|
||||
component: markRaw(WmWarehouseLocationSelect),
|
||||
componentProps: {
|
||||
placeholder: '请选择库区',
|
||||
},
|
||||
rules: 'selectRequired',
|
||||
dependencies: {
|
||||
triggerFields: ['warehouseId'],
|
||||
componentProps: (values) => ({
|
||||
// 切换库区后清空库位
|
||||
onChange: async () => {
|
||||
await formApi?.setFieldValue('areaId', undefined);
|
||||
},
|
||||
placeholder: '请选择库区',
|
||||
warehouseId: values.warehouseId,
|
||||
}),
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldName: 'areaId',
|
||||
label: '库位',
|
||||
component: markRaw(WmWarehouseAreaSelect),
|
||||
componentProps: {
|
||||
placeholder: '请选择库位',
|
||||
},
|
||||
rules: 'selectRequired',
|
||||
dependencies: {
|
||||
triggerFields: ['locationId'],
|
||||
componentProps: (values) => ({
|
||||
locationId: values.locationId,
|
||||
placeholder: '请选择库位',
|
||||
}),
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldName: 'batchCode',
|
||||
label: '批次号',
|
||||
component: 'Input',
|
||||
componentProps: {
|
||||
placeholder: '请输入批次号',
|
||||
},
|
||||
rules: 'required',
|
||||
},
|
||||
{
|
||||
fieldName: 'quantity',
|
||||
label: '数量',
|
||||
component: 'InputNumber',
|
||||
componentProps: {
|
||||
class: '!w-full',
|
||||
min: 0,
|
||||
placeholder: '请输入数量',
|
||||
precision: 2,
|
||||
},
|
||||
rules: 'required',
|
||||
},
|
||||
];
|
||||
}
|
||||
|
|
@ -0,0 +1,221 @@
|
|||
<script lang="ts" setup>
|
||||
import type { VxeTableGridOptions } from '#/adapter/vxe-table';
|
||||
import type { MesWmReturnSalesApi } from '#/api/mes/wm/returnsales';
|
||||
|
||||
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 {
|
||||
cancelReturnSales,
|
||||
deleteReturnSales,
|
||||
exportReturnSales,
|
||||
getReturnSalesPage,
|
||||
} from '#/api/mes/wm/returnsales';
|
||||
import { $t } from '#/locales';
|
||||
import { MesWmReturnSalesStatusEnum } 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: MesWmReturnSalesApi.ReturnSales) {
|
||||
formModalApi.setData({ formType: 'detail', id: row.id }).open();
|
||||
}
|
||||
|
||||
/** 编辑销售退货单 */
|
||||
function handleEdit(row: MesWmReturnSalesApi.ReturnSales) {
|
||||
formModalApi.setData({ formType: 'update', id: row.id }).open();
|
||||
}
|
||||
|
||||
/** 执行上架 */
|
||||
function handleStock(row: MesWmReturnSalesApi.ReturnSales) {
|
||||
formModalApi.setData({ formType: 'stock', id: row.id }).open();
|
||||
}
|
||||
|
||||
/** 执行退货 */
|
||||
function handleFinish(row: MesWmReturnSalesApi.ReturnSales) {
|
||||
formModalApi.setData({ formType: 'finish', id: row.id }).open();
|
||||
}
|
||||
|
||||
/** 提示前往质检模块 */
|
||||
function handleQc() {
|
||||
message.info('请前往【质量管理 - 退货检验(RQC)】中进行退货检验操作');
|
||||
}
|
||||
|
||||
/** 删除销售退货单 */
|
||||
async function handleDelete(row: MesWmReturnSalesApi.ReturnSales) {
|
||||
const hideLoading = message.loading({
|
||||
content: $t('ui.actionMessage.deleting', [row.code]),
|
||||
duration: 0,
|
||||
});
|
||||
try {
|
||||
await deleteReturnSales(row.id!);
|
||||
message.success($t('ui.actionMessage.deleteSuccess', [row.code]));
|
||||
handleRefresh();
|
||||
} finally {
|
||||
hideLoading();
|
||||
}
|
||||
}
|
||||
|
||||
/** 取消销售退货单 */
|
||||
async function handleCancel(row: MesWmReturnSalesApi.ReturnSales) {
|
||||
await cancelReturnSales(row.id!);
|
||||
message.success('取消成功');
|
||||
handleRefresh();
|
||||
}
|
||||
|
||||
/** 导出表格 */
|
||||
async function handleExport() {
|
||||
const data = await exportReturnSales(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 getReturnSalesPage({
|
||||
pageNo: page.currentPage,
|
||||
pageSize: page.pageSize,
|
||||
...formValues,
|
||||
});
|
||||
},
|
||||
},
|
||||
},
|
||||
rowConfig: {
|
||||
keyField: 'id',
|
||||
isHover: true,
|
||||
},
|
||||
toolbarConfig: {
|
||||
refresh: true,
|
||||
search: true,
|
||||
},
|
||||
} as VxeTableGridOptions<MesWmReturnSalesApi.ReturnSales>,
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Page auto-content-height>
|
||||
<template #doc>
|
||||
<DocAlert
|
||||
title="【仓库】发货通知、销售出库、销售退货"
|
||||
url="https://doc.iocoder.cn/mes/wm/sales-out/"
|
||||
/>
|
||||
</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-return-sales:create'],
|
||||
onClick: handleCreate,
|
||||
},
|
||||
{
|
||||
label: $t('ui.actionTitle.export'),
|
||||
type: 'primary',
|
||||
icon: ACTION_ICON.DOWNLOAD,
|
||||
auth: ['mes:wm-return-sales: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-return-sales:update'],
|
||||
ifShow: row.status === MesWmReturnSalesStatusEnum.PREPARE,
|
||||
onClick: handleEdit.bind(null, row),
|
||||
},
|
||||
{
|
||||
label: $t('common.delete'),
|
||||
type: 'link',
|
||||
danger: true,
|
||||
icon: ACTION_ICON.DELETE,
|
||||
auth: ['mes:wm-return-sales:delete'],
|
||||
ifShow: row.status === MesWmReturnSalesStatusEnum.PREPARE,
|
||||
popConfirm: {
|
||||
title: $t('ui.actionMessage.deleteConfirm', [row.code]),
|
||||
confirm: handleDelete.bind(null, row),
|
||||
},
|
||||
},
|
||||
{
|
||||
label: '执行质检',
|
||||
type: 'link',
|
||||
ifShow: row.status === MesWmReturnSalesStatusEnum.CONFIRMED,
|
||||
onClick: handleQc,
|
||||
},
|
||||
{
|
||||
label: '执行退货',
|
||||
type: 'link',
|
||||
auth: ['mes:wm-return-sales:finish'],
|
||||
ifShow: row.status === MesWmReturnSalesStatusEnum.APPROVING,
|
||||
onClick: handleFinish.bind(null, row),
|
||||
},
|
||||
{
|
||||
label: '执行上架',
|
||||
type: 'link',
|
||||
auth: ['mes:wm-return-sales:stock'],
|
||||
ifShow: row.status === MesWmReturnSalesStatusEnum.APPROVED,
|
||||
onClick: handleStock.bind(null, row),
|
||||
},
|
||||
{
|
||||
label: '取消',
|
||||
type: 'link',
|
||||
danger: true,
|
||||
auth: ['mes:wm-return-sales:cancel'],
|
||||
ifShow:
|
||||
row.status === MesWmReturnSalesStatusEnum.CONFIRMED ||
|
||||
row.status === MesWmReturnSalesStatusEnum.APPROVING ||
|
||||
row.status === MesWmReturnSalesStatusEnum.APPROVED,
|
||||
popConfirm: {
|
||||
title: '确认取消该销售退货单?取消后不可恢复。',
|
||||
confirm: handleCancel.bind(null, row),
|
||||
},
|
||||
},
|
||||
]"
|
||||
/>
|
||||
</template>
|
||||
</Grid>
|
||||
</Page>
|
||||
</template>
|
||||
|
|
@ -0,0 +1,104 @@
|
|||
<script lang="ts" setup>
|
||||
import type { MesWmReturnSalesDetailApi } from '#/api/mes/wm/returnsales/detail';
|
||||
|
||||
import { computed, ref } from 'vue';
|
||||
|
||||
import { useVbenModal } from '@vben/common-ui';
|
||||
|
||||
import { message } from 'ant-design-vue';
|
||||
|
||||
import { useVbenForm } from '#/adapter/form';
|
||||
import {
|
||||
createReturnSalesDetail,
|
||||
getReturnSalesDetail,
|
||||
updateReturnSalesDetail,
|
||||
} from '#/api/mes/wm/returnsales/detail';
|
||||
import { $t } from '#/locales';
|
||||
|
||||
import { useDetailFormSchema } from '../data';
|
||||
|
||||
const emit = defineEmits<{ success: [lineId: number] }>();
|
||||
const formData = ref<MesWmReturnSalesDetailApi.ReturnSalesDetail>();
|
||||
const returnId = 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-1',
|
||||
labelWidth: 90,
|
||||
},
|
||||
layout: 'horizontal',
|
||||
schema: useDetailFormSchema(),
|
||||
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 MesWmReturnSalesDetailApi.ReturnSalesDetail;
|
||||
data.returnId = returnId.value;
|
||||
data.lineId = lineId.value;
|
||||
try {
|
||||
await (formData.value?.id
|
||||
? updateReturnSalesDetail({ ...data, id: formData.value.id })
|
||||
: createReturnSalesDetail(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;
|
||||
}
|
||||
formApi.setState({ schema: useDetailFormSchema(formApi) });
|
||||
// 加载数据
|
||||
const data = modalApi.getData<{
|
||||
detailId?: number;
|
||||
itemId?: number;
|
||||
lineId: number;
|
||||
returnId: number;
|
||||
}>();
|
||||
returnId.value = data.returnId;
|
||||
lineId.value = data.lineId;
|
||||
if (data.detailId) {
|
||||
modalApi.lock();
|
||||
try {
|
||||
formData.value = await getReturnSalesDetail(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-3/5">
|
||||
<Form class="mx-4" />
|
||||
</Modal>
|
||||
</template>
|
||||
|
|
@ -0,0 +1,103 @@
|
|||
<script lang="ts" setup>
|
||||
import type { VxeTableGridOptions } from '#/adapter/vxe-table';
|
||||
import type { MesWmReturnSalesDetailApi } from '#/api/mes/wm/returnsales/detail';
|
||||
|
||||
import { computed, watch } from 'vue';
|
||||
|
||||
import { message } from 'ant-design-vue';
|
||||
|
||||
import { ACTION_ICON, TableAction, useVbenVxeGrid } from '#/adapter/vxe-table';
|
||||
import { deleteReturnSalesDetail } from '#/api/mes/wm/returnsales/detail';
|
||||
import { $t } from '#/locales';
|
||||
|
||||
import { type FormType, useDetailGridColumns } from '../data';
|
||||
|
||||
const props = defineProps<{
|
||||
details: MesWmReturnSalesDetailApi.ReturnSalesDetail[];
|
||||
formType: FormType;
|
||||
}>();
|
||||
|
||||
const emit = defineEmits<{
|
||||
edit: [detailId: number];
|
||||
refresh: [];
|
||||
}>();
|
||||
|
||||
const isStock = computed(() => props.formType === 'stock'); // 是否为上架模式
|
||||
|
||||
/** 编辑上架明细 */
|
||||
function handleEdit(row: MesWmReturnSalesDetailApi.ReturnSalesDetail) {
|
||||
emit('edit', row.id!);
|
||||
}
|
||||
|
||||
/** 删除上架明细 */
|
||||
async function handleDelete(
|
||||
row: MesWmReturnSalesDetailApi.ReturnSalesDetail,
|
||||
) {
|
||||
const hideLoading = message.loading({
|
||||
content: $t('ui.actionMessage.deleting', [row.warehouseName]),
|
||||
duration: 0,
|
||||
});
|
||||
try {
|
||||
await deleteReturnSalesDetail(row.id!);
|
||||
message.success($t('ui.actionMessage.deleteSuccess', [row.warehouseName]));
|
||||
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<MesWmReturnSalesDetailApi.ReturnSalesDetail>,
|
||||
});
|
||||
|
||||
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.warehouseName,
|
||||
]),
|
||||
confirm: handleDelete.bind(null, row),
|
||||
},
|
||||
},
|
||||
]"
|
||||
/>
|
||||
</template>
|
||||
</Grid>
|
||||
</div>
|
||||
</template>
|
||||
|
|
@ -0,0 +1,233 @@
|
|||
<script lang="ts" setup>
|
||||
import type { FormType } from '../data';
|
||||
|
||||
import type { MesWmReturnSalesApi } from '#/api/mes/wm/returnsales';
|
||||
|
||||
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 {
|
||||
createReturnSales,
|
||||
finishReturnSales,
|
||||
getReturnSales,
|
||||
stockReturnSales,
|
||||
submitReturnSales,
|
||||
updateReturnSales,
|
||||
} from '#/api/mes/wm/returnsales';
|
||||
import { $t } from '#/locales';
|
||||
import { MesWmReturnSalesStatusEnum } 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<MesWmReturnSalesApi.ReturnSales>();
|
||||
const originalSnapshot = ref(''); // 表单原始数据快照,用于提交时跳过未变更的保存请求
|
||||
const isEditable = computed(() => // 是否为编辑模式(可保存)
|
||||
['create', 'update'].includes(formType.value),
|
||||
);
|
||||
const isStock = computed(() => formType.value === 'stock'); // 是否为上架模式
|
||||
const isFinish = computed(() => formType.value === 'finish'); // 是否为执行退货模式
|
||||
const canSubmit = computed(() => // 是否可提交
|
||||
formType.value === 'update' &&
|
||||
formData.value?.status === MesWmReturnSalesStatusEnum.PREPARE,
|
||||
);
|
||||
const getTitle = computed(() => {
|
||||
switch (formType.value) {
|
||||
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 MesWmReturnSalesApi.ReturnSales;
|
||||
await updateReturnSales({ ...formData.value, ...data });
|
||||
originalSnapshot.value = current;
|
||||
}
|
||||
await submitReturnSales(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 stockReturnSales(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 finishReturnSales(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 MesWmReturnSalesApi.ReturnSales;
|
||||
try {
|
||||
if (formData.value?.id) {
|
||||
await updateReturnSales({ ...formData.value, ...data });
|
||||
formData.value = { ...formData.value, ...data };
|
||||
} else {
|
||||
const id = await createReturnSales(data);
|
||||
formData.value = {
|
||||
...data,
|
||||
id,
|
||||
status: MesWmReturnSalesStatusEnum.PREPARE,
|
||||
};
|
||||
await formApi.setFieldValue('id', id);
|
||||
await formApi.setFieldValue('status', formData.value.status);
|
||||
formType.value = 'update';
|
||||
}
|
||||
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) });
|
||||
formApi.setDisabled(!isEditable.value);
|
||||
modalApi.setState({ showConfirmButton: isEditable.value });
|
||||
if (data?.id) {
|
||||
modalApi.lock();
|
||||
try {
|
||||
formData.value = await getReturnSales(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
|
||||
:client-id="formData.clientId"
|
||||
:form-type="formType"
|
||||
:return-id="formData.id"
|
||||
:sales-order-code="formData.salesOrderCode"
|
||||
/>
|
||||
</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="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 { MesWmReturnSalesLineApi } from '#/api/mes/wm/returnsales/line';
|
||||
|
||||
import { computed, ref } from 'vue';
|
||||
|
||||
import { useVbenModal } from '@vben/common-ui';
|
||||
|
||||
import { message } from 'ant-design-vue';
|
||||
|
||||
import { useVbenForm } from '#/adapter/form';
|
||||
import {
|
||||
createReturnSalesLine,
|
||||
getReturnSalesLine,
|
||||
updateReturnSalesLine,
|
||||
} from '#/api/mes/wm/returnsales/line';
|
||||
import { $t } from '#/locales';
|
||||
|
||||
import { useLineFormSchema } from '../data';
|
||||
|
||||
const emit = defineEmits(['success']);
|
||||
const formData = ref<MesWmReturnSalesLineApi.ReturnSalesLine>();
|
||||
const returnId = 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 MesWmReturnSalesLineApi.ReturnSalesLine;
|
||||
data.returnId = returnId.value;
|
||||
try {
|
||||
await (formData.value?.id
|
||||
? updateReturnSalesLine({ ...data, id: formData.value.id })
|
||||
: createReturnSalesLine(data));
|
||||
// 关闭并提示
|
||||
await modalApi.close();
|
||||
emit('success');
|
||||
message.success($t('ui.actionMessage.operationSuccess'));
|
||||
} finally {
|
||||
modalApi.unlock();
|
||||
}
|
||||
},
|
||||
async onOpenChange(isOpen: boolean) {
|
||||
if (!isOpen) {
|
||||
formData.value = undefined;
|
||||
return;
|
||||
}
|
||||
// 加载数据
|
||||
const data = modalApi.getData<{
|
||||
clientId?: number;
|
||||
id?: number;
|
||||
returnId: number;
|
||||
salesOrderCode?: string;
|
||||
}>();
|
||||
returnId.value = data.returnId;
|
||||
formApi.setState({
|
||||
schema: useLineFormSchema(data.clientId, data.salesOrderCode),
|
||||
});
|
||||
if (!data.id) {
|
||||
return;
|
||||
}
|
||||
modalApi.lock();
|
||||
try {
|
||||
formData.value = await getReturnSalesLine(data.id);
|
||||
// 设置到 values
|
||||
await formApi.setValues(formData.value);
|
||||
} finally {
|
||||
modalApi.unlock();
|
||||
}
|
||||
},
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Modal :title="getTitle" class="w-3/5">
|
||||
<Form class="mx-4" />
|
||||
</Modal>
|
||||
</template>
|
||||
|
|
@ -0,0 +1,244 @@
|
|||
<script lang="ts" setup>
|
||||
import type { VxeTableGridOptions } from '#/adapter/vxe-table';
|
||||
import type { MesWmReturnSalesDetailApi } from '#/api/mes/wm/returnsales/detail';
|
||||
import type { MesWmReturnSalesLineApi } from '#/api/mes/wm/returnsales/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 { getReturnSalesDetailListByLineId } from '#/api/mes/wm/returnsales/detail';
|
||||
import {
|
||||
deleteReturnSalesLine,
|
||||
getReturnSalesLinePage,
|
||||
} from '#/api/mes/wm/returnsales/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<{
|
||||
clientId?: number;
|
||||
formType: FormType;
|
||||
returnId: number;
|
||||
salesOrderCode?: string;
|
||||
}>();
|
||||
|
||||
const isEditable = computed(() => // 是否可编辑明细行
|
||||
['create', 'update'].includes(props.formType),
|
||||
);
|
||||
const isStock = computed(() => props.formType === 'stock'); // 是否为上架模式
|
||||
const detailMap = reactive<
|
||||
Record<number, MesWmReturnSalesDetailApi.ReturnSalesDetail[]>
|
||||
>({}); // 已展开行的上架明细缓存
|
||||
|
||||
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({
|
||||
clientId: props.clientId,
|
||||
returnId: props.returnId,
|
||||
salesOrderCode: props.salesOrderCode,
|
||||
})
|
||||
.open();
|
||||
}
|
||||
|
||||
/** 编辑物料 */
|
||||
function handleEdit(row: MesWmReturnSalesLineApi.ReturnSalesLine) {
|
||||
lineFormModalApi
|
||||
.setData({
|
||||
clientId: props.clientId,
|
||||
id: row.id,
|
||||
returnId: props.returnId,
|
||||
salesOrderCode: props.salesOrderCode,
|
||||
})
|
||||
.open();
|
||||
}
|
||||
|
||||
/** 删除物料 */
|
||||
async function handleDelete(row: MesWmReturnSalesLineApi.ReturnSalesLine) {
|
||||
const hideLoading = message.loading({
|
||||
content: $t('ui.actionMessage.deleting', [row.itemName]),
|
||||
duration: 0,
|
||||
});
|
||||
try {
|
||||
await deleteReturnSalesLine(row.id!);
|
||||
message.success($t('ui.actionMessage.deleteSuccess', [row.itemName]));
|
||||
handleRefresh();
|
||||
} finally {
|
||||
hideLoading();
|
||||
}
|
||||
}
|
||||
|
||||
/** 上架:直接打开明细创建表单 */
|
||||
function handleStock(row: MesWmReturnSalesLineApi.ReturnSalesLine) {
|
||||
openDetailForm(row.id!, row.itemId);
|
||||
}
|
||||
|
||||
/** 打开上架明细表单 */
|
||||
function openDetailForm(lineId: number, itemId?: number, detailId?: number) {
|
||||
detailFormModalApi
|
||||
.setData({ detailId, itemId, lineId, returnId: props.returnId })
|
||||
.open();
|
||||
}
|
||||
|
||||
/** 获取已展开行的上架明细 */
|
||||
function getExpandedDetails(row: MesWmReturnSalesLineApi.ReturnSalesLine) {
|
||||
return detailMap[row.id!] || [];
|
||||
}
|
||||
|
||||
/** 加载指定行的上架明细 */
|
||||
async function loadLineDetails(lineId: number) {
|
||||
detailMap[lineId] = await getReturnSalesDetailListByLineId(lineId);
|
||||
}
|
||||
|
||||
/** 展开行时懒加载上架明细 */
|
||||
async function handleExpandChange(
|
||||
row: MesWmReturnSalesLineApi.ReturnSalesLine,
|
||||
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 ({ page }) => {
|
||||
if (!props.returnId) {
|
||||
return { list: [], total: 0 };
|
||||
}
|
||||
return await getReturnSalesLinePage({
|
||||
pageNo: page.currentPage,
|
||||
pageSize: page.pageSize,
|
||||
returnId: props.returnId,
|
||||
});
|
||||
},
|
||||
},
|
||||
},
|
||||
rowConfig: {
|
||||
keyField: 'id',
|
||||
isHover: true,
|
||||
},
|
||||
toolbarConfig: {
|
||||
refresh: true,
|
||||
},
|
||||
} as VxeTableGridOptions<MesWmReturnSalesLineApi.ReturnSalesLine>,
|
||||
gridEvents: {
|
||||
toggleRowExpand: ({
|
||||
expanded,
|
||||
row,
|
||||
}: {
|
||||
expanded: boolean;
|
||||
row: MesWmReturnSalesLineApi.ReturnSalesLine;
|
||||
}) => {
|
||||
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 }">
|
||||
<div class="flex items-center justify-center">
|
||||
<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"
|
||||
/>
|
||||
</div>
|
||||
</template>
|
||||
</Grid>
|
||||
</div>
|
||||
</template>
|
||||
|
|
@ -0,0 +1,533 @@
|
|||
import type { VbenFormApi, VbenFormSchema } from '#/adapter/form';
|
||||
import type { VxeTableGridOptions } from '#/adapter/vxe-table';
|
||||
import type { MesWmMaterialStockApi } from '#/api/mes/wm/materialstock';
|
||||
import type { MesWmReturnVendorApi } from '#/api/mes/wm/returnvendor';
|
||||
import type { MesWmReturnVendorDetailApi } from '#/api/mes/wm/returnvendor/detail';
|
||||
import type { MesWmReturnVendorLineApi } from '#/api/mes/wm/returnvendor/line';
|
||||
|
||||
import { h, markRaw } from 'vue';
|
||||
|
||||
import { DICT_TYPE } from '@vben/constants';
|
||||
|
||||
import { Button } from 'ant-design-vue';
|
||||
|
||||
import { generateAutoCode } from '#/api/mes/md/autocode/record';
|
||||
import MdItemSelect from '#/views/mes/md/item/components/md-item-select.vue';
|
||||
import MdVendorSelect from '#/views/mes/md/vendor/components/md-vendor-select.vue';
|
||||
import { MesAutoCodeRuleCode } from '#/views/mes/utils/constants';
|
||||
import { WmBatchSelect } from '#/views/mes/wm/batch/components';
|
||||
import { WmMaterialStockSelect } from '#/views/mes/wm/materialstock/components';
|
||||
import {
|
||||
WmWarehouseAreaSelect,
|
||||
WmWarehouseLocationSelect,
|
||||
WmWarehouseSelect,
|
||||
} from '#/views/mes/wm/warehouse/components';
|
||||
|
||||
/** 表单类型 */
|
||||
export type FormType = 'create' | 'detail' | 'finish' | 'stock' | 'update';
|
||||
|
||||
/** 表单头部是否只读(拣货、详情、完成态) */
|
||||
function isHeaderReadonly(formType: FormType): boolean {
|
||||
return (
|
||||
formType === 'detail' || formType === 'finish' || formType === 'stock'
|
||||
);
|
||||
}
|
||||
|
||||
/** 新增/修改的表单 */
|
||||
export function useFormSchema(
|
||||
formType: FormType,
|
||||
formApi?: VbenFormApi,
|
||||
): VbenFormSchema[] {
|
||||
return [
|
||||
{
|
||||
fieldName: 'id',
|
||||
component: 'Input',
|
||||
dependencies: {
|
||||
triggerFields: [''],
|
||||
show: () => false,
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldName: 'status',
|
||||
component: 'Input',
|
||||
dependencies: {
|
||||
triggerFields: [''],
|
||||
show: () => false,
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldName: 'code',
|
||||
label: '退货单编号',
|
||||
component: 'Input',
|
||||
componentProps: {
|
||||
placeholder: '请输入退货单编号',
|
||||
},
|
||||
rules: 'required',
|
||||
suffix: isHeaderReadonly(formType)
|
||||
? undefined
|
||||
: () =>
|
||||
h(
|
||||
Button,
|
||||
{
|
||||
type: 'default',
|
||||
onClick: async () => {
|
||||
const code = await generateAutoCode(
|
||||
MesAutoCodeRuleCode.WM_RETURN_VENDOR_CODE,
|
||||
);
|
||||
await formApi?.setFieldValue('code', code);
|
||||
},
|
||||
},
|
||||
{ default: () => '生成' },
|
||||
),
|
||||
},
|
||||
{
|
||||
fieldName: 'name',
|
||||
label: '退货单名称',
|
||||
component: 'Input',
|
||||
componentProps: {
|
||||
placeholder: '请输入退货单名称',
|
||||
},
|
||||
rules: 'required',
|
||||
},
|
||||
{
|
||||
fieldName: 'purchaseOrderCode',
|
||||
label: '采购订单号',
|
||||
component: 'Input',
|
||||
componentProps: {
|
||||
placeholder: '请输入采购订单号',
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldName: 'vendorId',
|
||||
label: '供应商',
|
||||
component: markRaw(MdVendorSelect),
|
||||
componentProps: {
|
||||
placeholder: '请选择供应商',
|
||||
},
|
||||
rules: 'selectRequired',
|
||||
},
|
||||
{
|
||||
fieldName: 'returnDate',
|
||||
label: '退货日期',
|
||||
component: 'DatePicker',
|
||||
componentProps: {
|
||||
class: '!w-full',
|
||||
format: 'YYYY-MM-DD HH:mm:ss',
|
||||
placeholder: '请选择退货日期',
|
||||
showTime: true,
|
||||
valueFormat: 'x',
|
||||
},
|
||||
rules: 'required',
|
||||
},
|
||||
{
|
||||
fieldName: 'returnReason',
|
||||
label: '退货原因',
|
||||
component: 'Textarea',
|
||||
formItemClass: 'col-span-3',
|
||||
componentProps: {
|
||||
placeholder: '请输入退货原因',
|
||||
rows: 2,
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldName: 'transportCode',
|
||||
label: '运单号',
|
||||
component: 'Input',
|
||||
componentProps: {
|
||||
placeholder: '请输入运单号',
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldName: 'transportTelephone',
|
||||
label: '联系电话',
|
||||
component: 'Input',
|
||||
componentProps: {
|
||||
placeholder: '请输入联系电话',
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldName: 'remark',
|
||||
label: '备注',
|
||||
component: 'Textarea',
|
||||
formItemClass: 'col-span-3',
|
||||
componentProps: {
|
||||
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: 'purchaseOrderCode',
|
||||
label: '采购订单编号',
|
||||
component: 'Input',
|
||||
componentProps: {
|
||||
allowClear: true,
|
||||
placeholder: '请输入采购订单编号',
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldName: 'vendorId',
|
||||
label: '供应商',
|
||||
component: markRaw(MdVendorSelect),
|
||||
componentProps: {
|
||||
placeholder: '请选择供应商',
|
||||
},
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
/** 列表的字段 */
|
||||
export function useGridColumns(): VxeTableGridOptions<MesWmReturnVendorApi.ReturnVendor>['columns'] {
|
||||
return [
|
||||
{
|
||||
field: 'code',
|
||||
title: '退货单编号',
|
||||
minWidth: 160,
|
||||
slots: { default: 'code' },
|
||||
},
|
||||
{
|
||||
field: 'name',
|
||||
title: '退货单名称',
|
||||
minWidth: 150,
|
||||
},
|
||||
{
|
||||
field: 'purchaseOrderCode',
|
||||
title: '采购订单号',
|
||||
minWidth: 140,
|
||||
},
|
||||
{
|
||||
field: 'vendorCode',
|
||||
title: '供应商编码',
|
||||
minWidth: 120,
|
||||
},
|
||||
{
|
||||
field: 'vendorName',
|
||||
title: '供应商名称',
|
||||
minWidth: 150,
|
||||
},
|
||||
{
|
||||
field: 'returnDate',
|
||||
title: '退货日期',
|
||||
width: 180,
|
||||
formatter: 'formatDateTime',
|
||||
},
|
||||
{
|
||||
field: 'status',
|
||||
title: '单据状态',
|
||||
minWidth: 110,
|
||||
cellRender: {
|
||||
name: 'CellDict',
|
||||
props: { type: DICT_TYPE.MES_WM_RETURN_VENDOR_STATUS },
|
||||
},
|
||||
},
|
||||
{
|
||||
title: '操作',
|
||||
width: 240,
|
||||
fixed: 'right',
|
||||
slots: { default: 'actions' },
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
/** 退货单行子表的字段 */
|
||||
export function useLineGridColumns(
|
||||
editable: boolean,
|
||||
stockable: boolean,
|
||||
): VxeTableGridOptions<MesWmReturnVendorLineApi.ReturnVendorLine>['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,
|
||||
},
|
||||
...(editable || stockable
|
||||
? [
|
||||
{
|
||||
title: '操作',
|
||||
width: 160,
|
||||
fixed: 'right',
|
||||
slots: { default: 'actions' },
|
||||
} as const,
|
||||
]
|
||||
: []),
|
||||
];
|
||||
}
|
||||
|
||||
/** 退货单行新增/修改的表单 */
|
||||
export function useLineFormSchema(
|
||||
vendorId?: number,
|
||||
formApi?: VbenFormApi,
|
||||
): VbenFormSchema[] {
|
||||
return [
|
||||
{
|
||||
fieldName: 'itemId',
|
||||
label: '产品物料',
|
||||
component: markRaw(MdItemSelect),
|
||||
componentProps: {
|
||||
placeholder: '请选择产品物料',
|
||||
},
|
||||
rules: 'selectRequired',
|
||||
},
|
||||
{
|
||||
fieldName: 'quantity',
|
||||
label: '退货数量',
|
||||
component: 'InputNumber',
|
||||
componentProps: {
|
||||
class: '!w-full',
|
||||
min: 0,
|
||||
placeholder: '请输入退货数量',
|
||||
precision: 2,
|
||||
},
|
||||
rules: 'required',
|
||||
},
|
||||
{
|
||||
fieldName: 'batchId',
|
||||
label: '批次号',
|
||||
component: markRaw(WmBatchSelect),
|
||||
componentProps: {
|
||||
// 选择批次后同步批次号
|
||||
onChange: async (batch?: { code?: string }) => {
|
||||
await formApi?.setFieldValue('batchCode', batch?.code);
|
||||
},
|
||||
vendorId,
|
||||
},
|
||||
dependencies: {
|
||||
triggerFields: ['itemId'],
|
||||
componentProps: (values) => ({
|
||||
itemId: values.itemId,
|
||||
vendorId,
|
||||
}),
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldName: 'batchCode',
|
||||
component: 'Input',
|
||||
dependencies: {
|
||||
triggerFields: [''],
|
||||
show: () => false,
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldName: 'remark',
|
||||
label: '备注',
|
||||
component: 'Textarea',
|
||||
formItemClass: 'col-span-3',
|
||||
componentProps: {
|
||||
placeholder: '请输入备注',
|
||||
rows: 3,
|
||||
},
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
/** 拣货明细子表的字段 */
|
||||
export function useDetailGridColumns(
|
||||
stockable: boolean,
|
||||
): VxeTableGridOptions<MesWmReturnVendorDetailApi.ReturnVendorDetail>['columns'] {
|
||||
return [
|
||||
{
|
||||
field: 'batchCode',
|
||||
title: '批次号',
|
||||
minWidth: 120,
|
||||
},
|
||||
{
|
||||
field: 'warehouseName',
|
||||
title: '仓库名称',
|
||||
minWidth: 100,
|
||||
},
|
||||
{
|
||||
field: 'locationName',
|
||||
title: '库区名称',
|
||||
minWidth: 100,
|
||||
},
|
||||
{
|
||||
field: 'areaName',
|
||||
title: '库位名称',
|
||||
minWidth: 100,
|
||||
},
|
||||
{
|
||||
field: 'quantity',
|
||||
title: '数量',
|
||||
width: 100,
|
||||
},
|
||||
...(stockable
|
||||
? [
|
||||
{
|
||||
title: '操作',
|
||||
width: 120,
|
||||
fixed: 'right',
|
||||
slots: { default: 'actions' },
|
||||
} as const,
|
||||
]
|
||||
: []),
|
||||
];
|
||||
}
|
||||
|
||||
/** 拣货明细新增/修改的表单 */
|
||||
export function useDetailFormSchema(formApi?: VbenFormApi): VbenFormSchema[] {
|
||||
return [
|
||||
{
|
||||
fieldName: 'quantityMax',
|
||||
component: 'Input',
|
||||
dependencies: {
|
||||
triggerFields: [''],
|
||||
show: () => false,
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldName: 'itemId',
|
||||
label: '物料',
|
||||
component: markRaw(MdItemSelect),
|
||||
componentProps: {
|
||||
disabled: true,
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldName: 'materialStockId',
|
||||
label: '库存记录',
|
||||
component: markRaw(WmMaterialStockSelect),
|
||||
componentProps: {
|
||||
// 选择库存记录后,自动回填仓库/库区/库位/批次/数量
|
||||
onChange: async (stock?: MesWmMaterialStockApi.MaterialStock) => {
|
||||
await formApi?.setValues({
|
||||
areaId: stock?.areaId,
|
||||
batchCode: stock?.batchCode,
|
||||
batchId: stock?.batchId,
|
||||
locationId: stock?.locationId,
|
||||
quantity: stock?.quantity,
|
||||
quantityMax: stock?.quantity,
|
||||
warehouseId: stock?.warehouseId,
|
||||
});
|
||||
},
|
||||
},
|
||||
rules: 'selectRequired',
|
||||
dependencies: {
|
||||
triggerFields: ['itemId'],
|
||||
componentProps: (values) => ({
|
||||
itemId: values.itemId,
|
||||
}),
|
||||
},
|
||||
},
|
||||
{
|
||||
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: 'warehouseId',
|
||||
label: '仓库',
|
||||
component: markRaw(WmWarehouseSelect),
|
||||
componentProps: {
|
||||
disabled: true,
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldName: 'locationId',
|
||||
label: '库区',
|
||||
component: markRaw(WmWarehouseLocationSelect),
|
||||
componentProps: {
|
||||
disabled: true,
|
||||
},
|
||||
dependencies: {
|
||||
triggerFields: ['warehouseId'],
|
||||
componentProps: (values) => ({
|
||||
disabled: true,
|
||||
warehouseId: values.warehouseId,
|
||||
}),
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldName: 'areaId',
|
||||
label: '库位',
|
||||
component: markRaw(WmWarehouseAreaSelect),
|
||||
componentProps: {
|
||||
disabled: true,
|
||||
},
|
||||
dependencies: {
|
||||
triggerFields: ['locationId'],
|
||||
componentProps: (values) => ({
|
||||
disabled: true,
|
||||
locationId: values.locationId,
|
||||
}),
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldName: 'batchCode',
|
||||
label: '批次号',
|
||||
component: 'Input',
|
||||
componentProps: {
|
||||
disabled: true,
|
||||
},
|
||||
},
|
||||
];
|
||||
}
|
||||
|
|
@ -0,0 +1,209 @@
|
|||
<script lang="ts" setup>
|
||||
import type { VxeTableGridOptions } from '#/adapter/vxe-table';
|
||||
import type { MesWmReturnVendorApi } from '#/api/mes/wm/returnvendor';
|
||||
|
||||
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 {
|
||||
cancelReturnVendor,
|
||||
deleteReturnVendor,
|
||||
exportReturnVendor,
|
||||
getReturnVendorPage,
|
||||
} from '#/api/mes/wm/returnvendor';
|
||||
import { $t } from '#/locales';
|
||||
import { MesWmReturnVendorStatusEnum } 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: MesWmReturnVendorApi.ReturnVendor) {
|
||||
formModalApi.setData({ formType: 'detail', id: row.id }).open();
|
||||
}
|
||||
|
||||
/** 编辑供应商退货单 */
|
||||
function handleEdit(row: MesWmReturnVendorApi.ReturnVendor) {
|
||||
formModalApi.setData({ formType: 'update', id: row.id }).open();
|
||||
}
|
||||
|
||||
/** 执行拣货 */
|
||||
function handleStock(row: MesWmReturnVendorApi.ReturnVendor) {
|
||||
formModalApi.setData({ formType: 'stock', id: row.id }).open();
|
||||
}
|
||||
|
||||
/** 完成退货 */
|
||||
function handleFinish(row: MesWmReturnVendorApi.ReturnVendor) {
|
||||
formModalApi.setData({ formType: 'finish', id: row.id }).open();
|
||||
}
|
||||
|
||||
/** 删除供应商退货单 */
|
||||
async function handleDelete(row: MesWmReturnVendorApi.ReturnVendor) {
|
||||
const hideLoading = message.loading({
|
||||
content: $t('ui.actionMessage.deleting', [row.code]),
|
||||
duration: 0,
|
||||
});
|
||||
try {
|
||||
await deleteReturnVendor(row.id!);
|
||||
message.success($t('ui.actionMessage.deleteSuccess', [row.code]));
|
||||
handleRefresh();
|
||||
} finally {
|
||||
hideLoading();
|
||||
}
|
||||
}
|
||||
|
||||
/** 取消供应商退货单 */
|
||||
async function handleCancel(row: MesWmReturnVendorApi.ReturnVendor) {
|
||||
await cancelReturnVendor(row.id!);
|
||||
message.success('取消成功');
|
||||
handleRefresh();
|
||||
}
|
||||
|
||||
/** 导出表格 */
|
||||
async function handleExport() {
|
||||
const data = await exportReturnVendor(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 getReturnVendorPage({
|
||||
pageNo: page.currentPage,
|
||||
pageSize: page.pageSize,
|
||||
...formValues,
|
||||
});
|
||||
},
|
||||
},
|
||||
},
|
||||
rowConfig: {
|
||||
keyField: 'id',
|
||||
isHover: true,
|
||||
},
|
||||
toolbarConfig: {
|
||||
refresh: true,
|
||||
search: true,
|
||||
},
|
||||
} as VxeTableGridOptions<MesWmReturnVendorApi.ReturnVendor>,
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Page auto-content-height>
|
||||
<template #doc>
|
||||
<DocAlert
|
||||
title="【仓库】到货通知、采购入库、采购退货"
|
||||
url="https://doc.iocoder.cn/mes/wm/purchase-in/"
|
||||
/>
|
||||
</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-return-vendor:create'],
|
||||
onClick: handleCreate,
|
||||
},
|
||||
{
|
||||
label: $t('ui.actionTitle.export'),
|
||||
type: 'primary',
|
||||
icon: ACTION_ICON.DOWNLOAD,
|
||||
auth: ['mes:wm-return-vendor: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-return-vendor:update'],
|
||||
ifShow: row.status === MesWmReturnVendorStatusEnum.PREPARE,
|
||||
onClick: handleEdit.bind(null, row),
|
||||
},
|
||||
{
|
||||
label: $t('common.delete'),
|
||||
type: 'link',
|
||||
danger: true,
|
||||
icon: ACTION_ICON.DELETE,
|
||||
auth: ['mes:wm-return-vendor:delete'],
|
||||
ifShow: row.status === MesWmReturnVendorStatusEnum.PREPARE,
|
||||
popConfirm: {
|
||||
title: $t('ui.actionMessage.deleteConfirm', [row.code]),
|
||||
confirm: handleDelete.bind(null, row),
|
||||
},
|
||||
},
|
||||
{
|
||||
label: '执行拣货',
|
||||
type: 'link',
|
||||
auth: ['mes:wm-return-vendor:update'],
|
||||
ifShow: row.status === MesWmReturnVendorStatusEnum.APPROVING,
|
||||
onClick: handleStock.bind(null, row),
|
||||
},
|
||||
{
|
||||
label: '完成退货',
|
||||
type: 'link',
|
||||
auth: ['mes:wm-return-vendor:update-status'],
|
||||
ifShow: row.status === MesWmReturnVendorStatusEnum.APPROVED,
|
||||
onClick: handleFinish.bind(null, row),
|
||||
},
|
||||
{
|
||||
label: '取消',
|
||||
type: 'link',
|
||||
danger: true,
|
||||
auth: ['mes:wm-return-vendor:update'],
|
||||
ifShow:
|
||||
row.status === MesWmReturnVendorStatusEnum.APPROVING ||
|
||||
row.status === MesWmReturnVendorStatusEnum.APPROVED,
|
||||
popConfirm: {
|
||||
title: '确认取消该供应商退货单?取消后不可恢复。',
|
||||
confirm: handleCancel.bind(null, row),
|
||||
},
|
||||
},
|
||||
]"
|
||||
/>
|
||||
</template>
|
||||
</Grid>
|
||||
</Page>
|
||||
</template>
|
||||
|
|
@ -0,0 +1,104 @@
|
|||
<script lang="ts" setup>
|
||||
import type { MesWmReturnVendorDetailApi } from '#/api/mes/wm/returnvendor/detail';
|
||||
|
||||
import { computed, ref } from 'vue';
|
||||
|
||||
import { useVbenModal } from '@vben/common-ui';
|
||||
|
||||
import { message } from 'ant-design-vue';
|
||||
|
||||
import { useVbenForm } from '#/adapter/form';
|
||||
import {
|
||||
createReturnVendorDetail,
|
||||
getReturnVendorDetail,
|
||||
updateReturnVendorDetail,
|
||||
} from '#/api/mes/wm/returnvendor/detail';
|
||||
import { $t } from '#/locales';
|
||||
|
||||
import { useDetailFormSchema } from '../data';
|
||||
|
||||
const emit = defineEmits<{ success: [lineId: number] }>();
|
||||
const formData = ref<MesWmReturnVendorDetailApi.ReturnVendorDetail>();
|
||||
const returnId = 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-1',
|
||||
labelWidth: 90,
|
||||
},
|
||||
layout: 'horizontal',
|
||||
schema: useDetailFormSchema(),
|
||||
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 MesWmReturnVendorDetailApi.ReturnVendorDetail;
|
||||
data.returnId = returnId.value;
|
||||
data.lineId = lineId.value;
|
||||
try {
|
||||
await (formData.value?.id
|
||||
? updateReturnVendorDetail({ ...data, id: formData.value.id })
|
||||
: createReturnVendorDetail(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;
|
||||
}
|
||||
formApi.setState({ schema: useDetailFormSchema(formApi) });
|
||||
// 加载数据
|
||||
const data = modalApi.getData<{
|
||||
detailId?: number;
|
||||
itemId?: number;
|
||||
lineId: number;
|
||||
returnId: number;
|
||||
}>();
|
||||
returnId.value = data.returnId;
|
||||
lineId.value = data.lineId;
|
||||
if (data.detailId) {
|
||||
modalApi.lock();
|
||||
try {
|
||||
formData.value = await getReturnVendorDetail(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-3/5">
|
||||
<Form class="mx-4" />
|
||||
</Modal>
|
||||
</template>
|
||||
|
|
@ -0,0 +1,103 @@
|
|||
<script lang="ts" setup>
|
||||
import type { VxeTableGridOptions } from '#/adapter/vxe-table';
|
||||
import type { MesWmReturnVendorDetailApi } from '#/api/mes/wm/returnvendor/detail';
|
||||
|
||||
import { computed, watch } from 'vue';
|
||||
|
||||
import { message } from 'ant-design-vue';
|
||||
|
||||
import { ACTION_ICON, TableAction, useVbenVxeGrid } from '#/adapter/vxe-table';
|
||||
import { deleteReturnVendorDetail } from '#/api/mes/wm/returnvendor/detail';
|
||||
import { $t } from '#/locales';
|
||||
|
||||
import { type FormType, useDetailGridColumns } from '../data';
|
||||
|
||||
const props = defineProps<{
|
||||
details: MesWmReturnVendorDetailApi.ReturnVendorDetail[];
|
||||
formType: FormType;
|
||||
}>();
|
||||
|
||||
const emit = defineEmits<{
|
||||
edit: [detailId: number];
|
||||
refresh: [];
|
||||
}>();
|
||||
|
||||
const isStock = computed(() => props.formType === 'stock'); // 是否为拣货模式
|
||||
|
||||
/** 编辑拣货明细 */
|
||||
function handleEdit(row: MesWmReturnVendorDetailApi.ReturnVendorDetail) {
|
||||
emit('edit', row.id!);
|
||||
}
|
||||
|
||||
/** 删除拣货明细 */
|
||||
async function handleDelete(
|
||||
row: MesWmReturnVendorDetailApi.ReturnVendorDetail,
|
||||
) {
|
||||
const hideLoading = message.loading({
|
||||
content: $t('ui.actionMessage.deleting', [row.warehouseName]),
|
||||
duration: 0,
|
||||
});
|
||||
try {
|
||||
await deleteReturnVendorDetail(row.id!);
|
||||
message.success($t('ui.actionMessage.deleteSuccess', [row.warehouseName]));
|
||||
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<MesWmReturnVendorDetailApi.ReturnVendorDetail>,
|
||||
});
|
||||
|
||||
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.warehouseName,
|
||||
]),
|
||||
confirm: handleDelete.bind(null, row),
|
||||
},
|
||||
},
|
||||
]"
|
||||
/>
|
||||
</template>
|
||||
</Grid>
|
||||
</div>
|
||||
</template>
|
||||
|
|
@ -0,0 +1,238 @@
|
|||
<script lang="ts" setup>
|
||||
import type { FormType } from '../data';
|
||||
|
||||
import type { MesWmReturnVendorApi } from '#/api/mes/wm/returnvendor';
|
||||
|
||||
import { computed, ref } from 'vue';
|
||||
|
||||
import { confirm, useVbenModal } from '@vben/common-ui';
|
||||
|
||||
import { Button, Divider, message, Popconfirm } from 'ant-design-vue';
|
||||
|
||||
import { useVbenForm } from '#/adapter/form';
|
||||
import {
|
||||
checkReturnVendorQuantity,
|
||||
createReturnVendor,
|
||||
finishReturnVendor,
|
||||
getReturnVendor,
|
||||
stockReturnVendor,
|
||||
submitReturnVendor,
|
||||
updateReturnVendor,
|
||||
} from '#/api/mes/wm/returnvendor';
|
||||
import { $t } from '#/locales';
|
||||
import { MesWmReturnVendorStatusEnum } 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<MesWmReturnVendorApi.ReturnVendor>();
|
||||
const originalSnapshot = ref(''); // 表单原始数据快照,用于提交时跳过未变更的保存请求
|
||||
const isEditable = computed(() => // 是否为编辑模式(可保存)
|
||||
['create', 'update'].includes(formType.value),
|
||||
);
|
||||
const isStock = computed(() => formType.value === 'stock'); // 是否为拣货模式
|
||||
const isFinish = computed(() => formType.value === 'finish'); // 是否为完成退货模式
|
||||
const canSubmit = computed(() => // 是否可提交
|
||||
formType.value === 'update' &&
|
||||
formData.value?.status === MesWmReturnVendorStatusEnum.PREPARE,
|
||||
);
|
||||
const getTitle = computed(() => {
|
||||
switch (formType.value) {
|
||||
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 MesWmReturnVendorApi.ReturnVendor;
|
||||
await updateReturnVendor({ ...formData.value, ...data });
|
||||
originalSnapshot.value = current;
|
||||
}
|
||||
await submitReturnVendor(formData.value.id);
|
||||
message.success('提交成功');
|
||||
await modalApi.close();
|
||||
emit('success');
|
||||
} finally {
|
||||
modalApi.unlock();
|
||||
}
|
||||
}
|
||||
|
||||
/** 执行拣货:拣货数量与退货数量不一致时二次确认 */
|
||||
async function handleStock() {
|
||||
if (!formData.value?.id) {
|
||||
return;
|
||||
}
|
||||
const quantityMatch = await checkReturnVendorQuantity(formData.value.id);
|
||||
if (!quantityMatch) {
|
||||
try {
|
||||
await confirm('退货数量与拣货数量不一致,确认执行拣货?');
|
||||
} catch {
|
||||
return;
|
||||
}
|
||||
}
|
||||
modalApi.lock();
|
||||
try {
|
||||
await stockReturnVendor(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 finishReturnVendor(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 MesWmReturnVendorApi.ReturnVendor;
|
||||
try {
|
||||
if (formData.value?.id) {
|
||||
await updateReturnVendor({ ...formData.value, ...data });
|
||||
formData.value = { ...formData.value, ...data };
|
||||
} else {
|
||||
const id = await createReturnVendor(data);
|
||||
formData.value = {
|
||||
...data,
|
||||
id,
|
||||
status: MesWmReturnVendorStatusEnum.PREPARE,
|
||||
};
|
||||
await formApi.setFieldValue('id', id);
|
||||
await formApi.setFieldValue('status', formData.value.status);
|
||||
formType.value = 'update';
|
||||
}
|
||||
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) });
|
||||
formApi.setDisabled(!isEditable.value);
|
||||
modalApi.setState({ showConfirmButton: isEditable.value });
|
||||
if (data?.id) {
|
||||
modalApi.lock();
|
||||
try {
|
||||
formData.value = await getReturnVendor(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"
|
||||
:return-id="formData.id"
|
||||
:vendor-id="formData.vendorId"
|
||||
/>
|
||||
</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>
|
||||
<Button v-if="isStock" type="primary" @click="handleStock">
|
||||
执行拣货
|
||||
</Button>
|
||||
<Popconfirm
|
||||
v-if="isFinish"
|
||||
title="确认完成该退货单并执行退货?"
|
||||
@confirm="handleFinish"
|
||||
>
|
||||
<Button type="primary">完成退货</Button>
|
||||
</Popconfirm>
|
||||
</div>
|
||||
</template>
|
||||
</Modal>
|
||||
</template>
|
||||
|
|
@ -0,0 +1,99 @@
|
|||
<script lang="ts" setup>
|
||||
import type { MesWmReturnVendorLineApi } from '#/api/mes/wm/returnvendor/line';
|
||||
|
||||
import { computed, ref } from 'vue';
|
||||
|
||||
import { useVbenModal } from '@vben/common-ui';
|
||||
|
||||
import { message } from 'ant-design-vue';
|
||||
|
||||
import { useVbenForm } from '#/adapter/form';
|
||||
import {
|
||||
createReturnVendorLine,
|
||||
getReturnVendorLine,
|
||||
updateReturnVendorLine,
|
||||
} from '#/api/mes/wm/returnvendor/line';
|
||||
import { $t } from '#/locales';
|
||||
|
||||
import { useLineFormSchema } from '../data';
|
||||
|
||||
const emit = defineEmits(['success']);
|
||||
const formData = ref<MesWmReturnVendorLineApi.ReturnVendorLine>();
|
||||
const returnId = 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 MesWmReturnVendorLineApi.ReturnVendorLine;
|
||||
data.returnId = returnId.value;
|
||||
try {
|
||||
await (formData.value?.id
|
||||
? updateReturnVendorLine({ ...data, id: formData.value.id })
|
||||
: createReturnVendorLine(data));
|
||||
// 关闭并提示
|
||||
await modalApi.close();
|
||||
emit('success');
|
||||
message.success($t('ui.actionMessage.operationSuccess'));
|
||||
} finally {
|
||||
modalApi.unlock();
|
||||
}
|
||||
},
|
||||
async onOpenChange(isOpen: boolean) {
|
||||
if (!isOpen) {
|
||||
formData.value = undefined;
|
||||
return;
|
||||
}
|
||||
// 加载数据
|
||||
const data = modalApi.getData<{
|
||||
id?: number;
|
||||
returnId: number;
|
||||
vendorId?: number;
|
||||
}>();
|
||||
returnId.value = data.returnId;
|
||||
formApi.setState({ schema: useLineFormSchema(data.vendorId, formApi) });
|
||||
if (!data.id) {
|
||||
return;
|
||||
}
|
||||
modalApi.lock();
|
||||
try {
|
||||
formData.value = await getReturnVendorLine(data.id);
|
||||
// 设置到 values
|
||||
await formApi.setValues(formData.value);
|
||||
} finally {
|
||||
modalApi.unlock();
|
||||
}
|
||||
},
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Modal :title="getTitle" class="w-3/5">
|
||||
<Form class="mx-4" />
|
||||
</Modal>
|
||||
</template>
|
||||
|
|
@ -0,0 +1,234 @@
|
|||
<script lang="ts" setup>
|
||||
import type { VxeTableGridOptions } from '#/adapter/vxe-table';
|
||||
import type { MesWmReturnVendorDetailApi } from '#/api/mes/wm/returnvendor/detail';
|
||||
import type { MesWmReturnVendorLineApi } from '#/api/mes/wm/returnvendor/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 { getReturnVendorDetailListByLineId } from '#/api/mes/wm/returnvendor/detail';
|
||||
import {
|
||||
deleteReturnVendorLine,
|
||||
getReturnVendorLinePage,
|
||||
} from '#/api/mes/wm/returnvendor/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;
|
||||
returnId: number;
|
||||
vendorId?: number;
|
||||
}>();
|
||||
|
||||
const isEditable = computed(() => // 是否可编辑明细行
|
||||
['create', 'update'].includes(props.formType),
|
||||
);
|
||||
const isStock = computed(() => props.formType === 'stock'); // 是否为拣货模式
|
||||
const detailMap = reactive<
|
||||
Record<number, MesWmReturnVendorDetailApi.ReturnVendorDetail[]>
|
||||
>({}); // 已展开行的拣货明细缓存
|
||||
|
||||
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({ returnId: props.returnId, vendorId: props.vendorId })
|
||||
.open();
|
||||
}
|
||||
|
||||
/** 编辑物料 */
|
||||
function handleEdit(row: MesWmReturnVendorLineApi.ReturnVendorLine) {
|
||||
lineFormModalApi
|
||||
.setData({ id: row.id, returnId: props.returnId, vendorId: props.vendorId })
|
||||
.open();
|
||||
}
|
||||
|
||||
/** 删除物料 */
|
||||
async function handleDelete(row: MesWmReturnVendorLineApi.ReturnVendorLine) {
|
||||
const hideLoading = message.loading({
|
||||
content: $t('ui.actionMessage.deleting', [row.itemName]),
|
||||
duration: 0,
|
||||
});
|
||||
try {
|
||||
await deleteReturnVendorLine(row.id!);
|
||||
message.success($t('ui.actionMessage.deleteSuccess', [row.itemName]));
|
||||
handleRefresh();
|
||||
} finally {
|
||||
hideLoading();
|
||||
}
|
||||
}
|
||||
|
||||
/** 拣货:直接打开明细创建表单 */
|
||||
function handlePicking(row: MesWmReturnVendorLineApi.ReturnVendorLine) {
|
||||
openDetailForm(row.id!, row.itemId);
|
||||
}
|
||||
|
||||
/** 打开拣货明细表单 */
|
||||
function openDetailForm(lineId: number, itemId?: number, detailId?: number) {
|
||||
detailFormModalApi
|
||||
.setData({ detailId, itemId, lineId, returnId: props.returnId })
|
||||
.open();
|
||||
}
|
||||
|
||||
/** 获取已展开行的拣货明细 */
|
||||
function getExpandedDetails(row: MesWmReturnVendorLineApi.ReturnVendorLine) {
|
||||
return detailMap[row.id!] || [];
|
||||
}
|
||||
|
||||
/** 加载指定行的拣货明细 */
|
||||
async function loadLineDetails(lineId: number) {
|
||||
detailMap[lineId] = await getReturnVendorDetailListByLineId(lineId);
|
||||
}
|
||||
|
||||
/** 展开行时懒加载拣货明细 */
|
||||
async function handleExpandChange(
|
||||
row: MesWmReturnVendorLineApi.ReturnVendorLine,
|
||||
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 ({ page }) => {
|
||||
if (!props.returnId) {
|
||||
return { list: [], total: 0 };
|
||||
}
|
||||
return await getReturnVendorLinePage({
|
||||
pageNo: page.currentPage,
|
||||
pageSize: page.pageSize,
|
||||
returnId: props.returnId,
|
||||
});
|
||||
},
|
||||
},
|
||||
},
|
||||
rowConfig: {
|
||||
keyField: 'id',
|
||||
isHover: true,
|
||||
},
|
||||
toolbarConfig: {
|
||||
refresh: true,
|
||||
},
|
||||
} as VxeTableGridOptions<MesWmReturnVendorLineApi.ReturnVendorLine>,
|
||||
gridEvents: {
|
||||
toggleRowExpand: ({
|
||||
expanded,
|
||||
row,
|
||||
}: {
|
||||
expanded: boolean;
|
||||
row: MesWmReturnVendorLineApi.ReturnVendorLine;
|
||||
}) => {
|
||||
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 }">
|
||||
<div class="flex items-center justify-center">
|
||||
<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: handlePicking.bind(null, row),
|
||||
},
|
||||
]"
|
||||
/>
|
||||
<PrinterLabel
|
||||
v-if="isStock"
|
||||
:biz-code="row.batchCode"
|
||||
:biz-id="row.batchId"
|
||||
biz-type="BATCH"
|
||||
/>
|
||||
</div>
|
||||
</template>
|
||||
</Grid>
|
||||
</div>
|
||||
</template>
|
||||
|
|
@ -0,0 +1,571 @@
|
|||
import type { VbenFormApi, VbenFormSchema } from '#/adapter/form';
|
||||
import type { VxeTableGridOptions } from '#/adapter/vxe-table';
|
||||
import type { MesWmMaterialStockApi } from '#/api/mes/wm/materialstock';
|
||||
import type { MesWmReturnIssueApi } from '#/api/mes/wm/returnissue';
|
||||
import type { MesWmReturnIssueDetailApi } from '#/api/mes/wm/returnissue/detail';
|
||||
import type { MesWmReturnIssueLineApi } from '#/api/mes/wm/returnissue/line';
|
||||
|
||||
import { h, markRaw } from 'vue';
|
||||
|
||||
import { DICT_TYPE } from '@vben/constants';
|
||||
import { getDictOptions } from '@vben/hooks';
|
||||
|
||||
import { ElButton } from 'element-plus';
|
||||
|
||||
import { z } from '#/adapter/form';
|
||||
import { generateAutoCode } from '#/api/mes/md/autocode/record';
|
||||
import MdItemSelect from '#/views/mes/md/item/components/md-item-select.vue';
|
||||
import MdWorkstationSelect from '#/views/mes/md/workstation/components/md-workstation-select.vue';
|
||||
import ProWorkOrderSelect from '#/views/mes/pro/workorder/components/pro-work-order-select.vue';
|
||||
import {
|
||||
MesAutoCodeRuleCode,
|
||||
MesProWorkOrderStatusEnum,
|
||||
} 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 = 'create' | 'detail' | 'finish' | 'stock' | 'update';
|
||||
|
||||
/** 表单头部是否只读(上架、详情、执行退料态) */
|
||||
function isHeaderReadonly(formType: FormType): boolean {
|
||||
return (
|
||||
formType === 'detail' || formType === 'finish' || formType === 'stock'
|
||||
);
|
||||
}
|
||||
|
||||
/** 新增/修改的表单 */
|
||||
export function useFormSchema(
|
||||
formType: FormType,
|
||||
formApi?: VbenFormApi,
|
||||
): VbenFormSchema[] {
|
||||
return [
|
||||
{
|
||||
fieldName: 'id',
|
||||
component: 'Input',
|
||||
dependencies: {
|
||||
triggerFields: [''],
|
||||
show: () => false,
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldName: 'status',
|
||||
component: 'Input',
|
||||
dependencies: {
|
||||
triggerFields: [''],
|
||||
show: () => false,
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldName: 'code',
|
||||
label: '退料单编号',
|
||||
component: 'Input',
|
||||
componentProps: {
|
||||
placeholder: '请输入退料单编号',
|
||||
},
|
||||
rules: 'required',
|
||||
suffix: isHeaderReadonly(formType)
|
||||
? undefined
|
||||
: () =>
|
||||
h(
|
||||
ElButton,
|
||||
{
|
||||
onClick: async () => {
|
||||
const code = await generateAutoCode(
|
||||
MesAutoCodeRuleCode.WM_RETURN_ISSUE_CODE,
|
||||
);
|
||||
await formApi?.setFieldValue('code', code);
|
||||
},
|
||||
},
|
||||
{ default: () => '生成' },
|
||||
),
|
||||
},
|
||||
{
|
||||
fieldName: 'name',
|
||||
label: '退料单名称',
|
||||
component: 'Input',
|
||||
componentProps: {
|
||||
placeholder: '请输入退料单名称',
|
||||
},
|
||||
rules: 'required',
|
||||
},
|
||||
{
|
||||
fieldName: 'type',
|
||||
label: '退料类型',
|
||||
component: 'Select',
|
||||
componentProps: {
|
||||
clearable: true,
|
||||
options: getDictOptions(DICT_TYPE.MES_WM_RETURN_ISSUE_TYPE, 'number'),
|
||||
placeholder: '请选择退料类型',
|
||||
},
|
||||
rules: 'required',
|
||||
},
|
||||
{
|
||||
fieldName: 'workOrderId',
|
||||
label: '生产工单',
|
||||
component: markRaw(ProWorkOrderSelect),
|
||||
componentProps: {
|
||||
status: MesProWorkOrderStatusEnum.CONFIRMED,
|
||||
},
|
||||
rules: 'selectRequired',
|
||||
},
|
||||
{
|
||||
fieldName: 'workstationId',
|
||||
label: '工作站',
|
||||
component: markRaw(MdWorkstationSelect),
|
||||
componentProps: {
|
||||
placeholder: '请选择工作站',
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldName: 'returnDate',
|
||||
label: '退料日期',
|
||||
component: 'DatePicker',
|
||||
componentProps: {
|
||||
class: '!w-full',
|
||||
format: 'YYYY-MM-DD HH:mm:ss',
|
||||
placeholder: '请选择退料日期',
|
||||
type: 'datetime',
|
||||
valueFormat: 'x',
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldName: 'remark',
|
||||
label: '备注',
|
||||
component: 'Textarea',
|
||||
formItemClass: 'col-span-3',
|
||||
componentProps: {
|
||||
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: 'workOrderId',
|
||||
label: '生产工单',
|
||||
component: markRaw(ProWorkOrderSelect),
|
||||
componentProps: {
|
||||
placeholder: '请选择生产工单',
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldName: 'type',
|
||||
label: '退料类型',
|
||||
component: 'Select',
|
||||
componentProps: {
|
||||
clearable: true,
|
||||
options: getDictOptions(DICT_TYPE.MES_WM_RETURN_ISSUE_TYPE, 'number'),
|
||||
placeholder: '请选择退料类型',
|
||||
},
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
/** 列表的字段 */
|
||||
export function useGridColumns(): VxeTableGridOptions<MesWmReturnIssueApi.ReturnIssue>['columns'] {
|
||||
return [
|
||||
{
|
||||
field: 'code',
|
||||
title: '退料单编号',
|
||||
minWidth: 160,
|
||||
slots: { default: 'code' },
|
||||
},
|
||||
{
|
||||
field: 'name',
|
||||
title: '退料单名称',
|
||||
minWidth: 150,
|
||||
},
|
||||
{
|
||||
field: 'type',
|
||||
title: '退料类型',
|
||||
minWidth: 110,
|
||||
cellRender: {
|
||||
name: 'CellDict',
|
||||
props: { type: DICT_TYPE.MES_WM_RETURN_ISSUE_TYPE },
|
||||
},
|
||||
},
|
||||
{
|
||||
field: 'workOrderCode',
|
||||
title: '生产工单',
|
||||
minWidth: 140,
|
||||
},
|
||||
{
|
||||
field: 'workstationName',
|
||||
title: '工作站',
|
||||
minWidth: 120,
|
||||
},
|
||||
{
|
||||
field: 'returnDate',
|
||||
title: '退料日期',
|
||||
width: 180,
|
||||
formatter: 'formatDateTime',
|
||||
},
|
||||
{
|
||||
field: 'status',
|
||||
title: '单据状态',
|
||||
minWidth: 110,
|
||||
cellRender: {
|
||||
name: 'CellDict',
|
||||
props: { type: DICT_TYPE.MES_WM_RETURN_ISSUE_STATUS },
|
||||
},
|
||||
},
|
||||
{
|
||||
title: '操作',
|
||||
width: 240,
|
||||
fixed: 'right',
|
||||
slots: { default: 'actions' },
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
/** 退料单行子表的字段 */
|
||||
export function useLineGridColumns(
|
||||
editable: boolean,
|
||||
stockable: boolean,
|
||||
): VxeTableGridOptions<MesWmReturnIssueLineApi.ReturnIssueLine>['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: 'rqcCheckFlag',
|
||||
title: '是否检测',
|
||||
width: 100,
|
||||
cellRender: {
|
||||
name: 'CellDict',
|
||||
props: { type: DICT_TYPE.INFRA_BOOLEAN_STRING },
|
||||
},
|
||||
},
|
||||
{
|
||||
field: 'qualityStatus',
|
||||
title: '质量状态',
|
||||
width: 100,
|
||||
cellRender: {
|
||||
name: 'CellDict',
|
||||
props: { type: DICT_TYPE.MES_WM_QUALITY_STATUS },
|
||||
},
|
||||
},
|
||||
...(editable || stockable
|
||||
? [
|
||||
{
|
||||
title: '操作',
|
||||
width: 200,
|
||||
fixed: 'right',
|
||||
slots: { default: 'actions' },
|
||||
} as const,
|
||||
]
|
||||
: []),
|
||||
];
|
||||
}
|
||||
|
||||
/** 退料单行新增/修改的表单 */
|
||||
export function useLineFormSchema(formApi?: VbenFormApi): VbenFormSchema[] {
|
||||
return [
|
||||
{
|
||||
fieldName: 'materialStockId',
|
||||
label: '库存记录',
|
||||
component: markRaw(WmMaterialStockSelect),
|
||||
componentProps: {
|
||||
// 选择库存记录后,自动回填物料/批次/数量
|
||||
onChange: async (stock?: MesWmMaterialStockApi.MaterialStock) => {
|
||||
await formApi?.setValues({
|
||||
batchCode: stock?.batchCode,
|
||||
batchId: stock?.batchId,
|
||||
itemId: stock?.itemId,
|
||||
quantity: stock?.quantity,
|
||||
quantityMax: stock?.quantity,
|
||||
});
|
||||
},
|
||||
virtualFilter: 'only',
|
||||
},
|
||||
rules: 'selectRequired',
|
||||
},
|
||||
{
|
||||
fieldName: 'quantityMax',
|
||||
component: 'Input',
|
||||
dependencies: {
|
||||
triggerFields: [''],
|
||||
show: () => false,
|
||||
},
|
||||
},
|
||||
{
|
||||
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: 'rqcCheckFlag',
|
||||
label: '需要质检',
|
||||
component: 'Switch',
|
||||
rules: z.boolean().default(false),
|
||||
},
|
||||
{
|
||||
fieldName: 'itemId',
|
||||
label: '物料',
|
||||
component: markRaw(MdItemSelect),
|
||||
componentProps: {
|
||||
disabled: true,
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldName: 'batchCode',
|
||||
label: '批次号',
|
||||
component: 'Input',
|
||||
componentProps: {
|
||||
disabled: true,
|
||||
placeholder: '选择库存后自动带出',
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldName: 'remark',
|
||||
label: '备注',
|
||||
component: 'Textarea',
|
||||
formItemClass: 'col-span-3',
|
||||
componentProps: {
|
||||
placeholder: '请输入备注',
|
||||
rows: 3,
|
||||
},
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
/** 上架明细子表的字段 */
|
||||
export function useDetailGridColumns(
|
||||
stockable: boolean,
|
||||
): VxeTableGridOptions<MesWmReturnIssueDetailApi.ReturnIssueDetail>['columns'] {
|
||||
return [
|
||||
{
|
||||
field: 'batchCode',
|
||||
title: '批次号',
|
||||
minWidth: 120,
|
||||
},
|
||||
{
|
||||
field: 'warehouseName',
|
||||
title: '仓库名称',
|
||||
minWidth: 100,
|
||||
},
|
||||
{
|
||||
field: 'locationName',
|
||||
title: '库区名称',
|
||||
minWidth: 100,
|
||||
},
|
||||
{
|
||||
field: 'areaName',
|
||||
title: '库位名称',
|
||||
minWidth: 100,
|
||||
},
|
||||
{
|
||||
field: 'quantity',
|
||||
title: '数量',
|
||||
width: 100,
|
||||
},
|
||||
...(stockable
|
||||
? [
|
||||
{
|
||||
title: '操作',
|
||||
width: 120,
|
||||
fixed: 'right',
|
||||
slots: { default: 'actions' },
|
||||
} as const,
|
||||
]
|
||||
: []),
|
||||
];
|
||||
}
|
||||
|
||||
/** 上架明细新增/修改的表单 */
|
||||
export function useDetailFormSchema(formApi?: VbenFormApi): VbenFormSchema[] {
|
||||
return [
|
||||
{
|
||||
fieldName: 'quantityMax',
|
||||
component: 'Input',
|
||||
dependencies: {
|
||||
triggerFields: [''],
|
||||
show: () => false,
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldName: 'itemId',
|
||||
label: '物料',
|
||||
component: markRaw(MdItemSelect),
|
||||
componentProps: {
|
||||
disabled: true,
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldName: 'materialStockId',
|
||||
label: '库存记录',
|
||||
component: markRaw(WmMaterialStockSelect),
|
||||
componentProps: {
|
||||
// 选择库存记录后,自动回填仓库/库区/库位/批次/数量
|
||||
onChange: async (stock?: MesWmMaterialStockApi.MaterialStock) => {
|
||||
await formApi?.setValues({
|
||||
areaId: stock?.areaId,
|
||||
batchCode: stock?.batchCode,
|
||||
batchId: stock?.batchId,
|
||||
locationId: stock?.locationId,
|
||||
quantity: stock?.quantity,
|
||||
quantityMax: stock?.quantity,
|
||||
warehouseId: stock?.warehouseId,
|
||||
});
|
||||
},
|
||||
virtualFilter: 'only',
|
||||
},
|
||||
rules: 'selectRequired',
|
||||
dependencies: {
|
||||
triggerFields: ['itemId'],
|
||||
componentProps: (values) => ({
|
||||
itemId: values.itemId,
|
||||
virtualFilter: 'only',
|
||||
}),
|
||||
},
|
||||
},
|
||||
{
|
||||
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: 'warehouseId',
|
||||
label: '入库仓库',
|
||||
component: markRaw(WmWarehouseSelect),
|
||||
componentProps: {
|
||||
disabled: true,
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldName: 'locationId',
|
||||
label: '库区',
|
||||
component: markRaw(WmWarehouseLocationSelect),
|
||||
componentProps: {
|
||||
disabled: true,
|
||||
},
|
||||
dependencies: {
|
||||
triggerFields: ['warehouseId'],
|
||||
componentProps: (values) => ({
|
||||
disabled: true,
|
||||
warehouseId: values.warehouseId,
|
||||
}),
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldName: 'areaId',
|
||||
label: '库位',
|
||||
component: markRaw(WmWarehouseAreaSelect),
|
||||
componentProps: {
|
||||
disabled: true,
|
||||
},
|
||||
dependencies: {
|
||||
triggerFields: ['locationId'],
|
||||
componentProps: (values) => ({
|
||||
disabled: true,
|
||||
locationId: values.locationId,
|
||||
}),
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldName: 'batchCode',
|
||||
label: '批次号',
|
||||
component: 'Input',
|
||||
componentProps: {
|
||||
disabled: true,
|
||||
},
|
||||
},
|
||||
];
|
||||
}
|
||||
|
|
@ -0,0 +1,224 @@
|
|||
<script lang="ts" setup>
|
||||
import type { VxeTableGridOptions } from '#/adapter/vxe-table';
|
||||
import type { MesWmReturnIssueApi } from '#/api/mes/wm/returnissue';
|
||||
|
||||
import { DocAlert, Page, useVbenModal } from '@vben/common-ui';
|
||||
import { downloadFileFromBlobPart } from '@vben/utils';
|
||||
|
||||
import { ElButton, ElLoading, ElMessage } from 'element-plus';
|
||||
|
||||
import { ACTION_ICON, TableAction, useVbenVxeGrid } from '#/adapter/vxe-table';
|
||||
import {
|
||||
cancelReturnIssue,
|
||||
deleteReturnIssue,
|
||||
exportReturnIssue,
|
||||
getReturnIssuePage,
|
||||
} from '#/api/mes/wm/returnissue';
|
||||
import { $t } from '#/locales';
|
||||
import { MesWmReturnIssueStatusEnum } 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: MesWmReturnIssueApi.ReturnIssue) {
|
||||
formModalApi.setData({ formType: 'detail', id: row.id }).open();
|
||||
}
|
||||
|
||||
/** 编辑生产退料单 */
|
||||
function handleEdit(row: MesWmReturnIssueApi.ReturnIssue) {
|
||||
formModalApi.setData({ formType: 'update', id: row.id }).open();
|
||||
}
|
||||
|
||||
/** 执行上架 */
|
||||
function handleStock(row: MesWmReturnIssueApi.ReturnIssue) {
|
||||
formModalApi.setData({ formType: 'stock', id: row.id }).open();
|
||||
}
|
||||
|
||||
/** 执行退料 */
|
||||
function handleFinish(row: MesWmReturnIssueApi.ReturnIssue) {
|
||||
formModalApi.setData({ formType: 'finish', id: row.id }).open();
|
||||
}
|
||||
|
||||
/** 提示前往质检模块 */
|
||||
function handleQc() {
|
||||
ElMessage.info('请前往【质量管理 - 退货检验(RQC)】中进行退料检验操作');
|
||||
}
|
||||
|
||||
/** 删除生产退料单 */
|
||||
async function handleDelete(row: MesWmReturnIssueApi.ReturnIssue) {
|
||||
const loadingInstance = ElLoading.service({
|
||||
text: $t('ui.actionMessage.deleting', [row.code]),
|
||||
});
|
||||
try {
|
||||
await deleteReturnIssue(row.id!);
|
||||
ElMessage.success($t('ui.actionMessage.deleteSuccess', [row.code]));
|
||||
handleRefresh();
|
||||
} finally {
|
||||
loadingInstance.close();
|
||||
}
|
||||
}
|
||||
|
||||
/** 取消生产退料单 */
|
||||
async function handleCancel(row: MesWmReturnIssueApi.ReturnIssue) {
|
||||
await cancelReturnIssue(row.id!);
|
||||
ElMessage.success('取消成功');
|
||||
handleRefresh();
|
||||
}
|
||||
|
||||
/** 导出表格 */
|
||||
async function handleExport() {
|
||||
const data = await exportReturnIssue(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 getReturnIssuePage({
|
||||
pageNo: page.currentPage,
|
||||
pageSize: page.pageSize,
|
||||
...formValues,
|
||||
});
|
||||
},
|
||||
},
|
||||
},
|
||||
rowConfig: {
|
||||
keyField: 'id',
|
||||
isHover: true,
|
||||
},
|
||||
toolbarConfig: {
|
||||
refresh: true,
|
||||
search: true,
|
||||
},
|
||||
} as VxeTableGridOptions<MesWmReturnIssueApi.ReturnIssue>,
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Page auto-content-height>
|
||||
<template #doc>
|
||||
<DocAlert
|
||||
title="【仓库】生产领料、生产退料、物料消耗"
|
||||
url="https://doc.iocoder.cn/mes/wm/issue-return/"
|
||||
/>
|
||||
</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-return-issue:create'],
|
||||
onClick: handleCreate,
|
||||
},
|
||||
{
|
||||
label: $t('ui.actionTitle.export'),
|
||||
type: 'primary',
|
||||
icon: ACTION_ICON.DOWNLOAD,
|
||||
auth: ['mes:wm-return-issue:export'],
|
||||
onClick: handleExport,
|
||||
},
|
||||
]"
|
||||
/>
|
||||
</template>
|
||||
<template #code="{ row }">
|
||||
<ElButton link type="primary" @click="handleDetail(row)">
|
||||
{{ row.code }}
|
||||
</ElButton>
|
||||
</template>
|
||||
<template #actions="{ row }">
|
||||
<TableAction
|
||||
:actions="[
|
||||
{
|
||||
label: $t('common.edit'),
|
||||
type: 'primary',
|
||||
link: true,
|
||||
icon: ACTION_ICON.EDIT,
|
||||
auth: ['mes:wm-return-issue:update'],
|
||||
ifShow: row.status === MesWmReturnIssueStatusEnum.PREPARE,
|
||||
onClick: handleEdit.bind(null, row),
|
||||
},
|
||||
{
|
||||
label: $t('common.delete'),
|
||||
type: 'danger',
|
||||
link: true,
|
||||
icon: ACTION_ICON.DELETE,
|
||||
auth: ['mes:wm-return-issue:delete'],
|
||||
ifShow: row.status === MesWmReturnIssueStatusEnum.PREPARE,
|
||||
popConfirm: {
|
||||
title: $t('ui.actionMessage.deleteConfirm', [row.code]),
|
||||
confirm: handleDelete.bind(null, row),
|
||||
},
|
||||
},
|
||||
{
|
||||
label: '执行质检',
|
||||
type: 'primary',
|
||||
link: true,
|
||||
ifShow: row.status === MesWmReturnIssueStatusEnum.CONFIRMED,
|
||||
onClick: handleQc,
|
||||
},
|
||||
{
|
||||
label: '执行上架',
|
||||
type: 'primary',
|
||||
link: true,
|
||||
auth: ['mes:wm-return-issue:update'],
|
||||
ifShow: row.status === MesWmReturnIssueStatusEnum.APPROVING,
|
||||
onClick: handleStock.bind(null, row),
|
||||
},
|
||||
{
|
||||
label: '执行退料',
|
||||
type: 'primary',
|
||||
link: true,
|
||||
auth: ['mes:wm-return-issue:finish'],
|
||||
ifShow: row.status === MesWmReturnIssueStatusEnum.APPROVED,
|
||||
onClick: handleFinish.bind(null, row),
|
||||
},
|
||||
{
|
||||
label: '取消',
|
||||
type: 'danger',
|
||||
link: true,
|
||||
auth: ['mes:wm-return-issue:update'],
|
||||
ifShow:
|
||||
row.status === MesWmReturnIssueStatusEnum.CONFIRMED ||
|
||||
row.status === MesWmReturnIssueStatusEnum.APPROVING ||
|
||||
row.status === MesWmReturnIssueStatusEnum.APPROVED,
|
||||
popConfirm: {
|
||||
title: '确认取消该生产退料单?取消后不可恢复。',
|
||||
confirm: handleCancel.bind(null, row),
|
||||
},
|
||||
},
|
||||
]"
|
||||
/>
|
||||
</template>
|
||||
</Grid>
|
||||
</Page>
|
||||
</template>
|
||||
|
|
@ -0,0 +1,104 @@
|
|||
<script lang="ts" setup>
|
||||
import type { MesWmReturnIssueDetailApi } from '#/api/mes/wm/returnissue/detail';
|
||||
|
||||
import { computed, ref } from 'vue';
|
||||
|
||||
import { useVbenModal } from '@vben/common-ui';
|
||||
|
||||
import { ElMessage } from 'element-plus';
|
||||
|
||||
import { useVbenForm } from '#/adapter/form';
|
||||
import {
|
||||
createReturnIssueDetail,
|
||||
getReturnIssueDetail,
|
||||
updateReturnIssueDetail,
|
||||
} from '#/api/mes/wm/returnissue/detail';
|
||||
import { $t } from '#/locales';
|
||||
|
||||
import { useDetailFormSchema } from '../data';
|
||||
|
||||
const emit = defineEmits<{ success: [lineId: number] }>();
|
||||
const formData = ref<MesWmReturnIssueDetailApi.ReturnIssueDetail>();
|
||||
const issueId = 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-1',
|
||||
labelWidth: 90,
|
||||
},
|
||||
layout: 'horizontal',
|
||||
schema: useDetailFormSchema(),
|
||||
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 MesWmReturnIssueDetailApi.ReturnIssueDetail;
|
||||
data.issueId = issueId.value;
|
||||
data.lineId = lineId.value;
|
||||
try {
|
||||
await (formData.value?.id
|
||||
? updateReturnIssueDetail({ ...data, id: formData.value.id })
|
||||
: createReturnIssueDetail(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;
|
||||
}
|
||||
formApi.setState({ schema: useDetailFormSchema(formApi) });
|
||||
// 加载数据
|
||||
const data = modalApi.getData<{
|
||||
detailId?: number;
|
||||
issueId: number;
|
||||
itemId?: number;
|
||||
lineId: number;
|
||||
}>();
|
||||
issueId.value = data.issueId;
|
||||
lineId.value = data.lineId;
|
||||
if (data.detailId) {
|
||||
modalApi.lock();
|
||||
try {
|
||||
formData.value = await getReturnIssueDetail(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-3/5">
|
||||
<Form class="mx-4" />
|
||||
</Modal>
|
||||
</template>
|
||||
|
|
@ -0,0 +1,103 @@
|
|||
<script lang="ts" setup>
|
||||
import type { VxeTableGridOptions } from '#/adapter/vxe-table';
|
||||
import type { MesWmReturnIssueDetailApi } from '#/api/mes/wm/returnissue/detail';
|
||||
|
||||
import { computed, watch } from 'vue';
|
||||
|
||||
import { ElLoading, ElMessage } from 'element-plus';
|
||||
|
||||
import { ACTION_ICON, TableAction, useVbenVxeGrid } from '#/adapter/vxe-table';
|
||||
import { deleteReturnIssueDetail } from '#/api/mes/wm/returnissue/detail';
|
||||
import { $t } from '#/locales';
|
||||
|
||||
import { type FormType, useDetailGridColumns } from '../data';
|
||||
|
||||
const props = defineProps<{
|
||||
details: MesWmReturnIssueDetailApi.ReturnIssueDetail[];
|
||||
formType: FormType;
|
||||
}>();
|
||||
|
||||
const emit = defineEmits<{
|
||||
edit: [detailId: number];
|
||||
refresh: [];
|
||||
}>();
|
||||
|
||||
const isStock = computed(() => props.formType === 'stock'); // 是否为入库上架模式
|
||||
|
||||
/** 编辑上架明细 */
|
||||
function handleEdit(row: MesWmReturnIssueDetailApi.ReturnIssueDetail) {
|
||||
emit('edit', row.id!);
|
||||
}
|
||||
|
||||
/** 删除上架明细 */
|
||||
async function handleDelete(
|
||||
row: MesWmReturnIssueDetailApi.ReturnIssueDetail,
|
||||
) {
|
||||
const loadingInstance = ElLoading.service({
|
||||
text: $t('ui.actionMessage.deleting', [row.warehouseName]),
|
||||
});
|
||||
try {
|
||||
await deleteReturnIssueDetail(row.id!);
|
||||
ElMessage.success($t('ui.actionMessage.deleteSuccess', [row.warehouseName]));
|
||||
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<MesWmReturnIssueDetailApi.ReturnIssueDetail>,
|
||||
});
|
||||
|
||||
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.warehouseName,
|
||||
]),
|
||||
confirm: handleDelete.bind(null, row),
|
||||
},
|
||||
},
|
||||
]"
|
||||
/>
|
||||
</template>
|
||||
</Grid>
|
||||
</div>
|
||||
</template>
|
||||
|
|
@ -0,0 +1,230 @@
|
|||
<script lang="ts" setup>
|
||||
import type { FormType } from '../data';
|
||||
|
||||
import type { MesWmReturnIssueApi } from '#/api/mes/wm/returnissue';
|
||||
|
||||
import { computed, ref } from 'vue';
|
||||
|
||||
import { useVbenModal } from '@vben/common-ui';
|
||||
|
||||
import { ElButton, ElDivider, ElMessage, ElPopconfirm } from 'element-plus';
|
||||
|
||||
import { useVbenForm } from '#/adapter/form';
|
||||
import {
|
||||
createReturnIssue,
|
||||
finishReturnIssue,
|
||||
getReturnIssue,
|
||||
stockReturnIssue,
|
||||
submitReturnIssue,
|
||||
updateReturnIssue,
|
||||
} from '#/api/mes/wm/returnissue';
|
||||
import { $t } from '#/locales';
|
||||
import { MesWmReturnIssueStatusEnum } 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<MesWmReturnIssueApi.ReturnIssue>();
|
||||
const originalSnapshot = ref(''); // 表单原始数据快照,用于提交时跳过未变更的保存请求
|
||||
const isEditable = computed(() => // 是否为编辑模式(可保存)
|
||||
['create', 'update'].includes(formType.value),
|
||||
);
|
||||
const isStock = computed(() => formType.value === 'stock'); // 是否为入库上架模式
|
||||
const isFinish = computed(() => formType.value === 'finish'); // 是否为执行退料模式
|
||||
const canSubmit = computed(() => // 是否可提交
|
||||
formType.value === 'update' &&
|
||||
formData.value?.status === MesWmReturnIssueStatusEnum.PREPARE,
|
||||
);
|
||||
const getTitle = computed(() => {
|
||||
switch (formType.value) {
|
||||
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 MesWmReturnIssueApi.ReturnIssue;
|
||||
await updateReturnIssue({ ...formData.value, ...data });
|
||||
originalSnapshot.value = current;
|
||||
}
|
||||
await submitReturnIssue(formData.value.id);
|
||||
ElMessage.success('提交成功');
|
||||
await modalApi.close();
|
||||
emit('success');
|
||||
} finally {
|
||||
modalApi.unlock();
|
||||
}
|
||||
}
|
||||
|
||||
/** 入库上架 */
|
||||
async function handleStock() {
|
||||
if (!formData.value?.id) {
|
||||
return;
|
||||
}
|
||||
modalApi.lock();
|
||||
try {
|
||||
await stockReturnIssue(formData.value.id);
|
||||
ElMessage.success('入库上架成功');
|
||||
await modalApi.close();
|
||||
emit('success');
|
||||
} finally {
|
||||
modalApi.unlock();
|
||||
}
|
||||
}
|
||||
|
||||
/** 执行退料 */
|
||||
async function handleFinish() {
|
||||
if (!formData.value?.id) {
|
||||
return;
|
||||
}
|
||||
modalApi.lock();
|
||||
try {
|
||||
await finishReturnIssue(formData.value.id);
|
||||
ElMessage.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 MesWmReturnIssueApi.ReturnIssue;
|
||||
try {
|
||||
if (formData.value?.id) {
|
||||
await updateReturnIssue({ ...formData.value, ...data });
|
||||
formData.value = { ...formData.value, ...data };
|
||||
} else {
|
||||
const id = await createReturnIssue(data);
|
||||
formData.value = {
|
||||
...data,
|
||||
id,
|
||||
status: MesWmReturnIssueStatusEnum.PREPARE,
|
||||
};
|
||||
await formApi.setFieldValue('id', id);
|
||||
await formApi.setFieldValue('status', formData.value.status);
|
||||
formType.value = 'update';
|
||||
}
|
||||
originalSnapshot.value = JSON.stringify(await formApi.getValues());
|
||||
emit('success');
|
||||
ElMessage.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) });
|
||||
formApi.setDisabled(!isEditable.value);
|
||||
modalApi.setState({ showConfirmButton: isEditable.value });
|
||||
if (data?.id) {
|
||||
modalApi.lock();
|
||||
try {
|
||||
formData.value = await getReturnIssue(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">
|
||||
<ElDivider>物料信息</ElDivider>
|
||||
<div class="mx-4">
|
||||
<LineList :form-type="formType" :issue-id="formData.id" />
|
||||
</div>
|
||||
</template>
|
||||
<template #prepend-footer>
|
||||
<div class="flex flex-auto items-center gap-2">
|
||||
<ElPopconfirm
|
||||
v-if="canSubmit"
|
||||
title="确认提交该退料单?【提交后将不能修改】"
|
||||
width="260"
|
||||
@confirm="handleSubmit"
|
||||
>
|
||||
<template #reference>
|
||||
<ElButton type="primary">提交</ElButton>
|
||||
</template>
|
||||
</ElPopconfirm>
|
||||
<ElButton v-if="isStock" type="primary" @click="handleStock">
|
||||
入库上架
|
||||
</ElButton>
|
||||
<ElPopconfirm
|
||||
v-if="isFinish"
|
||||
title="确认完成该退料单并执行入库吗?"
|
||||
width="260"
|
||||
@confirm="handleFinish"
|
||||
>
|
||||
<template #reference>
|
||||
<ElButton type="primary">执行退料</ElButton>
|
||||
</template>
|
||||
</ElPopconfirm>
|
||||
</div>
|
||||
</template>
|
||||
</Modal>
|
||||
</template>
|
||||
|
|
@ -0,0 +1,95 @@
|
|||
<script lang="ts" setup>
|
||||
import type { MesWmReturnIssueLineApi } from '#/api/mes/wm/returnissue/line';
|
||||
|
||||
import { computed, ref } from 'vue';
|
||||
|
||||
import { useVbenModal } from '@vben/common-ui';
|
||||
|
||||
import { ElMessage } from 'element-plus';
|
||||
|
||||
import { useVbenForm } from '#/adapter/form';
|
||||
import {
|
||||
createReturnIssueLine,
|
||||
getReturnIssueLine,
|
||||
updateReturnIssueLine,
|
||||
} from '#/api/mes/wm/returnissue/line';
|
||||
import { $t } from '#/locales';
|
||||
|
||||
import { useLineFormSchema } from '../data';
|
||||
|
||||
const emit = defineEmits(['success']);
|
||||
const formData = ref<MesWmReturnIssueLineApi.ReturnIssueLine>();
|
||||
const issueId = 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 MesWmReturnIssueLineApi.ReturnIssueLine;
|
||||
data.issueId = issueId.value;
|
||||
try {
|
||||
await (formData.value?.id
|
||||
? updateReturnIssueLine({ ...data, id: formData.value.id })
|
||||
: createReturnIssueLine(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; issueId: number }>();
|
||||
issueId.value = data.issueId;
|
||||
if (!data.id) {
|
||||
return;
|
||||
}
|
||||
modalApi.lock();
|
||||
try {
|
||||
formData.value = await getReturnIssueLine(data.id);
|
||||
// 设置到 values
|
||||
await formApi.setValues(formData.value);
|
||||
} finally {
|
||||
modalApi.unlock();
|
||||
}
|
||||
},
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Modal :title="getTitle" class="w-3/5">
|
||||
<Form class="mx-4" />
|
||||
</Modal>
|
||||
</template>
|
||||
|
|
@ -0,0 +1,249 @@
|
|||
<script lang="ts" setup>
|
||||
import type { VxeTableGridOptions } from '#/adapter/vxe-table';
|
||||
import type { MesWmReturnIssueDetailApi } from '#/api/mes/wm/returnissue/detail';
|
||||
import type { MesWmReturnIssueLineApi } from '#/api/mes/wm/returnissue/line';
|
||||
|
||||
import { computed, reactive, ref } from 'vue';
|
||||
|
||||
import { useVbenModal } from '@vben/common-ui';
|
||||
|
||||
import { ElLoading, ElMessage } from 'element-plus';
|
||||
|
||||
import { ACTION_ICON, TableAction, useVbenVxeGrid } from '#/adapter/vxe-table';
|
||||
import { getReturnIssueDetailListByLineId } from '#/api/mes/wm/returnissue/detail';
|
||||
import {
|
||||
deleteReturnIssueLine,
|
||||
getReturnIssueLinePage,
|
||||
} from '#/api/mes/wm/returnissue/line';
|
||||
import { $t } from '#/locales';
|
||||
import { BarcodeBizTypeEnum } from '#/views/mes/utils/constants';
|
||||
import { BarcodeDetail, 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;
|
||||
issueId: number;
|
||||
}>();
|
||||
|
||||
const isEditable = computed(() => // 是否可编辑明细行
|
||||
['create', 'update'].includes(props.formType),
|
||||
);
|
||||
const isStock = computed(() => props.formType === 'stock'); // 是否为入库上架模式
|
||||
const detailMap = reactive<
|
||||
Record<number, MesWmReturnIssueDetailApi.ReturnIssueDetail[]>
|
||||
>({}); // 已展开行的上架明细缓存
|
||||
const barcodeDetailRef = ref(); // 条码详情弹窗实例
|
||||
|
||||
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({ issueId: props.issueId }).open();
|
||||
}
|
||||
|
||||
/** 编辑物料 */
|
||||
function handleEdit(row: MesWmReturnIssueLineApi.ReturnIssueLine) {
|
||||
lineFormModalApi.setData({ id: row.id, issueId: props.issueId }).open();
|
||||
}
|
||||
|
||||
/** 删除物料 */
|
||||
async function handleDelete(row: MesWmReturnIssueLineApi.ReturnIssueLine) {
|
||||
const loadingInstance = ElLoading.service({
|
||||
text: $t('ui.actionMessage.deleting', [row.itemName]),
|
||||
});
|
||||
try {
|
||||
await deleteReturnIssueLine(row.id!);
|
||||
ElMessage.success($t('ui.actionMessage.deleteSuccess', [row.itemName]));
|
||||
handleRefresh();
|
||||
} finally {
|
||||
loadingInstance.close();
|
||||
}
|
||||
}
|
||||
|
||||
/** 上架:直接打开明细创建表单 */
|
||||
function handlePicking(row: MesWmReturnIssueLineApi.ReturnIssueLine) {
|
||||
openDetailForm(row.id!, row.itemId);
|
||||
}
|
||||
|
||||
/** 查看物料条码 */
|
||||
function handleBarcode(row: MesWmReturnIssueLineApi.ReturnIssueLine) {
|
||||
barcodeDetailRef.value?.openByBusiness(
|
||||
row.itemId,
|
||||
BarcodeBizTypeEnum.ITEM,
|
||||
row.itemCode,
|
||||
row.itemName,
|
||||
);
|
||||
}
|
||||
|
||||
/** 打开上架明细表单 */
|
||||
function openDetailForm(lineId: number, itemId?: number, detailId?: number) {
|
||||
detailFormModalApi
|
||||
.setData({ detailId, issueId: props.issueId, itemId, lineId })
|
||||
.open();
|
||||
}
|
||||
|
||||
/** 获取已展开行的上架明细 */
|
||||
function getExpandedDetails(row: MesWmReturnIssueLineApi.ReturnIssueLine) {
|
||||
return detailMap[row.id!] || [];
|
||||
}
|
||||
|
||||
/** 加载指定行的上架明细 */
|
||||
async function loadLineDetails(lineId: number) {
|
||||
detailMap[lineId] = await getReturnIssueDetailListByLineId(lineId);
|
||||
}
|
||||
|
||||
/** 展开行时懒加载上架明细 */
|
||||
async function handleExpandChange(
|
||||
row: MesWmReturnIssueLineApi.ReturnIssueLine,
|
||||
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 ({ page }) => {
|
||||
if (!props.issueId) {
|
||||
return { list: [], total: 0 };
|
||||
}
|
||||
return await getReturnIssueLinePage({
|
||||
issueId: props.issueId,
|
||||
pageNo: page.currentPage,
|
||||
pageSize: page.pageSize,
|
||||
});
|
||||
},
|
||||
},
|
||||
},
|
||||
rowConfig: {
|
||||
keyField: 'id',
|
||||
isHover: true,
|
||||
},
|
||||
toolbarConfig: {
|
||||
refresh: true,
|
||||
},
|
||||
} as VxeTableGridOptions<MesWmReturnIssueLineApi.ReturnIssueLine>,
|
||||
gridEvents: {
|
||||
toggleRowExpand: ({
|
||||
expanded,
|
||||
row,
|
||||
}: {
|
||||
expanded: boolean;
|
||||
row: MesWmReturnIssueLineApi.ReturnIssueLine;
|
||||
}) => {
|
||||
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 }">
|
||||
<div class="flex items-center justify-center">
|
||||
<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: handlePicking.bind(null, row),
|
||||
},
|
||||
{
|
||||
label: '条码',
|
||||
type: 'primary',
|
||||
link: true,
|
||||
onClick: handleBarcode.bind(null, row),
|
||||
},
|
||||
]"
|
||||
/>
|
||||
<PrinterLabel
|
||||
v-if="isStock"
|
||||
:biz-code="row.batchCode"
|
||||
:biz-id="row.batchId"
|
||||
biz-type="BATCH"
|
||||
/>
|
||||
</div>
|
||||
</template>
|
||||
</Grid>
|
||||
<BarcodeDetail ref="barcodeDetailRef" />
|
||||
</div>
|
||||
</template>
|
||||
|
|
@ -0,0 +1,521 @@
|
|||
import type { VbenFormApi, VbenFormSchema } from '#/adapter/form';
|
||||
import type { VxeTableGridOptions } from '#/adapter/vxe-table';
|
||||
import type { MesWmReturnSalesApi } from '#/api/mes/wm/returnsales';
|
||||
import type { MesWmReturnSalesDetailApi } from '#/api/mes/wm/returnsales/detail';
|
||||
import type { MesWmReturnSalesLineApi } from '#/api/mes/wm/returnsales/line';
|
||||
|
||||
import { h, markRaw } from 'vue';
|
||||
|
||||
import { DICT_TYPE } from '@vben/constants';
|
||||
import { getDictOptions } from '@vben/hooks';
|
||||
|
||||
import { ElButton } from 'element-plus';
|
||||
|
||||
import { z } from '#/adapter/form';
|
||||
import { generateAutoCode } from '#/api/mes/md/autocode/record';
|
||||
import MdClientSelect from '#/views/mes/md/client/components/md-client-select.vue';
|
||||
import MdItemSelect from '#/views/mes/md/item/components/md-item-select.vue';
|
||||
import { MesAutoCodeRuleCode } from '#/views/mes/utils/constants';
|
||||
import { WmBatchSelect } from '#/views/mes/wm/batch/components';
|
||||
import {
|
||||
WmWarehouseAreaSelect,
|
||||
WmWarehouseLocationSelect,
|
||||
WmWarehouseSelect,
|
||||
} from '#/views/mes/wm/warehouse/components';
|
||||
|
||||
/** 表单类型 */
|
||||
export type FormType = 'create' | 'detail' | 'finish' | 'stock' | 'update';
|
||||
|
||||
/** 表单头部是否只读(上架、详情、执行退货态) */
|
||||
function isHeaderReadonly(formType: FormType): boolean {
|
||||
return (
|
||||
formType === 'detail' || formType === 'finish' || formType === 'stock'
|
||||
);
|
||||
}
|
||||
|
||||
/** 新增/修改的表单 */
|
||||
export function useFormSchema(
|
||||
formType: FormType,
|
||||
formApi?: VbenFormApi,
|
||||
): VbenFormSchema[] {
|
||||
return [
|
||||
{
|
||||
fieldName: 'id',
|
||||
component: 'Input',
|
||||
dependencies: {
|
||||
triggerFields: [''],
|
||||
show: () => false,
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldName: 'status',
|
||||
component: 'Input',
|
||||
dependencies: {
|
||||
triggerFields: [''],
|
||||
show: () => false,
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldName: 'code',
|
||||
label: '退货单编号',
|
||||
component: 'Input',
|
||||
componentProps: {
|
||||
placeholder: '请输入退货单编号',
|
||||
},
|
||||
rules: 'required',
|
||||
suffix: isHeaderReadonly(formType)
|
||||
? undefined
|
||||
: () =>
|
||||
h(
|
||||
ElButton,
|
||||
{
|
||||
onClick: async () => {
|
||||
const code = await generateAutoCode(
|
||||
MesAutoCodeRuleCode.WM_RETURN_SALES_CODE,
|
||||
);
|
||||
await formApi?.setFieldValue('code', code);
|
||||
},
|
||||
},
|
||||
{ default: () => '生成' },
|
||||
),
|
||||
},
|
||||
{
|
||||
fieldName: 'name',
|
||||
label: '退货单名称',
|
||||
component: 'Input',
|
||||
componentProps: {
|
||||
placeholder: '请输入退货单名称',
|
||||
},
|
||||
rules: 'required',
|
||||
},
|
||||
{
|
||||
fieldName: 'salesOrderCode',
|
||||
label: '销售订单号',
|
||||
component: 'Input',
|
||||
componentProps: {
|
||||
placeholder: '请输入销售订单号',
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldName: 'clientId',
|
||||
label: '客户',
|
||||
component: markRaw(MdClientSelect),
|
||||
componentProps: {
|
||||
placeholder: '请选择客户',
|
||||
},
|
||||
rules: 'selectRequired',
|
||||
},
|
||||
{
|
||||
fieldName: 'returnDate',
|
||||
label: '退货日期',
|
||||
component: 'DatePicker',
|
||||
componentProps: {
|
||||
class: '!w-full',
|
||||
format: 'YYYY-MM-DD',
|
||||
placeholder: '请选择退货日期',
|
||||
type: 'date',
|
||||
valueFormat: 'x',
|
||||
},
|
||||
rules: 'required',
|
||||
},
|
||||
{
|
||||
fieldName: 'returnReason',
|
||||
label: '退货原因',
|
||||
component: 'Textarea',
|
||||
formItemClass: 'col-span-3',
|
||||
componentProps: {
|
||||
placeholder: '请输入退货原因',
|
||||
rows: 2,
|
||||
},
|
||||
rules: 'required',
|
||||
},
|
||||
{
|
||||
fieldName: 'remark',
|
||||
label: '备注',
|
||||
component: 'Textarea',
|
||||
formItemClass: 'col-span-3',
|
||||
componentProps: {
|
||||
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: 'salesOrderCode',
|
||||
label: '销售订单号',
|
||||
component: 'Input',
|
||||
componentProps: {
|
||||
clearable: true,
|
||||
placeholder: '请输入销售订单号',
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldName: 'clientId',
|
||||
label: '客户',
|
||||
component: markRaw(MdClientSelect),
|
||||
componentProps: {
|
||||
placeholder: '请选择客户',
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldName: 'status',
|
||||
label: '单据状态',
|
||||
component: 'Select',
|
||||
componentProps: {
|
||||
clearable: true,
|
||||
options: getDictOptions(DICT_TYPE.MES_WM_RETURN_SALES_STATUS, 'number'),
|
||||
placeholder: '请选择单据状态',
|
||||
},
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
/** 列表的字段 */
|
||||
export function useGridColumns(): VxeTableGridOptions<MesWmReturnSalesApi.ReturnSales>['columns'] {
|
||||
return [
|
||||
{
|
||||
field: 'code',
|
||||
title: '退货单编号',
|
||||
minWidth: 160,
|
||||
slots: { default: 'code' },
|
||||
},
|
||||
{
|
||||
field: 'name',
|
||||
title: '退货单名称',
|
||||
minWidth: 150,
|
||||
},
|
||||
{
|
||||
field: 'salesOrderCode',
|
||||
title: '销售订单号',
|
||||
minWidth: 140,
|
||||
},
|
||||
{
|
||||
field: 'clientCode',
|
||||
title: '客户编码',
|
||||
minWidth: 120,
|
||||
},
|
||||
{
|
||||
field: 'clientName',
|
||||
title: '客户名称',
|
||||
minWidth: 150,
|
||||
},
|
||||
{
|
||||
field: 'returnReason',
|
||||
title: '退货原因',
|
||||
minWidth: 150,
|
||||
},
|
||||
{
|
||||
field: 'returnDate',
|
||||
title: '退货日期',
|
||||
width: 180,
|
||||
formatter: 'formatDate',
|
||||
},
|
||||
{
|
||||
field: 'status',
|
||||
title: '单据状态',
|
||||
minWidth: 110,
|
||||
cellRender: {
|
||||
name: 'CellDict',
|
||||
props: { type: DICT_TYPE.MES_WM_RETURN_SALES_STATUS },
|
||||
},
|
||||
},
|
||||
{
|
||||
title: '操作',
|
||||
width: 240,
|
||||
fixed: 'right',
|
||||
slots: { default: 'actions' },
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
/** 退货单行子表的字段 */
|
||||
export function useLineGridColumns(
|
||||
editable: boolean,
|
||||
stockable: boolean,
|
||||
): VxeTableGridOptions<MesWmReturnSalesLineApi.ReturnSalesLine>['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: 'rqcCheckFlag',
|
||||
title: '是否需要质检',
|
||||
width: 120,
|
||||
cellRender: {
|
||||
name: 'CellDict',
|
||||
props: { type: DICT_TYPE.INFRA_BOOLEAN_STRING },
|
||||
},
|
||||
},
|
||||
{
|
||||
field: 'qualityStatus',
|
||||
title: '质量状态',
|
||||
width: 100,
|
||||
cellRender: {
|
||||
name: 'CellDict',
|
||||
props: { type: DICT_TYPE.MES_WM_QUALITY_STATUS },
|
||||
},
|
||||
},
|
||||
...(editable || stockable
|
||||
? [
|
||||
{
|
||||
title: '操作',
|
||||
width: 160,
|
||||
fixed: 'right',
|
||||
slots: { default: 'actions' },
|
||||
} as const,
|
||||
]
|
||||
: []),
|
||||
];
|
||||
}
|
||||
|
||||
/** 退货单行新增/修改的表单 */
|
||||
export function useLineFormSchema(
|
||||
clientId?: number,
|
||||
salesOrderCode?: string,
|
||||
): VbenFormSchema[] {
|
||||
return [
|
||||
{
|
||||
fieldName: 'itemId',
|
||||
label: '物料',
|
||||
component: markRaw(MdItemSelect),
|
||||
componentProps: {
|
||||
placeholder: '请选择物料',
|
||||
},
|
||||
rules: 'selectRequired',
|
||||
},
|
||||
{
|
||||
fieldName: 'quantity',
|
||||
label: '退货数量',
|
||||
component: 'InputNumber',
|
||||
componentProps: {
|
||||
class: '!w-full',
|
||||
controlsPosition: 'right',
|
||||
min: 0,
|
||||
placeholder: '请输入退货数量',
|
||||
precision: 2,
|
||||
},
|
||||
rules: 'required',
|
||||
},
|
||||
{
|
||||
fieldName: 'batchId',
|
||||
label: '批次',
|
||||
component: markRaw(WmBatchSelect),
|
||||
componentProps: {
|
||||
clientId,
|
||||
placeholder: '请选择批次',
|
||||
salesOrderCode,
|
||||
},
|
||||
dependencies: {
|
||||
triggerFields: ['itemId'],
|
||||
componentProps: (values) => ({
|
||||
clientId,
|
||||
itemId: values.itemId,
|
||||
placeholder: '请选择批次',
|
||||
salesOrderCode,
|
||||
}),
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldName: 'rqcCheckFlag',
|
||||
label: '需要质检',
|
||||
component: 'Switch',
|
||||
rules: z.boolean().default(true),
|
||||
},
|
||||
{
|
||||
fieldName: 'remark',
|
||||
label: '备注',
|
||||
component: 'Textarea',
|
||||
formItemClass: 'col-span-3',
|
||||
componentProps: {
|
||||
placeholder: '请输入备注',
|
||||
rows: 3,
|
||||
},
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
/** 上架明细子表的字段 */
|
||||
export function useDetailGridColumns(
|
||||
stockable: boolean,
|
||||
): VxeTableGridOptions<MesWmReturnSalesDetailApi.ReturnSalesDetail>['columns'] {
|
||||
return [
|
||||
{
|
||||
field: 'batchCode',
|
||||
title: '批次号',
|
||||
minWidth: 120,
|
||||
},
|
||||
{
|
||||
field: 'warehouseName',
|
||||
title: '仓库名称',
|
||||
minWidth: 100,
|
||||
},
|
||||
{
|
||||
field: 'locationName',
|
||||
title: '库区名称',
|
||||
minWidth: 100,
|
||||
},
|
||||
{
|
||||
field: 'areaName',
|
||||
title: '库位名称',
|
||||
minWidth: 100,
|
||||
},
|
||||
{
|
||||
field: 'quantity',
|
||||
title: '数量',
|
||||
width: 100,
|
||||
},
|
||||
...(stockable
|
||||
? [
|
||||
{
|
||||
title: '操作',
|
||||
width: 120,
|
||||
fixed: 'right',
|
||||
slots: { default: 'actions' },
|
||||
} as const,
|
||||
]
|
||||
: []),
|
||||
];
|
||||
}
|
||||
|
||||
/** 上架明细新增/修改的表单 */
|
||||
export function useDetailFormSchema(formApi?: VbenFormApi): VbenFormSchema[] {
|
||||
return [
|
||||
{
|
||||
fieldName: 'itemId',
|
||||
label: '物料',
|
||||
component: markRaw(MdItemSelect),
|
||||
componentProps: {
|
||||
disabled: true,
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldName: 'warehouseId',
|
||||
label: '入库仓库',
|
||||
component: markRaw(WmWarehouseSelect),
|
||||
componentProps: {
|
||||
// 切换仓库后清空库区和库位
|
||||
onChange: async () => {
|
||||
await formApi?.setValues({
|
||||
areaId: undefined,
|
||||
locationId: undefined,
|
||||
});
|
||||
},
|
||||
placeholder: '请选择仓库',
|
||||
},
|
||||
rules: 'selectRequired',
|
||||
},
|
||||
{
|
||||
fieldName: 'locationId',
|
||||
label: '库区',
|
||||
component: markRaw(WmWarehouseLocationSelect),
|
||||
componentProps: {
|
||||
placeholder: '请选择库区',
|
||||
},
|
||||
rules: 'selectRequired',
|
||||
dependencies: {
|
||||
triggerFields: ['warehouseId'],
|
||||
componentProps: (values) => ({
|
||||
// 切换库区后清空库位
|
||||
onChange: async () => {
|
||||
await formApi?.setFieldValue('areaId', undefined);
|
||||
},
|
||||
placeholder: '请选择库区',
|
||||
warehouseId: values.warehouseId,
|
||||
}),
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldName: 'areaId',
|
||||
label: '库位',
|
||||
component: markRaw(WmWarehouseAreaSelect),
|
||||
componentProps: {
|
||||
placeholder: '请选择库位',
|
||||
},
|
||||
rules: 'selectRequired',
|
||||
dependencies: {
|
||||
triggerFields: ['locationId'],
|
||||
componentProps: (values) => ({
|
||||
locationId: values.locationId,
|
||||
placeholder: '请选择库位',
|
||||
}),
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldName: 'batchCode',
|
||||
label: '批次号',
|
||||
component: 'Input',
|
||||
componentProps: {
|
||||
placeholder: '请输入批次号',
|
||||
},
|
||||
rules: 'required',
|
||||
},
|
||||
{
|
||||
fieldName: 'quantity',
|
||||
label: '数量',
|
||||
component: 'InputNumber',
|
||||
componentProps: {
|
||||
class: '!w-full',
|
||||
controlsPosition: 'right',
|
||||
min: 0,
|
||||
placeholder: '请输入数量',
|
||||
precision: 2,
|
||||
},
|
||||
rules: 'required',
|
||||
},
|
||||
];
|
||||
}
|
||||
|
|
@ -0,0 +1,224 @@
|
|||
<script lang="ts" setup>
|
||||
import type { VxeTableGridOptions } from '#/adapter/vxe-table';
|
||||
import type { MesWmReturnSalesApi } from '#/api/mes/wm/returnsales';
|
||||
|
||||
import { DocAlert, Page, useVbenModal } from '@vben/common-ui';
|
||||
import { downloadFileFromBlobPart } from '@vben/utils';
|
||||
|
||||
import { ElButton, ElLoading, ElMessage } from 'element-plus';
|
||||
|
||||
import { ACTION_ICON, TableAction, useVbenVxeGrid } from '#/adapter/vxe-table';
|
||||
import {
|
||||
cancelReturnSales,
|
||||
deleteReturnSales,
|
||||
exportReturnSales,
|
||||
getReturnSalesPage,
|
||||
} from '#/api/mes/wm/returnsales';
|
||||
import { $t } from '#/locales';
|
||||
import { MesWmReturnSalesStatusEnum } 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: MesWmReturnSalesApi.ReturnSales) {
|
||||
formModalApi.setData({ formType: 'detail', id: row.id }).open();
|
||||
}
|
||||
|
||||
/** 编辑销售退货单 */
|
||||
function handleEdit(row: MesWmReturnSalesApi.ReturnSales) {
|
||||
formModalApi.setData({ formType: 'update', id: row.id }).open();
|
||||
}
|
||||
|
||||
/** 执行上架 */
|
||||
function handleStock(row: MesWmReturnSalesApi.ReturnSales) {
|
||||
formModalApi.setData({ formType: 'stock', id: row.id }).open();
|
||||
}
|
||||
|
||||
/** 执行退货 */
|
||||
function handleFinish(row: MesWmReturnSalesApi.ReturnSales) {
|
||||
formModalApi.setData({ formType: 'finish', id: row.id }).open();
|
||||
}
|
||||
|
||||
/** 提示前往质检模块 */
|
||||
function handleQc() {
|
||||
ElMessage.info('请前往【质量管理 - 退货检验(RQC)】中进行退货检验操作');
|
||||
}
|
||||
|
||||
/** 删除销售退货单 */
|
||||
async function handleDelete(row: MesWmReturnSalesApi.ReturnSales) {
|
||||
const loadingInstance = ElLoading.service({
|
||||
text: $t('ui.actionMessage.deleting', [row.code]),
|
||||
});
|
||||
try {
|
||||
await deleteReturnSales(row.id!);
|
||||
ElMessage.success($t('ui.actionMessage.deleteSuccess', [row.code]));
|
||||
handleRefresh();
|
||||
} finally {
|
||||
loadingInstance.close();
|
||||
}
|
||||
}
|
||||
|
||||
/** 取消销售退货单 */
|
||||
async function handleCancel(row: MesWmReturnSalesApi.ReturnSales) {
|
||||
await cancelReturnSales(row.id!);
|
||||
ElMessage.success('取消成功');
|
||||
handleRefresh();
|
||||
}
|
||||
|
||||
/** 导出表格 */
|
||||
async function handleExport() {
|
||||
const data = await exportReturnSales(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 getReturnSalesPage({
|
||||
pageNo: page.currentPage,
|
||||
pageSize: page.pageSize,
|
||||
...formValues,
|
||||
});
|
||||
},
|
||||
},
|
||||
},
|
||||
rowConfig: {
|
||||
keyField: 'id',
|
||||
isHover: true,
|
||||
},
|
||||
toolbarConfig: {
|
||||
refresh: true,
|
||||
search: true,
|
||||
},
|
||||
} as VxeTableGridOptions<MesWmReturnSalesApi.ReturnSales>,
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Page auto-content-height>
|
||||
<template #doc>
|
||||
<DocAlert
|
||||
title="【仓库】发货通知、销售出库、销售退货"
|
||||
url="https://doc.iocoder.cn/mes/wm/sales-out/"
|
||||
/>
|
||||
</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-return-sales:create'],
|
||||
onClick: handleCreate,
|
||||
},
|
||||
{
|
||||
label: $t('ui.actionTitle.export'),
|
||||
type: 'primary',
|
||||
icon: ACTION_ICON.DOWNLOAD,
|
||||
auth: ['mes:wm-return-sales:export'],
|
||||
onClick: handleExport,
|
||||
},
|
||||
]"
|
||||
/>
|
||||
</template>
|
||||
<template #code="{ row }">
|
||||
<ElButton link type="primary" @click="handleDetail(row)">
|
||||
{{ row.code }}
|
||||
</ElButton>
|
||||
</template>
|
||||
<template #actions="{ row }">
|
||||
<TableAction
|
||||
:actions="[
|
||||
{
|
||||
label: $t('common.edit'),
|
||||
type: 'primary',
|
||||
link: true,
|
||||
icon: ACTION_ICON.EDIT,
|
||||
auth: ['mes:wm-return-sales:update'],
|
||||
ifShow: row.status === MesWmReturnSalesStatusEnum.PREPARE,
|
||||
onClick: handleEdit.bind(null, row),
|
||||
},
|
||||
{
|
||||
label: $t('common.delete'),
|
||||
type: 'danger',
|
||||
link: true,
|
||||
icon: ACTION_ICON.DELETE,
|
||||
auth: ['mes:wm-return-sales:delete'],
|
||||
ifShow: row.status === MesWmReturnSalesStatusEnum.PREPARE,
|
||||
popConfirm: {
|
||||
title: $t('ui.actionMessage.deleteConfirm', [row.code]),
|
||||
confirm: handleDelete.bind(null, row),
|
||||
},
|
||||
},
|
||||
{
|
||||
label: '执行质检',
|
||||
type: 'primary',
|
||||
link: true,
|
||||
ifShow: row.status === MesWmReturnSalesStatusEnum.CONFIRMED,
|
||||
onClick: handleQc,
|
||||
},
|
||||
{
|
||||
label: '执行退货',
|
||||
type: 'primary',
|
||||
link: true,
|
||||
auth: ['mes:wm-return-sales:finish'],
|
||||
ifShow: row.status === MesWmReturnSalesStatusEnum.APPROVING,
|
||||
onClick: handleFinish.bind(null, row),
|
||||
},
|
||||
{
|
||||
label: '执行上架',
|
||||
type: 'primary',
|
||||
link: true,
|
||||
auth: ['mes:wm-return-sales:stock'],
|
||||
ifShow: row.status === MesWmReturnSalesStatusEnum.APPROVED,
|
||||
onClick: handleStock.bind(null, row),
|
||||
},
|
||||
{
|
||||
label: '取消',
|
||||
type: 'danger',
|
||||
link: true,
|
||||
auth: ['mes:wm-return-sales:cancel'],
|
||||
ifShow:
|
||||
row.status === MesWmReturnSalesStatusEnum.CONFIRMED ||
|
||||
row.status === MesWmReturnSalesStatusEnum.APPROVING ||
|
||||
row.status === MesWmReturnSalesStatusEnum.APPROVED,
|
||||
popConfirm: {
|
||||
title: '确认取消该销售退货单?取消后不可恢复。',
|
||||
confirm: handleCancel.bind(null, row),
|
||||
},
|
||||
},
|
||||
]"
|
||||
/>
|
||||
</template>
|
||||
</Grid>
|
||||
</Page>
|
||||
</template>
|
||||
|
|
@ -0,0 +1,104 @@
|
|||
<script lang="ts" setup>
|
||||
import type { MesWmReturnSalesDetailApi } from '#/api/mes/wm/returnsales/detail';
|
||||
|
||||
import { computed, ref } from 'vue';
|
||||
|
||||
import { useVbenModal } from '@vben/common-ui';
|
||||
|
||||
import { ElMessage } from 'element-plus';
|
||||
|
||||
import { useVbenForm } from '#/adapter/form';
|
||||
import {
|
||||
createReturnSalesDetail,
|
||||
getReturnSalesDetail,
|
||||
updateReturnSalesDetail,
|
||||
} from '#/api/mes/wm/returnsales/detail';
|
||||
import { $t } from '#/locales';
|
||||
|
||||
import { useDetailFormSchema } from '../data';
|
||||
|
||||
const emit = defineEmits<{ success: [lineId: number] }>();
|
||||
const formData = ref<MesWmReturnSalesDetailApi.ReturnSalesDetail>();
|
||||
const returnId = 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-1',
|
||||
labelWidth: 90,
|
||||
},
|
||||
layout: 'horizontal',
|
||||
schema: useDetailFormSchema(),
|
||||
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 MesWmReturnSalesDetailApi.ReturnSalesDetail;
|
||||
data.returnId = returnId.value;
|
||||
data.lineId = lineId.value;
|
||||
try {
|
||||
await (formData.value?.id
|
||||
? updateReturnSalesDetail({ ...data, id: formData.value.id })
|
||||
: createReturnSalesDetail(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;
|
||||
}
|
||||
formApi.setState({ schema: useDetailFormSchema(formApi) });
|
||||
// 加载数据
|
||||
const data = modalApi.getData<{
|
||||
detailId?: number;
|
||||
itemId?: number;
|
||||
lineId: number;
|
||||
returnId: number;
|
||||
}>();
|
||||
returnId.value = data.returnId;
|
||||
lineId.value = data.lineId;
|
||||
if (data.detailId) {
|
||||
modalApi.lock();
|
||||
try {
|
||||
formData.value = await getReturnSalesDetail(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-3/5">
|
||||
<Form class="mx-4" />
|
||||
</Modal>
|
||||
</template>
|
||||
|
|
@ -0,0 +1,103 @@
|
|||
<script lang="ts" setup>
|
||||
import type { VxeTableGridOptions } from '#/adapter/vxe-table';
|
||||
import type { MesWmReturnSalesDetailApi } from '#/api/mes/wm/returnsales/detail';
|
||||
|
||||
import { computed, watch } from 'vue';
|
||||
|
||||
import { ElLoading, ElMessage } from 'element-plus';
|
||||
|
||||
import { ACTION_ICON, TableAction, useVbenVxeGrid } from '#/adapter/vxe-table';
|
||||
import { deleteReturnSalesDetail } from '#/api/mes/wm/returnsales/detail';
|
||||
import { $t } from '#/locales';
|
||||
|
||||
import { type FormType, useDetailGridColumns } from '../data';
|
||||
|
||||
const props = defineProps<{
|
||||
details: MesWmReturnSalesDetailApi.ReturnSalesDetail[];
|
||||
formType: FormType;
|
||||
}>();
|
||||
|
||||
const emit = defineEmits<{
|
||||
edit: [detailId: number];
|
||||
refresh: [];
|
||||
}>();
|
||||
|
||||
const isStock = computed(() => props.formType === 'stock'); // 是否为上架模式
|
||||
|
||||
/** 编辑上架明细 */
|
||||
function handleEdit(row: MesWmReturnSalesDetailApi.ReturnSalesDetail) {
|
||||
emit('edit', row.id!);
|
||||
}
|
||||
|
||||
/** 删除上架明细 */
|
||||
async function handleDelete(
|
||||
row: MesWmReturnSalesDetailApi.ReturnSalesDetail,
|
||||
) {
|
||||
const loadingInstance = ElLoading.service({
|
||||
text: $t('ui.actionMessage.deleting', [row.warehouseName]),
|
||||
});
|
||||
try {
|
||||
await deleteReturnSalesDetail(row.id!);
|
||||
ElMessage.success($t('ui.actionMessage.deleteSuccess', [row.warehouseName]));
|
||||
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<MesWmReturnSalesDetailApi.ReturnSalesDetail>,
|
||||
});
|
||||
|
||||
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.warehouseName,
|
||||
]),
|
||||
confirm: handleDelete.bind(null, row),
|
||||
},
|
||||
},
|
||||
]"
|
||||
/>
|
||||
</template>
|
||||
</Grid>
|
||||
</div>
|
||||
</template>
|
||||
|
|
@ -0,0 +1,242 @@
|
|||
<script lang="ts" setup>
|
||||
import type { FormType } from '../data';
|
||||
|
||||
import type { MesWmReturnSalesApi } from '#/api/mes/wm/returnsales';
|
||||
|
||||
import { computed, ref } from 'vue';
|
||||
|
||||
import { useVbenModal } from '@vben/common-ui';
|
||||
|
||||
import { ElButton, ElDivider, ElMessage, ElPopconfirm } from 'element-plus';
|
||||
|
||||
import { useVbenForm } from '#/adapter/form';
|
||||
import {
|
||||
createReturnSales,
|
||||
finishReturnSales,
|
||||
getReturnSales,
|
||||
stockReturnSales,
|
||||
submitReturnSales,
|
||||
updateReturnSales,
|
||||
} from '#/api/mes/wm/returnsales';
|
||||
import { $t } from '#/locales';
|
||||
import { MesWmReturnSalesStatusEnum } 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<MesWmReturnSalesApi.ReturnSales>();
|
||||
const originalSnapshot = ref(''); // 表单原始数据快照,用于提交时跳过未变更的保存请求
|
||||
const isEditable = computed(() => // 是否为编辑模式(可保存)
|
||||
['create', 'update'].includes(formType.value),
|
||||
);
|
||||
const isStock = computed(() => formType.value === 'stock'); // 是否为上架模式
|
||||
const isFinish = computed(() => formType.value === 'finish'); // 是否为执行退货模式
|
||||
const canSubmit = computed(() => // 是否可提交
|
||||
formType.value === 'update' &&
|
||||
formData.value?.status === MesWmReturnSalesStatusEnum.PREPARE,
|
||||
);
|
||||
const getTitle = computed(() => {
|
||||
switch (formType.value) {
|
||||
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 MesWmReturnSalesApi.ReturnSales;
|
||||
await updateReturnSales({ ...formData.value, ...data });
|
||||
originalSnapshot.value = current;
|
||||
}
|
||||
await submitReturnSales(formData.value.id);
|
||||
ElMessage.success('提交成功');
|
||||
await modalApi.close();
|
||||
emit('success');
|
||||
} finally {
|
||||
modalApi.unlock();
|
||||
}
|
||||
}
|
||||
|
||||
/** 执行上架 */
|
||||
async function handleStock() {
|
||||
if (!formData.value?.id) {
|
||||
return;
|
||||
}
|
||||
modalApi.lock();
|
||||
try {
|
||||
await stockReturnSales(formData.value.id);
|
||||
ElMessage.success('上架成功');
|
||||
await modalApi.close();
|
||||
emit('success');
|
||||
} finally {
|
||||
modalApi.unlock();
|
||||
}
|
||||
}
|
||||
|
||||
/** 执行退货 */
|
||||
async function handleFinish() {
|
||||
if (!formData.value?.id) {
|
||||
return;
|
||||
}
|
||||
modalApi.lock();
|
||||
try {
|
||||
await finishReturnSales(formData.value.id);
|
||||
ElMessage.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 MesWmReturnSalesApi.ReturnSales;
|
||||
try {
|
||||
if (formData.value?.id) {
|
||||
await updateReturnSales({ ...formData.value, ...data });
|
||||
formData.value = { ...formData.value, ...data };
|
||||
} else {
|
||||
const id = await createReturnSales(data);
|
||||
formData.value = {
|
||||
...data,
|
||||
id,
|
||||
status: MesWmReturnSalesStatusEnum.PREPARE,
|
||||
};
|
||||
await formApi.setFieldValue('id', id);
|
||||
await formApi.setFieldValue('status', formData.value.status);
|
||||
formType.value = 'update';
|
||||
}
|
||||
originalSnapshot.value = JSON.stringify(await formApi.getValues());
|
||||
emit('success');
|
||||
ElMessage.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) });
|
||||
formApi.setDisabled(!isEditable.value);
|
||||
modalApi.setState({ showConfirmButton: isEditable.value });
|
||||
if (data?.id) {
|
||||
modalApi.lock();
|
||||
try {
|
||||
formData.value = await getReturnSales(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">
|
||||
<ElDivider>物料信息</ElDivider>
|
||||
<div class="mx-4">
|
||||
<LineList
|
||||
:client-id="formData.clientId"
|
||||
:form-type="formType"
|
||||
:return-id="formData.id"
|
||||
:sales-order-code="formData.salesOrderCode"
|
||||
/>
|
||||
</div>
|
||||
</template>
|
||||
<template #prepend-footer>
|
||||
<div class="flex flex-auto items-center gap-2">
|
||||
<ElPopconfirm
|
||||
v-if="canSubmit"
|
||||
title="确认提交该销售退货单?【提交后将不能修改】"
|
||||
width="260"
|
||||
@confirm="handleSubmit"
|
||||
>
|
||||
<template #reference>
|
||||
<ElButton type="primary">提交</ElButton>
|
||||
</template>
|
||||
</ElPopconfirm>
|
||||
<ElPopconfirm
|
||||
v-if="isStock"
|
||||
title="确认执行上架?"
|
||||
width="260"
|
||||
@confirm="handleStock"
|
||||
>
|
||||
<template #reference>
|
||||
<ElButton type="primary">执行上架</ElButton>
|
||||
</template>
|
||||
</ElPopconfirm>
|
||||
<ElPopconfirm
|
||||
v-if="isFinish"
|
||||
title="确认执行退货?执行后将进入待上架状态。"
|
||||
width="260"
|
||||
@confirm="handleFinish"
|
||||
>
|
||||
<template #reference>
|
||||
<ElButton type="primary">执行退货</ElButton>
|
||||
</template>
|
||||
</ElPopconfirm>
|
||||
</div>
|
||||
</template>
|
||||
</Modal>
|
||||
</template>
|
||||
|
|
@ -0,0 +1,102 @@
|
|||
<script lang="ts" setup>
|
||||
import type { MesWmReturnSalesLineApi } from '#/api/mes/wm/returnsales/line';
|
||||
|
||||
import { computed, ref } from 'vue';
|
||||
|
||||
import { useVbenModal } from '@vben/common-ui';
|
||||
|
||||
import { ElMessage } from 'element-plus';
|
||||
|
||||
import { useVbenForm } from '#/adapter/form';
|
||||
import {
|
||||
createReturnSalesLine,
|
||||
getReturnSalesLine,
|
||||
updateReturnSalesLine,
|
||||
} from '#/api/mes/wm/returnsales/line';
|
||||
import { $t } from '#/locales';
|
||||
|
||||
import { useLineFormSchema } from '../data';
|
||||
|
||||
const emit = defineEmits(['success']);
|
||||
const formData = ref<MesWmReturnSalesLineApi.ReturnSalesLine>();
|
||||
const returnId = 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 MesWmReturnSalesLineApi.ReturnSalesLine;
|
||||
data.returnId = returnId.value;
|
||||
try {
|
||||
await (formData.value?.id
|
||||
? updateReturnSalesLine({ ...data, id: formData.value.id })
|
||||
: createReturnSalesLine(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;
|
||||
}
|
||||
// 加载数据
|
||||
const data = modalApi.getData<{
|
||||
clientId?: number;
|
||||
id?: number;
|
||||
returnId: number;
|
||||
salesOrderCode?: string;
|
||||
}>();
|
||||
returnId.value = data.returnId;
|
||||
formApi.setState({
|
||||
schema: useLineFormSchema(data.clientId, data.salesOrderCode),
|
||||
});
|
||||
if (!data.id) {
|
||||
return;
|
||||
}
|
||||
modalApi.lock();
|
||||
try {
|
||||
formData.value = await getReturnSalesLine(data.id);
|
||||
// 设置到 values
|
||||
await formApi.setValues(formData.value);
|
||||
} finally {
|
||||
modalApi.unlock();
|
||||
}
|
||||
},
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Modal :title="getTitle" class="w-3/5">
|
||||
<Form class="mx-4" />
|
||||
</Modal>
|
||||
</template>
|
||||
|
|
@ -0,0 +1,245 @@
|
|||
<script lang="ts" setup>
|
||||
import type { VxeTableGridOptions } from '#/adapter/vxe-table';
|
||||
import type { MesWmReturnSalesDetailApi } from '#/api/mes/wm/returnsales/detail';
|
||||
import type { MesWmReturnSalesLineApi } from '#/api/mes/wm/returnsales/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 { getReturnSalesDetailListByLineId } from '#/api/mes/wm/returnsales/detail';
|
||||
import {
|
||||
deleteReturnSalesLine,
|
||||
getReturnSalesLinePage,
|
||||
} from '#/api/mes/wm/returnsales/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<{
|
||||
clientId?: number;
|
||||
formType: FormType;
|
||||
returnId: number;
|
||||
salesOrderCode?: string;
|
||||
}>();
|
||||
|
||||
const isEditable = computed(() => // 是否可编辑明细行
|
||||
['create', 'update'].includes(props.formType),
|
||||
);
|
||||
const isStock = computed(() => props.formType === 'stock'); // 是否为上架模式
|
||||
const detailMap = reactive<
|
||||
Record<number, MesWmReturnSalesDetailApi.ReturnSalesDetail[]>
|
||||
>({}); // 已展开行的上架明细缓存
|
||||
|
||||
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({
|
||||
clientId: props.clientId,
|
||||
returnId: props.returnId,
|
||||
salesOrderCode: props.salesOrderCode,
|
||||
})
|
||||
.open();
|
||||
}
|
||||
|
||||
/** 编辑物料 */
|
||||
function handleEdit(row: MesWmReturnSalesLineApi.ReturnSalesLine) {
|
||||
lineFormModalApi
|
||||
.setData({
|
||||
clientId: props.clientId,
|
||||
id: row.id,
|
||||
returnId: props.returnId,
|
||||
salesOrderCode: props.salesOrderCode,
|
||||
})
|
||||
.open();
|
||||
}
|
||||
|
||||
/** 删除物料 */
|
||||
async function handleDelete(row: MesWmReturnSalesLineApi.ReturnSalesLine) {
|
||||
const loadingInstance = ElLoading.service({
|
||||
text: $t('ui.actionMessage.deleting', [row.itemName]),
|
||||
});
|
||||
try {
|
||||
await deleteReturnSalesLine(row.id!);
|
||||
ElMessage.success($t('ui.actionMessage.deleteSuccess', [row.itemName]));
|
||||
handleRefresh();
|
||||
} finally {
|
||||
loadingInstance.close();
|
||||
}
|
||||
}
|
||||
|
||||
/** 上架:直接打开明细创建表单 */
|
||||
function handleStock(row: MesWmReturnSalesLineApi.ReturnSalesLine) {
|
||||
openDetailForm(row.id!, row.itemId);
|
||||
}
|
||||
|
||||
/** 打开上架明细表单 */
|
||||
function openDetailForm(lineId: number, itemId?: number, detailId?: number) {
|
||||
detailFormModalApi
|
||||
.setData({ detailId, itemId, lineId, returnId: props.returnId })
|
||||
.open();
|
||||
}
|
||||
|
||||
/** 获取已展开行的上架明细 */
|
||||
function getExpandedDetails(row: MesWmReturnSalesLineApi.ReturnSalesLine) {
|
||||
return detailMap[row.id!] || [];
|
||||
}
|
||||
|
||||
/** 加载指定行的上架明细 */
|
||||
async function loadLineDetails(lineId: number) {
|
||||
detailMap[lineId] = await getReturnSalesDetailListByLineId(lineId);
|
||||
}
|
||||
|
||||
/** 展开行时懒加载上架明细 */
|
||||
async function handleExpandChange(
|
||||
row: MesWmReturnSalesLineApi.ReturnSalesLine,
|
||||
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 ({ page }) => {
|
||||
if (!props.returnId) {
|
||||
return { list: [], total: 0 };
|
||||
}
|
||||
return await getReturnSalesLinePage({
|
||||
pageNo: page.currentPage,
|
||||
pageSize: page.pageSize,
|
||||
returnId: props.returnId,
|
||||
});
|
||||
},
|
||||
},
|
||||
},
|
||||
rowConfig: {
|
||||
keyField: 'id',
|
||||
isHover: true,
|
||||
},
|
||||
toolbarConfig: {
|
||||
refresh: true,
|
||||
},
|
||||
} as VxeTableGridOptions<MesWmReturnSalesLineApi.ReturnSalesLine>,
|
||||
gridEvents: {
|
||||
toggleRowExpand: ({
|
||||
expanded,
|
||||
row,
|
||||
}: {
|
||||
expanded: boolean;
|
||||
row: MesWmReturnSalesLineApi.ReturnSalesLine;
|
||||
}) => {
|
||||
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 }">
|
||||
<div class="flex items-center justify-center">
|
||||
<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"
|
||||
/>
|
||||
</div>
|
||||
</template>
|
||||
</Grid>
|
||||
</div>
|
||||
</template>
|
||||
|
|
@ -0,0 +1,535 @@
|
|||
import type { VbenFormApi, VbenFormSchema } from '#/adapter/form';
|
||||
import type { VxeTableGridOptions } from '#/adapter/vxe-table';
|
||||
import type { MesWmMaterialStockApi } from '#/api/mes/wm/materialstock';
|
||||
import type { MesWmReturnVendorApi } from '#/api/mes/wm/returnvendor';
|
||||
import type { MesWmReturnVendorDetailApi } from '#/api/mes/wm/returnvendor/detail';
|
||||
import type { MesWmReturnVendorLineApi } from '#/api/mes/wm/returnvendor/line';
|
||||
|
||||
import { h, markRaw } from 'vue';
|
||||
|
||||
import { DICT_TYPE } from '@vben/constants';
|
||||
|
||||
import { ElButton } from 'element-plus';
|
||||
|
||||
import { generateAutoCode } from '#/api/mes/md/autocode/record';
|
||||
import MdItemSelect from '#/views/mes/md/item/components/md-item-select.vue';
|
||||
import MdVendorSelect from '#/views/mes/md/vendor/components/md-vendor-select.vue';
|
||||
import { MesAutoCodeRuleCode } from '#/views/mes/utils/constants';
|
||||
import { WmBatchSelect } from '#/views/mes/wm/batch/components';
|
||||
import { WmMaterialStockSelect } from '#/views/mes/wm/materialstock/components';
|
||||
import {
|
||||
WmWarehouseAreaSelect,
|
||||
WmWarehouseLocationSelect,
|
||||
WmWarehouseSelect,
|
||||
} from '#/views/mes/wm/warehouse/components';
|
||||
|
||||
/** 表单类型 */
|
||||
export type FormType = 'create' | 'detail' | 'finish' | 'stock' | 'update';
|
||||
|
||||
/** 表单头部是否只读(拣货、详情、完成态) */
|
||||
function isHeaderReadonly(formType: FormType): boolean {
|
||||
return (
|
||||
formType === 'detail' || formType === 'finish' || formType === 'stock'
|
||||
);
|
||||
}
|
||||
|
||||
/** 新增/修改的表单 */
|
||||
export function useFormSchema(
|
||||
formType: FormType,
|
||||
formApi?: VbenFormApi,
|
||||
): VbenFormSchema[] {
|
||||
return [
|
||||
{
|
||||
fieldName: 'id',
|
||||
component: 'Input',
|
||||
dependencies: {
|
||||
triggerFields: [''],
|
||||
show: () => false,
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldName: 'status',
|
||||
component: 'Input',
|
||||
dependencies: {
|
||||
triggerFields: [''],
|
||||
show: () => false,
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldName: 'code',
|
||||
label: '退货单编号',
|
||||
component: 'Input',
|
||||
componentProps: {
|
||||
placeholder: '请输入退货单编号',
|
||||
},
|
||||
rules: 'required',
|
||||
suffix: isHeaderReadonly(formType)
|
||||
? undefined
|
||||
: () =>
|
||||
h(
|
||||
ElButton,
|
||||
{
|
||||
onClick: async () => {
|
||||
const code = await generateAutoCode(
|
||||
MesAutoCodeRuleCode.WM_RETURN_VENDOR_CODE,
|
||||
);
|
||||
await formApi?.setFieldValue('code', code);
|
||||
},
|
||||
},
|
||||
{ default: () => '生成' },
|
||||
),
|
||||
},
|
||||
{
|
||||
fieldName: 'name',
|
||||
label: '退货单名称',
|
||||
component: 'Input',
|
||||
componentProps: {
|
||||
placeholder: '请输入退货单名称',
|
||||
},
|
||||
rules: 'required',
|
||||
},
|
||||
{
|
||||
fieldName: 'purchaseOrderCode',
|
||||
label: '采购订单号',
|
||||
component: 'Input',
|
||||
componentProps: {
|
||||
placeholder: '请输入采购订单号',
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldName: 'vendorId',
|
||||
label: '供应商',
|
||||
component: markRaw(MdVendorSelect),
|
||||
componentProps: {
|
||||
placeholder: '请选择供应商',
|
||||
},
|
||||
rules: 'selectRequired',
|
||||
},
|
||||
{
|
||||
fieldName: 'returnDate',
|
||||
label: '退货日期',
|
||||
component: 'DatePicker',
|
||||
componentProps: {
|
||||
class: '!w-full',
|
||||
format: 'YYYY-MM-DD HH:mm:ss',
|
||||
placeholder: '请选择退货日期',
|
||||
type: 'datetime',
|
||||
valueFormat: 'x',
|
||||
},
|
||||
rules: 'required',
|
||||
},
|
||||
{
|
||||
fieldName: 'returnReason',
|
||||
label: '退货原因',
|
||||
component: 'Textarea',
|
||||
formItemClass: 'col-span-3',
|
||||
componentProps: {
|
||||
placeholder: '请输入退货原因',
|
||||
rows: 2,
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldName: 'transportCode',
|
||||
label: '运单号',
|
||||
component: 'Input',
|
||||
componentProps: {
|
||||
placeholder: '请输入运单号',
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldName: 'transportTelephone',
|
||||
label: '联系电话',
|
||||
component: 'Input',
|
||||
componentProps: {
|
||||
placeholder: '请输入联系电话',
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldName: 'remark',
|
||||
label: '备注',
|
||||
component: 'Textarea',
|
||||
formItemClass: 'col-span-3',
|
||||
componentProps: {
|
||||
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: 'purchaseOrderCode',
|
||||
label: '采购订单编号',
|
||||
component: 'Input',
|
||||
componentProps: {
|
||||
clearable: true,
|
||||
placeholder: '请输入采购订单编号',
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldName: 'vendorId',
|
||||
label: '供应商',
|
||||
component: markRaw(MdVendorSelect),
|
||||
componentProps: {
|
||||
placeholder: '请选择供应商',
|
||||
},
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
/** 列表的字段 */
|
||||
export function useGridColumns(): VxeTableGridOptions<MesWmReturnVendorApi.ReturnVendor>['columns'] {
|
||||
return [
|
||||
{
|
||||
field: 'code',
|
||||
title: '退货单编号',
|
||||
minWidth: 160,
|
||||
slots: { default: 'code' },
|
||||
},
|
||||
{
|
||||
field: 'name',
|
||||
title: '退货单名称',
|
||||
minWidth: 150,
|
||||
},
|
||||
{
|
||||
field: 'purchaseOrderCode',
|
||||
title: '采购订单号',
|
||||
minWidth: 140,
|
||||
},
|
||||
{
|
||||
field: 'vendorCode',
|
||||
title: '供应商编码',
|
||||
minWidth: 120,
|
||||
},
|
||||
{
|
||||
field: 'vendorName',
|
||||
title: '供应商名称',
|
||||
minWidth: 150,
|
||||
},
|
||||
{
|
||||
field: 'returnDate',
|
||||
title: '退货日期',
|
||||
width: 180,
|
||||
formatter: 'formatDateTime',
|
||||
},
|
||||
{
|
||||
field: 'status',
|
||||
title: '单据状态',
|
||||
minWidth: 110,
|
||||
cellRender: {
|
||||
name: 'CellDict',
|
||||
props: { type: DICT_TYPE.MES_WM_RETURN_VENDOR_STATUS },
|
||||
},
|
||||
},
|
||||
{
|
||||
title: '操作',
|
||||
width: 240,
|
||||
fixed: 'right',
|
||||
slots: { default: 'actions' },
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
/** 退货单行子表的字段 */
|
||||
export function useLineGridColumns(
|
||||
editable: boolean,
|
||||
stockable: boolean,
|
||||
): VxeTableGridOptions<MesWmReturnVendorLineApi.ReturnVendorLine>['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,
|
||||
},
|
||||
...(editable || stockable
|
||||
? [
|
||||
{
|
||||
title: '操作',
|
||||
width: 160,
|
||||
fixed: 'right',
|
||||
slots: { default: 'actions' },
|
||||
} as const,
|
||||
]
|
||||
: []),
|
||||
];
|
||||
}
|
||||
|
||||
/** 退货单行新增/修改的表单 */
|
||||
export function useLineFormSchema(
|
||||
vendorId?: number,
|
||||
formApi?: VbenFormApi,
|
||||
): VbenFormSchema[] {
|
||||
return [
|
||||
{
|
||||
fieldName: 'itemId',
|
||||
label: '产品物料',
|
||||
component: markRaw(MdItemSelect),
|
||||
componentProps: {
|
||||
placeholder: '请选择产品物料',
|
||||
},
|
||||
rules: 'selectRequired',
|
||||
},
|
||||
{
|
||||
fieldName: 'quantity',
|
||||
label: '退货数量',
|
||||
component: 'InputNumber',
|
||||
componentProps: {
|
||||
class: '!w-full',
|
||||
controlsPosition: 'right',
|
||||
min: 0,
|
||||
placeholder: '请输入退货数量',
|
||||
precision: 2,
|
||||
},
|
||||
rules: 'required',
|
||||
},
|
||||
{
|
||||
fieldName: 'batchId',
|
||||
label: '批次号',
|
||||
component: markRaw(WmBatchSelect),
|
||||
componentProps: {
|
||||
// 选择批次后同步批次号
|
||||
onChange: async (batch?: { code?: string }) => {
|
||||
await formApi?.setFieldValue('batchCode', batch?.code);
|
||||
},
|
||||
vendorId,
|
||||
},
|
||||
dependencies: {
|
||||
triggerFields: ['itemId'],
|
||||
componentProps: (values) => ({
|
||||
itemId: values.itemId,
|
||||
vendorId,
|
||||
}),
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldName: 'batchCode',
|
||||
component: 'Input',
|
||||
dependencies: {
|
||||
triggerFields: [''],
|
||||
show: () => false,
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldName: 'remark',
|
||||
label: '备注',
|
||||
component: 'Textarea',
|
||||
formItemClass: 'col-span-3',
|
||||
componentProps: {
|
||||
placeholder: '请输入备注',
|
||||
rows: 3,
|
||||
},
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
/** 拣货明细子表的字段 */
|
||||
export function useDetailGridColumns(
|
||||
stockable: boolean,
|
||||
): VxeTableGridOptions<MesWmReturnVendorDetailApi.ReturnVendorDetail>['columns'] {
|
||||
return [
|
||||
{
|
||||
field: 'batchCode',
|
||||
title: '批次号',
|
||||
minWidth: 120,
|
||||
},
|
||||
{
|
||||
field: 'warehouseName',
|
||||
title: '仓库名称',
|
||||
minWidth: 100,
|
||||
},
|
||||
{
|
||||
field: 'locationName',
|
||||
title: '库区名称',
|
||||
minWidth: 100,
|
||||
},
|
||||
{
|
||||
field: 'areaName',
|
||||
title: '库位名称',
|
||||
minWidth: 100,
|
||||
},
|
||||
{
|
||||
field: 'quantity',
|
||||
title: '数量',
|
||||
width: 100,
|
||||
},
|
||||
...(stockable
|
||||
? [
|
||||
{
|
||||
title: '操作',
|
||||
width: 120,
|
||||
fixed: 'right',
|
||||
slots: { default: 'actions' },
|
||||
} as const,
|
||||
]
|
||||
: []),
|
||||
];
|
||||
}
|
||||
|
||||
/** 拣货明细新增/修改的表单 */
|
||||
export function useDetailFormSchema(formApi?: VbenFormApi): VbenFormSchema[] {
|
||||
return [
|
||||
{
|
||||
fieldName: 'quantityMax',
|
||||
component: 'Input',
|
||||
dependencies: {
|
||||
triggerFields: [''],
|
||||
show: () => false,
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldName: 'itemId',
|
||||
label: '物料',
|
||||
component: markRaw(MdItemSelect),
|
||||
componentProps: {
|
||||
disabled: true,
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldName: 'materialStockId',
|
||||
label: '库存记录',
|
||||
component: markRaw(WmMaterialStockSelect),
|
||||
componentProps: {
|
||||
// 选择库存记录后,自动回填仓库/库区/库位/批次/数量
|
||||
onChange: async (stock?: MesWmMaterialStockApi.MaterialStock) => {
|
||||
await formApi?.setValues({
|
||||
areaId: stock?.areaId,
|
||||
batchCode: stock?.batchCode,
|
||||
batchId: stock?.batchId,
|
||||
locationId: stock?.locationId,
|
||||
quantity: stock?.quantity,
|
||||
quantityMax: stock?.quantity,
|
||||
warehouseId: stock?.warehouseId,
|
||||
});
|
||||
},
|
||||
},
|
||||
rules: 'selectRequired',
|
||||
dependencies: {
|
||||
triggerFields: ['itemId'],
|
||||
componentProps: (values) => ({
|
||||
itemId: values.itemId,
|
||||
}),
|
||||
},
|
||||
},
|
||||
{
|
||||
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: 'warehouseId',
|
||||
label: '仓库',
|
||||
component: markRaw(WmWarehouseSelect),
|
||||
componentProps: {
|
||||
disabled: true,
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldName: 'locationId',
|
||||
label: '库区',
|
||||
component: markRaw(WmWarehouseLocationSelect),
|
||||
componentProps: {
|
||||
disabled: true,
|
||||
},
|
||||
dependencies: {
|
||||
triggerFields: ['warehouseId'],
|
||||
componentProps: (values) => ({
|
||||
disabled: true,
|
||||
warehouseId: values.warehouseId,
|
||||
}),
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldName: 'areaId',
|
||||
label: '库位',
|
||||
component: markRaw(WmWarehouseAreaSelect),
|
||||
componentProps: {
|
||||
disabled: true,
|
||||
},
|
||||
dependencies: {
|
||||
triggerFields: ['locationId'],
|
||||
componentProps: (values) => ({
|
||||
disabled: true,
|
||||
locationId: values.locationId,
|
||||
}),
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldName: 'batchCode',
|
||||
label: '批次号',
|
||||
component: 'Input',
|
||||
componentProps: {
|
||||
disabled: true,
|
||||
},
|
||||
},
|
||||
];
|
||||
}
|
||||
|
|
@ -0,0 +1,211 @@
|
|||
<script lang="ts" setup>
|
||||
import type { VxeTableGridOptions } from '#/adapter/vxe-table';
|
||||
import type { MesWmReturnVendorApi } from '#/api/mes/wm/returnvendor';
|
||||
|
||||
import { DocAlert, Page, useVbenModal } from '@vben/common-ui';
|
||||
import { downloadFileFromBlobPart } from '@vben/utils';
|
||||
|
||||
import { ElButton, ElLoading, ElMessage } from 'element-plus';
|
||||
|
||||
import { ACTION_ICON, TableAction, useVbenVxeGrid } from '#/adapter/vxe-table';
|
||||
import {
|
||||
cancelReturnVendor,
|
||||
deleteReturnVendor,
|
||||
exportReturnVendor,
|
||||
getReturnVendorPage,
|
||||
} from '#/api/mes/wm/returnvendor';
|
||||
import { $t } from '#/locales';
|
||||
import { MesWmReturnVendorStatusEnum } 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: MesWmReturnVendorApi.ReturnVendor) {
|
||||
formModalApi.setData({ formType: 'detail', id: row.id }).open();
|
||||
}
|
||||
|
||||
/** 编辑供应商退货单 */
|
||||
function handleEdit(row: MesWmReturnVendorApi.ReturnVendor) {
|
||||
formModalApi.setData({ formType: 'update', id: row.id }).open();
|
||||
}
|
||||
|
||||
/** 执行拣货 */
|
||||
function handleStock(row: MesWmReturnVendorApi.ReturnVendor) {
|
||||
formModalApi.setData({ formType: 'stock', id: row.id }).open();
|
||||
}
|
||||
|
||||
/** 完成退货 */
|
||||
function handleFinish(row: MesWmReturnVendorApi.ReturnVendor) {
|
||||
formModalApi.setData({ formType: 'finish', id: row.id }).open();
|
||||
}
|
||||
|
||||
/** 删除供应商退货单 */
|
||||
async function handleDelete(row: MesWmReturnVendorApi.ReturnVendor) {
|
||||
const loadingInstance = ElLoading.service({
|
||||
text: $t('ui.actionMessage.deleting', [row.code]),
|
||||
});
|
||||
try {
|
||||
await deleteReturnVendor(row.id!);
|
||||
ElMessage.success($t('ui.actionMessage.deleteSuccess', [row.code]));
|
||||
handleRefresh();
|
||||
} finally {
|
||||
loadingInstance.close();
|
||||
}
|
||||
}
|
||||
|
||||
/** 取消供应商退货单 */
|
||||
async function handleCancel(row: MesWmReturnVendorApi.ReturnVendor) {
|
||||
await cancelReturnVendor(row.id!);
|
||||
ElMessage.success('取消成功');
|
||||
handleRefresh();
|
||||
}
|
||||
|
||||
/** 导出表格 */
|
||||
async function handleExport() {
|
||||
const data = await exportReturnVendor(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 getReturnVendorPage({
|
||||
pageNo: page.currentPage,
|
||||
pageSize: page.pageSize,
|
||||
...formValues,
|
||||
});
|
||||
},
|
||||
},
|
||||
},
|
||||
rowConfig: {
|
||||
keyField: 'id',
|
||||
isHover: true,
|
||||
},
|
||||
toolbarConfig: {
|
||||
refresh: true,
|
||||
search: true,
|
||||
},
|
||||
} as VxeTableGridOptions<MesWmReturnVendorApi.ReturnVendor>,
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Page auto-content-height>
|
||||
<template #doc>
|
||||
<DocAlert
|
||||
title="【仓库】到货通知、采购入库、采购退货"
|
||||
url="https://doc.iocoder.cn/mes/wm/purchase-in/"
|
||||
/>
|
||||
</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-return-vendor:create'],
|
||||
onClick: handleCreate,
|
||||
},
|
||||
{
|
||||
label: $t('ui.actionTitle.export'),
|
||||
type: 'primary',
|
||||
icon: ACTION_ICON.DOWNLOAD,
|
||||
auth: ['mes:wm-return-vendor:export'],
|
||||
onClick: handleExport,
|
||||
},
|
||||
]"
|
||||
/>
|
||||
</template>
|
||||
<template #code="{ row }">
|
||||
<ElButton link type="primary" @click="handleDetail(row)">
|
||||
{{ row.code }}
|
||||
</ElButton>
|
||||
</template>
|
||||
<template #actions="{ row }">
|
||||
<TableAction
|
||||
:actions="[
|
||||
{
|
||||
label: $t('common.edit'),
|
||||
type: 'primary',
|
||||
link: true,
|
||||
icon: ACTION_ICON.EDIT,
|
||||
auth: ['mes:wm-return-vendor:update'],
|
||||
ifShow: row.status === MesWmReturnVendorStatusEnum.PREPARE,
|
||||
onClick: handleEdit.bind(null, row),
|
||||
},
|
||||
{
|
||||
label: $t('common.delete'),
|
||||
type: 'danger',
|
||||
link: true,
|
||||
icon: ACTION_ICON.DELETE,
|
||||
auth: ['mes:wm-return-vendor:delete'],
|
||||
ifShow: row.status === MesWmReturnVendorStatusEnum.PREPARE,
|
||||
popConfirm: {
|
||||
title: $t('ui.actionMessage.deleteConfirm', [row.code]),
|
||||
confirm: handleDelete.bind(null, row),
|
||||
},
|
||||
},
|
||||
{
|
||||
label: '执行拣货',
|
||||
type: 'primary',
|
||||
link: true,
|
||||
auth: ['mes:wm-return-vendor:update'],
|
||||
ifShow: row.status === MesWmReturnVendorStatusEnum.APPROVING,
|
||||
onClick: handleStock.bind(null, row),
|
||||
},
|
||||
{
|
||||
label: '完成退货',
|
||||
type: 'primary',
|
||||
link: true,
|
||||
auth: ['mes:wm-return-vendor:update-status'],
|
||||
ifShow: row.status === MesWmReturnVendorStatusEnum.APPROVED,
|
||||
onClick: handleFinish.bind(null, row),
|
||||
},
|
||||
{
|
||||
label: '取消',
|
||||
type: 'danger',
|
||||
link: true,
|
||||
auth: ['mes:wm-return-vendor:update'],
|
||||
ifShow:
|
||||
row.status === MesWmReturnVendorStatusEnum.APPROVING ||
|
||||
row.status === MesWmReturnVendorStatusEnum.APPROVED,
|
||||
popConfirm: {
|
||||
title: '确认取消该供应商退货单?取消后不可恢复。',
|
||||
confirm: handleCancel.bind(null, row),
|
||||
},
|
||||
},
|
||||
]"
|
||||
/>
|
||||
</template>
|
||||
</Grid>
|
||||
</Page>
|
||||
</template>
|
||||
|
|
@ -0,0 +1,104 @@
|
|||
<script lang="ts" setup>
|
||||
import type { MesWmReturnVendorDetailApi } from '#/api/mes/wm/returnvendor/detail';
|
||||
|
||||
import { computed, ref } from 'vue';
|
||||
|
||||
import { useVbenModal } from '@vben/common-ui';
|
||||
|
||||
import { ElMessage } from 'element-plus';
|
||||
|
||||
import { useVbenForm } from '#/adapter/form';
|
||||
import {
|
||||
createReturnVendorDetail,
|
||||
getReturnVendorDetail,
|
||||
updateReturnVendorDetail,
|
||||
} from '#/api/mes/wm/returnvendor/detail';
|
||||
import { $t } from '#/locales';
|
||||
|
||||
import { useDetailFormSchema } from '../data';
|
||||
|
||||
const emit = defineEmits<{ success: [lineId: number] }>();
|
||||
const formData = ref<MesWmReturnVendorDetailApi.ReturnVendorDetail>();
|
||||
const returnId = 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-1',
|
||||
labelWidth: 90,
|
||||
},
|
||||
layout: 'horizontal',
|
||||
schema: useDetailFormSchema(),
|
||||
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 MesWmReturnVendorDetailApi.ReturnVendorDetail;
|
||||
data.returnId = returnId.value;
|
||||
data.lineId = lineId.value;
|
||||
try {
|
||||
await (formData.value?.id
|
||||
? updateReturnVendorDetail({ ...data, id: formData.value.id })
|
||||
: createReturnVendorDetail(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;
|
||||
}
|
||||
formApi.setState({ schema: useDetailFormSchema(formApi) });
|
||||
// 加载数据
|
||||
const data = modalApi.getData<{
|
||||
detailId?: number;
|
||||
itemId?: number;
|
||||
lineId: number;
|
||||
returnId: number;
|
||||
}>();
|
||||
returnId.value = data.returnId;
|
||||
lineId.value = data.lineId;
|
||||
if (data.detailId) {
|
||||
modalApi.lock();
|
||||
try {
|
||||
formData.value = await getReturnVendorDetail(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-3/5">
|
||||
<Form class="mx-4" />
|
||||
</Modal>
|
||||
</template>
|
||||
|
|
@ -0,0 +1,103 @@
|
|||
<script lang="ts" setup>
|
||||
import type { VxeTableGridOptions } from '#/adapter/vxe-table';
|
||||
import type { MesWmReturnVendorDetailApi } from '#/api/mes/wm/returnvendor/detail';
|
||||
|
||||
import { computed, watch } from 'vue';
|
||||
|
||||
import { ElLoading, ElMessage } from 'element-plus';
|
||||
|
||||
import { ACTION_ICON, TableAction, useVbenVxeGrid } from '#/adapter/vxe-table';
|
||||
import { deleteReturnVendorDetail } from '#/api/mes/wm/returnvendor/detail';
|
||||
import { $t } from '#/locales';
|
||||
|
||||
import { type FormType, useDetailGridColumns } from '../data';
|
||||
|
||||
const props = defineProps<{
|
||||
details: MesWmReturnVendorDetailApi.ReturnVendorDetail[];
|
||||
formType: FormType;
|
||||
}>();
|
||||
|
||||
const emit = defineEmits<{
|
||||
edit: [detailId: number];
|
||||
refresh: [];
|
||||
}>();
|
||||
|
||||
const isStock = computed(() => props.formType === 'stock'); // 是否为拣货模式
|
||||
|
||||
/** 编辑拣货明细 */
|
||||
function handleEdit(row: MesWmReturnVendorDetailApi.ReturnVendorDetail) {
|
||||
emit('edit', row.id!);
|
||||
}
|
||||
|
||||
/** 删除拣货明细 */
|
||||
async function handleDelete(
|
||||
row: MesWmReturnVendorDetailApi.ReturnVendorDetail,
|
||||
) {
|
||||
const loadingInstance = ElLoading.service({
|
||||
text: $t('ui.actionMessage.deleting', [row.warehouseName]),
|
||||
});
|
||||
try {
|
||||
await deleteReturnVendorDetail(row.id!);
|
||||
ElMessage.success($t('ui.actionMessage.deleteSuccess', [row.warehouseName]));
|
||||
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<MesWmReturnVendorDetailApi.ReturnVendorDetail>,
|
||||
});
|
||||
|
||||
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.warehouseName,
|
||||
]),
|
||||
confirm: handleDelete.bind(null, row),
|
||||
},
|
||||
},
|
||||
]"
|
||||
/>
|
||||
</template>
|
||||
</Grid>
|
||||
</div>
|
||||
</template>
|
||||
|
|
@ -0,0 +1,244 @@
|
|||
<script lang="ts" setup>
|
||||
import type { FormType } from '../data';
|
||||
|
||||
import type { MesWmReturnVendorApi } from '#/api/mes/wm/returnvendor';
|
||||
|
||||
import { computed, ref } from 'vue';
|
||||
|
||||
import { confirm, useVbenModal } from '@vben/common-ui';
|
||||
|
||||
import { ElButton, ElDivider, ElMessage, ElPopconfirm } from 'element-plus';
|
||||
|
||||
import { useVbenForm } from '#/adapter/form';
|
||||
import {
|
||||
checkReturnVendorQuantity,
|
||||
createReturnVendor,
|
||||
finishReturnVendor,
|
||||
getReturnVendor,
|
||||
stockReturnVendor,
|
||||
submitReturnVendor,
|
||||
updateReturnVendor,
|
||||
} from '#/api/mes/wm/returnvendor';
|
||||
import { $t } from '#/locales';
|
||||
import { MesWmReturnVendorStatusEnum } 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<MesWmReturnVendorApi.ReturnVendor>();
|
||||
const originalSnapshot = ref(''); // 表单原始数据快照,用于提交时跳过未变更的保存请求
|
||||
const isEditable = computed(() => // 是否为编辑模式(可保存)
|
||||
['create', 'update'].includes(formType.value),
|
||||
);
|
||||
const isStock = computed(() => formType.value === 'stock'); // 是否为拣货模式
|
||||
const isFinish = computed(() => formType.value === 'finish'); // 是否为完成退货模式
|
||||
const canSubmit = computed(() => // 是否可提交
|
||||
formType.value === 'update' &&
|
||||
formData.value?.status === MesWmReturnVendorStatusEnum.PREPARE,
|
||||
);
|
||||
const getTitle = computed(() => {
|
||||
switch (formType.value) {
|
||||
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 MesWmReturnVendorApi.ReturnVendor;
|
||||
await updateReturnVendor({ ...formData.value, ...data });
|
||||
originalSnapshot.value = current;
|
||||
}
|
||||
await submitReturnVendor(formData.value.id);
|
||||
ElMessage.success('提交成功');
|
||||
await modalApi.close();
|
||||
emit('success');
|
||||
} finally {
|
||||
modalApi.unlock();
|
||||
}
|
||||
}
|
||||
|
||||
/** 执行拣货:拣货数量与退货数量不一致时二次确认 */
|
||||
async function handleStock() {
|
||||
if (!formData.value?.id) {
|
||||
return;
|
||||
}
|
||||
const quantityMatch = await checkReturnVendorQuantity(formData.value.id);
|
||||
if (!quantityMatch) {
|
||||
try {
|
||||
await confirm('退货数量与拣货数量不一致,确认执行拣货?');
|
||||
} catch {
|
||||
return;
|
||||
}
|
||||
}
|
||||
modalApi.lock();
|
||||
try {
|
||||
await stockReturnVendor(formData.value.id);
|
||||
ElMessage.success('拣货成功');
|
||||
await modalApi.close();
|
||||
emit('success');
|
||||
} finally {
|
||||
modalApi.unlock();
|
||||
}
|
||||
}
|
||||
|
||||
/** 完成退货 */
|
||||
async function handleFinish() {
|
||||
if (!formData.value?.id) {
|
||||
return;
|
||||
}
|
||||
modalApi.lock();
|
||||
try {
|
||||
await finishReturnVendor(formData.value.id);
|
||||
ElMessage.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 MesWmReturnVendorApi.ReturnVendor;
|
||||
try {
|
||||
if (formData.value?.id) {
|
||||
await updateReturnVendor({ ...formData.value, ...data });
|
||||
formData.value = { ...formData.value, ...data };
|
||||
} else {
|
||||
const id = await createReturnVendor(data);
|
||||
formData.value = {
|
||||
...data,
|
||||
id,
|
||||
status: MesWmReturnVendorStatusEnum.PREPARE,
|
||||
};
|
||||
await formApi.setFieldValue('id', id);
|
||||
await formApi.setFieldValue('status', formData.value.status);
|
||||
formType.value = 'update';
|
||||
}
|
||||
originalSnapshot.value = JSON.stringify(await formApi.getValues());
|
||||
emit('success');
|
||||
ElMessage.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) });
|
||||
formApi.setDisabled(!isEditable.value);
|
||||
modalApi.setState({ showConfirmButton: isEditable.value });
|
||||
if (data?.id) {
|
||||
modalApi.lock();
|
||||
try {
|
||||
formData.value = await getReturnVendor(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">
|
||||
<ElDivider>物料信息</ElDivider>
|
||||
<div class="mx-4">
|
||||
<LineList
|
||||
:form-type="formType"
|
||||
:return-id="formData.id"
|
||||
:vendor-id="formData.vendorId"
|
||||
/>
|
||||
</div>
|
||||
</template>
|
||||
<template #prepend-footer>
|
||||
<div class="flex flex-auto items-center gap-2">
|
||||
<ElPopconfirm
|
||||
v-if="canSubmit"
|
||||
title="确认提交该退货单?【提交后将不能修改】"
|
||||
width="260"
|
||||
@confirm="handleSubmit"
|
||||
>
|
||||
<template #reference>
|
||||
<ElButton type="primary">提交</ElButton>
|
||||
</template>
|
||||
</ElPopconfirm>
|
||||
<ElButton v-if="isStock" type="primary" @click="handleStock">
|
||||
执行拣货
|
||||
</ElButton>
|
||||
<ElPopconfirm
|
||||
v-if="isFinish"
|
||||
title="确认完成该退货单并执行退货?"
|
||||
width="260"
|
||||
@confirm="handleFinish"
|
||||
>
|
||||
<template #reference>
|
||||
<ElButton type="primary">完成退货</ElButton>
|
||||
</template>
|
||||
</ElPopconfirm>
|
||||
</div>
|
||||
</template>
|
||||
</Modal>
|
||||
</template>
|
||||
|
|
@ -0,0 +1,99 @@
|
|||
<script lang="ts" setup>
|
||||
import type { MesWmReturnVendorLineApi } from '#/api/mes/wm/returnvendor/line';
|
||||
|
||||
import { computed, ref } from 'vue';
|
||||
|
||||
import { useVbenModal } from '@vben/common-ui';
|
||||
|
||||
import { ElMessage } from 'element-plus';
|
||||
|
||||
import { useVbenForm } from '#/adapter/form';
|
||||
import {
|
||||
createReturnVendorLine,
|
||||
getReturnVendorLine,
|
||||
updateReturnVendorLine,
|
||||
} from '#/api/mes/wm/returnvendor/line';
|
||||
import { $t } from '#/locales';
|
||||
|
||||
import { useLineFormSchema } from '../data';
|
||||
|
||||
const emit = defineEmits(['success']);
|
||||
const formData = ref<MesWmReturnVendorLineApi.ReturnVendorLine>();
|
||||
const returnId = 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 MesWmReturnVendorLineApi.ReturnVendorLine;
|
||||
data.returnId = returnId.value;
|
||||
try {
|
||||
await (formData.value?.id
|
||||
? updateReturnVendorLine({ ...data, id: formData.value.id })
|
||||
: createReturnVendorLine(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;
|
||||
}
|
||||
// 加载数据
|
||||
const data = modalApi.getData<{
|
||||
id?: number;
|
||||
returnId: number;
|
||||
vendorId?: number;
|
||||
}>();
|
||||
returnId.value = data.returnId;
|
||||
formApi.setState({ schema: useLineFormSchema(data.vendorId, formApi) });
|
||||
if (!data.id) {
|
||||
return;
|
||||
}
|
||||
modalApi.lock();
|
||||
try {
|
||||
formData.value = await getReturnVendorLine(data.id);
|
||||
// 设置到 values
|
||||
await formApi.setValues(formData.value);
|
||||
} finally {
|
||||
modalApi.unlock();
|
||||
}
|
||||
},
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Modal :title="getTitle" class="w-3/5">
|
||||
<Form class="mx-4" />
|
||||
</Modal>
|
||||
</template>
|
||||
|
|
@ -0,0 +1,235 @@
|
|||
<script lang="ts" setup>
|
||||
import type { VxeTableGridOptions } from '#/adapter/vxe-table';
|
||||
import type { MesWmReturnVendorDetailApi } from '#/api/mes/wm/returnvendor/detail';
|
||||
import type { MesWmReturnVendorLineApi } from '#/api/mes/wm/returnvendor/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 { getReturnVendorDetailListByLineId } from '#/api/mes/wm/returnvendor/detail';
|
||||
import {
|
||||
deleteReturnVendorLine,
|
||||
getReturnVendorLinePage,
|
||||
} from '#/api/mes/wm/returnvendor/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;
|
||||
returnId: number;
|
||||
vendorId?: number;
|
||||
}>();
|
||||
|
||||
const isEditable = computed(() => // 是否可编辑明细行
|
||||
['create', 'update'].includes(props.formType),
|
||||
);
|
||||
const isStock = computed(() => props.formType === 'stock'); // 是否为拣货模式
|
||||
const detailMap = reactive<
|
||||
Record<number, MesWmReturnVendorDetailApi.ReturnVendorDetail[]>
|
||||
>({}); // 已展开行的拣货明细缓存
|
||||
|
||||
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({ returnId: props.returnId, vendorId: props.vendorId })
|
||||
.open();
|
||||
}
|
||||
|
||||
/** 编辑物料 */
|
||||
function handleEdit(row: MesWmReturnVendorLineApi.ReturnVendorLine) {
|
||||
lineFormModalApi
|
||||
.setData({ id: row.id, returnId: props.returnId, vendorId: props.vendorId })
|
||||
.open();
|
||||
}
|
||||
|
||||
/** 删除物料 */
|
||||
async function handleDelete(row: MesWmReturnVendorLineApi.ReturnVendorLine) {
|
||||
const loadingInstance = ElLoading.service({
|
||||
text: $t('ui.actionMessage.deleting', [row.itemName]),
|
||||
});
|
||||
try {
|
||||
await deleteReturnVendorLine(row.id!);
|
||||
ElMessage.success($t('ui.actionMessage.deleteSuccess', [row.itemName]));
|
||||
handleRefresh();
|
||||
} finally {
|
||||
loadingInstance.close();
|
||||
}
|
||||
}
|
||||
|
||||
/** 拣货:直接打开明细创建表单 */
|
||||
function handlePicking(row: MesWmReturnVendorLineApi.ReturnVendorLine) {
|
||||
openDetailForm(row.id!, row.itemId);
|
||||
}
|
||||
|
||||
/** 打开拣货明细表单 */
|
||||
function openDetailForm(lineId: number, itemId?: number, detailId?: number) {
|
||||
detailFormModalApi
|
||||
.setData({ detailId, itemId, lineId, returnId: props.returnId })
|
||||
.open();
|
||||
}
|
||||
|
||||
/** 获取已展开行的拣货明细 */
|
||||
function getExpandedDetails(row: MesWmReturnVendorLineApi.ReturnVendorLine) {
|
||||
return detailMap[row.id!] || [];
|
||||
}
|
||||
|
||||
/** 加载指定行的拣货明细 */
|
||||
async function loadLineDetails(lineId: number) {
|
||||
detailMap[lineId] = await getReturnVendorDetailListByLineId(lineId);
|
||||
}
|
||||
|
||||
/** 展开行时懒加载拣货明细 */
|
||||
async function handleExpandChange(
|
||||
row: MesWmReturnVendorLineApi.ReturnVendorLine,
|
||||
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 ({ page }) => {
|
||||
if (!props.returnId) {
|
||||
return { list: [], total: 0 };
|
||||
}
|
||||
return await getReturnVendorLinePage({
|
||||
pageNo: page.currentPage,
|
||||
pageSize: page.pageSize,
|
||||
returnId: props.returnId,
|
||||
});
|
||||
},
|
||||
},
|
||||
},
|
||||
rowConfig: {
|
||||
keyField: 'id',
|
||||
isHover: true,
|
||||
},
|
||||
toolbarConfig: {
|
||||
refresh: true,
|
||||
},
|
||||
} as VxeTableGridOptions<MesWmReturnVendorLineApi.ReturnVendorLine>,
|
||||
gridEvents: {
|
||||
toggleRowExpand: ({
|
||||
expanded,
|
||||
row,
|
||||
}: {
|
||||
expanded: boolean;
|
||||
row: MesWmReturnVendorLineApi.ReturnVendorLine;
|
||||
}) => {
|
||||
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 }">
|
||||
<div class="flex items-center justify-center">
|
||||
<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: handlePicking.bind(null, row),
|
||||
},
|
||||
]"
|
||||
/>
|
||||
<PrinterLabel
|
||||
v-if="isStock"
|
||||
:biz-code="row.batchCode"
|
||||
:biz-id="row.batchId"
|
||||
biz-type="BATCH"
|
||||
/>
|
||||
</div>
|
||||
</template>
|
||||
</Grid>
|
||||
</div>
|
||||
</template>
|
||||
Loading…
Reference in New Issue