From 5f8ed20e1875aea7caca47d1b58d4182a27de1eb Mon Sep 17 00:00:00 2001
From: hLinx <327159425@qq.com>
Date: Thu, 12 Dec 2024 11:59:08 +0800
Subject: [PATCH] =?UTF-8?q?feat(frontend):=20=E5=B7=A5=E5=85=B7=E7=AE=B1?=
=?UTF-8?q?=E6=94=AF=E6=8C=81=E8=B5=84=E6=BA=90=E6=B1=A0=E5=8D=8F=E8=AE=AE?=
=?UTF-8?q?=E5=8F=98=E6=9B=B4=5Feditable=5Ftable=20#8076=20#=20Reviewed,?=
=?UTF-8?q?=20transaction=20id:=2026753?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
dbm-ui/frontend/package.json | 2 +-
.../src/components/editable-table/Column.vue | 122 +++++++++++++-----
.../src/components/editable-table/Index.vue | 21 +--
.../src/components/editable-table/Row.vue | 4 +-
.../components/editable-table/edit/Input.vue | 17 ++-
.../editable-table/hooks/use-scroll.ts | 6 +-
.../src/components/editable-table/types.ts | 2 +-
dbm-ui/frontend/src/demo/Index.vue | 50 ++++---
.../toolbox-field/edit-cluster/Index.vue | 9 --
.../toolbox-field/edit-table-name/Index.vue | 9 --
.../toolbox-field/operation-column/Index.vue | 118 +++++++++++++++++
11 files changed, 272 insertions(+), 88 deletions(-)
delete mode 100644 dbm-ui/frontend/src/views/db-manage/common/toolbox-field/edit-cluster/Index.vue
delete mode 100644 dbm-ui/frontend/src/views/db-manage/common/toolbox-field/edit-table-name/Index.vue
create mode 100644 dbm-ui/frontend/src/views/db-manage/common/toolbox-field/operation-column/Index.vue
diff --git a/dbm-ui/frontend/package.json b/dbm-ui/frontend/package.json
index 1d38e3939a..08821ad7c3 100644
--- a/dbm-ui/frontend/package.json
+++ b/dbm-ui/frontend/package.json
@@ -27,7 +27,7 @@
"@icon-cool/bk-icon-bk-biz-components": "0.0.4",
"@vueuse/core": "^11.0.3",
"axios": "^1.7.7",
- "bkui-vue": "2.0.1-beta.78",
+ "bkui-vue": "2.0.1-beta.84",
"date-fns": "3.6.0",
"dayjs": "^1.11.13",
"echarts": "^5.5.1",
diff --git a/dbm-ui/frontend/src/components/editable-table/Column.vue b/dbm-ui/frontend/src/components/editable-table/Column.vue
index e85fd9fbb2..7d314809e6 100644
--- a/dbm-ui/frontend/src/components/editable-table/Column.vue
+++ b/dbm-ui/frontend/src/components/editable-table/Column.vue
@@ -19,17 +19,7 @@
}"
class="bk-editable-table-field-cell">
-
-
-
-
-
+
@@ -38,12 +28,22 @@
+
+
+
+
+
diff --git a/dbm-ui/frontend/src/components/editable-table/hooks/use-scroll.ts b/dbm-ui/frontend/src/components/editable-table/hooks/use-scroll.ts
index c9030713a2..a109c0d370 100644
--- a/dbm-ui/frontend/src/components/editable-table/hooks/use-scroll.ts
+++ b/dbm-ui/frontend/src/components/editable-table/hooks/use-scroll.ts
@@ -1,4 +1,3 @@
-import _ from 'lodash';
import { onBeforeUnmount, onMounted, type Ref, shallowRef } from 'vue';
export default function (tableContentRef: Ref) {
@@ -8,7 +7,7 @@ export default function (tableContentRef: Ref) {
const handleHorizontalScroll = _.throttle(() => {
const tableEl = tableContentRef.value as HTMLElement;
const { scrollLeft } = tableEl;
- const tableContentWidth = tableEl.getBoundingClientRect().width;
+ const tableWrapperWidth = tableEl.getBoundingClientRect().width;
const tableWidth = tableEl.querySelector('table')!.getBoundingClientRect().width;
if (scrollLeft === 0) {
leftFixedStyles.value = {
@@ -24,8 +23,7 @@ export default function (tableContentRef: Ref) {
width: `${fixedWidth}px`,
};
}
-
- if (tableContentWidth + scrollLeft >= tableWidth) {
+ if (tableWrapperWidth + scrollLeft >= tableWidth) {
rightFixedStyles.value = {
display: 'none',
};
diff --git a/dbm-ui/frontend/src/components/editable-table/types.ts b/dbm-ui/frontend/src/components/editable-table/types.ts
index 34b65a81f3..627b8f6f9d 100644
--- a/dbm-ui/frontend/src/components/editable-table/types.ts
+++ b/dbm-ui/frontend/src/components/editable-table/types.ts
@@ -7,5 +7,5 @@ export interface IRule {
pattern?: RegExp;
validator?: (value: any) => Promise | boolean | string;
message: (() => string) | string;
- trigger: 'change' | 'blur';
+ trigger: string;
}
diff --git a/dbm-ui/frontend/src/demo/Index.vue b/dbm-ui/frontend/src/demo/Index.vue
index 1d6efb0628..6b949ac739 100644
--- a/dbm-ui/frontend/src/demo/Index.vue
+++ b/dbm-ui/frontend/src/demo/Index.vue
@@ -10,18 +10,18 @@
field="name"
fixed="left"
label="第一列"
- :min-width="300"
- :rowspan="5">
+ :loading="isLoading"
+ :min-width="300">
+ :min-width="300">
+ :min-width="300">
@@ -69,6 +68,9 @@
:min-width="300">
+
({
name: 'name',
age: '',
@@ -104,11 +108,8 @@
const tableRef = useTemplateRef('table');
const isSubmiting = ref(false);
- const isLoading = ref(true);
-
- setTimeout(() => {
- isLoading.value = false;
- }, 10000);
+ const isLoading = ref(false);
+ let data = 0;
const dataModel = reactive([
createData(),
@@ -130,7 +131,17 @@
name: [
{
validator: (value: string) => {
- console.log('name = ', value);
+ data += 1;
+ console.log('change validator name = ', value, data);
+ return Boolean(value);
+ },
+ message: '错了',
+ trigger: 'change',
+ },
+ {
+ validator: (value: string) => {
+ data += 2;
+ console.log('blur validator name = ', value, data);
return Boolean(value);
},
message: '错了',
@@ -139,10 +150,7 @@
],
age: [
{
- validator: (value: string) => {
- console.log('validator', value);
- return true;
- },
+ validator: () => false,
message: '错了没',
trigger: 'change',
},
@@ -153,6 +161,14 @@
console.log('handleClear');
};
+ const handelNameChange = () => {
+ isLoading.value = true;
+ console.log('handelNameChange');
+ setTimeout(() => {
+ isLoading.value = false;
+ data += 1000;
+ }, 0);
+ };
const handleChange = (value: string) => {
console.log(value);
};
@@ -160,7 +176,7 @@
const handleSubmit = () => {
isSubmiting.value = true;
tableRef
- .value!.validate()
+ .value!.validateByColumnIndex(0)
.then(() => {
console.log('success');
})
diff --git a/dbm-ui/frontend/src/views/db-manage/common/toolbox-field/edit-cluster/Index.vue b/dbm-ui/frontend/src/views/db-manage/common/toolbox-field/edit-cluster/Index.vue
deleted file mode 100644
index 09a5ac894a..0000000000
--- a/dbm-ui/frontend/src/views/db-manage/common/toolbox-field/edit-cluster/Index.vue
+++ /dev/null
@@ -1,9 +0,0 @@
-
-
-
-
-
diff --git a/dbm-ui/frontend/src/views/db-manage/common/toolbox-field/edit-table-name/Index.vue b/dbm-ui/frontend/src/views/db-manage/common/toolbox-field/edit-table-name/Index.vue
deleted file mode 100644
index 09a5ac894a..0000000000
--- a/dbm-ui/frontend/src/views/db-manage/common/toolbox-field/edit-table-name/Index.vue
+++ /dev/null
@@ -1,9 +0,0 @@
-
-
-
-
-
diff --git a/dbm-ui/frontend/src/views/db-manage/common/toolbox-field/operation-column/Index.vue b/dbm-ui/frontend/src/views/db-manage/common/toolbox-field/operation-column/Index.vue
new file mode 100644
index 0000000000..1f5da372e4
--- /dev/null
+++ b/dbm-ui/frontend/src/views/db-manage/common/toolbox-field/operation-column/Index.vue
@@ -0,0 +1,118 @@
+
+
+
+
+
+
+
+
+