From 051f3751a5cfd4397d89cd7d9c548a3c388f6eee Mon Sep 17 00:00:00 2001 From: lichx Date: Thu, 12 Dec 2024 15:48:01 +0800 Subject: [PATCH] =?UTF-8?q?[bugfix]=20=E4=BF=AE=E6=94=B9=E9=83=A8=E5=88=86?= =?UTF-8?q?bug=20Expr2=20=E7=94=A8=E4=BE=8B=E6=94=B9=E4=B8=BA=E8=80=81?= =?UTF-8?q?=E5=B8=88=E8=A6=81=E6=B1=82=E7=9A=84=E7=94=A8=E4=BE=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/expr2/OperationTable.vue | 18 ++++++------------ src/store/expr2/defaultOperation.ts | 15 ++++++++------- src/store/expr2/expr2Store.ts | 4 ++-- 3 files changed, 16 insertions(+), 21 deletions(-) diff --git a/src/components/expr2/OperationTable.vue b/src/components/expr2/OperationTable.vue index 1fbd0cc..512b2cf 100644 --- a/src/components/expr2/OperationTable.vue +++ b/src/components/expr2/OperationTable.vue @@ -48,16 +48,8 @@ let beforeFromKey = -1; let beforeToKey = -1; function FindOriginOperationIndex(key: string): number { - let index = parseInt(key) - 1; - index = data.value[index].id; - console.log("index", index) - if (index === 0) - return -1; - for (let i = 0; i < originOperations.value.length; i++) { - if (originOperations.value[i].id === index) - return i; - } - return -1; + let ans = parseInt(key) - 2; + return ans < 0? -1: ans; } function OnTableBlur(col: number, {key: editedRowKey}: { key: string }, value: number | string) { @@ -66,7 +58,7 @@ function OnTableBlur(col: number, {key: editedRowKey}: { key: string }, value: n console.log(index, col, value) if (index === -1) { if (col === 2) { - startTrack.value = value as number; + startTrack.value = parseInt(value as string); tableChanged.value = true; } return; @@ -200,7 +192,7 @@ function InsertBefore(row: number) { function InsertEnd() { originOperations.value.push({ - id: 0, + id: -1, track: -1 }); tableChanged.value = true; @@ -210,6 +202,8 @@ function InsertEnd() { function Delete(row: number) { let key = data.value[row - 1].key; let index = FindOriginOperationIndex(key); + if(index === -1) + return; originOperations.value.splice(index, 1); tableChanged.value = true; } diff --git a/src/store/expr2/defaultOperation.ts b/src/store/expr2/defaultOperation.ts index 1843c82..2a20d0f 100644 --- a/src/store/expr2/defaultOperation.ts +++ b/src/store/expr2/defaultOperation.ts @@ -1,11 +1,12 @@ const operations: Operation[] = [ - {id: 1, track: 90}, - {id: 2, track: 60}, - {id: 3, track: 10}, - {id: 4, track: 30}, - {id: 5, track: 20}, - {id: 6, track: 99}, - {id: 7, track: 50}, + {id: 1, track: 98}, + {id: 2, track: 183}, + {id: 3, track: 37}, + {id: 4, track: 122}, + {id: 5, track: 14}, + {id: 6, track: 124}, + {id: 7, track: 65}, + {id: 8, track: 67}, ]; export default operations; diff --git a/src/store/expr2/expr2Store.ts b/src/store/expr2/expr2Store.ts index ba7244b..b0d9144 100644 --- a/src/store/expr2/expr2Store.ts +++ b/src/store/expr2/expr2Store.ts @@ -5,9 +5,9 @@ import {Algorithm} from "@/logical/expr2/disk.ts"; const useExpr2Store = defineStore('expr2', { state: () => ({ - trackCount: 100, + trackCount: 200, currentTrack: 0, - startTrack: 50, + startTrack: 53, operations: operations, originOperations: operations, tableChanged: false,