From f4ceeb35c1538d15a3ca1afa1d0b49a609097679 Mon Sep 17 00:00:00 2001 From: "liu.shiyi" Date: Tue, 1 Aug 2023 15:52:50 +0800 Subject: [PATCH] =?UTF-8?q?feat:=E4=BF=AE=E6=94=B9http=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=E9=9B=86=E6=95=B0=E6=8D=AE=E9=A2=84=E8=A7=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../DataSetManagement/src/HttpEditForm.vue | 8 +++++++- .../packages/js/mixins/commonMixins.js | 2 ++ .../packages/js/utils/httpParamsFormatting.js | 19 +++++++++---------- 3 files changed, 18 insertions(+), 11 deletions(-) diff --git a/data-room-ui/packages/DataSetManagement/src/HttpEditForm.vue b/data-room-ui/packages/DataSetManagement/src/HttpEditForm.vue index 5da0393b..5280e2af 100644 --- a/data-room-ui/packages/DataSetManagement/src/HttpEditForm.vue +++ b/data-room-ui/packages/DataSetManagement/src/HttpEditForm.vue @@ -504,6 +504,7 @@ :data="dataPreviewList" max-height="400" :border="true" + height="500px" class="bs-el-table bs-scrollbar" > { - this.dataPreviewList = res.data && Array.isArray(res.data) ? res.data : [] + const { resp, response } = res + // this.dataPreviewList = res.data && Array.isArray(res.data) ? res.data : [] + this.dataPreviewList = [{}] + for (const item in response.data) { + this.dataPreviewList[0][item] = response.data[item] + } // 获取数据后更新输出字段 this.updateOoutputFieldList(this.dataPreviewList) this.$message.success('解析并执行成功') diff --git a/data-room-ui/packages/js/mixins/commonMixins.js b/data-room-ui/packages/js/mixins/commonMixins.js index a297cda1..c9343e13 100644 --- a/data-room-ui/packages/js/mixins/commonMixins.js +++ b/data-room-ui/packages/js/mixins/commonMixins.js @@ -77,6 +77,7 @@ export default { if (res.executionByFrontend) { if (res.data.datasetType === 'http') { _res = await axiosFormatting(res.data) + _res = _res.resp } if (res.data.datasetType === 'js') { try { @@ -123,6 +124,7 @@ export default { if (res.executionByFrontend) { if (res.data.datasetType === 'http') { _res = await axiosFormatting(res.data) + _res = _res.resp } if (res.data.datasetType === 'js') { try { diff --git a/data-room-ui/packages/js/utils/httpParamsFormatting.js b/data-room-ui/packages/js/utils/httpParamsFormatting.js index a1f85154..f65afe46 100644 --- a/data-room-ui/packages/js/utils/httpParamsFormatting.js +++ b/data-room-ui/packages/js/utils/httpParamsFormatting.js @@ -33,19 +33,18 @@ export default function axiosFormatting (customConfig) { /** 添加响应拦截器 **/ instance.interceptors.response.use(response => { - if (response.data.code === 200) { - // 执行响应脚本 - // eslint-disable-next-line no-new-func + console.log('response', response) + // 执行响应脚本 + // eslint-disable-next-line no-new-func + if (newCustomConfig.responseScript) { const getResp = new Function('response', newCustomConfig.responseScript) const resp = getResp(response) - console.log(resp) - return Promise.resolve(resp) + console.log('resp', resp) + return Promise.resolve({ resp, response }) } else { - Message({ - message: response.data.message, - type: 'error' - }) - return Promise.reject(response.data.message) + console.log(response.data) + const resp = response + return Promise.resolve({ resp, response }) } }) const body = {}