feat(mes): 迁移 ipqc、oqc、rqc 功能
parent
76260e67f3
commit
d245eca60d
|
|
@ -0,0 +1,566 @@
|
|||
import type { VbenFormApi, VbenFormSchema } from '#/adapter/form';
|
||||
import type { VxeTableGridOptions } from '#/adapter/vxe-table';
|
||||
import type { MesQcIpqcApi } from '#/api/mes/qc/ipqc';
|
||||
import type { MesQcIpqcLineApi } from '#/api/mes/qc/ipqc/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 { getSimpleUserList } from '#/api/system/user';
|
||||
import MdItemSelect from '#/views/mes/md/item/components/md-item-select.vue';
|
||||
import MdWorkstationSelect from '#/views/mes/md/workstation/components/md-workstation-select.vue';
|
||||
import ProTaskSelect from '#/views/mes/pro/task/components/pro-task-select.vue';
|
||||
import ProWorkOrderSelect from '#/views/mes/pro/workorder/components/pro-work-order-select.vue';
|
||||
import {
|
||||
MesAutoCodeRuleCode,
|
||||
MesProTaskStatusEnum,
|
||||
MesProWorkOrderStatusEnum,
|
||||
} from '#/views/mes/utils/constants';
|
||||
|
||||
/** 表单类型 */
|
||||
export type FormType = 'create' | 'detail' | 'update';
|
||||
|
||||
/** 把不合格品数量同步为工废 + 料废 + 其他废品之和 */
|
||||
function syncUnqualified(formApi?: VbenFormApi) {
|
||||
if (!formApi) {
|
||||
return;
|
||||
}
|
||||
void (async () => {
|
||||
const values = await formApi.getValues();
|
||||
const next =
|
||||
Number(values.laborScrapQuantity || 0) +
|
||||
Number(values.materialScrapQuantity || 0) +
|
||||
Number(values.otherScrapQuantity || 0);
|
||||
await formApi.setFieldValue('unqualifiedQuantity', next);
|
||||
})();
|
||||
}
|
||||
|
||||
/** 新增/修改的表单 */
|
||||
export function useFormSchema(formApi?: VbenFormApi): VbenFormSchema[] {
|
||||
return [
|
||||
{
|
||||
fieldName: 'id',
|
||||
component: 'Input',
|
||||
dependencies: {
|
||||
triggerFields: [''],
|
||||
show: () => false,
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldName: 'sourceDocId',
|
||||
component: 'Input',
|
||||
dependencies: {
|
||||
triggerFields: [''],
|
||||
show: () => false,
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldName: 'sourceLineId',
|
||||
component: 'Input',
|
||||
dependencies: {
|
||||
triggerFields: [''],
|
||||
show: () => false,
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldName: 'status',
|
||||
component: 'Input',
|
||||
dependencies: {
|
||||
triggerFields: [''],
|
||||
show: () => false,
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldName: 'code',
|
||||
label: '检验单编号',
|
||||
component: 'Input',
|
||||
componentProps: {
|
||||
placeholder: '请输入检验单编号',
|
||||
},
|
||||
rules: 'required',
|
||||
suffix: () =>
|
||||
h(
|
||||
Button,
|
||||
{
|
||||
type: 'default',
|
||||
onClick: async () => {
|
||||
try {
|
||||
const code = await generateAutoCode(
|
||||
MesAutoCodeRuleCode.QC_IPQC_CODE,
|
||||
);
|
||||
await formApi?.setFieldValue('code', code);
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
}
|
||||
},
|
||||
},
|
||||
{ default: () => '生成' },
|
||||
),
|
||||
},
|
||||
{
|
||||
fieldName: 'name',
|
||||
label: '检验单名称',
|
||||
component: 'Input',
|
||||
componentProps: {
|
||||
placeholder: '请输入检验单名称',
|
||||
},
|
||||
rules: 'required',
|
||||
},
|
||||
{
|
||||
fieldName: 'type',
|
||||
label: '检验类型',
|
||||
component: 'Select',
|
||||
componentProps: {
|
||||
allowClear: true,
|
||||
options: getDictOptions(DICT_TYPE.MES_IPQC_TYPE, 'number'),
|
||||
placeholder: '请选择检验类型',
|
||||
},
|
||||
rules: 'selectRequired',
|
||||
},
|
||||
{
|
||||
fieldName: 'sourceDocType',
|
||||
label: '来源单据类型',
|
||||
component: 'Select',
|
||||
componentProps: {
|
||||
disabled: true,
|
||||
options: getDictOptions(DICT_TYPE.MES_QC_SOURCE_DOC_TYPE, 'number'),
|
||||
placeholder: '来源单据类型',
|
||||
},
|
||||
dependencies: {
|
||||
triggerFields: ['sourceDocType'],
|
||||
show: (values) => !!values.sourceDocType,
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldName: 'sourceDocCode',
|
||||
label: '来源单据编号',
|
||||
component: 'Input',
|
||||
componentProps: {
|
||||
disabled: true,
|
||||
placeholder: '来源单据编号',
|
||||
},
|
||||
dependencies: {
|
||||
triggerFields: ['sourceDocType', 'sourceDocId'],
|
||||
show: (values) => !!values.sourceDocType && !!values.sourceDocId,
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldName: 'workOrderId',
|
||||
label: '生产工单',
|
||||
component: markRaw(ProWorkOrderSelect),
|
||||
componentProps: {
|
||||
placeholder: '请选择生产工单',
|
||||
status: MesProWorkOrderStatusEnum.CONFIRMED,
|
||||
// 工单变更时清空生产任务
|
||||
onChange: () => formApi?.setFieldValue('taskId', undefined),
|
||||
},
|
||||
rules: 'selectRequired',
|
||||
dependencies: {
|
||||
triggerFields: ['sourceDocId'],
|
||||
componentProps: (values) => ({
|
||||
disabled: !!values.sourceDocId,
|
||||
placeholder: '请选择生产工单',
|
||||
status: MesProWorkOrderStatusEnum.CONFIRMED,
|
||||
onChange: () => formApi?.setFieldValue('taskId', undefined),
|
||||
}),
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldName: 'workstationId',
|
||||
label: '工位',
|
||||
component: markRaw(MdWorkstationSelect),
|
||||
componentProps: {
|
||||
placeholder: '请选择工位',
|
||||
},
|
||||
rules: 'selectRequired',
|
||||
dependencies: {
|
||||
triggerFields: ['sourceDocId'],
|
||||
componentProps: (values) => ({
|
||||
disabled: !!values.sourceDocId,
|
||||
placeholder: '请选择工位',
|
||||
}),
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldName: 'taskId',
|
||||
label: '生产任务',
|
||||
component: markRaw(ProTaskSelect),
|
||||
componentProps: {
|
||||
placeholder: '请选择生产任务',
|
||||
statuses: [MesProTaskStatusEnum.PREPARE],
|
||||
},
|
||||
dependencies: {
|
||||
triggerFields: ['sourceDocId', 'workOrderId', 'workstationId'],
|
||||
componentProps: (values) => ({
|
||||
disabled: !!values.sourceDocId || !values.workOrderId,
|
||||
placeholder: '请选择生产任务',
|
||||
statuses: [MesProTaskStatusEnum.PREPARE],
|
||||
workOrderId: values.workOrderId,
|
||||
workstationId: values.workstationId,
|
||||
}),
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldName: 'checkQuantity',
|
||||
label: '检测数量',
|
||||
component: 'InputNumber',
|
||||
componentProps: {
|
||||
class: '!w-full',
|
||||
min: 0,
|
||||
placeholder: '请输入检测数量',
|
||||
precision: 2,
|
||||
},
|
||||
rules: 'required',
|
||||
dependencies: {
|
||||
triggerFields: ['sourceDocId'],
|
||||
componentProps: (values) => ({
|
||||
class: '!w-full',
|
||||
disabled: !!values.sourceDocId,
|
||||
min: 0,
|
||||
placeholder: '请输入检测数量',
|
||||
precision: 2,
|
||||
}),
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldName: 'qualifiedQuantity',
|
||||
label: '合格品数量',
|
||||
component: 'InputNumber',
|
||||
componentProps: {
|
||||
class: '!w-full',
|
||||
min: 0,
|
||||
placeholder: '请输入合格品数量',
|
||||
precision: 2,
|
||||
},
|
||||
rules: 'required',
|
||||
},
|
||||
{
|
||||
fieldName: 'unqualifiedQuantity',
|
||||
label: '不合格品数量',
|
||||
component: 'InputNumber',
|
||||
componentProps: {
|
||||
class: '!w-full',
|
||||
min: 0,
|
||||
placeholder: '请输入不合格品数量',
|
||||
precision: 2,
|
||||
},
|
||||
rules: 'required',
|
||||
},
|
||||
{
|
||||
fieldName: 'laborScrapQuantity',
|
||||
label: '工废数量',
|
||||
component: 'InputNumber',
|
||||
componentProps: {
|
||||
class: '!w-full',
|
||||
min: 0,
|
||||
placeholder: '请输入工废数量',
|
||||
precision: 2,
|
||||
onChange: () => syncUnqualified(formApi),
|
||||
},
|
||||
rules: 'required',
|
||||
dependencies: {
|
||||
triggerFields: ['unqualifiedQuantity'],
|
||||
show: (values) =>
|
||||
values.unqualifiedQuantity != null && values.unqualifiedQuantity > 0,
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldName: 'materialScrapQuantity',
|
||||
label: '料废数量',
|
||||
component: 'InputNumber',
|
||||
componentProps: {
|
||||
class: '!w-full',
|
||||
min: 0,
|
||||
placeholder: '请输入料废数量',
|
||||
precision: 2,
|
||||
onChange: () => syncUnqualified(formApi),
|
||||
},
|
||||
rules: 'required',
|
||||
dependencies: {
|
||||
triggerFields: ['unqualifiedQuantity'],
|
||||
show: (values) =>
|
||||
values.unqualifiedQuantity != null && values.unqualifiedQuantity > 0,
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldName: 'otherScrapQuantity',
|
||||
label: '其他废品数量',
|
||||
component: 'InputNumber',
|
||||
componentProps: {
|
||||
class: '!w-full',
|
||||
min: 0,
|
||||
placeholder: '请输入其他废品数量',
|
||||
precision: 2,
|
||||
onChange: () => syncUnqualified(formApi),
|
||||
},
|
||||
rules: 'required',
|
||||
dependencies: {
|
||||
triggerFields: ['unqualifiedQuantity'],
|
||||
show: (values) =>
|
||||
values.unqualifiedQuantity != null && values.unqualifiedQuantity > 0,
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldName: 'inspectorUserId',
|
||||
label: '检测人员',
|
||||
component: 'ApiSelect',
|
||||
componentProps: {
|
||||
allowClear: true,
|
||||
api: getSimpleUserList,
|
||||
labelField: 'nickname',
|
||||
placeholder: '请选择检测人员',
|
||||
valueField: 'id',
|
||||
},
|
||||
rules: 'selectRequired',
|
||||
},
|
||||
{
|
||||
fieldName: 'inspectDate',
|
||||
label: '检测日期',
|
||||
component: 'DatePicker',
|
||||
componentProps: {
|
||||
format: 'YYYY-MM-DD',
|
||||
placeholder: '请选择检测日期',
|
||||
valueFormat: 'x',
|
||||
},
|
||||
rules: 'required',
|
||||
},
|
||||
{
|
||||
fieldName: 'checkResult',
|
||||
label: '检测结果',
|
||||
component: 'Select',
|
||||
componentProps: {
|
||||
allowClear: true,
|
||||
options: getDictOptions(DICT_TYPE.MES_QC_CHECK_RESULT, 'number'),
|
||||
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: 'type',
|
||||
label: '检验类型',
|
||||
component: 'Select',
|
||||
componentProps: {
|
||||
allowClear: true,
|
||||
options: getDictOptions(DICT_TYPE.MES_IPQC_TYPE, 'number'),
|
||||
placeholder: '请选择检验类型',
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldName: 'workOrderId',
|
||||
label: '生产工单',
|
||||
component: markRaw(ProWorkOrderSelect),
|
||||
componentProps: {
|
||||
placeholder: '请选择生产工单',
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldName: 'itemId',
|
||||
label: '产品物料',
|
||||
component: markRaw(MdItemSelect),
|
||||
componentProps: {
|
||||
placeholder: '请选择产品物料',
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldName: 'checkResult',
|
||||
label: '检测结果',
|
||||
component: 'Select',
|
||||
componentProps: {
|
||||
allowClear: true,
|
||||
options: getDictOptions(DICT_TYPE.MES_QC_CHECK_RESULT, 'number'),
|
||||
placeholder: '请选择检测结果',
|
||||
},
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
/** 列表的字段 */
|
||||
export function useGridColumns(): VxeTableGridOptions<MesQcIpqcApi.Ipqc>['columns'] {
|
||||
return [
|
||||
{
|
||||
field: 'code',
|
||||
title: '检验单编号',
|
||||
width: 160,
|
||||
slots: { default: 'code' },
|
||||
},
|
||||
{
|
||||
field: 'name',
|
||||
title: '检验单名称',
|
||||
minWidth: 180,
|
||||
},
|
||||
{
|
||||
field: 'type',
|
||||
title: '检验类型',
|
||||
width: 120,
|
||||
cellRender: {
|
||||
name: 'CellDict',
|
||||
props: { type: DICT_TYPE.MES_IPQC_TYPE },
|
||||
},
|
||||
},
|
||||
{
|
||||
field: 'workOrderCode',
|
||||
title: '生产工单编号',
|
||||
width: 140,
|
||||
},
|
||||
{
|
||||
field: 'itemCode',
|
||||
title: '产品物料编码',
|
||||
width: 130,
|
||||
},
|
||||
{
|
||||
field: 'itemName',
|
||||
title: '产品物料名称',
|
||||
minWidth: 150,
|
||||
},
|
||||
{
|
||||
field: 'itemSpecification',
|
||||
title: '规格型号',
|
||||
width: 130,
|
||||
},
|
||||
{
|
||||
field: 'unitName',
|
||||
title: '单位',
|
||||
width: 80,
|
||||
},
|
||||
{
|
||||
field: 'checkQuantity',
|
||||
title: '检测数量',
|
||||
width: 100,
|
||||
},
|
||||
{
|
||||
field: 'checkResult',
|
||||
title: '检测结果',
|
||||
width: 110,
|
||||
cellRender: {
|
||||
name: 'CellDict',
|
||||
props: { type: DICT_TYPE.MES_QC_CHECK_RESULT },
|
||||
},
|
||||
},
|
||||
{
|
||||
field: 'inspectDate',
|
||||
title: '检测日期',
|
||||
width: 120,
|
||||
formatter: 'formatDate',
|
||||
},
|
||||
{
|
||||
field: 'inspectorNickname',
|
||||
title: '检测人员',
|
||||
width: 100,
|
||||
},
|
||||
{
|
||||
field: 'status',
|
||||
title: '单据状态',
|
||||
width: 100,
|
||||
cellRender: {
|
||||
name: 'CellDict',
|
||||
props: { type: DICT_TYPE.MES_ORDER_STATUS },
|
||||
},
|
||||
},
|
||||
{
|
||||
title: '操作',
|
||||
width: 180,
|
||||
fixed: 'right',
|
||||
slots: { default: 'actions' },
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
/** 过程检验单行子表的字段 */
|
||||
export function useLineGridColumns(): VxeTableGridOptions<MesQcIpqcLineApi.IpqcLine>['columns'] {
|
||||
return [
|
||||
{
|
||||
field: 'indicatorName',
|
||||
title: '检测项名称',
|
||||
minWidth: 150,
|
||||
},
|
||||
{
|
||||
field: 'indicatorType',
|
||||
title: '检测项类型',
|
||||
width: 120,
|
||||
cellRender: {
|
||||
name: 'CellDict',
|
||||
props: { type: DICT_TYPE.MES_INDICATOR_TYPE },
|
||||
},
|
||||
},
|
||||
{
|
||||
field: 'toolName',
|
||||
title: '检测工具',
|
||||
width: 120,
|
||||
},
|
||||
{
|
||||
field: 'checkMethod',
|
||||
title: '检测方法',
|
||||
minWidth: 180,
|
||||
},
|
||||
{
|
||||
field: 'standardValue',
|
||||
title: '标准值',
|
||||
width: 100,
|
||||
},
|
||||
{
|
||||
field: 'unitMeasureName',
|
||||
title: '单位',
|
||||
width: 80,
|
||||
},
|
||||
{
|
||||
field: 'maxThreshold',
|
||||
title: '误差上限',
|
||||
width: 100,
|
||||
},
|
||||
{
|
||||
field: 'minThreshold',
|
||||
title: '误差下限',
|
||||
width: 100,
|
||||
},
|
||||
{
|
||||
field: 'criticalQuantity',
|
||||
title: '致命缺陷数',
|
||||
width: 110,
|
||||
},
|
||||
{
|
||||
field: 'majorQuantity',
|
||||
title: '严重缺陷数',
|
||||
width: 110,
|
||||
},
|
||||
{
|
||||
field: 'minorQuantity',
|
||||
title: '轻微缺陷数',
|
||||
width: 110,
|
||||
},
|
||||
{
|
||||
title: '操作',
|
||||
width: 110,
|
||||
fixed: 'right',
|
||||
slots: { default: 'actions' },
|
||||
},
|
||||
];
|
||||
}
|
||||
|
|
@ -0,0 +1,167 @@
|
|||
<script lang="ts" setup>
|
||||
import type { VxeTableGridOptions } from '#/adapter/vxe-table';
|
||||
import type { MesQcIpqcApi } from '#/api/mes/qc/ipqc';
|
||||
|
||||
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 { deleteIpqc, exportIpqc, getIpqcPage } from '#/api/mes/qc/ipqc';
|
||||
import { $t } from '#/locales';
|
||||
import { MesQcStatusEnum } 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: MesQcIpqcApi.Ipqc) {
|
||||
formModalApi.setData({ formType: 'detail', id: row.id }).open();
|
||||
}
|
||||
|
||||
/** 编辑过程检验单 */
|
||||
function handleEdit(row: MesQcIpqcApi.Ipqc) {
|
||||
formModalApi.setData({ formType: 'update', id: row.id }).open();
|
||||
}
|
||||
|
||||
/** 删除过程检验单 */
|
||||
async function handleDelete(row: MesQcIpqcApi.Ipqc) {
|
||||
const hideLoading = message.loading({
|
||||
content: $t('ui.actionMessage.deleting', [row.code]),
|
||||
duration: 0,
|
||||
});
|
||||
try {
|
||||
await deleteIpqc(row.id!);
|
||||
message.success($t('ui.actionMessage.deleteSuccess', [row.code]));
|
||||
handleRefresh();
|
||||
} finally {
|
||||
hideLoading();
|
||||
}
|
||||
}
|
||||
|
||||
/** 导出表格 */
|
||||
async function handleExport() {
|
||||
const data = await exportIpqc(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 getIpqcPage({
|
||||
pageNo: page.currentPage,
|
||||
pageSize: page.pageSize,
|
||||
...formValues,
|
||||
});
|
||||
},
|
||||
},
|
||||
},
|
||||
rowConfig: {
|
||||
keyField: 'id',
|
||||
isHover: true,
|
||||
},
|
||||
toolbarConfig: {
|
||||
refresh: true,
|
||||
search: true,
|
||||
},
|
||||
} as VxeTableGridOptions<MesQcIpqcApi.Ipqc>,
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Page auto-content-height>
|
||||
<template #doc>
|
||||
<DocAlert
|
||||
title="【质量】过程检验(IPQC)"
|
||||
url="https://doc.iocoder.cn/mes/qc/ipqc/"
|
||||
/>
|
||||
</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:qc-ipqc:create'],
|
||||
onClick: handleCreate,
|
||||
},
|
||||
{
|
||||
label: $t('ui.actionTitle.export'),
|
||||
type: 'primary',
|
||||
icon: ACTION_ICON.DOWNLOAD,
|
||||
auth: ['mes:qc-ipqc: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:qc-ipqc:update'],
|
||||
ifShow: row.status === MesQcStatusEnum.DRAFT,
|
||||
onClick: handleEdit.bind(null, row),
|
||||
},
|
||||
{
|
||||
label: $t('common.delete'),
|
||||
type: 'link',
|
||||
danger: true,
|
||||
icon: ACTION_ICON.DELETE,
|
||||
auth: ['mes:qc-ipqc:delete'],
|
||||
ifShow: row.status === MesQcStatusEnum.DRAFT,
|
||||
popConfirm: {
|
||||
title: $t('ui.actionMessage.deleteConfirm', [row.code]),
|
||||
confirm: handleDelete.bind(null, row),
|
||||
},
|
||||
},
|
||||
{
|
||||
label: $t('common.detail'),
|
||||
type: 'link',
|
||||
icon: ACTION_ICON.VIEW,
|
||||
auth: ['mes:qc-ipqc:query'],
|
||||
onClick: handleDetail.bind(null, row),
|
||||
},
|
||||
]"
|
||||
/>
|
||||
</template>
|
||||
</Grid>
|
||||
</Page>
|
||||
</template>
|
||||
|
|
@ -0,0 +1,97 @@
|
|||
<script lang="ts" setup>
|
||||
import type { VxeTableGridOptions } from '#/adapter/vxe-table';
|
||||
import type { MesQcIpqcLineApi } from '#/api/mes/qc/ipqc/line';
|
||||
|
||||
import { useVbenModal } from '@vben/common-ui';
|
||||
|
||||
import { ACTION_ICON, TableAction, useVbenVxeGrid } from '#/adapter/vxe-table';
|
||||
import { getIpqcLinePage } from '#/api/mes/qc/ipqc/line';
|
||||
import { MesQcTypeEnum } from '#/views/mes/utils/constants';
|
||||
|
||||
import { DefectRecordInlineList } from '../../defectrecord/components';
|
||||
import { useLineGridColumns } from '../data';
|
||||
|
||||
const props = defineProps<{
|
||||
formType?: string;
|
||||
ipqcId: number;
|
||||
}>();
|
||||
|
||||
const emit = defineEmits<{ refresh: [] }>();
|
||||
|
||||
const [DefectModal, defectModalApi] = useVbenModal({
|
||||
connectedComponent: DefectRecordInlineList,
|
||||
destroyOnClose: true,
|
||||
});
|
||||
|
||||
/** 刷新表格 */
|
||||
function handleRefresh() {
|
||||
gridApi.query();
|
||||
}
|
||||
|
||||
/** 缺陷记录变更后,刷新本表格并通知父组件刷新主表统计 */
|
||||
function handleDefectChanged() {
|
||||
handleRefresh();
|
||||
emit('refresh');
|
||||
}
|
||||
|
||||
/** 打开缺陷记录弹窗 */
|
||||
function handleOpenDefect(row: MesQcIpqcLineApi.IpqcLine) {
|
||||
defectModalApi
|
||||
.setData({
|
||||
formType: props.formType,
|
||||
lineId: row.id,
|
||||
qcId: props.ipqcId,
|
||||
qcType: MesQcTypeEnum.IPQC,
|
||||
})
|
||||
.open();
|
||||
}
|
||||
|
||||
const [Grid, gridApi] = useVbenVxeGrid({
|
||||
gridOptions: {
|
||||
columns: useLineGridColumns(),
|
||||
height: 360,
|
||||
keepSource: true,
|
||||
proxyConfig: {
|
||||
ajax: {
|
||||
query: async ({ page }) => {
|
||||
if (!props.ipqcId) {
|
||||
return { list: [], total: 0 };
|
||||
}
|
||||
return await getIpqcLinePage({
|
||||
ipqcId: props.ipqcId,
|
||||
pageNo: page.currentPage,
|
||||
pageSize: page.pageSize,
|
||||
});
|
||||
},
|
||||
},
|
||||
},
|
||||
rowConfig: {
|
||||
keyField: 'id',
|
||||
isHover: true,
|
||||
},
|
||||
toolbarConfig: {
|
||||
refresh: true,
|
||||
},
|
||||
} as VxeTableGridOptions<MesQcIpqcLineApi.IpqcLine>,
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div>
|
||||
<DefectModal @success="handleDefectChanged" />
|
||||
<Grid table-title="检验项">
|
||||
<template #actions="{ row }">
|
||||
<TableAction
|
||||
:actions="[
|
||||
{
|
||||
label: '缺陷列表',
|
||||
type: 'link',
|
||||
icon: ACTION_ICON.VIEW,
|
||||
onClick: handleOpenDefect.bind(null, row),
|
||||
},
|
||||
]"
|
||||
/>
|
||||
</template>
|
||||
</Grid>
|
||||
</div>
|
||||
</template>
|
||||
|
|
@ -0,0 +1,518 @@
|
|||
import type { VbenFormApi, VbenFormSchema } from '#/adapter/form';
|
||||
import type { VxeTableGridOptions } from '#/adapter/vxe-table';
|
||||
import type { MesQcOqcApi } from '#/api/mes/qc/oqc';
|
||||
import type { MesQcOqcLineApi } from '#/api/mes/qc/oqc/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 { getSimpleUserList } from '#/api/system/user';
|
||||
import MdClientSelect from '#/views/mes/md/client/components/md-client-select.vue';
|
||||
import MdItemSelect from '#/views/mes/md/item/components/md-item-select.vue';
|
||||
import { MesAutoCodeRuleCode } from '#/views/mes/utils/constants';
|
||||
|
||||
/** 表单类型 */
|
||||
export type FormType = 'create' | 'detail' | 'update';
|
||||
|
||||
/** 新增/修改的表单 */
|
||||
export function useFormSchema(formApi?: VbenFormApi): VbenFormSchema[] {
|
||||
return [
|
||||
{
|
||||
fieldName: 'id',
|
||||
component: 'Input',
|
||||
dependencies: {
|
||||
triggerFields: [''],
|
||||
show: () => false,
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldName: 'sourceDocId',
|
||||
component: 'Input',
|
||||
dependencies: {
|
||||
triggerFields: [''],
|
||||
show: () => false,
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldName: 'sourceLineId',
|
||||
component: 'Input',
|
||||
dependencies: {
|
||||
triggerFields: [''],
|
||||
show: () => false,
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldName: 'status',
|
||||
component: 'Input',
|
||||
dependencies: {
|
||||
triggerFields: [''],
|
||||
show: () => false,
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldName: 'code',
|
||||
label: '检验单编号',
|
||||
component: 'Input',
|
||||
componentProps: {
|
||||
placeholder: '请输入检验单编号',
|
||||
},
|
||||
rules: 'required',
|
||||
suffix: () =>
|
||||
h(
|
||||
Button,
|
||||
{
|
||||
type: 'default',
|
||||
onClick: async () => {
|
||||
try {
|
||||
const code = await generateAutoCode(
|
||||
MesAutoCodeRuleCode.QC_OQC_CODE,
|
||||
);
|
||||
await formApi?.setFieldValue('code', code);
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
}
|
||||
},
|
||||
},
|
||||
{ default: () => '生成' },
|
||||
),
|
||||
},
|
||||
{
|
||||
fieldName: 'name',
|
||||
label: '检验单名称',
|
||||
component: 'Input',
|
||||
componentProps: {
|
||||
placeholder: '请输入检验单名称',
|
||||
},
|
||||
rules: 'required',
|
||||
},
|
||||
{
|
||||
fieldName: 'sourceDocType',
|
||||
label: '来源单据类型',
|
||||
component: 'Select',
|
||||
componentProps: {
|
||||
disabled: true,
|
||||
options: getDictOptions(DICT_TYPE.MES_QC_SOURCE_DOC_TYPE, 'number'),
|
||||
placeholder: '来源单据类型',
|
||||
},
|
||||
dependencies: {
|
||||
triggerFields: ['sourceDocType'],
|
||||
show: (values) => !!values.sourceDocType,
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldName: 'sourceDocCode',
|
||||
label: '来源单据编号',
|
||||
component: 'Input',
|
||||
componentProps: {
|
||||
disabled: true,
|
||||
placeholder: '来源单据编号',
|
||||
},
|
||||
dependencies: {
|
||||
triggerFields: ['sourceDocType', 'sourceDocId'],
|
||||
show: (values) => !!values.sourceDocType && !!values.sourceDocId,
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldName: 'itemId',
|
||||
label: '产品物料',
|
||||
component: markRaw(MdItemSelect),
|
||||
componentProps: {
|
||||
placeholder: '请选择产品物料',
|
||||
},
|
||||
rules: 'selectRequired',
|
||||
dependencies: {
|
||||
triggerFields: ['sourceDocId'],
|
||||
componentProps: (values) => ({
|
||||
disabled: !!values.sourceDocId,
|
||||
placeholder: '请选择产品物料',
|
||||
}),
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldName: 'clientId',
|
||||
label: '客户',
|
||||
component: markRaw(MdClientSelect),
|
||||
componentProps: {
|
||||
placeholder: '请选择客户',
|
||||
},
|
||||
rules: 'selectRequired',
|
||||
dependencies: {
|
||||
triggerFields: ['sourceDocId'],
|
||||
componentProps: (values) => ({
|
||||
disabled: !!values.sourceDocId,
|
||||
placeholder: '请选择客户',
|
||||
}),
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldName: 'batchCode',
|
||||
label: '批次号',
|
||||
component: 'Input',
|
||||
componentProps: {
|
||||
placeholder: '请输入批次号',
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldName: 'outQuantity',
|
||||
label: '发货数量',
|
||||
component: 'InputNumber',
|
||||
componentProps: {
|
||||
class: '!w-full',
|
||||
min: 0,
|
||||
placeholder: '请输入发货数量',
|
||||
precision: 2,
|
||||
// 新建态下,发货数量变化时把 checkQuantity 也填上同值
|
||||
onChange: async (value: null | number | undefined) => {
|
||||
if (value == null || !formApi) return;
|
||||
const values = await formApi.getValues();
|
||||
if (!values.id && values.checkQuantity == null) {
|
||||
await formApi.setFieldValue('checkQuantity', value);
|
||||
}
|
||||
},
|
||||
},
|
||||
rules: 'required',
|
||||
dependencies: {
|
||||
triggerFields: ['sourceDocId'],
|
||||
componentProps: (values) => ({
|
||||
class: '!w-full',
|
||||
disabled: !!values.sourceDocId,
|
||||
min: 0,
|
||||
placeholder: '请输入发货数量',
|
||||
precision: 2,
|
||||
onChange: async (value: null | number | undefined) => {
|
||||
if (value == null || !formApi) return;
|
||||
const current = await formApi.getValues();
|
||||
if (!current.id && current.checkQuantity == null) {
|
||||
await formApi.setFieldValue('checkQuantity', value);
|
||||
}
|
||||
},
|
||||
}),
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldName: 'checkQuantity',
|
||||
label: '检测数量',
|
||||
component: 'InputNumber',
|
||||
componentProps: {
|
||||
class: '!w-full',
|
||||
min: 0,
|
||||
placeholder: '请输入检测数量',
|
||||
// 新建态下,检测数量变化时把 outQuantity 也填上同值
|
||||
onChange: async (value: null | number | undefined) => {
|
||||
if (value == null || !formApi) return;
|
||||
const values = await formApi.getValues();
|
||||
if (!values.id && values.outQuantity == null) {
|
||||
await formApi.setFieldValue('outQuantity', value);
|
||||
}
|
||||
},
|
||||
},
|
||||
rules: 'required',
|
||||
},
|
||||
{
|
||||
fieldName: 'qualifiedQuantity',
|
||||
label: '合格品数量',
|
||||
component: 'InputNumber',
|
||||
componentProps: {
|
||||
class: '!w-full',
|
||||
min: 0,
|
||||
placeholder: '请输入合格品数量',
|
||||
},
|
||||
rules: 'required',
|
||||
},
|
||||
{
|
||||
fieldName: 'unqualifiedQuantity',
|
||||
label: '不合格品数量',
|
||||
component: 'InputNumber',
|
||||
componentProps: {
|
||||
class: '!w-full',
|
||||
min: 0,
|
||||
placeholder: '请输入不合格品数量',
|
||||
},
|
||||
rules: 'required',
|
||||
},
|
||||
{
|
||||
fieldName: 'inspectorUserId',
|
||||
label: '检测人员',
|
||||
component: 'ApiSelect',
|
||||
componentProps: {
|
||||
allowClear: true,
|
||||
api: getSimpleUserList,
|
||||
labelField: 'nickname',
|
||||
placeholder: '请选择检测人员',
|
||||
valueField: 'id',
|
||||
},
|
||||
rules: 'selectRequired',
|
||||
},
|
||||
{
|
||||
fieldName: 'outDate',
|
||||
label: '出货日期',
|
||||
component: 'DatePicker',
|
||||
componentProps: {
|
||||
format: 'YYYY-MM-DD',
|
||||
placeholder: '请选择出货日期',
|
||||
valueFormat: 'x',
|
||||
},
|
||||
rules: 'required',
|
||||
},
|
||||
{
|
||||
fieldName: 'inspectDate',
|
||||
label: '检测日期',
|
||||
component: 'DatePicker',
|
||||
componentProps: {
|
||||
format: 'YYYY-MM-DD',
|
||||
placeholder: '请选择检测日期',
|
||||
valueFormat: 'x',
|
||||
},
|
||||
rules: 'required',
|
||||
},
|
||||
{
|
||||
fieldName: 'checkResult',
|
||||
label: '检测结果',
|
||||
component: 'Select',
|
||||
componentProps: {
|
||||
allowClear: true,
|
||||
options: getDictOptions(DICT_TYPE.MES_QC_CHECK_RESULT, 'number'),
|
||||
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: 'clientId',
|
||||
label: '客户',
|
||||
component: markRaw(MdClientSelect),
|
||||
componentProps: {
|
||||
placeholder: '请选择客户',
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldName: 'batchCode',
|
||||
label: '批次号',
|
||||
component: 'Input',
|
||||
componentProps: {
|
||||
allowClear: true,
|
||||
placeholder: '请输入批次号',
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldName: 'itemId',
|
||||
label: '产品物料',
|
||||
component: markRaw(MdItemSelect),
|
||||
componentProps: {
|
||||
placeholder: '请选择产品物料',
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldName: 'checkResult',
|
||||
label: '检测结果',
|
||||
component: 'Select',
|
||||
componentProps: {
|
||||
allowClear: true,
|
||||
options: getDictOptions(DICT_TYPE.MES_QC_CHECK_RESULT, 'number'),
|
||||
placeholder: '请选择检测结果',
|
||||
},
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
/** 列表的字段 */
|
||||
export function useGridColumns(): VxeTableGridOptions<MesQcOqcApi.Oqc>['columns'] {
|
||||
return [
|
||||
{
|
||||
field: 'code',
|
||||
title: '检验单编号',
|
||||
width: 160,
|
||||
slots: { default: 'code' },
|
||||
},
|
||||
{
|
||||
field: 'name',
|
||||
title: '检验单名称',
|
||||
minWidth: 180,
|
||||
},
|
||||
{
|
||||
field: 'clientNickname',
|
||||
title: '客户名称',
|
||||
width: 120,
|
||||
},
|
||||
{
|
||||
field: 'batchCode',
|
||||
title: '批次号',
|
||||
width: 130,
|
||||
},
|
||||
{
|
||||
field: 'itemCode',
|
||||
title: '产品物料编码',
|
||||
width: 130,
|
||||
},
|
||||
{
|
||||
field: 'itemName',
|
||||
title: '产品物料名称',
|
||||
minWidth: 150,
|
||||
},
|
||||
{
|
||||
field: 'itemSpecification',
|
||||
title: '规格型号',
|
||||
minWidth: 150,
|
||||
},
|
||||
{
|
||||
field: 'unitName',
|
||||
title: '单位',
|
||||
width: 80,
|
||||
},
|
||||
{
|
||||
field: 'outQuantity',
|
||||
title: '发货数量',
|
||||
width: 100,
|
||||
},
|
||||
{
|
||||
field: 'checkQuantity',
|
||||
title: '检测数量',
|
||||
width: 100,
|
||||
},
|
||||
{
|
||||
field: 'unqualifiedQuantity',
|
||||
title: '不合格数',
|
||||
width: 100,
|
||||
},
|
||||
{
|
||||
field: 'checkResult',
|
||||
title: '检测结果',
|
||||
width: 110,
|
||||
cellRender: {
|
||||
name: 'CellDict',
|
||||
props: { type: DICT_TYPE.MES_QC_CHECK_RESULT },
|
||||
},
|
||||
},
|
||||
{
|
||||
field: 'outDate',
|
||||
title: '出货日期',
|
||||
width: 120,
|
||||
formatter: 'formatDate',
|
||||
},
|
||||
{
|
||||
field: 'inspectDate',
|
||||
title: '检测日期',
|
||||
width: 120,
|
||||
formatter: 'formatDate',
|
||||
},
|
||||
{
|
||||
field: 'inspectorNickname',
|
||||
title: '检测人员',
|
||||
width: 100,
|
||||
},
|
||||
{
|
||||
field: 'status',
|
||||
title: '单据状态',
|
||||
width: 100,
|
||||
cellRender: {
|
||||
name: 'CellDict',
|
||||
props: { type: DICT_TYPE.MES_ORDER_STATUS },
|
||||
},
|
||||
},
|
||||
{
|
||||
title: '操作',
|
||||
width: 220,
|
||||
fixed: 'right',
|
||||
slots: { default: 'actions' },
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
/** 出货检验单行子表的字段 */
|
||||
export function useLineGridColumns(): VxeTableGridOptions<MesQcOqcLineApi.OqcLine>['columns'] {
|
||||
return [
|
||||
{
|
||||
field: 'indicatorName',
|
||||
title: '检测项名称',
|
||||
minWidth: 150,
|
||||
},
|
||||
{
|
||||
field: 'indicatorType',
|
||||
title: '检测项类型',
|
||||
width: 120,
|
||||
cellRender: {
|
||||
name: 'CellDict',
|
||||
props: { type: DICT_TYPE.MES_INDICATOR_TYPE },
|
||||
},
|
||||
},
|
||||
{
|
||||
field: 'tool',
|
||||
title: '检测工具',
|
||||
width: 120,
|
||||
},
|
||||
{
|
||||
field: 'checkMethod',
|
||||
title: '检测方法',
|
||||
minWidth: 180,
|
||||
},
|
||||
{
|
||||
field: 'standardValue',
|
||||
title: '标准值',
|
||||
width: 100,
|
||||
},
|
||||
{
|
||||
field: 'unitMeasureName',
|
||||
title: '单位',
|
||||
width: 80,
|
||||
},
|
||||
{
|
||||
field: 'maxThreshold',
|
||||
title: '误差上限',
|
||||
width: 100,
|
||||
},
|
||||
{
|
||||
field: 'minThreshold',
|
||||
title: '误差下限',
|
||||
width: 100,
|
||||
},
|
||||
{
|
||||
field: 'criticalQuantity',
|
||||
title: '致命缺陷数',
|
||||
width: 110,
|
||||
},
|
||||
{
|
||||
field: 'majorQuantity',
|
||||
title: '严重缺陷数',
|
||||
width: 110,
|
||||
},
|
||||
{
|
||||
field: 'minorQuantity',
|
||||
title: '轻微缺陷数',
|
||||
width: 110,
|
||||
},
|
||||
{
|
||||
title: '操作',
|
||||
width: 110,
|
||||
fixed: 'right',
|
||||
slots: { default: 'actions' },
|
||||
},
|
||||
];
|
||||
}
|
||||
|
|
@ -0,0 +1,167 @@
|
|||
<script lang="ts" setup>
|
||||
import type { VxeTableGridOptions } from '#/adapter/vxe-table';
|
||||
import type { MesQcOqcApi } from '#/api/mes/qc/oqc';
|
||||
|
||||
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 { deleteOqc, exportOqc, getOqcPage } from '#/api/mes/qc/oqc';
|
||||
import { $t } from '#/locales';
|
||||
import { MesQcStatusEnum } 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: MesQcOqcApi.Oqc) {
|
||||
formModalApi.setData({ formType: 'detail', id: row.id }).open();
|
||||
}
|
||||
|
||||
/** 编辑出货检验单 */
|
||||
function handleEdit(row: MesQcOqcApi.Oqc) {
|
||||
formModalApi.setData({ formType: 'update', id: row.id }).open();
|
||||
}
|
||||
|
||||
/** 删除出货检验单 */
|
||||
async function handleDelete(row: MesQcOqcApi.Oqc) {
|
||||
const hideLoading = message.loading({
|
||||
content: $t('ui.actionMessage.deleting', [row.code]),
|
||||
duration: 0,
|
||||
});
|
||||
try {
|
||||
await deleteOqc(row.id!);
|
||||
message.success($t('ui.actionMessage.deleteSuccess', [row.code]));
|
||||
handleRefresh();
|
||||
} finally {
|
||||
hideLoading();
|
||||
}
|
||||
}
|
||||
|
||||
/** 导出表格 */
|
||||
async function handleExport() {
|
||||
const data = await exportOqc(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 getOqcPage({
|
||||
pageNo: page.currentPage,
|
||||
pageSize: page.pageSize,
|
||||
...formValues,
|
||||
});
|
||||
},
|
||||
},
|
||||
},
|
||||
rowConfig: {
|
||||
keyField: 'id',
|
||||
isHover: true,
|
||||
},
|
||||
toolbarConfig: {
|
||||
refresh: true,
|
||||
search: true,
|
||||
},
|
||||
} as VxeTableGridOptions<MesQcOqcApi.Oqc>,
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Page auto-content-height>
|
||||
<template #doc>
|
||||
<DocAlert
|
||||
title="【质量】出货检验(OQC)"
|
||||
url="https://doc.iocoder.cn/mes/qc/oqc/"
|
||||
/>
|
||||
</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:qc-oqc:create'],
|
||||
onClick: handleCreate,
|
||||
},
|
||||
{
|
||||
label: $t('ui.actionTitle.export'),
|
||||
type: 'primary',
|
||||
icon: ACTION_ICON.DOWNLOAD,
|
||||
auth: ['mes:qc-oqc: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:qc-oqc:update'],
|
||||
ifShow: row.status === MesQcStatusEnum.DRAFT,
|
||||
onClick: handleEdit.bind(null, row),
|
||||
},
|
||||
{
|
||||
label: $t('common.delete'),
|
||||
type: 'link',
|
||||
danger: true,
|
||||
icon: ACTION_ICON.DELETE,
|
||||
auth: ['mes:qc-oqc:delete'],
|
||||
ifShow: row.status === MesQcStatusEnum.DRAFT,
|
||||
popConfirm: {
|
||||
title: $t('ui.actionMessage.deleteConfirm', [row.code]),
|
||||
confirm: handleDelete.bind(null, row),
|
||||
},
|
||||
},
|
||||
{
|
||||
label: $t('common.detail'),
|
||||
type: 'link',
|
||||
icon: ACTION_ICON.VIEW,
|
||||
auth: ['mes:qc-oqc:query'],
|
||||
onClick: handleDetail.bind(null, row),
|
||||
},
|
||||
]"
|
||||
/>
|
||||
</template>
|
||||
</Grid>
|
||||
</Page>
|
||||
</template>
|
||||
|
|
@ -0,0 +1,231 @@
|
|||
<script lang="ts" setup>
|
||||
import type { FormType } from '../data';
|
||||
|
||||
import type { MesQcOqcApi } from '#/api/mes/qc/oqc';
|
||||
|
||||
import { computed, ref } from 'vue';
|
||||
|
||||
import { confirm, useVbenModal } from '@vben/common-ui';
|
||||
|
||||
import { Button, Descriptions, message, Tabs } from 'ant-design-vue';
|
||||
|
||||
import { useVbenForm } from '#/adapter/form';
|
||||
import {
|
||||
createOqc,
|
||||
finishOqc,
|
||||
getOqc,
|
||||
updateOqc,
|
||||
} from '#/api/mes/qc/oqc';
|
||||
import { $t } from '#/locales';
|
||||
import { MesQcStatusEnum, MesQcTypeEnum } from '#/views/mes/utils/constants';
|
||||
|
||||
import { QcIndicatorResultList } from '../../indicatorresult/components';
|
||||
import { useFormSchema } from '../data';
|
||||
import LineList from './line-list.vue';
|
||||
|
||||
const emit = defineEmits(['success']);
|
||||
const formType = ref<FormType>('create');
|
||||
const formData = ref<MesQcOqcApi.Oqc>();
|
||||
const subTabsName = ref('line');
|
||||
const originalSnapshot = ref('');
|
||||
const isDetail = computed(() => formType.value === 'detail');
|
||||
const canFinish = computed(
|
||||
() =>
|
||||
formType.value === 'update' &&
|
||||
formData.value?.status === MesQcStatusEnum.DRAFT,
|
||||
);
|
||||
const getTitle = computed(() => {
|
||||
if (formType.value === 'detail') {
|
||||
return $t('ui.actionTitle.view', ['出货检验单']);
|
||||
}
|
||||
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,
|
||||
},
|
||||
wrapperClass: 'grid-cols-3',
|
||||
layout: 'horizontal',
|
||||
schema: [],
|
||||
showDefaultActions: false,
|
||||
});
|
||||
|
||||
/** 子表变更后刷新主表头数据(缺陷统计等) */
|
||||
async function handleRefresh() {
|
||||
if (!formData.value?.id) {
|
||||
return;
|
||||
}
|
||||
formData.value = await getOqc(formData.value.id);
|
||||
}
|
||||
|
||||
/** 提交表单 */
|
||||
async function handleSubmit(): Promise<boolean> {
|
||||
const { valid } = await formApi.validate();
|
||||
if (!valid) {
|
||||
return false;
|
||||
}
|
||||
const data = (await formApi.getValues()) as MesQcOqcApi.Oqc;
|
||||
if (formData.value?.id) {
|
||||
await updateOqc({ ...data, id: formData.value.id });
|
||||
formData.value = { ...formData.value, ...data };
|
||||
} else {
|
||||
const id = await createOqc(data);
|
||||
formData.value = {
|
||||
...data,
|
||||
id: id as unknown as number,
|
||||
status: MesQcStatusEnum.DRAFT,
|
||||
};
|
||||
await formApi.setFieldValue('id', formData.value.id);
|
||||
await formApi.setFieldValue('status', formData.value.status);
|
||||
formType.value = 'update';
|
||||
}
|
||||
originalSnapshot.value = JSON.stringify(await formApi.getValues());
|
||||
return true;
|
||||
}
|
||||
|
||||
/** 完成检验单:表单有修改时先保存,再调用完成接口 */
|
||||
async function handleFinish() {
|
||||
const id = formData.value?.id;
|
||||
if (!id) {
|
||||
return;
|
||||
}
|
||||
const { valid } = await formApi.validate();
|
||||
if (!valid) {
|
||||
return;
|
||||
}
|
||||
await confirm({
|
||||
content: '是否完成出货检验单编制?【完成后将不能更改】',
|
||||
});
|
||||
modalApi.lock();
|
||||
try {
|
||||
const current = JSON.stringify(await formApi.getValues());
|
||||
if (current !== originalSnapshot.value) {
|
||||
const data = (await formApi.getValues()) as MesQcOqcApi.Oqc;
|
||||
await updateOqc({ ...data, id });
|
||||
formData.value = { ...formData.value, ...data };
|
||||
originalSnapshot.value = current;
|
||||
}
|
||||
await finishOqc(id);
|
||||
message.success('完成成功');
|
||||
await modalApi.close();
|
||||
emit('success');
|
||||
} finally {
|
||||
modalApi.unlock();
|
||||
}
|
||||
}
|
||||
|
||||
// TODO @AI:方法内注释;
|
||||
const [Modal, modalApi] = useVbenModal({
|
||||
async onConfirm() {
|
||||
if (isDetail.value) {
|
||||
await modalApi.close();
|
||||
return;
|
||||
}
|
||||
modalApi.lock();
|
||||
try {
|
||||
const ok = await handleSubmit();
|
||||
if (!ok) {
|
||||
return;
|
||||
}
|
||||
message.success($t('ui.actionMessage.operationSuccess'));
|
||||
await modalApi.close();
|
||||
emit('success');
|
||||
} finally {
|
||||
modalApi.unlock();
|
||||
}
|
||||
},
|
||||
async onOpenChange(isOpen: boolean) {
|
||||
if (!isOpen) {
|
||||
formData.value = undefined;
|
||||
originalSnapshot.value = '';
|
||||
return;
|
||||
}
|
||||
formApi.setState({ schema: useFormSchema(formApi) });
|
||||
subTabsName.value = 'line';
|
||||
const data = modalApi.getData<{
|
||||
formType: FormType;
|
||||
id?: number;
|
||||
prefill?: MesQcOqcApi.Oqc;
|
||||
}>();
|
||||
formType.value = data.formType;
|
||||
formApi.setDisabled(formType.value === 'detail');
|
||||
modalApi.setState({ showConfirmButton: formType.value !== 'detail' });
|
||||
if (data?.id) {
|
||||
modalApi.lock();
|
||||
try {
|
||||
formData.value = await getOqc(data.id);
|
||||
await formApi.setValues(formData.value);
|
||||
} finally {
|
||||
modalApi.unlock();
|
||||
}
|
||||
} else if (data?.prefill) {
|
||||
formData.value = { ...data.prefill };
|
||||
await formApi.setValues(data.prefill);
|
||||
}
|
||||
originalSnapshot.value = JSON.stringify(await formApi.getValues());
|
||||
},
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Modal :title="getTitle" class="w-4/5">
|
||||
<Form class="mx-4" />
|
||||
<!-- 缺陷统计(只读) -->
|
||||
<div v-if="formData?.id" class="mx-4 mt-4">
|
||||
<Descriptions title="缺陷情况" :column="3" bordered size="small">
|
||||
<Descriptions.Item label="致命缺陷数">
|
||||
{{ formData.criticalQuantity ?? 0 }}
|
||||
</Descriptions.Item>
|
||||
<Descriptions.Item label="严重缺陷数">
|
||||
{{ formData.majorQuantity ?? 0 }}
|
||||
</Descriptions.Item>
|
||||
<Descriptions.Item label="轻微缺陷数">
|
||||
{{ formData.minorQuantity ?? 0 }}
|
||||
</Descriptions.Item>
|
||||
<Descriptions.Item label="致命缺陷率">
|
||||
{{ formData.criticalRate ?? 0 }}%
|
||||
</Descriptions.Item>
|
||||
<Descriptions.Item label="严重缺陷率">
|
||||
{{ formData.majorRate ?? 0 }}%
|
||||
</Descriptions.Item>
|
||||
<Descriptions.Item label="轻微缺陷率">
|
||||
{{ formData.minorRate ?? 0 }}%
|
||||
</Descriptions.Item>
|
||||
</Descriptions>
|
||||
</div>
|
||||
<Tabs
|
||||
v-if="formData?.id"
|
||||
v-model:active-key="subTabsName"
|
||||
class="mx-4 mt-4"
|
||||
>
|
||||
<Tabs.TabPane key="line" tab="检验项">
|
||||
<LineList
|
||||
:form-type="formType"
|
||||
:oqc-id="formData.id"
|
||||
@refresh="handleRefresh"
|
||||
/>
|
||||
</Tabs.TabPane>
|
||||
<Tabs.TabPane key="result" tab="检测结果">
|
||||
<QcIndicatorResultList
|
||||
:qc-id="formData.id"
|
||||
:qc-type="MesQcTypeEnum.OQC"
|
||||
:readonly="isDetail"
|
||||
/>
|
||||
</Tabs.TabPane>
|
||||
</Tabs>
|
||||
<template #prepend-footer>
|
||||
<div class="flex flex-auto items-center gap-2">
|
||||
<Button v-if="canFinish" type="primary" @click="handleFinish">
|
||||
完成
|
||||
</Button>
|
||||
</div>
|
||||
</template>
|
||||
</Modal>
|
||||
</template>
|
||||
|
|
@ -0,0 +1,97 @@
|
|||
<script lang="ts" setup>
|
||||
import type { VxeTableGridOptions } from '#/adapter/vxe-table';
|
||||
import type { MesQcOqcLineApi } from '#/api/mes/qc/oqc/line';
|
||||
|
||||
import { useVbenModal } from '@vben/common-ui';
|
||||
|
||||
import { ACTION_ICON, TableAction, useVbenVxeGrid } from '#/adapter/vxe-table';
|
||||
import { getOqcLinePage } from '#/api/mes/qc/oqc/line';
|
||||
import { MesQcTypeEnum } from '#/views/mes/utils/constants';
|
||||
|
||||
import { DefectRecordInlineList } from '../../defectrecord/components';
|
||||
import { useLineGridColumns } from '../data';
|
||||
|
||||
const props = defineProps<{
|
||||
formType?: string;
|
||||
oqcId: number;
|
||||
}>();
|
||||
|
||||
const emit = defineEmits<{ refresh: [] }>();
|
||||
|
||||
const [DefectModal, defectModalApi] = useVbenModal({
|
||||
connectedComponent: DefectRecordInlineList,
|
||||
destroyOnClose: true,
|
||||
});
|
||||
|
||||
/** 刷新表格 */
|
||||
function handleRefresh() {
|
||||
gridApi.query();
|
||||
}
|
||||
|
||||
/** 缺陷记录变更后,刷新本表格并通知父组件刷新主表统计 */
|
||||
function handleDefectChanged() {
|
||||
handleRefresh();
|
||||
emit('refresh');
|
||||
}
|
||||
|
||||
/** 打开缺陷记录弹窗 */
|
||||
function handleOpenDefect(row: MesQcOqcLineApi.OqcLine) {
|
||||
defectModalApi
|
||||
.setData({
|
||||
formType: props.formType,
|
||||
lineId: row.id,
|
||||
qcId: props.oqcId,
|
||||
qcType: MesQcTypeEnum.OQC,
|
||||
})
|
||||
.open();
|
||||
}
|
||||
|
||||
const [Grid, gridApi] = useVbenVxeGrid({
|
||||
gridOptions: {
|
||||
columns: useLineGridColumns(),
|
||||
height: 360,
|
||||
keepSource: true,
|
||||
proxyConfig: {
|
||||
ajax: {
|
||||
query: async ({ page }) => {
|
||||
if (!props.oqcId) {
|
||||
return { list: [], total: 0 };
|
||||
}
|
||||
return await getOqcLinePage({
|
||||
oqcId: props.oqcId,
|
||||
pageNo: page.currentPage,
|
||||
pageSize: page.pageSize,
|
||||
});
|
||||
},
|
||||
},
|
||||
},
|
||||
rowConfig: {
|
||||
keyField: 'id',
|
||||
isHover: true,
|
||||
},
|
||||
toolbarConfig: {
|
||||
refresh: true,
|
||||
},
|
||||
} as VxeTableGridOptions<MesQcOqcLineApi.OqcLine>,
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div>
|
||||
<DefectModal @success="handleDefectChanged" />
|
||||
<Grid table-title="检验项">
|
||||
<template #actions="{ row }">
|
||||
<TableAction
|
||||
:actions="[
|
||||
{
|
||||
label: '缺陷列表',
|
||||
type: 'link',
|
||||
icon: ACTION_ICON.VIEW,
|
||||
onClick: handleOpenDefect.bind(null, row),
|
||||
},
|
||||
]"
|
||||
/>
|
||||
</template>
|
||||
</Grid>
|
||||
</div>
|
||||
</template>
|
||||
|
|
@ -0,0 +1,495 @@
|
|||
import type { VbenFormApi, VbenFormSchema } from '#/adapter/form';
|
||||
import type { VxeTableGridOptions } from '#/adapter/vxe-table';
|
||||
import type { MesQcRqcApi } from '#/api/mes/qc/rqc';
|
||||
import type { MesQcRqcLineApi } from '#/api/mes/qc/rqc/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 { getSimpleUserList } from '#/api/system/user';
|
||||
import MdItemSelect from '#/views/mes/md/item/components/md-item-select.vue';
|
||||
import {
|
||||
MesAutoCodeRuleCode,
|
||||
MesQcSourceDocTypeEnum,
|
||||
} from '#/views/mes/utils/constants';
|
||||
|
||||
/** 表单类型 */
|
||||
export type FormType = 'create' | 'detail' | 'update';
|
||||
|
||||
/** 列表搜索专用:来源单据类型字典只允许 RQC 用到的两种 */
|
||||
function getRqcSourceDocTypeOptions() {
|
||||
const allowed = new Set<number>([
|
||||
MesQcSourceDocTypeEnum.RETURN_ISSUE,
|
||||
MesQcSourceDocTypeEnum.RETURN_SALES,
|
||||
]);
|
||||
return getDictOptions(DICT_TYPE.MES_QC_SOURCE_DOC_TYPE, 'number').filter(
|
||||
(item) => allowed.has(Number(item.value)),
|
||||
);
|
||||
}
|
||||
|
||||
/** 新增/修改的表单 */
|
||||
export function useFormSchema(formApi?: VbenFormApi): VbenFormSchema[] {
|
||||
return [
|
||||
{
|
||||
fieldName: 'id',
|
||||
component: 'Input',
|
||||
dependencies: {
|
||||
triggerFields: [''],
|
||||
show: () => false,
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldName: 'sourceDocId',
|
||||
component: 'Input',
|
||||
dependencies: {
|
||||
triggerFields: [''],
|
||||
show: () => false,
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldName: 'sourceLineId',
|
||||
component: 'Input',
|
||||
dependencies: {
|
||||
triggerFields: [''],
|
||||
show: () => false,
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldName: 'status',
|
||||
component: 'Input',
|
||||
dependencies: {
|
||||
triggerFields: [''],
|
||||
show: () => false,
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldName: 'code',
|
||||
label: '检验单编号',
|
||||
component: 'Input',
|
||||
componentProps: {
|
||||
placeholder: '请输入检验单编号',
|
||||
},
|
||||
rules: 'required',
|
||||
suffix: () =>
|
||||
h(
|
||||
Button,
|
||||
{
|
||||
type: 'default',
|
||||
onClick: async () => {
|
||||
try {
|
||||
const code = await generateAutoCode(
|
||||
MesAutoCodeRuleCode.QC_RQC_CODE,
|
||||
);
|
||||
await formApi?.setFieldValue('code', code);
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
}
|
||||
},
|
||||
},
|
||||
{ default: () => '生成' },
|
||||
),
|
||||
},
|
||||
{
|
||||
fieldName: 'name',
|
||||
label: '检验单名称',
|
||||
component: 'Input',
|
||||
componentProps: {
|
||||
placeholder: '请输入检验单名称',
|
||||
},
|
||||
rules: 'required',
|
||||
},
|
||||
{
|
||||
fieldName: 'sourceDocType',
|
||||
label: '来源单据类型',
|
||||
component: 'Select',
|
||||
componentProps: {
|
||||
disabled: true,
|
||||
options: getDictOptions(DICT_TYPE.MES_QC_SOURCE_DOC_TYPE, 'number'),
|
||||
placeholder: '来源单据类型',
|
||||
},
|
||||
dependencies: {
|
||||
triggerFields: ['sourceDocType'],
|
||||
show: (values) => !!values.sourceDocType,
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldName: 'sourceDocCode',
|
||||
label: '来源单据编号',
|
||||
component: 'Input',
|
||||
componentProps: {
|
||||
disabled: true,
|
||||
placeholder: '来源单据编号',
|
||||
},
|
||||
dependencies: {
|
||||
triggerFields: ['sourceDocType', 'sourceDocId'],
|
||||
show: (values) => !!values.sourceDocType && !!values.sourceDocId,
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldName: 'type',
|
||||
label: '检验类型',
|
||||
component: 'Select',
|
||||
componentProps: {
|
||||
allowClear: true,
|
||||
options: getDictOptions(DICT_TYPE.MES_RQC_TYPE, 'number'),
|
||||
placeholder: '请选择检验类型',
|
||||
},
|
||||
rules: 'selectRequired',
|
||||
},
|
||||
{
|
||||
fieldName: 'itemId',
|
||||
label: '产品物料',
|
||||
component: markRaw(MdItemSelect),
|
||||
componentProps: {
|
||||
placeholder: '请选择产品物料',
|
||||
},
|
||||
rules: 'selectRequired',
|
||||
dependencies: {
|
||||
triggerFields: ['sourceDocId'],
|
||||
componentProps: (values) => ({
|
||||
disabled: !!values.sourceDocId,
|
||||
placeholder: '请选择产品物料',
|
||||
}),
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldName: 'batchCode',
|
||||
label: '批次号',
|
||||
component: 'Input',
|
||||
componentProps: {
|
||||
placeholder: '请输入批次号',
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldName: 'checkQuantity',
|
||||
label: '检测数量',
|
||||
component: 'InputNumber',
|
||||
componentProps: {
|
||||
class: '!w-full',
|
||||
min: 0,
|
||||
placeholder: '请输入',
|
||||
precision: 2,
|
||||
},
|
||||
rules: 'required',
|
||||
dependencies: {
|
||||
triggerFields: ['sourceDocId'],
|
||||
componentProps: (values) => ({
|
||||
class: '!w-full',
|
||||
disabled: !!values.sourceDocId,
|
||||
min: 0,
|
||||
placeholder: '请输入',
|
||||
precision: 2,
|
||||
}),
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldName: 'qualifiedQuantity',
|
||||
label: '合格品数量',
|
||||
component: 'InputNumber',
|
||||
componentProps: {
|
||||
class: '!w-full',
|
||||
min: 0,
|
||||
placeholder: '请输入',
|
||||
precision: 2,
|
||||
},
|
||||
rules: 'required',
|
||||
},
|
||||
{
|
||||
fieldName: 'unqualifiedQuantity',
|
||||
label: '不合格品数量',
|
||||
component: 'InputNumber',
|
||||
componentProps: {
|
||||
class: '!w-full',
|
||||
min: 0,
|
||||
placeholder: '请输入',
|
||||
precision: 2,
|
||||
},
|
||||
rules: 'required',
|
||||
},
|
||||
{
|
||||
fieldName: 'inspectDate',
|
||||
label: '检测日期',
|
||||
component: 'DatePicker',
|
||||
componentProps: {
|
||||
format: 'YYYY-MM-DD HH:mm:ss',
|
||||
placeholder: '请选择检测日期',
|
||||
showTime: true,
|
||||
valueFormat: 'x',
|
||||
},
|
||||
rules: 'required',
|
||||
},
|
||||
{
|
||||
fieldName: 'inspectorUserId',
|
||||
label: '检测人员',
|
||||
component: 'ApiSelect',
|
||||
componentProps: {
|
||||
allowClear: true,
|
||||
api: getSimpleUserList,
|
||||
labelField: 'nickname',
|
||||
placeholder: '请选择检测人员',
|
||||
valueField: 'id',
|
||||
},
|
||||
rules: 'selectRequired',
|
||||
},
|
||||
{
|
||||
fieldName: 'checkResult',
|
||||
label: '检测结果',
|
||||
component: 'Select',
|
||||
componentProps: {
|
||||
allowClear: true,
|
||||
options: getDictOptions(DICT_TYPE.MES_QC_CHECK_RESULT, 'number'),
|
||||
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: 'sourceDocType',
|
||||
label: '来源单据类型',
|
||||
component: 'Select',
|
||||
componentProps: {
|
||||
allowClear: true,
|
||||
options: getRqcSourceDocTypeOptions(),
|
||||
placeholder: '请选择来源单据类型',
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldName: 'sourceDocCode',
|
||||
label: '来源单据编号',
|
||||
component: 'Input',
|
||||
componentProps: {
|
||||
allowClear: true,
|
||||
placeholder: '请输入来源单据编号',
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldName: 'itemId',
|
||||
label: '产品物料',
|
||||
component: markRaw(MdItemSelect),
|
||||
componentProps: {
|
||||
placeholder: '请选择产品物料',
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldName: 'batchCode',
|
||||
label: '批次号',
|
||||
component: 'Input',
|
||||
componentProps: {
|
||||
allowClear: true,
|
||||
placeholder: '请输入批次号',
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldName: 'checkResult',
|
||||
label: '检测结果',
|
||||
component: 'Select',
|
||||
componentProps: {
|
||||
allowClear: true,
|
||||
options: getDictOptions(DICT_TYPE.MES_QC_CHECK_RESULT, 'number'),
|
||||
placeholder: '请选择检测结果',
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldName: 'inspectorUserId',
|
||||
label: '检测人员',
|
||||
component: 'ApiSelect',
|
||||
componentProps: {
|
||||
allowClear: true,
|
||||
api: getSimpleUserList,
|
||||
labelField: 'nickname',
|
||||
placeholder: '请选择检测人员',
|
||||
valueField: 'id',
|
||||
},
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
/** 列表的字段 */
|
||||
export function useGridColumns(): VxeTableGridOptions<MesQcRqcApi.Rqc>['columns'] {
|
||||
return [
|
||||
{
|
||||
field: 'code',
|
||||
title: '检验单编号',
|
||||
width: 160,
|
||||
slots: { default: 'code' },
|
||||
},
|
||||
{
|
||||
field: 'name',
|
||||
title: '检验单名称',
|
||||
minWidth: 180,
|
||||
},
|
||||
{
|
||||
field: 'sourceDocType',
|
||||
title: '来源单据类型',
|
||||
width: 120,
|
||||
cellRender: {
|
||||
name: 'CellDict',
|
||||
props: { type: DICT_TYPE.MES_QC_SOURCE_DOC_TYPE },
|
||||
},
|
||||
},
|
||||
{
|
||||
field: 'sourceDocCode',
|
||||
title: '来源单据编码',
|
||||
width: 160,
|
||||
},
|
||||
{
|
||||
field: 'itemCode',
|
||||
title: '产品物料编码',
|
||||
width: 130,
|
||||
},
|
||||
{
|
||||
field: 'itemName',
|
||||
title: '产品物料名称',
|
||||
minWidth: 150,
|
||||
},
|
||||
{
|
||||
field: 'itemSpecification',
|
||||
title: '规格型号',
|
||||
width: 130,
|
||||
},
|
||||
{
|
||||
field: 'unitName',
|
||||
title: '单位',
|
||||
width: 80,
|
||||
},
|
||||
{
|
||||
field: 'batchCode',
|
||||
title: '批次号',
|
||||
width: 130,
|
||||
},
|
||||
{
|
||||
field: 'checkResult',
|
||||
title: '检测结果',
|
||||
width: 110,
|
||||
cellRender: {
|
||||
name: 'CellDict',
|
||||
props: { type: DICT_TYPE.MES_QC_CHECK_RESULT },
|
||||
},
|
||||
},
|
||||
{
|
||||
field: 'inspectDate',
|
||||
title: '检测日期',
|
||||
width: 160,
|
||||
formatter: 'formatDateTime',
|
||||
},
|
||||
{
|
||||
field: 'inspectorNickname',
|
||||
title: '检测人员',
|
||||
width: 100,
|
||||
},
|
||||
{
|
||||
field: 'status',
|
||||
title: '单据状态',
|
||||
width: 100,
|
||||
cellRender: {
|
||||
name: 'CellDict',
|
||||
props: { type: DICT_TYPE.MES_ORDER_STATUS },
|
||||
},
|
||||
},
|
||||
{
|
||||
title: '操作',
|
||||
width: 180,
|
||||
fixed: 'right',
|
||||
slots: { default: 'actions' },
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
/** 退货检验单行子表的字段 */
|
||||
export function useLineGridColumns(): VxeTableGridOptions<MesQcRqcLineApi.RqcLine>['columns'] {
|
||||
return [
|
||||
{
|
||||
field: 'indicatorName',
|
||||
title: '检测项名称',
|
||||
minWidth: 150,
|
||||
},
|
||||
{
|
||||
field: 'indicatorType',
|
||||
title: '检测项类型',
|
||||
width: 120,
|
||||
cellRender: {
|
||||
name: 'CellDict',
|
||||
props: { type: DICT_TYPE.MES_INDICATOR_TYPE },
|
||||
},
|
||||
},
|
||||
{
|
||||
field: 'tool',
|
||||
title: '检测工具',
|
||||
width: 120,
|
||||
},
|
||||
{
|
||||
field: 'checkMethod',
|
||||
title: '检测方法',
|
||||
minWidth: 180,
|
||||
},
|
||||
{
|
||||
field: 'standardValue',
|
||||
title: '标准值',
|
||||
width: 100,
|
||||
},
|
||||
{
|
||||
field: 'unitMeasureName',
|
||||
title: '单位',
|
||||
width: 80,
|
||||
},
|
||||
{
|
||||
field: 'maxThreshold',
|
||||
title: '误差上限',
|
||||
width: 100,
|
||||
},
|
||||
{
|
||||
field: 'minThreshold',
|
||||
title: '误差下限',
|
||||
width: 100,
|
||||
},
|
||||
{
|
||||
field: 'criticalQuantity',
|
||||
title: '致命缺陷数',
|
||||
width: 110,
|
||||
},
|
||||
{
|
||||
field: 'majorQuantity',
|
||||
title: '严重缺陷数',
|
||||
width: 110,
|
||||
},
|
||||
{
|
||||
field: 'minorQuantity',
|
||||
title: '轻微缺陷数',
|
||||
width: 110,
|
||||
},
|
||||
{
|
||||
title: '操作',
|
||||
width: 110,
|
||||
fixed: 'right',
|
||||
slots: { default: 'actions' },
|
||||
},
|
||||
];
|
||||
}
|
||||
|
|
@ -0,0 +1,167 @@
|
|||
<script lang="ts" setup>
|
||||
import type { VxeTableGridOptions } from '#/adapter/vxe-table';
|
||||
import type { MesQcRqcApi } from '#/api/mes/qc/rqc';
|
||||
|
||||
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 { deleteRqc, exportRqc, getRqcPage } from '#/api/mes/qc/rqc';
|
||||
import { $t } from '#/locales';
|
||||
import { MesQcStatusEnum } 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: MesQcRqcApi.Rqc) {
|
||||
formModalApi.setData({ formType: 'detail', id: row.id }).open();
|
||||
}
|
||||
|
||||
/** 编辑退货检验单 */
|
||||
function handleEdit(row: MesQcRqcApi.Rqc) {
|
||||
formModalApi.setData({ formType: 'update', id: row.id }).open();
|
||||
}
|
||||
|
||||
/** 删除退货检验单 */
|
||||
async function handleDelete(row: MesQcRqcApi.Rqc) {
|
||||
const hideLoading = message.loading({
|
||||
content: $t('ui.actionMessage.deleting', [row.code]),
|
||||
duration: 0,
|
||||
});
|
||||
try {
|
||||
await deleteRqc(row.id!);
|
||||
message.success($t('ui.actionMessage.deleteSuccess', [row.code]));
|
||||
handleRefresh();
|
||||
} finally {
|
||||
hideLoading();
|
||||
}
|
||||
}
|
||||
|
||||
/** 导出表格 */
|
||||
async function handleExport() {
|
||||
const data = await exportRqc(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 getRqcPage({
|
||||
pageNo: page.currentPage,
|
||||
pageSize: page.pageSize,
|
||||
...formValues,
|
||||
});
|
||||
},
|
||||
},
|
||||
},
|
||||
rowConfig: {
|
||||
keyField: 'id',
|
||||
isHover: true,
|
||||
},
|
||||
toolbarConfig: {
|
||||
refresh: true,
|
||||
search: true,
|
||||
},
|
||||
} as VxeTableGridOptions<MesQcRqcApi.Rqc>,
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Page auto-content-height>
|
||||
<template #doc>
|
||||
<DocAlert
|
||||
title="【质量】退货检验(RQC)"
|
||||
url="https://doc.iocoder.cn/mes/qc/rqc/"
|
||||
/>
|
||||
</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:qc-rqc:create'],
|
||||
onClick: handleCreate,
|
||||
},
|
||||
{
|
||||
label: $t('ui.actionTitle.export'),
|
||||
type: 'primary',
|
||||
icon: ACTION_ICON.DOWNLOAD,
|
||||
auth: ['mes:qc-rqc: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:qc-rqc:update'],
|
||||
ifShow: row.status === MesQcStatusEnum.DRAFT,
|
||||
onClick: handleEdit.bind(null, row),
|
||||
},
|
||||
{
|
||||
label: $t('common.delete'),
|
||||
type: 'link',
|
||||
danger: true,
|
||||
icon: ACTION_ICON.DELETE,
|
||||
auth: ['mes:qc-rqc:delete'],
|
||||
ifShow: row.status === MesQcStatusEnum.DRAFT,
|
||||
popConfirm: {
|
||||
title: $t('ui.actionMessage.deleteConfirm', [row.code]),
|
||||
confirm: handleDelete.bind(null, row),
|
||||
},
|
||||
},
|
||||
{
|
||||
label: $t('common.detail'),
|
||||
type: 'link',
|
||||
icon: ACTION_ICON.VIEW,
|
||||
auth: ['mes:qc-rqc:query'],
|
||||
onClick: handleDetail.bind(null, row),
|
||||
},
|
||||
]"
|
||||
/>
|
||||
</template>
|
||||
</Grid>
|
||||
</Page>
|
||||
</template>
|
||||
|
|
@ -0,0 +1,232 @@
|
|||
<script lang="ts" setup>
|
||||
import type { FormType } from '../data';
|
||||
|
||||
import type { MesQcRqcApi } from '#/api/mes/qc/rqc';
|
||||
|
||||
import { computed, ref } from 'vue';
|
||||
|
||||
import { confirm, useVbenModal } from '@vben/common-ui';
|
||||
|
||||
import { Button, Descriptions, message, Tabs } from 'ant-design-vue';
|
||||
|
||||
import { useVbenForm } from '#/adapter/form';
|
||||
import {
|
||||
createRqc,
|
||||
finishRqc,
|
||||
getRqc,
|
||||
updateRqc,
|
||||
} from '#/api/mes/qc/rqc';
|
||||
import { $t } from '#/locales';
|
||||
import { MesQcStatusEnum, MesQcTypeEnum } from '#/views/mes/utils/constants';
|
||||
|
||||
import { QcIndicatorResultList } from '../../indicatorresult/components';
|
||||
import { useFormSchema } from '../data';
|
||||
import LineList from './line-list.vue';
|
||||
|
||||
const emit = defineEmits(['success']);
|
||||
const formType = ref<FormType>('create');
|
||||
const formData = ref<MesQcRqcApi.Rqc>();
|
||||
const subTabsName = ref('line');
|
||||
const originalSnapshot = ref('');
|
||||
const isDetail = computed(() => formType.value === 'detail');
|
||||
const canFinish = computed(
|
||||
() =>
|
||||
formType.value === 'update' &&
|
||||
formData.value?.status === MesQcStatusEnum.DRAFT,
|
||||
);
|
||||
const getTitle = computed(() => {
|
||||
if (formType.value === 'detail') {
|
||||
return $t('ui.actionTitle.view', ['退货检验单']);
|
||||
}
|
||||
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,
|
||||
},
|
||||
wrapperClass: 'grid-cols-3',
|
||||
layout: 'horizontal',
|
||||
schema: [],
|
||||
showDefaultActions: false,
|
||||
});
|
||||
|
||||
/** 子表变更后刷新主表头数据(缺陷统计等) */
|
||||
async function handleRefresh() {
|
||||
if (!formData.value?.id) {
|
||||
return;
|
||||
}
|
||||
formData.value = await getRqc(formData.value.id);
|
||||
}
|
||||
|
||||
/** 提交表单 */
|
||||
async function handleSubmit(): Promise<boolean> {
|
||||
const { valid } = await formApi.validate();
|
||||
if (!valid) {
|
||||
return false;
|
||||
}
|
||||
const data = (await formApi.getValues()) as MesQcRqcApi.Rqc;
|
||||
if (formData.value?.id) {
|
||||
await updateRqc({ ...data, id: formData.value.id });
|
||||
formData.value = { ...formData.value, ...data };
|
||||
} else {
|
||||
const id = await createRqc(data);
|
||||
formData.value = {
|
||||
...data,
|
||||
id: id as unknown as number,
|
||||
status: MesQcStatusEnum.DRAFT,
|
||||
};
|
||||
await formApi.setFieldValue('id', formData.value.id);
|
||||
await formApi.setFieldValue('status', formData.value.status);
|
||||
formType.value = 'update';
|
||||
}
|
||||
originalSnapshot.value = JSON.stringify(await formApi.getValues());
|
||||
return true;
|
||||
}
|
||||
|
||||
/** 完成检验单:表单有修改时先保存,再调用完成接口 */
|
||||
async function handleFinish() {
|
||||
const id = formData.value?.id;
|
||||
if (!id) {
|
||||
return;
|
||||
}
|
||||
const { valid } = await formApi.validate();
|
||||
if (!valid) {
|
||||
return;
|
||||
}
|
||||
// TODO @AI:这种类型,可以简化成 await confirm('');如果可以,写到 style vue 里;然后把相关的类似情况,都一次性改掉;
|
||||
await confirm({
|
||||
content: '是否完成退货检验单编制?【完成后将不能更改】',
|
||||
});
|
||||
modalApi.lock();
|
||||
try {
|
||||
const current = JSON.stringify(await formApi.getValues());
|
||||
if (current !== originalSnapshot.value) {
|
||||
const data = (await formApi.getValues()) as MesQcRqcApi.Rqc;
|
||||
await updateRqc({ ...data, id });
|
||||
formData.value = { ...formData.value, ...data };
|
||||
originalSnapshot.value = current;
|
||||
}
|
||||
await finishRqc(id);
|
||||
message.success('完成成功');
|
||||
await modalApi.close();
|
||||
emit('success');
|
||||
} finally {
|
||||
modalApi.unlock();
|
||||
}
|
||||
}
|
||||
|
||||
// TODO @AI:方法内注释;
|
||||
const [Modal, modalApi] = useVbenModal({
|
||||
async onConfirm() {
|
||||
if (isDetail.value) {
|
||||
await modalApi.close();
|
||||
return;
|
||||
}
|
||||
modalApi.lock();
|
||||
try {
|
||||
const ok = await handleSubmit();
|
||||
if (!ok) {
|
||||
return;
|
||||
}
|
||||
message.success($t('ui.actionMessage.operationSuccess'));
|
||||
await modalApi.close();
|
||||
emit('success');
|
||||
} finally {
|
||||
modalApi.unlock();
|
||||
}
|
||||
},
|
||||
async onOpenChange(isOpen: boolean) {
|
||||
if (!isOpen) {
|
||||
formData.value = undefined;
|
||||
originalSnapshot.value = '';
|
||||
return;
|
||||
}
|
||||
formApi.setState({ schema: useFormSchema(formApi) });
|
||||
subTabsName.value = 'line';
|
||||
const data = modalApi.getData<{
|
||||
formType: FormType;
|
||||
id?: number;
|
||||
prefill?: MesQcRqcApi.Rqc;
|
||||
}>();
|
||||
formType.value = data.formType;
|
||||
formApi.setDisabled(formType.value === 'detail');
|
||||
modalApi.setState({ showConfirmButton: formType.value !== 'detail' });
|
||||
if (data?.id) {
|
||||
modalApi.lock();
|
||||
try {
|
||||
formData.value = await getRqc(data.id);
|
||||
await formApi.setValues(formData.value);
|
||||
} finally {
|
||||
modalApi.unlock();
|
||||
}
|
||||
} else if (data?.prefill) {
|
||||
formData.value = { ...data.prefill };
|
||||
await formApi.setValues(data.prefill);
|
||||
}
|
||||
originalSnapshot.value = JSON.stringify(await formApi.getValues());
|
||||
},
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Modal :title="getTitle" class="w-4/5">
|
||||
<Form class="mx-4" />
|
||||
<!-- 缺陷统计(只读) -->
|
||||
<div v-if="formData?.id" class="mx-4 mt-4">
|
||||
<Descriptions title="缺陷情况" :column="3" bordered size="small">
|
||||
<Descriptions.Item label="致命缺陷数">
|
||||
{{ formData.criticalQuantity ?? 0 }}
|
||||
</Descriptions.Item>
|
||||
<Descriptions.Item label="严重缺陷数">
|
||||
{{ formData.majorQuantity ?? 0 }}
|
||||
</Descriptions.Item>
|
||||
<Descriptions.Item label="轻微缺陷数">
|
||||
{{ formData.minorQuantity ?? 0 }}
|
||||
</Descriptions.Item>
|
||||
<Descriptions.Item label="致命缺陷率">
|
||||
{{ formData.criticalRate ?? 0 }}%
|
||||
</Descriptions.Item>
|
||||
<Descriptions.Item label="严重缺陷率">
|
||||
{{ formData.majorRate ?? 0 }}%
|
||||
</Descriptions.Item>
|
||||
<Descriptions.Item label="轻微缺陷率">
|
||||
{{ formData.minorRate ?? 0 }}%
|
||||
</Descriptions.Item>
|
||||
</Descriptions>
|
||||
</div>
|
||||
<Tabs
|
||||
v-if="formData?.id"
|
||||
v-model:active-key="subTabsName"
|
||||
class="mx-4 mt-4"
|
||||
>
|
||||
<Tabs.TabPane key="line" tab="检验项">
|
||||
<LineList
|
||||
:form-type="formType"
|
||||
:rqc-id="formData.id"
|
||||
@refresh="handleRefresh"
|
||||
/>
|
||||
</Tabs.TabPane>
|
||||
<Tabs.TabPane key="result" tab="检测结果">
|
||||
<QcIndicatorResultList
|
||||
:qc-id="formData.id"
|
||||
:qc-type="MesQcTypeEnum.RQC"
|
||||
:readonly="isDetail"
|
||||
/>
|
||||
</Tabs.TabPane>
|
||||
</Tabs>
|
||||
<template #prepend-footer>
|
||||
<div class="flex flex-auto items-center gap-2">
|
||||
<Button v-if="canFinish" type="primary" @click="handleFinish">
|
||||
完成
|
||||
</Button>
|
||||
</div>
|
||||
</template>
|
||||
</Modal>
|
||||
</template>
|
||||
|
|
@ -0,0 +1,97 @@
|
|||
<script lang="ts" setup>
|
||||
import type { VxeTableGridOptions } from '#/adapter/vxe-table';
|
||||
import type { MesQcRqcLineApi } from '#/api/mes/qc/rqc/line';
|
||||
|
||||
import { useVbenModal } from '@vben/common-ui';
|
||||
|
||||
import { ACTION_ICON, TableAction, useVbenVxeGrid } from '#/adapter/vxe-table';
|
||||
import { getRqcLinePage } from '#/api/mes/qc/rqc/line';
|
||||
import { MesQcTypeEnum } from '#/views/mes/utils/constants';
|
||||
|
||||
import { DefectRecordInlineList } from '../../defectrecord/components';
|
||||
import { useLineGridColumns } from '../data';
|
||||
|
||||
const props = defineProps<{
|
||||
formType?: string;
|
||||
rqcId: number;
|
||||
}>();
|
||||
|
||||
const emit = defineEmits<{ refresh: [] }>();
|
||||
|
||||
const [DefectModal, defectModalApi] = useVbenModal({
|
||||
connectedComponent: DefectRecordInlineList,
|
||||
destroyOnClose: true,
|
||||
});
|
||||
|
||||
/** 刷新表格 */
|
||||
function handleRefresh() {
|
||||
gridApi.query();
|
||||
}
|
||||
|
||||
/** 缺陷记录变更后,刷新本表格并通知父组件刷新主表统计 */
|
||||
function handleDefectChanged() {
|
||||
handleRefresh();
|
||||
emit('refresh');
|
||||
}
|
||||
|
||||
/** 打开缺陷记录弹窗 */
|
||||
function handleOpenDefect(row: MesQcRqcLineApi.RqcLine) {
|
||||
defectModalApi
|
||||
.setData({
|
||||
formType: props.formType,
|
||||
lineId: row.id,
|
||||
qcId: props.rqcId,
|
||||
qcType: MesQcTypeEnum.RQC,
|
||||
})
|
||||
.open();
|
||||
}
|
||||
|
||||
const [Grid, gridApi] = useVbenVxeGrid({
|
||||
gridOptions: {
|
||||
columns: useLineGridColumns(),
|
||||
height: 360,
|
||||
keepSource: true,
|
||||
proxyConfig: {
|
||||
ajax: {
|
||||
query: async ({ page }) => {
|
||||
if (!props.rqcId) {
|
||||
return { list: [], total: 0 };
|
||||
}
|
||||
return await getRqcLinePage({
|
||||
rqcId: props.rqcId,
|
||||
pageNo: page.currentPage,
|
||||
pageSize: page.pageSize,
|
||||
});
|
||||
},
|
||||
},
|
||||
},
|
||||
rowConfig: {
|
||||
keyField: 'id',
|
||||
isHover: true,
|
||||
},
|
||||
toolbarConfig: {
|
||||
refresh: true,
|
||||
},
|
||||
} as VxeTableGridOptions<MesQcRqcLineApi.RqcLine>,
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div>
|
||||
<DefectModal @success="handleDefectChanged" />
|
||||
<Grid table-title="检验项">
|
||||
<template #actions="{ row }">
|
||||
<TableAction
|
||||
:actions="[
|
||||
{
|
||||
label: '缺陷列表',
|
||||
type: 'link',
|
||||
icon: ACTION_ICON.VIEW,
|
||||
onClick: handleOpenDefect.bind(null, row),
|
||||
},
|
||||
]"
|
||||
/>
|
||||
</template>
|
||||
</Grid>
|
||||
</div>
|
||||
</template>
|
||||
|
|
@ -0,0 +1,573 @@
|
|||
import type { VbenFormApi, VbenFormSchema } from '#/adapter/form';
|
||||
import type { VxeTableGridOptions } from '#/adapter/vxe-table';
|
||||
import type { MesQcIpqcApi } from '#/api/mes/qc/ipqc';
|
||||
import type { MesQcIpqcLineApi } from '#/api/mes/qc/ipqc/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 { getSimpleUserList } from '#/api/system/user';
|
||||
import MdItemSelect from '#/views/mes/md/item/components/md-item-select.vue';
|
||||
import MdWorkstationSelect from '#/views/mes/md/workstation/components/md-workstation-select.vue';
|
||||
import ProTaskSelect from '#/views/mes/pro/task/components/pro-task-select.vue';
|
||||
import ProWorkOrderSelect from '#/views/mes/pro/workorder/components/pro-work-order-select.vue';
|
||||
import {
|
||||
MesAutoCodeRuleCode,
|
||||
MesProTaskStatusEnum,
|
||||
MesProWorkOrderStatusEnum,
|
||||
} from '#/views/mes/utils/constants';
|
||||
|
||||
/** 表单类型 */
|
||||
export type FormType = 'create' | 'detail' | 'update';
|
||||
|
||||
/** 把不合格品数量同步为工废 + 料废 + 其他废品之和 */
|
||||
function syncUnqualified(formApi?: VbenFormApi) {
|
||||
if (!formApi) {
|
||||
return;
|
||||
}
|
||||
void (async () => {
|
||||
const values = await formApi.getValues();
|
||||
const next =
|
||||
Number(values.laborScrapQuantity || 0) +
|
||||
Number(values.materialScrapQuantity || 0) +
|
||||
Number(values.otherScrapQuantity || 0);
|
||||
await formApi.setFieldValue('unqualifiedQuantity', next);
|
||||
})();
|
||||
}
|
||||
|
||||
/** 新增/修改的表单 */
|
||||
export function useFormSchema(formApi?: VbenFormApi): VbenFormSchema[] {
|
||||
return [
|
||||
{
|
||||
fieldName: 'id',
|
||||
component: 'Input',
|
||||
dependencies: {
|
||||
triggerFields: [''],
|
||||
show: () => false,
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldName: 'sourceDocId',
|
||||
component: 'Input',
|
||||
dependencies: {
|
||||
triggerFields: [''],
|
||||
show: () => false,
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldName: 'sourceLineId',
|
||||
component: 'Input',
|
||||
dependencies: {
|
||||
triggerFields: [''],
|
||||
show: () => false,
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldName: 'status',
|
||||
component: 'Input',
|
||||
dependencies: {
|
||||
triggerFields: [''],
|
||||
show: () => false,
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldName: 'code',
|
||||
label: '检验单编号',
|
||||
component: 'Input',
|
||||
componentProps: {
|
||||
placeholder: '请输入检验单编号',
|
||||
},
|
||||
rules: 'required',
|
||||
suffix: () =>
|
||||
h(
|
||||
ElButton,
|
||||
{
|
||||
onClick: async () => {
|
||||
try {
|
||||
const code = await generateAutoCode(
|
||||
MesAutoCodeRuleCode.QC_IPQC_CODE,
|
||||
);
|
||||
await formApi?.setFieldValue('code', code);
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
}
|
||||
},
|
||||
},
|
||||
{ default: () => '生成' },
|
||||
),
|
||||
},
|
||||
{
|
||||
fieldName: 'name',
|
||||
label: '检验单名称',
|
||||
component: 'Input',
|
||||
componentProps: {
|
||||
placeholder: '请输入检验单名称',
|
||||
},
|
||||
rules: 'required',
|
||||
},
|
||||
{
|
||||
fieldName: 'type',
|
||||
label: '检验类型',
|
||||
component: 'Select',
|
||||
componentProps: {
|
||||
clearable: true,
|
||||
options: getDictOptions(DICT_TYPE.MES_IPQC_TYPE, 'number'),
|
||||
placeholder: '请选择检验类型',
|
||||
},
|
||||
rules: 'selectRequired',
|
||||
},
|
||||
{
|
||||
fieldName: 'sourceDocType',
|
||||
label: '来源单据类型',
|
||||
component: 'Select',
|
||||
componentProps: {
|
||||
disabled: true,
|
||||
options: getDictOptions(DICT_TYPE.MES_QC_SOURCE_DOC_TYPE, 'number'),
|
||||
placeholder: '来源单据类型',
|
||||
},
|
||||
dependencies: {
|
||||
triggerFields: ['sourceDocType'],
|
||||
show: (values) => !!values.sourceDocType,
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldName: 'sourceDocCode',
|
||||
label: '来源单据编号',
|
||||
component: 'Input',
|
||||
componentProps: {
|
||||
disabled: true,
|
||||
placeholder: '来源单据编号',
|
||||
},
|
||||
dependencies: {
|
||||
triggerFields: ['sourceDocType', 'sourceDocId'],
|
||||
show: (values) => !!values.sourceDocType && !!values.sourceDocId,
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldName: 'workOrderId',
|
||||
label: '生产工单',
|
||||
component: markRaw(ProWorkOrderSelect),
|
||||
componentProps: {
|
||||
placeholder: '请选择生产工单',
|
||||
status: MesProWorkOrderStatusEnum.CONFIRMED,
|
||||
// 工单变更时清空生产任务
|
||||
onChange: () => formApi?.setFieldValue('taskId', undefined),
|
||||
},
|
||||
rules: 'selectRequired',
|
||||
dependencies: {
|
||||
triggerFields: ['sourceDocId'],
|
||||
componentProps: (values) => ({
|
||||
disabled: !!values.sourceDocId,
|
||||
placeholder: '请选择生产工单',
|
||||
status: MesProWorkOrderStatusEnum.CONFIRMED,
|
||||
onChange: () => formApi?.setFieldValue('taskId', undefined),
|
||||
}),
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldName: 'workstationId',
|
||||
label: '工位',
|
||||
component: markRaw(MdWorkstationSelect),
|
||||
componentProps: {
|
||||
placeholder: '请选择工位',
|
||||
},
|
||||
rules: 'selectRequired',
|
||||
dependencies: {
|
||||
triggerFields: ['sourceDocId'],
|
||||
componentProps: (values) => ({
|
||||
disabled: !!values.sourceDocId,
|
||||
placeholder: '请选择工位',
|
||||
}),
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldName: 'taskId',
|
||||
label: '生产任务',
|
||||
component: markRaw(ProTaskSelect),
|
||||
componentProps: {
|
||||
placeholder: '请选择生产任务',
|
||||
statuses: [MesProTaskStatusEnum.PREPARE],
|
||||
},
|
||||
dependencies: {
|
||||
triggerFields: ['sourceDocId', 'workOrderId', 'workstationId'],
|
||||
componentProps: (values) => ({
|
||||
disabled: !!values.sourceDocId || !values.workOrderId,
|
||||
placeholder: '请选择生产任务',
|
||||
statuses: [MesProTaskStatusEnum.PREPARE],
|
||||
workOrderId: values.workOrderId,
|
||||
workstationId: values.workstationId,
|
||||
}),
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldName: 'checkQuantity',
|
||||
label: '检测数量',
|
||||
component: 'InputNumber',
|
||||
componentProps: {
|
||||
class: '!w-full',
|
||||
controlsPosition: 'right',
|
||||
min: 0,
|
||||
placeholder: '请输入检测数量',
|
||||
precision: 2,
|
||||
},
|
||||
rules: 'required',
|
||||
dependencies: {
|
||||
triggerFields: ['sourceDocId'],
|
||||
componentProps: (values) => ({
|
||||
class: '!w-full',
|
||||
controlsPosition: 'right',
|
||||
disabled: !!values.sourceDocId,
|
||||
min: 0,
|
||||
placeholder: '请输入检测数量',
|
||||
precision: 2,
|
||||
}),
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldName: 'qualifiedQuantity',
|
||||
label: '合格品数量',
|
||||
component: 'InputNumber',
|
||||
componentProps: {
|
||||
class: '!w-full',
|
||||
controlsPosition: 'right',
|
||||
min: 0,
|
||||
placeholder: '请输入合格品数量',
|
||||
precision: 2,
|
||||
},
|
||||
rules: 'required',
|
||||
},
|
||||
{
|
||||
fieldName: 'unqualifiedQuantity',
|
||||
label: '不合格品数量',
|
||||
component: 'InputNumber',
|
||||
componentProps: {
|
||||
class: '!w-full',
|
||||
controlsPosition: 'right',
|
||||
min: 0,
|
||||
placeholder: '请输入不合格品数量',
|
||||
precision: 2,
|
||||
},
|
||||
rules: 'required',
|
||||
},
|
||||
{
|
||||
fieldName: 'laborScrapQuantity',
|
||||
label: '工废数量',
|
||||
component: 'InputNumber',
|
||||
componentProps: {
|
||||
class: '!w-full',
|
||||
controlsPosition: 'right',
|
||||
min: 0,
|
||||
placeholder: '请输入工废数量',
|
||||
precision: 2,
|
||||
onChange: () => syncUnqualified(formApi),
|
||||
},
|
||||
rules: 'required',
|
||||
dependencies: {
|
||||
triggerFields: ['unqualifiedQuantity'],
|
||||
show: (values) =>
|
||||
values.unqualifiedQuantity != null && values.unqualifiedQuantity > 0,
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldName: 'materialScrapQuantity',
|
||||
label: '料废数量',
|
||||
component: 'InputNumber',
|
||||
componentProps: {
|
||||
class: '!w-full',
|
||||
controlsPosition: 'right',
|
||||
min: 0,
|
||||
placeholder: '请输入料废数量',
|
||||
precision: 2,
|
||||
onChange: () => syncUnqualified(formApi),
|
||||
},
|
||||
rules: 'required',
|
||||
dependencies: {
|
||||
triggerFields: ['unqualifiedQuantity'],
|
||||
show: (values) =>
|
||||
values.unqualifiedQuantity != null && values.unqualifiedQuantity > 0,
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldName: 'otherScrapQuantity',
|
||||
label: '其他废品数量',
|
||||
component: 'InputNumber',
|
||||
componentProps: {
|
||||
class: '!w-full',
|
||||
controlsPosition: 'right',
|
||||
min: 0,
|
||||
placeholder: '请输入其他废品数量',
|
||||
precision: 2,
|
||||
onChange: () => syncUnqualified(formApi),
|
||||
},
|
||||
rules: 'required',
|
||||
dependencies: {
|
||||
triggerFields: ['unqualifiedQuantity'],
|
||||
show: (values) =>
|
||||
values.unqualifiedQuantity != null && values.unqualifiedQuantity > 0,
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldName: 'inspectorUserId',
|
||||
label: '检测人员',
|
||||
component: 'ApiSelect',
|
||||
componentProps: {
|
||||
api: getSimpleUserList,
|
||||
clearable: true,
|
||||
labelField: 'nickname',
|
||||
placeholder: '请选择检测人员',
|
||||
valueField: 'id',
|
||||
},
|
||||
rules: 'selectRequired',
|
||||
},
|
||||
{
|
||||
fieldName: 'inspectDate',
|
||||
label: '检测日期',
|
||||
component: 'DatePicker',
|
||||
componentProps: {
|
||||
format: 'YYYY-MM-DD',
|
||||
placeholder: '请选择检测日期',
|
||||
type: 'date',
|
||||
valueFormat: 'x',
|
||||
},
|
||||
rules: 'required',
|
||||
},
|
||||
{
|
||||
fieldName: 'checkResult',
|
||||
label: '检测结果',
|
||||
component: 'Select',
|
||||
componentProps: {
|
||||
clearable: true,
|
||||
options: getDictOptions(DICT_TYPE.MES_QC_CHECK_RESULT, 'number'),
|
||||
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: 'type',
|
||||
label: '检验类型',
|
||||
component: 'Select',
|
||||
componentProps: {
|
||||
clearable: true,
|
||||
options: getDictOptions(DICT_TYPE.MES_IPQC_TYPE, 'number'),
|
||||
placeholder: '请选择检验类型',
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldName: 'workOrderId',
|
||||
label: '生产工单',
|
||||
component: markRaw(ProWorkOrderSelect),
|
||||
componentProps: {
|
||||
placeholder: '请选择生产工单',
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldName: 'itemId',
|
||||
label: '产品物料',
|
||||
component: markRaw(MdItemSelect),
|
||||
componentProps: {
|
||||
placeholder: '请选择产品物料',
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldName: 'checkResult',
|
||||
label: '检测结果',
|
||||
component: 'Select',
|
||||
componentProps: {
|
||||
clearable: true,
|
||||
options: getDictOptions(DICT_TYPE.MES_QC_CHECK_RESULT, 'number'),
|
||||
placeholder: '请选择检测结果',
|
||||
},
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
/** 列表的字段 */
|
||||
export function useGridColumns(): VxeTableGridOptions<MesQcIpqcApi.Ipqc>['columns'] {
|
||||
return [
|
||||
{
|
||||
field: 'code',
|
||||
title: '检验单编号',
|
||||
width: 160,
|
||||
slots: { default: 'code' },
|
||||
},
|
||||
{
|
||||
field: 'name',
|
||||
title: '检验单名称',
|
||||
minWidth: 180,
|
||||
},
|
||||
{
|
||||
field: 'type',
|
||||
title: '检验类型',
|
||||
width: 120,
|
||||
cellRender: {
|
||||
name: 'CellDict',
|
||||
props: { type: DICT_TYPE.MES_IPQC_TYPE },
|
||||
},
|
||||
},
|
||||
{
|
||||
field: 'workOrderCode',
|
||||
title: '生产工单编号',
|
||||
width: 140,
|
||||
},
|
||||
{
|
||||
field: 'itemCode',
|
||||
title: '产品物料编码',
|
||||
width: 130,
|
||||
},
|
||||
{
|
||||
field: 'itemName',
|
||||
title: '产品物料名称',
|
||||
minWidth: 150,
|
||||
},
|
||||
{
|
||||
field: 'itemSpecification',
|
||||
title: '规格型号',
|
||||
width: 130,
|
||||
},
|
||||
{
|
||||
field: 'unitName',
|
||||
title: '单位',
|
||||
width: 80,
|
||||
},
|
||||
{
|
||||
field: 'checkQuantity',
|
||||
title: '检测数量',
|
||||
width: 100,
|
||||
},
|
||||
{
|
||||
field: 'checkResult',
|
||||
title: '检测结果',
|
||||
width: 110,
|
||||
cellRender: {
|
||||
name: 'CellDict',
|
||||
props: { type: DICT_TYPE.MES_QC_CHECK_RESULT },
|
||||
},
|
||||
},
|
||||
{
|
||||
field: 'inspectDate',
|
||||
title: '检测日期',
|
||||
width: 120,
|
||||
formatter: 'formatDate',
|
||||
},
|
||||
{
|
||||
field: 'inspectorNickname',
|
||||
title: '检测人员',
|
||||
width: 100,
|
||||
},
|
||||
{
|
||||
field: 'status',
|
||||
title: '单据状态',
|
||||
width: 100,
|
||||
cellRender: {
|
||||
name: 'CellDict',
|
||||
props: { type: DICT_TYPE.MES_ORDER_STATUS },
|
||||
},
|
||||
},
|
||||
{
|
||||
title: '操作',
|
||||
width: 180,
|
||||
fixed: 'right',
|
||||
slots: { default: 'actions' },
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
/** 过程检验单行子表的字段 */
|
||||
export function useLineGridColumns(): VxeTableGridOptions<MesQcIpqcLineApi.IpqcLine>['columns'] {
|
||||
return [
|
||||
{
|
||||
field: 'indicatorName',
|
||||
title: '检测项名称',
|
||||
minWidth: 150,
|
||||
},
|
||||
{
|
||||
field: 'indicatorType',
|
||||
title: '检测项类型',
|
||||
width: 120,
|
||||
cellRender: {
|
||||
name: 'CellDict',
|
||||
props: { type: DICT_TYPE.MES_INDICATOR_TYPE },
|
||||
},
|
||||
},
|
||||
{
|
||||
field: 'toolName',
|
||||
title: '检测工具',
|
||||
width: 120,
|
||||
},
|
||||
{
|
||||
field: 'checkMethod',
|
||||
title: '检测方法',
|
||||
minWidth: 180,
|
||||
},
|
||||
{
|
||||
field: 'standardValue',
|
||||
title: '标准值',
|
||||
width: 100,
|
||||
},
|
||||
{
|
||||
field: 'unitMeasureName',
|
||||
title: '单位',
|
||||
width: 80,
|
||||
},
|
||||
{
|
||||
field: 'maxThreshold',
|
||||
title: '误差上限',
|
||||
width: 100,
|
||||
},
|
||||
{
|
||||
field: 'minThreshold',
|
||||
title: '误差下限',
|
||||
width: 100,
|
||||
},
|
||||
{
|
||||
field: 'criticalQuantity',
|
||||
title: '致命缺陷数',
|
||||
width: 110,
|
||||
},
|
||||
{
|
||||
field: 'majorQuantity',
|
||||
title: '严重缺陷数',
|
||||
width: 110,
|
||||
},
|
||||
{
|
||||
field: 'minorQuantity',
|
||||
title: '轻微缺陷数',
|
||||
width: 110,
|
||||
},
|
||||
{
|
||||
title: '操作',
|
||||
width: 110,
|
||||
fixed: 'right',
|
||||
slots: { default: 'actions' },
|
||||
},
|
||||
];
|
||||
}
|
||||
|
|
@ -0,0 +1,168 @@
|
|||
<script lang="ts" setup>
|
||||
import type { VxeTableGridOptions } from '#/adapter/vxe-table';
|
||||
import type { MesQcIpqcApi } from '#/api/mes/qc/ipqc';
|
||||
|
||||
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 { deleteIpqc, exportIpqc, getIpqcPage } from '#/api/mes/qc/ipqc';
|
||||
import { $t } from '#/locales';
|
||||
import { MesQcStatusEnum } 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: MesQcIpqcApi.Ipqc) {
|
||||
formModalApi.setData({ formType: 'detail', id: row.id }).open();
|
||||
}
|
||||
|
||||
/** 编辑过程检验单 */
|
||||
function handleEdit(row: MesQcIpqcApi.Ipqc) {
|
||||
formModalApi.setData({ formType: 'update', id: row.id }).open();
|
||||
}
|
||||
|
||||
/** 删除过程检验单 */
|
||||
async function handleDelete(row: MesQcIpqcApi.Ipqc) {
|
||||
const loadingInstance = ElLoading.service({
|
||||
text: $t('ui.actionMessage.deleting', [row.code]),
|
||||
});
|
||||
try {
|
||||
await deleteIpqc(row.id!);
|
||||
ElMessage.success($t('ui.actionMessage.deleteSuccess', [row.code]));
|
||||
handleRefresh();
|
||||
} finally {
|
||||
loadingInstance.close();
|
||||
}
|
||||
}
|
||||
|
||||
/** 导出表格 */
|
||||
async function handleExport() {
|
||||
const data = await exportIpqc(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 getIpqcPage({
|
||||
pageNo: page.currentPage,
|
||||
pageSize: page.pageSize,
|
||||
...formValues,
|
||||
});
|
||||
},
|
||||
},
|
||||
},
|
||||
rowConfig: {
|
||||
keyField: 'id',
|
||||
isHover: true,
|
||||
},
|
||||
toolbarConfig: {
|
||||
refresh: true,
|
||||
search: true,
|
||||
},
|
||||
} as VxeTableGridOptions<MesQcIpqcApi.Ipqc>,
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Page auto-content-height>
|
||||
<template #doc>
|
||||
<DocAlert
|
||||
title="【质量】过程检验(IPQC)"
|
||||
url="https://doc.iocoder.cn/mes/qc/ipqc/"
|
||||
/>
|
||||
</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:qc-ipqc:create'],
|
||||
onClick: handleCreate,
|
||||
},
|
||||
{
|
||||
label: $t('ui.actionTitle.export'),
|
||||
type: 'primary',
|
||||
icon: ACTION_ICON.DOWNLOAD,
|
||||
auth: ['mes:qc-ipqc: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:qc-ipqc:update'],
|
||||
ifShow: row.status === MesQcStatusEnum.DRAFT,
|
||||
onClick: handleEdit.bind(null, row),
|
||||
},
|
||||
{
|
||||
label: $t('common.delete'),
|
||||
type: 'danger',
|
||||
link: true,
|
||||
icon: ACTION_ICON.DELETE,
|
||||
auth: ['mes:qc-ipqc:delete'],
|
||||
ifShow: row.status === MesQcStatusEnum.DRAFT,
|
||||
popConfirm: {
|
||||
title: $t('ui.actionMessage.deleteConfirm', [row.code]),
|
||||
confirm: handleDelete.bind(null, row),
|
||||
},
|
||||
},
|
||||
{
|
||||
label: $t('common.detail'),
|
||||
type: 'primary',
|
||||
link: true,
|
||||
icon: ACTION_ICON.VIEW,
|
||||
auth: ['mes:qc-ipqc:query'],
|
||||
onClick: handleDetail.bind(null, row),
|
||||
},
|
||||
]"
|
||||
/>
|
||||
</template>
|
||||
</Grid>
|
||||
</Page>
|
||||
</template>
|
||||
|
|
@ -0,0 +1,233 @@
|
|||
<script lang="ts" setup>
|
||||
import type { FormType } from '../data';
|
||||
|
||||
import type { MesQcIpqcApi } from '#/api/mes/qc/ipqc';
|
||||
|
||||
import { computed, ref } from 'vue';
|
||||
|
||||
import { confirm, useVbenModal } from '@vben/common-ui';
|
||||
|
||||
import {
|
||||
ElButton,
|
||||
ElDescriptions,
|
||||
ElDescriptionsItem,
|
||||
ElMessage,
|
||||
ElTabPane,
|
||||
ElTabs,
|
||||
} from 'element-plus';
|
||||
|
||||
import { useVbenForm } from '#/adapter/form';
|
||||
import {
|
||||
createIpqc,
|
||||
finishIpqc,
|
||||
getIpqc,
|
||||
updateIpqc,
|
||||
} from '#/api/mes/qc/ipqc';
|
||||
import { $t } from '#/locales';
|
||||
import { MesQcStatusEnum, MesQcTypeEnum } from '#/views/mes/utils/constants';
|
||||
|
||||
import { QcIndicatorResultList } from '../../indicatorresult/components';
|
||||
import { useFormSchema } from '../data';
|
||||
import LineList from './line-list.vue';
|
||||
|
||||
const emit = defineEmits(['success']);
|
||||
const formType = ref<FormType>('create');
|
||||
const formData = ref<MesQcIpqcApi.Ipqc>();
|
||||
const subTabsName = ref('line');
|
||||
const originalSnapshot = ref('');
|
||||
const isDetail = computed(() => formType.value === 'detail');
|
||||
const canFinish = computed(
|
||||
() =>
|
||||
formType.value === 'update' &&
|
||||
formData.value?.status === MesQcStatusEnum.DRAFT,
|
||||
);
|
||||
const getTitle = computed(() => {
|
||||
if (formType.value === 'detail') {
|
||||
return $t('ui.actionTitle.view', ['过程检验单']);
|
||||
}
|
||||
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,
|
||||
},
|
||||
wrapperClass: 'grid-cols-3',
|
||||
layout: 'horizontal',
|
||||
schema: [],
|
||||
showDefaultActions: false,
|
||||
});
|
||||
|
||||
/** 子表变更后刷新主表头数据(缺陷统计等) */
|
||||
async function handleRefresh() {
|
||||
if (!formData.value?.id) {
|
||||
return;
|
||||
}
|
||||
formData.value = await getIpqc(formData.value.id);
|
||||
}
|
||||
|
||||
/** 提交表单 */
|
||||
async function handleSubmit(): Promise<boolean> {
|
||||
const { valid } = await formApi.validate();
|
||||
if (!valid) {
|
||||
return false;
|
||||
}
|
||||
const data = (await formApi.getValues()) as MesQcIpqcApi.Ipqc;
|
||||
if (formData.value?.id) {
|
||||
await updateIpqc({ ...data, id: formData.value.id });
|
||||
formData.value = { ...formData.value, ...data };
|
||||
} else {
|
||||
const id = await createIpqc(data);
|
||||
formData.value = {
|
||||
...data,
|
||||
id: id as unknown as number,
|
||||
status: MesQcStatusEnum.DRAFT,
|
||||
};
|
||||
await formApi.setFieldValue('id', formData.value.id);
|
||||
await formApi.setFieldValue('status', formData.value.status);
|
||||
formType.value = 'update';
|
||||
}
|
||||
originalSnapshot.value = JSON.stringify(await formApi.getValues());
|
||||
return true;
|
||||
}
|
||||
|
||||
/** 完成检验单:表单有修改时先保存,再调用完成接口 */
|
||||
async function handleFinish() {
|
||||
const id = formData.value?.id;
|
||||
if (!id) {
|
||||
return;
|
||||
}
|
||||
const { valid } = await formApi.validate();
|
||||
if (!valid) {
|
||||
return;
|
||||
}
|
||||
await confirm({
|
||||
content: '是否完成过程检验单编制?【完成后将不能更改】',
|
||||
});
|
||||
modalApi.lock();
|
||||
try {
|
||||
const current = JSON.stringify(await formApi.getValues());
|
||||
if (current !== originalSnapshot.value) {
|
||||
const data = (await formApi.getValues()) as MesQcIpqcApi.Ipqc;
|
||||
await updateIpqc({ ...data, id });
|
||||
formData.value = { ...formData.value, ...data };
|
||||
originalSnapshot.value = current;
|
||||
}
|
||||
await finishIpqc(id);
|
||||
ElMessage.success('完成成功');
|
||||
await modalApi.close();
|
||||
emit('success');
|
||||
} finally {
|
||||
modalApi.unlock();
|
||||
}
|
||||
}
|
||||
|
||||
const [Modal, modalApi] = useVbenModal({
|
||||
async onConfirm() {
|
||||
if (isDetail.value) {
|
||||
await modalApi.close();
|
||||
return;
|
||||
}
|
||||
modalApi.lock();
|
||||
try {
|
||||
const ok = await handleSubmit();
|
||||
if (!ok) {
|
||||
return;
|
||||
}
|
||||
ElMessage.success($t('ui.actionMessage.operationSuccess'));
|
||||
await modalApi.close();
|
||||
emit('success');
|
||||
} finally {
|
||||
modalApi.unlock();
|
||||
}
|
||||
},
|
||||
async onOpenChange(isOpen: boolean) {
|
||||
if (!isOpen) {
|
||||
formData.value = undefined;
|
||||
originalSnapshot.value = '';
|
||||
return;
|
||||
}
|
||||
formApi.setState({ schema: useFormSchema(formApi) });
|
||||
subTabsName.value = 'line';
|
||||
const data = modalApi.getData<{
|
||||
formType: FormType;
|
||||
id?: number;
|
||||
prefill?: MesQcIpqcApi.Ipqc;
|
||||
}>();
|
||||
formType.value = data.formType;
|
||||
formApi.setDisabled(formType.value === 'detail');
|
||||
modalApi.setState({ showConfirmButton: formType.value !== 'detail' });
|
||||
if (data?.id) {
|
||||
modalApi.lock();
|
||||
try {
|
||||
formData.value = await getIpqc(data.id);
|
||||
await formApi.setValues(formData.value);
|
||||
} finally {
|
||||
modalApi.unlock();
|
||||
}
|
||||
} else if (data?.prefill) {
|
||||
formData.value = { ...data.prefill };
|
||||
await formApi.setValues(data.prefill);
|
||||
}
|
||||
originalSnapshot.value = JSON.stringify(await formApi.getValues());
|
||||
},
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Modal :title="getTitle" class="w-4/5">
|
||||
<Form class="mx-4" />
|
||||
<!-- 缺陷统计(只读) -->
|
||||
<div v-if="formData?.id" class="mx-4 mt-4">
|
||||
<ElDescriptions title="缺陷情况" :column="3" border size="small">
|
||||
<ElDescriptionsItem label="致命缺陷数">
|
||||
{{ formData.criticalQuantity ?? 0 }}
|
||||
</ElDescriptionsItem>
|
||||
<ElDescriptionsItem label="严重缺陷数">
|
||||
{{ formData.majorQuantity ?? 0 }}
|
||||
</ElDescriptionsItem>
|
||||
<ElDescriptionsItem label="轻微缺陷数">
|
||||
{{ formData.minorQuantity ?? 0 }}
|
||||
</ElDescriptionsItem>
|
||||
<ElDescriptionsItem label="致命缺陷率">
|
||||
{{ formData.criticalRate ?? 0 }}%
|
||||
</ElDescriptionsItem>
|
||||
<ElDescriptionsItem label="严重缺陷率">
|
||||
{{ formData.majorRate ?? 0 }}%
|
||||
</ElDescriptionsItem>
|
||||
<ElDescriptionsItem label="轻微缺陷率">
|
||||
{{ formData.minorRate ?? 0 }}%
|
||||
</ElDescriptionsItem>
|
||||
</ElDescriptions>
|
||||
</div>
|
||||
<ElTabs v-if="formData?.id" v-model="subTabsName" class="mx-4 mt-4">
|
||||
<ElTabPane label="检验项" name="line">
|
||||
<LineList
|
||||
:form-type="formType"
|
||||
:ipqc-id="formData.id"
|
||||
@refresh="handleRefresh"
|
||||
/>
|
||||
</ElTabPane>
|
||||
<ElTabPane label="检测结果" name="result">
|
||||
<QcIndicatorResultList
|
||||
:qc-id="formData.id"
|
||||
:qc-type="MesQcTypeEnum.IPQC"
|
||||
:readonly="isDetail"
|
||||
/>
|
||||
</ElTabPane>
|
||||
</ElTabs>
|
||||
<template #prepend-footer>
|
||||
<div class="flex flex-auto items-center gap-2">
|
||||
<ElButton v-if="canFinish" type="primary" @click="handleFinish">
|
||||
完成
|
||||
</ElButton>
|
||||
</div>
|
||||
</template>
|
||||
</Modal>
|
||||
</template>
|
||||
|
|
@ -0,0 +1,98 @@
|
|||
<script lang="ts" setup>
|
||||
import type { VxeTableGridOptions } from '#/adapter/vxe-table';
|
||||
import type { MesQcIpqcLineApi } from '#/api/mes/qc/ipqc/line';
|
||||
|
||||
import { useVbenModal } from '@vben/common-ui';
|
||||
|
||||
import { ACTION_ICON, TableAction, useVbenVxeGrid } from '#/adapter/vxe-table';
|
||||
import { getIpqcLinePage } from '#/api/mes/qc/ipqc/line';
|
||||
import { MesQcTypeEnum } from '#/views/mes/utils/constants';
|
||||
|
||||
import { DefectRecordInlineList } from '../../defectrecord/components';
|
||||
import { useLineGridColumns } from '../data';
|
||||
|
||||
const props = defineProps<{
|
||||
formType?: string;
|
||||
ipqcId: number;
|
||||
}>();
|
||||
|
||||
const emit = defineEmits<{ refresh: [] }>();
|
||||
|
||||
const [DefectModal, defectModalApi] = useVbenModal({
|
||||
connectedComponent: DefectRecordInlineList,
|
||||
destroyOnClose: true,
|
||||
});
|
||||
|
||||
/** 刷新表格 */
|
||||
function handleRefresh() {
|
||||
gridApi.query();
|
||||
}
|
||||
|
||||
/** 缺陷记录变更后,刷新本表格并通知父组件刷新主表统计 */
|
||||
function handleDefectChanged() {
|
||||
handleRefresh();
|
||||
emit('refresh');
|
||||
}
|
||||
|
||||
/** 打开缺陷记录弹窗 */
|
||||
function handleOpenDefect(row: MesQcIpqcLineApi.IpqcLine) {
|
||||
defectModalApi
|
||||
.setData({
|
||||
formType: props.formType,
|
||||
lineId: row.id,
|
||||
qcId: props.ipqcId,
|
||||
qcType: MesQcTypeEnum.IPQC,
|
||||
})
|
||||
.open();
|
||||
}
|
||||
|
||||
const [Grid, gridApi] = useVbenVxeGrid({
|
||||
gridOptions: {
|
||||
columns: useLineGridColumns(),
|
||||
height: 360,
|
||||
keepSource: true,
|
||||
proxyConfig: {
|
||||
ajax: {
|
||||
query: async ({ page }) => {
|
||||
if (!props.ipqcId) {
|
||||
return { list: [], total: 0 };
|
||||
}
|
||||
return await getIpqcLinePage({
|
||||
ipqcId: props.ipqcId,
|
||||
pageNo: page.currentPage,
|
||||
pageSize: page.pageSize,
|
||||
});
|
||||
},
|
||||
},
|
||||
},
|
||||
rowConfig: {
|
||||
keyField: 'id',
|
||||
isHover: true,
|
||||
},
|
||||
toolbarConfig: {
|
||||
refresh: true,
|
||||
},
|
||||
} as VxeTableGridOptions<MesQcIpqcLineApi.IpqcLine>,
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div>
|
||||
<DefectModal @success="handleDefectChanged" />
|
||||
<Grid table-title="检验项">
|
||||
<template #actions="{ row }">
|
||||
<TableAction
|
||||
:actions="[
|
||||
{
|
||||
label: '缺陷列表',
|
||||
type: 'primary',
|
||||
link: true,
|
||||
icon: ACTION_ICON.VIEW,
|
||||
onClick: handleOpenDefect.bind(null, row),
|
||||
},
|
||||
]"
|
||||
/>
|
||||
</template>
|
||||
</Grid>
|
||||
</div>
|
||||
</template>
|
||||
|
|
@ -0,0 +1,524 @@
|
|||
import type { VbenFormApi, VbenFormSchema } from '#/adapter/form';
|
||||
import type { VxeTableGridOptions } from '#/adapter/vxe-table';
|
||||
import type { MesQcOqcApi } from '#/api/mes/qc/oqc';
|
||||
import type { MesQcOqcLineApi } from '#/api/mes/qc/oqc/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 { getSimpleUserList } from '#/api/system/user';
|
||||
import MdClientSelect from '#/views/mes/md/client/components/md-client-select.vue';
|
||||
import MdItemSelect from '#/views/mes/md/item/components/md-item-select.vue';
|
||||
import { MesAutoCodeRuleCode } from '#/views/mes/utils/constants';
|
||||
|
||||
/** 表单类型 */
|
||||
export type FormType = 'create' | 'detail' | 'update';
|
||||
|
||||
/** 新增/修改的表单 */
|
||||
export function useFormSchema(formApi?: VbenFormApi): VbenFormSchema[] {
|
||||
return [
|
||||
{
|
||||
fieldName: 'id',
|
||||
component: 'Input',
|
||||
dependencies: {
|
||||
triggerFields: [''],
|
||||
show: () => false,
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldName: 'sourceDocId',
|
||||
component: 'Input',
|
||||
dependencies: {
|
||||
triggerFields: [''],
|
||||
show: () => false,
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldName: 'sourceLineId',
|
||||
component: 'Input',
|
||||
dependencies: {
|
||||
triggerFields: [''],
|
||||
show: () => false,
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldName: 'status',
|
||||
component: 'Input',
|
||||
dependencies: {
|
||||
triggerFields: [''],
|
||||
show: () => false,
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldName: 'code',
|
||||
label: '检验单编号',
|
||||
component: 'Input',
|
||||
componentProps: {
|
||||
placeholder: '请输入检验单编号',
|
||||
},
|
||||
rules: 'required',
|
||||
suffix: () =>
|
||||
h(
|
||||
ElButton,
|
||||
{
|
||||
onClick: async () => {
|
||||
try {
|
||||
const code = await generateAutoCode(
|
||||
MesAutoCodeRuleCode.QC_OQC_CODE,
|
||||
);
|
||||
await formApi?.setFieldValue('code', code);
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
}
|
||||
},
|
||||
},
|
||||
{ default: () => '生成' },
|
||||
),
|
||||
},
|
||||
{
|
||||
fieldName: 'name',
|
||||
label: '检验单名称',
|
||||
component: 'Input',
|
||||
componentProps: {
|
||||
placeholder: '请输入检验单名称',
|
||||
},
|
||||
rules: 'required',
|
||||
},
|
||||
{
|
||||
fieldName: 'sourceDocType',
|
||||
label: '来源单据类型',
|
||||
component: 'Select',
|
||||
componentProps: {
|
||||
disabled: true,
|
||||
options: getDictOptions(DICT_TYPE.MES_QC_SOURCE_DOC_TYPE, 'number'),
|
||||
placeholder: '来源单据类型',
|
||||
},
|
||||
dependencies: {
|
||||
triggerFields: ['sourceDocType'],
|
||||
show: (values) => !!values.sourceDocType,
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldName: 'sourceDocCode',
|
||||
label: '来源单据编号',
|
||||
component: 'Input',
|
||||
componentProps: {
|
||||
disabled: true,
|
||||
placeholder: '来源单据编号',
|
||||
},
|
||||
dependencies: {
|
||||
triggerFields: ['sourceDocType', 'sourceDocId'],
|
||||
show: (values) => !!values.sourceDocType && !!values.sourceDocId,
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldName: 'itemId',
|
||||
label: '产品物料',
|
||||
component: markRaw(MdItemSelect),
|
||||
componentProps: {
|
||||
placeholder: '请选择产品物料',
|
||||
},
|
||||
rules: 'selectRequired',
|
||||
dependencies: {
|
||||
triggerFields: ['sourceDocId'],
|
||||
componentProps: (values) => ({
|
||||
disabled: !!values.sourceDocId,
|
||||
placeholder: '请选择产品物料',
|
||||
}),
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldName: 'clientId',
|
||||
label: '客户',
|
||||
component: markRaw(MdClientSelect),
|
||||
componentProps: {
|
||||
placeholder: '请选择客户',
|
||||
},
|
||||
rules: 'selectRequired',
|
||||
dependencies: {
|
||||
triggerFields: ['sourceDocId'],
|
||||
componentProps: (values) => ({
|
||||
disabled: !!values.sourceDocId,
|
||||
placeholder: '请选择客户',
|
||||
}),
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldName: 'batchCode',
|
||||
label: '批次号',
|
||||
component: 'Input',
|
||||
componentProps: {
|
||||
placeholder: '请输入批次号',
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldName: 'outQuantity',
|
||||
label: '发货数量',
|
||||
component: 'InputNumber',
|
||||
componentProps: {
|
||||
class: '!w-full',
|
||||
controlsPosition: 'right',
|
||||
min: 0,
|
||||
placeholder: '请输入发货数量',
|
||||
precision: 2,
|
||||
// 新建态下,发货数量变化时把 checkQuantity 也填上同值
|
||||
onChange: async (value: null | number | undefined) => {
|
||||
if (value == null || !formApi) return;
|
||||
const values = await formApi.getValues();
|
||||
if (!values.id && values.checkQuantity == null) {
|
||||
await formApi.setFieldValue('checkQuantity', value);
|
||||
}
|
||||
},
|
||||
},
|
||||
rules: 'required',
|
||||
dependencies: {
|
||||
triggerFields: ['sourceDocId'],
|
||||
componentProps: (values) => ({
|
||||
class: '!w-full',
|
||||
controlsPosition: 'right',
|
||||
disabled: !!values.sourceDocId,
|
||||
min: 0,
|
||||
placeholder: '请输入发货数量',
|
||||
precision: 2,
|
||||
onChange: async (value: null | number | undefined) => {
|
||||
if (value == null || !formApi) return;
|
||||
const current = await formApi.getValues();
|
||||
if (!current.id && current.checkQuantity == null) {
|
||||
await formApi.setFieldValue('checkQuantity', value);
|
||||
}
|
||||
},
|
||||
}),
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldName: 'checkQuantity',
|
||||
label: '检测数量',
|
||||
component: 'InputNumber',
|
||||
componentProps: {
|
||||
class: '!w-full',
|
||||
controlsPosition: 'right',
|
||||
min: 0,
|
||||
placeholder: '请输入检测数量',
|
||||
// 新建态下,检测数量变化时把 outQuantity 也填上同值
|
||||
onChange: async (value: null | number | undefined) => {
|
||||
if (value == null || !formApi) return;
|
||||
const values = await formApi.getValues();
|
||||
if (!values.id && values.outQuantity == null) {
|
||||
await formApi.setFieldValue('outQuantity', value);
|
||||
}
|
||||
},
|
||||
},
|
||||
rules: 'required',
|
||||
},
|
||||
{
|
||||
fieldName: 'qualifiedQuantity',
|
||||
label: '合格品数量',
|
||||
component: 'InputNumber',
|
||||
componentProps: {
|
||||
class: '!w-full',
|
||||
controlsPosition: 'right',
|
||||
min: 0,
|
||||
placeholder: '请输入合格品数量',
|
||||
},
|
||||
rules: 'required',
|
||||
},
|
||||
{
|
||||
fieldName: 'unqualifiedQuantity',
|
||||
label: '不合格品数量',
|
||||
component: 'InputNumber',
|
||||
componentProps: {
|
||||
class: '!w-full',
|
||||
controlsPosition: 'right',
|
||||
min: 0,
|
||||
placeholder: '请输入不合格品数量',
|
||||
},
|
||||
rules: 'required',
|
||||
},
|
||||
{
|
||||
fieldName: 'inspectorUserId',
|
||||
label: '检测人员',
|
||||
component: 'ApiSelect',
|
||||
componentProps: {
|
||||
api: getSimpleUserList,
|
||||
clearable: true,
|
||||
labelField: 'nickname',
|
||||
placeholder: '请选择检测人员',
|
||||
valueField: 'id',
|
||||
},
|
||||
rules: 'selectRequired',
|
||||
},
|
||||
{
|
||||
fieldName: 'outDate',
|
||||
label: '出货日期',
|
||||
component: 'DatePicker',
|
||||
componentProps: {
|
||||
format: 'YYYY-MM-DD',
|
||||
placeholder: '请选择出货日期',
|
||||
type: 'date',
|
||||
valueFormat: 'x',
|
||||
},
|
||||
rules: 'required',
|
||||
},
|
||||
{
|
||||
fieldName: 'inspectDate',
|
||||
label: '检测日期',
|
||||
component: 'DatePicker',
|
||||
componentProps: {
|
||||
format: 'YYYY-MM-DD',
|
||||
placeholder: '请选择检测日期',
|
||||
type: 'date',
|
||||
valueFormat: 'x',
|
||||
},
|
||||
rules: 'required',
|
||||
},
|
||||
{
|
||||
fieldName: 'checkResult',
|
||||
label: '检测结果',
|
||||
component: 'Select',
|
||||
componentProps: {
|
||||
clearable: true,
|
||||
options: getDictOptions(DICT_TYPE.MES_QC_CHECK_RESULT, 'number'),
|
||||
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: 'clientId',
|
||||
label: '客户',
|
||||
component: markRaw(MdClientSelect),
|
||||
componentProps: {
|
||||
placeholder: '请选择客户',
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldName: 'batchCode',
|
||||
label: '批次号',
|
||||
component: 'Input',
|
||||
componentProps: {
|
||||
clearable: true,
|
||||
placeholder: '请输入批次号',
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldName: 'itemId',
|
||||
label: '产品物料',
|
||||
component: markRaw(MdItemSelect),
|
||||
componentProps: {
|
||||
placeholder: '请选择产品物料',
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldName: 'checkResult',
|
||||
label: '检测结果',
|
||||
component: 'Select',
|
||||
componentProps: {
|
||||
clearable: true,
|
||||
options: getDictOptions(DICT_TYPE.MES_QC_CHECK_RESULT, 'number'),
|
||||
placeholder: '请选择检测结果',
|
||||
},
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
/** 列表的字段 */
|
||||
export function useGridColumns(): VxeTableGridOptions<MesQcOqcApi.Oqc>['columns'] {
|
||||
return [
|
||||
{
|
||||
field: 'code',
|
||||
title: '检验单编号',
|
||||
width: 160,
|
||||
slots: { default: 'code' },
|
||||
},
|
||||
{
|
||||
field: 'name',
|
||||
title: '检验单名称',
|
||||
minWidth: 180,
|
||||
},
|
||||
{
|
||||
field: 'clientNickname',
|
||||
title: '客户名称',
|
||||
width: 120,
|
||||
},
|
||||
{
|
||||
field: 'batchCode',
|
||||
title: '批次号',
|
||||
width: 130,
|
||||
},
|
||||
{
|
||||
field: 'itemCode',
|
||||
title: '产品物料编码',
|
||||
width: 130,
|
||||
},
|
||||
{
|
||||
field: 'itemName',
|
||||
title: '产品物料名称',
|
||||
minWidth: 150,
|
||||
},
|
||||
{
|
||||
field: 'itemSpecification',
|
||||
title: '规格型号',
|
||||
minWidth: 150,
|
||||
},
|
||||
{
|
||||
field: 'unitName',
|
||||
title: '单位',
|
||||
width: 80,
|
||||
},
|
||||
{
|
||||
field: 'outQuantity',
|
||||
title: '发货数量',
|
||||
width: 100,
|
||||
},
|
||||
{
|
||||
field: 'checkQuantity',
|
||||
title: '检测数量',
|
||||
width: 100,
|
||||
},
|
||||
{
|
||||
field: 'unqualifiedQuantity',
|
||||
title: '不合格数',
|
||||
width: 100,
|
||||
},
|
||||
{
|
||||
field: 'checkResult',
|
||||
title: '检测结果',
|
||||
width: 110,
|
||||
cellRender: {
|
||||
name: 'CellDict',
|
||||
props: { type: DICT_TYPE.MES_QC_CHECK_RESULT },
|
||||
},
|
||||
},
|
||||
{
|
||||
field: 'outDate',
|
||||
title: '出货日期',
|
||||
width: 120,
|
||||
formatter: 'formatDate',
|
||||
},
|
||||
{
|
||||
field: 'inspectDate',
|
||||
title: '检测日期',
|
||||
width: 120,
|
||||
formatter: 'formatDate',
|
||||
},
|
||||
{
|
||||
field: 'inspectorNickname',
|
||||
title: '检测人员',
|
||||
width: 100,
|
||||
},
|
||||
{
|
||||
field: 'status',
|
||||
title: '单据状态',
|
||||
width: 100,
|
||||
cellRender: {
|
||||
name: 'CellDict',
|
||||
props: { type: DICT_TYPE.MES_ORDER_STATUS },
|
||||
},
|
||||
},
|
||||
{
|
||||
title: '操作',
|
||||
width: 220,
|
||||
fixed: 'right',
|
||||
slots: { default: 'actions' },
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
/** 出货检验单行子表的字段 */
|
||||
export function useLineGridColumns(): VxeTableGridOptions<MesQcOqcLineApi.OqcLine>['columns'] {
|
||||
return [
|
||||
{
|
||||
field: 'indicatorName',
|
||||
title: '检测项名称',
|
||||
minWidth: 150,
|
||||
},
|
||||
{
|
||||
field: 'indicatorType',
|
||||
title: '检测项类型',
|
||||
width: 120,
|
||||
cellRender: {
|
||||
name: 'CellDict',
|
||||
props: { type: DICT_TYPE.MES_INDICATOR_TYPE },
|
||||
},
|
||||
},
|
||||
{
|
||||
field: 'tool',
|
||||
title: '检测工具',
|
||||
width: 120,
|
||||
},
|
||||
{
|
||||
field: 'checkMethod',
|
||||
title: '检测方法',
|
||||
minWidth: 180,
|
||||
},
|
||||
{
|
||||
field: 'standardValue',
|
||||
title: '标准值',
|
||||
width: 100,
|
||||
},
|
||||
{
|
||||
field: 'unitMeasureName',
|
||||
title: '单位',
|
||||
width: 80,
|
||||
},
|
||||
{
|
||||
field: 'maxThreshold',
|
||||
title: '误差上限',
|
||||
width: 100,
|
||||
},
|
||||
{
|
||||
field: 'minThreshold',
|
||||
title: '误差下限',
|
||||
width: 100,
|
||||
},
|
||||
{
|
||||
field: 'criticalQuantity',
|
||||
title: '致命缺陷数',
|
||||
width: 110,
|
||||
},
|
||||
{
|
||||
field: 'majorQuantity',
|
||||
title: '严重缺陷数',
|
||||
width: 110,
|
||||
},
|
||||
{
|
||||
field: 'minorQuantity',
|
||||
title: '轻微缺陷数',
|
||||
width: 110,
|
||||
},
|
||||
{
|
||||
title: '操作',
|
||||
width: 110,
|
||||
fixed: 'right',
|
||||
slots: { default: 'actions' },
|
||||
},
|
||||
];
|
||||
}
|
||||
|
|
@ -0,0 +1,168 @@
|
|||
<script lang="ts" setup>
|
||||
import type { VxeTableGridOptions } from '#/adapter/vxe-table';
|
||||
import type { MesQcOqcApi } from '#/api/mes/qc/oqc';
|
||||
|
||||
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 { deleteOqc, exportOqc, getOqcPage } from '#/api/mes/qc/oqc';
|
||||
import { $t } from '#/locales';
|
||||
import { MesQcStatusEnum } 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: MesQcOqcApi.Oqc) {
|
||||
formModalApi.setData({ formType: 'detail', id: row.id }).open();
|
||||
}
|
||||
|
||||
/** 编辑出货检验单 */
|
||||
function handleEdit(row: MesQcOqcApi.Oqc) {
|
||||
formModalApi.setData({ formType: 'update', id: row.id }).open();
|
||||
}
|
||||
|
||||
/** 删除出货检验单 */
|
||||
async function handleDelete(row: MesQcOqcApi.Oqc) {
|
||||
const loadingInstance = ElLoading.service({
|
||||
text: $t('ui.actionMessage.deleting', [row.code]),
|
||||
});
|
||||
try {
|
||||
await deleteOqc(row.id!);
|
||||
ElMessage.success($t('ui.actionMessage.deleteSuccess', [row.code]));
|
||||
handleRefresh();
|
||||
} finally {
|
||||
loadingInstance.close();
|
||||
}
|
||||
}
|
||||
|
||||
/** 导出表格 */
|
||||
async function handleExport() {
|
||||
const data = await exportOqc(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 getOqcPage({
|
||||
pageNo: page.currentPage,
|
||||
pageSize: page.pageSize,
|
||||
...formValues,
|
||||
});
|
||||
},
|
||||
},
|
||||
},
|
||||
rowConfig: {
|
||||
keyField: 'id',
|
||||
isHover: true,
|
||||
},
|
||||
toolbarConfig: {
|
||||
refresh: true,
|
||||
search: true,
|
||||
},
|
||||
} as VxeTableGridOptions<MesQcOqcApi.Oqc>,
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Page auto-content-height>
|
||||
<template #doc>
|
||||
<DocAlert
|
||||
title="【质量】出货检验(OQC)"
|
||||
url="https://doc.iocoder.cn/mes/qc/oqc/"
|
||||
/>
|
||||
</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:qc-oqc:create'],
|
||||
onClick: handleCreate,
|
||||
},
|
||||
{
|
||||
label: $t('ui.actionTitle.export'),
|
||||
type: 'primary',
|
||||
icon: ACTION_ICON.DOWNLOAD,
|
||||
auth: ['mes:qc-oqc: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:qc-oqc:update'],
|
||||
ifShow: row.status === MesQcStatusEnum.DRAFT,
|
||||
onClick: handleEdit.bind(null, row),
|
||||
},
|
||||
{
|
||||
label: $t('common.delete'),
|
||||
type: 'danger',
|
||||
link: true,
|
||||
icon: ACTION_ICON.DELETE,
|
||||
auth: ['mes:qc-oqc:delete'],
|
||||
ifShow: row.status === MesQcStatusEnum.DRAFT,
|
||||
popConfirm: {
|
||||
title: $t('ui.actionMessage.deleteConfirm', [row.code]),
|
||||
confirm: handleDelete.bind(null, row),
|
||||
},
|
||||
},
|
||||
{
|
||||
label: $t('common.detail'),
|
||||
type: 'primary',
|
||||
link: true,
|
||||
icon: ACTION_ICON.VIEW,
|
||||
auth: ['mes:qc-oqc:query'],
|
||||
onClick: handleDetail.bind(null, row),
|
||||
},
|
||||
]"
|
||||
/>
|
||||
</template>
|
||||
</Grid>
|
||||
</Page>
|
||||
</template>
|
||||
|
|
@ -0,0 +1,233 @@
|
|||
<script lang="ts" setup>
|
||||
import type { FormType } from '../data';
|
||||
|
||||
import type { MesQcOqcApi } from '#/api/mes/qc/oqc';
|
||||
|
||||
import { computed, ref } from 'vue';
|
||||
|
||||
import { confirm, useVbenModal } from '@vben/common-ui';
|
||||
|
||||
import {
|
||||
ElButton,
|
||||
ElDescriptions,
|
||||
ElDescriptionsItem,
|
||||
ElMessage,
|
||||
ElTabPane,
|
||||
ElTabs,
|
||||
} from 'element-plus';
|
||||
|
||||
import { useVbenForm } from '#/adapter/form';
|
||||
import {
|
||||
createOqc,
|
||||
finishOqc,
|
||||
getOqc,
|
||||
updateOqc,
|
||||
} from '#/api/mes/qc/oqc';
|
||||
import { $t } from '#/locales';
|
||||
import { MesQcStatusEnum, MesQcTypeEnum } from '#/views/mes/utils/constants';
|
||||
|
||||
import { QcIndicatorResultList } from '../../indicatorresult/components';
|
||||
import { useFormSchema } from '../data';
|
||||
import LineList from './line-list.vue';
|
||||
|
||||
const emit = defineEmits(['success']);
|
||||
const formType = ref<FormType>('create');
|
||||
const formData = ref<MesQcOqcApi.Oqc>();
|
||||
const subTabsName = ref('line');
|
||||
const originalSnapshot = ref('');
|
||||
const isDetail = computed(() => formType.value === 'detail');
|
||||
const canFinish = computed(
|
||||
() =>
|
||||
formType.value === 'update' &&
|
||||
formData.value?.status === MesQcStatusEnum.DRAFT,
|
||||
);
|
||||
const getTitle = computed(() => {
|
||||
if (formType.value === 'detail') {
|
||||
return $t('ui.actionTitle.view', ['出货检验单']);
|
||||
}
|
||||
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,
|
||||
},
|
||||
wrapperClass: 'grid-cols-3',
|
||||
layout: 'horizontal',
|
||||
schema: [],
|
||||
showDefaultActions: false,
|
||||
});
|
||||
|
||||
/** 子表变更后刷新主表头数据(缺陷统计等) */
|
||||
async function handleRefresh() {
|
||||
if (!formData.value?.id) {
|
||||
return;
|
||||
}
|
||||
formData.value = await getOqc(formData.value.id);
|
||||
}
|
||||
|
||||
/** 提交表单 */
|
||||
async function handleSubmit(): Promise<boolean> {
|
||||
const { valid } = await formApi.validate();
|
||||
if (!valid) {
|
||||
return false;
|
||||
}
|
||||
const data = (await formApi.getValues()) as MesQcOqcApi.Oqc;
|
||||
if (formData.value?.id) {
|
||||
await updateOqc({ ...data, id: formData.value.id });
|
||||
formData.value = { ...formData.value, ...data };
|
||||
} else {
|
||||
const id = await createOqc(data);
|
||||
formData.value = {
|
||||
...data,
|
||||
id: id as unknown as number,
|
||||
status: MesQcStatusEnum.DRAFT,
|
||||
};
|
||||
await formApi.setFieldValue('id', formData.value.id);
|
||||
await formApi.setFieldValue('status', formData.value.status);
|
||||
formType.value = 'update';
|
||||
}
|
||||
originalSnapshot.value = JSON.stringify(await formApi.getValues());
|
||||
return true;
|
||||
}
|
||||
|
||||
/** 完成检验单:表单有修改时先保存,再调用完成接口 */
|
||||
async function handleFinish() {
|
||||
const id = formData.value?.id;
|
||||
if (!id) {
|
||||
return;
|
||||
}
|
||||
const { valid } = await formApi.validate();
|
||||
if (!valid) {
|
||||
return;
|
||||
}
|
||||
await confirm({
|
||||
content: '是否完成出货检验单编制?【完成后将不能更改】',
|
||||
});
|
||||
modalApi.lock();
|
||||
try {
|
||||
const current = JSON.stringify(await formApi.getValues());
|
||||
if (current !== originalSnapshot.value) {
|
||||
const data = (await formApi.getValues()) as MesQcOqcApi.Oqc;
|
||||
await updateOqc({ ...data, id });
|
||||
formData.value = { ...formData.value, ...data };
|
||||
originalSnapshot.value = current;
|
||||
}
|
||||
await finishOqc(id);
|
||||
ElMessage.success('完成成功');
|
||||
await modalApi.close();
|
||||
emit('success');
|
||||
} finally {
|
||||
modalApi.unlock();
|
||||
}
|
||||
}
|
||||
|
||||
const [Modal, modalApi] = useVbenModal({
|
||||
async onConfirm() {
|
||||
if (isDetail.value) {
|
||||
await modalApi.close();
|
||||
return;
|
||||
}
|
||||
modalApi.lock();
|
||||
try {
|
||||
const ok = await handleSubmit();
|
||||
if (!ok) {
|
||||
return;
|
||||
}
|
||||
ElMessage.success($t('ui.actionMessage.operationSuccess'));
|
||||
await modalApi.close();
|
||||
emit('success');
|
||||
} finally {
|
||||
modalApi.unlock();
|
||||
}
|
||||
},
|
||||
async onOpenChange(isOpen: boolean) {
|
||||
if (!isOpen) {
|
||||
formData.value = undefined;
|
||||
originalSnapshot.value = '';
|
||||
return;
|
||||
}
|
||||
formApi.setState({ schema: useFormSchema(formApi) });
|
||||
subTabsName.value = 'line';
|
||||
const data = modalApi.getData<{
|
||||
formType: FormType;
|
||||
id?: number;
|
||||
prefill?: MesQcOqcApi.Oqc;
|
||||
}>();
|
||||
formType.value = data.formType;
|
||||
formApi.setDisabled(formType.value === 'detail');
|
||||
modalApi.setState({ showConfirmButton: formType.value !== 'detail' });
|
||||
if (data?.id) {
|
||||
modalApi.lock();
|
||||
try {
|
||||
formData.value = await getOqc(data.id);
|
||||
await formApi.setValues(formData.value);
|
||||
} finally {
|
||||
modalApi.unlock();
|
||||
}
|
||||
} else if (data?.prefill) {
|
||||
formData.value = { ...data.prefill };
|
||||
await formApi.setValues(data.prefill);
|
||||
}
|
||||
originalSnapshot.value = JSON.stringify(await formApi.getValues());
|
||||
},
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Modal :title="getTitle" class="w-4/5">
|
||||
<Form class="mx-4" />
|
||||
<!-- 缺陷统计(只读) -->
|
||||
<div v-if="formData?.id" class="mx-4 mt-4">
|
||||
<ElDescriptions title="缺陷情况" :column="3" border size="small">
|
||||
<ElDescriptionsItem label="致命缺陷数">
|
||||
{{ formData.criticalQuantity ?? 0 }}
|
||||
</ElDescriptionsItem>
|
||||
<ElDescriptionsItem label="严重缺陷数">
|
||||
{{ formData.majorQuantity ?? 0 }}
|
||||
</ElDescriptionsItem>
|
||||
<ElDescriptionsItem label="轻微缺陷数">
|
||||
{{ formData.minorQuantity ?? 0 }}
|
||||
</ElDescriptionsItem>
|
||||
<ElDescriptionsItem label="致命缺陷率">
|
||||
{{ formData.criticalRate ?? 0 }}%
|
||||
</ElDescriptionsItem>
|
||||
<ElDescriptionsItem label="严重缺陷率">
|
||||
{{ formData.majorRate ?? 0 }}%
|
||||
</ElDescriptionsItem>
|
||||
<ElDescriptionsItem label="轻微缺陷率">
|
||||
{{ formData.minorRate ?? 0 }}%
|
||||
</ElDescriptionsItem>
|
||||
</ElDescriptions>
|
||||
</div>
|
||||
<ElTabs v-if="formData?.id" v-model="subTabsName" class="mx-4 mt-4">
|
||||
<ElTabPane label="检验项" name="line">
|
||||
<LineList
|
||||
:form-type="formType"
|
||||
:oqc-id="formData.id"
|
||||
@refresh="handleRefresh"
|
||||
/>
|
||||
</ElTabPane>
|
||||
<ElTabPane label="检测结果" name="result">
|
||||
<QcIndicatorResultList
|
||||
:qc-id="formData.id"
|
||||
:qc-type="MesQcTypeEnum.OQC"
|
||||
:readonly="isDetail"
|
||||
/>
|
||||
</ElTabPane>
|
||||
</ElTabs>
|
||||
<template #prepend-footer>
|
||||
<div class="flex flex-auto items-center gap-2">
|
||||
<ElButton v-if="canFinish" type="primary" @click="handleFinish">
|
||||
完成
|
||||
</ElButton>
|
||||
</div>
|
||||
</template>
|
||||
</Modal>
|
||||
</template>
|
||||
|
|
@ -0,0 +1,98 @@
|
|||
<script lang="ts" setup>
|
||||
import type { VxeTableGridOptions } from '#/adapter/vxe-table';
|
||||
import type { MesQcOqcLineApi } from '#/api/mes/qc/oqc/line';
|
||||
|
||||
import { useVbenModal } from '@vben/common-ui';
|
||||
|
||||
import { ACTION_ICON, TableAction, useVbenVxeGrid } from '#/adapter/vxe-table';
|
||||
import { getOqcLinePage } from '#/api/mes/qc/oqc/line';
|
||||
import { MesQcTypeEnum } from '#/views/mes/utils/constants';
|
||||
|
||||
import { DefectRecordInlineList } from '../../defectrecord/components';
|
||||
import { useLineGridColumns } from '../data';
|
||||
|
||||
const props = defineProps<{
|
||||
formType?: string;
|
||||
oqcId: number;
|
||||
}>();
|
||||
|
||||
const emit = defineEmits<{ refresh: [] }>();
|
||||
|
||||
const [DefectModal, defectModalApi] = useVbenModal({
|
||||
connectedComponent: DefectRecordInlineList,
|
||||
destroyOnClose: true,
|
||||
});
|
||||
|
||||
/** 刷新表格 */
|
||||
function handleRefresh() {
|
||||
gridApi.query();
|
||||
}
|
||||
|
||||
/** 缺陷记录变更后,刷新本表格并通知父组件刷新主表统计 */
|
||||
function handleDefectChanged() {
|
||||
handleRefresh();
|
||||
emit('refresh');
|
||||
}
|
||||
|
||||
/** 打开缺陷记录弹窗 */
|
||||
function handleOpenDefect(row: MesQcOqcLineApi.OqcLine) {
|
||||
defectModalApi
|
||||
.setData({
|
||||
formType: props.formType,
|
||||
lineId: row.id,
|
||||
qcId: props.oqcId,
|
||||
qcType: MesQcTypeEnum.OQC,
|
||||
})
|
||||
.open();
|
||||
}
|
||||
|
||||
const [Grid, gridApi] = useVbenVxeGrid({
|
||||
gridOptions: {
|
||||
columns: useLineGridColumns(),
|
||||
height: 360,
|
||||
keepSource: true,
|
||||
proxyConfig: {
|
||||
ajax: {
|
||||
query: async ({ page }) => {
|
||||
if (!props.oqcId) {
|
||||
return { list: [], total: 0 };
|
||||
}
|
||||
return await getOqcLinePage({
|
||||
oqcId: props.oqcId,
|
||||
pageNo: page.currentPage,
|
||||
pageSize: page.pageSize,
|
||||
});
|
||||
},
|
||||
},
|
||||
},
|
||||
rowConfig: {
|
||||
keyField: 'id',
|
||||
isHover: true,
|
||||
},
|
||||
toolbarConfig: {
|
||||
refresh: true,
|
||||
},
|
||||
} as VxeTableGridOptions<MesQcOqcLineApi.OqcLine>,
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div>
|
||||
<DefectModal @success="handleDefectChanged" />
|
||||
<Grid table-title="检验项">
|
||||
<template #actions="{ row }">
|
||||
<TableAction
|
||||
:actions="[
|
||||
{
|
||||
label: '缺陷列表',
|
||||
type: 'primary',
|
||||
link: true,
|
||||
icon: ACTION_ICON.VIEW,
|
||||
onClick: handleOpenDefect.bind(null, row),
|
||||
},
|
||||
]"
|
||||
/>
|
||||
</template>
|
||||
</Grid>
|
||||
</div>
|
||||
</template>
|
||||
|
|
@ -0,0 +1,498 @@
|
|||
import type { VbenFormApi, VbenFormSchema } from '#/adapter/form';
|
||||
import type { VxeTableGridOptions } from '#/adapter/vxe-table';
|
||||
import type { MesQcRqcApi } from '#/api/mes/qc/rqc';
|
||||
import type { MesQcRqcLineApi } from '#/api/mes/qc/rqc/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 { getSimpleUserList } from '#/api/system/user';
|
||||
import MdItemSelect from '#/views/mes/md/item/components/md-item-select.vue';
|
||||
import {
|
||||
MesAutoCodeRuleCode,
|
||||
MesQcSourceDocTypeEnum,
|
||||
} from '#/views/mes/utils/constants';
|
||||
|
||||
/** 表单类型 */
|
||||
export type FormType = 'create' | 'detail' | 'update';
|
||||
|
||||
/** 列表搜索专用:来源单据类型字典只允许 RQC 用到的两种 */
|
||||
function getRqcSourceDocTypeOptions() {
|
||||
const allowed = new Set<number>([
|
||||
MesQcSourceDocTypeEnum.RETURN_ISSUE,
|
||||
MesQcSourceDocTypeEnum.RETURN_SALES,
|
||||
]);
|
||||
return getDictOptions(DICT_TYPE.MES_QC_SOURCE_DOC_TYPE, 'number').filter(
|
||||
(item) => allowed.has(Number(item.value)),
|
||||
);
|
||||
}
|
||||
|
||||
/** 新增/修改的表单 */
|
||||
export function useFormSchema(formApi?: VbenFormApi): VbenFormSchema[] {
|
||||
return [
|
||||
{
|
||||
fieldName: 'id',
|
||||
component: 'Input',
|
||||
dependencies: {
|
||||
triggerFields: [''],
|
||||
show: () => false,
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldName: 'sourceDocId',
|
||||
component: 'Input',
|
||||
dependencies: {
|
||||
triggerFields: [''],
|
||||
show: () => false,
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldName: 'sourceLineId',
|
||||
component: 'Input',
|
||||
dependencies: {
|
||||
triggerFields: [''],
|
||||
show: () => false,
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldName: 'status',
|
||||
component: 'Input',
|
||||
dependencies: {
|
||||
triggerFields: [''],
|
||||
show: () => false,
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldName: 'code',
|
||||
label: '检验单编号',
|
||||
component: 'Input',
|
||||
componentProps: {
|
||||
placeholder: '请输入检验单编号',
|
||||
},
|
||||
rules: 'required',
|
||||
suffix: () =>
|
||||
h(
|
||||
ElButton,
|
||||
{
|
||||
onClick: async () => {
|
||||
try {
|
||||
const code = await generateAutoCode(
|
||||
MesAutoCodeRuleCode.QC_RQC_CODE,
|
||||
);
|
||||
await formApi?.setFieldValue('code', code);
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
}
|
||||
},
|
||||
},
|
||||
{ default: () => '生成' },
|
||||
),
|
||||
},
|
||||
{
|
||||
fieldName: 'name',
|
||||
label: '检验单名称',
|
||||
component: 'Input',
|
||||
componentProps: {
|
||||
placeholder: '请输入检验单名称',
|
||||
},
|
||||
rules: 'required',
|
||||
},
|
||||
{
|
||||
fieldName: 'sourceDocType',
|
||||
label: '来源单据类型',
|
||||
component: 'Select',
|
||||
componentProps: {
|
||||
disabled: true,
|
||||
options: getDictOptions(DICT_TYPE.MES_QC_SOURCE_DOC_TYPE, 'number'),
|
||||
placeholder: '来源单据类型',
|
||||
},
|
||||
dependencies: {
|
||||
triggerFields: ['sourceDocType'],
|
||||
show: (values) => !!values.sourceDocType,
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldName: 'sourceDocCode',
|
||||
label: '来源单据编号',
|
||||
component: 'Input',
|
||||
componentProps: {
|
||||
disabled: true,
|
||||
placeholder: '来源单据编号',
|
||||
},
|
||||
dependencies: {
|
||||
triggerFields: ['sourceDocType', 'sourceDocId'],
|
||||
show: (values) => !!values.sourceDocType && !!values.sourceDocId,
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldName: 'type',
|
||||
label: '检验类型',
|
||||
component: 'Select',
|
||||
componentProps: {
|
||||
clearable: true,
|
||||
options: getDictOptions(DICT_TYPE.MES_RQC_TYPE, 'number'),
|
||||
placeholder: '请选择检验类型',
|
||||
},
|
||||
rules: 'selectRequired',
|
||||
},
|
||||
{
|
||||
fieldName: 'itemId',
|
||||
label: '产品物料',
|
||||
component: markRaw(MdItemSelect),
|
||||
componentProps: {
|
||||
placeholder: '请选择产品物料',
|
||||
},
|
||||
rules: 'selectRequired',
|
||||
dependencies: {
|
||||
triggerFields: ['sourceDocId'],
|
||||
componentProps: (values) => ({
|
||||
disabled: !!values.sourceDocId,
|
||||
placeholder: '请选择产品物料',
|
||||
}),
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldName: 'batchCode',
|
||||
label: '批次号',
|
||||
component: 'Input',
|
||||
componentProps: {
|
||||
placeholder: '请输入批次号',
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldName: 'checkQuantity',
|
||||
label: '检测数量',
|
||||
component: 'InputNumber',
|
||||
componentProps: {
|
||||
class: '!w-full',
|
||||
controlsPosition: 'right',
|
||||
min: 0,
|
||||
placeholder: '请输入',
|
||||
precision: 2,
|
||||
},
|
||||
rules: 'required',
|
||||
dependencies: {
|
||||
triggerFields: ['sourceDocId'],
|
||||
componentProps: (values) => ({
|
||||
class: '!w-full',
|
||||
controlsPosition: 'right',
|
||||
disabled: !!values.sourceDocId,
|
||||
min: 0,
|
||||
placeholder: '请输入',
|
||||
precision: 2,
|
||||
}),
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldName: 'qualifiedQuantity',
|
||||
label: '合格品数量',
|
||||
component: 'InputNumber',
|
||||
componentProps: {
|
||||
class: '!w-full',
|
||||
controlsPosition: 'right',
|
||||
min: 0,
|
||||
placeholder: '请输入',
|
||||
precision: 2,
|
||||
},
|
||||
rules: 'required',
|
||||
},
|
||||
{
|
||||
fieldName: 'unqualifiedQuantity',
|
||||
label: '不合格品数量',
|
||||
component: 'InputNumber',
|
||||
componentProps: {
|
||||
class: '!w-full',
|
||||
controlsPosition: 'right',
|
||||
min: 0,
|
||||
placeholder: '请输入',
|
||||
precision: 2,
|
||||
},
|
||||
rules: 'required',
|
||||
},
|
||||
{
|
||||
fieldName: 'inspectDate',
|
||||
label: '检测日期',
|
||||
component: 'DatePicker',
|
||||
componentProps: {
|
||||
format: 'YYYY-MM-DD HH:mm:ss',
|
||||
placeholder: '请选择检测日期',
|
||||
type: 'datetime',
|
||||
valueFormat: 'x',
|
||||
},
|
||||
rules: 'required',
|
||||
},
|
||||
{
|
||||
fieldName: 'inspectorUserId',
|
||||
label: '检测人员',
|
||||
component: 'ApiSelect',
|
||||
componentProps: {
|
||||
api: getSimpleUserList,
|
||||
clearable: true,
|
||||
labelField: 'nickname',
|
||||
placeholder: '请选择检测人员',
|
||||
valueField: 'id',
|
||||
},
|
||||
rules: 'selectRequired',
|
||||
},
|
||||
{
|
||||
fieldName: 'checkResult',
|
||||
label: '检测结果',
|
||||
component: 'Select',
|
||||
componentProps: {
|
||||
clearable: true,
|
||||
options: getDictOptions(DICT_TYPE.MES_QC_CHECK_RESULT, 'number'),
|
||||
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: 'sourceDocType',
|
||||
label: '来源单据类型',
|
||||
component: 'Select',
|
||||
componentProps: {
|
||||
clearable: true,
|
||||
options: getRqcSourceDocTypeOptions(),
|
||||
placeholder: '请选择来源单据类型',
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldName: 'sourceDocCode',
|
||||
label: '来源单据编号',
|
||||
component: 'Input',
|
||||
componentProps: {
|
||||
clearable: true,
|
||||
placeholder: '请输入来源单据编号',
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldName: 'itemId',
|
||||
label: '产品物料',
|
||||
component: markRaw(MdItemSelect),
|
||||
componentProps: {
|
||||
placeholder: '请选择产品物料',
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldName: 'batchCode',
|
||||
label: '批次号',
|
||||
component: 'Input',
|
||||
componentProps: {
|
||||
clearable: true,
|
||||
placeholder: '请输入批次号',
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldName: 'checkResult',
|
||||
label: '检测结果',
|
||||
component: 'Select',
|
||||
componentProps: {
|
||||
clearable: true,
|
||||
options: getDictOptions(DICT_TYPE.MES_QC_CHECK_RESULT, 'number'),
|
||||
placeholder: '请选择检测结果',
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldName: 'inspectorUserId',
|
||||
label: '检测人员',
|
||||
component: 'ApiSelect',
|
||||
componentProps: {
|
||||
api: getSimpleUserList,
|
||||
clearable: true,
|
||||
labelField: 'nickname',
|
||||
placeholder: '请选择检测人员',
|
||||
valueField: 'id',
|
||||
},
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
/** 列表的字段 */
|
||||
export function useGridColumns(): VxeTableGridOptions<MesQcRqcApi.Rqc>['columns'] {
|
||||
return [
|
||||
{
|
||||
field: 'code',
|
||||
title: '检验单编号',
|
||||
width: 160,
|
||||
slots: { default: 'code' },
|
||||
},
|
||||
{
|
||||
field: 'name',
|
||||
title: '检验单名称',
|
||||
minWidth: 180,
|
||||
},
|
||||
{
|
||||
field: 'sourceDocType',
|
||||
title: '来源单据类型',
|
||||
width: 120,
|
||||
cellRender: {
|
||||
name: 'CellDict',
|
||||
props: { type: DICT_TYPE.MES_QC_SOURCE_DOC_TYPE },
|
||||
},
|
||||
},
|
||||
{
|
||||
field: 'sourceDocCode',
|
||||
title: '来源单据编码',
|
||||
width: 160,
|
||||
},
|
||||
{
|
||||
field: 'itemCode',
|
||||
title: '产品物料编码',
|
||||
width: 130,
|
||||
},
|
||||
{
|
||||
field: 'itemName',
|
||||
title: '产品物料名称',
|
||||
minWidth: 150,
|
||||
},
|
||||
{
|
||||
field: 'itemSpecification',
|
||||
title: '规格型号',
|
||||
width: 130,
|
||||
},
|
||||
{
|
||||
field: 'unitName',
|
||||
title: '单位',
|
||||
width: 80,
|
||||
},
|
||||
{
|
||||
field: 'batchCode',
|
||||
title: '批次号',
|
||||
width: 130,
|
||||
},
|
||||
{
|
||||
field: 'checkResult',
|
||||
title: '检测结果',
|
||||
width: 110,
|
||||
cellRender: {
|
||||
name: 'CellDict',
|
||||
props: { type: DICT_TYPE.MES_QC_CHECK_RESULT },
|
||||
},
|
||||
},
|
||||
{
|
||||
field: 'inspectDate',
|
||||
title: '检测日期',
|
||||
width: 160,
|
||||
formatter: 'formatDateTime',
|
||||
},
|
||||
{
|
||||
field: 'inspectorNickname',
|
||||
title: '检测人员',
|
||||
width: 100,
|
||||
},
|
||||
{
|
||||
field: 'status',
|
||||
title: '单据状态',
|
||||
width: 100,
|
||||
cellRender: {
|
||||
name: 'CellDict',
|
||||
props: { type: DICT_TYPE.MES_ORDER_STATUS },
|
||||
},
|
||||
},
|
||||
{
|
||||
title: '操作',
|
||||
width: 180,
|
||||
fixed: 'right',
|
||||
slots: { default: 'actions' },
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
/** 退货检验单行子表的字段 */
|
||||
export function useLineGridColumns(): VxeTableGridOptions<MesQcRqcLineApi.RqcLine>['columns'] {
|
||||
return [
|
||||
{
|
||||
field: 'indicatorName',
|
||||
title: '检测项名称',
|
||||
minWidth: 150,
|
||||
},
|
||||
{
|
||||
field: 'indicatorType',
|
||||
title: '检测项类型',
|
||||
width: 120,
|
||||
cellRender: {
|
||||
name: 'CellDict',
|
||||
props: { type: DICT_TYPE.MES_INDICATOR_TYPE },
|
||||
},
|
||||
},
|
||||
{
|
||||
field: 'tool',
|
||||
title: '检测工具',
|
||||
width: 120,
|
||||
},
|
||||
{
|
||||
field: 'checkMethod',
|
||||
title: '检测方法',
|
||||
minWidth: 180,
|
||||
},
|
||||
{
|
||||
field: 'standardValue',
|
||||
title: '标准值',
|
||||
width: 100,
|
||||
},
|
||||
{
|
||||
field: 'unitMeasureName',
|
||||
title: '单位',
|
||||
width: 80,
|
||||
},
|
||||
{
|
||||
field: 'maxThreshold',
|
||||
title: '误差上限',
|
||||
width: 100,
|
||||
},
|
||||
{
|
||||
field: 'minThreshold',
|
||||
title: '误差下限',
|
||||
width: 100,
|
||||
},
|
||||
{
|
||||
field: 'criticalQuantity',
|
||||
title: '致命缺陷数',
|
||||
width: 110,
|
||||
},
|
||||
{
|
||||
field: 'majorQuantity',
|
||||
title: '严重缺陷数',
|
||||
width: 110,
|
||||
},
|
||||
{
|
||||
field: 'minorQuantity',
|
||||
title: '轻微缺陷数',
|
||||
width: 110,
|
||||
},
|
||||
{
|
||||
title: '操作',
|
||||
width: 110,
|
||||
fixed: 'right',
|
||||
slots: { default: 'actions' },
|
||||
},
|
||||
];
|
||||
}
|
||||
|
|
@ -0,0 +1,168 @@
|
|||
<script lang="ts" setup>
|
||||
import type { VxeTableGridOptions } from '#/adapter/vxe-table';
|
||||
import type { MesQcRqcApi } from '#/api/mes/qc/rqc';
|
||||
|
||||
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 { deleteRqc, exportRqc, getRqcPage } from '#/api/mes/qc/rqc';
|
||||
import { $t } from '#/locales';
|
||||
import { MesQcStatusEnum } 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: MesQcRqcApi.Rqc) {
|
||||
formModalApi.setData({ formType: 'detail', id: row.id }).open();
|
||||
}
|
||||
|
||||
/** 编辑退货检验单 */
|
||||
function handleEdit(row: MesQcRqcApi.Rqc) {
|
||||
formModalApi.setData({ formType: 'update', id: row.id }).open();
|
||||
}
|
||||
|
||||
/** 删除退货检验单 */
|
||||
async function handleDelete(row: MesQcRqcApi.Rqc) {
|
||||
const loadingInstance = ElLoading.service({
|
||||
text: $t('ui.actionMessage.deleting', [row.code]),
|
||||
});
|
||||
try {
|
||||
await deleteRqc(row.id!);
|
||||
ElMessage.success($t('ui.actionMessage.deleteSuccess', [row.code]));
|
||||
handleRefresh();
|
||||
} finally {
|
||||
loadingInstance.close();
|
||||
}
|
||||
}
|
||||
|
||||
/** 导出表格 */
|
||||
async function handleExport() {
|
||||
const data = await exportRqc(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 getRqcPage({
|
||||
pageNo: page.currentPage,
|
||||
pageSize: page.pageSize,
|
||||
...formValues,
|
||||
});
|
||||
},
|
||||
},
|
||||
},
|
||||
rowConfig: {
|
||||
keyField: 'id',
|
||||
isHover: true,
|
||||
},
|
||||
toolbarConfig: {
|
||||
refresh: true,
|
||||
search: true,
|
||||
},
|
||||
} as VxeTableGridOptions<MesQcRqcApi.Rqc>,
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Page auto-content-height>
|
||||
<template #doc>
|
||||
<DocAlert
|
||||
title="【质量】退货检验(RQC)"
|
||||
url="https://doc.iocoder.cn/mes/qc/rqc/"
|
||||
/>
|
||||
</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:qc-rqc:create'],
|
||||
onClick: handleCreate,
|
||||
},
|
||||
{
|
||||
label: $t('ui.actionTitle.export'),
|
||||
type: 'primary',
|
||||
icon: ACTION_ICON.DOWNLOAD,
|
||||
auth: ['mes:qc-rqc: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:qc-rqc:update'],
|
||||
ifShow: row.status === MesQcStatusEnum.DRAFT,
|
||||
onClick: handleEdit.bind(null, row),
|
||||
},
|
||||
{
|
||||
label: $t('common.delete'),
|
||||
type: 'danger',
|
||||
link: true,
|
||||
icon: ACTION_ICON.DELETE,
|
||||
auth: ['mes:qc-rqc:delete'],
|
||||
ifShow: row.status === MesQcStatusEnum.DRAFT,
|
||||
popConfirm: {
|
||||
title: $t('ui.actionMessage.deleteConfirm', [row.code]),
|
||||
confirm: handleDelete.bind(null, row),
|
||||
},
|
||||
},
|
||||
{
|
||||
label: $t('common.detail'),
|
||||
type: 'primary',
|
||||
link: true,
|
||||
icon: ACTION_ICON.VIEW,
|
||||
auth: ['mes:qc-rqc:query'],
|
||||
onClick: handleDetail.bind(null, row),
|
||||
},
|
||||
]"
|
||||
/>
|
||||
</template>
|
||||
</Grid>
|
||||
</Page>
|
||||
</template>
|
||||
|
|
@ -0,0 +1,233 @@
|
|||
<script lang="ts" setup>
|
||||
import type { FormType } from '../data';
|
||||
|
||||
import type { MesQcRqcApi } from '#/api/mes/qc/rqc';
|
||||
|
||||
import { computed, ref } from 'vue';
|
||||
|
||||
import { confirm, useVbenModal } from '@vben/common-ui';
|
||||
|
||||
import {
|
||||
ElButton,
|
||||
ElDescriptions,
|
||||
ElDescriptionsItem,
|
||||
ElMessage,
|
||||
ElTabPane,
|
||||
ElTabs,
|
||||
} from 'element-plus';
|
||||
|
||||
import { useVbenForm } from '#/adapter/form';
|
||||
import {
|
||||
createRqc,
|
||||
finishRqc,
|
||||
getRqc,
|
||||
updateRqc,
|
||||
} from '#/api/mes/qc/rqc';
|
||||
import { $t } from '#/locales';
|
||||
import { MesQcStatusEnum, MesQcTypeEnum } from '#/views/mes/utils/constants';
|
||||
|
||||
import { QcIndicatorResultList } from '../../indicatorresult/components';
|
||||
import { useFormSchema } from '../data';
|
||||
import LineList from './line-list.vue';
|
||||
|
||||
const emit = defineEmits(['success']);
|
||||
const formType = ref<FormType>('create');
|
||||
const formData = ref<MesQcRqcApi.Rqc>();
|
||||
const subTabsName = ref('line');
|
||||
const originalSnapshot = ref('');
|
||||
const isDetail = computed(() => formType.value === 'detail');
|
||||
const canFinish = computed(
|
||||
() =>
|
||||
formType.value === 'update' &&
|
||||
formData.value?.status === MesQcStatusEnum.DRAFT,
|
||||
);
|
||||
const getTitle = computed(() => {
|
||||
if (formType.value === 'detail') {
|
||||
return $t('ui.actionTitle.view', ['退货检验单']);
|
||||
}
|
||||
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,
|
||||
},
|
||||
wrapperClass: 'grid-cols-3',
|
||||
layout: 'horizontal',
|
||||
schema: [],
|
||||
showDefaultActions: false,
|
||||
});
|
||||
|
||||
/** 子表变更后刷新主表头数据(缺陷统计等) */
|
||||
async function handleRefresh() {
|
||||
if (!formData.value?.id) {
|
||||
return;
|
||||
}
|
||||
formData.value = await getRqc(formData.value.id);
|
||||
}
|
||||
|
||||
/** 提交表单 */
|
||||
async function handleSubmit(): Promise<boolean> {
|
||||
const { valid } = await formApi.validate();
|
||||
if (!valid) {
|
||||
return false;
|
||||
}
|
||||
const data = (await formApi.getValues()) as MesQcRqcApi.Rqc;
|
||||
if (formData.value?.id) {
|
||||
await updateRqc({ ...data, id: formData.value.id });
|
||||
formData.value = { ...formData.value, ...data };
|
||||
} else {
|
||||
const id = await createRqc(data);
|
||||
formData.value = {
|
||||
...data,
|
||||
id: id as unknown as number,
|
||||
status: MesQcStatusEnum.DRAFT,
|
||||
};
|
||||
await formApi.setFieldValue('id', formData.value.id);
|
||||
await formApi.setFieldValue('status', formData.value.status);
|
||||
formType.value = 'update';
|
||||
}
|
||||
originalSnapshot.value = JSON.stringify(await formApi.getValues());
|
||||
return true;
|
||||
}
|
||||
|
||||
/** 完成检验单:表单有修改时先保存,再调用完成接口 */
|
||||
async function handleFinish() {
|
||||
const id = formData.value?.id;
|
||||
if (!id) {
|
||||
return;
|
||||
}
|
||||
const { valid } = await formApi.validate();
|
||||
if (!valid) {
|
||||
return;
|
||||
}
|
||||
await confirm({
|
||||
content: '是否完成退货检验单编制?【完成后将不能更改】',
|
||||
});
|
||||
modalApi.lock();
|
||||
try {
|
||||
const current = JSON.stringify(await formApi.getValues());
|
||||
if (current !== originalSnapshot.value) {
|
||||
const data = (await formApi.getValues()) as MesQcRqcApi.Rqc;
|
||||
await updateRqc({ ...data, id });
|
||||
formData.value = { ...formData.value, ...data };
|
||||
originalSnapshot.value = current;
|
||||
}
|
||||
await finishRqc(id);
|
||||
ElMessage.success('完成成功');
|
||||
await modalApi.close();
|
||||
emit('success');
|
||||
} finally {
|
||||
modalApi.unlock();
|
||||
}
|
||||
}
|
||||
|
||||
const [Modal, modalApi] = useVbenModal({
|
||||
async onConfirm() {
|
||||
if (isDetail.value) {
|
||||
await modalApi.close();
|
||||
return;
|
||||
}
|
||||
modalApi.lock();
|
||||
try {
|
||||
const ok = await handleSubmit();
|
||||
if (!ok) {
|
||||
return;
|
||||
}
|
||||
ElMessage.success($t('ui.actionMessage.operationSuccess'));
|
||||
await modalApi.close();
|
||||
emit('success');
|
||||
} finally {
|
||||
modalApi.unlock();
|
||||
}
|
||||
},
|
||||
async onOpenChange(isOpen: boolean) {
|
||||
if (!isOpen) {
|
||||
formData.value = undefined;
|
||||
originalSnapshot.value = '';
|
||||
return;
|
||||
}
|
||||
formApi.setState({ schema: useFormSchema(formApi) });
|
||||
subTabsName.value = 'line';
|
||||
const data = modalApi.getData<{
|
||||
formType: FormType;
|
||||
id?: number;
|
||||
prefill?: MesQcRqcApi.Rqc;
|
||||
}>();
|
||||
formType.value = data.formType;
|
||||
formApi.setDisabled(formType.value === 'detail');
|
||||
modalApi.setState({ showConfirmButton: formType.value !== 'detail' });
|
||||
if (data?.id) {
|
||||
modalApi.lock();
|
||||
try {
|
||||
formData.value = await getRqc(data.id);
|
||||
await formApi.setValues(formData.value);
|
||||
} finally {
|
||||
modalApi.unlock();
|
||||
}
|
||||
} else if (data?.prefill) {
|
||||
formData.value = { ...data.prefill };
|
||||
await formApi.setValues(data.prefill);
|
||||
}
|
||||
originalSnapshot.value = JSON.stringify(await formApi.getValues());
|
||||
},
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Modal :title="getTitle" class="w-4/5">
|
||||
<Form class="mx-4" />
|
||||
<!-- 缺陷统计(只读) -->
|
||||
<div v-if="formData?.id" class="mx-4 mt-4">
|
||||
<ElDescriptions title="缺陷情况" :column="3" border size="small">
|
||||
<ElDescriptionsItem label="致命缺陷数">
|
||||
{{ formData.criticalQuantity ?? 0 }}
|
||||
</ElDescriptionsItem>
|
||||
<ElDescriptionsItem label="严重缺陷数">
|
||||
{{ formData.majorQuantity ?? 0 }}
|
||||
</ElDescriptionsItem>
|
||||
<ElDescriptionsItem label="轻微缺陷数">
|
||||
{{ formData.minorQuantity ?? 0 }}
|
||||
</ElDescriptionsItem>
|
||||
<ElDescriptionsItem label="致命缺陷率">
|
||||
{{ formData.criticalRate ?? 0 }}%
|
||||
</ElDescriptionsItem>
|
||||
<ElDescriptionsItem label="严重缺陷率">
|
||||
{{ formData.majorRate ?? 0 }}%
|
||||
</ElDescriptionsItem>
|
||||
<ElDescriptionsItem label="轻微缺陷率">
|
||||
{{ formData.minorRate ?? 0 }}%
|
||||
</ElDescriptionsItem>
|
||||
</ElDescriptions>
|
||||
</div>
|
||||
<ElTabs v-if="formData?.id" v-model="subTabsName" class="mx-4 mt-4">
|
||||
<ElTabPane label="检验项" name="line">
|
||||
<LineList
|
||||
:form-type="formType"
|
||||
:rqc-id="formData.id"
|
||||
@refresh="handleRefresh"
|
||||
/>
|
||||
</ElTabPane>
|
||||
<ElTabPane label="检测结果" name="result">
|
||||
<QcIndicatorResultList
|
||||
:qc-id="formData.id"
|
||||
:qc-type="MesQcTypeEnum.RQC"
|
||||
:readonly="isDetail"
|
||||
/>
|
||||
</ElTabPane>
|
||||
</ElTabs>
|
||||
<template #prepend-footer>
|
||||
<div class="flex flex-auto items-center gap-2">
|
||||
<ElButton v-if="canFinish" type="primary" @click="handleFinish">
|
||||
完成
|
||||
</ElButton>
|
||||
</div>
|
||||
</template>
|
||||
</Modal>
|
||||
</template>
|
||||
|
|
@ -0,0 +1,98 @@
|
|||
<script lang="ts" setup>
|
||||
import type { VxeTableGridOptions } from '#/adapter/vxe-table';
|
||||
import type { MesQcRqcLineApi } from '#/api/mes/qc/rqc/line';
|
||||
|
||||
import { useVbenModal } from '@vben/common-ui';
|
||||
|
||||
import { ACTION_ICON, TableAction, useVbenVxeGrid } from '#/adapter/vxe-table';
|
||||
import { getRqcLinePage } from '#/api/mes/qc/rqc/line';
|
||||
import { MesQcTypeEnum } from '#/views/mes/utils/constants';
|
||||
|
||||
import { DefectRecordInlineList } from '../../defectrecord/components';
|
||||
import { useLineGridColumns } from '../data';
|
||||
|
||||
const props = defineProps<{
|
||||
formType?: string;
|
||||
rqcId: number;
|
||||
}>();
|
||||
|
||||
const emit = defineEmits<{ refresh: [] }>();
|
||||
|
||||
const [DefectModal, defectModalApi] = useVbenModal({
|
||||
connectedComponent: DefectRecordInlineList,
|
||||
destroyOnClose: true,
|
||||
});
|
||||
|
||||
/** 刷新表格 */
|
||||
function handleRefresh() {
|
||||
gridApi.query();
|
||||
}
|
||||
|
||||
/** 缺陷记录变更后,刷新本表格并通知父组件刷新主表统计 */
|
||||
function handleDefectChanged() {
|
||||
handleRefresh();
|
||||
emit('refresh');
|
||||
}
|
||||
|
||||
/** 打开缺陷记录弹窗 */
|
||||
function handleOpenDefect(row: MesQcRqcLineApi.RqcLine) {
|
||||
defectModalApi
|
||||
.setData({
|
||||
formType: props.formType,
|
||||
lineId: row.id,
|
||||
qcId: props.rqcId,
|
||||
qcType: MesQcTypeEnum.RQC,
|
||||
})
|
||||
.open();
|
||||
}
|
||||
|
||||
const [Grid, gridApi] = useVbenVxeGrid({
|
||||
gridOptions: {
|
||||
columns: useLineGridColumns(),
|
||||
height: 360,
|
||||
keepSource: true,
|
||||
proxyConfig: {
|
||||
ajax: {
|
||||
query: async ({ page }) => {
|
||||
if (!props.rqcId) {
|
||||
return { list: [], total: 0 };
|
||||
}
|
||||
return await getRqcLinePage({
|
||||
rqcId: props.rqcId,
|
||||
pageNo: page.currentPage,
|
||||
pageSize: page.pageSize,
|
||||
});
|
||||
},
|
||||
},
|
||||
},
|
||||
rowConfig: {
|
||||
keyField: 'id',
|
||||
isHover: true,
|
||||
},
|
||||
toolbarConfig: {
|
||||
refresh: true,
|
||||
},
|
||||
} as VxeTableGridOptions<MesQcRqcLineApi.RqcLine>,
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div>
|
||||
<DefectModal @success="handleDefectChanged" />
|
||||
<Grid table-title="检验项">
|
||||
<template #actions="{ row }">
|
||||
<TableAction
|
||||
:actions="[
|
||||
{
|
||||
label: '缺陷列表',
|
||||
type: 'primary',
|
||||
link: true,
|
||||
icon: ACTION_ICON.VIEW,
|
||||
onClick: handleOpenDefect.bind(null, row),
|
||||
},
|
||||
]"
|
||||
/>
|
||||
</template>
|
||||
</Grid>
|
||||
</div>
|
||||
</template>
|
||||
Loading…
Reference in New Issue