Merge remote-tracking branch 'origin/生产及设备基础资料'

This commit is contained in:
2026-05-28 17:16:45 +08:00
21 changed files with 1678 additions and 35 deletions

View File

@@ -5,6 +5,15 @@
<a-button type="primary" v-auth="'mes:mes_material:add'" @click="handleAdd" preIcon="ant-design:plus-outlined">新增</a-button>
<a-button type="primary" v-auth="'mes:mes_material:exportXls'" preIcon="ant-design:export-outlined" @click="onExportXls">导出</a-button>
<j-upload-button type="primary" v-auth="'mes:mes_material:importExcel'" preIcon="ant-design:import-outlined" @click="onImportXls">导入</j-upload-button>
<a-button
type="primary"
v-auth="'mes:mes_material:rubberQuickTestInspect'"
preIcon="ant-design:experiment-outlined"
:disabled="selectedRowKeys.length === 0"
@click="handleRubberQuickTest"
>
检验
</a-button>
<a-dropdown v-if="selectedRowKeys.length > 0">
<template #overlay>
<a-menu>
@@ -29,7 +38,10 @@ import { useListPage } from '/@/hooks/system/useListPage';
import MesMaterialModal from './modules/MesMaterialModal.vue';
import { columns, searchFormSchema } from './MesMaterial.data';
import { batchDelete, deleteOne, getExportUrl, getImportUrl, list } from './MesMaterial.api';
import { batchFromMaterial } from '/@/views/xslmes/mesXslRubberQuickTestRecord/MesXslRubberQuickTestRecord.api';
import { useMessage } from '/@/hooks/web/useMessage';
const { createMessage } = useMessage();
const [registerModal, { openModal }] = useModal();
const { tableContext, onExportXls, onImportXls } = useListPage({
tableProps: {
@@ -63,6 +75,18 @@ async function batchHandleDelete() {
function handleSuccess() {
reload();
}
async function handleRubberQuickTest() {
if (!selectedRowKeys.value?.length) {
createMessage.warning('请至少选择一条胶料');
return;
}
try {
await batchFromMaterial({ materialIds: [...selectedRowKeys.value] });
createMessage.success('快检记录已生成,请到「胶料快检记录」中编辑');
} catch (e: any) {
createMessage.error(e?.message || '生成失败');
}
}
function getTableAction(record) {
return [{ label: '编辑', onClick: handleEdit.bind(null, record), auth: 'mes:mes_material:edit' }];
}

View File

@@ -0,0 +1,54 @@
import { defHttp } from '/@/utils/http/axios';
import { useMessage } from '/@/hooks/web/useMessage';
const { createConfirm } = useMessage();
enum Api {
list = '/xslmes/mesXslRubberQuickTestRecord/list',
save = '/xslmes/mesXslRubberQuickTestRecord/add',
edit = '/xslmes/mesXslRubberQuickTestRecord/edit',
deleteOne = '/xslmes/mesXslRubberQuickTestRecord/delete',
deleteBatch = '/xslmes/mesXslRubberQuickTestRecord/deleteBatch',
importExcel = '/xslmes/mesXslRubberQuickTestRecord/importExcel',
exportXls = '/xslmes/mesXslRubberQuickTestRecord/exportXls',
queryById = '/xslmes/mesXslRubberQuickTestRecord/queryById',
queryLineList = '/xslmes/mesXslRubberQuickTestRecord/queryLineListByRecordId',
batchFromMaterial = '/xslmes/mesXslRubberQuickTestRecord/batchFromMaterial',
}
export const getExportUrl = Api.exportXls;
export const getImportUrl = Api.importExcel;
export const list = (params) => defHttp.get({ url: Api.list, params });
export const queryById = (params: { id: string }) => defHttp.get({ url: Api.queryById, params });
export const queryLineListByRecordId = (params: { id: string }) => defHttp.get({ url: Api.queryLineList, params });
export const batchFromMaterial = (params) => defHttp.post({ url: Api.batchFromMaterial, params });
export const deleteOne = (params, handleSuccess) => {
return defHttp.delete({ url: Api.deleteOne, params }, { joinParamsToUrl: true }).then(() => {
handleSuccess();
});
};
export const batchDelete = (params, handleSuccess) => {
createConfirm({
iconType: 'warning',
title: '确认删除',
content: '是否删除选中数据',
okText: '确认',
cancelText: '取消',
onOk: () => {
return defHttp.delete({ url: Api.deleteBatch, data: params }, { joinParamsToUrl: true }).then(() => {
handleSuccess();
});
},
});
};
export const saveOrUpdate = (params, isUpdate) => {
const url = isUpdate ? Api.edit : Api.save;
return defHttp.post({ url, params });
};

View File

@@ -0,0 +1,173 @@
import { BasicColumn, FormSchema } from '/@/components/Table';
import { JVxeColumn, JVxeTypes } from '/@/components/jeecg/JVxeTable/types';
const numProps = { style: { width: '100%' }, precision: 6 };
export const columns: BasicColumn[] = [
{ title: '单号', align: 'center', dataIndex: 'recordNo', width: 150 },
{ title: '胶料名称', align: 'center', dataIndex: 'rubberMaterialName', width: 140 },
{ title: '生产机台', align: 'center', dataIndex: 'prodEquipmentName', width: 120 },
{ title: '生产日期', align: 'center', dataIndex: 'productionDate', width: 110 },
{ title: '车次编号', align: 'center', dataIndex: 'trainNo', width: 100 },
{ title: '班次', align: 'center', dataIndex: 'workShift_dictText', width: 80 },
{ title: '班组', align: 'center', dataIndex: 'workTeam_dictText', width: 80 },
{ title: '检验次数', align: 'center', dataIndex: 'inspectTimes', width: 90 },
{ title: '检验时间', align: 'center', dataIndex: 'inspectTime', width: 165 },
{ title: '检验人', align: 'center', dataIndex: 'inspectorRealname', width: 100 },
{ title: '检验类型', align: 'center', dataIndex: 'quickTestTypeName', width: 120 },
{ title: '检验结果', align: 'center', dataIndex: 'inspectResult_dictText', width: 90 },
{ title: '生产计划号', align: 'center', dataIndex: 'productionPlanNo', width: 120 },
{ title: '检验机台', align: 'center', dataIndex: 'inspectEquipmentName', width: 120 },
{ title: '胶料卡片号', align: 'center', dataIndex: 'rubberCardNo', width: 120 },
{ title: '胶料批次', align: 'center', dataIndex: 'rubberBatchNo', width: 120 },
];
export const searchFormSchema: FormSchema[] = [
{ label: '单号', field: 'recordNo', component: 'Input', colProps: { span: 6 } },
{ label: '胶料名称', field: 'rubberMaterialName', component: 'Input', colProps: { span: 6 } },
{ label: '生产计划号', field: 'productionPlanNo', component: 'Input', colProps: { span: 6 } },
{ label: '胶料批次', field: 'rubberBatchNo', component: 'Input', colProps: { span: 6 } },
{
label: '检验结果',
field: 'inspectResult',
component: 'JDictSelectTag',
componentProps: { dictCode: 'xslmes_rubber_quick_test_record_result' },
colProps: { span: 6 },
},
];
export const formSchema: FormSchema[] = [
{ label: '', field: 'id', component: 'Input', show: false },
{ label: '', field: 'stdId', component: 'Input', show: false },
{ label: '', field: 'rubberMaterialId', component: 'Input', show: false },
{ label: '', field: 'prodEquipmentLedgerId', component: 'Input', show: false },
{ label: '', field: 'inspectEquipmentLedgerId', component: 'Input', show: false },
{ label: '', field: 'inspectorUserId', component: 'Input', show: false },
{ label: '', field: 'inspectorUsername', component: 'Input', show: false },
{ label: '', field: 'quickTestTypeId', component: 'Input', show: false },
{
label: '单号',
field: 'recordNo',
component: 'Input',
componentProps: { readonly: true, placeholder: '保存时自动生成' },
},
{
label: '胶料名称',
field: 'rubberMaterialName',
component: 'Input',
componentProps: { readonly: true },
},
{
label: '生产机台',
field: 'prodEquipmentName',
component: 'Input',
slot: 'prodEquipmentPicker',
},
{
label: '生产日期',
field: 'productionDate',
component: 'DatePicker',
componentProps: { valueFormat: 'YYYY-MM-DD', style: { width: '100%' } },
},
{ label: '车次编号', field: 'trainNo', component: 'Input' },
{
label: '班次',
field: 'workShift',
component: 'JDictSelectTag',
componentProps: { dictCode: 'xslmes_rubber_quick_test_work_shift', placeholder: '请选择班次' },
},
{
label: '班组',
field: 'workTeam',
component: 'JDictSelectTag',
componentProps: { dictCode: 'xslmes_rubber_quick_test_work_team', placeholder: '请选择班组' },
},
{
label: '检验次数',
field: 'inspectTimes',
component: 'InputNumber',
componentProps: { style: { width: '100%' }, min: 0, precision: 0 },
},
{
label: '检验时间',
field: 'inspectTime',
component: 'DatePicker',
componentProps: {
showTime: true,
valueFormat: 'YYYY-MM-DD HH:mm:ss',
style: { width: '100%' },
},
},
{
label: '检验人',
field: 'inspectorUserId',
component: 'JSelectUser',
componentProps: ({ formActionType }) => ({
rowKey: 'id',
labelKey: 'realname',
isRadioSelection: true,
maxSelectCount: 1,
onOptionsChange: (options) => {
const row = options?.[0];
if (row) {
formActionType?.setFieldsValue?.({
inspectorUsername: row.username,
inspectorRealname: row.realname,
});
}
},
}),
},
{ label: '', field: 'inspectorRealname', component: 'Input', show: false },
{
label: '检验类型',
field: 'quickTestTypeId',
component: 'JSearchSelect',
componentProps: {
dict: 'mes_xsl_rubber_quick_test_type,type_name,id',
async: true,
placeholder: '请选择检验类型',
},
},
{
label: '检验结果',
field: 'inspectResult',
component: 'JDictSelectTag',
componentProps: { dictCode: 'xslmes_rubber_quick_test_record_result', placeholder: '合格/不合格' },
},
{ label: '生产计划号', field: 'productionPlanNo', component: 'Input' },
{
label: '检验机台',
field: 'inspectEquipmentName',
component: 'Input',
slot: 'inspectEquipmentPicker',
},
{ label: '胶料卡片号', field: 'rubberCardNo', component: 'Input' },
{ label: '胶料批次', field: 'rubberBatchNo', component: 'Input' },
];
export const lineJVxeColumns: JVxeColumn[] = [
{ title: '', key: 'dataPointId', type: JVxeTypes.hidden },
{ title: '检验项目', key: 'inspectItem', type: JVxeTypes.normal, width: 180, disabled: true },
{
title: '检验下限',
key: 'lowerLimit',
type: JVxeTypes.normal,
width: 110,
disabled: true,
},
{
title: '检验值',
key: 'inspectValue',
type: JVxeTypes.inputNumber,
width: 110,
componentProps: numProps,
},
{
title: '检验上限',
key: 'upperLimit',
type: JVxeTypes.normal,
width: 110,
disabled: true,
},
];

View File

@@ -0,0 +1,118 @@
<template>
<div>
<BasicTable @register="registerTable" :rowSelection="rowSelection">
<template #tableTitle>
<a-button
type="primary"
v-auth="'mes:mes_xsl_rubber_quick_test_record:exportXls'"
preIcon="ant-design:export-outlined"
@click="onExportXls"
>
导出
</a-button>
<j-upload-button
type="primary"
v-auth="'mes:mes_xsl_rubber_quick_test_record:importExcel'"
preIcon="ant-design:import-outlined"
@click="onImportXls"
>
导入
</j-upload-button>
<a-dropdown v-if="selectedRowKeys.length > 0">
<template #overlay>
<a-menu>
<a-menu-item key="1" @click="batchHandleDelete">
<Icon icon="ant-design:delete-outlined" />
删除
</a-menu-item>
</a-menu>
</template>
<a-button v-auth="'mes:mes_xsl_rubber_quick_test_record:deleteBatch'">
批量操作
<Icon icon="mdi:chevron-down" />
</a-button>
</a-dropdown>
</template>
<template #action="{ record }">
<TableAction :actions="getTableAction(record)" :dropDownActions="getDropDownAction(record)" />
</template>
</BasicTable>
<MesXslRubberQuickTestRecordModal @register="registerModal" @success="handleSuccess" />
</div>
</template>
<script lang="ts" name="xslmes-mesXslRubberQuickTestRecord" setup>
import { BasicTable, TableAction } from '/@/components/Table';
import { useModal } from '/@/components/Modal';
import { useListPage } from '/@/hooks/system/useListPage';
import Icon from '/@/components/Icon';
import MesXslRubberQuickTestRecordModal from './components/MesXslRubberQuickTestRecordModal.vue';
import { columns, searchFormSchema } from './MesXslRubberQuickTestRecord.data';
import { list, deleteOne, batchDelete, getExportUrl, getImportUrl } from './MesXslRubberQuickTestRecord.api';
const [registerModal, { openModal }] = useModal();
const { tableContext, onExportXls, onImportXls } = useListPage({
tableProps: {
title: '胶料快检记录',
api: list,
columns,
canResize: true,
formConfig: {
schemas: searchFormSchema,
labelWidth: 120,
autoSubmitOnEnter: true,
showAdvancedButton: true,
},
actionColumn: {
width: 160,
fixed: 'right',
},
},
exportConfig: {
name: '胶料快检记录',
url: getExportUrl,
},
importConfig: {
url: getImportUrl,
success: handleSuccess,
},
});
const [registerTable, { reload }, { rowSelection, selectedRowKeys }] = tableContext;
function handleEdit(record: Recordable) {
openModal(true, { record, isUpdate: true, showFooter: true });
}
function handleDetail(record: Recordable) {
openModal(true, { record, isUpdate: true, showFooter: false });
}
async function handleDelete(record) {
await deleteOne({ id: record.id }, reload);
}
async function batchHandleDelete() {
await batchDelete({ ids: selectedRowKeys.value }, reload);
}
function handleSuccess() {
reload();
}
function getTableAction(record) {
return [{ label: '编辑', onClick: handleEdit.bind(null, record), auth: 'mes:mes_xsl_rubber_quick_test_record:edit' }];
}
function getDropDownAction(record) {
return [
{ label: '详情', onClick: handleDetail.bind(null, record) },
{
label: '删除',
popConfirm: { title: '是否确认删除', confirm: handleDelete.bind(null, record) },
auth: 'mes:mes_xsl_rubber_quick_test_record:delete',
},
];
}
</script>

View File

@@ -0,0 +1,166 @@
<template>
<BasicModal
v-bind="$attrs"
destroyOnClose
:title="title"
width="1100px"
@register="registerModal"
@ok="handleSubmit"
>
<BasicForm @register="registerForm">
<template #prodEquipmentPicker="{ model, field }">
<a-input-group compact style="display: flex; width: 100%">
<a-input v-model:value="model[field]" read-only placeholder="请选择生产机台" style="flex: 1" />
<a-button type="primary" :disabled="isDetail" @click="openProdEquipmentSelect">选择</a-button>
<a-button v-if="model.prodEquipmentLedgerId && !isDetail" @click="clearProdEquipment(model)">清除</a-button>
</a-input-group>
</template>
<template #inspectEquipmentPicker="{ model, field }">
<a-input-group compact style="display: flex; width: 100%">
<a-input v-model:value="model[field]" read-only placeholder="请选择检验机台" style="flex: 1" />
<a-button type="primary" :disabled="isDetail" @click="openInspectEquipmentSelect">选择</a-button>
<a-button v-if="model.inspectEquipmentLedgerId && !isDetail" @click="clearInspectEquipment(model)">清除</a-button>
</a-input-group>
</template>
</BasicForm>
<a-divider orientation="left">检验明细由实验标准带出不可增删</a-divider>
<JVxeTable
v-if="tableReady"
ref="lineTableRef"
row-number
keep-source
:toolbar="false"
:insert-row="false"
:remove-btn="false"
:max-height="380"
:loading="lineLoading"
:columns="lineJVxeColumns"
:dataSource="lineDataSource"
:disabled="isDetail"
/>
<MesXslEquipmentLedgerSelectModal @register="registerLedgerModal" @select="onLedgerSelect" />
</BasicModal>
</template>
<script lang="ts" setup>
import { computed, ref, unref } from 'vue';
import { BasicModal, useModalInner, useModal } from '/@/components/Modal';
import { BasicForm, useForm } from '/@/components/Form/index';
import type { JVxeTableInstance } from '/@/components/jeecg/JVxeTable/types';
import { useMessage } from '/@/hooks/web/useMessage';
import { formSchema, lineJVxeColumns } from '../MesXslRubberQuickTestRecord.data';
import { saveOrUpdate, queryById, queryLineListByRecordId } from '../MesXslRubberQuickTestRecord.api';
import MesXslEquipmentLedgerSelectModal from '/@/views/xslmes/mesXslEquipInspectConfig/components/MesXslEquipmentLedgerSelectModal.vue';
const emit = defineEmits(['register', 'success']);
const { createMessage } = useMessage();
const isDetail = ref(false);
const tableReady = ref(false);
const lineLoading = ref(false);
const lineDataSource = ref<Recordable[]>([]);
const lineTableRef = ref<JVxeTableInstance>();
const ledgerPickTarget = ref<'prod' | 'inspect'>('prod');
const [registerForm, { resetFields, setFieldsValue, validate, setProps, getFieldsValue }] = useForm({
labelWidth: 120,
schemas: formSchema,
showActionButtonGroup: false,
baseColProps: { span: 12 },
});
const [registerLedgerModal, { openModal: openLedgerModal }] = useModal();
const [registerModal, { setModalProps, closeModal }] = useModalInner(async (data) => {
tableReady.value = false;
lineDataSource.value = [];
await resetFields();
setModalProps({ confirmLoading: false, showCancelBtn: data?.showFooter, showOkBtn: data?.showFooter });
isDetail.value = !data?.showFooter;
setProps({ disabled: !data?.showFooter });
if (data?.record?.id) {
lineLoading.value = true;
try {
const mainRaw = await queryById({ id: data.record.id });
const m = (mainRaw as any)?.id != null ? mainRaw : (mainRaw as any)?.result ?? mainRaw;
const linesRaw = await queryLineListByRecordId({ id: data.record.id });
const list = Array.isArray(linesRaw) ? linesRaw : (linesRaw as any)?.result ?? [];
await setFieldsValue({ ...m });
lineDataSource.value = list || [];
} finally {
lineLoading.value = false;
}
}
tableReady.value = true;
});
const title = computed(() => (unref(isDetail) ? '快检记录详情' : '编辑胶料快检记录'));
function openProdEquipmentSelect() {
ledgerPickTarget.value = 'prod';
const vals = getFieldsValue();
openLedgerModal(true, { equipmentLedgerId: vals?.prodEquipmentLedgerId || '' });
}
function openInspectEquipmentSelect() {
ledgerPickTarget.value = 'inspect';
const vals = getFieldsValue();
openLedgerModal(true, { equipmentLedgerId: vals?.inspectEquipmentLedgerId || '' });
}
async function onLedgerSelect(payload: Recordable) {
if (ledgerPickTarget.value === 'prod') {
await setFieldsValue({
prodEquipmentLedgerId: payload.equipmentLedgerId || '',
prodEquipmentName: payload.equipmentName || '',
});
} else {
await setFieldsValue({
inspectEquipmentLedgerId: payload.equipmentLedgerId || '',
inspectEquipmentName: payload.equipmentName || '',
});
}
}
function clearProdEquipment(model: Recordable) {
model.prodEquipmentLedgerId = '';
model.prodEquipmentName = '';
}
function clearInspectEquipment(model: Recordable) {
model.inspectEquipmentLedgerId = '';
model.inspectEquipmentName = '';
}
async function handleSubmit() {
if (unref(isDetail)) {
closeModal();
return;
}
try {
const values = await validate();
const lineRef = lineTableRef.value as any;
const tableData = (lineRef?.getTableData?.() || lineDataSource.value || []) as Recordable[];
const lineList = tableData
.filter((r) => r && r.inspectItem)
.map((r) => ({
dataPointId: r.dataPointId,
inspectItem: r.inspectItem,
lowerLimit: r.lowerLimit,
inspectValue: r.inspectValue,
upperLimit: r.upperLimit,
}));
if (!lineList.length) {
createMessage.warning('检验明细不能为空');
return;
}
setModalProps({ confirmLoading: true });
await saveOrUpdate({ ...values, lineList }, true);
closeModal();
emit('success');
} finally {
setModalProps({ confirmLoading: false });
}
}
</script>