feat(mes/qc): 迁移批次追溯(batchtrace)ele 端 + antd 改用 Vben Description
- ele: 新增 mes/wm/batch API、batchtrace 主页和向前/向后追溯子组件,
与 antd 端实现保持一致
- antd: trace-detail 改用 useDescription({ schema }) 模式,schema
抽到 data.ts 的 useDetailSchema();trace-list 的 pagerConfig /
rowConfig / toolbarConfig 单行展开为多行
pull/350/head
parent
76e9df6e8e
commit
b2ccdf80b2
|
|
@ -1,6 +1,7 @@
|
||||||
import type { VbenFormSchema } from '#/adapter/form';
|
import type { VbenFormSchema } from '#/adapter/form';
|
||||||
import type { VxeTableGridOptions } from '#/adapter/vxe-table';
|
import type { VxeTableGridOptions } from '#/adapter/vxe-table';
|
||||||
import type { MesWmBatchApi } from '#/api/mes/wm/batch';
|
import type { MesWmBatchApi } from '#/api/mes/wm/batch';
|
||||||
|
import type { DescriptionItemSchema } from '#/components/description';
|
||||||
|
|
||||||
import { markRaw } from 'vue';
|
import { markRaw } from 'vue';
|
||||||
|
|
||||||
|
|
@ -167,3 +168,62 @@ export function useTraceGridColumns(): VxeTableGridOptions<MesWmBatchApi.Batch>[
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** 批次追溯详情的描述字段 */
|
||||||
|
export function useDetailSchema(): DescriptionItemSchema[] {
|
||||||
|
return [
|
||||||
|
{
|
||||||
|
field: 'code',
|
||||||
|
label: '批次编号',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
field: 'itemCode',
|
||||||
|
label: '物资编码',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
field: 'itemName',
|
||||||
|
label: '物资名称',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
field: 'itemSpecification',
|
||||||
|
label: '规格型号',
|
||||||
|
span: 3,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
field: 'purchaseOrderCode',
|
||||||
|
label: '采购订单编号',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
field: 'vendorCode',
|
||||||
|
label: '供应商编码',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
field: 'vendorName',
|
||||||
|
label: '供应商名称',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
field: 'salesOrderCode',
|
||||||
|
label: '销售订单编号',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
field: 'clientCode',
|
||||||
|
label: '客户编码',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
field: 'clientName',
|
||||||
|
label: '客户名称',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
field: 'lotNumber',
|
||||||
|
label: '生产批号',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
field: 'workOrderCode',
|
||||||
|
label: '生产工单',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
field: 'workstationCode',
|
||||||
|
label: '工作站编码',
|
||||||
|
},
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -5,13 +5,22 @@ import { ref } from 'vue';
|
||||||
|
|
||||||
import { useVbenModal } from '@vben/common-ui';
|
import { useVbenModal } from '@vben/common-ui';
|
||||||
|
|
||||||
import { Descriptions, Tabs } from 'ant-design-vue';
|
import { Tabs } from 'ant-design-vue';
|
||||||
|
|
||||||
|
import { useDescription } from '#/components/description';
|
||||||
|
|
||||||
|
import { useDetailSchema } from '../data';
|
||||||
import TraceList from './trace-list.vue';
|
import TraceList from './trace-list.vue';
|
||||||
|
|
||||||
const detailData = ref<MesWmBatchApi.Batch>(); // 当前批次详情
|
const detailData = ref<MesWmBatchApi.Batch>(); // 当前批次详情
|
||||||
const subTabsName = ref<'backward' | 'forward'>('forward'); // 当前激活的追溯方向
|
const subTabsName = ref<'backward' | 'forward'>('forward'); // 当前激活的追溯方向
|
||||||
|
|
||||||
|
const [Descriptions] = useDescription({
|
||||||
|
bordered: true,
|
||||||
|
column: 3,
|
||||||
|
schema: useDetailSchema(),
|
||||||
|
});
|
||||||
|
|
||||||
const [Modal, modalApi] = useVbenModal({
|
const [Modal, modalApi] = useVbenModal({
|
||||||
onOpenChange(isOpen) {
|
onOpenChange(isOpen) {
|
||||||
if (!isOpen) {
|
if (!isOpen) {
|
||||||
|
|
@ -31,53 +40,11 @@ const [Modal, modalApi] = useVbenModal({
|
||||||
:show-cancel-button="false"
|
:show-cancel-button="false"
|
||||||
:show-confirm-button="false"
|
:show-confirm-button="false"
|
||||||
>
|
>
|
||||||
<div class="mx-4 mt-2">
|
<Descriptions class="mx-4 mt-2" :data="detailData" />
|
||||||
<Descriptions :column="3" bordered size="small">
|
|
||||||
<Descriptions.Item label="批次编号">
|
|
||||||
{{ detailData?.code || '-' }}
|
|
||||||
</Descriptions.Item>
|
|
||||||
<Descriptions.Item label="物资编码">
|
|
||||||
{{ detailData?.itemCode || '-' }}
|
|
||||||
</Descriptions.Item>
|
|
||||||
<Descriptions.Item label="物资名称">
|
|
||||||
{{ detailData?.itemName || '-' }}
|
|
||||||
</Descriptions.Item>
|
|
||||||
<Descriptions.Item label="规格型号" :span="3">
|
|
||||||
{{ detailData?.itemSpecification || '-' }}
|
|
||||||
</Descriptions.Item>
|
|
||||||
<Descriptions.Item label="采购订单编号">
|
|
||||||
{{ detailData?.purchaseOrderCode || '-' }}
|
|
||||||
</Descriptions.Item>
|
|
||||||
<Descriptions.Item label="供应商编码">
|
|
||||||
{{ detailData?.vendorCode || '-' }}
|
|
||||||
</Descriptions.Item>
|
|
||||||
<Descriptions.Item label="供应商名称">
|
|
||||||
{{ detailData?.vendorName || '-' }}
|
|
||||||
</Descriptions.Item>
|
|
||||||
<Descriptions.Item label="销售订单编号">
|
|
||||||
{{ detailData?.salesOrderCode || '-' }}
|
|
||||||
</Descriptions.Item>
|
|
||||||
<Descriptions.Item label="客户编码">
|
|
||||||
{{ detailData?.clientCode || '-' }}
|
|
||||||
</Descriptions.Item>
|
|
||||||
<Descriptions.Item label="客户名称">
|
|
||||||
{{ detailData?.clientName || '-' }}
|
|
||||||
</Descriptions.Item>
|
|
||||||
<Descriptions.Item label="生产批号">
|
|
||||||
{{ detailData?.lotNumber || '-' }}
|
|
||||||
</Descriptions.Item>
|
|
||||||
<Descriptions.Item label="生产工单">
|
|
||||||
{{ detailData?.workOrderCode || '-' }}
|
|
||||||
</Descriptions.Item>
|
|
||||||
<Descriptions.Item label="工作站编码">
|
|
||||||
{{ detailData?.workstationCode || '-' }}
|
|
||||||
</Descriptions.Item>
|
|
||||||
</Descriptions>
|
|
||||||
</div>
|
|
||||||
<Tabs
|
<Tabs
|
||||||
v-if="detailData?.code"
|
v-if="detailData?.code"
|
||||||
v-model:active-key="subTabsName"
|
v-model:active-key="subTabsName"
|
||||||
class="mx-4! mt-4!"
|
class="mx-4 mt-4"
|
||||||
type="card"
|
type="card"
|
||||||
>
|
>
|
||||||
<Tabs.TabPane key="forward" tab="向前追溯">
|
<Tabs.TabPane key="forward" tab="向前追溯">
|
||||||
|
|
|
||||||
|
|
@ -21,10 +21,17 @@ const [Grid, gridApi] = useVbenVxeGrid({
|
||||||
gridOptions: {
|
gridOptions: {
|
||||||
columns: useTraceGridColumns(),
|
columns: useTraceGridColumns(),
|
||||||
minHeight: 240,
|
minHeight: 240,
|
||||||
pagerConfig: { enabled: false },
|
pagerConfig: {
|
||||||
rowConfig: { isHover: true, keyField: 'id' },
|
enabled: false,
|
||||||
|
},
|
||||||
|
rowConfig: {
|
||||||
|
isHover: true,
|
||||||
|
keyField: 'id',
|
||||||
|
},
|
||||||
showOverflow: true,
|
showOverflow: true,
|
||||||
toolbarConfig: { enabled: false },
|
toolbarConfig: {
|
||||||
|
enabled: false,
|
||||||
|
},
|
||||||
} as VxeTableGridOptions<MesWmBatchApi.Batch>,
|
} as VxeTableGridOptions<MesWmBatchApi.Batch>,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,67 @@
|
||||||
|
import type { PageParam, PageResult } from '@vben/request';
|
||||||
|
|
||||||
|
import { requestClient } from '#/api/request';
|
||||||
|
|
||||||
|
export namespace MesWmBatchApi {
|
||||||
|
/** MES 批次 */
|
||||||
|
export interface Batch {
|
||||||
|
id?: number; // 批次 ID
|
||||||
|
code?: string; // 批次编码
|
||||||
|
itemId?: number; // 物料 ID
|
||||||
|
itemCode?: string; // 物料编码
|
||||||
|
itemName?: string; // 物料名称
|
||||||
|
itemSpecification?: string; // 规格型号
|
||||||
|
unitName?: string; // 单位名称
|
||||||
|
produceDate?: Date; // 生产日期
|
||||||
|
expireDate?: Date; // 有效期
|
||||||
|
receiptDate?: Date; // 入库日期
|
||||||
|
vendorId?: number; // 供应商 ID
|
||||||
|
vendorCode?: string; // 供应商编码
|
||||||
|
vendorName?: string; // 供应商名称
|
||||||
|
clientId?: number; // 客户 ID
|
||||||
|
clientCode?: string; // 客户编码
|
||||||
|
clientName?: string; // 客户名称
|
||||||
|
purchaseOrderCode?: string; // 采购订单编号
|
||||||
|
salesOrderCode?: string; // 销售订单编号
|
||||||
|
workOrderId?: number; // 生产工单 ID
|
||||||
|
workOrderCode?: string; // 生产工单编号
|
||||||
|
taskId?: number; // 生产任务 ID
|
||||||
|
taskCode?: string; // 生产任务编号
|
||||||
|
workstationId?: number; // 工作站 ID
|
||||||
|
workstationCode?: string; // 工作站编码
|
||||||
|
toolId?: number; // 工具 ID
|
||||||
|
toolCode?: string; // 工具编号
|
||||||
|
moldId?: number; // 模具 ID
|
||||||
|
lotNumber?: string; // 生产批号
|
||||||
|
qualityStatus?: number; // 质量状态
|
||||||
|
remark?: string; // 备注
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 查询批次详情 */
|
||||||
|
export function getBatch(id: number) {
|
||||||
|
return requestClient.get<MesWmBatchApi.Batch>(`/mes/wm/batch/get?id=${id}`);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 查询批次分页 */
|
||||||
|
export function getBatchPage(params: PageParam) {
|
||||||
|
return requestClient.get<PageResult<MesWmBatchApi.Batch>>(
|
||||||
|
'/mes/wm/batch/page',
|
||||||
|
{ params },
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 批次向前追溯 */
|
||||||
|
export function getForwardBatchList(code: string) {
|
||||||
|
return requestClient.get<MesWmBatchApi.Batch[]>('/mes/wm/batch/forward-list', {
|
||||||
|
params: { code },
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 批次向后追溯 */
|
||||||
|
export function getBackwardBatchList(code: string) {
|
||||||
|
return requestClient.get<MesWmBatchApi.Batch[]>(
|
||||||
|
'/mes/wm/batch/backward-list',
|
||||||
|
{ params: { code } },
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,229 @@
|
||||||
|
import type { VbenFormSchema } from '#/adapter/form';
|
||||||
|
import type { VxeTableGridOptions } from '#/adapter/vxe-table';
|
||||||
|
import type { MesWmBatchApi } from '#/api/mes/wm/batch';
|
||||||
|
import type { DescriptionItemSchema } from '#/components/description';
|
||||||
|
|
||||||
|
import { markRaw } from 'vue';
|
||||||
|
|
||||||
|
import MdClientSelect from '#/views/mes/md/client/components/md-client-select.vue';
|
||||||
|
import MdItemSelect from '#/views/mes/md/item/components/md-item-select.vue';
|
||||||
|
import MdVendorSelect from '#/views/mes/md/vendor/components/md-vendor-select.vue';
|
||||||
|
|
||||||
|
/** 列表的搜索表单 */
|
||||||
|
export function useGridFormSchema(): VbenFormSchema[] {
|
||||||
|
return [
|
||||||
|
{
|
||||||
|
fieldName: 'code',
|
||||||
|
label: '批次号',
|
||||||
|
component: 'Input',
|
||||||
|
componentProps: {
|
||||||
|
clearable: true,
|
||||||
|
placeholder: '请输入批次号',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
fieldName: 'itemId',
|
||||||
|
label: '产品物料',
|
||||||
|
component: markRaw(MdItemSelect),
|
||||||
|
componentProps: {
|
||||||
|
placeholder: '请选择产品物料',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
fieldName: 'vendorId',
|
||||||
|
label: '供应商',
|
||||||
|
component: markRaw(MdVendorSelect),
|
||||||
|
componentProps: {
|
||||||
|
placeholder: '请选择供应商',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
fieldName: 'clientId',
|
||||||
|
label: '客户',
|
||||||
|
component: markRaw(MdClientSelect),
|
||||||
|
componentProps: {
|
||||||
|
placeholder: '请选择客户',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
fieldName: 'salesOrderCode',
|
||||||
|
label: '销售订单编号',
|
||||||
|
component: 'Input',
|
||||||
|
componentProps: {
|
||||||
|
clearable: true,
|
||||||
|
placeholder: '请输入销售订单编号',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
fieldName: 'purchaseOrderCode',
|
||||||
|
label: '采购订单编号',
|
||||||
|
component: 'Input',
|
||||||
|
componentProps: {
|
||||||
|
clearable: true,
|
||||||
|
placeholder: '请输入采购订单编号',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 列表的字段 */
|
||||||
|
export function useGridColumns(): VxeTableGridOptions<MesWmBatchApi.Batch>['columns'] {
|
||||||
|
return [
|
||||||
|
{
|
||||||
|
field: 'code',
|
||||||
|
title: '批次编号',
|
||||||
|
minWidth: 160,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
field: 'itemCode',
|
||||||
|
title: '产品物料编码',
|
||||||
|
minWidth: 140,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
field: 'itemName',
|
||||||
|
title: '产品物料名称',
|
||||||
|
minWidth: 160,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
field: 'itemSpecification',
|
||||||
|
title: '规格型号',
|
||||||
|
minWidth: 140,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
field: 'unitName',
|
||||||
|
title: '单位',
|
||||||
|
width: 80,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
field: 'vendorCode',
|
||||||
|
title: '供应商编码',
|
||||||
|
minWidth: 140,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
field: 'vendorName',
|
||||||
|
title: '供应商名称',
|
||||||
|
minWidth: 160,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
field: 'clientCode',
|
||||||
|
title: '客户编码',
|
||||||
|
minWidth: 140,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
field: 'clientName',
|
||||||
|
title: '客户名称',
|
||||||
|
minWidth: 160,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
field: 'salesOrderCode',
|
||||||
|
title: '销售订单编号',
|
||||||
|
minWidth: 160,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
field: 'purchaseOrderCode',
|
||||||
|
title: '采购订单编号',
|
||||||
|
minWidth: 160,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '操作',
|
||||||
|
width: 110,
|
||||||
|
fixed: 'right',
|
||||||
|
slots: { default: 'actions' },
|
||||||
|
},
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 追溯明细列表的字段 */
|
||||||
|
export function useTraceGridColumns(): VxeTableGridOptions<MesWmBatchApi.Batch>['columns'] {
|
||||||
|
return [
|
||||||
|
{
|
||||||
|
field: 'workOrderCode',
|
||||||
|
title: '生产工单号',
|
||||||
|
width: 160,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
field: 'code',
|
||||||
|
title: '批次编号',
|
||||||
|
minWidth: 160,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
field: 'itemCode',
|
||||||
|
title: '产品物料编码',
|
||||||
|
minWidth: 140,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
field: 'itemName',
|
||||||
|
title: '产品物料名称',
|
||||||
|
minWidth: 160,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
field: 'itemSpecification',
|
||||||
|
title: '规格型号',
|
||||||
|
minWidth: 140,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
field: 'unitName',
|
||||||
|
title: '单位',
|
||||||
|
width: 80,
|
||||||
|
},
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 批次追溯详情的描述字段 */
|
||||||
|
export function useDetailSchema(): DescriptionItemSchema[] {
|
||||||
|
return [
|
||||||
|
{
|
||||||
|
field: 'code',
|
||||||
|
label: '批次编号',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
field: 'itemCode',
|
||||||
|
label: '物资编码',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
field: 'itemName',
|
||||||
|
label: '物资名称',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
field: 'itemSpecification',
|
||||||
|
label: '规格型号',
|
||||||
|
span: 3,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
field: 'purchaseOrderCode',
|
||||||
|
label: '采购订单编号',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
field: 'vendorCode',
|
||||||
|
label: '供应商编码',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
field: 'vendorName',
|
||||||
|
label: '供应商名称',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
field: 'salesOrderCode',
|
||||||
|
label: '销售订单编号',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
field: 'clientCode',
|
||||||
|
label: '客户编码',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
field: 'clientName',
|
||||||
|
label: '客户名称',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
field: 'lotNumber',
|
||||||
|
label: '生产批号',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
field: 'workOrderCode',
|
||||||
|
label: '生产工单',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
field: 'workstationCode',
|
||||||
|
label: '工作站编码',
|
||||||
|
},
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,82 @@
|
||||||
|
<script lang="ts" setup>
|
||||||
|
import type { VxeTableGridOptions } from '#/adapter/vxe-table';
|
||||||
|
import type { MesWmBatchApi } from '#/api/mes/wm/batch';
|
||||||
|
|
||||||
|
import { DocAlert, Page, useVbenModal } from '@vben/common-ui';
|
||||||
|
|
||||||
|
import { ACTION_ICON, TableAction, useVbenVxeGrid } from '#/adapter/vxe-table';
|
||||||
|
import { getBatchPage } from '#/api/mes/wm/batch';
|
||||||
|
|
||||||
|
import { useGridColumns, useGridFormSchema } from './data';
|
||||||
|
import TraceDetail from './modules/trace-detail.vue';
|
||||||
|
|
||||||
|
const [DetailModal, detailModalApi] = useVbenModal({
|
||||||
|
connectedComponent: TraceDetail,
|
||||||
|
destroyOnClose: true,
|
||||||
|
});
|
||||||
|
|
||||||
|
/** 打开批次追溯详情 */
|
||||||
|
function handleTrace(row: MesWmBatchApi.Batch) {
|
||||||
|
detailModalApi.setData(row).open();
|
||||||
|
}
|
||||||
|
|
||||||
|
const [Grid] = useVbenVxeGrid({
|
||||||
|
formOptions: {
|
||||||
|
schema: useGridFormSchema(),
|
||||||
|
},
|
||||||
|
gridOptions: {
|
||||||
|
columns: useGridColumns(),
|
||||||
|
height: 'auto',
|
||||||
|
keepSource: true,
|
||||||
|
proxyConfig: {
|
||||||
|
ajax: {
|
||||||
|
query: async ({ page }, formValues) => {
|
||||||
|
return await getBatchPage({
|
||||||
|
pageNo: page.currentPage,
|
||||||
|
pageSize: page.pageSize,
|
||||||
|
...formValues,
|
||||||
|
});
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
rowConfig: {
|
||||||
|
keyField: 'id',
|
||||||
|
isHover: true,
|
||||||
|
},
|
||||||
|
toolbarConfig: {
|
||||||
|
refresh: true,
|
||||||
|
search: true,
|
||||||
|
},
|
||||||
|
} as VxeTableGridOptions<MesWmBatchApi.Batch>,
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<Page auto-content-height>
|
||||||
|
<template #doc>
|
||||||
|
<DocAlert
|
||||||
|
title="【仓库】批次管理、库存现有量、库存事务"
|
||||||
|
url="https://doc.iocoder.cn/mes/wm/stock/"
|
||||||
|
/>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<DetailModal />
|
||||||
|
|
||||||
|
<Grid table-title="批次追溯列表">
|
||||||
|
<template #actions="{ row }">
|
||||||
|
<TableAction
|
||||||
|
:actions="[
|
||||||
|
{
|
||||||
|
label: '批次追溯',
|
||||||
|
type: 'primary',
|
||||||
|
link: true,
|
||||||
|
icon: ACTION_ICON.VIEW,
|
||||||
|
auth: ['mes:wm-batch:query'],
|
||||||
|
onClick: handleTrace.bind(null, row),
|
||||||
|
},
|
||||||
|
]"
|
||||||
|
/>
|
||||||
|
</template>
|
||||||
|
</Grid>
|
||||||
|
</Page>
|
||||||
|
</template>
|
||||||
|
|
@ -0,0 +1,58 @@
|
||||||
|
<script lang="ts" setup>
|
||||||
|
import type { MesWmBatchApi } from '#/api/mes/wm/batch';
|
||||||
|
|
||||||
|
import { ref } from 'vue';
|
||||||
|
|
||||||
|
import { useVbenModal } from '@vben/common-ui';
|
||||||
|
|
||||||
|
import { ElTabPane, ElTabs } from 'element-plus';
|
||||||
|
|
||||||
|
import { useDescription } from '#/components/description';
|
||||||
|
|
||||||
|
import { useDetailSchema } from '../data';
|
||||||
|
import TraceList from './trace-list.vue';
|
||||||
|
|
||||||
|
const detailData = ref<MesWmBatchApi.Batch>(); // 当前批次详情
|
||||||
|
const subTabsName = ref<'backward' | 'forward'>('forward'); // 当前激活的追溯方向
|
||||||
|
|
||||||
|
const [Descriptions] = useDescription({
|
||||||
|
border: true,
|
||||||
|
column: 3,
|
||||||
|
schema: useDetailSchema(),
|
||||||
|
});
|
||||||
|
|
||||||
|
const [Modal, modalApi] = useVbenModal({
|
||||||
|
onOpenChange(isOpen) {
|
||||||
|
if (!isOpen) {
|
||||||
|
detailData.value = undefined;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
detailData.value = modalApi.getData<MesWmBatchApi.Batch>();
|
||||||
|
subTabsName.value = 'forward';
|
||||||
|
},
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<Modal
|
||||||
|
title="批次追溯"
|
||||||
|
class="w-4/5"
|
||||||
|
:show-cancel-button="false"
|
||||||
|
:show-confirm-button="false"
|
||||||
|
>
|
||||||
|
<Descriptions class="mx-4 mt-2" :data="detailData" />
|
||||||
|
<ElTabs
|
||||||
|
v-if="detailData?.code"
|
||||||
|
v-model="subTabsName"
|
||||||
|
class="mx-4 mt-4"
|
||||||
|
type="card"
|
||||||
|
>
|
||||||
|
<ElTabPane label="向前追溯" name="forward">
|
||||||
|
<TraceList :batch-code="detailData.code" direction="forward" />
|
||||||
|
</ElTabPane>
|
||||||
|
<ElTabPane label="向后追溯" name="backward">
|
||||||
|
<TraceList :batch-code="detailData.code" direction="backward" />
|
||||||
|
</ElTabPane>
|
||||||
|
</ElTabs>
|
||||||
|
</Modal>
|
||||||
|
</template>
|
||||||
|
|
@ -0,0 +1,67 @@
|
||||||
|
<script lang="ts" setup>
|
||||||
|
import type { VxeTableGridOptions } from '#/adapter/vxe-table';
|
||||||
|
import type { MesWmBatchApi } from '#/api/mes/wm/batch';
|
||||||
|
|
||||||
|
import { watch } from 'vue';
|
||||||
|
|
||||||
|
import { useVbenVxeGrid } from '#/adapter/vxe-table';
|
||||||
|
import {
|
||||||
|
getBackwardBatchList,
|
||||||
|
getForwardBatchList,
|
||||||
|
} from '#/api/mes/wm/batch';
|
||||||
|
|
||||||
|
import { useTraceGridColumns } from '../data';
|
||||||
|
|
||||||
|
const props = defineProps<{
|
||||||
|
batchCode?: string;
|
||||||
|
direction: 'backward' | 'forward'; // 追溯方向:forward=向前,backward=向后
|
||||||
|
}>();
|
||||||
|
|
||||||
|
const [Grid, gridApi] = useVbenVxeGrid({
|
||||||
|
gridOptions: {
|
||||||
|
columns: useTraceGridColumns(),
|
||||||
|
minHeight: 240,
|
||||||
|
pagerConfig: {
|
||||||
|
enabled: false,
|
||||||
|
},
|
||||||
|
rowConfig: {
|
||||||
|
isHover: true,
|
||||||
|
keyField: 'id',
|
||||||
|
},
|
||||||
|
showOverflow: true,
|
||||||
|
toolbarConfig: {
|
||||||
|
enabled: false,
|
||||||
|
},
|
||||||
|
} as VxeTableGridOptions<MesWmBatchApi.Batch>,
|
||||||
|
});
|
||||||
|
|
||||||
|
/** 加载追溯列表 */
|
||||||
|
async function getList() {
|
||||||
|
if (!props.batchCode) {
|
||||||
|
await gridApi.grid?.loadData([]);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
gridApi.setLoading(true);
|
||||||
|
try {
|
||||||
|
const list =
|
||||||
|
props.direction === 'forward'
|
||||||
|
? await getForwardBatchList(props.batchCode)
|
||||||
|
: await getBackwardBatchList(props.batchCode);
|
||||||
|
await gridApi.grid?.loadData(list);
|
||||||
|
} finally {
|
||||||
|
gridApi.setLoading(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
watch(
|
||||||
|
() => props.batchCode,
|
||||||
|
() => {
|
||||||
|
getList();
|
||||||
|
},
|
||||||
|
{ immediate: true },
|
||||||
|
);
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<Grid class="w-full" />
|
||||||
|
</template>
|
||||||
Loading…
Reference in New Issue