新增物料类型处理逻辑,确保在保存和编辑称重记录时自动设置默认物料类型。更新前端表单以支持密炼物料的选择和显示,优化用户体验。添加分类字典和数据字典的事件广播功能,增强系统的实时数据同步能力。

This commit is contained in:
geht
2026-05-07 17:53:48 +08:00
parent ce9dc8efd8
commit f60a4fb203
55 changed files with 2968 additions and 375 deletions

View File

@@ -0,0 +1,45 @@
import { defHttp } from '/@/utils/http/axios';
import { useMessage } from '/@/hooks/web/useMessage';
const { createConfirm } = useMessage();
enum Api {
list = '/xslmes/mesXslRawMaterialEntry/list',
save = '/xslmes/mesXslRawMaterialEntry/add',
edit = '/xslmes/mesXslRawMaterialEntry/edit',
deleteOne = '/xslmes/mesXslRawMaterialEntry/delete',
deleteBatch = '/xslmes/mesXslRawMaterialEntry/deleteBatch',
importExcel = '/xslmes/mesXslRawMaterialEntry/importExcel',
exportXls = '/xslmes/mesXslRawMaterialEntry/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) => {
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) => {
let url = isUpdate ? Api.edit : Api.save;
return defHttp.post({ url: url, params });
};

View File

@@ -0,0 +1,263 @@
import { BasicColumn, FormSchema } from '/@/components/Table';
export const columns: BasicColumn[] = [
{ title: '条码', align: 'center', dataIndex: 'barcode', width: 160 },
{ title: '批次号', align: 'center', dataIndex: 'batchNo', width: 140 },
{
title: '入场时间',
align: 'center',
dataIndex: 'entryTime',
width: 160,
customRender: ({ text }) => (!text ? '' : text.length > 19 ? text.substring(0, 19) : text),
},
{ title: '榜单号', align: 'center', dataIndex: 'billNo', width: 160 },
{ title: '物料名称', align: 'center', dataIndex: 'materialName', width: 140, ellipsis: true },
{ title: '供料客户', align: 'center', dataIndex: 'supplyCustomer', width: 140, ellipsis: true },
{ title: '供应商名称', align: 'center', dataIndex: 'supplierName', width: 140, ellipsis: true },
{ title: '厂家物料名称', align: 'center', dataIndex: 'manufacturerMaterialName', width: 140, ellipsis: true },
{ title: '保质期', align: 'center', dataIndex: 'shelfLife', width: 100 },
{ title: '总重(KG)', align: 'center', dataIndex: 'totalWeight', width: 100 },
{ title: '总份数', align: 'center', dataIndex: 'totalPortions', width: 80 },
{ title: '每份总重(KG)', align: 'center', dataIndex: 'portionWeight', width: 110 },
{ title: '每份包数', align: 'center', dataIndex: 'portionPackages', width: 80 },
{ title: '检测结果', align: 'center', dataIndex: 'testResult_dictText', width: 90 },
{ title: '检测状态', align: 'center', dataIndex: 'testStatus_dictText', width: 90 },
{ title: '打印标记', align: 'center', dataIndex: 'printFlag_dictText', width: 90 },
{ title: '入库结存', align: 'center', dataIndex: 'stockBalance_dictText', width: 90 },
{ title: '库位', align: 'center', dataIndex: 'warehouseLocation', width: 100 },
{ title: '卸货人', align: 'center', dataIndex: 'unloadOperator', width: 90 },
{ title: '是否特采', align: 'center', dataIndex: 'isSpecialAdoption_dictText', width: 80 },
{ title: '特采操作人', align: 'center', dataIndex: 'specialAdoptionOperator', width: 100 },
{
title: '特采时间',
align: 'center',
dataIndex: 'specialAdoptionTime',
width: 160,
customRender: ({ text }) => (!text ? '' : text.length > 19 ? text.substring(0, 19) : text),
},
{ title: '特采原因', align: 'center', dataIndex: 'specialAdoptionReason', width: 160, ellipsis: true },
{ title: '状态', align: 'center', dataIndex: 'status_dictText', width: 80 },
{ title: '备注', align: 'center', dataIndex: 'remark', width: 160, ellipsis: true },
{
title: '创建时间',
align: 'center',
dataIndex: 'createTime',
width: 160,
customRender: ({ text }) => (!text ? '' : text.length > 19 ? text.substring(0, 19) : text),
},
];
export const searchFormSchema: FormSchema[] = [
{ label: '条码', field: 'barcode', component: 'JInput', colProps: { span: 6 } },
{ label: '批次号', field: 'batchNo', component: 'JInput', colProps: { span: 6 } },
{ label: '榜单号', field: 'billNo', component: 'JInput', colProps: { span: 6 } },
{ label: '物料名称', field: 'materialName', component: 'JInput', colProps: { span: 6 } },
{ label: '供应商名称', field: 'supplierName', component: 'JInput', colProps: { span: 6 } },
{
label: '检测结果',
field: 'testResult',
component: 'JDictSelectTag',
componentProps: { dictCode: 'xslmes_test_result' },
colProps: { span: 6 },
},
{
label: '检测状态',
field: 'testStatus',
component: 'JDictSelectTag',
componentProps: { dictCode: 'xslmes_test_status' },
colProps: { span: 6 },
},
{
label: '是否特采',
field: 'isSpecialAdoption',
component: 'JDictSelectTag',
componentProps: { dictCode: 'yn' },
colProps: { span: 6 },
},
{
label: '状态',
field: 'status',
component: 'JDictSelectTag',
componentProps: { dictCode: 'xslmes_entry_status' },
colProps: { span: 6 },
},
{
label: '入场时间',
field: 'entryTime',
component: 'RangePicker',
componentProps: { showTime: true, valueFormat: 'YYYY-MM-DD HH:mm:ss' },
colProps: { span: 8 },
},
];
export const formSchema: FormSchema[] = [
{ label: '', field: 'id', component: 'Input', show: false },
{ label: '', field: 'weightRecordId', component: 'Input', show: false },
{ label: '', field: 'materialId', component: 'Input', show: false },
{ label: '', field: 'supplierId', component: 'Input', show: false },
{
label: '条码',
field: 'barcode',
component: 'Input',
componentProps: { placeholder: '请输入条码' },
},
{
label: '批次号',
field: 'batchNo',
component: 'Input',
componentProps: { placeholder: '请输入批次号' },
},
{
label: '入场时间',
field: 'entryTime',
component: 'DatePicker',
componentProps: { showTime: true, valueFormat: 'YYYY-MM-DD HH:mm:ss', placeholder: '请选择入场时间' },
},
{
label: '榜单号',
field: 'billNo',
component: 'Input',
componentProps: { placeholder: '请输入榜单号' },
},
{
label: '物料名称',
field: 'materialName',
component: 'Input',
componentProps: { placeholder: '请输入物料名称' },
},
{
label: '供料客户',
field: 'supplyCustomer',
component: 'Input',
componentProps: { placeholder: '请输入供料客户' },
},
{
label: '供应商名称',
field: 'supplierName',
component: 'Input',
componentProps: { placeholder: '请输入供应商名称' },
},
{
label: '厂家物料名称',
field: 'manufacturerMaterialName',
component: 'Input',
componentProps: { placeholder: '请输入厂家物料名称' },
},
{
label: '保质期',
field: 'shelfLife',
component: 'Input',
componentProps: { placeholder: '请输入保质期' },
},
{
label: '总重(KG)',
field: 'totalWeight',
component: 'InputNumber',
componentProps: { min: 0, precision: 2, placeholder: '请输入总重', style: { width: '100%' } },
},
{
label: '总份数',
field: 'totalPortions',
component: 'InputNumber',
componentProps: { min: 0, placeholder: '请输入总份数', style: { width: '100%' } },
},
{
label: '每份总重(KG)',
field: 'portionWeight',
component: 'InputNumber',
componentProps: { min: 0, precision: 2, placeholder: '请输入每份总重', style: { width: '100%' } },
},
{
label: '每份包数',
field: 'portionPackages',
component: 'InputNumber',
componentProps: { min: 0, placeholder: '请输入每份包数', style: { width: '100%' } },
},
{
label: '检测结果',
field: 'testResult',
component: 'JDictSelectTag',
componentProps: { dictCode: 'xslmes_test_result', placeholder: '请选择检测结果' },
},
{
label: '检测状态',
field: 'testStatus',
component: 'JDictSelectTag',
componentProps: { dictCode: 'xslmes_test_status', placeholder: '请选择检测状态' },
},
{
label: '打印标记',
field: 'printFlag',
component: 'JDictSelectTag',
componentProps: { dictCode: 'xslmes_print_flag', placeholder: '请选择' },
},
{
label: '入库结存',
field: 'stockBalance',
component: 'JDictSelectTag',
componentProps: { dictCode: 'yn', placeholder: '请选择' },
},
{
label: '库位',
field: 'warehouseLocation',
component: 'Input',
componentProps: { placeholder: '请输入库位' },
},
{
label: '卸货人',
field: 'unloadOperator',
component: 'Input',
componentProps: { placeholder: '请输入卸货人' },
},
{
label: '是否特采',
field: 'isSpecialAdoption',
component: 'JDictSelectTag',
componentProps: { dictCode: 'yn', placeholder: '请选择' },
},
{
label: '特采操作人',
field: 'specialAdoptionOperator',
component: 'Input',
componentProps: { placeholder: '请输入特采操作人' },
},
{
label: '特采时间',
field: 'specialAdoptionTime',
component: 'DatePicker',
componentProps: { showTime: true, valueFormat: 'YYYY-MM-DD HH:mm:ss', placeholder: '请选择特采时间' },
},
{
label: '特采原因',
field: 'specialAdoptionReason',
component: 'InputTextArea',
componentProps: { rows: 3, placeholder: '请输入特采原因' },
colProps: { span: 24 },
},
{
label: '状态',
field: 'status',
component: 'JDictSelectTag',
componentProps: { dictCode: 'xslmes_entry_status', placeholder: '请选择状态' },
},
{
label: '备注',
field: 'remark',
component: 'InputTextArea',
componentProps: { rows: 3, placeholder: '请输入备注' },
colProps: { span: 24 },
},
];
export const superQuerySchema = {
barcode: { title: '条码', order: 0, view: 'text' },
batchNo: { title: '批次号', order: 1, view: 'text' },
entryTime: { title: '入场时间', order: 2, view: 'datetime' },
billNo: { title: '榜单号', order: 3, view: 'text' },
materialName: { title: '物料名称', order: 4, view: 'text' },
supplierName: { title: '供应商名称', order: 5, view: 'text' },
totalWeight: { title: '总重(KG)', order: 6, view: 'number' },
testStatus: { title: '检测状态', order: 7, view: 'list', dictCode: 'xslmes_test_status' },
isSpecialAdoption: { title: '是否特采', order: 8, view: 'list', dictCode: 'yn' },
status: { title: '状态', order: 9, view: 'list', dictCode: 'xslmes_entry_status' },
};

View File

@@ -0,0 +1,143 @@
<template>
<div>
<BasicTable @register="registerTable" :rowSelection="rowSelection">
<template #tableTitle>
<a-button type="primary" v-auth="'xslmes:mes_xsl_raw_material_entry:add'" @click="handleAdd" preIcon="ant-design:plus-outlined"> 新增</a-button>
<a-button type="primary" v-auth="'xslmes:mes_xsl_raw_material_entry:exportXls'" preIcon="ant-design:export-outlined" @click="onExportXls"> 导出</a-button>
<j-upload-button type="primary" v-auth="'xslmes:mes_xsl_raw_material_entry: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="'xslmes:mes_xsl_raw_material_entry:deleteBatch'">批量操作
<Icon icon="mdi:chevron-down" />
</a-button>
</a-dropdown>
<super-query :config="superQueryConfig" @search="handleSuperQuery" />
</template>
<template #action="{ record }">
<TableAction :actions="getTableAction(record)" :dropDownActions="getDropDownAction(record)" />
</template>
</BasicTable>
<MesXslRawMaterialEntryModal @register="registerModal" @success="handleSuccess" />
</div>
</template>
<script lang="ts" name="xslmes-mesXslRawMaterialEntry" setup>
import { ref, reactive } from 'vue';
import { BasicTable, useTable, TableAction } from '/@/components/Table';
import { useModal } from '/@/components/Modal';
import { useListPage } from '/@/hooks/system/useListPage';
import MesXslRawMaterialEntryModal from './components/MesXslRawMaterialEntryModal.vue';
import { columns, searchFormSchema, superQuerySchema } from './MesXslRawMaterialEntry.data';
import { list, deleteOne, batchDelete, getImportUrl, getExportUrl } from './MesXslRawMaterialEntry.api';
const queryParam = reactive<any>({});
const [registerModal, { openModal }] = useModal();
const { prefixCls, tableContext, onExportXls, onImportXls } = useListPage({
tableProps: {
title: '原料入场记录',
api: list,
columns,
canResize: true,
formConfig: {
schemas: searchFormSchema,
autoSubmitOnEnter: true,
showAdvancedButton: true,
fieldMapToTime: [
['entryTime', ['entryTime_begin', 'entryTime_end'], 'YYYY-MM-DD HH:mm:ss'],
],
},
actionColumn: {
width: 120,
fixed: 'right',
},
beforeFetch: (params) => {
return Object.assign(params, queryParam);
},
},
exportConfig: {
name: '原料入场记录',
url: getExportUrl,
params: queryParam,
},
importConfig: {
url: getImportUrl,
success: handleSuccess,
},
});
const [registerTable, { reload }, { rowSelection, selectedRowKeys }] = tableContext;
const superQueryConfig = reactive(superQuerySchema);
function handleSuperQuery(params) {
Object.keys(params).map((k) => {
queryParam[k] = params[k];
});
reload();
}
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);
}
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: 'xslmes:mes_xsl_raw_material_entry:edit',
},
];
}
function getDropDownAction(record) {
return [
{
label: '详情',
onClick: handleDetail.bind(null, record),
},
{
label: '删除',
popConfirm: {
title: '是否确认删除',
confirm: handleDelete.bind(null, record),
placement: 'topLeft',
},
auth: 'xslmes:mes_xsl_raw_material_entry:delete',
},
];
}
</script>
<style lang="less" scoped>
:deep(.ant-picker-range) {
width: 100%;
}
</style>

View File

@@ -0,0 +1,66 @@
<template>
<BasicModal v-bind="$attrs" @register="registerModal" destroyOnClose :title="title" :width="1100" @ok="handleSubmit">
<BasicForm @register="registerForm" name="MesXslRawMaterialEntryForm" />
</BasicModal>
</template>
<script lang="ts" setup>
import { ref, computed, unref } from 'vue';
import { BasicModal, useModalInner } from '/@/components/Modal';
import { BasicForm, useForm } from '/@/components/Form/index';
import { formSchema } from '../MesXslRawMaterialEntry.data';
import { saveOrUpdate } from '../MesXslRawMaterialEntry.api';
const emit = defineEmits(['register', 'success']);
const isUpdate = ref(true);
const isDetail = ref(false);
const [registerForm, { setProps, resetFields, setFieldsValue, validate, scrollToField }] = useForm({
labelWidth: 120,
schemas: formSchema,
showActionButtonGroup: false,
baseColProps: { span: 12 },
});
const [registerModal, { setModalProps, closeModal }] = useModalInner(async (data) => {
await resetFields();
setModalProps({ confirmLoading: false, showCancelBtn: !!data?.showFooter, showOkBtn: !!data?.showFooter });
isUpdate.value = !!data?.isUpdate;
isDetail.value = !data?.showFooter;
if (unref(isUpdate)) {
await setFieldsValue({ ...data.record });
}
setProps({ disabled: !data?.showFooter });
});
const title = computed(() => (!unref(isUpdate) ? '新增' : unref(isDetail) ? '详情' : '编辑'));
async function handleSubmit() {
try {
const values = await validate();
setModalProps({ confirmLoading: true });
await saveOrUpdate(values, unref(isUpdate));
closeModal();
emit('success');
} catch (e: any) {
if (e?.errorFields) {
const firstField = e.errorFields[0];
if (firstField) {
scrollToField(firstField.name, { behavior: 'smooth', block: 'center' });
}
}
return Promise.reject(e);
} finally {
setModalProps({ confirmLoading: false });
}
}
</script>
<style lang="less" scoped>
:deep(.ant-input-number) {
width: 100%;
}
:deep(.ant-calendar-picker) {
width: 100%;
}
</style>

View File

@@ -13,7 +13,8 @@ export const columns: BasicColumn[] = [
{ title: '车号', align: 'center', dataIndex: 'plateNumber', width: 120 },
{ title: '发货单位', align: 'center', dataIndex: 'senderUnit', width: 160, ellipsis: true },
{ title: '收货单位', align: 'center', dataIndex: 'receiverUnit', width: 160, ellipsis: true },
{ title: '货物名称', align: 'center', dataIndex: 'goodsName', width: 140, ellipsis: true },
{ title: '密炼物料', align: 'center', dataIndex: 'mixerMaterialNames', width: 160, ellipsis: true },
{ title: '类型', align: 'center', dataIndex: 'materialType_dictText', width: 90 },
{ title: '毛重(KG)', align: 'center', dataIndex: 'grossWeight', width: 100 },
{ title: '皮重(KG)', align: 'center', dataIndex: 'tareWeight', width: 100 },
{ title: '净重(KG)', align: 'center', dataIndex: 'netWeight', width: 100 },
@@ -77,10 +78,17 @@ export const formSchema: FormSchema[] = [
componentProps: { placeholder: '出厂时自动带出客户简称' },
},
{
label: '货物名称',
field: 'goodsName',
label: '密炼物料',
field: 'mixerMaterialNames',
component: 'Input',
componentProps: { placeholder: '请输入货物名称' },
componentProps: { placeholder: '由桌面端称重操作填入,可手动编辑' },
},
{
label: '类型',
field: 'materialType',
component: 'JDictSelectTag',
componentProps: { dictCode: 'xslmes_weight_material_type' },
defaultValue: '1',
},
{
label: '毛重(KG)',
@@ -119,6 +127,7 @@ export const superQuerySchema = {
inoutDirection: { title: '进出方向', order: 1, view: 'list', dictCode: 'xslmes_inout_direction' },
plateNumber: { title: '车号', order: 2, view: 'text' },
weighDate: { title: '称重日期', order: 3, view: 'date' },
grossWeight: { title: '毛重(KG)', order: 4, view: 'number' },
netWeight: { title: '重(KG)', order: 5, view: 'number' },
materialType: { title: '类型', order: 4, view: 'list', dictCode: 'xslmes_weight_material_type' },
grossWeight: { title: '重(KG)', order: 5, view: 'number' },
netWeight: { title: '净重(KG)', order: 6, view: 'number' },
};

View File

@@ -46,6 +46,8 @@
api: list,
columns,
canResize: true,
// 更新列配置缓存 key避免用户历史列顺序覆盖默认顺序
tableSetting: { cacheKey: 'mesXslWeightRecordColumns_v20260507' },
formConfig: {
schemas: searchFormSchema,
autoSubmitOnEnter: true,