胶料快检实验类型、胶料快检数据点、胶料快检实验方法新增

This commit is contained in:
2026-05-25 11:01:00 +08:00
parent fa1c5c9b42
commit af8bf14b5e
44 changed files with 4476 additions and 1 deletions

View File

@@ -0,0 +1,64 @@
import { defHttp } from '/@/utils/http/axios';
import { useMessage } from '/@/hooks/web/useMessage';
const { createConfirm } = useMessage();
enum Api {
list = '/xslmes/mesXslRubberQuickTestMethod/list',
nextMethodCode = '/xslmes/mesXslRubberQuickTestMethod/nextMethodCode',
checkMethodName = '/xslmes/mesXslRubberQuickTestMethod/checkMethodName',
save = '/xslmes/mesXslRubberQuickTestMethod/add',
edit = '/xslmes/mesXslRubberQuickTestMethod/edit',
deleteOne = '/xslmes/mesXslRubberQuickTestMethod/delete',
deleteBatch = '/xslmes/mesXslRubberQuickTestMethod/deleteBatch',
importExcel = '/xslmes/mesXslRubberQuickTestMethod/importExcel',
exportXls = '/xslmes/mesXslRubberQuickTestMethod/exportXls',
queryById = '/xslmes/mesXslRubberQuickTestMethod/queryById',
queryLineList = '/xslmes/mesXslRubberQuickTestMethod/queryLineListByMethodId',
}
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 queryLineListByMethodId = (params: { id: string }) => defHttp.get({ url: Api.queryLineList, params });
export const fetchNextMethodCode = () => defHttp.get({ url: Api.nextMethodCode }, { successMessageMode: 'none' });
export const checkMethodName = (params: { methodName: string; dataId?: string }) =>
defHttp.get(

View File

@@ -0,0 +1,364 @@
import { BasicColumn, FormSchema } from '/@/components/Table';
import { JVxeColumn, JVxeTypes } from '/@/components/jeecg/JVxeTable/types';
import { checkMethodName } from './MesXslRubberQuickTestMethod.api';
export const columns: BasicColumn[] = [
{ title: '方法编号', align: 'center', dataIndex: 'methodCode', width: 100 },
{ title: '实验方法名称', align: 'center', dataIndex: 'methodName', width: 180 },
{ title: '实验类型', align: 'center', dataIndex: 'quickTestTypeName', width: 140 },
{ title: '实验温度°C', align: 'center', dataIndex: 'testTempC', width: 110 },
{ title: '预热时间min', align: 'center', dataIndex: 'preheatTimeMin', width: 110 },
{ title: '实验时间min', align: 'center', dataIndex: 'testTimeMin', width: 110 },
{ title: '转子类型', align: 'center', dataIndex: 'rotorType_dictText', width: 90 },
{ title: '创建人', align: 'center', dataIndex: 'createBy', width: 100 },
{
title: '创建时间',
align: 'center',
dataIndex: 'createTime',
width: 165,
customRender: ({ text }) => (!text ? '' : String(text).length > 19 ? String(text).substring(0, 19) : text),
},
];
export const searchFormSchema: FormSchema[] = [
{ label: '方法编号', field: 'methodCode', component: 'Input', colProps: { span: 6 } },
{ label: '实验方法名称', field: 'methodName', component: 'Input', colProps: { span: 6 } },
{
label: '实验类型',
field: 'quickTestTypeId',
component: 'JSearchSelect',
componentProps: {
dict: 'mes_xsl_rubber_quick_test_type,type_name,id',
async: true,
},
colProps: { span: 6 },
},
];
export const formSchema: FormSchema[] = [
{ label: '', field: 'id', component: 'Input', show: false },
{
label: '方法编号',
field: 'methodCode',
component: 'Input',
componentProps: { readonly: true, placeholder: '保存时从001起自动生成' },
},
{
label: '实验方法名称',
field: 'methodName',
component: 'Input',
required: true,
componentProps: { placeholder: '同租户内不可重复' },
dynamicRules: ({ model }) => [
{ required: true, message: '请输入实验方法名称' },
{
validator: async (_rule, value) => {
const v = value == null ? '' : String(value).trim();
if (!v) {
return Promise.resolve();
}
try {
await checkMethodName({ methodName: v, dataId: model?.id });
return Promise.resolve();
} catch (e: any) {
const msg = e?.response?.data?.message || e?.message || '实验方法名称已存在';
return Promise.reject(msg);
}
},
trigger: ['blur', 'change'],
},
],
},
{
label: '实验类型',
field: 'quickTestTypeId',
component: 'JSearchSelect',
required: true,
componentProps: {
dict: 'mes_xsl_rubber_quick_test_type,type_name,id',
async: true,
placeholder: '请选择实验类型',
},
},
{ label: '', field: 'quickTestTypeName', component: 'Input', show: false },
{
label: '实验温度°C',
field: 'testTempC',
component: 'InputNumber',
componentProps: { style: { width: '100%' }, precision: 2 },
},
{
label: '预热时间min',
field: 'preheatTimeMin',
component: 'InputNumber',
componentProps: { style: { width: '100%' }, precision: 2, min: 0 },
},
{
label: '实验时间min',
field: 'testTimeMin',
component: 'InputNumber',
componentProps: { style: { width: '100%' }, precision: 2, min: 0 },
},
{
label: '实验角度Deg',
field: 'testAngleDeg',
component: 'InputNumber',
componentProps: { style: { width: '100%' }, precision: 2 },
},
{
label: '实验频率Hz',
field: 'testFreqHz',
component: 'InputNumber',
componentProps: { style: { width: '100%' }, precision: 2, min: 0 },
},
{
label: '转子类型',
field: 'rotorType',
component: 'JDictSelectTag',
componentProps: { dictCode: 'xslmes_rubber_quick_test_rotor_type', placeholder: '大转子/小转子' },
},
{
label: '转子速度rpm',
field: 'rotorSpeedRpm',
component: 'InputNumber',
componentProps: { style: { width: '100%' }, precision: 2, min: 0 },
},
{
label: '方法描述',
field: 'methodDesc',
component: 'InputTextArea',
colProps: { span: 24 },
componentProps: { rows: 3, maxlength: 500 },
},
];
/** 明细行单位字典编码(与 Flyway / sys_dict 一致) */
export const LINE_UNIT_DICT_CODES = {
torque: 'xslmes_rubber_quick_test_torque_unit',
time: 'xslmes_rubber_quick_test_time_unit',
mooney: 'xslmes_rubber_quick_test_mooney_unit',
} as const;
/** 字典未加载时的兜底默认值(与字典 sort_order 首项一致) */
export const LINE_UNIT_DICT_FALLBACK = {
torqueUnitType: 'Ib.in',
timeUnitType: 'sec',
mooneyUnitType: 'MU',
};
/** 取字典排序后的第一项 value */
export function pickFirstDictItemValue(items: Recordable[] | null | undefined): string | undefined {
if (!items?.length) {
return undefined;
}
const sorted = [...items].sort(
(a, b) => Number(a.sortOrder ?? a.sort ?? 0) - Number(b.sortOrder ?? b.sort ?? 0),
);
const v = sorted[0]?.value;
return v != null && String(v) !== '' ? String(v) : undefined;
}
export const lineJVxeColumns: JVxeColumn[] = [
{ title: '', key: 'dataPointId', type: JVxeTypes.hidden },
{ title: '数据点', key: 'pointName', type: JVxeTypes.normal, width: 160, disabled: true },
{ title: '单位类型', key: 'unitType', type: JVxeTypes.normal, width: 120, disabled: true },
{
title: '扭矩单位类型',
key: 'torqueUnitType',
type: JVxeTypes.select,
width: 130,
dictCode: 'xslmes_rubber_quick_test_torque_unit',
allowClear: false,
placeholder: '请选择',
validateRules: [{ required: true, message: '${title}不能为空' }],
},
{
title: '时间单位类型',
key: 'timeUnitType',
type: JVxeTypes.select,
width: 120,
dictCode: 'xslmes_rubber_quick_test_time_unit',
allowClear: false,
placeholder: '请选择',
validateRules: [{ required: true, message: '${title}不能为空' }],
},
{
title: '门尼单位类型',
key: 'mooneyUnitType',
type: JVxeTypes.select,
width: 120,
dictCode: 'xslmes_rubber_quick_test_mooney_unit',
allowClear: false,
placeholder: '请选择',
validateRules: [{ required: true, message: '${title}不能为空' }],
},
];

View File

@@ -0,0 +1,136 @@
<template>
<div>
<BasicTable @register="registerTable" :rowSelection="rowSelection">
<template #tableTitle>
<a-button
type="primary"
v-auth="'mes:mes_xsl_rubber_quick_test_method:add'"
@click="handleAdd"
preIcon="ant-design:plus-outlined"
>
新增
</a-button>
<a-button
type="primary"
v-auth="'mes:mes_xsl_rubber_quick_test_method:exportXls'"
preIcon="ant-design:export-outlined"
@click="onExportXls"
>
导出
</a-button>
<j-upload-button
type="primary"
v-auth="'mes:mes_xsl_rubber_quick_test_method: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_method:deleteBatch'">
批量操作
<Icon icon="mdi:chevron-down" />
</a-button>
</a-dropdown>
</template>
<template #action="{ record }">
<TableAction
:actions="[
{
label: '编辑',
onClick: handleEdit.bind(null, record),
auth: 'mes:mes_xsl_rubber_quick_test_method:edit',
},
]"
:dropDownActions="getDropDownAction(record)"
/>
</template>
</BasicTable>
<MesXslRubberQuickTestMethodModal @register="registerModal" @success="handleSuccess" />
</div>
</template>
<script lang="ts" name="xslmes-mesXslRubberQuickTestMethod" setup>
import { BasicTable, TableAction } from '/@/components/Table';
import { useModal } from '/@/components/Modal';
import { useListPage } from '/@/hooks/system/useListPage';
import Icon from '/@/components/Icon';
import MesXslRubberQuickTestMethodModal from './components/MesXslRubberQuickTestMethodModal.vue';
import { columns, searchFormSchema } from './MesXslRubberQuickTestMethod.data';
import { list, deleteOne, batchDelete, getExportUrl, getImportUrl } from './MesXslRubberQuickTestMethod.api';

View File

@@ -0,0 +1,78 @@
<template>
<BasicModal v-bind="$attrs" :title="modalTitle" :width="1000" @register="registerModal" @ok="handleOk">
<BasicTable @register="registerTable" />
</BasicModal>
</template>
<script lang="ts" setup>
import { computed, ref } from 'vue';
import { BasicModal, useModalInner } from '/@/components/Modal';
import { BasicTable, useTable } from '/@/components/Table';
import { list } from '/@/views/xslmes/mesXslRubberQuickTestDataPoint/MesXslRubberQuickTestDataPoint.api';
const emit = defineEmits(['register', 'select']);
const filterQuickTestTypeId = ref('');
const selectedRows = ref<Recordable[]>([]);
const modalTitle = computed(() => '选择数据点(可多选)');
function handleSelectionChange(_keys: string[], rows: Recordable[]) {
selectedRows.value = rows || [];
}
function fetchPointPage(params: Recordable) {
const p = { ...params };
if (filterQuickTestTypeId.value) {
p.quickTestTypeId = filterQuickTestTypeId.value;
}
return list(p);
}
const [registerTable, { reload, getSelectRows, clearSelectedRowKeys }] = useTable({
api: fetchPointPage,
columns: [
{ title: '数据点名称', dataIndex: 'pointName', width: 160 },
{ title: '实验类型', dataIndex: 'quickTestTypeName', width: 140 },
{ title: '单位类型', dataIndex: 'unitType', width: 120 },
{ title: '描述', dataIndex: 'pointDesc', width: 200, ellipsis: true },
],

View File

@@ -0,0 +1,478 @@
<template>
<BasicModal
v-bind="$attrs"
destroyOnClose
:title="title"
width="1100px"
@register="registerModal"
@ok="handleSubmit"
>
<BasicForm @register="registerForm" />
<a-divider orientation="left">数据点明细</a-divider>
<JVxeTable
v-if="tableReady"
ref="lineTableRef"
toolbar
row-number
rowSelection
keep-source
:insert-row="false"
:max-height="380"
:loading="lineLoading"
:columns="lineJVxeColumns"
:dataSource="lineDataSource"
:disabled="!showFooterFlag"
:toolbar-config="{ btn: ['remove'], slots: ['suffix'] }"
:add-btn-cfg="{ enabled: false }"
>
<template #toolbarSuffix>
<a-button
v-if="showFooterFlag"
type="primary"
preIcon="ant-design:plus-outlined"
@click="openDataPointSelect"
>
选择数据点
</a-button>
</template>
</JVxeTable>
<MesXslRubberQuickTestDataPointSelectModal @register="registerPointModal" @select="onDataPointsSelect" />
</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 { initDictOptions } from '/@/utils/dict';
import {
formSchema,
lineJVxeColumns,
LINE_UNIT_DICT_CODES,
LINE_UNIT_DICT_FALLBACK,
pickFirstDictItemValue,
} from '../MesXslRubberQuickTestMethod.data';
import {
saveOrUpdate,
queryById,
queryLineListByMethodId,
fetchNextMethodCode,
} from '../MesXslRubberQuickTestMethod.api';
import MesXslRubberQuickTestDataPointSelectModal from './MesXslRubberQuickTestDataPointSelectModal.vue';
const emit = defineEmits(['register', 'success']);
const { createMessage } = useMessage();
const isUpdate = ref(false);
const isDetail = ref(false);
const showFooterFlag = ref(true);
const tableReady = ref(false);
const lineLoading = ref(false);
const lineDataSource = ref<Recordable[]>([]);
const lineTableRef = ref<JVxeTableInstance>();
const defaultLineUnits = ref({ ...LINE_UNIT_DICT_FALLBACK });
async function loadDefaultLineUnits() {
try {
const [torque, time, mooney] = await Promise.all([
initDictOptions(LINE_UNIT_DICT_CODES.torque),
initDictOptions(LINE_UNIT_DICT_CODES.time),
initDictOptions(LINE_UNIT_DICT_CODES.mooney),
]);
defaultLineUnits.value = {
torqueUnitType: pickFirstDictItemValue(torque) ?? LINE_UNIT_DICT_FALLBACK.torqueUnitType,
timeUnitType: pickFirstDictItemValue(time) ?? LINE_UNIT_DICT_FALLBACK.timeUnitType,
mooneyUnitType: pickFirstDictItemValue(mooney) ?? LINE_UNIT_DICT_FALLBACK.mooneyUnitType,
};
} catch {
defaultLineUnits.value = { ...LINE_UNIT_DICT_FALLBACK };
}
}
function applyDefaultLineUnits(row: Recordable): Recordable {
const d = defaultLineUnits.value;
return {
...row,
torqueUnitType: row.torqueUnitType || d.torqueUnitType,
timeUnitType: row.timeUnitType || d.timeUnitType,
mooneyUnitType: row.mooneyUnitType || d.mooneyUnitType,
};
}
const [registerForm, { resetFields, setFieldsValue, validate, setProps, getFieldsValue }] = useForm({
labelWidth: 120,
schemas: formSchema,
showActionButtonGroup: false,
baseColProps: { span: 12 },
});
const [registerPointModal, { openModal: openPointModal }] = useModal();
const [registerModal, { setModalProps, closeModal }] = useModalInner(async (data) => {
tableReady.value = false;
lineDataSource.value = [];
await resetFields();
await loadDefaultLineUnits();
setModalProps({ confirmLoading: false, showCancelBtn: data?.showFooter, showOkBtn: data?.showFooter });
isUpdate.value = !!data?.isUpdate;
isDetail.value = !data?.showFooter;
showFooterFlag.value = !!data?.showFooter;
setProps({ disabled: !data?.showFooter });
if (unref(isUpdate) && 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 queryLineListByMethodId({ id: data.record.id });
const list = Array.isArray(linesRaw) ? linesRaw : (linesRaw as any)?.result ?? [];
await setFieldsValue({ ...m });
lineDataSource.value = (list || []).map((row) => applyDefaultLineUnits(row));
} finally {
lineLoading.value = false;
}
} else {
try {
const nextCode = await fetchNextMethodCode();
await setFieldsValue({ methodCode: nextCode });
} catch {
await setFieldsValue({ methodCode: '' });
}
}
tableReady.value = true;
});
const title = computed(() =>
!unref(isUpdate) ? '新增胶料快检实验方法' : unref(isDetail) ? '实验方法详情' : '编辑胶料快检实验方法',
);
function pointToLineRow(point: Recordable) {
const d = defaultLineUnits.value;
return {
dataPointId: point.id,
pointName: point.pointName,
unitType: point.unitType,
torqueUnitType: d.torqueUnitType,
timeUnitType: d.timeUnitType,
mooneyUnitType: d.mooneyUnitType,
};
}
function getExistingPointIds(): Set<string> {
const lineRef = lineTableRef.value as any;
const tableData = (lineRef?.getTableData?.() || lineDataSource.value || []) as Recordable[];
const ids = new Set<string>();
for (const r of tableData) {
if (r?.dataPointId) {
ids.add(String(r.dataPointId));
}
}
return ids;
}
function openDataPointSelect() {
const vals = getFieldsValue();
if (!vals?.quickTestTypeId) {
createMessage.warning('请先选择实验类型');
return;
}
openPointModal(true, { quickTestTypeId: vals.quickTestTypeId });
}
function onDataPointsSelect(payload: Recordable | Recordable[]) {
const points = Array.isArray(payload) ? payload : payload ? [payload] : [];
if (!points.length) {
return;
}
const existing = getExistingPointIds();
const toAdd: Recordable[] = [];
const skipped: string[] = [];
for (const point of points) {
if (!point?.id) {
continue;
}
const id = String(point.id);
if (existing.has(id)) {
skipped.push(point.pointName || id);
continue;
}
existing.add(id);
toAdd.push(pointToLineRow(point));
}
if (!toAdd.length) {
if (skipped.length) {
createMessage.warning('所选数据点均已在明细中,未添加新行');
}
return;
}
const lineRef = lineTableRef.value as any;
if (lineRef?.pushRows) {
lineRef.pushRows(toAdd);
} else {
lineDataSource.value = [...lineDataSource.value, ...toAdd];
}
if (skipped.length) {
createMessage.warning(`已添加 ${toAdd.length} 项,跳过 ${skipped.length} 项重复数据点`);
}
}
async function handleSubmit() {
try {
const values = await validate();
const lineRef = lineTableRef.value as any;
const tableData = (lineRef?.getTableData?.() || []) as Recordable[];
const lineList = tableData
.filter((r) => r && r.dataPointId)
.map((r) => {
const row = applyDefaultLineUnits(r);
return {
dataPointId: row.dataPointId,
pointName: row.pointName,
unitType: row.unitType,
torqueUnitType: row.torqueUnitType,
timeUnitType: row.timeUnitType,
mooneyUnitType: row.mooneyUnitType,
};
});
if (!lineList.length) {
createMessage.warning('请通过「选择数据点」至少添加一条明细');
return;
}
const ids = new Set<string>();
for (const line of lineList) {
if (ids.has(line.dataPointId)) {
createMessage.warning('明细中数据点不能重复');
return;
}
ids.add(line.dataPointId);
}
setModalProps({ confirmLoading: true });
await saveOrUpdate({ ...values, lineList }, unref(isUpdate));
closeModal();
emit('success');
} finally {
setModalProps({ confirmLoading: false });
}
}
</script>