快检实验标准新增
This commit is contained in:
@@ -0,0 +1,68 @@
|
||||
import { defHttp } from '/@/utils/http/axios';
|
||||
import { useMessage } from '/@/hooks/web/useMessage';
|
||||
|
||||
const { createConfirm } = useMessage();
|
||||
|
||||
enum Api {
|
||||
list = '/xslmes/mesXslRubberQuickTestStd/list',
|
||||
checkStdName = '/xslmes/mesXslRubberQuickTestStd/checkStdName',
|
||||
save = '/xslmes/mesXslRubberQuickTestStd/add',
|
||||
edit = '/xslmes/mesXslRubberQuickTestStd/edit',
|
||||
deleteOne = '/xslmes/mesXslRubberQuickTestStd/delete',
|
||||
deleteBatch = '/xslmes/mesXslRubberQuickTestStd/deleteBatch',
|
||||
importExcel = '/xslmes/mesXslRubberQuickTestStd/importExcel',
|
||||
exportXls = '/xslmes/mesXslRubberQuickTestStd/exportXls',
|
||||
queryById = '/xslmes/mesXslRubberQuickTestStd/queryById',
|
||||
queryLineList = '/xslmes/mesXslRubberQuickTestStd/queryLineListByStdId',
|
||||
updateStatus = '/xslmes/mesXslRubberQuickTestStd/updateStatus',
|
||||
}
|
||||
|
||||
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 queryLineListByStdId = (params: { id: string }) => defHttp.get({ url: Api.queryLineList, params });
|
||||
|
||||
export const checkStdName = (params: { stdName: string; dataId?: string }) =>
|
||||
defHttp.get(
|
||||
{ url: Api.checkStdName, params },
|
||||
{
|
||||
successMessageMode: 'none',
|
||||
errorMessageMode: 'none',
|
||||
},
|
||||
);
|
||||
|
||||
export const updateStatus = (params: { id: string; enableStatus: string }, handleSuccess?: () => void) => {
|
||||
return defHttp.post({ url: Api.updateStatus, params }, { joinParamsToUrl: true }).then(() => {
|
||||
handleSuccess?.();
|
||||
});
|
||||
};
|
||||
|
||||
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 });
|
||||
};
|
||||
@@ -0,0 +1,155 @@
|
||||
import { BasicColumn, FormSchema } from '/@/components/Table';
|
||||
import { JVxeColumn, JVxeTypes } from '/@/components/jeecg/JVxeTable/types';
|
||||
import { checkStdName } from './MesXslRubberQuickTestStd.api';
|
||||
|
||||
const numProps = { style: { width: '100%' }, precision: 6 };
|
||||
|
||||
export const columns: BasicColumn[] = [
|
||||
{ title: '实验标准名称', align: 'center', dataIndex: 'stdName', width: 180 },
|
||||
{ title: '实验方法', align: 'center', dataIndex: 'testMethodName', width: 160 },
|
||||
{ title: '密炼机类型', align: 'center', dataIndex: 'mixerType_dictText', width: 110 },
|
||||
{ title: '胶料名称', align: 'center', dataIndex: 'rubberMaterialName', width: 140 },
|
||||
{ title: '发行编号', align: 'center', dataIndex: 'issueNumber', width: 120 },
|
||||
{ title: '发行日期', align: 'center', dataIndex: 'issueDate', width: 110 },
|
||||
{ title: '发行部门', align: 'center', dataIndex: 'issueDeptName', width: 140 },
|
||||
{ title: '启用状态', align: 'center', dataIndex: 'enableStatus_dictText', width: 90 },
|
||||
{ title: '审核状态', align: 'center', dataIndex: 'auditStatus_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: 'stdName', component: 'Input', colProps: { span: 6 } },
|
||||
{ label: '实验方法', field: 'testMethodName', component: 'Input', colProps: { span: 6 } },
|
||||
{ label: '胶料名称', field: 'rubberMaterialName', component: 'Input', colProps: { span: 6 } },
|
||||
{
|
||||
label: '启用状态',
|
||||
field: 'enableStatus',
|
||||
component: 'JDictSelectTag',
|
||||
componentProps: { dictCode: 'xslmes_rubber_quick_test_std_enable_status' },
|
||||
colProps: { span: 6 },
|
||||
},
|
||||
];
|
||||
|
||||
export const formSchema: FormSchema[] = [
|
||||
{ label: '', field: 'id', component: 'Input', show: false },
|
||||
{ label: '', field: 'testMethodId', component: 'Input', show: false },
|
||||
{ label: '', field: 'rubberMaterialId', component: 'Input', show: false },
|
||||
{ label: '', field: 'psCompileId', component: 'Input', show: false },
|
||||
{ label: '', field: 'issueDeptId', component: 'Input', show: false },
|
||||
{ label: '', field: 'enableStatus', component: 'Input', show: false },
|
||||
{ label: '', field: 'auditStatus', component: 'Input', show: false },
|
||||
{
|
||||
label: '实验标准名称',
|
||||
field: 'stdName',
|
||||
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 checkStdName({ stdName: 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: 'testMethodName',
|
||||
component: 'Input',
|
||||
slot: 'testMethodPicker',
|
||||
required: true,
|
||||
dynamicRules: () => [{ required: true, message: '请选择实验方法' }],
|
||||
},
|
||||
{
|
||||
label: '密炼机类型',
|
||||
field: 'mixerType',
|
||||
component: 'JDictSelectTag',
|
||||
required: true,
|
||||
componentProps: { dictCode: 'xslmes_rubber_quick_test_mixer_type', placeholder: '请选择密炼机类型' },
|
||||
},
|
||||
{
|
||||
label: '胶料名称',
|
||||
field: 'rubberMaterialName',
|
||||
component: 'Input',
|
||||
slot: 'rubberMaterialPicker',
|
||||
required: true,
|
||||
dynamicRules: () => [{ required: true, message: '请选择胶料信息' }],
|
||||
},
|
||||
{
|
||||
label: '发行编号',
|
||||
field: 'issueNumber',
|
||||
component: 'Input',
|
||||
slot: 'issueNumberPicker',
|
||||
},
|
||||
{
|
||||
label: '发行日期',
|
||||
field: 'issueDate',
|
||||
component: 'DatePicker',
|
||||
componentProps: { valueFormat: 'YYYY-MM-DD', style: { width: '100%' } },
|
||||
},
|
||||
{
|
||||
label: '发行部门',
|
||||
field: 'issueDeptName',
|
||||
component: 'Input',
|
||||
slot: 'issueDeptPicker',
|
||||
},
|
||||
];
|
||||
|
||||
export const lineJVxeColumns: JVxeColumn[] = [
|
||||
{ title: '', key: 'dataPointId', type: JVxeTypes.hidden },
|
||||
{ title: '数据点', key: 'pointName', type: JVxeTypes.normal, width: 180, disabled: true },
|
||||
{
|
||||
title: '下限值',
|
||||
key: 'lowerLimit',
|
||||
type: JVxeTypes.inputNumber,
|
||||
width: 110,
|
||||
componentProps: numProps,
|
||||
},
|
||||
{
|
||||
title: '下警告值',
|
||||
key: 'lowerWarn',
|
||||
type: JVxeTypes.inputNumber,
|
||||
width: 110,
|
||||
componentProps: numProps,
|
||||
},
|
||||
{
|
||||
title: '目标值',
|
||||
key: 'targetValue',
|
||||
type: JVxeTypes.inputNumber,
|
||||
width: 110,
|
||||
componentProps: numProps,
|
||||
},
|
||||
{
|
||||
title: '上警告值',
|
||||
key: 'upperWarn',
|
||||
type: JVxeTypes.inputNumber,
|
||||
width: 110,
|
||||
componentProps: numProps,
|
||||
},
|
||||
{
|
||||
title: '上限值',
|
||||
key: 'upperLimit',
|
||||
type: JVxeTypes.inputNumber,
|
||||
width: 110,
|
||||
componentProps: numProps,
|
||||
},
|
||||
];
|
||||
@@ -0,0 +1,158 @@
|
||||
<template>
|
||||
<div>
|
||||
<BasicTable @register="registerTable" :rowSelection="rowSelection">
|
||||
<template #tableTitle>
|
||||
<a-button
|
||||
type="primary"
|
||||
v-auth="'mes:mes_xsl_rubber_quick_test_std:add'"
|
||||
@click="handleAdd"
|
||||
preIcon="ant-design:plus-outlined"
|
||||
>
|
||||
新增
|
||||
</a-button>
|
||||
<a-button
|
||||
type="primary"
|
||||
v-auth="'mes:mes_xsl_rubber_quick_test_std:exportXls'"
|
||||
preIcon="ant-design:export-outlined"
|
||||
@click="onExportXls"
|
||||
>
|
||||
导出
|
||||
</a-button>
|
||||
<j-upload-button
|
||||
type="primary"
|
||||
v-auth="'mes:mes_xsl_rubber_quick_test_std: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_std:deleteBatch'">
|
||||
批量操作
|
||||
<Icon icon="mdi:chevron-down" />
|
||||
</a-button>
|
||||
</a-dropdown>
|
||||
</template>
|
||||
<template #action="{ record }">
|
||||
<TableAction :actions="getTableAction(record)" :dropDownActions="getDropDownAction(record)" />
|
||||
</template>
|
||||
</BasicTable>
|
||||
<MesXslRubberQuickTestStdModal @register="registerModal" @success="handleSuccess" />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script lang="ts" name="xslmes-mesXslRubberQuickTestStd" setup>
|
||||
import { BasicTable, TableAction } from '/@/components/Table';
|
||||
import { useModal } from '/@/components/Modal';
|
||||
import { useListPage } from '/@/hooks/system/useListPage';
|
||||
import Icon from '/@/components/Icon';
|
||||
import MesXslRubberQuickTestStdModal from './components/MesXslRubberQuickTestStdModal.vue';
|
||||
import { columns, searchFormSchema } from './MesXslRubberQuickTestStd.data';
|
||||
import { list, deleteOne, batchDelete, getExportUrl, getImportUrl, updateStatus } from './MesXslRubberQuickTestStd.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: 220,
|
||||
fixed: 'right',
|
||||
},
|
||||
},
|
||||
exportConfig: {
|
||||
name: '胶料快检实验标准',
|
||||
url: getExportUrl,
|
||||
},
|
||||
importConfig: {
|
||||
url: getImportUrl,
|
||||
success: handleSuccess,
|
||||
},
|
||||
});
|
||||
|
||||
const [registerTable, { reload }, { rowSelection, selectedRowKeys }] = tableContext;
|
||||
|
||||
function handleAdd() {
|
||||
openModal(true, { isUpdate: false, showFooter: true });
|
||||
}
|
||||
|
||||
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 }, handleSuccess);
|
||||
}
|
||||
|
||||
function isRecordEnabled(record: Recordable) {
|
||||
return record.enableStatus === '1' || record.enableStatus === 1;
|
||||
}
|
||||
|
||||
async function handleToggleStatus(record: Recordable, enableStatus: string) {
|
||||
await updateStatus({ id: record.id, enableStatus }, handleSuccess);
|
||||
}
|
||||
|
||||
async function batchHandleDelete() {
|
||||
await batchDelete({ ids: selectedRowKeys.value }, handleSuccess);
|
||||
}
|
||||
|
||||
function handleSuccess() {
|
||||
selectedRowKeys.value = [];
|
||||
reload();
|
||||
}
|
||||
|
||||
function getTableAction(record) {
|
||||
return [
|
||||
{
|
||||
label: '编辑',
|
||||
onClick: handleEdit.bind(null, record),
|
||||
auth: 'mes:mes_xsl_rubber_quick_test_std:edit',
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
function getDropDownAction(record) {
|
||||
const enabled = isRecordEnabled(record);
|
||||
return [
|
||||
{ label: '详情', onClick: handleDetail.bind(null, record) },
|
||||
{
|
||||
label: '启用',
|
||||
ifShow: !enabled,
|
||||
onClick: handleToggleStatus.bind(null, record, '1'),
|
||||
auth: 'mes:mes_xsl_rubber_quick_test_std:updateStatus',
|
||||
},
|
||||
{
|
||||
label: '停用',
|
||||
ifShow: enabled,
|
||||
onClick: handleToggleStatus.bind(null, record, '0'),
|
||||
auth: 'mes:mes_xsl_rubber_quick_test_std:updateStatus',
|
||||
},
|
||||
{
|
||||
label: '删除',
|
||||
popConfirm: { title: '是否确认删除', confirm: handleDelete.bind(null, record) },
|
||||
auth: 'mes:mes_xsl_rubber_quick_test_std:delete',
|
||||
},
|
||||
];
|
||||
}
|
||||
</script>
|
||||
@@ -0,0 +1,91 @@
|
||||
<template>
|
||||
<BasicModal v-bind="$attrs" title="选择实验方法" :width="960" @register="registerModal" @ok="handleOk">
|
||||
<BasicTable @register="registerTable" />
|
||||
</BasicModal>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { ref } from 'vue';
|
||||
import { BasicModal, useModalInner } from '/@/components/Modal';
|
||||
import { BasicTable, useTable } from '/@/components/Table';
|
||||
import type { FormSchema } from '/@/components/Table';
|
||||
import { list as methodList, queryById as queryMethodById } from '../../mesXslRubberQuickTestMethod/MesXslRubberQuickTestMethod.api';
|
||||
import { columns as methodColumns } from '../../mesXslRubberQuickTestMethod/MesXslRubberQuickTestMethod.data';
|
||||
import { useMessage } from '/@/hooks/web/useMessage';
|
||||
|
||||
const emit = defineEmits(['register', 'select']);
|
||||
const { createMessage } = useMessage();
|
||||
|
||||
const selectSearchSchema: FormSchema[] = [
|
||||
{ label: '方法编号', field: 'methodCode', component: 'JInput', colProps: { span: 8 } },
|
||||
{ label: '实验方法名称', field: 'methodName', component: 'JInput', colProps: { span: 8 } },
|
||||
];
|
||||
|
||||
const selectedRow = ref<Recordable | null>(null);
|
||||
|
||||
const [registerTable, { reload, getSelectRowKeys, getSelectRows, setSelectedRowKeys, clearSelectedRowKeys }] = useTable({
|
||||
api: methodList,
|
||||
columns: methodColumns.slice(0, 4),
|
||||
rowKey: 'id',
|
||||
useSearchForm: true,
|
||||
formConfig: {
|
||||
labelWidth: 100,
|
||||
schemas: selectSearchSchema,
|
||||
},
|
||||
pagination: { pageSize: 10 },
|
||||
canResize: false,
|
||||
showIndexColumn: false,
|
||||
immediate: true,
|
||||
rowSelection: {
|
||||
type: 'radio',
|
||||
columnWidth: 48,
|
||||
onChange: (_keys, rows) => {
|
||||
selectedRow.value = rows?.[0] ?? null;
|
||||
},
|
||||
},
|
||||
clickToRowSelect: true,
|
||||
});
|
||||
|
||||
const [registerModal, { setModalProps, closeModal }] = useModalInner(async (data) => {
|
||||
selectedRow.value = null;
|
||||
clearSelectedRowKeys?.();
|
||||
setModalProps({ confirmLoading: false });
|
||||
const methodId = data?.testMethodId as string | undefined;
|
||||
if (methodId) {
|
||||
setSelectedRowKeys?.([methodId]);
|
||||
try {
|
||||
const raw = await queryMethodById({ id: methodId });
|
||||
const row = (raw as Recordable)?.methodName != null ? raw : (raw as Recordable)?.result;
|
||||
if (row) {
|
||||
selectedRow.value = row;
|
||||
}
|
||||
} catch {
|
||||
// ignore
|
||||
}
|
||||
}
|
||||
reload();
|
||||
});
|
||||
|
||||
async function handleOk() {
|
||||
const keys = (getSelectRowKeys?.() || []) as string[];
|
||||
let row = selectedRow.value || ((getSelectRows?.() || []) as Recordable[])[0];
|
||||
if (!row && keys.length) {
|
||||
try {
|
||||
const raw = await queryMethodById({ id: keys[0] });
|
||||
row = (raw as Recordable)?.methodName != null ? raw : (raw as Recordable)?.result;
|
||||
} catch {
|
||||
// ignore
|
||||
}
|
||||
}
|
||||
if (!row?.id) {
|
||||
createMessage.warning('请选择一条实验方法');
|
||||
return;
|
||||
}
|
||||
emit('select', {
|
||||
testMethodId: row.id,
|
||||
testMethodName: row.methodName || '',
|
||||
methodCode: row.methodCode || '',
|
||||
});
|
||||
closeModal();
|
||||
}
|
||||
</script>
|
||||
@@ -0,0 +1,104 @@
|
||||
<template>
|
||||
<BasicModal v-bind="$attrs" title="选择发行编号(原材料检验标准)" :width="960" @register="registerModal" @ok="handleOk">
|
||||
<BasicTable @register="registerTable" />
|
||||
</BasicModal>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { ref } from 'vue';
|
||||
import { BasicModal, useModalInner } from '/@/components/Modal';
|
||||
import { BasicTable, useTable } from '/@/components/Table';
|
||||
import type { FormSchema } from '/@/components/Table';
|
||||
import { list as mixerPsList, queryById as queryMixerPsById } from '../../mesXslMixerPsCompile/MesXslMixerPsCompile.api';
|
||||
import { columns as mixerPsColumns } from '../../mesXslMixerPsCompile/MesXslMixerPsCompile.data';
|
||||
import { useMessage } from '/@/hooks/web/useMessage';
|
||||
|
||||
const emit = defineEmits(['register', 'select']);
|
||||
const { createMessage } = useMessage();
|
||||
|
||||
/** 密炼PS类型:原材料检验标准 */
|
||||
const PS_TYPE_RAW_INSPECT_STD = 'raw_inspect_std';
|
||||
|
||||
const selectSearchSchema: FormSchema[] = [
|
||||
{ label: 'PS编码', field: 'psCode', component: 'JInput', colProps: { span: 8 } },
|
||||
{ label: '标题', field: 'title', component: 'JInput', colProps: { span: 8 } },
|
||||
];
|
||||
|
||||
const selectedRow = ref<Recordable | null>(null);
|
||||
|
||||
const [registerTable, { reload, getSelectRowKeys, getSelectRows, setSelectedRowKeys, clearSelectedRowKeys }] = useTable({
|
||||
api: mixerPsList,
|
||||
columns: mixerPsColumns.slice(0, 7),
|
||||
rowKey: 'id',
|
||||
useSearchForm: true,
|
||||
formConfig: {
|
||||
labelWidth: 90,
|
||||
schemas: selectSearchSchema,
|
||||
},
|
||||
pagination: { pageSize: 10 },
|
||||
canResize: false,
|
||||
showIndexColumn: false,
|
||||
immediate: true,
|
||||
beforeFetch: (params) => ({
|
||||
...params,
|
||||
psType: PS_TYPE_RAW_INSPECT_STD,
|
||||
}),
|
||||
rowSelection: {
|
||||
type: 'radio',
|
||||
columnWidth: 48,
|
||||
onChange: (_keys, rows) => {
|
||||
selectedRow.value = rows?.[0] ?? null;
|
||||
},
|
||||
},
|
||||
clickToRowSelect: true,
|
||||
});
|
||||
|
||||
const [registerModal, { setModalProps, closeModal }] = useModalInner(async (data) => {
|
||||
selectedRow.value = null;
|
||||
clearSelectedRowKeys?.();
|
||||
setModalProps({ confirmLoading: false });
|
||||
const psId = data?.psCompileId as string | undefined;
|
||||
if (psId) {
|
||||
setSelectedRowKeys?.([psId]);
|
||||
try {
|
||||
const raw = await queryMixerPsById({ id: psId });
|
||||
const row = (raw as Recordable)?.psCode != null ? raw : (raw as Recordable)?.result;
|
||||
if (row) {
|
||||
selectedRow.value = row;
|
||||
}
|
||||
} catch {
|
||||
// ignore
|
||||
}
|
||||
}
|
||||
reload();
|
||||
});
|
||||
|
||||
async function handleOk() {
|
||||
const keys = (getSelectRowKeys?.() || []) as string[];
|
||||
let row = selectedRow.value || ((getSelectRows?.() || []) as Recordable[])[0];
|
||||
if (!row && keys.length) {
|
||||
try {
|
||||
const raw = await queryMixerPsById({ id: keys[0] });
|
||||
row = (raw as Recordable)?.psCode != null ? raw : (raw as Recordable)?.result;
|
||||
} catch {
|
||||
// ignore
|
||||
}
|
||||
}
|
||||
if (!row?.id) {
|
||||
createMessage.warning('请选择一条密炼PS');
|
||||
return;
|
||||
}
|
||||
if (row.psType && row.psType !== PS_TYPE_RAW_INSPECT_STD) {
|
||||
createMessage.warning('仅可选择类型为原材料检验标准的密炼PS');
|
||||
return;
|
||||
}
|
||||
emit('select', {
|
||||
psCompileId: row.id,
|
||||
issueNumber: row.psCode || '',
|
||||
issueDate: row.issueDate || undefined,
|
||||
issueDeptId: row.sendDeptId || undefined,
|
||||
issueDeptName: row.sendDeptId_dictText || undefined,
|
||||
});
|
||||
closeModal();
|
||||
}
|
||||
</script>
|
||||
@@ -0,0 +1,290 @@
|
||||
<template>
|
||||
<BasicModal
|
||||
v-bind="$attrs"
|
||||
destroyOnClose
|
||||
:title="title"
|
||||
width="1100px"
|
||||
@register="registerModal"
|
||||
@ok="handleSubmit"
|
||||
>
|
||||
<BasicForm @register="registerForm">
|
||||
<template #testMethodPicker="{ 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="openMethodSelect">选择</a-button>
|
||||
</a-input-group>
|
||||
</template>
|
||||
<template #rubberMaterialPicker="{ 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="openMaterialSelect">选择</a-button>
|
||||
</a-input-group>
|
||||
</template>
|
||||
<template #issueNumberPicker="{ 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="openPsSelect">选择</a-button>
|
||||
<a-button v-if="model.issueNumber && !isDetail" @click="clearIssueNumber(model)">清除</a-button>
|
||||
</a-input-group>
|
||||
</template>
|
||||
<template #issueDeptPicker="{ 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="openDeptSelect">选择</a-button>
|
||||
<a-button v-if="model.issueDeptId && !isDetail" @click="clearIssueDept(model)">清除</a-button>
|
||||
</a-input-group>
|
||||
</template>
|
||||
</BasicForm>
|
||||
<a-divider orientation="left">标准明细(由实验方法带出数据点,不可增删)</a-divider>
|
||||
<JVxeTable
|
||||
v-if="tableReady"
|
||||
ref="lineTableRef"
|
||||
toolbar
|
||||
row-number
|
||||
keep-source
|
||||
:insert-row="false"
|
||||
:remove-btn="false"
|
||||
:max-height="380"
|
||||
:loading="lineLoading"
|
||||
:columns="lineJVxeColumns"
|
||||
:dataSource="lineDataSource"
|
||||
:disabled="isDetail"
|
||||
:toolbar-config="{ btn: [] }"
|
||||
:add-btn-cfg="{ enabled: false }"
|
||||
/>
|
||||
<MesXslRubberQuickTestMethodSelectModal @register="registerMethodModal" @select="onMethodSelect" />
|
||||
<MesMaterialSelectModal @register="registerMaterialModal" @select="onMaterialSelect" />
|
||||
<MesXslRubberQuickTestStdMixerPsSelectModal @register="registerPsModal" @select="onPsSelect" />
|
||||
<DeptSelectModal @register="registerDeptModal" @getSelectResult="onIssueDeptSelect" />
|
||||
</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 '../MesXslRubberQuickTestStd.data';
|
||||
import { saveOrUpdate, queryById, queryLineListByStdId } from '../MesXslRubberQuickTestStd.api';
|
||||
import { queryLineListByMethodId } from '../../mesXslRubberQuickTestMethod/MesXslRubberQuickTestMethod.api';
|
||||
import MesXslRubberQuickTestMethodSelectModal from './MesXslRubberQuickTestMethodSelectModal.vue';
|
||||
import MesXslRubberQuickTestStdMixerPsSelectModal from './MesXslRubberQuickTestStdMixerPsSelectModal.vue';
|
||||
import MesMaterialSelectModal from '/@/views/mes/material/modules/MesMaterialSelectModal.vue';
|
||||
import DeptSelectModal from '/@/components/Form/src/jeecg/components/modal/DeptSelectModal.vue';
|
||||
|
||||
const emit = defineEmits(['register', 'success']);
|
||||
const { createMessage } = useMessage();
|
||||
|
||||
const isUpdate = ref(false);
|
||||
const isDetail = ref(false);
|
||||
const tableReady = ref(false);
|
||||
const lineLoading = ref(false);
|
||||
const lineDataSource = ref<Recordable[]>([]);
|
||||
const lineTableRef = ref<JVxeTableInstance>();
|
||||
const lastMethodId = ref<string>('');
|
||||
|
||||
const [registerForm, { resetFields, setFieldsValue, validate, setProps, getFieldsValue }] = useForm({
|
||||
labelWidth: 120,
|
||||
schemas: formSchema,
|
||||
showActionButtonGroup: false,
|
||||
baseColProps: { span: 12 },
|
||||
});
|
||||
|
||||
const [registerMethodModal, { openModal: openMethodModal }] = useModal();
|
||||
const [registerMaterialModal, { openModal: openMaterialModal }] = useModal();
|
||||
const [registerPsModal, { openModal: openPsModal }] = useModal();
|
||||
const [registerDeptModal, { openModal: openDeptModal }] = useModal();
|
||||
|
||||
const [registerModal, { setModalProps, closeModal }] = useModalInner(async (data) => {
|
||||
tableReady.value = false;
|
||||
lineDataSource.value = [];
|
||||
lastMethodId.value = '';
|
||||
await resetFields();
|
||||
setModalProps({ confirmLoading: false, showCancelBtn: data?.showFooter, showOkBtn: data?.showFooter });
|
||||
isUpdate.value = !!data?.isUpdate;
|
||||
isDetail.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 queryLineListByStdId({ id: data.record.id });
|
||||
const list = Array.isArray(linesRaw) ? linesRaw : (linesRaw as any)?.result ?? [];
|
||||
await setFieldsValue({ ...m });
|
||||
lineDataSource.value = list || [];
|
||||
lastMethodId.value = m?.testMethodId || '';
|
||||
} finally {
|
||||
lineLoading.value = false;
|
||||
}
|
||||
} else {
|
||||
await setFieldsValue({ enableStatus: '1', auditStatus: '0' });
|
||||
}
|
||||
tableReady.value = true;
|
||||
});
|
||||
|
||||
const title = computed(() =>
|
||||
!unref(isUpdate) ? '新增胶料快检实验标准' : unref(isDetail) ? '实验标准详情' : '编辑胶料快检实验标准',
|
||||
);
|
||||
|
||||
function methodLineToStdRow(ml: Recordable, existing?: Recordable): Recordable {
|
||||
return {
|
||||
dataPointId: ml.dataPointId,
|
||||
pointName: ml.pointName,
|
||||
lowerLimit: existing?.lowerLimit ?? null,
|
||||
lowerWarn: existing?.lowerWarn ?? null,
|
||||
targetValue: existing?.targetValue ?? null,
|
||||
upperWarn: existing?.upperWarn ?? null,
|
||||
upperLimit: existing?.upperLimit ?? null,
|
||||
};
|
||||
}
|
||||
|
||||
async function loadLinesFromMethod(methodId: string, mergeExisting = true) {
|
||||
if (!methodId) {
|
||||
lineDataSource.value = [];
|
||||
return;
|
||||
}
|
||||
lineLoading.value = true;
|
||||
try {
|
||||
const linesRaw = await queryLineListByMethodId({ id: methodId });
|
||||
const methodLines = Array.isArray(linesRaw) ? linesRaw : (linesRaw as any)?.result ?? [];
|
||||
const existingMap = new Map<string, Recordable>();
|
||||
if (mergeExisting) {
|
||||
const current = (lineTableRef.value as any)?.getTableData?.() || lineDataSource.value || [];
|
||||
for (const row of current as Recordable[]) {
|
||||
if (row?.dataPointId) {
|
||||
existingMap.set(String(row.dataPointId), row);
|
||||
}
|
||||
}
|
||||
}
|
||||
lineDataSource.value = (methodLines || []).map((ml: Recordable) =>
|
||||
methodLineToStdRow(ml, existingMap.get(String(ml.dataPointId))),
|
||||
);
|
||||
} finally {
|
||||
lineLoading.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
function openMethodSelect() {
|
||||
const vals = getFieldsValue();
|
||||
openMethodModal(true, { testMethodId: vals?.testMethodId || '' });
|
||||
}
|
||||
|
||||
async function onMethodSelect(payload: Recordable) {
|
||||
const methodId = payload?.testMethodId || '';
|
||||
await setFieldsValue({
|
||||
testMethodId: methodId,
|
||||
testMethodName: payload?.testMethodName || '',
|
||||
});
|
||||
if (methodId !== lastMethodId.value) {
|
||||
lastMethodId.value = methodId;
|
||||
await loadLinesFromMethod(methodId, false);
|
||||
}
|
||||
}
|
||||
|
||||
function openMaterialSelect() {
|
||||
const vals = getFieldsValue();
|
||||
openMaterialModal(true, { materialId: vals?.rubberMaterialId || '' });
|
||||
}
|
||||
|
||||
async function onMaterialSelect(payload: Recordable) {
|
||||
await setFieldsValue({
|
||||
rubberMaterialId: payload.materialId || '',
|
||||
rubberMaterialName: payload.materialName || '',
|
||||
});
|
||||
}
|
||||
|
||||
function openPsSelect() {
|
||||
const vals = getFieldsValue();
|
||||
openPsModal(true, { psCompileId: vals?.psCompileId || '' });
|
||||
}
|
||||
|
||||
async function onPsSelect(payload: Recordable) {
|
||||
await setFieldsValue({
|
||||
psCompileId: payload.psCompileId || '',
|
||||
issueNumber: payload.issueNumber || '',
|
||||
issueDate: payload.issueDate || undefined,
|
||||
issueDeptId: payload.issueDeptId || undefined,
|
||||
issueDeptName: payload.issueDeptName || undefined,
|
||||
});
|
||||
}
|
||||
|
||||
function clearIssueNumber(model: Recordable) {
|
||||
model.psCompileId = '';
|
||||
model.issueNumber = '';
|
||||
}
|
||||
|
||||
function openDeptSelect() {
|
||||
openDeptModal(true, { isUpdate: false });
|
||||
}
|
||||
|
||||
function resolveIssueDeptSelection(options: Recordable[] = [], values: Recordable[] = []) {
|
||||
const opt = options?.[0] || {};
|
||||
let id = '';
|
||||
let name = opt.label != null ? String(opt.label) : '';
|
||||
if (opt.value != null && opt.value !== '') {
|
||||
if (typeof opt.value === 'string' || typeof opt.value === 'number') {
|
||||
id = String(opt.value);
|
||||
} else if (typeof opt.value === 'object') {
|
||||
const row = opt.value as Recordable;
|
||||
id = String(row.id ?? row.key ?? row.value ?? '');
|
||||
if (!name) {
|
||||
name = String(row.departName ?? row.title ?? row.label ?? '');
|
||||
}
|
||||
}
|
||||
}
|
||||
const rawValue = values?.[0];
|
||||
if (!id && rawValue != null && rawValue !== '') {
|
||||
id = String(rawValue);
|
||||
}
|
||||
return { id, name };
|
||||
}
|
||||
|
||||
async function onIssueDeptSelect(options: Recordable[], values: Recordable[]) {
|
||||
const { id, name } = resolveIssueDeptSelection(options, values);
|
||||
await setFieldsValue({
|
||||
issueDeptId: id,
|
||||
issueDeptName: name,
|
||||
});
|
||||
}
|
||||
|
||||
function clearIssueDept(model: Recordable) {
|
||||
model.issueDeptId = '';
|
||||
model.issueDeptName = '';
|
||||
}
|
||||
|
||||
async function handleSubmit() {
|
||||
try {
|
||||
const values = await validate();
|
||||
if (!values?.testMethodId) {
|
||||
createMessage.warning('请选择实验方法');
|
||||
return;
|
||||
}
|
||||
const lineRef = lineTableRef.value as any;
|
||||
const tableData = (lineRef?.getTableData?.() || lineDataSource.value || []) as Recordable[];
|
||||
const lineList = tableData
|
||||
.filter((r) => r && r.dataPointId)
|
||||
.map((r) => ({
|
||||
dataPointId: r.dataPointId,
|
||||
pointName: r.pointName,
|
||||
lowerLimit: r.lowerLimit,
|
||||
lowerWarn: r.lowerWarn,
|
||||
targetValue: r.targetValue,
|
||||
upperWarn: r.upperWarn,
|
||||
upperLimit: r.upperLimit,
|
||||
}));
|
||||
if (!lineList.length) {
|
||||
createMessage.warning('请先选择实验方法以带出数据点明细');
|
||||
return;
|
||||
}
|
||||
setModalProps({ confirmLoading: true });
|
||||
await saveOrUpdate({ ...values, lineList }, unref(isUpdate));
|
||||
closeModal();
|
||||
emit('success');
|
||||
} finally {
|
||||
setModalProps({ confirmLoading: false });
|
||||
}
|
||||
}
|
||||
</script>
|
||||
Reference in New Issue
Block a user