From fbfaa59b1451adff324418c73470e5eb563300f8 Mon Sep 17 00:00:00 2001 From: plum <40649341+plum-k@users.noreply.github.com> Date: Wed, 15 Apr 2026 23:34:52 +0800 Subject: [PATCH] fix(data-center): populate SQL data source options and normalize dataset source id mapping --- packages/editor/src/http/api/dataSet.ts | 2 +- .../src/views/home/dataCenter/DataSet.vue | 4 +- .../views/home/dataCenter/DataSetModal.vue | 464 ++++++++++++------ packages/editor/types/data-source.d.ts | 16 +- 4 files changed, 318 insertions(+), 168 deletions(-) diff --git a/packages/editor/src/http/api/dataSet.ts b/packages/editor/src/http/api/dataSet.ts index 6004b71..501289d 100644 --- a/packages/editor/src/http/api/dataSet.ts +++ b/packages/editor/src/http/api/dataSet.ts @@ -17,7 +17,7 @@ export interface DataSetPayload { type: "API" | "SQL" | "JSON" | string; method?: IDataSet.Item["method"]; api?: string; - dataSourceId?: string; + dataSourceId?: IDataSet.Item["id"]; sql?: string; json?: string; } diff --git a/packages/editor/src/views/home/dataCenter/DataSet.vue b/packages/editor/src/views/home/dataCenter/DataSet.vue index 2b5f522..b8a2a6b 100644 --- a/packages/editor/src/views/home/dataCenter/DataSet.vue +++ b/packages/editor/src/views/home/dataCenter/DataSet.vue @@ -65,7 +65,7 @@ const defaultDataSet: IDataSet.Item = { type: 'API', method: 'GET', api: '', - dataSource: '', + dataSourceId: '', sql: '', json: '' }; @@ -179,7 +179,7 @@ async function editDataSet(item) { const detail = (res.data || item) as any; resetCurrentDataSet({ ...detail, - dataSource: detail.dataSourceId || detail.dataSource || "" + dataSourceId: detail.dataSourceId || detail.dataSource ? String(detail.dataSourceId || detail.dataSource) : "" }); showDataSetModal.value = true } diff --git a/packages/editor/src/views/home/dataCenter/DataSetModal.vue b/packages/editor/src/views/home/dataCenter/DataSetModal.vue index b844b82..3519b07 100644 --- a/packages/editor/src/views/home/dataCenter/DataSetModal.vue +++ b/packages/editor/src/views/home/dataCenter/DataSetModal.vue @@ -1,180 +1,326 @@ - - - - - - - - - - - - - + + + + + + + + + + + + + - - - - - - - - + + + + + + + + - - - - - - - - - - {{ t('home.Parameter is passed as ') }} - '${id}' , - {{ t('home.For example:') }} - SELECT * FROM table WHERE id='${id}' - - - + + + + + + + + + + {{ t('home.dataCenter["Parameter is passed as:"]') }} + '${id}' , + {{ t('home.dataCenter["For example:"]') }} + SELECT * FROM table WHERE id='${id}' + + + - - - - - + + + + + - - - {{ t("other.Cancel") }} - {{ t("other.Ok") }} - - - - - - + + + {{ t("other.Cancel") }} + {{ t("other.Ok") }} + + + + + + \ No newline at end of file diff --git a/packages/editor/types/data-source.d.ts b/packages/editor/types/data-source.d.ts index 6356c50..60c9549 100644 --- a/packages/editor/types/data-source.d.ts +++ b/packages/editor/types/data-source.d.ts @@ -1,6 +1,7 @@ declare namespace IDataSource { + type Id = string | number; interface Item { - id: string; + id: Id; name: string; type: string; connectionString: string; @@ -10,21 +11,24 @@ declare namespace IDataSource { } declare namespace IDataSet { + type Id = string | number; interface Item { - id: string; - groupId: string; + id: Id; + groupId: Id; name: string; type: string; method?: "GET" | "POST"; api?: string; - dataSource?: string; + dataSourceId?: Id; + dataSource?: Id; sql?: string; json?: string; + createTime?: string; } interface IGroup { - id: string; - pid?: string; + id: Id; + pid?: Id; name: string; children?: IGroup[]; }