密炼机动作维护、日罐物料对应关系

This commit is contained in:
2026-05-21 10:04:06 +08:00
parent 09c58f80eb
commit e678276aba
24 changed files with 1443 additions and 0 deletions

View File

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

View File

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

View File

@@ -0,0 +1,28 @@
import { defHttp } from '/@/utils/http/axios';
enum Api {
list = '/xslmes/mesXslDayTankMaterialMap/list',
save = '/xslmes/mesXslDayTankMaterialMap/add',
edit = '/xslmes/mesXslDayTankMaterialMap/edit',
deleteOne = '/xslmes/mesXslDayTankMaterialMap/delete',
deleteBatch = '/xslmes/mesXslDayTankMaterialMap/deleteBatch',
queryById = '/xslmes/mesXslDayTankMaterialMap/queryById',
exportXls = '/xslmes/mesXslDayTankMaterialMap/exportXls',
equipmentQueryById = '/xslmes/mesXslEquipmentLedger/queryById',
}
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) =>
defHttp.delete({ url: Api.deleteBatch, params }, { joinParamsToUrl: true }).then(() => handleSuccess());
export const saveOrUpdate = (params, isUpdate) => defHttp.post({ url: isUpdate ? Api.edit : Api.save, params });
export const queryById = (params) => defHttp.get({ url: Api.queryById, params });
export const queryEquipmentById = (params: { id: string }) => defHttp.get({ url: Api.equipmentQueryById, params });
export const getExportUrl = Api.exportXls;

View File

@@ -0,0 +1,154 @@
import { BasicColumn, FormSchema } from '/@/components/Table';
import { loadTreeData } from '/@/api/common/api';
import { queryEquipmentById } from './MesXslDayTankMaterialMap.api';
function useStatusText(v: unknown) {
if (v === 1) return '使用中';
if (v === 0) return '停用';
return '-';
}
function allowSyncText(v: unknown) {
if (v === 1) return '允许';
if (v === 0) return '不允许';
return '-';
}
const useStatusOptions = [
{ label: '使用中', value: 1 },
{ label: '停用', value: 0 },
];
const allowSyncOptions = [
{ label: '允许', value: 1 },
{ label: '不允许', value: 0 },
];
export const columns: BasicColumn[] = [
{ title: '机台代码', align: 'center', dataIndex: 'machineCode', width: 140 },
{ title: '机台名称', align: 'center', dataIndex: 'equipmentId_dictText', width: 160 },
{ title: '料仓分类', align: 'center', dataIndex: 'siloCategoryId_dictText', width: 140 },
{ title: '工位', align: 'center', dataIndex: 'station', width: 120 },
{ title: '料仓号', align: 'center', dataIndex: 'siloNo', width: 120 },
{ title: '物料名称', align: 'center', dataIndex: 'materialId_dictText', width: 160 },
{
title: '使用状态',
align: 'center',
dataIndex: 'useStatus',
width: 120,
customRender: ({ text }) => useStatusText(text),
},
{
title: '是否允许同步',
align: 'center',
dataIndex: 'allowSync',
width: 120,
customRender: ({ text }) => allowSyncText(text),
},
];
export const searchFormSchema: FormSchema[] = [
{
label: '机台名称',
field: 'equipmentId',
component: 'JDictSelectTag',
componentProps: { dictCode: 'mes_xsl_equipment_ledger,equipment_name,id' },
colProps: { span: 6 },
},
{
label: '物料名称',
field: 'materialId',
component: 'JDictSelectTag',
componentProps: { dictCode: 'mes_material,material_name,id' },
colProps: { span: 6 },
},
{
label: '料仓分类',
field: 'siloCategoryId',
component: 'ApiSelect',
componentProps: {
api: loadTreeData,
params: { pcode: 'XSLMES_LCTYPE' },
resultField: '',
labelField: 'title',
valueField: 'key',
placeholder: '请选择料仓分类',
},
colProps: { span: 6 },
},
{
label: '使用状态',
field: 'useStatus',
component: 'Select',
componentProps: { options: useStatusOptions },
colProps: { span: 6 },
},
];
export const formSchema: FormSchema[] = [
{ label: '', field: 'id', component: 'Input', show: false },
{
label: '机台名称',
field: 'equipmentId',
component: 'JDictSelectTag',
required: true,
componentProps: ({ formModel }) => ({
dictCode: 'mes_xsl_equipment_ledger,equipment_name,id',
placeholder: '请选择设备台账中的机台名称',
onChange: async (value: string) => {
if (!value) {
formModel.machineCode = '';
return;
}
try {
const equipment = await queryEquipmentById({ id: value });
formModel.machineCode = equipment?.equipmentCode || '';
} catch {
formModel.machineCode = '';
}
},
}),
},
{
label: '机台代码',
field: 'machineCode',
component: 'Input',
componentProps: { disabled: true, placeholder: '选择机台名称后自动带出设备编号' },
},
{
label: '料仓分类',
field: 'siloCategoryId',
component: 'ApiSelect',
componentProps: {
api: loadTreeData,
params: { pcode: 'XSLMES_LCTYPE' },
resultField: '',
labelField: 'title',
valueField: 'key',
placeholder: '请选择料仓分类',
},
},
{ label: '工位', field: 'station', component: 'Input' },
{ label: '料仓号', field: 'siloNo', component: 'Input' },
{
label: '物料名称',
field: 'materialId',
component: 'JDictSelectTag',
required: true,
componentProps: { dictCode: 'mes_material,material_name,id', placeholder: '请选择胶料信息中的物料名称' },
},
{
label: '使用状态',
field: 'useStatus',
component: 'Select',
defaultValue: 1,
componentProps: { options: useStatusOptions },
},
{
label: '是否允许同步',
field: 'allowSync',
component: 'Select',
defaultValue: 1,
componentProps: { options: allowSyncOptions },
},
];

View File

@@ -0,0 +1,84 @@
<template>
<div>
<BasicTable @register="registerTable" :rowSelection="rowSelection">
<template #tableTitle>
<a-button type="primary" v-auth="'xslmes:mes_xsl_day_tank_material_map:add'" @click="handleAdd" preIcon="ant-design:plus-outlined">新增</a-button>
<a-button
type="primary"
v-auth="'xslmes:mes_xsl_day_tank_material_map:exportXls'"
preIcon="ant-design:export-outlined"
@click="onExportXls"
>
导出
</a-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>
<MesXslDayTankMaterialMapModal @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 MesXslDayTankMaterialMapModal from './modules/MesXslDayTankMaterialMapModal.vue';
import { columns, searchFormSchema } from './MesXslDayTankMaterialMap.data';
import { batchDelete, deleteOne, getExportUrl, list } from './MesXslDayTankMaterialMap.api';
const [registerModal, { openModal }] = useModal();
const { tableContext, onExportXls } = useListPage({
tableProps: {
title: '日罐物料对应信息',
api: list,
columns,
canResize: true,
formConfig: { labelWidth: 100, schemas: searchFormSchema, autoSubmitOnEnter: true },
actionColumn: { width: 120, fixed: 'right' },
},
exportConfig: { name: '日罐物料对应信息', url: getExportUrl },
});
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.join(',') }, reload);
}
function handleSuccess() {
reload();
}
function getTableAction(record) {
return [{ label: '编辑', onClick: handleEdit.bind(null, record), auth: 'xslmes:mes_xsl_day_tank_material_map:edit' }];
}
function getDropDownAction(record) {
return [
{ label: '详情', onClick: handleDetail.bind(null, record) },
{
label: '删除',
popConfirm: { title: '是否确认删除', confirm: handleDelete.bind(null, record) },
auth: 'xslmes:mes_xsl_day_tank_material_map:delete',
},
];
}
</script>

View File

@@ -0,0 +1,67 @@
<template>
<BasicModal v-bind="$attrs" @register="registerModal" :title="title" width="760px" @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 '../MesXslDayTankMaterialMap.data';
import { queryEquipmentById, saveOrUpdate } from '../MesXslDayTankMaterialMap.api';
const emit = defineEmits(['register', 'success']);
const isUpdate = ref(true);
const isDetail = ref(false);
const [registerForm, { resetFields, setFieldsValue, validate, setProps, getFieldsValue }] = useForm({
labelWidth: 110,
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;
isDetail.value = !data?.showFooter;
if (unref(isUpdate)) {
await setFieldsValue({ ...data.record });
} else {
await setFieldsValue({ useStatus: 1, allowSync: 1 });
}
setProps({ disabled: !data?.showFooter });
});
const title = computed(() =>
!unref(isUpdate) ? '新增日罐物料对应信息' : unref(isDetail) ? '日罐物料对应信息详情' : '编辑日罐物料对应信息',
);
async function fillMachineCodeByEquipment() {
const values = getFieldsValue();
if (!values?.equipmentId) {
await setFieldsValue({ machineCode: '' });
return;
}
try {
const equipment = await queryEquipmentById({ id: values.equipmentId });
await setFieldsValue({ machineCode: equipment?.equipmentCode || '' });
} catch {
await setFieldsValue({ machineCode: '' });
}
}
async function handleSubmit() {
try {
await fillMachineCodeByEquipment();
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,33 @@
import { defHttp } from '/@/utils/http/axios';
enum Api {
list = '/xslmes/mesXslMixerAction/list',
checkActionName = '/xslmes/mesXslMixerAction/checkActionName',
checkActionCode = '/xslmes/mesXslMixerAction/checkActionCode',
save = '/xslmes/mesXslMixerAction/add',
edit = '/xslmes/mesXslMixerAction/edit',
deleteOne = '/xslmes/mesXslMixerAction/delete',
deleteBatch = '/xslmes/mesXslMixerAction/deleteBatch',
queryById = '/xslmes/mesXslMixerAction/queryById',
exportXls = '/xslmes/mesXslMixerAction/exportXls',
}
export const list = (params) => defHttp.get({ url: Api.list, params });
export const checkActionName = (params: { actionName: string; dataId?: string }) =>
defHttp.get({ url: Api.checkActionName, params }, { successMessageMode: 'none', errorMessageMode: 'none' });
export const checkActionCode = (params: { actionCode: string; dataId?: string }) =>
defHttp.get({ url: Api.checkActionCode, params }, { successMessageMode: 'none', errorMessageMode: 'none' });
export const deleteOne = (params, handleSuccess) =>
defHttp.delete({ url: Api.deleteOne, params }, { joinParamsToUrl: true }).then(() => handleSuccess());
export const batchDelete = (params, handleSuccess) =>
defHttp.delete({ url: Api.deleteBatch, params }, { joinParamsToUrl: true }).then(() => handleSuccess());
export const saveOrUpdate = (params, isUpdate) => defHttp.post({ url: isUpdate ? Api.edit : Api.save, params });
export const queryById = (params) => defHttp.get({ url: Api.queryById, params });
export const getExportUrl = Api.exportXls;

View File

@@ -0,0 +1,76 @@
import { BasicColumn, FormSchema } from '/@/components/Table';
import { checkActionCode, checkActionName } from './MesXslMixerAction.api';
export const columns: BasicColumn[] = [
{ title: '设备名称', align: 'center', dataIndex: 'equipmentId_dictText', width: 180 },
{ title: '动作名称', align: 'center', dataIndex: 'actionName', width: 180 },
{ title: '动作代号', align: 'center', dataIndex: 'actionCode', width: 160 },
{ title: '创建时间', align: 'center', dataIndex: 'createTime', width: 170 },
];
export const searchFormSchema: FormSchema[] = [
{
label: '设备名称',
field: 'equipmentId',
component: 'JDictSelectTag',
componentProps: { dictCode: 'mes_xsl_equipment_ledger,equipment_name,id' },
colProps: { span: 6 },
},
{ label: '动作名称', field: 'actionName', component: 'Input', colProps: { span: 6 } },
{ label: '动作代号', field: 'actionCode', component: 'Input', colProps: { span: 6 } },
];
export const formSchema: FormSchema[] = [
{ label: '', field: 'id', component: 'Input', show: false },
{
label: '设备名称',
field: 'equipmentId',
component: 'JDictSelectTag',
required: true,
componentProps: { dictCode: 'mes_xsl_equipment_ledger,equipment_name,id', placeholder: '请选择设备台账中的设备' },
},
{
label: '动作名称',
field: 'actionName',
component: 'Input',
required: true,
dynamicRules: ({ model }) => [
{ required: true, message: '请输入动作名称' },
{
validator: async (_rule, value) => {
const v = value == null ? '' : String(value).trim();
if (!v) return Promise.resolve();
try {
await checkActionName({ actionName: v, dataId: model?.id });
return Promise.resolve();
} catch (e: any) {
return Promise.reject(e?.response?.data?.message || e?.message || '动作名称不能重复');
}
},
trigger: 'blur',
},
],
},
{
label: '动作代号',
field: 'actionCode',
component: 'Input',
required: true,
dynamicRules: ({ model }) => [
{ required: true, message: '请输入动作代号' },
{
validator: async (_rule, value) => {
const v = value == null ? '' : String(value).trim();
if (!v) return Promise.resolve();
try {
await checkActionCode({ actionCode: v, dataId: model?.id });
return Promise.resolve();
} catch (e: any) {
return Promise.reject(e?.response?.data?.message || e?.message || '动作代号不能重复');
}
},
trigger: 'blur',
},
],
},
];

View File

@@ -0,0 +1,84 @@
<template>
<div>
<BasicTable @register="registerTable" :rowSelection="rowSelection">
<template #tableTitle>
<a-button type="primary" v-auth="'xslmes:mes_xsl_mixer_action:add'" @click="handleAdd" preIcon="ant-design:plus-outlined">新增</a-button>
<a-button
type="primary"
v-auth="'xslmes:mes_xsl_mixer_action:exportXls'"
preIcon="ant-design:export-outlined"
@click="onExportXls"
>
导出
</a-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>
<MesXslMixerActionModal @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 MesXslMixerActionModal from './modules/MesXslMixerActionModal.vue';
import { columns, searchFormSchema } from './MesXslMixerAction.data';
import { batchDelete, deleteOne, getExportUrl, list } from './MesXslMixerAction.api';
const [registerModal, { openModal }] = useModal();
const { tableContext, onExportXls } = useListPage({
tableProps: {
title: '密炼机动作维护',
api: list,
columns,
canResize: true,
formConfig: { labelWidth: 100, schemas: searchFormSchema, autoSubmitOnEnter: true },
actionColumn: { width: 120, fixed: 'right' },
},
exportConfig: { name: '密炼机动作维护', url: getExportUrl },
});
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.join(',') }, reload);
}
function handleSuccess() {
reload();
}
function getTableAction(record) {
return [{ label: '编辑', onClick: handleEdit.bind(null, record), auth: 'xslmes:mes_xsl_mixer_action:edit' }];
}
function getDropDownAction(record) {
return [
{ label: '详情', onClick: handleDetail.bind(null, record) },
{
label: '删除',
popConfirm: { title: '是否确认删除', confirm: handleDelete.bind(null, record) },
auth: 'xslmes:mes_xsl_mixer_action:delete',
},
];
}
</script>

View File

@@ -0,0 +1,48 @@
<template>
<BasicModal v-bind="$attrs" @register="registerModal" :title="title" width="680px" @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 '../MesXslMixerAction.data';
import { saveOrUpdate } from '../MesXslMixerAction.api';
const emit = defineEmits(['register', 'success']);
const isUpdate = ref(true);
const isDetail = ref(false);
const [registerForm, { resetFields, setFieldsValue, validate, setProps }] = useForm({
labelWidth: 110,
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;
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, isUpdate.value);
closeModal();
emit('success');
} finally {
setModalProps({ confirmLoading: false });
}
}
</script>