From f06cfbfda63c758dc1edfd2cfaabee9f5c46f3b4 Mon Sep 17 00:00:00 2001 From: zhang zhuo Date: Tue, 25 Nov 2025 14:22:11 +0800 Subject: [PATCH] =?UTF-8?q?=E8=A1=A8=E5=8D=95=E6=9E=84=E5=BB=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/assets/icons/FuZhi.vue | 3 + src/assets/icons/ShanChu.vue | 3 + src/utils/tools.ts | 54 +++++++++++- src/views/tools/form/center.vue | 143 +++++++++++++++++++++++--------- src/views/tools/form/index.vue | 8 +- src/views/tools/form/left.vue | 10 ++- src/views/tools/form/right.vue | 33 +++++++- 7 files changed, 205 insertions(+), 49 deletions(-) create mode 100644 src/assets/icons/FuZhi.vue create mode 100644 src/assets/icons/ShanChu.vue diff --git a/src/assets/icons/FuZhi.vue b/src/assets/icons/FuZhi.vue new file mode 100644 index 0000000..8542a93 --- /dev/null +++ b/src/assets/icons/FuZhi.vue @@ -0,0 +1,3 @@ + diff --git a/src/assets/icons/ShanChu.vue b/src/assets/icons/ShanChu.vue new file mode 100644 index 0000000..073ae21 --- /dev/null +++ b/src/assets/icons/ShanChu.vue @@ -0,0 +1,3 @@ + diff --git a/src/utils/tools.ts b/src/utils/tools.ts index 11ffb16..dc99e3a 100644 --- a/src/utils/tools.ts +++ b/src/utils/tools.ts @@ -161,7 +161,59 @@ const tools = { } else { return '未知' } + }, + // 数组0 - index + array: { + // 交换 + swap(arr: Array, index1: number, index2: number) { + arr[index1] = arr.splice(index2, 1, arr[index1])[0]; + return arr; + }, + zIndexUp(arr, index) { + if (index !== 0) { + this.swap(arr, index, index - 1); + } + }, + zIndexDown(arr, index) { + if (index + 1 < arr.length) { + this.swap(arr, index, index + 1); + } + }, + zIndexTop(arr, index) { + if (index > 0) { + const moveNum = index - 0; + for (let i = 0; i < moveNum; i++) { + this.swap(arr, index, index - 1); + index--; + } + } + }, + zIndexBottom(arr, index) { + if (index + 1 < arr.length) { + const moveNum = arr.length - 1 - index; + for (let i = 0; i < moveNum; i++) { + this.swap(arr, index, index + 1); + index++; + } + } + }, + // index1 >>> index2 + zIndexTo(arr, index1, index2) { + if (index1 === index2) return; + if (index1 < index2) { + const moveNum = index2 - 1 - index1; + for (let i = 0; i < moveNum; i++) { + this.swap(arr, index1, index1 + 1); + index1++; + } + } else { + const moveNum = index1 - index2; + for (let i = 0; i < moveNum; i++) { + this.swap(arr, index1, index1 - 1); + index1--; + } + } + } } } - export default tools diff --git a/src/views/tools/form/center.vue b/src/views/tools/form/center.vue index 0f2ca1a..c652bd9 100644 --- a/src/views/tools/form/center.vue +++ b/src/views/tools/form/center.vue @@ -1,32 +1,30 @@