From f8fb1410e7de240caf687768ee6021f70c9a901f Mon Sep 17 00:00:00 2001 From: junjun Date: Thu, 5 Jun 2025 11:09:43 +0800 Subject: [PATCH] feat(datasource): datasource table --- frontend/src/api/datasource.ts | 2 + frontend/src/views/ds/TableList.vue | 123 +++++++++++++++++++++++++--- 2 files changed, 114 insertions(+), 11 deletions(-) diff --git a/frontend/src/api/datasource.ts b/frontend/src/api/datasource.ts index 1240e45d..64c86355 100644 --- a/frontend/src/api/datasource.ts +++ b/frontend/src/api/datasource.ts @@ -15,4 +15,6 @@ export const datasourceApi = { fieldList: (id: Number) => request.post(`/datasource/fieldList/${id}`), edit: (data: any) => request.post('/datasource/editLocalComment', data), previewData: (id: Number, data: any) => request.post(`/datasource/previewData/${id}`, data), + saveTable: (data: any) => request.post('/datasource/editTable', data), + saveField: (data: any) => request.post('/datasource/editField', data) } \ No newline at end of file diff --git a/frontend/src/views/ds/TableList.vue b/frontend/src/views/ds/TableList.vue index 0be405a7..56d1a889 100644 --- a/frontend/src/views/ds/TableList.vue +++ b/frontend/src/views/ds/TableList.vue @@ -5,7 +5,7 @@ {{ props.dsName }} - Save +
@@ -43,7 +43,8 @@ {{ currentTable.table_name }} Comment: - + {{ currentTable.custom_comment }} +
@@ -89,6 +91,48 @@ + + +
Table Comment
+ + +
+ Cancel + Confirm +
+
+ + +
Field Comment
+ + +
+ Cancel + Confirm +
+
@@ -98,6 +142,7 @@ import { datasourceApi } from "@/api/datasource"; import { onMounted } from "vue"; import { ArrowLeft } from "@element-plus/icons-vue"; import type { TabsPaneContext } from "element-plus-secondary"; +import IconOpeEdit from '@/assets/svg/operate/ope-edit.svg' const props = defineProps({ dsId: { type: [Number], required: true }, @@ -108,10 +153,13 @@ const dsId = ref(0); const searchValue = ref(""); const tableList = ref([]); const currentTable = ref({}); +const currentField = ref({}); const fieldList = ref([]); const previewData = ref({}); const activeName = ref("schema"); +const tableDialog = ref(false) +const fieldDialog = ref(false) const buildData = () => { return { table: currentTable.value, fields: fieldList.value }; @@ -121,15 +169,59 @@ const back = () => { history.back(); }; -const save = () => { - datasourceApi.edit(buildData()).then(() => { +// const save = () => { +// datasourceApi.edit(buildData()).then(() => { +// ElMessage({ +// message: "Save success", +// type: "success", +// showClose: true, +// }); +// }); +// }; + +const editTable = () => { + tableDialog.value = true +} + +const closeTable = () => { + tableDialog.value = false +} + +const saveTable = () => { + datasourceApi.saveTable(currentTable.value).then(() => { + closeTable() ElMessage({ - message: "Save success", + message: "Edit Success", type: "success", showClose: true, - }); - }); -}; + }) + }) +} + +const editField = (row: any) => { + currentField.value = row + fieldDialog.value = true +} + +const changeStatus = (row: any) => { + currentField.value = row + saveField() +} + +const closeField = () => { + fieldDialog.value = false +} + +const saveField = () => { + datasourceApi.saveField(currentField.value).then(() => { + closeField() + ElMessage({ + message: "Edit Success", + type: "success", + showClose: true, + }) + }) +} const clickTable = (table: any) => { currentTable.value = table; @@ -200,4 +292,13 @@ onMounted(() => { } } } + +.field-comment{ + display: flex; + align-items: center; + + .action-btn{ + margin-left: 10px; + } +}