From 10d7bfa0dbcbbf841acf145869835a030346913b Mon Sep 17 00:00:00 2001 From: taojinlong Date: Wed, 8 Jun 2022 10:46:12 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20sql=20=E6=95=B0=E6=8D=AE=E9=9B=86?= =?UTF-8?q?=E5=8F=82=E6=95=B0=E4=BC=A0=E9=80=92?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/resources/db/migration/V36__1.12.sql | 14 ++++++++ frontend/src/lang/zh.js | 3 ++ frontend/src/views/dataset/add/AddSQL.vue | 32 ++++++++++++++++++- 3 files changed, 48 insertions(+), 1 deletion(-) diff --git a/backend/src/main/resources/db/migration/V36__1.12.sql b/backend/src/main/resources/db/migration/V36__1.12.sql index 5ded5a0267..908b821a69 100644 --- a/backend/src/main/resources/db/migration/V36__1.12.sql +++ b/backend/src/main/resources/db/migration/V36__1.12.sql @@ -19,3 +19,17 @@ CREATE TABLE `chart_view_field` `last_sync_time` bigint(13) DEFAULT NULL COMMENT '同步时间', PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE utf8mb4_general_ci; + +DROP TABLE IF EXISTS `sql_variable`; +CREATE TABLE `sql_variable` +( + `id` varchar(50) NOT NULL COMMENT 'ID', + `table_id` varchar(50) NOT NULL COMMENT '数据集ID', + `variable_name` varchar(255) NOT NULL COMMENT '名称', + `alias` varchar(255) NOT NULL COMMENT '别名', + `type` varchar(50) NOT NULL COMMENT '类型', + `details` longtext DEFAULT NULL COMMENT '明细', + `default_value` longtext DEFAULT NULL COMMENT '默认值', + `required` tinyint(1) NOT NULL DEFAULT '0' COMMENT '是否必填', + PRIMARY KEY (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE utf8mb4_general_ci; \ No newline at end of file diff --git a/frontend/src/lang/zh.js b/frontend/src/lang/zh.js index 2d9678c76b..64c76e1e8c 100644 --- a/frontend/src/lang/zh.js +++ b/frontend/src/lang/zh.js @@ -2080,5 +2080,8 @@ export default { }, plugin_style: { border: '边框' + }, + sql_variable: { + variable_mgm: '参数设置' } } diff --git a/frontend/src/views/dataset/add/AddSQL.vue b/frontend/src/views/dataset/add/AddSQL.vue index b52b880061..80c161e7a6 100644 --- a/frontend/src/views/dataset/add/AddSQL.vue +++ b/frontend/src/views/dataset/add/AddSQL.vue @@ -46,6 +46,7 @@ + {{ $t('sql_variable.variable_mgm') }} @@ -94,6 +95,20 @@ + + + + + + + + + + + + + + @@ -161,6 +176,10 @@ export default { selectedDatasource: {}, engineMode: 'local', disabledSync: true, + showVariableMgm: false, + dialogTitle: '', + variables: [], + variablesTmp: [] } }, computed: { @@ -335,7 +354,18 @@ export default { this.fields = [] this.mode = '0' this.syncType = 'sync_now' - } + }, + + variableMgm() { + var reg = new RegExp("${(.*?)}", "gim"); + var match = this.sql.match(reg); + console.log(match) + this.dialogTitle = this.$t('sql_variable.variable_mgm') + this.showVariableMgm = true + }, + closeVariableMgm() { + this.showVariableMgm = false + }, } }