密炼物料信息

This commit is contained in:
2026-05-06 17:15:52 +08:00
parent 76ed8f0534
commit d2941aa0c7
13 changed files with 540 additions and 2 deletions

View File

@@ -0,0 +1,32 @@
import { defHttp } from '/@/utils/http/axios';
import { Modal } from 'ant-design-vue';
enum Api {
list = '/mes/material/mixerMaterial/list',
save = '/mes/material/mixerMaterial/add',
edit = '/mes/material/mixerMaterial/edit',
deleteOne = '/mes/material/mixerMaterial/delete',
deleteBatch = '/mes/material/mixerMaterial/deleteBatch',
importExcel = '/mes/material/mixerMaterial/importExcel',
exportXls = '/mes/material/mixerMaterial/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: '是否删除选中数据',
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 });

View File

@@ -0,0 +1,117 @@
import { BasicColumn, FormSchema } from '/@/components/Table';
function feedManageStatusText(v: unknown) {
if (v === 1) return '在投管';
if (v === 0) return '未投管';
return '-';
}
function useStatusText(v: unknown) {
if (v === 1) return '使用中';
if (v === 0) return '停用';
return '-';
}
export const columns: BasicColumn[] = [
{ title: '物料编码', align: 'center', width: 120, dataIndex: 'materialCode' },
{ title: '物料名称', align: 'center', width: 160, dataIndex: 'materialName' },
{ title: 'ERP编号', align: 'center', width: 120, dataIndex: 'erpCode' },
{ title: '物料大类', align: 'center', width: 120, dataIndex: 'majorCategoryId_dictText' },
{ title: '物料小类', align: 'center', width: 120, dataIndex: 'minorCategoryId_dictText' },
{ title: '物料描述', align: 'center', width: 180, ellipsis: true, dataIndex: 'materialDesc' },
{ title: '物料别名', align: 'center', width: 120, dataIndex: 'aliasName' },
{
title: '投管状态',
align: 'center',
width: 100,
dataIndex: 'feedManageStatus',
customRender: ({ text }) => feedManageStatusText(text),
},
{
title: '使用状态',
align: 'center',
width: 100,
dataIndex: 'useStatus',
customRender: ({ text }) => useStatusText(text),
},
{ title: '比重', align: 'center', width: 90, dataIndex: 'specificGravity' },
{ title: '保质期(天)', align: 'center', width: 100, dataIndex: 'shelfLifeDays' },
{ title: '最短烘胶(分)', align: 'center', width: 110, dataIndex: 'minBakeMinutes' },
{ title: '总安全库存KG', align: 'center', width: 120, dataIndex: 'totalSafetyStockKg' },
{ title: '合格品安全库存KG', align: 'center', width: 130, dataIndex: 'qualifiedSafetyStockKg' },
{ title: '创建时间', align: 'center', width: 160, dataIndex: 'createTime' },
];
export const searchFormSchema: FormSchema[] = [
{ label: '物料编码', field: 'materialCode', component: 'Input', colProps: { span: 6 } },
{ label: '物料名称', field: 'materialName', component: 'Input', colProps: { span: 6 } },
{ label: 'ERP编号', field: 'erpCode', component: 'Input', colProps: { span: 6 } },
{
label: '物料大类',
field: 'majorCategoryId',
component: 'JDictSelectTag',
componentProps: { dictCode: 'mes_material_category,category_name,id' },
colProps: { span: 6 },
},
];
const feedManageOptions = [
{ label: '在投管', value: 1 },
{ label: '未投管', value: 0 },
];
const useStatusOptions = [
{ label: '使用中', value: 1 },
{ label: '停用', value: 0 },
];
export const formSchema: FormSchema[] = [
{ label: '', field: 'id', component: 'Input', show: false },
{ label: '物料编码', field: 'materialCode', component: 'Input', required: true },
{ label: '物料名称', field: 'materialName', component: 'Input', required: true },
{ label: 'ERP编号', field: 'erpCode', component: 'Input' },
{
label: '物料大类',
field: 'majorCategoryId',
component: 'JDictSelectTag',
componentProps: { dictCode: 'mes_material_category,category_name,id' },
},
{
label: '物料小类',
field: 'minorCategoryId',
component: 'JDictSelectTag',
componentProps: { dictCode: 'mes_material_category,category_name,id' },
},
{ label: '物料描述', field: 'materialDesc', component: 'InputTextArea' },
{ label: '物料别名', field: 'aliasName', component: 'Input' },
{
label: '投管状态',
field: 'feedManageStatus',
component: 'Select',
defaultValue: 1,
componentProps: { options: feedManageOptions },
},
{
label: '使用状态',
field: 'useStatus',
component: 'Select',
defaultValue: 1,
componentProps: { options: useStatusOptions },
},
{ label: '比重', field: 'specificGravity', component: 'InputNumber', componentProps: { min: 0, step: 0.001, precision: 6 } },
{ label: '保质期(天)', field: 'shelfLifeDays', component: 'InputNumber', componentProps: { min: 0, precision: 0 } },
{ label: '最短烘胶时间(分钟)', field: 'minBakeMinutes', component: 'InputNumber', componentProps: { min: 0, precision: 0 } },
{
label: '总安全库存KG',
field: 'totalSafetyStockKg',
component: 'InputNumber',
componentProps: { min: 0, step: 0.0001, precision: 4 },
},
{
label: '合格品安全库存KG',
field: 'qualifiedSafetyStockKg',
component: 'InputNumber',
componentProps: { min: 0, step: 0.0001, precision: 4 },
},
{ label: '备注', field: 'remark', component: 'InputTextArea' },
];

View File

@@ -0,0 +1,79 @@
<template>
<div>
<BasicTable @register="registerTable" :rowSelection="rowSelection">
<template #tableTitle>
<a-button type="primary" v-auth="'mes:mes_mixer_material:add'" @click="handleAdd" preIcon="ant-design:plus-outlined">新增</a-button>
<a-button type="primary" v-auth="'mes:mes_mixer_material:exportXls'" preIcon="ant-design:export-outlined" @click="onExportXls">导出</a-button>
<j-upload-button type="primary" v-auth="'mes:mes_mixer_material: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>批量操作<Icon icon="mdi:chevron-down" /></a-button>
</a-dropdown>
</template>
<template #action="{ record }">
<TableAction :actions="getTableAction(record)" :dropDownActions="getDropDownAction(record)" />
</template>
</BasicTable>
<MesMixerMaterialModal @register="registerModal" @success="handleSuccess" />
</div>
</template>
<script lang="ts" setup>
import { BasicTable, TableAction } from '/@/components/Table';
import { useModal } from '/@/components/Modal';
import { useListPage } from '/@/hooks/system/useListPage';
import MesMixerMaterialModal from './modules/MesMixerMaterialModal.vue';
import { columns, searchFormSchema } from './MesMixerMaterial.data';
import { batchDelete, deleteOne, getExportUrl, getImportUrl, list } from './MesMixerMaterial.api';
const [registerModal, { openModal }] = useModal();
const { tableContext, onExportXls, onImportXls } = useListPage({
tableProps: {
title: '密炼物料信息',
api: list,
columns,
canResize: true,
formConfig: { labelWidth: 120, schemas: searchFormSchema, autoSubmitOnEnter: true, showAdvancedButton: true },
actionColumn: { width: 120 },
},
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 }, reload);
}
async function batchHandleDelete() {
await batchDelete({ ids: selectedRowKeys.value }, reload);
}
function handleSuccess() {
reload();
}
function getTableAction(record) {
return [{ label: '编辑', onClick: handleEdit.bind(null, record), auth: 'mes:mes_mixer_material:edit' }];
}
function getDropDownAction(record) {
return [
{ label: '详情', onClick: handleDetail.bind(null, record) },
{
label: '删除',
popConfirm: { title: '是否确认删除', confirm: handleDelete.bind(null, record) },
auth: 'mes:mes_mixer_material:delete',
},
];
}
</script>

View File

@@ -0,0 +1,46 @@
<template>
<BasicModal @register="registerModal" :title="title" width="720px" 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 '../MesMixerMaterial.data';
import { saveOrUpdate } from '../MesMixerMaterial.api';
const emit = defineEmits(['register', 'success']);
const isUpdate = ref(true);
const [registerForm, { resetFields, setFieldsValue, validate, setProps }] = useForm({
labelWidth: 140,
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>

View File

@@ -0,0 +1,7 @@
<template>
<MesMixerMaterialList />
</template>
<script lang="ts" setup>
import MesMixerMaterialList from '../material/MesMixerMaterialList.vue';
</script>