feat:修改http数据集数据预览

main
liu.shiyi 2 years ago
parent 723a072f51
commit f4ceeb35c1

@ -504,6 +504,7 @@
:data="dataPreviewList"
max-height="400"
:border="true"
height="500px"
class="bs-el-table bs-scrollbar"
>
<el-table-column
@ -987,7 +988,12 @@ export default {
if (this.dataForm.config.requestType === 'frontend') {
// this.replaceParams(this.dataForm.config.paramsList)
axiosFormatting({ ...this.dataForm.config }).then((res) => {
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('解析并执行成功')

@ -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 {

@ -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 = {}

Loading…
Cancel
Save