Merge branch 'master' of github.com:gcpaas/DataRoom

main
wu.jian2 2 years ago
commit 5fde1a80c7

@ -917,6 +917,7 @@ export default {
} else {
//
const script = JSON.stringify(this.dataForm.config)
console.log(this.dataForm.config)
const executeParams = {
script,
params: this.dataForm.paramsList,

@ -1,12 +1,13 @@
import axios from 'axios'
import { Loading, Message } from 'element-ui'
export default function axiosFormatting (customConfig) {
//将请求头和请求参数的值转化为对象形式
const headers = arrToObject(customConfig.headers)
const params = arrToObject(customConfig.params)
const httpConfig = {
timeout: 1000 * 30,
baseURL: '',
headers: {
...customConfig.headers
}
headers
}
// let loadingInstance = null // 加载全局的loading
const instance = axios.create(httpConfig)
@ -30,6 +31,10 @@ export default function axiosFormatting (customConfig) {
// 执行响应脚本
const data = response.data.data
eval(customConfig.responseScript)
Message({
message: '执行成功',
type: 'success'
})
return Promise.resolve(data)
} else {
Message({
@ -43,7 +48,7 @@ export default function axiosFormatting (customConfig) {
instance({
method: customConfig.method,
url: customConfig.url,
params: customConfig.params,
params,
data: customConfig.method === 'post' ? customConfig.body : undefined
}).then(response => {
resolve(response)
@ -52,3 +57,11 @@ export default function axiosFormatting (customConfig) {
})
})
}
// 数组转化为对象
function arrToObject(list) {
const obj = {}
list.forEach(item=>{
obj[item.key] = item.value
})
return obj
}

Loading…
Cancel
Save