diff --git a/data-room-ui/example/main.js b/data-room-ui/example/main.js index c566d664..a85f2555 100644 --- a/data-room-ui/example/main.js +++ b/data-room-ui/example/main.js @@ -13,6 +13,7 @@ import * as $dataRoomAxios from 'data-room-ui/js/utils/http.js' import { registerConfig } from '@gcpaas/data-room-ui' import remoteComponents from '@/remoteComponents/exports.js' import customDatasetComponents from '@/customDatasetComponents/exports.js' +import customPlots from '@/customPlots/exports' Vue.use(ElementUI, { size: 'mini' }) registerConfig( { @@ -65,7 +66,10 @@ promise.polyfill() Vue.use(ElementUI, { size: 'mini' }) Vue.prototype.$dataRoomAxios = $dataRoomAxios Vue.config.productionTip = false - +// 兼容ie下双向绑定事件 +Vue.prototype.inputChange = function (e) { + return e.target.value +} /* eslint-disable no-new */ new Vue({ el: '#app', 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..28eb0f64 --- /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/DataSetManagement/src/index.vue b/data-room-ui/packages/DataSetManagement/src/index.vue index 458d8ffc..240a6bad 100644 --- a/data-room-ui/packages/DataSetManagement/src/index.vue +++ b/data-room-ui/packages/DataSetManagement/src/index.vue @@ -262,6 +262,7 @@ import checkDatasource from 'data-room-ui/DataSourceManagement/src/checkDatasour import CustomEditForm from './CustomEditForm.vue' import { pageMixins } from 'data-room-ui/js/mixins/page' import OriginalEditForm from './OriginalEditForm.vue' +import HttpEditForm from './HttpEditForm.vue' import DatasetTypeDialog from './DatasetTypeDialog.vue' import StoredProcedureEditForm from './StoredProcedureEditForm.vue' import { datasetPage, datasetRemove, datasetCheck } from 'data-room-ui/js/utils/datasetConfigService' @@ -280,7 +281,8 @@ export default { StoredProcedureEditForm, ScriptEditForm, JsEditForm, - checkDatasource + checkDatasource, + HttpEditForm }, mixins: [pageMixins], props: { @@ -529,7 +531,8 @@ export default { { name: '存储过程数据集', datasetType: 'storedProcedure', componentName: 'StoredProcedureEditForm' }, { name: 'JSON数据集', datasetType: 'json', componentName: 'JsonEditForm' }, { name: '脚本数据集', datasetType: 'script', componentName: 'ScriptEditForm' }, - { name: 'JS数据集', datasetType: 'js', componentName: 'JsEditForm' } + { name: 'JS数据集', datasetType: 'js', componentName: 'JsEditForm' }, + { name: 'HTTP数据集', datasetType: 'http', componentName: 'HttpEditForm' } ] if (window.BS_CONFIG?.datasetTypeList&&window.BS_CONFIG?.datasetTypeList?.length!=0) { this.datasetTypeList = [{ name: '全部', datasetType: '' }, ...list.filter(item => window.BS_CONFIG?.datasetTypeList.findIndex(x => x === item.datasetType) !== -1)] 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) + }) + }) +}