From 79b837901ab2063978bd07dd39bea05f9107e439 Mon Sep 17 00:00:00 2001 From: "liu.shiyi" Date: Fri, 28 Jul 2023 09:46:02 +0800 Subject: [PATCH 1/8] =?UTF-8?q?feat:http=E6=95=B0=E6=8D=AE=E9=9B=86?= =?UTF-8?q?=E5=90=8E=E7=AB=AF=E4=BB=A3=E7=90=86=E6=95=B0=E6=8D=AE=E6=98=BE?= =?UTF-8?q?=E7=A4=BA=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- data-room-ui/packages/DataSetManagement/src/HttpEditForm.vue | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/data-room-ui/packages/DataSetManagement/src/HttpEditForm.vue b/data-room-ui/packages/DataSetManagement/src/HttpEditForm.vue index e75cc517..027aa920 100644 --- a/data-room-ui/packages/DataSetManagement/src/HttpEditForm.vue +++ b/data-room-ui/packages/DataSetManagement/src/HttpEditForm.vue @@ -991,7 +991,7 @@ export default { dataSetType: 'http' } datasetExecuteTest(executeParams).then(res => { - this.dataPreviewList = res + this.dataPreviewList = res.data // 获取数据后更新输出字段 this.updateOoutputFieldList(this.dataPreviewList) this.$message.success('解析并执行成功') From 9c3f0f38f7282d49ffe07d28690b490765051a7b Mon Sep 17 00:00:00 2001 From: "liu.shiyi" Date: Fri, 28 Jul 2023 10:46:28 +0800 Subject: [PATCH 2/8] =?UTF-8?q?feat:http=E6=95=B0=E6=8D=AE=E9=9B=86?= =?UTF-8?q?=E6=B7=BB=E5=8A=A0g2plot=E5=89=8D=E7=AB=AF=E4=BB=A3=E7=90=86?= =?UTF-8?q?=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../DataSetManagement/src/HttpEditForm.vue | 1 - .../packages/js/mixins/commonMixins.js | 46 ++++++------------- .../packages/js/utils/httpParamsFormatting.js | 4 -- 3 files changed, 14 insertions(+), 37 deletions(-) diff --git a/data-room-ui/packages/DataSetManagement/src/HttpEditForm.vue b/data-room-ui/packages/DataSetManagement/src/HttpEditForm.vue index 027aa920..02199a95 100644 --- a/data-room-ui/packages/DataSetManagement/src/HttpEditForm.vue +++ b/data-room-ui/packages/DataSetManagement/src/HttpEditForm.vue @@ -980,7 +980,6 @@ export default { this.dataPreviewList = res.data // 获取数据后更新输出字段 this.updateOoutputFieldList(this.dataPreviewList) - console.log(res) }) } else { // 如果是后端代理,则将配置传到后端 diff --git a/data-room-ui/packages/js/mixins/commonMixins.js b/data-room-ui/packages/js/mixins/commonMixins.js index c06e155a..a297cda1 100644 --- a/data-room-ui/packages/js/mixins/commonMixins.js +++ b/data-room-ui/packages/js/mixins/commonMixins.js @@ -71,28 +71,13 @@ export default { pageCode: this.pageCode, size: size, type: config.type - }).then((res) => { + }).then(async (res) => { + let _res = _.cloneDeep(res) // 如果是http数据集的前端代理,则需要调封装的axios请求 - // if (data.executionByFrontend) { - // axiosFormatting(data.data).then(res => { - // config = this.dataFormatting(config, res) - // this.changeChartConfig(config) - // }) - // } - // if (data.datasetType !== 'http' && data.executionByFrontend) { - // try { - // const scriptAfterReplacement = data.data.replace(/\${(.*?)}/g, (match, p) => { - // // 根据parmas的key获取value - // return `'${this.config.dataSource?.params[p]}' || '${p}'` - // }) - // // eslint-disable-next-line no-new-func - // const scriptMethod = new Function(scriptAfterReplacement) - // data.data = scriptMethod() - // } catch (error) { - // console.error('数据集脚本执行失败', error) - // } - // } if (res.executionByFrontend) { + if (res.data.datasetType === 'http') { + _res = await axiosFormatting(res.data) + } if (res.data.datasetType === 'js') { try { const scriptAfterReplacement = res.data.script.replace(/\${(.*?)}/g, (match, p) => { @@ -101,13 +86,13 @@ export default { }) // eslint-disable-next-line no-new-func const scriptMethod = new Function(scriptAfterReplacement) - res.data = scriptMethod() + _res.data = scriptMethod() } catch (error) { console.error('JS数据集脚本执行失败', error) } } } - config = this.dataFormatting(config, res) + config = this.dataFormatting(config, _res) this.changeChartConfig(config) }).catch((err) => { console.error(err) @@ -132,15 +117,13 @@ export default { filterList: filterList || this.filterList } return new Promise((resolve, reject) => { - getUpdateChartInfo(params).then((res) => { + getUpdateChartInfo(params).then(async (res) => { + let _res = _.cloneDeep(res) // 如果是http数据集的前端代理,则需要调封装的axios请求 - // if (data.executionByFrontend) { - // axiosFormatting(data.data).then(res => { - // config = this.dataFormatting(config, res) - // this.changeChartConfig(config) - // }) - // } if (res.executionByFrontend) { + if (res.data.datasetType === 'http') { + _res = await axiosFormatting(res.data) + } if (res.data.datasetType === 'js') { try { const scriptAfterReplacement = res.data.script.replace(/\${(.*?)}/g, (match, p) => { @@ -149,14 +132,13 @@ export default { }) // eslint-disable-next-line no-new-func const scriptMethod = new Function(scriptAfterReplacement) - res.data = scriptMethod() + _res.data = scriptMethod() } catch (error) { console.error('JS数据集脚本执行失败', error) } } } - config = this.dataFormatting(config, res) - this.changeChartConfig(config) + config = this.dataFormatting(config, _res) if (this.chart) { // 单指标组件和多指标组件的changeData传参不同 if (['Liquid', 'Gauge', 'RingProgress'].includes(config.chartType)) { diff --git a/data-room-ui/packages/js/utils/httpParamsFormatting.js b/data-room-ui/packages/js/utils/httpParamsFormatting.js index 3d4c0f4e..605f8267 100644 --- a/data-room-ui/packages/js/utils/httpParamsFormatting.js +++ b/data-room-ui/packages/js/utils/httpParamsFormatting.js @@ -37,10 +37,6 @@ export default function axiosFormatting (customConfig) { // 执行响应脚本 const resp = _.cloneDeep(response.data) eval(newCustomConfig.responseScript) - Message({ - message: '执行成功', - type: 'success' - }) return Promise.resolve(resp) } else { Message({ From 858fc425830fb7ad44eaadb8da9f60c1b053f7e2 Mon Sep 17 00:00:00 2001 From: "hong.yang" Date: Fri, 28 Jul 2023 10:56:01 +0800 Subject: [PATCH 3/8] =?UTF-8?q?feat:=20=E5=8D=87=E7=BA=A7=E6=95=B0?= =?UTF-8?q?=E6=8D=AE=E9=9B=86=E6=8F=92=E4=BB=B6=E7=89=88=E6=9C=AC=E5=88=B0?= =?UTF-8?q?1.0.1.2023072801.Alpha?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 升级数据集插件版本到1.0.1.2023072801.Alpha --- DataRoom/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DataRoom/pom.xml b/DataRoom/pom.xml index 8082f7a1..3b54394e 100644 --- a/DataRoom/pom.xml +++ b/DataRoom/pom.xml @@ -60,7 +60,7 @@ 0.3.2 2.2 4.9.1 - 1.0.1.2023072703.Alpha + 1.0.1.2023072801.Alpha From 331bb7891d3592f618f665803bdffbefc6231171 Mon Sep 17 00:00:00 2001 From: "liu.tao3" Date: Fri, 28 Jul 2023 11:39:59 +0800 Subject: [PATCH 4/8] =?UTF-8?q?fix:=E4=BF=AE=E6=94=B9=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=E9=9B=86=E4=BC=A0=E5=8F=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../DataSetManagement/src/OriginalEditForm.vue | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/data-room-ui/packages/DataSetManagement/src/OriginalEditForm.vue b/data-room-ui/packages/DataSetManagement/src/OriginalEditForm.vue index 6b6d83d4..2e5ff579 100644 --- a/data-room-ui/packages/DataSetManagement/src/OriginalEditForm.vue +++ b/data-room-ui/packages/DataSetManagement/src/OriginalEditForm.vue @@ -655,7 +655,11 @@ export default { getData () { const executeParams = { dataSourceId: this.dataForm.sourceId, - script: this.dataForm.fieldInfo.join(','), + script:JSON.stringify({ + fieldInfo: this.dataForm.fieldInfo,// 未选中字段就传空数组 + tableName: this.dataForm.tableName, + repeatStatus: this.dataForm.repeatStatus + }) , // 原始表数据集没有数据集参数 params: [], dataSetType: 'original', @@ -856,7 +860,11 @@ export default { if (!this.dataForm.sourceId || !this.dataForm.tableName) return const executeParams = { dataSourceId: this.dataForm.sourceId, - script: this.dataForm.fieldInfo.join(','), + script:JSON.stringify({ + fieldInfo: this.dataForm.fieldInfo,// 未选中字段就传空数组 + tableName: this.dataForm.tableName, + repeatStatus: this.dataForm.repeatStatus + }) , // 原始表数据集没有数据集参数 params: [], dataSetType: 'original', From c88ca74ba73dd5ef7aab3d5e3a77b2b8d7d99c47 Mon Sep 17 00:00:00 2001 From: "liu.shiyi" Date: Fri, 28 Jul 2023 11:43:50 +0800 Subject: [PATCH 5/8] =?UTF-8?q?feat:=E4=BF=AE=E6=94=B9http=E6=95=B0?= =?UTF-8?q?=E6=8D=AE=E9=9B=86=E6=A0=B7=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../DataSetManagement/src/HttpEditForm.vue | 428 +++++++++--------- 1 file changed, 212 insertions(+), 216 deletions(-) diff --git a/data-room-ui/packages/DataSetManagement/src/HttpEditForm.vue b/data-room-ui/packages/DataSetManagement/src/HttpEditForm.vue index 02199a95..72541bdc 100644 --- a/data-room-ui/packages/DataSetManagement/src/HttpEditForm.vue +++ b/data-room-ui/packages/DataSetManagement/src/HttpEditForm.vue @@ -146,6 +146,40 @@ + + + + + + GET + + + POST + + + + + + + + + + - - - - GET - - - POST - - - - - - - - - 增加 - - - - - - - - - - - - - - 移除 + 增加 - - - - - - 增加 - - - - - - - - - - - - - + + + + + + + + + + + + 移除 + + + + + + + - 移除 + 增加 - - - - - - - - - - - - + + + + + + + + + + + + + + 移除 + + + + + + + + + + + + + + + + + + + + +
{ - // acc[cur.name] = cur.value - // return acc - // }, {}) - // // 将url中 ${xxx} 替换成 ${params.xxx} - // const str = string.replace(/\$\{(\w+)\}/g, (match, p1) => { - // return '${params.' + p1 + '}' - // }) - // const transformStr = '' - // // 将字符串中的${}替换为变量, 使用eval执行 - // eval('transformStr = `' + str + '`') - // return transformStr - // }, - // evalArrFunc (paramsList, arr) { - // // 取name作为变量名, value作为变量值 { name: '站三', token: '123'} - // const params = paramsList.reduce((acc, cur) => { - // acc[cur.name] = cur.value - // return acc - // }, {}) - // - // // 取name作为变量名, value作为变量值 { _name: '${name}', _token: '${token}'} - // const paramsListObj = arr.reduce((acc, cur) => { - // acc[cur.key] = cur.value - // return acc - // }, {}) - // // 转成字符串 - // const paramsListStr = JSON.stringify(paramsListObj) - // - // // 将url中 ${xxx} 替换成 ${params.xxx} - // const str = paramsListStr.replace(/\$\{(\w+)\}/g, (match, p1) => { - // return '${params.' + p1 + '}' - // }) - // const transformStr = '' - // // 将字符串中的${}替换为变量, 使用eval执行 - // eval('transformStr = `' + str + '`') - // const obj = JSON.parse(transformStr) - // return obj - // }, // 获取请求地址、请求头、请求参数、请求体中所有的变量,在动态参数中进行变量 getPramsList () { const paramNames1 = this.getValName(this.dataForm.config.url) @@ -1222,4 +1215,7 @@ export default { .tree-box { padding: 0; } +.tabs-box{ + margin-left: 45px; +} From 4c03df4b7f1d09677d9c6173ae63b4fcd4e03f5b Mon Sep 17 00:00:00 2001 From: "liu.shiyi" Date: Fri, 28 Jul 2023 13:48:09 +0800 Subject: [PATCH 6/8] =?UTF-8?q?feat:http=E6=95=B0=E6=8D=AE=E9=9B=86?= =?UTF-8?q?=E6=95=B0=E6=8D=AE=E4=B8=8D=E6=BB=A1=E8=B6=B3=E8=A6=81=E6=B1=82?= =?UTF-8?q?=E6=97=B6=E6=8A=A5=E9=94=99=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../packages/DataSetManagement/src/HttpEditForm.vue | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/data-room-ui/packages/DataSetManagement/src/HttpEditForm.vue b/data-room-ui/packages/DataSetManagement/src/HttpEditForm.vue index 72541bdc..995650e7 100644 --- a/data-room-ui/packages/DataSetManagement/src/HttpEditForm.vue +++ b/data-room-ui/packages/DataSetManagement/src/HttpEditForm.vue @@ -520,6 +520,7 @@ >
+
{ - this.dataPreviewList = res.data + this.dataPreviewList = res.data && Array.isArray(res.data) ? res.data : [] // 获取数据后更新输出字段 this.updateOoutputFieldList(this.dataPreviewList) + this.$message.success('解析并执行成功') }) } else { // 如果是后端代理,则将配置传到后端 @@ -983,7 +986,7 @@ export default { dataSetType: 'http' } datasetExecuteTest(executeParams).then(res => { - this.dataPreviewList = res.data + this.dataPreviewList = res.data && Array.isArray(res.data) ? res.data : [] // 获取数据后更新输出字段 this.updateOoutputFieldList(this.dataPreviewList) this.$message.success('解析并执行成功') From b329e10274a249645ed929134f80e6f7476bb67a Mon Sep 17 00:00:00 2001 From: "liu.shiyi" Date: Fri, 28 Jul 2023 14:49:16 +0800 Subject: [PATCH 7/8] =?UTF-8?q?feat:=E4=BC=98=E5=8C=96http=E6=95=B0?= =?UTF-8?q?=E6=8D=AE=E9=9B=86=E6=95=B0=E6=8D=AE=E6=A0=B7=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../DataSetManagement/src/HttpEditForm.vue | 51 +++++++++---------- 1 file changed, 24 insertions(+), 27 deletions(-) diff --git a/data-room-ui/packages/DataSetManagement/src/HttpEditForm.vue b/data-room-ui/packages/DataSetManagement/src/HttpEditForm.vue index 995650e7..5c0c8262 100644 --- a/data-room-ui/packages/DataSetManagement/src/HttpEditForm.vue +++ b/data-room-ui/packages/DataSetManagement/src/HttpEditForm.vue @@ -146,6 +146,22 @@ + + + + + + + - - - - - - - { - this.dataPreviewList = res.data && Array.isArray(res.data) ? res.data : [] + this.dataPreviewList = res.data && Array.isArray(res.data) ? res.data : [] // 获取数据后更新输出字段 this.updateOoutputFieldList(this.dataPreviewList) this.$message.success('解析并执行成功') From 9c9f3297e994b52a12a54df82c84f5c8ad50e520 Mon Sep 17 00:00:00 2001 From: "liu.shiyi" Date: Fri, 28 Jul 2023 15:46:31 +0800 Subject: [PATCH 8/8] =?UTF-8?q?feat:=E4=BC=98=E5=8C=96http=E6=95=B0?= =?UTF-8?q?=E6=8D=AE=E9=9B=86=E5=93=8D=E5=BA=94=E6=8B=A6=E6=88=AA=E5=A4=84?= =?UTF-8?q?=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- data-room-ui/packages/js/utils/httpParamsFormatting.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/data-room-ui/packages/js/utils/httpParamsFormatting.js b/data-room-ui/packages/js/utils/httpParamsFormatting.js index 605f8267..a1f85154 100644 --- a/data-room-ui/packages/js/utils/httpParamsFormatting.js +++ b/data-room-ui/packages/js/utils/httpParamsFormatting.js @@ -35,8 +35,10 @@ export default function axiosFormatting (customConfig) { instance.interceptors.response.use(response => { if (response.data.code === 200) { // 执行响应脚本 - const resp = _.cloneDeep(response.data) - eval(newCustomConfig.responseScript) + // eslint-disable-next-line no-new-func + const getResp = new Function('response', newCustomConfig.responseScript) + const resp = getResp(response) + console.log(resp) return Promise.resolve(resp) } else { Message({ @@ -76,7 +78,7 @@ function replaceUrlParam (url, paramName, paramValue) { } // 将参数的值替换掉其他配置中对应属性的值 function replaceParams (customConfig) { - let newConfig = _.cloneDeep(customConfig) + const newConfig = _.cloneDeep(customConfig) newConfig.url = evalStrFunc(newConfig.paramsList, newConfig.url) newConfig.headers = evalArrFunc(newConfig.paramsList, newConfig.headers) newConfig.params = evalArrFunc(newConfig.paramsList, newConfig.params)