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

main
wu.jian2 2 years ago
commit 5fde1a80c7

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

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