feat(mes): 迁移(wm-misc)相关迁移
parent
e09db73f73
commit
25bbe79cb2
|
|
@ -0,0 +1,453 @@
|
||||||
|
import type { VbenFormApi, VbenFormSchema } from '#/adapter/form';
|
||||||
|
import type { VxeTableGridOptions } from '#/adapter/vxe-table';
|
||||||
|
import type { MesWmMaterialStockApi } from '#/api/mes/wm/materialstock';
|
||||||
|
import type { MesWmMiscIssueApi } from '#/api/mes/wm/miscissue';
|
||||||
|
import type { MesWmMiscIssueLineApi } from '#/api/mes/wm/miscissue/line';
|
||||||
|
|
||||||
|
import { h, markRaw } from 'vue';
|
||||||
|
|
||||||
|
import { DICT_TYPE } from '@vben/constants';
|
||||||
|
import { getDictOptions } from '@vben/hooks';
|
||||||
|
|
||||||
|
import { Button } from 'ant-design-vue';
|
||||||
|
|
||||||
|
import { generateAutoCode } from '#/api/mes/md/autocode/record';
|
||||||
|
import { getRangePickerDefaultProps } from '#/utils';
|
||||||
|
import { MesAutoCodeRuleCode } 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' | 'update';
|
||||||
|
|
||||||
|
/** 表单头部是否只读(详情、执行出库态) */
|
||||||
|
function isHeaderReadonly(formType: FormType): boolean {
|
||||||
|
return formType === 'detail' || formType === 'finish';
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 新增/修改的表单 */
|
||||||
|
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_MISC_ISSUE_CODE,
|
||||||
|
);
|
||||||
|
await formApi?.setFieldValue('code', code);
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{ default: () => '生成' },
|
||||||
|
),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
fieldName: 'name',
|
||||||
|
label: '出库单名称',
|
||||||
|
component: 'Input',
|
||||||
|
componentProps: {
|
||||||
|
placeholder: '请输入出库单名称',
|
||||||
|
},
|
||||||
|
rules: 'required',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
fieldName: 'type',
|
||||||
|
label: '业务类型',
|
||||||
|
component: 'Select',
|
||||||
|
componentProps: {
|
||||||
|
options: getDictOptions(DICT_TYPE.MES_WM_MISC_ISSUE_TYPE, 'number'),
|
||||||
|
placeholder: '请选择业务类型',
|
||||||
|
},
|
||||||
|
rules: 'selectRequired',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
fieldName: 'issueDate',
|
||||||
|
label: '出库日期',
|
||||||
|
component: 'DatePicker',
|
||||||
|
componentProps: {
|
||||||
|
format: 'YYYY-MM-DD',
|
||||||
|
placeholder: '请选择出库日期',
|
||||||
|
valueFormat: 'x',
|
||||||
|
},
|
||||||
|
rules: 'required',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
fieldName: 'sourceDocType',
|
||||||
|
label: '来源单据类型',
|
||||||
|
component: 'Input',
|
||||||
|
componentProps: {
|
||||||
|
placeholder: '请输入来源单据类型',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
fieldName: 'sourceDocCode',
|
||||||
|
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: 'type',
|
||||||
|
label: '业务类型',
|
||||||
|
component: 'Select',
|
||||||
|
componentProps: {
|
||||||
|
allowClear: true,
|
||||||
|
options: getDictOptions(DICT_TYPE.MES_WM_MISC_ISSUE_TYPE, 'number'),
|
||||||
|
placeholder: '请选择业务类型',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
fieldName: 'sourceDocType',
|
||||||
|
label: '来源单据类型',
|
||||||
|
component: 'Input',
|
||||||
|
componentProps: {
|
||||||
|
allowClear: true,
|
||||||
|
placeholder: '请输入来源单据类型',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
fieldName: 'sourceDocCode',
|
||||||
|
label: '来源单据编号',
|
||||||
|
component: 'Input',
|
||||||
|
componentProps: {
|
||||||
|
allowClear: true,
|
||||||
|
placeholder: '请输入来源单据编号',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
fieldName: 'issueDate',
|
||||||
|
label: '出库日期',
|
||||||
|
component: 'RangePicker',
|
||||||
|
componentProps: {
|
||||||
|
...getRangePickerDefaultProps(),
|
||||||
|
allowClear: true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
fieldName: 'status',
|
||||||
|
label: '单据状态',
|
||||||
|
component: 'Select',
|
||||||
|
componentProps: {
|
||||||
|
allowClear: true,
|
||||||
|
options: getDictOptions(DICT_TYPE.MES_WM_MISC_ISSUE_STATUS, 'number'),
|
||||||
|
placeholder: '请选择单据状态',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 列表的字段 */
|
||||||
|
export function useGridColumns(): VxeTableGridOptions<MesWmMiscIssueApi.MiscIssue>['columns'] {
|
||||||
|
return [
|
||||||
|
{
|
||||||
|
field: 'code',
|
||||||
|
title: '出库单编号',
|
||||||
|
minWidth: 160,
|
||||||
|
slots: { default: 'code' },
|
||||||
|
},
|
||||||
|
{
|
||||||
|
field: 'name',
|
||||||
|
title: '出库单名称',
|
||||||
|
minWidth: 150,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
field: 'type',
|
||||||
|
title: '业务类型',
|
||||||
|
minWidth: 120,
|
||||||
|
cellRender: {
|
||||||
|
name: 'CellDict',
|
||||||
|
props: { type: DICT_TYPE.MES_WM_MISC_ISSUE_TYPE },
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
field: 'sourceDocType',
|
||||||
|
title: '来源单据类型',
|
||||||
|
minWidth: 120,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
field: 'sourceDocCode',
|
||||||
|
title: '来源单据编号',
|
||||||
|
minWidth: 150,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
field: 'issueDate',
|
||||||
|
title: '出库日期',
|
||||||
|
width: 180,
|
||||||
|
formatter: 'formatDate',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
field: 'status',
|
||||||
|
title: '单据状态',
|
||||||
|
minWidth: 100,
|
||||||
|
cellRender: {
|
||||||
|
name: 'CellDict',
|
||||||
|
props: { type: DICT_TYPE.MES_WM_MISC_ISSUE_STATUS },
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '操作',
|
||||||
|
width: 240,
|
||||||
|
fixed: 'right',
|
||||||
|
slots: { default: 'actions' },
|
||||||
|
},
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 出库单行子表的字段 */
|
||||||
|
export function useLineGridColumns(
|
||||||
|
editable = true,
|
||||||
|
): VxeTableGridOptions<MesWmMiscIssueLineApi.MiscIssueLine>['columns'] {
|
||||||
|
return [
|
||||||
|
{
|
||||||
|
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: 'warehouseName',
|
||||||
|
title: '仓库',
|
||||||
|
minWidth: 120,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
field: 'locationName',
|
||||||
|
title: '库区',
|
||||||
|
minWidth: 120,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
field: 'areaName',
|
||||||
|
title: '库位',
|
||||||
|
minWidth: 120,
|
||||||
|
},
|
||||||
|
...(editable
|
||||||
|
? [
|
||||||
|
{
|
||||||
|
title: '操作',
|
||||||
|
width: 120,
|
||||||
|
fixed: 'right',
|
||||||
|
slots: { default: 'actions' },
|
||||||
|
} as const,
|
||||||
|
]
|
||||||
|
: []),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 出库单行新增/修改的表单 */
|
||||||
|
export function useLineFormSchema(formApi?: VbenFormApi): VbenFormSchema[] {
|
||||||
|
return [
|
||||||
|
{
|
||||||
|
fieldName: 'itemId',
|
||||||
|
component: 'Input',
|
||||||
|
dependencies: {
|
||||||
|
triggerFields: [''],
|
||||||
|
show: () => false,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
fieldName: 'quantityMax',
|
||||||
|
component: 'Input',
|
||||||
|
dependencies: {
|
||||||
|
triggerFields: [''],
|
||||||
|
show: () => false,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
fieldName: 'materialStockId',
|
||||||
|
label: '库存物资',
|
||||||
|
component: markRaw(WmMaterialStockSelect),
|
||||||
|
componentProps: {
|
||||||
|
// 选择库存物资后,自动回填物料、批次号、仓库位置和最大可出库数量
|
||||||
|
onChange: async (stock?: MesWmMaterialStockApi.MaterialStock) => {
|
||||||
|
await formApi?.setValues({
|
||||||
|
areaId: stock?.areaId,
|
||||||
|
batchCode: stock?.batchCode,
|
||||||
|
itemId: stock?.itemId,
|
||||||
|
locationId: stock?.locationId,
|
||||||
|
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.01,
|
||||||
|
placeholder: '请输入出库数量',
|
||||||
|
precision: 2,
|
||||||
|
},
|
||||||
|
rules: 'required',
|
||||||
|
dependencies: {
|
||||||
|
triggerFields: ['quantityMax'],
|
||||||
|
componentProps: (values) => ({
|
||||||
|
class: '!w-full',
|
||||||
|
max: values.quantityMax,
|
||||||
|
min: 0.01,
|
||||||
|
placeholder: '请输入出库数量',
|
||||||
|
precision: 2,
|
||||||
|
}),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
fieldName: 'batchCode',
|
||||||
|
label: '批次号',
|
||||||
|
component: 'Input',
|
||||||
|
componentProps: {
|
||||||
|
disabled: true,
|
||||||
|
placeholder: '批次号',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
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: 'remark',
|
||||||
|
label: '备注',
|
||||||
|
component: 'Textarea',
|
||||||
|
formItemClass: 'col-span-3',
|
||||||
|
componentProps: {
|
||||||
|
placeholder: '请输入备注',
|
||||||
|
rows: 3,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,195 @@
|
||||||
|
<script lang="ts" setup>
|
||||||
|
import type { VxeTableGridOptions } from '#/adapter/vxe-table';
|
||||||
|
import type { MesWmMiscIssueApi } from '#/api/mes/wm/miscissue';
|
||||||
|
|
||||||
|
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 {
|
||||||
|
cancelMiscIssue,
|
||||||
|
deleteMiscIssue,
|
||||||
|
exportMiscIssue,
|
||||||
|
getMiscIssuePage,
|
||||||
|
} from '#/api/mes/wm/miscissue';
|
||||||
|
import { $t } from '#/locales';
|
||||||
|
import { MesWmMiscIssueStatusEnum } 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: MesWmMiscIssueApi.MiscIssue) {
|
||||||
|
formModalApi.setData({ formType: 'detail', id: row.id }).open();
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 编辑杂项出库单 */
|
||||||
|
function handleEdit(row: MesWmMiscIssueApi.MiscIssue) {
|
||||||
|
formModalApi.setData({ formType: 'update', id: row.id }).open();
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 执行出库 */
|
||||||
|
function handleFinish(row: MesWmMiscIssueApi.MiscIssue) {
|
||||||
|
formModalApi.setData({ formType: 'finish', id: row.id }).open();
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 删除杂项出库单 */
|
||||||
|
async function handleDelete(row: MesWmMiscIssueApi.MiscIssue) {
|
||||||
|
const hideLoading = message.loading({
|
||||||
|
content: $t('ui.actionMessage.deleting', [row.code]),
|
||||||
|
duration: 0,
|
||||||
|
});
|
||||||
|
try {
|
||||||
|
await deleteMiscIssue(row.id!);
|
||||||
|
message.success($t('ui.actionMessage.deleteSuccess', [row.code]));
|
||||||
|
handleRefresh();
|
||||||
|
} finally {
|
||||||
|
hideLoading();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 取消杂项出库单 */
|
||||||
|
async function handleCancel(row: MesWmMiscIssueApi.MiscIssue) {
|
||||||
|
await cancelMiscIssue(row.id!);
|
||||||
|
message.success('取消成功');
|
||||||
|
handleRefresh();
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 导出表格 */
|
||||||
|
async function handleExport() {
|
||||||
|
const data = await exportMiscIssue(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 getMiscIssuePage({
|
||||||
|
pageNo: page.currentPage,
|
||||||
|
pageSize: page.pageSize,
|
||||||
|
...formValues,
|
||||||
|
});
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
rowConfig: {
|
||||||
|
keyField: 'id',
|
||||||
|
isHover: true,
|
||||||
|
},
|
||||||
|
toolbarConfig: {
|
||||||
|
refresh: true,
|
||||||
|
search: true,
|
||||||
|
},
|
||||||
|
} as VxeTableGridOptions<MesWmMiscIssueApi.MiscIssue>,
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<Page auto-content-height>
|
||||||
|
<template #doc>
|
||||||
|
<DocAlert
|
||||||
|
title="【仓库】其他入库、其他出库"
|
||||||
|
url="https://doc.iocoder.cn/mes/wm/misc/"
|
||||||
|
/>
|
||||||
|
</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-misc-issue:create'],
|
||||||
|
onClick: handleCreate,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: $t('ui.actionTitle.export'),
|
||||||
|
type: 'primary',
|
||||||
|
icon: ACTION_ICON.DOWNLOAD,
|
||||||
|
auth: ['mes:wm-misc-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-misc-issue:update'],
|
||||||
|
ifShow: row.status === MesWmMiscIssueStatusEnum.PREPARE,
|
||||||
|
onClick: handleEdit.bind(null, row),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: $t('common.delete'),
|
||||||
|
type: 'link',
|
||||||
|
danger: true,
|
||||||
|
icon: ACTION_ICON.DELETE,
|
||||||
|
auth: ['mes:wm-misc-issue:delete'],
|
||||||
|
ifShow: row.status === MesWmMiscIssueStatusEnum.PREPARE,
|
||||||
|
popConfirm: {
|
||||||
|
title: $t('ui.actionMessage.deleteConfirm', [row.code]),
|
||||||
|
confirm: handleDelete.bind(null, row),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '执行出库',
|
||||||
|
type: 'link',
|
||||||
|
auth: ['mes:wm-misc-issue:finish'],
|
||||||
|
ifShow: row.status === MesWmMiscIssueStatusEnum.APPROVED,
|
||||||
|
onClick: handleFinish.bind(null, row),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '取消',
|
||||||
|
type: 'link',
|
||||||
|
danger: true,
|
||||||
|
auth: ['mes:wm-misc-issue:update'],
|
||||||
|
ifShow: row.status === MesWmMiscIssueStatusEnum.APPROVED,
|
||||||
|
popConfirm: {
|
||||||
|
title: '确认取消该杂项出库单?取消后不可恢复。',
|
||||||
|
confirm: handleCancel.bind(null, row),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
]"
|
||||||
|
/>
|
||||||
|
</template>
|
||||||
|
</Grid>
|
||||||
|
</Page>
|
||||||
|
</template>
|
||||||
|
|
@ -0,0 +1,194 @@
|
||||||
|
<script lang="ts" setup>
|
||||||
|
import type { FormType } from '../data';
|
||||||
|
|
||||||
|
import type { MesWmMiscIssueApi } from '#/api/mes/wm/miscissue';
|
||||||
|
|
||||||
|
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 {
|
||||||
|
createMiscIssue,
|
||||||
|
finishMiscIssue,
|
||||||
|
getMiscIssue,
|
||||||
|
submitMiscIssue,
|
||||||
|
updateMiscIssue,
|
||||||
|
} from '#/api/mes/wm/miscissue';
|
||||||
|
import { $t } from '#/locales';
|
||||||
|
import { MesWmMiscIssueStatusEnum } 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<MesWmMiscIssueApi.MiscIssue>();
|
||||||
|
const originalSnapshot = ref(''); // 表单原始数据快照,用于提交时跳过未变更的保存请求
|
||||||
|
const isEditable = computed(() => // 是否为编辑模式(可保存)
|
||||||
|
['create', 'update'].includes(formType.value),
|
||||||
|
);
|
||||||
|
const isFinish = computed(() => formType.value === 'finish'); // 是否为执行出库模式
|
||||||
|
const canSubmit = computed(() => // 是否可提交
|
||||||
|
formType.value === 'update' &&
|
||||||
|
formData.value?.status === MesWmMiscIssueStatusEnum.PREPARE,
|
||||||
|
);
|
||||||
|
const getTitle = computed(() => {
|
||||||
|
if (formType.value === 'detail') {
|
||||||
|
return $t('ui.actionTitle.view', ['杂项出库单']);
|
||||||
|
}
|
||||||
|
if (formType.value === 'finish') {
|
||||||
|
return '执行出库';
|
||||||
|
}
|
||||||
|
return formType.value === 'update'
|
||||||
|
? $t('ui.actionTitle.edit', ['杂项出库单'])
|
||||||
|
: $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 MesWmMiscIssueApi.MiscIssue;
|
||||||
|
await updateMiscIssue({ ...formData.value, ...data });
|
||||||
|
originalSnapshot.value = current;
|
||||||
|
}
|
||||||
|
await submitMiscIssue(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 finishMiscIssue(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 MesWmMiscIssueApi.MiscIssue;
|
||||||
|
try {
|
||||||
|
if (formData.value?.id) {
|
||||||
|
await updateMiscIssue({ ...formData.value, ...data });
|
||||||
|
formData.value = { ...formData.value, ...data };
|
||||||
|
} else {
|
||||||
|
const id = await createMiscIssue(data);
|
||||||
|
formData.value = {
|
||||||
|
...data,
|
||||||
|
id,
|
||||||
|
status: MesWmMiscIssueStatusEnum.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(formType.value === 'detail' || formType.value === 'finish');
|
||||||
|
modalApi.setState({ showConfirmButton: isEditable.value });
|
||||||
|
if (data?.id) {
|
||||||
|
modalApi.lock();
|
||||||
|
try {
|
||||||
|
formData.value = await getMiscIssue(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>
|
||||||
|
<Popconfirm
|
||||||
|
v-if="isFinish"
|
||||||
|
title="确认执行出库?执行后将更新库存台账。"
|
||||||
|
@confirm="handleFinish"
|
||||||
|
>
|
||||||
|
<Button type="primary">执行出库</Button>
|
||||||
|
</Popconfirm>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
</Modal>
|
||||||
|
</template>
|
||||||
|
|
@ -0,0 +1,97 @@
|
||||||
|
<script lang="ts" setup>
|
||||||
|
import type { MesWmMiscIssueLineApi } from '#/api/mes/wm/miscissue/line';
|
||||||
|
|
||||||
|
import { computed, ref } from 'vue';
|
||||||
|
|
||||||
|
import { useVbenModal } from '@vben/common-ui';
|
||||||
|
|
||||||
|
import { message } from 'ant-design-vue';
|
||||||
|
|
||||||
|
import { useVbenForm } from '#/adapter/form';
|
||||||
|
import {
|
||||||
|
createMiscIssueLine,
|
||||||
|
getMiscIssueLine,
|
||||||
|
updateMiscIssueLine,
|
||||||
|
} from '#/api/mes/wm/miscissue/line';
|
||||||
|
import { $t } from '#/locales';
|
||||||
|
|
||||||
|
import { useLineFormSchema } from '../data';
|
||||||
|
|
||||||
|
const emit = defineEmits(['success']);
|
||||||
|
const formData = ref<MesWmMiscIssueLineApi.MiscIssueLine>();
|
||||||
|
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: useLineFormSchema(),
|
||||||
|
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 MesWmMiscIssueLineApi.MiscIssueLine;
|
||||||
|
data.issueId = issueId.value;
|
||||||
|
try {
|
||||||
|
await (formData.value?.id
|
||||||
|
? updateMiscIssueLine({ ...data, id: formData.value.id })
|
||||||
|
: createMiscIssueLine(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 getMiscIssueLine(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,137 @@
|
||||||
|
<script lang="ts" setup>
|
||||||
|
import type { VxeTableGridOptions } from '#/adapter/vxe-table';
|
||||||
|
import type { MesWmMiscIssueLineApi } from '#/api/mes/wm/miscissue/line';
|
||||||
|
|
||||||
|
import { computed } from 'vue';
|
||||||
|
|
||||||
|
import { useVbenModal } from '@vben/common-ui';
|
||||||
|
|
||||||
|
import { message } from 'ant-design-vue';
|
||||||
|
|
||||||
|
import { ACTION_ICON, TableAction, useVbenVxeGrid } from '#/adapter/vxe-table';
|
||||||
|
import {
|
||||||
|
deleteMiscIssueLine,
|
||||||
|
getMiscIssueLinePage,
|
||||||
|
} from '#/api/mes/wm/miscissue/line';
|
||||||
|
import { $t } from '#/locales';
|
||||||
|
|
||||||
|
import { type FormType, useLineGridColumns } from '../data';
|
||||||
|
import LineForm from './line-form.vue';
|
||||||
|
|
||||||
|
const props = defineProps<{
|
||||||
|
formType: FormType;
|
||||||
|
issueId: number;
|
||||||
|
}>();
|
||||||
|
|
||||||
|
const isEditable = computed(() => // 是否可编辑明细行
|
||||||
|
['create', 'update'].includes(props.formType),
|
||||||
|
);
|
||||||
|
|
||||||
|
const [LineFormModal, lineFormModalApi] = useVbenModal({
|
||||||
|
connectedComponent: LineForm,
|
||||||
|
destroyOnClose: true,
|
||||||
|
});
|
||||||
|
|
||||||
|
/** 刷新表格 */
|
||||||
|
function handleRefresh() {
|
||||||
|
gridApi.query();
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 添加物料 */
|
||||||
|
function handleCreate() {
|
||||||
|
lineFormModalApi.setData({ issueId: props.issueId }).open();
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 编辑物料 */
|
||||||
|
function handleEdit(row: MesWmMiscIssueLineApi.MiscIssueLine) {
|
||||||
|
lineFormModalApi.setData({ id: row.id, issueId: props.issueId }).open();
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 删除物料 */
|
||||||
|
async function handleDelete(row: MesWmMiscIssueLineApi.MiscIssueLine) {
|
||||||
|
const hideLoading = message.loading({
|
||||||
|
content: $t('ui.actionMessage.deleting', [row.itemName]),
|
||||||
|
duration: 0,
|
||||||
|
});
|
||||||
|
try {
|
||||||
|
await deleteMiscIssueLine(row.id!);
|
||||||
|
message.success($t('ui.actionMessage.deleteSuccess', [row.itemName]));
|
||||||
|
handleRefresh();
|
||||||
|
} finally {
|
||||||
|
hideLoading();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const [Grid, gridApi] = useVbenVxeGrid({
|
||||||
|
gridOptions: {
|
||||||
|
columns: useLineGridColumns(isEditable.value),
|
||||||
|
height: 360,
|
||||||
|
keepSource: true,
|
||||||
|
proxyConfig: {
|
||||||
|
ajax: {
|
||||||
|
query: async ({ page }) => {
|
||||||
|
if (!props.issueId) {
|
||||||
|
return { list: [], total: 0 };
|
||||||
|
}
|
||||||
|
return await getMiscIssueLinePage({
|
||||||
|
issueId: props.issueId,
|
||||||
|
pageNo: page.currentPage,
|
||||||
|
pageSize: page.pageSize,
|
||||||
|
});
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
rowConfig: {
|
||||||
|
keyField: 'id',
|
||||||
|
isHover: true,
|
||||||
|
},
|
||||||
|
toolbarConfig: {
|
||||||
|
refresh: true,
|
||||||
|
},
|
||||||
|
} as VxeTableGridOptions<MesWmMiscIssueLineApi.MiscIssueLine>,
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<div>
|
||||||
|
<LineFormModal @success="handleRefresh" />
|
||||||
|
<Grid table-title="物料信息">
|
||||||
|
<template v-if="isEditable" #toolbar-tools>
|
||||||
|
<TableAction
|
||||||
|
:actions="[
|
||||||
|
{
|
||||||
|
label: '添加物料',
|
||||||
|
type: 'primary',
|
||||||
|
icon: ACTION_ICON.ADD,
|
||||||
|
onClick: handleCreate,
|
||||||
|
},
|
||||||
|
]"
|
||||||
|
/>
|
||||||
|
</template>
|
||||||
|
<template #actions="{ row }">
|
||||||
|
<TableAction
|
||||||
|
:actions="[
|
||||||
|
{
|
||||||
|
label: $t('common.edit'),
|
||||||
|
type: 'link',
|
||||||
|
icon: ACTION_ICON.EDIT,
|
||||||
|
ifShow: isEditable,
|
||||||
|
onClick: handleEdit.bind(null, row),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: $t('common.delete'),
|
||||||
|
type: 'link',
|
||||||
|
danger: true,
|
||||||
|
icon: ACTION_ICON.DELETE,
|
||||||
|
ifShow: isEditable,
|
||||||
|
popConfirm: {
|
||||||
|
title: $t('ui.actionMessage.deleteConfirm', [row.itemName]),
|
||||||
|
confirm: handleDelete.bind(null, row),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
]"
|
||||||
|
/>
|
||||||
|
</template>
|
||||||
|
</Grid>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
@ -0,0 +1,423 @@
|
||||||
|
import type { VbenFormApi, VbenFormSchema } from '#/adapter/form';
|
||||||
|
import type { VxeTableGridOptions } from '#/adapter/vxe-table';
|
||||||
|
import type { MesWmMiscReceiptApi } from '#/api/mes/wm/miscreceipt';
|
||||||
|
import type { MesWmMiscReceiptLineApi } from '#/api/mes/wm/miscreceipt/line';
|
||||||
|
|
||||||
|
import { h, markRaw } from 'vue';
|
||||||
|
|
||||||
|
import { DICT_TYPE } from '@vben/constants';
|
||||||
|
import { getDictOptions } from '@vben/hooks';
|
||||||
|
|
||||||
|
import { Button } from 'ant-design-vue';
|
||||||
|
|
||||||
|
import { generateAutoCode } from '#/api/mes/md/autocode/record';
|
||||||
|
import { getRangePickerDefaultProps } from '#/utils';
|
||||||
|
import { MdItemSelect } from '#/views/mes/md/item/components';
|
||||||
|
import { MesAutoCodeRuleCode } from '#/views/mes/utils/constants';
|
||||||
|
import {
|
||||||
|
WmWarehouseAreaSelect,
|
||||||
|
WmWarehouseLocationSelect,
|
||||||
|
WmWarehouseSelect,
|
||||||
|
} from '#/views/mes/wm/warehouse/components';
|
||||||
|
|
||||||
|
/** 表单类型 */
|
||||||
|
export type FormType = 'create' | 'detail' | 'finish' | 'update';
|
||||||
|
|
||||||
|
/** 表单头部是否只读(详情、执行入库态) */
|
||||||
|
function isHeaderReadonly(formType: FormType): boolean {
|
||||||
|
return formType === 'detail' || formType === 'finish';
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 新增/修改的表单 */
|
||||||
|
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_MISC_RECEIPT_CODE,
|
||||||
|
);
|
||||||
|
await formApi?.setFieldValue('code', code);
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{ default: () => '生成' },
|
||||||
|
),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
fieldName: 'name',
|
||||||
|
label: '入库单名称',
|
||||||
|
component: 'Input',
|
||||||
|
componentProps: {
|
||||||
|
placeholder: '请输入入库单名称',
|
||||||
|
},
|
||||||
|
rules: 'required',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
fieldName: 'type',
|
||||||
|
label: '杂项类型',
|
||||||
|
component: 'Select',
|
||||||
|
componentProps: {
|
||||||
|
options: getDictOptions(DICT_TYPE.MES_WM_MISC_RECEIPT_TYPE, 'number'),
|
||||||
|
placeholder: '请选择杂项类型',
|
||||||
|
},
|
||||||
|
rules: 'selectRequired',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
fieldName: 'sourceDocType',
|
||||||
|
label: '来源单据类型',
|
||||||
|
component: 'Input',
|
||||||
|
componentProps: {
|
||||||
|
placeholder: '请输入来源单据类型',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
fieldName: 'sourceDocCode',
|
||||||
|
label: '来源单据编码',
|
||||||
|
component: 'Input',
|
||||||
|
componentProps: {
|
||||||
|
placeholder: '请输入来源单据编码',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
fieldName: 'receiptDate',
|
||||||
|
label: '入库日期',
|
||||||
|
component: 'DatePicker',
|
||||||
|
componentProps: {
|
||||||
|
format: 'YYYY-MM-DD',
|
||||||
|
placeholder: '请选择入库日期',
|
||||||
|
valueFormat: 'x',
|
||||||
|
},
|
||||||
|
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: 'type',
|
||||||
|
label: '杂项类型',
|
||||||
|
component: 'Select',
|
||||||
|
componentProps: {
|
||||||
|
allowClear: true,
|
||||||
|
options: getDictOptions(DICT_TYPE.MES_WM_MISC_RECEIPT_TYPE, 'number'),
|
||||||
|
placeholder: '请选择杂项类型',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
fieldName: 'sourceDocType',
|
||||||
|
label: '来源单据类型',
|
||||||
|
component: 'Input',
|
||||||
|
componentProps: {
|
||||||
|
allowClear: true,
|
||||||
|
placeholder: '请输入来源单据类型',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
fieldName: 'sourceDocCode',
|
||||||
|
label: '来源单据编号',
|
||||||
|
component: 'Input',
|
||||||
|
componentProps: {
|
||||||
|
allowClear: true,
|
||||||
|
placeholder: '请输入来源单据编号',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
fieldName: 'receiptDate',
|
||||||
|
label: '入库日期',
|
||||||
|
component: 'RangePicker',
|
||||||
|
componentProps: {
|
||||||
|
...getRangePickerDefaultProps(),
|
||||||
|
allowClear: true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
fieldName: 'status',
|
||||||
|
label: '单据状态',
|
||||||
|
component: 'Select',
|
||||||
|
componentProps: {
|
||||||
|
allowClear: true,
|
||||||
|
options: getDictOptions(DICT_TYPE.MES_WM_MISC_RECEIPT_STATUS, 'number'),
|
||||||
|
placeholder: '请选择单据状态',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 列表的字段 */
|
||||||
|
export function useGridColumns(): VxeTableGridOptions<MesWmMiscReceiptApi.MiscReceipt>['columns'] {
|
||||||
|
return [
|
||||||
|
{
|
||||||
|
field: 'code',
|
||||||
|
title: '入库单编号',
|
||||||
|
minWidth: 160,
|
||||||
|
slots: { default: 'code' },
|
||||||
|
},
|
||||||
|
{
|
||||||
|
field: 'name',
|
||||||
|
title: '入库单名称',
|
||||||
|
minWidth: 150,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
field: 'type',
|
||||||
|
title: '杂项类型',
|
||||||
|
minWidth: 100,
|
||||||
|
cellRender: {
|
||||||
|
name: 'CellDict',
|
||||||
|
props: { type: DICT_TYPE.MES_WM_MISC_RECEIPT_TYPE },
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
field: 'sourceDocType',
|
||||||
|
title: '来源单据类型',
|
||||||
|
minWidth: 120,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
field: 'sourceDocCode',
|
||||||
|
title: '来源单据编号',
|
||||||
|
minWidth: 150,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
field: 'receiptDate',
|
||||||
|
title: '入库日期',
|
||||||
|
width: 180,
|
||||||
|
formatter: 'formatDate',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
field: 'status',
|
||||||
|
title: '单据状态',
|
||||||
|
minWidth: 100,
|
||||||
|
cellRender: {
|
||||||
|
name: 'CellDict',
|
||||||
|
props: { type: DICT_TYPE.MES_WM_MISC_RECEIPT_STATUS },
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '操作',
|
||||||
|
width: 240,
|
||||||
|
fixed: 'right',
|
||||||
|
slots: { default: 'actions' },
|
||||||
|
},
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 入库单行子表的字段 */
|
||||||
|
export function useLineGridColumns(
|
||||||
|
editable = true,
|
||||||
|
): VxeTableGridOptions<MesWmMiscReceiptLineApi.MiscReceiptLine>['columns'] {
|
||||||
|
return [
|
||||||
|
{
|
||||||
|
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: 'warehouseName',
|
||||||
|
title: '仓库',
|
||||||
|
minWidth: 100,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
field: 'locationName',
|
||||||
|
title: '库区',
|
||||||
|
minWidth: 100,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
field: 'areaName',
|
||||||
|
title: '库位',
|
||||||
|
minWidth: 100,
|
||||||
|
},
|
||||||
|
...(editable
|
||||||
|
? [
|
||||||
|
{
|
||||||
|
title: '操作',
|
||||||
|
width: 160,
|
||||||
|
fixed: 'right',
|
||||||
|
slots: { default: 'actions' },
|
||||||
|
} as const,
|
||||||
|
]
|
||||||
|
: []),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 入库单行新增/修改的表单 */
|
||||||
|
export function useLineFormSchema(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.01,
|
||||||
|
placeholder: '请输入入库数量',
|
||||||
|
precision: 2,
|
||||||
|
},
|
||||||
|
rules: 'required',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
fieldName: 'batchCode',
|
||||||
|
label: '批次号',
|
||||||
|
component: 'Input',
|
||||||
|
componentProps: {
|
||||||
|
placeholder: '请输入批次号',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
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: 'remark',
|
||||||
|
label: '备注',
|
||||||
|
component: 'Textarea',
|
||||||
|
formItemClass: 'col-span-3',
|
||||||
|
componentProps: {
|
||||||
|
placeholder: '请输入备注',
|
||||||
|
rows: 3,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,195 @@
|
||||||
|
<script lang="ts" setup>
|
||||||
|
import type { VxeTableGridOptions } from '#/adapter/vxe-table';
|
||||||
|
import type { MesWmMiscReceiptApi } from '#/api/mes/wm/miscreceipt';
|
||||||
|
|
||||||
|
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 {
|
||||||
|
cancelMiscReceipt,
|
||||||
|
deleteMiscReceipt,
|
||||||
|
exportMiscReceipt,
|
||||||
|
getMiscReceiptPage,
|
||||||
|
} from '#/api/mes/wm/miscreceipt';
|
||||||
|
import { $t } from '#/locales';
|
||||||
|
import { MesWmMiscReceiptStatusEnum } 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: MesWmMiscReceiptApi.MiscReceipt) {
|
||||||
|
formModalApi.setData({ formType: 'detail', id: row.id }).open();
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 编辑杂项入库单 */
|
||||||
|
function handleEdit(row: MesWmMiscReceiptApi.MiscReceipt) {
|
||||||
|
formModalApi.setData({ formType: 'update', id: row.id }).open();
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 执行入库 */
|
||||||
|
function handleFinish(row: MesWmMiscReceiptApi.MiscReceipt) {
|
||||||
|
formModalApi.setData({ formType: 'finish', id: row.id }).open();
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 删除杂项入库单 */
|
||||||
|
async function handleDelete(row: MesWmMiscReceiptApi.MiscReceipt) {
|
||||||
|
const hideLoading = message.loading({
|
||||||
|
content: $t('ui.actionMessage.deleting', [row.code]),
|
||||||
|
duration: 0,
|
||||||
|
});
|
||||||
|
try {
|
||||||
|
await deleteMiscReceipt(row.id!);
|
||||||
|
message.success($t('ui.actionMessage.deleteSuccess', [row.code]));
|
||||||
|
handleRefresh();
|
||||||
|
} finally {
|
||||||
|
hideLoading();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 取消杂项入库单 */
|
||||||
|
async function handleCancel(row: MesWmMiscReceiptApi.MiscReceipt) {
|
||||||
|
await cancelMiscReceipt(row.id!);
|
||||||
|
message.success('取消成功');
|
||||||
|
handleRefresh();
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 导出表格 */
|
||||||
|
async function handleExport() {
|
||||||
|
const data = await exportMiscReceipt(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 getMiscReceiptPage({
|
||||||
|
pageNo: page.currentPage,
|
||||||
|
pageSize: page.pageSize,
|
||||||
|
...formValues,
|
||||||
|
});
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
rowConfig: {
|
||||||
|
keyField: 'id',
|
||||||
|
isHover: true,
|
||||||
|
},
|
||||||
|
toolbarConfig: {
|
||||||
|
refresh: true,
|
||||||
|
search: true,
|
||||||
|
},
|
||||||
|
} as VxeTableGridOptions<MesWmMiscReceiptApi.MiscReceipt>,
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<Page auto-content-height>
|
||||||
|
<template #doc>
|
||||||
|
<DocAlert
|
||||||
|
title="【仓库】其他入库、其他出库"
|
||||||
|
url="https://doc.iocoder.cn/mes/wm/misc/"
|
||||||
|
/>
|
||||||
|
</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:misc-receipt:create'],
|
||||||
|
onClick: handleCreate,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: $t('ui.actionTitle.export'),
|
||||||
|
type: 'primary',
|
||||||
|
icon: ACTION_ICON.DOWNLOAD,
|
||||||
|
auth: ['mes:wm:misc-receipt: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:misc-receipt:update'],
|
||||||
|
ifShow: row.status === MesWmMiscReceiptStatusEnum.PREPARE,
|
||||||
|
onClick: handleEdit.bind(null, row),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: $t('common.delete'),
|
||||||
|
type: 'link',
|
||||||
|
danger: true,
|
||||||
|
icon: ACTION_ICON.DELETE,
|
||||||
|
auth: ['mes:wm:misc-receipt:delete'],
|
||||||
|
ifShow: row.status === MesWmMiscReceiptStatusEnum.PREPARE,
|
||||||
|
popConfirm: {
|
||||||
|
title: $t('ui.actionMessage.deleteConfirm', [row.code]),
|
||||||
|
confirm: handleDelete.bind(null, row),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '执行入库',
|
||||||
|
type: 'link',
|
||||||
|
auth: ['mes:wm:misc-receipt:finish'],
|
||||||
|
ifShow: row.status === MesWmMiscReceiptStatusEnum.APPROVED,
|
||||||
|
onClick: handleFinish.bind(null, row),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '取消',
|
||||||
|
type: 'link',
|
||||||
|
danger: true,
|
||||||
|
auth: ['mes:wm:misc-receipt:cancel'],
|
||||||
|
ifShow: row.status === MesWmMiscReceiptStatusEnum.APPROVED,
|
||||||
|
popConfirm: {
|
||||||
|
title: '确认取消该杂项入库单吗?',
|
||||||
|
confirm: handleCancel.bind(null, row),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
]"
|
||||||
|
/>
|
||||||
|
</template>
|
||||||
|
</Grid>
|
||||||
|
</Page>
|
||||||
|
</template>
|
||||||
|
|
@ -0,0 +1,194 @@
|
||||||
|
<script lang="ts" setup>
|
||||||
|
import type { FormType } from '../data';
|
||||||
|
|
||||||
|
import type { MesWmMiscReceiptApi } from '#/api/mes/wm/miscreceipt';
|
||||||
|
|
||||||
|
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 {
|
||||||
|
createMiscReceipt,
|
||||||
|
finishMiscReceipt,
|
||||||
|
getMiscReceipt,
|
||||||
|
submitMiscReceipt,
|
||||||
|
updateMiscReceipt,
|
||||||
|
} from '#/api/mes/wm/miscreceipt';
|
||||||
|
import { $t } from '#/locales';
|
||||||
|
import { MesWmMiscReceiptStatusEnum } 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<MesWmMiscReceiptApi.MiscReceipt>();
|
||||||
|
const originalSnapshot = ref(''); // 表单原始数据快照,用于提交时跳过未变更的保存请求
|
||||||
|
const isEditable = computed(() => // 是否为编辑模式(可保存)
|
||||||
|
['create', 'update'].includes(formType.value),
|
||||||
|
);
|
||||||
|
const isFinish = computed(() => formType.value === 'finish'); // 是否为执行入库模式
|
||||||
|
const canSubmit = computed(() => // 是否可提交
|
||||||
|
formType.value === 'update' &&
|
||||||
|
formData.value?.status === MesWmMiscReceiptStatusEnum.PREPARE,
|
||||||
|
);
|
||||||
|
const getTitle = computed(() => {
|
||||||
|
if (formType.value === 'detail') {
|
||||||
|
return $t('ui.actionTitle.view', ['杂项入库单']);
|
||||||
|
}
|
||||||
|
if (formType.value === 'finish') {
|
||||||
|
return '执行入库';
|
||||||
|
}
|
||||||
|
return formType.value === 'update'
|
||||||
|
? $t('ui.actionTitle.edit', ['杂项入库单'])
|
||||||
|
: $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 MesWmMiscReceiptApi.MiscReceipt;
|
||||||
|
await updateMiscReceipt({ ...formData.value, ...data });
|
||||||
|
originalSnapshot.value = current;
|
||||||
|
}
|
||||||
|
await submitMiscReceipt(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 finishMiscReceipt(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 MesWmMiscReceiptApi.MiscReceipt;
|
||||||
|
try {
|
||||||
|
if (formData.value?.id) {
|
||||||
|
await updateMiscReceipt({ ...formData.value, ...data });
|
||||||
|
formData.value = { ...formData.value, ...data };
|
||||||
|
} else {
|
||||||
|
const id = await createMiscReceipt(data);
|
||||||
|
formData.value = {
|
||||||
|
...data,
|
||||||
|
id,
|
||||||
|
status: MesWmMiscReceiptStatusEnum.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(formType.value === 'detail' || formType.value === 'finish');
|
||||||
|
modalApi.setState({ showConfirmButton: isEditable.value });
|
||||||
|
if (data?.id) {
|
||||||
|
modalApi.lock();
|
||||||
|
try {
|
||||||
|
formData.value = await getMiscReceipt(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" :receipt-id="formData.id" />
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
<template #prepend-footer>
|
||||||
|
<div class="flex flex-auto items-center gap-2">
|
||||||
|
<Popconfirm
|
||||||
|
v-if="canSubmit"
|
||||||
|
title="确认提交该杂项入库单?【提交后将不能修改】"
|
||||||
|
@confirm="handleSubmit"
|
||||||
|
>
|
||||||
|
<Button type="primary">提交</Button>
|
||||||
|
</Popconfirm>
|
||||||
|
<Popconfirm
|
||||||
|
v-if="isFinish"
|
||||||
|
title="确认执行入库?执行后将更新库存台账。"
|
||||||
|
@confirm="handleFinish"
|
||||||
|
>
|
||||||
|
<Button type="primary">执行入库</Button>
|
||||||
|
</Popconfirm>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
</Modal>
|
||||||
|
</template>
|
||||||
|
|
@ -0,0 +1,98 @@
|
||||||
|
<script lang="ts" setup>
|
||||||
|
import type { MesWmMiscReceiptLineApi } from '#/api/mes/wm/miscreceipt/line';
|
||||||
|
|
||||||
|
import { computed, ref } from 'vue';
|
||||||
|
|
||||||
|
import { useVbenModal } from '@vben/common-ui';
|
||||||
|
|
||||||
|
import { message } from 'ant-design-vue';
|
||||||
|
|
||||||
|
import { useVbenForm } from '#/adapter/form';
|
||||||
|
import {
|
||||||
|
createMiscReceiptLine,
|
||||||
|
getMiscReceiptLine,
|
||||||
|
updateMiscReceiptLine,
|
||||||
|
} from '#/api/mes/wm/miscreceipt/line';
|
||||||
|
import { $t } from '#/locales';
|
||||||
|
|
||||||
|
import { useLineFormSchema } from '../data';
|
||||||
|
|
||||||
|
const emit = defineEmits(['success']);
|
||||||
|
const formData = ref<MesWmMiscReceiptLineApi.MiscReceiptLine>();
|
||||||
|
const receiptId = 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: useLineFormSchema(),
|
||||||
|
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 MesWmMiscReceiptLineApi.MiscReceiptLine;
|
||||||
|
data.receiptId = receiptId.value;
|
||||||
|
try {
|
||||||
|
await (formData.value?.id
|
||||||
|
? updateMiscReceiptLine({ ...data, id: formData.value.id })
|
||||||
|
: createMiscReceiptLine(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;
|
||||||
|
receiptId: number;
|
||||||
|
}>();
|
||||||
|
receiptId.value = data.receiptId;
|
||||||
|
if (!data.id) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
modalApi.lock();
|
||||||
|
try {
|
||||||
|
formData.value = await getMiscReceiptLine(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,137 @@
|
||||||
|
<script lang="ts" setup>
|
||||||
|
import type { VxeTableGridOptions } from '#/adapter/vxe-table';
|
||||||
|
import type { MesWmMiscReceiptLineApi } from '#/api/mes/wm/miscreceipt/line';
|
||||||
|
|
||||||
|
import { computed } from 'vue';
|
||||||
|
|
||||||
|
import { useVbenModal } from '@vben/common-ui';
|
||||||
|
|
||||||
|
import { message } from 'ant-design-vue';
|
||||||
|
|
||||||
|
import { ACTION_ICON, TableAction, useVbenVxeGrid } from '#/adapter/vxe-table';
|
||||||
|
import {
|
||||||
|
deleteMiscReceiptLine,
|
||||||
|
getMiscReceiptLineListByReceiptId,
|
||||||
|
} from '#/api/mes/wm/miscreceipt/line';
|
||||||
|
import { $t } from '#/locales';
|
||||||
|
|
||||||
|
import { type FormType, useLineGridColumns } from '../data';
|
||||||
|
import LineForm from './line-form.vue';
|
||||||
|
|
||||||
|
const props = defineProps<{
|
||||||
|
formType: FormType;
|
||||||
|
receiptId: number;
|
||||||
|
}>();
|
||||||
|
|
||||||
|
const isEditable = computed(() => // 是否可编辑明细行
|
||||||
|
['create', 'update'].includes(props.formType),
|
||||||
|
);
|
||||||
|
|
||||||
|
const [LineFormModal, lineFormModalApi] = useVbenModal({
|
||||||
|
connectedComponent: LineForm,
|
||||||
|
destroyOnClose: true,
|
||||||
|
});
|
||||||
|
|
||||||
|
/** 刷新表格 */
|
||||||
|
function handleRefresh() {
|
||||||
|
gridApi.query();
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 添加物料 */
|
||||||
|
function handleCreate() {
|
||||||
|
lineFormModalApi.setData({ receiptId: props.receiptId }).open();
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 编辑物料 */
|
||||||
|
function handleEdit(row: MesWmMiscReceiptLineApi.MiscReceiptLine) {
|
||||||
|
lineFormModalApi.setData({ id: row.id, receiptId: props.receiptId }).open();
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 删除物料 */
|
||||||
|
async function handleDelete(row: MesWmMiscReceiptLineApi.MiscReceiptLine) {
|
||||||
|
const hideLoading = message.loading({
|
||||||
|
content: $t('ui.actionMessage.deleting', [row.itemName]),
|
||||||
|
duration: 0,
|
||||||
|
});
|
||||||
|
try {
|
||||||
|
await deleteMiscReceiptLine(row.id!);
|
||||||
|
message.success($t('ui.actionMessage.deleteSuccess', [row.itemName]));
|
||||||
|
handleRefresh();
|
||||||
|
} finally {
|
||||||
|
hideLoading();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const [Grid, gridApi] = useVbenVxeGrid({
|
||||||
|
gridOptions: {
|
||||||
|
columns: useLineGridColumns(isEditable.value),
|
||||||
|
height: 360,
|
||||||
|
keepSource: true,
|
||||||
|
pagerConfig: {
|
||||||
|
enabled: false,
|
||||||
|
},
|
||||||
|
proxyConfig: {
|
||||||
|
ajax: {
|
||||||
|
query: async () => {
|
||||||
|
if (!props.receiptId) {
|
||||||
|
return { list: [], total: 0 };
|
||||||
|
}
|
||||||
|
const list = await getMiscReceiptLineListByReceiptId(props.receiptId);
|
||||||
|
return { list, total: list.length };
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
rowConfig: {
|
||||||
|
keyField: 'id',
|
||||||
|
isHover: true,
|
||||||
|
},
|
||||||
|
toolbarConfig: {
|
||||||
|
refresh: true,
|
||||||
|
},
|
||||||
|
} as VxeTableGridOptions<MesWmMiscReceiptLineApi.MiscReceiptLine>,
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<div>
|
||||||
|
<LineFormModal @success="handleRefresh" />
|
||||||
|
<Grid table-title="物料信息">
|
||||||
|
<template v-if="isEditable" #toolbar-tools>
|
||||||
|
<TableAction
|
||||||
|
:actions="[
|
||||||
|
{
|
||||||
|
label: '添加物料',
|
||||||
|
type: 'primary',
|
||||||
|
icon: ACTION_ICON.ADD,
|
||||||
|
onClick: handleCreate,
|
||||||
|
},
|
||||||
|
]"
|
||||||
|
/>
|
||||||
|
</template>
|
||||||
|
<template #actions="{ row }">
|
||||||
|
<TableAction
|
||||||
|
:actions="[
|
||||||
|
{
|
||||||
|
label: $t('common.edit'),
|
||||||
|
type: 'link',
|
||||||
|
icon: ACTION_ICON.EDIT,
|
||||||
|
ifShow: isEditable,
|
||||||
|
onClick: handleEdit.bind(null, row),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: $t('common.delete'),
|
||||||
|
type: 'link',
|
||||||
|
danger: true,
|
||||||
|
icon: ACTION_ICON.DELETE,
|
||||||
|
ifShow: isEditable,
|
||||||
|
popConfirm: {
|
||||||
|
title: $t('ui.actionMessage.deleteConfirm', [row.itemName]),
|
||||||
|
confirm: handleDelete.bind(null, row),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
]"
|
||||||
|
/>
|
||||||
|
</template>
|
||||||
|
</Grid>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
@ -8,7 +8,7 @@ export namespace MesWmMiscIssueApi {
|
||||||
id?: number; // 编号
|
id?: number; // 编号
|
||||||
code?: string; // 出库单编号
|
code?: string; // 出库单编号
|
||||||
name?: string; // 出库单名称
|
name?: string; // 出库单名称
|
||||||
type?: string; // 业务类型
|
type?: number; // 业务类型
|
||||||
sourceDocType?: string; // 来源单据类型
|
sourceDocType?: string; // 来源单据类型
|
||||||
sourceDocId?: number; // 来源单据编号
|
sourceDocId?: number; // 来源单据编号
|
||||||
sourceDocCode?: string; // 来源单据编码
|
sourceDocCode?: string; // 来源单据编码
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,455 @@
|
||||||
|
import type { VbenFormApi, VbenFormSchema } from '#/adapter/form';
|
||||||
|
import type { VxeTableGridOptions } from '#/adapter/vxe-table';
|
||||||
|
import type { MesWmMaterialStockApi } from '#/api/mes/wm/materialstock';
|
||||||
|
import type { MesWmMiscIssueApi } from '#/api/mes/wm/miscissue';
|
||||||
|
import type { MesWmMiscIssueLineApi } from '#/api/mes/wm/miscissue/line';
|
||||||
|
|
||||||
|
import { h, markRaw } from 'vue';
|
||||||
|
|
||||||
|
import { DICT_TYPE } from '@vben/constants';
|
||||||
|
import { getDictOptions } from '@vben/hooks';
|
||||||
|
|
||||||
|
import { ElButton } from 'element-plus';
|
||||||
|
|
||||||
|
import { generateAutoCode } from '#/api/mes/md/autocode/record';
|
||||||
|
import { getRangePickerDefaultProps } from '#/utils';
|
||||||
|
import { MesAutoCodeRuleCode } 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' | 'update';
|
||||||
|
|
||||||
|
/** 表单头部是否只读(详情、执行出库态) */
|
||||||
|
function isHeaderReadonly(formType: FormType): boolean {
|
||||||
|
return formType === 'detail' || formType === 'finish';
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 新增/修改的表单 */
|
||||||
|
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_MISC_ISSUE_CODE,
|
||||||
|
);
|
||||||
|
await formApi?.setFieldValue('code', code);
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{ default: () => '生成' },
|
||||||
|
),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
fieldName: 'name',
|
||||||
|
label: '出库单名称',
|
||||||
|
component: 'Input',
|
||||||
|
componentProps: {
|
||||||
|
placeholder: '请输入出库单名称',
|
||||||
|
},
|
||||||
|
rules: 'required',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
fieldName: 'type',
|
||||||
|
label: '业务类型',
|
||||||
|
component: 'Select',
|
||||||
|
componentProps: {
|
||||||
|
options: getDictOptions(DICT_TYPE.MES_WM_MISC_ISSUE_TYPE, 'number'),
|
||||||
|
placeholder: '请选择业务类型',
|
||||||
|
},
|
||||||
|
rules: 'selectRequired',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
fieldName: 'issueDate',
|
||||||
|
label: '出库日期',
|
||||||
|
component: 'DatePicker',
|
||||||
|
componentProps: {
|
||||||
|
format: 'YYYY-MM-DD',
|
||||||
|
placeholder: '请选择出库日期',
|
||||||
|
type: 'date',
|
||||||
|
valueFormat: 'x',
|
||||||
|
},
|
||||||
|
rules: 'required',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
fieldName: 'sourceDocType',
|
||||||
|
label: '来源单据类型',
|
||||||
|
component: 'Input',
|
||||||
|
componentProps: {
|
||||||
|
placeholder: '请输入来源单据类型',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
fieldName: 'sourceDocCode',
|
||||||
|
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: 'type',
|
||||||
|
label: '业务类型',
|
||||||
|
component: 'Select',
|
||||||
|
componentProps: {
|
||||||
|
clearable: true,
|
||||||
|
options: getDictOptions(DICT_TYPE.MES_WM_MISC_ISSUE_TYPE, 'number'),
|
||||||
|
placeholder: '请选择业务类型',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
fieldName: 'sourceDocType',
|
||||||
|
label: '来源单据类型',
|
||||||
|
component: 'Input',
|
||||||
|
componentProps: {
|
||||||
|
clearable: true,
|
||||||
|
placeholder: '请输入来源单据类型',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
fieldName: 'sourceDocCode',
|
||||||
|
label: '来源单据编号',
|
||||||
|
component: 'Input',
|
||||||
|
componentProps: {
|
||||||
|
clearable: true,
|
||||||
|
placeholder: '请输入来源单据编号',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
fieldName: 'issueDate',
|
||||||
|
label: '出库日期',
|
||||||
|
component: 'RangePicker',
|
||||||
|
componentProps: {
|
||||||
|
...getRangePickerDefaultProps(),
|
||||||
|
clearable: true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
fieldName: 'status',
|
||||||
|
label: '单据状态',
|
||||||
|
component: 'Select',
|
||||||
|
componentProps: {
|
||||||
|
clearable: true,
|
||||||
|
options: getDictOptions(DICT_TYPE.MES_WM_MISC_ISSUE_STATUS, 'number'),
|
||||||
|
placeholder: '请选择单据状态',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 列表的字段 */
|
||||||
|
export function useGridColumns(): VxeTableGridOptions<MesWmMiscIssueApi.MiscIssue>['columns'] {
|
||||||
|
return [
|
||||||
|
{
|
||||||
|
field: 'code',
|
||||||
|
title: '出库单编号',
|
||||||
|
minWidth: 160,
|
||||||
|
slots: { default: 'code' },
|
||||||
|
},
|
||||||
|
{
|
||||||
|
field: 'name',
|
||||||
|
title: '出库单名称',
|
||||||
|
minWidth: 150,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
field: 'type',
|
||||||
|
title: '业务类型',
|
||||||
|
minWidth: 120,
|
||||||
|
cellRender: {
|
||||||
|
name: 'CellDict',
|
||||||
|
props: { type: DICT_TYPE.MES_WM_MISC_ISSUE_TYPE },
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
field: 'sourceDocType',
|
||||||
|
title: '来源单据类型',
|
||||||
|
minWidth: 120,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
field: 'sourceDocCode',
|
||||||
|
title: '来源单据编号',
|
||||||
|
minWidth: 150,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
field: 'issueDate',
|
||||||
|
title: '出库日期',
|
||||||
|
width: 180,
|
||||||
|
formatter: 'formatDate',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
field: 'status',
|
||||||
|
title: '单据状态',
|
||||||
|
minWidth: 100,
|
||||||
|
cellRender: {
|
||||||
|
name: 'CellDict',
|
||||||
|
props: { type: DICT_TYPE.MES_WM_MISC_ISSUE_STATUS },
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '操作',
|
||||||
|
width: 240,
|
||||||
|
fixed: 'right',
|
||||||
|
slots: { default: 'actions' },
|
||||||
|
},
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 出库单行子表的字段 */
|
||||||
|
export function useLineGridColumns(
|
||||||
|
editable = true,
|
||||||
|
): VxeTableGridOptions<MesWmMiscIssueLineApi.MiscIssueLine>['columns'] {
|
||||||
|
return [
|
||||||
|
{
|
||||||
|
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: 'warehouseName',
|
||||||
|
title: '仓库',
|
||||||
|
minWidth: 120,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
field: 'locationName',
|
||||||
|
title: '库区',
|
||||||
|
minWidth: 120,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
field: 'areaName',
|
||||||
|
title: '库位',
|
||||||
|
minWidth: 120,
|
||||||
|
},
|
||||||
|
...(editable
|
||||||
|
? [
|
||||||
|
{
|
||||||
|
title: '操作',
|
||||||
|
width: 120,
|
||||||
|
fixed: 'right',
|
||||||
|
slots: { default: 'actions' },
|
||||||
|
} as const,
|
||||||
|
]
|
||||||
|
: []),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 出库单行新增/修改的表单 */
|
||||||
|
export function useLineFormSchema(formApi?: VbenFormApi): VbenFormSchema[] {
|
||||||
|
return [
|
||||||
|
{
|
||||||
|
fieldName: 'itemId',
|
||||||
|
component: 'Input',
|
||||||
|
dependencies: {
|
||||||
|
triggerFields: [''],
|
||||||
|
show: () => false,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
fieldName: 'quantityMax',
|
||||||
|
component: 'Input',
|
||||||
|
dependencies: {
|
||||||
|
triggerFields: [''],
|
||||||
|
show: () => false,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
fieldName: 'materialStockId',
|
||||||
|
label: '库存物资',
|
||||||
|
component: markRaw(WmMaterialStockSelect),
|
||||||
|
componentProps: {
|
||||||
|
// 选择库存物资后,自动回填物料、批次号、仓库位置和最大可出库数量
|
||||||
|
onChange: async (stock?: MesWmMaterialStockApi.MaterialStock) => {
|
||||||
|
await formApi?.setValues({
|
||||||
|
areaId: stock?.areaId,
|
||||||
|
batchCode: stock?.batchCode,
|
||||||
|
itemId: stock?.itemId,
|
||||||
|
locationId: stock?.locationId,
|
||||||
|
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.01,
|
||||||
|
placeholder: '请输入出库数量',
|
||||||
|
precision: 2,
|
||||||
|
},
|
||||||
|
rules: 'required',
|
||||||
|
dependencies: {
|
||||||
|
triggerFields: ['quantityMax'],
|
||||||
|
componentProps: (values) => ({
|
||||||
|
class: '!w-full',
|
||||||
|
controlsPosition: 'right',
|
||||||
|
max: values.quantityMax,
|
||||||
|
min: 0.01,
|
||||||
|
placeholder: '请输入出库数量',
|
||||||
|
precision: 2,
|
||||||
|
}),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
fieldName: 'batchCode',
|
||||||
|
label: '批次号',
|
||||||
|
component: 'Input',
|
||||||
|
componentProps: {
|
||||||
|
disabled: true,
|
||||||
|
placeholder: '批次号',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
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: 'remark',
|
||||||
|
label: '备注',
|
||||||
|
component: 'Textarea',
|
||||||
|
formItemClass: 'col-span-3',
|
||||||
|
componentProps: {
|
||||||
|
placeholder: '请输入备注',
|
||||||
|
rows: 3,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,196 @@
|
||||||
|
<script lang="ts" setup>
|
||||||
|
import type { VxeTableGridOptions } from '#/adapter/vxe-table';
|
||||||
|
import type { MesWmMiscIssueApi } from '#/api/mes/wm/miscissue';
|
||||||
|
|
||||||
|
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 {
|
||||||
|
cancelMiscIssue,
|
||||||
|
deleteMiscIssue,
|
||||||
|
exportMiscIssue,
|
||||||
|
getMiscIssuePage,
|
||||||
|
} from '#/api/mes/wm/miscissue';
|
||||||
|
import { $t } from '#/locales';
|
||||||
|
import { MesWmMiscIssueStatusEnum } 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: MesWmMiscIssueApi.MiscIssue) {
|
||||||
|
formModalApi.setData({ formType: 'detail', id: row.id }).open();
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 编辑杂项出库单 */
|
||||||
|
function handleEdit(row: MesWmMiscIssueApi.MiscIssue) {
|
||||||
|
formModalApi.setData({ formType: 'update', id: row.id }).open();
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 执行出库 */
|
||||||
|
function handleFinish(row: MesWmMiscIssueApi.MiscIssue) {
|
||||||
|
formModalApi.setData({ formType: 'finish', id: row.id }).open();
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 删除杂项出库单 */
|
||||||
|
async function handleDelete(row: MesWmMiscIssueApi.MiscIssue) {
|
||||||
|
const loadingInstance = ElLoading.service({
|
||||||
|
text: $t('ui.actionMessage.deleting', [row.code]),
|
||||||
|
});
|
||||||
|
try {
|
||||||
|
await deleteMiscIssue(row.id!);
|
||||||
|
ElMessage.success($t('ui.actionMessage.deleteSuccess', [row.code]));
|
||||||
|
handleRefresh();
|
||||||
|
} finally {
|
||||||
|
loadingInstance.close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 取消杂项出库单 */
|
||||||
|
async function handleCancel(row: MesWmMiscIssueApi.MiscIssue) {
|
||||||
|
await cancelMiscIssue(row.id!);
|
||||||
|
ElMessage.success('取消成功');
|
||||||
|
handleRefresh();
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 导出表格 */
|
||||||
|
async function handleExport() {
|
||||||
|
const data = await exportMiscIssue(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 getMiscIssuePage({
|
||||||
|
pageNo: page.currentPage,
|
||||||
|
pageSize: page.pageSize,
|
||||||
|
...formValues,
|
||||||
|
});
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
rowConfig: {
|
||||||
|
keyField: 'id',
|
||||||
|
isHover: true,
|
||||||
|
},
|
||||||
|
toolbarConfig: {
|
||||||
|
refresh: true,
|
||||||
|
search: true,
|
||||||
|
},
|
||||||
|
} as VxeTableGridOptions<MesWmMiscIssueApi.MiscIssue>,
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<Page auto-content-height>
|
||||||
|
<template #doc>
|
||||||
|
<DocAlert
|
||||||
|
title="【仓库】其他入库、其他出库"
|
||||||
|
url="https://doc.iocoder.cn/mes/wm/misc/"
|
||||||
|
/>
|
||||||
|
</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-misc-issue:create'],
|
||||||
|
onClick: handleCreate,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: $t('ui.actionTitle.export'),
|
||||||
|
type: 'primary',
|
||||||
|
icon: ACTION_ICON.DOWNLOAD,
|
||||||
|
auth: ['mes:wm-misc-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-misc-issue:update'],
|
||||||
|
ifShow: row.status === MesWmMiscIssueStatusEnum.PREPARE,
|
||||||
|
onClick: handleEdit.bind(null, row),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: $t('common.delete'),
|
||||||
|
type: 'danger',
|
||||||
|
link: true,
|
||||||
|
icon: ACTION_ICON.DELETE,
|
||||||
|
auth: ['mes:wm-misc-issue:delete'],
|
||||||
|
ifShow: row.status === MesWmMiscIssueStatusEnum.PREPARE,
|
||||||
|
popConfirm: {
|
||||||
|
title: $t('ui.actionMessage.deleteConfirm', [row.code]),
|
||||||
|
confirm: handleDelete.bind(null, row),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '执行出库',
|
||||||
|
type: 'primary',
|
||||||
|
link: true,
|
||||||
|
auth: ['mes:wm-misc-issue:finish'],
|
||||||
|
ifShow: row.status === MesWmMiscIssueStatusEnum.APPROVED,
|
||||||
|
onClick: handleFinish.bind(null, row),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '取消',
|
||||||
|
type: 'danger',
|
||||||
|
link: true,
|
||||||
|
auth: ['mes:wm-misc-issue:update'],
|
||||||
|
ifShow: row.status === MesWmMiscIssueStatusEnum.APPROVED,
|
||||||
|
popConfirm: {
|
||||||
|
title: '确认取消该杂项出库单?取消后不可恢复。',
|
||||||
|
confirm: handleCancel.bind(null, row),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
]"
|
||||||
|
/>
|
||||||
|
</template>
|
||||||
|
</Grid>
|
||||||
|
</Page>
|
||||||
|
</template>
|
||||||
|
|
@ -0,0 +1,200 @@
|
||||||
|
<script lang="ts" setup>
|
||||||
|
import type { FormType } from '../data';
|
||||||
|
|
||||||
|
import type { MesWmMiscIssueApi } from '#/api/mes/wm/miscissue';
|
||||||
|
|
||||||
|
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 {
|
||||||
|
createMiscIssue,
|
||||||
|
finishMiscIssue,
|
||||||
|
getMiscIssue,
|
||||||
|
submitMiscIssue,
|
||||||
|
updateMiscIssue,
|
||||||
|
} from '#/api/mes/wm/miscissue';
|
||||||
|
import { $t } from '#/locales';
|
||||||
|
import { MesWmMiscIssueStatusEnum } 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<MesWmMiscIssueApi.MiscIssue>();
|
||||||
|
const originalSnapshot = ref(''); // 表单原始数据快照,用于提交时跳过未变更的保存请求
|
||||||
|
const isEditable = computed(() => // 是否为编辑模式(可保存)
|
||||||
|
['create', 'update'].includes(formType.value),
|
||||||
|
);
|
||||||
|
const isFinish = computed(() => formType.value === 'finish'); // 是否为执行出库模式
|
||||||
|
const canSubmit = computed(() => // 是否可提交
|
||||||
|
formType.value === 'update' &&
|
||||||
|
formData.value?.status === MesWmMiscIssueStatusEnum.PREPARE,
|
||||||
|
);
|
||||||
|
const getTitle = computed(() => {
|
||||||
|
if (formType.value === 'detail') {
|
||||||
|
return $t('ui.actionTitle.view', ['杂项出库单']);
|
||||||
|
}
|
||||||
|
if (formType.value === 'finish') {
|
||||||
|
return '执行出库';
|
||||||
|
}
|
||||||
|
return formType.value === 'update'
|
||||||
|
? $t('ui.actionTitle.edit', ['杂项出库单'])
|
||||||
|
: $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 MesWmMiscIssueApi.MiscIssue;
|
||||||
|
await updateMiscIssue({ ...formData.value, ...data });
|
||||||
|
originalSnapshot.value = current;
|
||||||
|
}
|
||||||
|
await submitMiscIssue(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 finishMiscIssue(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 MesWmMiscIssueApi.MiscIssue;
|
||||||
|
try {
|
||||||
|
if (formData.value?.id) {
|
||||||
|
await updateMiscIssue({ ...formData.value, ...data });
|
||||||
|
formData.value = { ...formData.value, ...data };
|
||||||
|
} else {
|
||||||
|
const id = await createMiscIssue(data);
|
||||||
|
formData.value = {
|
||||||
|
...data,
|
||||||
|
id,
|
||||||
|
status: MesWmMiscIssueStatusEnum.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(formType.value === 'detail' || formType.value === 'finish');
|
||||||
|
modalApi.setState({ showConfirmButton: isEditable.value });
|
||||||
|
if (data?.id) {
|
||||||
|
modalApi.lock();
|
||||||
|
try {
|
||||||
|
formData.value = await getMiscIssue(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>
|
||||||
|
<ElPopconfirm
|
||||||
|
v-if="isFinish"
|
||||||
|
title="确认执行出库?执行后将更新库存台账。"
|
||||||
|
width="260"
|
||||||
|
@confirm="handleFinish"
|
||||||
|
>
|
||||||
|
<template #reference>
|
||||||
|
<ElButton type="primary">执行出库</ElButton>
|
||||||
|
</template>
|
||||||
|
</ElPopconfirm>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
</Modal>
|
||||||
|
</template>
|
||||||
|
|
@ -0,0 +1,97 @@
|
||||||
|
<script lang="ts" setup>
|
||||||
|
import type { MesWmMiscIssueLineApi } from '#/api/mes/wm/miscissue/line';
|
||||||
|
|
||||||
|
import { computed, ref } from 'vue';
|
||||||
|
|
||||||
|
import { useVbenModal } from '@vben/common-ui';
|
||||||
|
|
||||||
|
import { ElMessage } from 'element-plus';
|
||||||
|
|
||||||
|
import { useVbenForm } from '#/adapter/form';
|
||||||
|
import {
|
||||||
|
createMiscIssueLine,
|
||||||
|
getMiscIssueLine,
|
||||||
|
updateMiscIssueLine,
|
||||||
|
} from '#/api/mes/wm/miscissue/line';
|
||||||
|
import { $t } from '#/locales';
|
||||||
|
|
||||||
|
import { useLineFormSchema } from '../data';
|
||||||
|
|
||||||
|
const emit = defineEmits(['success']);
|
||||||
|
const formData = ref<MesWmMiscIssueLineApi.MiscIssueLine>();
|
||||||
|
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: useLineFormSchema(),
|
||||||
|
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 MesWmMiscIssueLineApi.MiscIssueLine;
|
||||||
|
data.issueId = issueId.value;
|
||||||
|
try {
|
||||||
|
await (formData.value?.id
|
||||||
|
? updateMiscIssueLine({ ...data, id: formData.value.id })
|
||||||
|
: createMiscIssueLine(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 getMiscIssueLine(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,137 @@
|
||||||
|
<script lang="ts" setup>
|
||||||
|
import type { VxeTableGridOptions } from '#/adapter/vxe-table';
|
||||||
|
import type { MesWmMiscIssueLineApi } from '#/api/mes/wm/miscissue/line';
|
||||||
|
|
||||||
|
import { computed } from 'vue';
|
||||||
|
|
||||||
|
import { useVbenModal } from '@vben/common-ui';
|
||||||
|
|
||||||
|
import { ElLoading, ElMessage } from 'element-plus';
|
||||||
|
|
||||||
|
import { ACTION_ICON, TableAction, useVbenVxeGrid } from '#/adapter/vxe-table';
|
||||||
|
import {
|
||||||
|
deleteMiscIssueLine,
|
||||||
|
getMiscIssueLinePage,
|
||||||
|
} from '#/api/mes/wm/miscissue/line';
|
||||||
|
import { $t } from '#/locales';
|
||||||
|
|
||||||
|
import { type FormType, useLineGridColumns } from '../data';
|
||||||
|
import LineForm from './line-form.vue';
|
||||||
|
|
||||||
|
const props = defineProps<{
|
||||||
|
formType: FormType;
|
||||||
|
issueId: number;
|
||||||
|
}>();
|
||||||
|
|
||||||
|
const isEditable = computed(() => // 是否可编辑明细行
|
||||||
|
['create', 'update'].includes(props.formType),
|
||||||
|
);
|
||||||
|
|
||||||
|
const [LineFormModal, lineFormModalApi] = useVbenModal({
|
||||||
|
connectedComponent: LineForm,
|
||||||
|
destroyOnClose: true,
|
||||||
|
});
|
||||||
|
|
||||||
|
/** 刷新表格 */
|
||||||
|
function handleRefresh() {
|
||||||
|
gridApi.query();
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 添加物料 */
|
||||||
|
function handleCreate() {
|
||||||
|
lineFormModalApi.setData({ issueId: props.issueId }).open();
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 编辑物料 */
|
||||||
|
function handleEdit(row: MesWmMiscIssueLineApi.MiscIssueLine) {
|
||||||
|
lineFormModalApi.setData({ id: row.id, issueId: props.issueId }).open();
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 删除物料 */
|
||||||
|
async function handleDelete(row: MesWmMiscIssueLineApi.MiscIssueLine) {
|
||||||
|
const loadingInstance = ElLoading.service({
|
||||||
|
text: $t('ui.actionMessage.deleting', [row.itemName]),
|
||||||
|
});
|
||||||
|
try {
|
||||||
|
await deleteMiscIssueLine(row.id!);
|
||||||
|
ElMessage.success($t('ui.actionMessage.deleteSuccess', [row.itemName]));
|
||||||
|
handleRefresh();
|
||||||
|
} finally {
|
||||||
|
loadingInstance.close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const [Grid, gridApi] = useVbenVxeGrid({
|
||||||
|
gridOptions: {
|
||||||
|
columns: useLineGridColumns(isEditable.value),
|
||||||
|
height: 360,
|
||||||
|
keepSource: true,
|
||||||
|
proxyConfig: {
|
||||||
|
ajax: {
|
||||||
|
query: async ({ page }) => {
|
||||||
|
if (!props.issueId) {
|
||||||
|
return { list: [], total: 0 };
|
||||||
|
}
|
||||||
|
return await getMiscIssueLinePage({
|
||||||
|
issueId: props.issueId,
|
||||||
|
pageNo: page.currentPage,
|
||||||
|
pageSize: page.pageSize,
|
||||||
|
});
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
rowConfig: {
|
||||||
|
keyField: 'id',
|
||||||
|
isHover: true,
|
||||||
|
},
|
||||||
|
toolbarConfig: {
|
||||||
|
refresh: true,
|
||||||
|
},
|
||||||
|
} as VxeTableGridOptions<MesWmMiscIssueLineApi.MiscIssueLine>,
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<div>
|
||||||
|
<LineFormModal @success="handleRefresh" />
|
||||||
|
<Grid table-title="物料信息">
|
||||||
|
<template v-if="isEditable" #toolbar-tools>
|
||||||
|
<TableAction
|
||||||
|
:actions="[
|
||||||
|
{
|
||||||
|
label: '添加物料',
|
||||||
|
type: 'primary',
|
||||||
|
icon: ACTION_ICON.ADD,
|
||||||
|
onClick: handleCreate,
|
||||||
|
},
|
||||||
|
]"
|
||||||
|
/>
|
||||||
|
</template>
|
||||||
|
<template #actions="{ row }">
|
||||||
|
<TableAction
|
||||||
|
:actions="[
|
||||||
|
{
|
||||||
|
label: $t('common.edit'),
|
||||||
|
type: 'primary',
|
||||||
|
link: true,
|
||||||
|
icon: ACTION_ICON.EDIT,
|
||||||
|
ifShow: isEditable,
|
||||||
|
onClick: handleEdit.bind(null, row),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: $t('common.delete'),
|
||||||
|
type: 'danger',
|
||||||
|
link: true,
|
||||||
|
icon: ACTION_ICON.DELETE,
|
||||||
|
ifShow: isEditable,
|
||||||
|
popConfirm: {
|
||||||
|
title: $t('ui.actionMessage.deleteConfirm', [row.itemName]),
|
||||||
|
confirm: handleDelete.bind(null, row),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
]"
|
||||||
|
/>
|
||||||
|
</template>
|
||||||
|
</Grid>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
@ -0,0 +1,424 @@
|
||||||
|
import type { VbenFormApi, VbenFormSchema } from '#/adapter/form';
|
||||||
|
import type { VxeTableGridOptions } from '#/adapter/vxe-table';
|
||||||
|
import type { MesWmMiscReceiptApi } from '#/api/mes/wm/miscreceipt';
|
||||||
|
import type { MesWmMiscReceiptLineApi } from '#/api/mes/wm/miscreceipt/line';
|
||||||
|
|
||||||
|
import { h, markRaw } from 'vue';
|
||||||
|
|
||||||
|
import { DICT_TYPE } from '@vben/constants';
|
||||||
|
import { getDictOptions } from '@vben/hooks';
|
||||||
|
|
||||||
|
import { ElButton } from 'element-plus';
|
||||||
|
|
||||||
|
import { generateAutoCode } from '#/api/mes/md/autocode/record';
|
||||||
|
import { getRangePickerDefaultProps } from '#/utils';
|
||||||
|
import { MdItemSelect } from '#/views/mes/md/item/components';
|
||||||
|
import { MesAutoCodeRuleCode } from '#/views/mes/utils/constants';
|
||||||
|
import {
|
||||||
|
WmWarehouseAreaSelect,
|
||||||
|
WmWarehouseLocationSelect,
|
||||||
|
WmWarehouseSelect,
|
||||||
|
} from '#/views/mes/wm/warehouse/components';
|
||||||
|
|
||||||
|
/** 表单类型 */
|
||||||
|
export type FormType = 'create' | 'detail' | 'finish' | 'update';
|
||||||
|
|
||||||
|
/** 表单头部是否只读(详情、执行入库态) */
|
||||||
|
function isHeaderReadonly(formType: FormType): boolean {
|
||||||
|
return formType === 'detail' || formType === 'finish';
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 新增/修改的表单 */
|
||||||
|
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_MISC_RECEIPT_CODE,
|
||||||
|
);
|
||||||
|
await formApi?.setFieldValue('code', code);
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{ default: () => '生成' },
|
||||||
|
),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
fieldName: 'name',
|
||||||
|
label: '入库单名称',
|
||||||
|
component: 'Input',
|
||||||
|
componentProps: {
|
||||||
|
placeholder: '请输入入库单名称',
|
||||||
|
},
|
||||||
|
rules: 'required',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
fieldName: 'type',
|
||||||
|
label: '杂项类型',
|
||||||
|
component: 'Select',
|
||||||
|
componentProps: {
|
||||||
|
options: getDictOptions(DICT_TYPE.MES_WM_MISC_RECEIPT_TYPE, 'number'),
|
||||||
|
placeholder: '请选择杂项类型',
|
||||||
|
},
|
||||||
|
rules: 'selectRequired',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
fieldName: 'sourceDocType',
|
||||||
|
label: '来源单据类型',
|
||||||
|
component: 'Input',
|
||||||
|
componentProps: {
|
||||||
|
placeholder: '请输入来源单据类型',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
fieldName: 'sourceDocCode',
|
||||||
|
label: '来源单据编码',
|
||||||
|
component: 'Input',
|
||||||
|
componentProps: {
|
||||||
|
placeholder: '请输入来源单据编码',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
fieldName: 'receiptDate',
|
||||||
|
label: '入库日期',
|
||||||
|
component: 'DatePicker',
|
||||||
|
componentProps: {
|
||||||
|
format: 'YYYY-MM-DD',
|
||||||
|
placeholder: '请选择入库日期',
|
||||||
|
type: 'date',
|
||||||
|
valueFormat: 'x',
|
||||||
|
},
|
||||||
|
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: 'type',
|
||||||
|
label: '杂项类型',
|
||||||
|
component: 'Select',
|
||||||
|
componentProps: {
|
||||||
|
clearable: true,
|
||||||
|
options: getDictOptions(DICT_TYPE.MES_WM_MISC_RECEIPT_TYPE, 'number'),
|
||||||
|
placeholder: '请选择杂项类型',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
fieldName: 'sourceDocType',
|
||||||
|
label: '来源单据类型',
|
||||||
|
component: 'Input',
|
||||||
|
componentProps: {
|
||||||
|
clearable: true,
|
||||||
|
placeholder: '请输入来源单据类型',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
fieldName: 'sourceDocCode',
|
||||||
|
label: '来源单据编号',
|
||||||
|
component: 'Input',
|
||||||
|
componentProps: {
|
||||||
|
clearable: true,
|
||||||
|
placeholder: '请输入来源单据编号',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
fieldName: 'receiptDate',
|
||||||
|
label: '入库日期',
|
||||||
|
component: 'RangePicker',
|
||||||
|
componentProps: {
|
||||||
|
...getRangePickerDefaultProps(),
|
||||||
|
clearable: true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
fieldName: 'status',
|
||||||
|
label: '单据状态',
|
||||||
|
component: 'Select',
|
||||||
|
componentProps: {
|
||||||
|
clearable: true,
|
||||||
|
options: getDictOptions(DICT_TYPE.MES_WM_MISC_RECEIPT_STATUS, 'number'),
|
||||||
|
placeholder: '请选择单据状态',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 列表的字段 */
|
||||||
|
export function useGridColumns(): VxeTableGridOptions<MesWmMiscReceiptApi.MiscReceipt>['columns'] {
|
||||||
|
return [
|
||||||
|
{
|
||||||
|
field: 'code',
|
||||||
|
title: '入库单编号',
|
||||||
|
minWidth: 160,
|
||||||
|
slots: { default: 'code' },
|
||||||
|
},
|
||||||
|
{
|
||||||
|
field: 'name',
|
||||||
|
title: '入库单名称',
|
||||||
|
minWidth: 150,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
field: 'type',
|
||||||
|
title: '杂项类型',
|
||||||
|
minWidth: 100,
|
||||||
|
cellRender: {
|
||||||
|
name: 'CellDict',
|
||||||
|
props: { type: DICT_TYPE.MES_WM_MISC_RECEIPT_TYPE },
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
field: 'sourceDocType',
|
||||||
|
title: '来源单据类型',
|
||||||
|
minWidth: 120,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
field: 'sourceDocCode',
|
||||||
|
title: '来源单据编号',
|
||||||
|
minWidth: 150,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
field: 'receiptDate',
|
||||||
|
title: '入库日期',
|
||||||
|
width: 180,
|
||||||
|
formatter: 'formatDate',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
field: 'status',
|
||||||
|
title: '单据状态',
|
||||||
|
minWidth: 100,
|
||||||
|
cellRender: {
|
||||||
|
name: 'CellDict',
|
||||||
|
props: { type: DICT_TYPE.MES_WM_MISC_RECEIPT_STATUS },
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '操作',
|
||||||
|
width: 240,
|
||||||
|
fixed: 'right',
|
||||||
|
slots: { default: 'actions' },
|
||||||
|
},
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 入库单行子表的字段 */
|
||||||
|
export function useLineGridColumns(
|
||||||
|
editable = true,
|
||||||
|
): VxeTableGridOptions<MesWmMiscReceiptLineApi.MiscReceiptLine>['columns'] {
|
||||||
|
return [
|
||||||
|
{
|
||||||
|
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: 'warehouseName',
|
||||||
|
title: '仓库',
|
||||||
|
minWidth: 100,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
field: 'locationName',
|
||||||
|
title: '库区',
|
||||||
|
minWidth: 100,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
field: 'areaName',
|
||||||
|
title: '库位',
|
||||||
|
minWidth: 100,
|
||||||
|
},
|
||||||
|
...(editable
|
||||||
|
? [
|
||||||
|
{
|
||||||
|
title: '操作',
|
||||||
|
width: 160,
|
||||||
|
fixed: 'right',
|
||||||
|
slots: { default: 'actions' },
|
||||||
|
} as const,
|
||||||
|
]
|
||||||
|
: []),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 入库单行新增/修改的表单 */
|
||||||
|
export function useLineFormSchema(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.01,
|
||||||
|
placeholder: '请输入入库数量',
|
||||||
|
precision: 2,
|
||||||
|
},
|
||||||
|
rules: 'required',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
fieldName: 'batchCode',
|
||||||
|
label: '批次号',
|
||||||
|
component: 'Input',
|
||||||
|
componentProps: {
|
||||||
|
placeholder: '请输入批次号',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
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: 'remark',
|
||||||
|
label: '备注',
|
||||||
|
component: 'Textarea',
|
||||||
|
formItemClass: 'col-span-3',
|
||||||
|
componentProps: {
|
||||||
|
placeholder: '请输入备注',
|
||||||
|
rows: 3,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,196 @@
|
||||||
|
<script lang="ts" setup>
|
||||||
|
import type { VxeTableGridOptions } from '#/adapter/vxe-table';
|
||||||
|
import type { MesWmMiscReceiptApi } from '#/api/mes/wm/miscreceipt';
|
||||||
|
|
||||||
|
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 {
|
||||||
|
cancelMiscReceipt,
|
||||||
|
deleteMiscReceipt,
|
||||||
|
exportMiscReceipt,
|
||||||
|
getMiscReceiptPage,
|
||||||
|
} from '#/api/mes/wm/miscreceipt';
|
||||||
|
import { $t } from '#/locales';
|
||||||
|
import { MesWmMiscReceiptStatusEnum } 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: MesWmMiscReceiptApi.MiscReceipt) {
|
||||||
|
formModalApi.setData({ formType: 'detail', id: row.id }).open();
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 编辑杂项入库单 */
|
||||||
|
function handleEdit(row: MesWmMiscReceiptApi.MiscReceipt) {
|
||||||
|
formModalApi.setData({ formType: 'update', id: row.id }).open();
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 执行入库 */
|
||||||
|
function handleFinish(row: MesWmMiscReceiptApi.MiscReceipt) {
|
||||||
|
formModalApi.setData({ formType: 'finish', id: row.id }).open();
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 删除杂项入库单 */
|
||||||
|
async function handleDelete(row: MesWmMiscReceiptApi.MiscReceipt) {
|
||||||
|
const loadingInstance = ElLoading.service({
|
||||||
|
text: $t('ui.actionMessage.deleting', [row.code]),
|
||||||
|
});
|
||||||
|
try {
|
||||||
|
await deleteMiscReceipt(row.id!);
|
||||||
|
ElMessage.success($t('ui.actionMessage.deleteSuccess', [row.code]));
|
||||||
|
handleRefresh();
|
||||||
|
} finally {
|
||||||
|
loadingInstance.close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 取消杂项入库单 */
|
||||||
|
async function handleCancel(row: MesWmMiscReceiptApi.MiscReceipt) {
|
||||||
|
await cancelMiscReceipt(row.id!);
|
||||||
|
ElMessage.success('取消成功');
|
||||||
|
handleRefresh();
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 导出表格 */
|
||||||
|
async function handleExport() {
|
||||||
|
const data = await exportMiscReceipt(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 getMiscReceiptPage({
|
||||||
|
pageNo: page.currentPage,
|
||||||
|
pageSize: page.pageSize,
|
||||||
|
...formValues,
|
||||||
|
});
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
rowConfig: {
|
||||||
|
keyField: 'id',
|
||||||
|
isHover: true,
|
||||||
|
},
|
||||||
|
toolbarConfig: {
|
||||||
|
refresh: true,
|
||||||
|
search: true,
|
||||||
|
},
|
||||||
|
} as VxeTableGridOptions<MesWmMiscReceiptApi.MiscReceipt>,
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<Page auto-content-height>
|
||||||
|
<template #doc>
|
||||||
|
<DocAlert
|
||||||
|
title="【仓库】其他入库、其他出库"
|
||||||
|
url="https://doc.iocoder.cn/mes/wm/misc/"
|
||||||
|
/>
|
||||||
|
</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:misc-receipt:create'],
|
||||||
|
onClick: handleCreate,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: $t('ui.actionTitle.export'),
|
||||||
|
type: 'primary',
|
||||||
|
icon: ACTION_ICON.DOWNLOAD,
|
||||||
|
auth: ['mes:wm:misc-receipt: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:misc-receipt:update'],
|
||||||
|
ifShow: row.status === MesWmMiscReceiptStatusEnum.PREPARE,
|
||||||
|
onClick: handleEdit.bind(null, row),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: $t('common.delete'),
|
||||||
|
type: 'danger',
|
||||||
|
link: true,
|
||||||
|
icon: ACTION_ICON.DELETE,
|
||||||
|
auth: ['mes:wm:misc-receipt:delete'],
|
||||||
|
ifShow: row.status === MesWmMiscReceiptStatusEnum.PREPARE,
|
||||||
|
popConfirm: {
|
||||||
|
title: $t('ui.actionMessage.deleteConfirm', [row.code]),
|
||||||
|
confirm: handleDelete.bind(null, row),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '执行入库',
|
||||||
|
type: 'primary',
|
||||||
|
link: true,
|
||||||
|
auth: ['mes:wm:misc-receipt:finish'],
|
||||||
|
ifShow: row.status === MesWmMiscReceiptStatusEnum.APPROVED,
|
||||||
|
onClick: handleFinish.bind(null, row),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '取消',
|
||||||
|
type: 'danger',
|
||||||
|
link: true,
|
||||||
|
auth: ['mes:wm:misc-receipt:cancel'],
|
||||||
|
ifShow: row.status === MesWmMiscReceiptStatusEnum.APPROVED,
|
||||||
|
popConfirm: {
|
||||||
|
title: '确认取消该杂项入库单吗?',
|
||||||
|
confirm: handleCancel.bind(null, row),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
]"
|
||||||
|
/>
|
||||||
|
</template>
|
||||||
|
</Grid>
|
||||||
|
</Page>
|
||||||
|
</template>
|
||||||
|
|
@ -0,0 +1,200 @@
|
||||||
|
<script lang="ts" setup>
|
||||||
|
import type { FormType } from '../data';
|
||||||
|
|
||||||
|
import type { MesWmMiscReceiptApi } from '#/api/mes/wm/miscreceipt';
|
||||||
|
|
||||||
|
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 {
|
||||||
|
createMiscReceipt,
|
||||||
|
finishMiscReceipt,
|
||||||
|
getMiscReceipt,
|
||||||
|
submitMiscReceipt,
|
||||||
|
updateMiscReceipt,
|
||||||
|
} from '#/api/mes/wm/miscreceipt';
|
||||||
|
import { $t } from '#/locales';
|
||||||
|
import { MesWmMiscReceiptStatusEnum } 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<MesWmMiscReceiptApi.MiscReceipt>();
|
||||||
|
const originalSnapshot = ref(''); // 表单原始数据快照,用于提交时跳过未变更的保存请求
|
||||||
|
const isEditable = computed(() => // 是否为编辑模式(可保存)
|
||||||
|
['create', 'update'].includes(formType.value),
|
||||||
|
);
|
||||||
|
const isFinish = computed(() => formType.value === 'finish'); // 是否为执行入库模式
|
||||||
|
const canSubmit = computed(() => // 是否可提交
|
||||||
|
formType.value === 'update' &&
|
||||||
|
formData.value?.status === MesWmMiscReceiptStatusEnum.PREPARE,
|
||||||
|
);
|
||||||
|
const getTitle = computed(() => {
|
||||||
|
if (formType.value === 'detail') {
|
||||||
|
return $t('ui.actionTitle.view', ['杂项入库单']);
|
||||||
|
}
|
||||||
|
if (formType.value === 'finish') {
|
||||||
|
return '执行入库';
|
||||||
|
}
|
||||||
|
return formType.value === 'update'
|
||||||
|
? $t('ui.actionTitle.edit', ['杂项入库单'])
|
||||||
|
: $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 MesWmMiscReceiptApi.MiscReceipt;
|
||||||
|
await updateMiscReceipt({ ...formData.value, ...data });
|
||||||
|
originalSnapshot.value = current;
|
||||||
|
}
|
||||||
|
await submitMiscReceipt(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 finishMiscReceipt(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 MesWmMiscReceiptApi.MiscReceipt;
|
||||||
|
try {
|
||||||
|
if (formData.value?.id) {
|
||||||
|
await updateMiscReceipt({ ...formData.value, ...data });
|
||||||
|
formData.value = { ...formData.value, ...data };
|
||||||
|
} else {
|
||||||
|
const id = await createMiscReceipt(data);
|
||||||
|
formData.value = {
|
||||||
|
...data,
|
||||||
|
id,
|
||||||
|
status: MesWmMiscReceiptStatusEnum.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(formType.value === 'detail' || formType.value === 'finish');
|
||||||
|
modalApi.setState({ showConfirmButton: isEditable.value });
|
||||||
|
if (data?.id) {
|
||||||
|
modalApi.lock();
|
||||||
|
try {
|
||||||
|
formData.value = await getMiscReceipt(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" :receipt-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>
|
||||||
|
<ElPopconfirm
|
||||||
|
v-if="isFinish"
|
||||||
|
title="确认执行入库?执行后将更新库存台账。"
|
||||||
|
width="260"
|
||||||
|
@confirm="handleFinish"
|
||||||
|
>
|
||||||
|
<template #reference>
|
||||||
|
<ElButton type="primary">执行入库</ElButton>
|
||||||
|
</template>
|
||||||
|
</ElPopconfirm>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
</Modal>
|
||||||
|
</template>
|
||||||
|
|
@ -0,0 +1,98 @@
|
||||||
|
<script lang="ts" setup>
|
||||||
|
import type { MesWmMiscReceiptLineApi } from '#/api/mes/wm/miscreceipt/line';
|
||||||
|
|
||||||
|
import { computed, ref } from 'vue';
|
||||||
|
|
||||||
|
import { useVbenModal } from '@vben/common-ui';
|
||||||
|
|
||||||
|
import { ElMessage } from 'element-plus';
|
||||||
|
|
||||||
|
import { useVbenForm } from '#/adapter/form';
|
||||||
|
import {
|
||||||
|
createMiscReceiptLine,
|
||||||
|
getMiscReceiptLine,
|
||||||
|
updateMiscReceiptLine,
|
||||||
|
} from '#/api/mes/wm/miscreceipt/line';
|
||||||
|
import { $t } from '#/locales';
|
||||||
|
|
||||||
|
import { useLineFormSchema } from '../data';
|
||||||
|
|
||||||
|
const emit = defineEmits(['success']);
|
||||||
|
const formData = ref<MesWmMiscReceiptLineApi.MiscReceiptLine>();
|
||||||
|
const receiptId = 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: useLineFormSchema(),
|
||||||
|
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 MesWmMiscReceiptLineApi.MiscReceiptLine;
|
||||||
|
data.receiptId = receiptId.value;
|
||||||
|
try {
|
||||||
|
await (formData.value?.id
|
||||||
|
? updateMiscReceiptLine({ ...data, id: formData.value.id })
|
||||||
|
: createMiscReceiptLine(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;
|
||||||
|
receiptId: number;
|
||||||
|
}>();
|
||||||
|
receiptId.value = data.receiptId;
|
||||||
|
if (!data.id) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
modalApi.lock();
|
||||||
|
try {
|
||||||
|
formData.value = await getMiscReceiptLine(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,137 @@
|
||||||
|
<script lang="ts" setup>
|
||||||
|
import type { VxeTableGridOptions } from '#/adapter/vxe-table';
|
||||||
|
import type { MesWmMiscReceiptLineApi } from '#/api/mes/wm/miscreceipt/line';
|
||||||
|
|
||||||
|
import { computed } from 'vue';
|
||||||
|
|
||||||
|
import { useVbenModal } from '@vben/common-ui';
|
||||||
|
|
||||||
|
import { ElLoading, ElMessage } from 'element-plus';
|
||||||
|
|
||||||
|
import { ACTION_ICON, TableAction, useVbenVxeGrid } from '#/adapter/vxe-table';
|
||||||
|
import {
|
||||||
|
deleteMiscReceiptLine,
|
||||||
|
getMiscReceiptLineListByReceiptId,
|
||||||
|
} from '#/api/mes/wm/miscreceipt/line';
|
||||||
|
import { $t } from '#/locales';
|
||||||
|
|
||||||
|
import { type FormType, useLineGridColumns } from '../data';
|
||||||
|
import LineForm from './line-form.vue';
|
||||||
|
|
||||||
|
const props = defineProps<{
|
||||||
|
formType: FormType;
|
||||||
|
receiptId: number;
|
||||||
|
}>();
|
||||||
|
|
||||||
|
const isEditable = computed(() => // 是否可编辑明细行
|
||||||
|
['create', 'update'].includes(props.formType),
|
||||||
|
);
|
||||||
|
|
||||||
|
const [LineFormModal, lineFormModalApi] = useVbenModal({
|
||||||
|
connectedComponent: LineForm,
|
||||||
|
destroyOnClose: true,
|
||||||
|
});
|
||||||
|
|
||||||
|
/** 刷新表格 */
|
||||||
|
function handleRefresh() {
|
||||||
|
gridApi.query();
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 添加物料 */
|
||||||
|
function handleCreate() {
|
||||||
|
lineFormModalApi.setData({ receiptId: props.receiptId }).open();
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 编辑物料 */
|
||||||
|
function handleEdit(row: MesWmMiscReceiptLineApi.MiscReceiptLine) {
|
||||||
|
lineFormModalApi.setData({ id: row.id, receiptId: props.receiptId }).open();
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 删除物料 */
|
||||||
|
async function handleDelete(row: MesWmMiscReceiptLineApi.MiscReceiptLine) {
|
||||||
|
const loadingInstance = ElLoading.service({
|
||||||
|
text: $t('ui.actionMessage.deleting', [row.itemName]),
|
||||||
|
});
|
||||||
|
try {
|
||||||
|
await deleteMiscReceiptLine(row.id!);
|
||||||
|
ElMessage.success($t('ui.actionMessage.deleteSuccess', [row.itemName]));
|
||||||
|
handleRefresh();
|
||||||
|
} finally {
|
||||||
|
loadingInstance.close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const [Grid, gridApi] = useVbenVxeGrid({
|
||||||
|
gridOptions: {
|
||||||
|
columns: useLineGridColumns(isEditable.value),
|
||||||
|
height: 360,
|
||||||
|
keepSource: true,
|
||||||
|
pagerConfig: {
|
||||||
|
enabled: false,
|
||||||
|
},
|
||||||
|
proxyConfig: {
|
||||||
|
ajax: {
|
||||||
|
query: async () => {
|
||||||
|
if (!props.receiptId) {
|
||||||
|
return { list: [], total: 0 };
|
||||||
|
}
|
||||||
|
const list = await getMiscReceiptLineListByReceiptId(props.receiptId);
|
||||||
|
return { list, total: list.length };
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
rowConfig: {
|
||||||
|
keyField: 'id',
|
||||||
|
isHover: true,
|
||||||
|
},
|
||||||
|
toolbarConfig: {
|
||||||
|
refresh: true,
|
||||||
|
},
|
||||||
|
} as VxeTableGridOptions<MesWmMiscReceiptLineApi.MiscReceiptLine>,
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<div>
|
||||||
|
<LineFormModal @success="handleRefresh" />
|
||||||
|
<Grid table-title="物料信息">
|
||||||
|
<template v-if="isEditable" #toolbar-tools>
|
||||||
|
<TableAction
|
||||||
|
:actions="[
|
||||||
|
{
|
||||||
|
label: '添加物料',
|
||||||
|
type: 'primary',
|
||||||
|
icon: ACTION_ICON.ADD,
|
||||||
|
onClick: handleCreate,
|
||||||
|
},
|
||||||
|
]"
|
||||||
|
/>
|
||||||
|
</template>
|
||||||
|
<template #actions="{ row }">
|
||||||
|
<TableAction
|
||||||
|
:actions="[
|
||||||
|
{
|
||||||
|
label: $t('common.edit'),
|
||||||
|
type: 'primary',
|
||||||
|
link: true,
|
||||||
|
icon: ACTION_ICON.EDIT,
|
||||||
|
ifShow: isEditable,
|
||||||
|
onClick: handleEdit.bind(null, row),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: $t('common.delete'),
|
||||||
|
type: 'danger',
|
||||||
|
link: true,
|
||||||
|
icon: ACTION_ICON.DELETE,
|
||||||
|
ifShow: isEditable,
|
||||||
|
popConfirm: {
|
||||||
|
title: $t('ui.actionMessage.deleteConfirm', [row.itemName]),
|
||||||
|
confirm: handleDelete.bind(null, row),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
]"
|
||||||
|
/>
|
||||||
|
</template>
|
||||||
|
</Grid>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
Loading…
Reference in New Issue