新增参照历史混合步骤功能,包含混合步骤复制、状态解析及历史步骤选择弹窗,优化用户交互体验。
This commit is contained in:
@@ -1115,3 +1115,73 @@ export function applyMixingMaterialFromSelection(row: Recordable, material: Reco
|
||||
//update-end---author:cursor ---date:20260525 for:【XSLMES-20260525-A53】种类仅读配置表,移除小类名兜底-----------
|
||||
}
|
||||
//update-end---author:cursor ---date:20260525 for:【XSLMES-20260525-A50】混炼示方密炼物料选料弹窗与种类解析-----------
|
||||
|
||||
//update-begin---author:cursor ---date:20260526 for:【XSLMES-20260526-A58】参照历史混合步骤选择弹窗-----------
|
||||
/** 混合步骤可复制的业务字段 */
|
||||
export const MIXING_STEP_COPY_FIELD_KEYS = [
|
||||
'sortNo',
|
||||
'actionName',
|
||||
'actionSec',
|
||||
'protectSec',
|
||||
'tempC',
|
||||
'powerKw',
|
||||
'energyKwh',
|
||||
'comboMode',
|
||||
'speedRpm',
|
||||
'pressureMpa',
|
||||
'boltPercent',
|
||||
] as const;
|
||||
|
||||
/** 判断混合步骤行是否含有效业务数据 */
|
||||
export function isMixingStepRowFilled(row: Recordable = {}): boolean {
|
||||
return MIXING_STEP_COPY_FIELD_KEYS.some((key) => {
|
||||
const value = row[key];
|
||||
return value != null && value !== '';
|
||||
});
|
||||
}
|
||||
|
||||
/** 从历史混炼示方混合步骤克隆为新行(生成新 id,剔除主表/审计字段) */
|
||||
export function cloneMixingHistoryStepRows(sourceRows: Recordable[] = []): Recordable[] {
|
||||
return (sourceRows || [])
|
||||
.filter((row) => isMixingStepRowFilled(row))
|
||||
.map((row, index) => {
|
||||
const next: Recordable = { id: buildUUID() };
|
||||
MIXING_STEP_COPY_FIELD_KEYS.forEach((key) => {
|
||||
const value = row[key];
|
||||
if (value != null && value !== '') {
|
||||
next[key] = value;
|
||||
}
|
||||
});
|
||||
if (next.sortNo == null) {
|
||||
next.sortNo = index + 1;
|
||||
}
|
||||
return next;
|
||||
});
|
||||
}
|
||||
|
||||
/** 解析混炼示方配方状态(参照旧系统展示) */
|
||||
export function resolveMixingSpecFormulaStatus(record: Recordable = {}): string {
|
||||
if (Number(record.delFlag) === 1) {
|
||||
return '作废';
|
||||
}
|
||||
if (record.approveTime) {
|
||||
return '审批通过';
|
||||
}
|
||||
return '编制中';
|
||||
}
|
||||
|
||||
/** 参照历史混合步骤:混炼示方选择列表列 */
|
||||
export const mixingSpecHistorySelectColumns: BasicColumn[] = [
|
||||
{ title: '示方编号', align: 'center', dataIndex: 'specName', width: 160 },
|
||||
{ title: '机台', align: 'center', dataIndex: 'machineName', width: 100 },
|
||||
{ title: '发行编号', align: 'center', dataIndex: 'issueNumber', width: 150 },
|
||||
{ title: '发行日期', align: 'center', dataIndex: 'makeDate', width: 120 },
|
||||
{
|
||||
title: '配方状态',
|
||||
align: 'center',
|
||||
dataIndex: 'formulaStatus',
|
||||
width: 100,
|
||||
customRender: ({ record }) => resolveMixingSpecFormulaStatus(record),
|
||||
},
|
||||
];
|
||||
//update-end---author:cursor ---date:20260526 for:【XSLMES-20260526-A58】参照历史混合步骤选择弹窗-----------
|
||||
|
||||
@@ -284,6 +284,9 @@
|
||||
<span>混合步骤</span>
|
||||
<div class="panel-head-actions" @click.stop>
|
||||
<MesXslMixingTableRowHeightSetting table-key="step" v-model:preference="stepHeightPref" />
|
||||
<!--update-begin---author:cursor ---date:20260526 for:【XSLMES-20260526-A58】混合步骤参照历史示方按钮----------- -->
|
||||
<a-button v-if="showFooter" size="small" @click="openHistoryStepPicker">参照历史混合步骤</a-button>
|
||||
<!--update-end---author:cursor ---date:20260526 for:【XSLMES-20260526-A58】混合步骤参照历史示方按钮----------- -->
|
||||
<a-button v-if="showFooter" size="small" type="primary" @click="addStepRow">新增行</a-button>
|
||||
</div>
|
||||
</div>
|
||||
@@ -417,6 +420,7 @@
|
||||
<MesXslEquipmentLedgerSelectModal @register="registerMachineModal" @select="onMachineSelect" />
|
||||
<MesXslMixerPsCompileSelectModal @register="registerIssueNumberModal" @select="onIssueNumberSelect" />
|
||||
<MesXslMixingMaterialSelectModal @register="registerMixingMaterialModal" @select="onMixingMaterialSelect" />
|
||||
<MesXslMixingSpecStepHistorySelectModal @register="registerHistoryStepModal" @select="onHistoryStepSelect" />
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
@@ -466,6 +470,7 @@ import {
|
||||
syncMaterialBaseUnitWeightFromDisplay,
|
||||
calcMixingFillVolume,
|
||||
resolveMixingSpecificGravity,
|
||||
cloneMixingHistoryStepRows,
|
||||
MIXING_MATERIAL_ROW_NUMBER_WIDTH,
|
||||
MIXING_MATERIAL_FOOTER_ROW_HEIGHT,
|
||||
MIXING_MATERIAL_MIN_COLUMN_WIDTH,
|
||||
@@ -482,6 +487,7 @@ import MesXslEquipmentLedgerSelectModal from '/@/views/xslmes/mesXslEquipInspect
|
||||
import { queryById as queryEquipmentById } from '/@/views/xslmes/mesXslEquipmentLedger/MesXslEquipmentLedger.api';
|
||||
import MesXslMixerPsCompileSelectModal from '/@/views/xslmes/mesXslMixerPsCompile/components/MesXslMixerPsCompileSelectModal.vue';
|
||||
import MesXslMixingMaterialSelectModal from './MesXslMixingMaterialSelectModal.vue';
|
||||
import MesXslMixingSpecStepHistorySelectModal from './MesXslMixingSpecStepHistorySelectModal.vue';
|
||||
|
||||
const emit = defineEmits(['register', 'success']);
|
||||
const { createMessage } = useMessage();
|
||||
@@ -886,12 +892,16 @@ const [registerForm, { resetFields, setFieldsValue, validate, setProps }] = useF
|
||||
const [registerMachineModal, { openModal: openMachineModalInner, closeModal: closeMachineModal }] = useModal();
|
||||
const [registerIssueNumberModal, { openModal: openIssueNumberModalInner, closeModal: closeIssueNumberModal }] = useModal();
|
||||
const [registerMixingMaterialModal, { openModal: openMixingMaterialModalInner, closeModal: closeMixingMaterialModal, setModalProps: setMixingMaterialModalProps }] = useModal();
|
||||
//update-begin---author:cursor ---date:20260526 for:【XSLMES-20260526-A58】参照历史混合步骤选择弹窗-----------
|
||||
const [registerHistoryStepModal, { openModal: openHistoryStepModalInner, closeModal: closeHistoryStepModal, setModalProps: setHistoryStepModalProps }] = useModal();
|
||||
//update-end---author:cursor ---date:20260526 for:【XSLMES-20260526-A58】参照历史混合步骤选择弹窗-----------
|
||||
|
||||
//update-begin---author:cursor ---date:20260525 for:【XSLMES-20260525-A52】关闭混炼示方弹窗时同步关闭嵌套选料弹窗-----------
|
||||
function closeNestedPickers() {
|
||||
closeMixingMaterialModal();
|
||||
closeMachineModal();
|
||||
closeIssueNumberModal();
|
||||
closeHistoryStepModal();
|
||||
materialPickerRow.value = null;
|
||||
}
|
||||
//update-end---author:cursor ---date:20260525 for:【XSLMES-20260525-A52】关闭混炼示方弹窗时同步关闭嵌套选料弹窗-----------
|
||||
@@ -950,6 +960,38 @@ function onMixingMaterialSelect(payload: Recordable | null) {
|
||||
recalcMaterialAccumWeight();
|
||||
materialPickerRow.value = null;
|
||||
}
|
||||
|
||||
//update-begin---author:cursor ---date:20260526 for:【XSLMES-20260526-A58】参照历史混合步骤回填明细-----------
|
||||
function openHistoryStepPicker() {
|
||||
if (!showFooter.value) {
|
||||
return;
|
||||
}
|
||||
setHistoryStepModalProps({ zIndex: 1500 });
|
||||
openHistoryStepModalInner(true, {
|
||||
machineId: sheetForm.machineId || '',
|
||||
excludeSpecId: sheetForm.id || '',
|
||||
});
|
||||
}
|
||||
|
||||
async function onHistoryStepSelect(payload: Recordable | null) {
|
||||
if (!payload?.mixingSpecId) {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
const raw = await queryById({ id: payload.mixingSpecId });
|
||||
const row = (raw as Recordable)?.specName != null ? raw : (raw as Recordable)?.result;
|
||||
const clonedSteps = cloneMixingHistoryStepRows(row?.stepList || []);
|
||||
if (!clonedSteps.length) {
|
||||
createMessage.warning('所选混炼示方没有可参照的混合步骤');
|
||||
return;
|
||||
}
|
||||
stepData.value = ensureMixingDetailRows(clonedSteps, DEFAULT_MIXING_STEP_ROW_COUNT);
|
||||
createMessage.success(`已参照「${payload.specName || row?.specName || ''}」混合步骤`);
|
||||
} catch {
|
||||
createMessage.error('加载历史混合步骤失败');
|
||||
}
|
||||
}
|
||||
//update-end---author:cursor ---date:20260526 for:【XSLMES-20260526-A58】参照历史混合步骤回填明细-----------
|
||||
//update-end---author:cursor ---date:20260522 for:【XSLMES-20260522-A33】混炼示方主表选择弹窗-----------
|
||||
|
||||
function ensureTcuDefaultRows(rows: Recordable[] = []) {
|
||||
|
||||
@@ -0,0 +1,232 @@
|
||||
<template>
|
||||
<BasicModal
|
||||
v-bind="$attrs"
|
||||
title="选取混合示方(双击表格可选择)"
|
||||
:width="960"
|
||||
:zIndex="1500"
|
||||
wrapClassName="mixing-step-history-picker-modal-wrap"
|
||||
@register="registerModal"
|
||||
@ok="handleOk"
|
||||
>
|
||||
<div class="mixing-step-history-picker">
|
||||
<div class="mixing-step-history-picker-toolbar">
|
||||
<span class="mixing-step-history-picker-label">关键字</span>
|
||||
<a-input
|
||||
v-model:value="keyword"
|
||||
allow-clear
|
||||
placeholder="规格/用途/发行编号/机台"
|
||||
style="width: 240px"
|
||||
@pressEnter="reloadTable"
|
||||
/>
|
||||
<span class="mixing-step-history-picker-label">机台</span>
|
||||
<a-select
|
||||
v-model:value="machineId"
|
||||
allow-clear
|
||||
show-search
|
||||
option-filter-prop="label"
|
||||
placeholder="==请选择=="
|
||||
style="width: 160px"
|
||||
:options="machineOptions"
|
||||
:loading="machineLoading"
|
||||
:getPopupContainer="getSelectPopupContainer"
|
||||
popupClassName="mixing-step-history-picker-machine-dropdown"
|
||||
@click.stop
|
||||
/>
|
||||
<a-button type="primary" @click="reloadTable">搜索</a-button>
|
||||
</div>
|
||||
<BasicTable @register="registerTable" @row-dbClick="handleRowDbClick" />
|
||||
</div>
|
||||
</BasicModal>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { ref } from 'vue';
|
||||
import { BasicModal, useModalInner } from '/@/components/Modal';
|
||||
import { BasicTable, useTable } from '/@/components/Table';
|
||||
import { useMessage } from '/@/hooks/web/useMessage';
|
||||
import { list as mixingSpecList, queryById as queryMixingSpecById } from '../MesXslMixingSpec.api';
|
||||
import { mixingSpecHistorySelectColumns } from '../MesXslMixingSpec.data';
|
||||
import { list as equipmentList } from '/@/views/xslmes/mesXslEquipmentLedger/MesXslEquipmentLedger.api';
|
||||
|
||||
const emit = defineEmits(['register', 'select']);
|
||||
|
||||
const { createMessage } = useMessage();
|
||||
|
||||
const keyword = ref('');
|
||||
const machineId = ref<string | undefined>(undefined);
|
||||
const machineOptions = ref<Array<{ label: string; value: string }>>([]);
|
||||
const machineLoading = ref(false);
|
||||
const excludeSpecId = ref('');
|
||||
const selectedRow = ref<Recordable | null>(null);
|
||||
|
||||
function getSelectPopupContainer() {
|
||||
return document.body;
|
||||
}
|
||||
|
||||
const [registerTable, { reload, getSelectRowKeys, getSelectRows, setSelectedRowKeys, clearSelectedRowKeys }] = useTable({
|
||||
api: mixingSpecList,
|
||||
columns: mixingSpecHistorySelectColumns,
|
||||
rowKey: 'id',
|
||||
useSearchForm: false,
|
||||
pagination: { pageSize: 30 },
|
||||
canResize: false,
|
||||
showIndexColumn: true,
|
||||
immediate: false,
|
||||
beforeFetch: (params) => ({
|
||||
...params,
|
||||
keyword: keyword.value?.trim() || undefined,
|
||||
machineId: machineId.value || undefined,
|
||||
}),
|
||||
afterFetch: (rows) => {
|
||||
if (!excludeSpecId.value) {
|
||||
return rows;
|
||||
}
|
||||
return (rows || []).filter((row) => row?.id !== excludeSpecId.value);
|
||||
},
|
||||
rowSelection: {
|
||||
type: 'radio',
|
||||
columnWidth: 48,
|
||||
onChange: (_keys, rows) => {
|
||||
selectedRow.value = rows?.[0] ?? null;
|
||||
},
|
||||
},
|
||||
clickToRowSelect: true,
|
||||
});
|
||||
|
||||
async function loadMachineOptions() {
|
||||
machineLoading.value = true;
|
||||
try {
|
||||
const optionMap = new Map<string, { label: string; value: string }>();
|
||||
const raw = await mixingSpecList({ pageNo: 1, pageSize: 500 });
|
||||
const page = (raw as Recordable)?.records != null ? raw : (raw as Recordable)?.result;
|
||||
const specRecords = ((page?.records || page || []) as Recordable[]).filter(Boolean);
|
||||
specRecords.forEach((row) => {
|
||||
if (!row?.machineId) {
|
||||
return;
|
||||
}
|
||||
const value = String(row.machineId);
|
||||
optionMap.set(value, {
|
||||
value,
|
||||
label: row.machineName || value,
|
||||
});
|
||||
});
|
||||
if (!optionMap.size) {
|
||||
const eqRaw = await equipmentList({ pageNo: 1, pageSize: 500 });
|
||||
const eqPage = (eqRaw as Recordable)?.records != null ? eqRaw : (eqRaw as Recordable)?.result;
|
||||
const eqRecords = ((eqPage?.records || eqPage || []) as Recordable[]).filter(Boolean);
|
||||
eqRecords.forEach((row) => {
|
||||
if (!row?.id) {
|
||||
return;
|
||||
}
|
||||
const value = String(row.id);
|
||||
optionMap.set(value, {
|
||||
value,
|
||||
label: row.equipmentName || row.equipmentCode || value,
|
||||
});
|
||||
});
|
||||
}
|
||||
machineOptions.value = Array.from(optionMap.values()).sort((a, b) =>
|
||||
a.label.localeCompare(b.label, 'zh-CN'),
|
||||
);
|
||||
} catch {
|
||||
machineOptions.value = [];
|
||||
} finally {
|
||||
machineLoading.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
function reloadTable() {
|
||||
reload();
|
||||
}
|
||||
|
||||
async function resolveSelectedRow(): Promise<Recordable | null> {
|
||||
const keys = (getSelectRowKeys?.() || []) as string[];
|
||||
let row = selectedRow.value || ((getSelectRows?.() || []) as Recordable[])[0];
|
||||
if (!row?.id && keys.length) {
|
||||
try {
|
||||
const raw = await queryMixingSpecById({ id: keys[0] });
|
||||
row = (raw as Recordable)?.specName != null ? raw : (raw as Recordable)?.result;
|
||||
} catch {
|
||||
row = null;
|
||||
}
|
||||
}
|
||||
return row?.id ? row : null;
|
||||
}
|
||||
|
||||
async function confirmSelect(row: Recordable) {
|
||||
if (!row?.id) {
|
||||
createMessage.warning('请选择一条混炼示方');
|
||||
return;
|
||||
}
|
||||
if (row.id === excludeSpecId.value) {
|
||||
createMessage.warning('不能参照当前正在编辑的混炼示方');
|
||||
return;
|
||||
}
|
||||
emit('select', {
|
||||
mixingSpecId: row.id,
|
||||
specName: row.specName || '',
|
||||
machineName: row.machineName || '',
|
||||
issueNumber: row.issueNumber || '',
|
||||
});
|
||||
closeModal();
|
||||
}
|
||||
|
||||
async function handleOk() {
|
||||
const row = await resolveSelectedRow();
|
||||
if (!row) {
|
||||
createMessage.warning('请选择一条混炼示方');
|
||||
return;
|
||||
}
|
||||
await confirmSelect(row);
|
||||
}
|
||||
|
||||
async function handleRowDbClick(record: Recordable) {
|
||||
if (!record?.id) {
|
||||
return;
|
||||
}
|
||||
setSelectedRowKeys?.([record.id]);
|
||||
selectedRow.value = record;
|
||||
await confirmSelect(record);
|
||||
}
|
||||
|
||||
const [registerModal, { setModalProps, closeModal }] = useModalInner(async (data) => {
|
||||
keyword.value = '';
|
||||
machineId.value = data?.machineId || undefined;
|
||||
excludeSpecId.value = data?.excludeSpecId || '';
|
||||
selectedRow.value = null;
|
||||
clearSelectedRowKeys?.();
|
||||
setModalProps({ confirmLoading: false });
|
||||
await loadMachineOptions();
|
||||
reload();
|
||||
});
|
||||
</script>
|
||||
|
||||
<style lang="less" scoped>
|
||||
.mixing-step-history-picker-toolbar {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
flex-wrap: wrap;
|
||||
gap: 8px;
|
||||
margin-bottom: 12px;
|
||||
}
|
||||
|
||||
.mixing-step-history-picker-label {
|
||||
color: #333;
|
||||
font-size: 13px;
|
||||
white-space: nowrap;
|
||||
}
|
||||
</style>
|
||||
|
||||
<style lang="less">
|
||||
/* 嵌套在全屏混炼示方弹窗之上,避免被父弹窗遮挡 */
|
||||
.mixing-step-history-picker-modal-wrap {
|
||||
.ant-modal {
|
||||
top: 40px;
|
||||
}
|
||||
}
|
||||
|
||||
/* 机台下拉挂到 body,避免弹窗 overflow 裁剪;层级高于 Modal */
|
||||
.mixing-step-history-picker-machine-dropdown {
|
||||
z-index: 2100 !important;
|
||||
}
|
||||
</style>
|
||||
Reference in New Issue
Block a user