From 40bfc450b1216acd2f54f36dc6ab0160c3d284b2 Mon Sep 17 00:00:00 2001 From: maochaoying <925670706@qq.com> Date: Fri, 28 Jul 2023 15:08:53 +0800 Subject: [PATCH] diy patj --- src/components/PathPlan.vue | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/src/components/PathPlan.vue b/src/components/PathPlan.vue index 8b900ec..137163c 100644 --- a/src/components/PathPlan.vue +++ b/src/components/PathPlan.vue @@ -42,8 +42,6 @@ const getLine = (index, position) => { return '' } -const pathArr = ref([]) - const showPath = item => { const testArr = taskStore.pathData.filter(it => it.number == item) if (testArr?.length > 0) { @@ -67,10 +65,10 @@ const planPath = item => { // 数组自记录order const coord = transItemToCoord(item) // 校验下当前数组中是否有该coord 有则删除,并且修改其余的order - const testArr = pathArr.value.filter(item => item.coord == coord) + const testArr = taskStore.pathData.filter(item => item.coord == coord) if (testArr?.length > 0) { // 有 - const leftArr = pathArr.value.filter(item => item.coord != coord) + const leftArr = taskStore.pathData.filter(item => item.coord != coord) const del = testArr[0] const delOrder = del.orderNumber leftArr.map(item => { @@ -79,16 +77,17 @@ const planPath = item => { item.orderNumber = item.orderNumber - 1 } }) - pathArr.value = leftArr + taskStore.updatePathData(leftArr) } else { // 没有 let obj = {} obj.coord = coord obj.number = item - obj.orderNumber = pathArr.value.length + 1 - pathArr.value.push(obj) + obj.orderNumber = taskStore.pathData.length + 1 + const arr = [...taskStore.pathData] + arr.push(obj) + taskStore.updatePathData(arr) } - taskStore.updatePathData(pathArr.value) } }