原材料检验项目功能、原材料检验标准功能
This commit is contained in:
@@ -3,6 +3,7 @@ import { Modal } from 'ant-design-vue';
|
||||
|
||||
enum Api {
|
||||
list = '/mes/material/mixerMaterial/list',
|
||||
queryById = '/mes/material/mixerMaterial/queryById',
|
||||
save = '/mes/material/mixerMaterial/add',
|
||||
edit = '/mes/material/mixerMaterial/edit',
|
||||
deleteOne = '/mes/material/mixerMaterial/delete',
|
||||
@@ -14,6 +15,7 @@ enum Api {
|
||||
export const getExportUrl = Api.exportXls;
|
||||
export const getImportUrl = Api.importExcel;
|
||||
export const list = (params) => defHttp.get({ url: Api.list, params });
|
||||
export const queryById = (params) => defHttp.get({ url: Api.queryById, params });
|
||||
|
||||
export const deleteOne = (params, handleSuccess) =>
|
||||
defHttp.delete({ url: Api.deleteOne, params }, { joinParamsToUrl: true }).then(() => handleSuccess());
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
import { defHttp } from '/@/utils/http/axios';
|
||||
import { Modal } from 'ant-design-vue';
|
||||
|
||||
enum Api {
|
||||
list = '/mes/material/rawMaterialInspectItem/list',
|
||||
save = '/mes/material/rawMaterialInspectItem/add',
|
||||
edit = '/mes/material/rawMaterialInspectItem/edit',
|
||||
deleteOne = '/mes/material/rawMaterialInspectItem/delete',
|
||||
deleteBatch = '/mes/material/rawMaterialInspectItem/deleteBatch',
|
||||
importExcel = '/mes/material/rawMaterialInspectItem/importExcel',
|
||||
exportXls = '/mes/material/rawMaterialInspectItem/exportXls',
|
||||
}
|
||||
|
||||
export const getExportUrl = Api.exportXls;
|
||||
export const getImportUrl = Api.importExcel;
|
||||
export const list = (params) => defHttp.get({ url: Api.list, params });
|
||||
export const deleteOne = (params, handleSuccess) =>
|
||||
defHttp.delete({ url: Api.deleteOne, params }, { joinParamsToUrl: true }).then(() => handleSuccess());
|
||||
export const batchDelete = (params, handleSuccess) =>
|
||||
Modal.confirm({
|
||||
title: '确认删除',
|
||||
content: '是否删除选中数据',
|
||||
onOk: () => defHttp.delete({ url: Api.deleteBatch, data: params }, { joinParamsToUrl: true }).then(() => handleSuccess()),
|
||||
});
|
||||
export const saveOrUpdate = (params, isUpdate) => defHttp.post({ url: isUpdate ? Api.edit : Api.save, params });
|
||||
@@ -0,0 +1,24 @@
|
||||
import { BasicColumn, FormSchema } from '/@/components/Table';
|
||||
|
||||
export const columns: BasicColumn[] = [
|
||||
{ title: '检验项目名称', align: 'center', dataIndex: 'inspectItemName', width: 200 },
|
||||
{ title: '英文名称', align: 'center', dataIndex: 'inspectItemNameEn', width: 200 },
|
||||
{ title: '单位', align: 'center', dataIndex: 'unitName', width: 100 },
|
||||
{ title: '标记', align: 'center', dataIndex: 'itemMark', width: 120 },
|
||||
{ title: '试验标准编号', align: 'center', dataIndex: 'testStandardNo', width: 160 },
|
||||
];
|
||||
|
||||
export const searchFormSchema: FormSchema[] = [
|
||||
{ label: '检验项目名称', field: 'inspectItemName', component: 'Input', colProps: { span: 6 } },
|
||||
{ label: '试验标准编号', field: 'testStandardNo', component: 'Input', colProps: { span: 6 } },
|
||||
];
|
||||
|
||||
export const formSchema: FormSchema[] = [
|
||||
{ label: '', field: 'id', component: 'Input', show: false },
|
||||
{ label: '检验项目名称', field: 'inspectItemName', component: 'Input', required: true },
|
||||
{ label: '英文名称', field: 'inspectItemNameEn', component: 'Input' },
|
||||
{ label: '单位', field: 'unitName', component: 'Input' },
|
||||
{ label: '标记', field: 'itemMark', component: 'Input' },
|
||||
{ label: '试验标准编号', field: 'testStandardNo', component: 'Input' },
|
||||
{ label: '备注', field: 'remark', component: 'InputTextArea' },
|
||||
];
|
||||
@@ -0,0 +1,58 @@
|
||||
<template>
|
||||
<div>
|
||||
<BasicTable @register="registerTable" :rowSelection="rowSelection">
|
||||
<template #tableTitle>
|
||||
<a-button type="primary" v-auth="'mes:mes_raw_material_inspect_item:add'" @click="handleAdd" preIcon="ant-design:plus-outlined">新增</a-button>
|
||||
</template>
|
||||
<template #action="{ record }">
|
||||
<TableAction
|
||||
:actions="[{ label: '编辑', onClick: handleEdit.bind(null, record), auth: 'mes:mes_raw_material_inspect_item:edit' }]"
|
||||
:dropDownActions="getDropDownAction(record)"
|
||||
/>
|
||||
</template>
|
||||
</BasicTable>
|
||||
<MesRawMaterialInspectItemModal @register="registerModal" @success="reload" />
|
||||
</div>
|
||||
</template>
|
||||
<script lang="ts" setup>
|
||||
import { BasicTable, TableAction } from '/@/components/Table';
|
||||
import { useModal } from '/@/components/Modal';
|
||||
import { useListPage } from '/@/hooks/system/useListPage';
|
||||
import MesRawMaterialInspectItemModal from './modules/MesRawMaterialInspectItemModal.vue';
|
||||
import { columns, searchFormSchema } from './MesRawMaterialInspectItem.data';
|
||||
import { list, deleteOne } from './MesRawMaterialInspectItem.api';
|
||||
const [registerModal, { openModal }] = useModal();
|
||||
const { tableContext } = useListPage({
|
||||
tableProps: {
|
||||
title: '原材料检验项目',
|
||||
api: list,
|
||||
columns,
|
||||
canResize: true,
|
||||
formConfig: { labelWidth: 120, schemas: searchFormSchema, autoSubmitOnEnter: true },
|
||||
actionColumn: { width: 120 },
|
||||
},
|
||||
});
|
||||
const [registerTable, { reload }, { rowSelection }] = 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 }, reload);
|
||||
}
|
||||
function getDropDownAction(record) {
|
||||
return [
|
||||
{ label: '详情', onClick: handleDetail.bind(null, record) },
|
||||
{
|
||||
label: '删除',
|
||||
popConfirm: { title: '是否确认删除', confirm: handleDelete.bind(null, record) },
|
||||
auth: 'mes:mes_raw_material_inspect_item:delete',
|
||||
},
|
||||
];
|
||||
}
|
||||
</script>
|
||||
@@ -0,0 +1,39 @@
|
||||
import { defHttp } from '/@/utils/http/axios';
|
||||
import { Modal } from 'ant-design-vue';
|
||||
|
||||
enum Api {
|
||||
list = '/mes/material/rawMaterialInspectStd/list',
|
||||
save = '/mes/material/rawMaterialInspectStd/add',
|
||||
edit = '/mes/material/rawMaterialInspectStd/edit',
|
||||
deleteOne = '/mes/material/rawMaterialInspectStd/delete',
|
||||
deleteBatch = '/mes/material/rawMaterialInspectStd/deleteBatch',
|
||||
importExcel = '/mes/material/rawMaterialInspectStd/importExcel',
|
||||
exportXls = '/mes/material/rawMaterialInspectStd/exportXls',
|
||||
queryById = '/mes/material/rawMaterialInspectStd/queryById',
|
||||
queryLineList = '/mes/material/rawMaterialInspectStd/queryLineListByStdId',
|
||||
setEnable = '/mes/material/rawMaterialInspectStd/setEnable',
|
||||
}
|
||||
|
||||
export const getExportUrl = Api.exportXls;
|
||||
export const getImportUrl = Api.importExcel;
|
||||
export const list = (params) => defHttp.get({ url: Api.list, params });
|
||||
export const queryById = (params) => defHttp.get({ url: Api.queryById, params });
|
||||
export const queryLineListByStdId = (params) => defHttp.get({ url: Api.queryLineList, params });
|
||||
|
||||
export const deleteOne = (params, handleSuccess) =>
|
||||
defHttp.delete({ url: Api.deleteOne, params }, { joinParamsToUrl: true }).then(() => handleSuccess());
|
||||
|
||||
export const batchDelete = (params, handleSuccess) => {
|
||||
Modal.confirm({
|
||||
title: '确认删除',
|
||||
content: '是否删除选中数据',
|
||||
okText: '确认',
|
||||
cancelText: '取消',
|
||||
onOk: () =>
|
||||
defHttp.delete({ url: Api.deleteBatch, data: params }, { joinParamsToUrl: true }).then(() => handleSuccess()),
|
||||
});
|
||||
};
|
||||
|
||||
export const saveOrUpdate = (params, isUpdate) => defHttp.post({ url: isUpdate ? Api.edit : Api.save, params });
|
||||
|
||||
export const setEnable = (params) => defHttp.post({ url: Api.setEnable, params });
|
||||
@@ -0,0 +1,126 @@
|
||||
import { BasicColumn, FormSchema } from '/@/components/Table';
|
||||
import { JVxeColumn, JVxeTypes } from '/@/components/jeecg/JVxeTable/types';
|
||||
|
||||
function enableText(v: unknown) {
|
||||
if (v === 1) return '启用';
|
||||
if (v === 0) return '停用';
|
||||
return '-';
|
||||
}
|
||||
|
||||
export const columns: BasicColumn[] = [
|
||||
{ title: '标准编号', align: 'center', dataIndex: 'standardNo', width: 140 },
|
||||
{ title: '物料名称', align: 'center', dataIndex: 'materialName', width: 160 },
|
||||
{ title: '种类', align: 'center', dataIndex: 'materialKind', width: 140, ellipsis: true },
|
||||
{ title: '版本', align: 'center', dataIndex: 'versionNo', width: 100 },
|
||||
{ title: '发行编号', align: 'center', dataIndex: 'issueNo', width: 120 },
|
||||
{ title: '版本状态', align: 'center', dataIndex: 'versionStatus', width: 100 },
|
||||
{
|
||||
title: '启用',
|
||||
align: 'center',
|
||||
dataIndex: 'enableFlag',
|
||||
width: 80,
|
||||
customRender: ({ text }) => enableText(text),
|
||||
},
|
||||
{ title: '生效日期', align: 'center', dataIndex: 'effectiveDate', width: 170 },
|
||||
{ title: '创建人', align: 'center', dataIndex: 'createBy', width: 100 },
|
||||
{ title: '创建时间', align: 'center', dataIndex: 'createTime', width: 170 },
|
||||
];
|
||||
|
||||
export const searchFormSchema: FormSchema[] = [
|
||||
{ label: '标准编号', field: 'standardNo', component: 'Input', colProps: { span: 6 } },
|
||||
{ label: '物料名称', field: 'materialName', component: 'Input', colProps: { span: 6 } },
|
||||
];
|
||||
|
||||
export const formSchema: FormSchema[] = [
|
||||
{ label: '', field: 'id', component: 'Input', show: false },
|
||||
{ label: '', field: 'mixerMaterialId', component: 'Input', show: false },
|
||||
{
|
||||
label: '标准编号',
|
||||
field: 'standardNo',
|
||||
component: 'Input',
|
||||
required: true,
|
||||
colProps: { span: 12 },
|
||||
},
|
||||
{
|
||||
label: '密炼物料',
|
||||
field: 'materialName',
|
||||
component: 'Input',
|
||||
slot: 'mixerMaterialPicker',
|
||||
rules: [{ required: true, message: '请选择密炼物料' }],
|
||||
colProps: { span: 12 },
|
||||
},
|
||||
{
|
||||
label: '物料描述',
|
||||
field: 'materialDesc',
|
||||
component: 'Input',
|
||||
componentProps: { readonly: true },
|
||||
colProps: { span: 12 },
|
||||
},
|
||||
{
|
||||
label: '种类',
|
||||
field: 'materialKind',
|
||||
component: 'Input',
|
||||
componentProps: { readonly: true },
|
||||
colProps: { span: 12 },
|
||||
},
|
||||
{ label: '版本', field: 'versionNo', component: 'Input', colProps: { span: 12 } },
|
||||
{ label: '发行编号', field: 'issueNo', component: 'Input', colProps: { span: 12 } },
|
||||
{ label: '版本状态', field: 'versionStatus', component: 'Input', colProps: { span: 12 } },
|
||||
{
|
||||
label: '创建人',
|
||||
field: 'createBy',
|
||||
component: 'Input',
|
||||
componentProps: { readonly: true },
|
||||
ifShow: ({ values }) => !!values?.id,
|
||||
colProps: { span: 12 },
|
||||
},
|
||||
{
|
||||
label: '创建时间',
|
||||
field: 'createTime',
|
||||
component: 'Input',
|
||||
componentProps: { readonly: true },
|
||||
ifShow: ({ values }) => !!values?.id,
|
||||
colProps: { span: 12 },
|
||||
},
|
||||
{
|
||||
label: '生效日期',
|
||||
field: 'effectiveDate',
|
||||
component: 'Input',
|
||||
componentProps: { readonly: true },
|
||||
ifShow: ({ values }) => !!values?.id,
|
||||
colProps: { span: 12 },
|
||||
},
|
||||
];
|
||||
|
||||
export const lineJVxeColumns: JVxeColumn[] = [
|
||||
{
|
||||
title: '检验项目',
|
||||
key: 'inspectItemId',
|
||||
type: JVxeTypes.selectDictSearch,
|
||||
width: 260,
|
||||
async: true,
|
||||
dict: 'mes_raw_material_inspect_item,inspect_item_name,id',
|
||||
tipsContent: '输入关键字搜索检验项目',
|
||||
validateRules: [{ required: true, message: '${title}必选' }],
|
||||
},
|
||||
{ title: '容许最小值', key: 'allowMin', type: JVxeTypes.inputNumber, width: 140 },
|
||||
{
|
||||
title: '包含最小值',
|
||||
key: 'includeMinFlag',
|
||||
type: JVxeTypes.checkbox,
|
||||
width: 120,
|
||||
align: 'center',
|
||||
customValue: [1, 0],
|
||||
defaultValue: 0,
|
||||
},
|
||||
{ title: '容许最大值', key: 'allowMax', type: JVxeTypes.inputNumber, width: 140 },
|
||||
{
|
||||
title: '包含最大值',
|
||||
key: 'includeMaxFlag',
|
||||
type: JVxeTypes.checkbox,
|
||||
width: 120,
|
||||
align: 'center',
|
||||
customValue: [1, 0],
|
||||
defaultValue: 0,
|
||||
},
|
||||
];
|
||||
@@ -0,0 +1,90 @@
|
||||
<template>
|
||||
<div>
|
||||
<BasicTable @register="registerTable" :rowSelection="rowSelection">
|
||||
<template #tableTitle>
|
||||
<a-button type="primary" v-auth="'mes:mes_raw_material_inspect_std:add'" @click="handleAdd" preIcon="ant-design:plus-outlined"
|
||||
>新增</a-button
|
||||
>
|
||||
</template>
|
||||
<template #action="{ record }">
|
||||
<TableAction
|
||||
:actions="[
|
||||
{ label: '编辑', onClick: handleEdit.bind(null, record), auth: 'mes:mes_raw_material_inspect_std:edit' },
|
||||
]"
|
||||
:dropDownActions="getDropDownAction(record)"
|
||||
/>
|
||||
</template>
|
||||
</BasicTable>
|
||||
<MesRawMaterialInspectStdModal @register="registerModal" @success="reload" />
|
||||
</div>
|
||||
</template>
|
||||
<script lang="ts" setup>
|
||||
import { BasicTable, TableAction } from '/@/components/Table';
|
||||
import { useModal } from '/@/components/Modal';
|
||||
import { useListPage } from '/@/hooks/system/useListPage';
|
||||
import MesRawMaterialInspectStdModal from './modules/MesRawMaterialInspectStdModal.vue';
|
||||
import { columns, searchFormSchema } from './MesRawMaterialInspectStd.data';
|
||||
import { list, deleteOne, setEnable } from './MesRawMaterialInspectStd.api';
|
||||
import { useMessage } from '/@/hooks/web/useMessage';
|
||||
|
||||
const { createMessage } = useMessage();
|
||||
const [registerModal, { openModal }] = useModal();
|
||||
const { tableContext } = useListPage({
|
||||
tableProps: {
|
||||
title: '原材料检验标准',
|
||||
api: list,
|
||||
columns,
|
||||
canResize: true,
|
||||
formConfig: { labelWidth: 100, schemas: searchFormSchema, autoSubmitOnEnter: true },
|
||||
actionColumn: { width: 200 },
|
||||
},
|
||||
});
|
||||
const [registerTable, { reload }, { rowSelection }] = 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 }, reload);
|
||||
}
|
||||
async function handleEnable(record: Recordable) {
|
||||
await setEnable({ id: record.id, enableFlag: 1 });
|
||||
createMessage.success('已启用');
|
||||
reload();
|
||||
}
|
||||
async function handleDisable(record: Recordable) {
|
||||
await setEnable({ id: record.id, enableFlag: 0 });
|
||||
createMessage.success('已停用');
|
||||
reload();
|
||||
}
|
||||
function getDropDownAction(record) {
|
||||
const actions: any[] = [
|
||||
{ label: '详情', onClick: handleDetail.bind(null, record) },
|
||||
{
|
||||
label: '删除',
|
||||
popConfirm: { title: '是否确认删除', confirm: handleDelete.bind(null, record) },
|
||||
auth: 'mes:mes_raw_material_inspect_std:delete',
|
||||
},
|
||||
];
|
||||
if (record.enableFlag !== 1) {
|
||||
actions.push({
|
||||
label: '启用',
|
||||
auth: 'mes:mes_raw_material_inspect_std:enable',
|
||||
popConfirm: { title: '启用后将记录当前时间到生效日期', confirm: () => handleEnable(record) },
|
||||
});
|
||||
} else {
|
||||
actions.push({
|
||||
label: '停用',
|
||||
auth: 'mes:mes_raw_material_inspect_std:enable',
|
||||
popConfirm: { title: '停用后将清除生效日期', confirm: () => handleDisable(record) },
|
||||
});
|
||||
}
|
||||
return actions;
|
||||
}
|
||||
</script>
|
||||
@@ -0,0 +1,93 @@
|
||||
<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 { list as mixerList, queryById as queryMixerById } from '../MesMixerMaterial.api';
|
||||
import { columns as mixerColumns, searchFormSchema as mixerSearch } from '../MesMixerMaterial.data';
|
||||
import { useMessage } from '/@/hooks/web/useMessage';
|
||||
|
||||
const emit = defineEmits(['register', 'select']);
|
||||
const { createMessage } = useMessage();
|
||||
|
||||
const selectedRow = ref<Recordable | null>(null);
|
||||
|
||||
const [registerTable, { reload, getSelectRowKeys, getSelectRows, setSelectedRowKeys, clearSelectedRowKeys }] = useTable({
|
||||
api: mixerList,
|
||||
columns: mixerColumns.slice(0, 6),
|
||||
rowKey: 'id',
|
||||
useSearchForm: true,
|
||||
formConfig: {
|
||||
labelWidth: 90,
|
||||
schemas: mixerSearch,
|
||||
},
|
||||
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 mid = data?.mixerMaterialId as string | undefined;
|
||||
if (mid) {
|
||||
setSelectedRowKeys?.([mid]);
|
||||
try {
|
||||
const raw = await queryMixerById({ id: mid });
|
||||
const row = (raw as any)?.id != null ? raw : (raw as any)?.result;
|
||||
if (row) {
|
||||
selectedRow.value = row;
|
||||
}
|
||||
} catch {
|
||||
// ignore
|
||||
}
|
||||
}
|
||||
reload();
|
||||
});
|
||||
|
||||
function buildKind(row: Recordable) {
|
||||
const a = row.majorCategoryId_dictText || '';
|
||||
const b = row.minorCategoryId_dictText || '';
|
||||
if (a && b) return `${a} / ${b}`;
|
||||
return a || b || '';
|
||||
}
|
||||
|
||||
async function handleOk() {
|
||||
const keys = (getSelectRowKeys?.() || []) as string[];
|
||||
let row = selectedRow.value || ((getSelectRows?.() || []) as Recordable[])[0];
|
||||
if (!row && keys.length) {
|
||||
try {
|
||||
const raw = await queryMixerById({ id: keys[0] });
|
||||
row = (raw as any)?.id != null ? raw : (raw as any)?.result;
|
||||
} catch {
|
||||
// ignore
|
||||
}
|
||||
}
|
||||
if (!row?.id) {
|
||||
createMessage.warning('请选择一条密炼物料');
|
||||
return;
|
||||
}
|
||||
emit('select', {
|
||||
mixerMaterialId: row.id,
|
||||
materialName: row.materialName || '',
|
||||
materialDesc: row.materialDesc || '',
|
||||
materialKind: buildKind(row),
|
||||
});
|
||||
closeModal();
|
||||
}
|
||||
</script>
|
||||
@@ -0,0 +1,38 @@
|
||||
<template>
|
||||
<BasicModal @register="registerModal" :title="title" width="50%" v-bind="$attrs" @ok="handleSubmit">
|
||||
<BasicForm @register="registerForm" />
|
||||
</BasicModal>
|
||||
</template>
|
||||
<script lang="ts" setup>
|
||||
import { computed, ref, unref } from 'vue';
|
||||
import { BasicModal, useModalInner } from '/@/components/Modal';
|
||||
import { BasicForm, useForm } from '/@/components/Form/index';
|
||||
import { formSchema } from '../MesRawMaterialInspectItem.data';
|
||||
import { saveOrUpdate } from '../MesRawMaterialInspectItem.api';
|
||||
const emit = defineEmits(['register', 'success']);
|
||||
const isUpdate = ref(true);
|
||||
const [registerForm, { resetFields, setFieldsValue, validate, setProps }] = useForm({
|
||||
labelWidth: 120,
|
||||
schemas: formSchema,
|
||||
showActionButtonGroup: false,
|
||||
});
|
||||
const [registerModal, { setModalProps, closeModal }] = useModalInner(async (data) => {
|
||||
await resetFields();
|
||||
setModalProps({ confirmLoading: false, showCancelBtn: data?.showFooter, showOkBtn: data?.showFooter });
|
||||
isUpdate.value = !!data?.isUpdate;
|
||||
if (unref(isUpdate)) await setFieldsValue({ ...data.record });
|
||||
setProps({ disabled: !data?.showFooter });
|
||||
});
|
||||
const title = computed(() => (!unref(isUpdate) ? '新增检验项目' : '编辑检验项目'));
|
||||
async function handleSubmit() {
|
||||
try {
|
||||
const values = await validate();
|
||||
setModalProps({ confirmLoading: true });
|
||||
await saveOrUpdate(values, isUpdate.value);
|
||||
closeModal();
|
||||
emit('success');
|
||||
} finally {
|
||||
setModalProps({ confirmLoading: false });
|
||||
}
|
||||
}
|
||||
</script>
|
||||
@@ -0,0 +1,161 @@
|
||||
<template>
|
||||
<BasicModal
|
||||
v-bind="$attrs"
|
||||
destroyOnClose
|
||||
:title="title"
|
||||
width="1000px"
|
||||
@register="registerModal"
|
||||
@ok="handleSubmit"
|
||||
>
|
||||
<BasicForm @register="registerForm" name="MesRawMaterialInspectStdForm">
|
||||
<template #mixerMaterialPicker="{ model, field }">
|
||||
<a-input-group compact style="display: flex; width: 100%">
|
||||
<a-input
|
||||
v-model:value="model[field]"
|
||||
read-only
|
||||
placeholder="请点击选择密炼物料"
|
||||
style="flex: 1"
|
||||
:disabled="!showFooterFlag"
|
||||
/>
|
||||
<a-button type="primary" :disabled="!showFooterFlag" @click="openMixerSelect">选择</a-button>
|
||||
<a-button v-if="model.mixerMaterialId && showFooterFlag" @click="clearMixer">清除</a-button>
|
||||
</a-input-group>
|
||||
</template>
|
||||
</BasicForm>
|
||||
<a-divider orientation="left">检验项目明细</a-divider>
|
||||
<JVxeTable
|
||||
v-if="tableReady"
|
||||
ref="lineTableRef"
|
||||
toolbar
|
||||
row-number
|
||||
keep-source
|
||||
:max-height="360"
|
||||
:loading="lineLoading"
|
||||
:columns="lineJVxeColumns"
|
||||
:dataSource="lineDataSource"
|
||||
:disabled="!showFooterFlag"
|
||||
/>
|
||||
<MesMixerMaterialSelectModal @register="registerMixerModal" @select="onMixerSelect" />
|
||||
</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 { formSchema, lineJVxeColumns } from '../MesRawMaterialInspectStd.data';
|
||||
import { saveOrUpdate, queryById, queryLineListByStdId } from '../MesRawMaterialInspectStd.api';
|
||||
import MesMixerMaterialSelectModal from './MesMixerMaterialSelectModal.vue';
|
||||
import { useMessage } from '/@/hooks/web/useMessage';
|
||||
|
||||
const emit = defineEmits(['register', 'success']);
|
||||
const { createMessage } = useMessage();
|
||||
const isUpdate = ref(false);
|
||||
const showFooterFlag = ref(true);
|
||||
const tableReady = ref(false);
|
||||
const lineLoading = ref(false);
|
||||
const lineDataSource = ref<Recordable[]>([]);
|
||||
const lineTableRef = ref<JVxeTableInstance>();
|
||||
|
||||
const [registerForm, { resetFields, setFieldsValue, validate, setProps, getFieldsValue }] = useForm({
|
||||
labelWidth: 110,
|
||||
schemas: formSchema,
|
||||
showActionButtonGroup: false,
|
||||
baseColProps: { span: 12 },
|
||||
});
|
||||
|
||||
const [registerMixerModal, { openModal: openMixerModal }] = useModal();
|
||||
|
||||
const [registerModal, { setModalProps, closeModal }] = useModalInner(async (data) => {
|
||||
tableReady.value = false;
|
||||
lineDataSource.value = [];
|
||||
await resetFields();
|
||||
setModalProps({ confirmLoading: false, showCancelBtn: data?.showFooter, showOkBtn: data?.showFooter });
|
||||
isUpdate.value = !!data?.isUpdate;
|
||||
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 queryLineListByStdId({ 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(() => {
|
||||
if (!showFooterFlag.value && unref(isUpdate)) {
|
||||
return '原材料检验标准详情';
|
||||
}
|
||||
return !unref(isUpdate) ? '新增原材料检验标准' : '编辑原材料检验标准';
|
||||
});
|
||||
|
||||
function openMixerSelect() {
|
||||
const mid = getFieldsValue()?.mixerMaterialId;
|
||||
openMixerModal(true, { mixerMaterialId: mid });
|
||||
}
|
||||
|
||||
function onMixerSelect(payload: Recordable | null) {
|
||||
if (!payload) {
|
||||
return;
|
||||
}
|
||||
setFieldsValue({
|
||||
mixerMaterialId: payload.mixerMaterialId,
|
||||
materialName: payload.materialName,
|
||||
materialDesc: payload.materialDesc,
|
||||
materialKind: payload.materialKind,
|
||||
});
|
||||
}
|
||||
|
||||
function clearMixer() {
|
||||
setFieldsValue({
|
||||
mixerMaterialId: '',
|
||||
materialName: '',
|
||||
materialDesc: '',
|
||||
materialKind: '',
|
||||
});
|
||||
}
|
||||
|
||||
async function handleSubmit() {
|
||||
try {
|
||||
const values = await validate();
|
||||
const lineRef = lineTableRef.value as any;
|
||||
if (lineRef?.validateTable) {
|
||||
const err = await lineRef.validateTable();
|
||||
if (err) {
|
||||
createMessage.warning('请完善检验项目明细');
|
||||
return;
|
||||
}
|
||||
}
|
||||
const tableData = (lineRef?.getTableData?.() || []) as Recordable[];
|
||||
const lineList = tableData
|
||||
.filter((r) => r && r.inspectItemId)
|
||||
.map((r) => ({
|
||||
inspectItemId: r.inspectItemId,
|
||||
inspectItemName: r.inspectItemName,
|
||||
allowMin: r.allowMin,
|
||||
allowMax: r.allowMax,
|
||||
includeMinFlag: r.includeMinFlag ?? 0,
|
||||
includeMaxFlag: r.includeMaxFlag ?? 0,
|
||||
}));
|
||||
if (!lineList.length) {
|
||||
createMessage.warning('请至少添加一行检验项目');
|
||||
return;
|
||||
}
|
||||
setModalProps({ confirmLoading: true });
|
||||
await saveOrUpdate({ ...values, lineList }, unref(isUpdate));
|
||||
closeModal();
|
||||
emit('success');
|
||||
} finally {
|
||||
setModalProps({ confirmLoading: false });
|
||||
}
|
||||
}
|
||||
</script>
|
||||
@@ -0,0 +1,7 @@
|
||||
<template>
|
||||
<MesRawMaterialInspectItemList />
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import MesRawMaterialInspectItemList from '../material/MesRawMaterialInspectItemList.vue';
|
||||
</script>
|
||||
@@ -0,0 +1,7 @@
|
||||
<template>
|
||||
<MesRawMaterialInspectStdList />
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import MesRawMaterialInspectStdList from '../material/MesRawMaterialInspectStdList.vue';
|
||||
</script>
|
||||
Reference in New Issue
Block a user