From 3ba0763927b9426223d620ac29152251522acd49 Mon Sep 17 00:00:00 2001 From: zch Date: Thu, 9 Jan 2025 09:20:34 +0800 Subject: [PATCH] =?UTF-8?q?change(mes/baseRoute):=20=E4=BC=98=E5=8C=96?= =?UTF-8?q?=E5=B7=A5=E8=89=BA=E8=B7=AF=E7=BA=BF=E7=BB=84=E6=88=90=E4=BF=A1?= =?UTF-8?q?=E6=81=AF=E6=93=8D=E4=BD=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 添加自动递增的 processOrder 功能 - 修改删除操作,采用重新排列 processOrder 的方式 - 更新选中数据的处理方式,使用 processId 替代索引 --- src/views/mes/baseRoute/index.vue | 30 ++++++++++++++++++++++++------ 1 file changed, 24 insertions(+), 6 deletions(-) diff --git a/src/views/mes/baseRoute/index.vue b/src/views/mes/baseRoute/index.vue index 68ea663..40075fa 100644 --- a/src/views/mes/baseRoute/index.vue +++ b/src/views/mes/baseRoute/index.vue @@ -407,7 +407,7 @@ const routeProcessUpdate = async (row: BaseRouteVO) => { dialog.title = '维护工艺路线步骤'; }; -// 修改rowProdBaseRouteProcessIndex方法,返回类名字符串 +/** 修改rowProdBaseRouteProcessIndex方法,返回类名字符串 */ const rowProdBaseRouteProcessIndex = ({ row, rowIndex }: { row: ProdBaseRouteProcess; rowIndex: number @@ -422,11 +422,20 @@ const rowProdBaseRouteProcessIndex = ({ row, rowIndex }: { // 返回一个空字符串表示不添加额外类名 return ''; }; + /** 工艺路线组成信息添加按钮操作 */ const handleAddProdBaseRouteProcess = () => { + // 找到当前 routeProcessBoList 中的最大 processOrder 值 + const maxProcessOrder = routeProcessBoList.value.reduce((max, item) => { + return Math.max(max, item.processOrder || 0); + }, 0); + + // 新增的 processOrder 值为 maxProcessOrder + 10 + const newProcessOrder = maxProcessOrder + 10; + routeProcessBoList.value.push({ - processId: '', - processOrder: '', + processId: '', // 可以设置一个默认值或自增ID + processOrder: newProcessOrder, remark: '', createBy: '', createTime: '', @@ -435,6 +444,7 @@ const handleAddProdBaseRouteProcess = () => { }); }; + /** 工艺路线组成信息删除按钮操作 */ const handleDeleteProdBaseRouteProcess = () => { // 检查是否有选中的工艺路线组成信息数据,如果没有则显示错误提示 @@ -443,15 +453,23 @@ const handleDeleteProdBaseRouteProcess = () => { } else { // 过滤掉已选中的工艺路线组成信息数据 routeProcessBoList.value = routeProcessBoList.value.filter( - item => !checkedProdBaseRouteProcess.value.includes(item.index) + item => !checkedProdBaseRouteProcess.value.includes(item.processId) ); + + // 重新排列 processOrder + routeProcessBoList.value.forEach((item, index) => { + item.processOrder = (index + 1) * 10; + }); + + // 清空选中的项 + checkedProdBaseRouteProcess.value = []; } }; /** 复选框选中数据 */ const handleProdBaseRouteProcessSelectionChange = (selection: any[]) => { - // 将选中的项的索引映射到checkedProdBaseRouteProcess.value数组中 - checkedProdBaseRouteProcess.value = selection.map(item => item.index); + // 将选中的项的 processId 映射到 checkedProdBaseRouteProcess.value 数组中 + checkedProdBaseRouteProcess.value = selection.map(item => item.processId); }; const getProcessList = async () => {