diff --git a/data-room-ui/packages/DataSetManagement/src/HttpEditForm.vue b/data-room-ui/packages/DataSetManagement/src/HttpEditForm.vue new file mode 100644 index 00000000..244d7955 --- /dev/null +++ b/data-room-ui/packages/DataSetManagement/src/HttpEditForm.vue @@ -0,0 +1,1114 @@ + + + + + + + + + {{ !isEdit ? 'HTTP数据集详情' : dataForm.id ? 'HTTP数据集编辑' : 'HTTP数据集新增' }} + + + + 帮助 + + + 保存 + + + 返回 + + + + + + + + + + + + + + + + + + + + + + + + + {{ data.name }} + + + + + + + + + + + + + + + + + + + + + + + + + + + + {dataForm.labelIds = ids}" + /> + + + + + + + GET + + + POST + + + + + + + + + 增加 + + + + + + + + + + + + + + + + + + + + + + 移除 + + + + + + + 增加 + + + + + + + + + + + + + + + 移除 + + + + + + + + + + + + + + + + + + 解析并执行 + + + + + + + + + 动态参数 + + 配置 + + + + + {{ param.name }} + ({{ param.remark }}) + + + 配置 + + + + + + + 输出字段 + + 配置 + + + + + {{ field.fieldName }} + + ({{ field.fieldDesc }}) + + 配置 + + + + + + + + + + 数据预览 + + + + + + {{ scope.row[key] }} + + + + + + + + + + + + + {{ scope.row[key] }} + + + + + + + + + + + + + {{ scope.row.fieldDesc }} + + + + + + + + + { outputFieldList = list }" + /> + + + + + + + + diff --git a/data-room-ui/packages/js/utils/httpParamsFormatting.js b/data-room-ui/packages/js/utils/httpParamsFormatting.js new file mode 100644 index 00000000..1fe11579 --- /dev/null +++ b/data-room-ui/packages/js/utils/httpParamsFormatting.js @@ -0,0 +1,54 @@ +import axios from 'axios' +import { Loading, Message } from 'element-ui' +export default function axiosFormatting (customConfig) { + const httpConfig = { + timeout: 1000 * 30, + baseURL: '', + headers: { + ...customConfig.headers + } + } + // let loadingInstance = null // 加载全局的loading + const instance = axios.create(httpConfig) + /** 添加请求拦截器 **/ + instance.interceptors.request.use(config => { + /** + * 在这里:可以根据业务需求可以在发送请求之前做些什么。 + * config.headers['token'] = sessionStorage.getItem('token') || '' + */ + // 执行请求脚本 + eval(customConfig.requestScript) + return config + }, error => { + // 对请求错误做些什么 + return Promise.reject(error) + }) + + /** 添加响应拦截器 **/ + instance.interceptors.response.use(response => { + if (response.data.code === 200) { + // 执行响应脚本 + const data = response.data.data + eval(customConfig.responseScript) + return Promise.resolve(data) + } else { + Message({ + message: response.data.message, + type: 'error' + }) + return Promise.reject(response.data.message) + } + }) + return new Promise((resolve, reject) => { + instance({ + method: customConfig.method, + url: customConfig.url, + params: customConfig.params, + data: customConfig.method === 'post' ? customConfig.body : undefined + }).then(response => { + resolve(response) + }).catch(error => { + reject(error) + }) + }) +}