Commit d0b02276 by yuwei

2.0.0项目初始化

parent 15f0d08b
package cn.datax.service.data.market.api.call.controller;
import cn.datax.common.base.BaseController;
import cn.datax.common.core.R;
import cn.datax.service.data.market.api.call.service.ApiHeaderService;
import cn.datax.service.data.market.api.vo.ApiHeader;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;
@RestController
public class ApiHeaderController extends BaseController {
@Autowired
private ApiHeaderService apiHeaderService;
@GetMapping(value = "/{id}/header")
public R getApiHeader(@PathVariable String id){
ApiHeader apiHeader = apiHeaderService.getApiHeader(id);
return R.ok().setData(apiHeader);
}
}
package cn.datax.service.data.market.api.call.service;
import cn.datax.service.data.market.api.vo.ApiHeader;
public interface ApiHeaderService {
ApiHeader getApiHeader(String id);
}
package cn.datax.service.data.market.api.call.service.impl;
import cn.datax.common.utils.MD5Util;
import cn.datax.common.utils.SecurityUtil;
import cn.datax.service.data.market.api.call.service.ApiHeaderService;
import cn.datax.service.data.market.api.vo.ApiHeader;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
@Service
@Transactional(propagation = Propagation.SUPPORTS, readOnly = true, rollbackFor = Exception.class)
public class ApiHeaderServiceImpl implements ApiHeaderService {
@Override
public ApiHeader getApiHeader(String id) {
ApiHeader apiHeader = new ApiHeader();
try {
MD5Util mt = MD5Util.getInstance();
apiHeader.setApiKey(mt.encode(id));
apiHeader.setSecretKey(mt.encode(SecurityUtil.getUserId()));
} catch (Exception e) {
}
return apiHeader;
}
}
package cn.datax.service.data.market.api.vo;
import lombok.Data;
import java.io.Serializable;
@Data
public class ApiHeader implements Serializable {
private static final long serialVersionUID=1L;
private String authorization;
private String apiKey;
private String secretKey;
}
...@@ -6,6 +6,7 @@ import lombok.Data; ...@@ -6,6 +6,7 @@ import lombok.Data;
import java.io.Serializable; import java.io.Serializable;
import java.util.List; import java.util.List;
@Data @Data
public class SqlParseVo implements Serializable { public class SqlParseVo implements Serializable {
......
...@@ -2,12 +2,15 @@ package cn.datax.service.data.market.service.impl; ...@@ -2,12 +2,15 @@ package cn.datax.service.data.market.service.impl;
import cn.datax.common.base.BaseServiceImpl; import cn.datax.common.base.BaseServiceImpl;
import cn.datax.common.core.RedisConstant; import cn.datax.common.core.RedisConstant;
import cn.datax.common.exception.DataException;
import cn.datax.service.data.market.api.dto.ApiMaskDto; import cn.datax.service.data.market.api.dto.ApiMaskDto;
import cn.datax.service.data.market.api.entity.ApiMaskEntity; import cn.datax.service.data.market.api.entity.ApiMaskEntity;
import cn.datax.service.data.market.dao.ApiMaskDao; import cn.datax.service.data.market.dao.ApiMaskDao;
import cn.datax.service.data.market.mapstruct.ApiMaskMapper; import cn.datax.service.data.market.mapstruct.ApiMaskMapper;
import cn.datax.service.data.market.service.ApiMaskService; import cn.datax.service.data.market.service.ApiMaskService;
import cn.datax.service.system.api.entity.DeptEntity;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.CacheConfig; import org.springframework.cache.annotation.CacheConfig;
import org.springframework.cache.annotation.CacheEvict; import org.springframework.cache.annotation.CacheEvict;
...@@ -42,6 +45,11 @@ public class ApiMaskServiceImpl extends BaseServiceImpl<ApiMaskDao, ApiMaskEntit ...@@ -42,6 +45,11 @@ public class ApiMaskServiceImpl extends BaseServiceImpl<ApiMaskDao, ApiMaskEntit
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public void saveApiMask(ApiMaskDto apiMaskDto) { public void saveApiMask(ApiMaskDto apiMaskDto) {
ApiMaskEntity apiMask = apiMaskMapper.toEntity(apiMaskDto); ApiMaskEntity apiMask = apiMaskMapper.toEntity(apiMaskDto);
// 校验api唯一
int n = apiMaskDao.selectCount(Wrappers.<ApiMaskEntity>lambdaQuery().eq(ApiMaskEntity::getApiId, apiMask.getApiId()));
if(n > 0){
throw new DataException("该api已进行过脱敏配置");
}
apiMaskDao.insert(apiMask); apiMaskDao.insert(apiMask);
} }
......
import request from '@/utils/request' import request from '@/utils/request'
export function getApiCall (data) { export function getApiHeader (id) {
return request({ return request({
url: '/data/api/v1/list', url: '/data/api/' + id + '/header',
method: 'get'
})
}
export function getApiCall (url, header, data) {
return request({
url: '/data/api/v1' + url,
method: 'get', method: 'get',
headers: header,
params: data params: data
}) })
} }
export function postApiCall (data) { export function postApiCall (url, header, data) {
return request({ return request({
url: '/data/api/v1/list', url: '/data/api/v1' + url,
method: 'post', method: 'post',
headers: header,
data: data data: data
}) })
} }
...@@ -137,7 +137,7 @@ export default { ...@@ -137,7 +137,7 @@ export default {
// 表单校验 // 表单校验
rules: { rules: {
sourceId: [ sourceId: [
{ required: true, message: '数据源不能为空', trigger: 'blur' } { required: true, message: '数据源不能为空', trigger: 'change' }
], ],
setName: [ setName: [
{ required: true, message: '数据集名称不能为空', trigger: 'blur' } { required: true, message: '数据集名称不能为空', trigger: 'blur' }
......
...@@ -130,6 +130,9 @@ export default { ...@@ -130,6 +130,9 @@ export default {
form: {}, form: {},
// 表单校验 // 表单校验
rules: { rules: {
sourceId: [
{ required: true, message: '数据源不能为空', trigger: 'change' }
],
setName: [ setName: [
{ required: true, message: '数据集名称不能为空', trigger: 'blur' } { required: true, message: '数据集名称不能为空', trigger: 'blur' }
] ]
......
...@@ -11,7 +11,7 @@ ...@@ -11,7 +11,7 @@
<div :style="classCardbody"> <div :style="classCardbody">
<el-form ref="form" :model="form" :rules="rules" label-width="80px"> <el-form ref="form" :model="form" :rules="rules" label-width="80px">
<el-form-item label="数据API" prop="apiId"> <el-form-item label="数据API" prop="apiId">
<el-select v-model="form.apiId" placeholder="请选择数据API" @change="apiSelectChanged"> <el-select v-model="form.apiId" placeholder="请选择数据API" disabled >
<el-option <el-option
v-for="api in apiOptions" v-for="api in apiOptions"
:key="api.id" :key="api.id"
...@@ -254,11 +254,6 @@ export default { ...@@ -254,11 +254,6 @@ export default {
} }
}) })
}, },
apiSelectChanged (val) {
this.resParamList = this.apiOptions.find(function (item) {
return item.id === val
}).resParams
},
fieldRule (fieldName) { fieldRule (fieldName) {
this.cipher.open = true this.cipher.open = true
this.form2.fieldName = fieldName this.form2.fieldName = fieldName
......
...@@ -186,36 +186,44 @@ ...@@ -186,36 +186,44 @@
</el-table-column> </el-table-column>
<el-table-column prop="paramType" label="参数类型" align="center" show-overflow-tooltip > <el-table-column prop="paramType" label="参数类型" align="center" show-overflow-tooltip >
<template slot-scope="scope"> <template slot-scope="scope">
<el-select v-model="scope.row.paramType" placeholder="请选择参数类型"> <el-form-item :prop=" 'reqParams.' + scope.$index + '.paramType' " :rules="rules3.paramType">
<el-option <el-select v-model="scope.row.paramType" placeholder="请选择参数类型">
v-for="dict in paramTypeOptions" <el-option
:key="dict.id" v-for="dict in paramTypeOptions"
:label="dict.itemValue" :key="dict.id"
:value="dict.itemText" :label="dict.itemValue"
></el-option> :value="dict.itemText"
</el-select> ></el-option>
</el-select>
</el-form-item>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column prop="whereType" label="操作符" align="center" show-overflow-tooltip > <el-table-column prop="whereType" label="操作符" align="center" show-overflow-tooltip >
<template slot-scope="scope"> <template slot-scope="scope">
<el-select v-model="scope.row.whereType" placeholder="请选择操作符"> <el-form-item :prop=" 'reqParams.' + scope.$index + '.whereType' " :rules="rules3.whereType">
<el-option <el-select v-model="scope.row.whereType" placeholder="请选择操作符">
v-for="dict in whereTypeOptions" <el-option
:key="dict.id" v-for="dict in whereTypeOptions"
:label="dict.itemValue" :key="dict.id"
:value="dict.itemText" :label="dict.itemValue"
></el-option> :value="dict.itemText"
</el-select> ></el-option>
</el-select>
</el-form-item>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column prop="exampleValue" label="示例值" align="center" show-overflow-tooltip > <el-table-column prop="exampleValue" label="示例值" align="center" show-overflow-tooltip >
<template slot-scope="scope"> <template slot-scope="scope">
<el-input v-model="scope.row.exampleValue" placeholder="请输入示例值" /> <el-form-item :prop=" 'reqParams.' + scope.$index + '.exampleValue' " :rules="rules3.exampleValue">
<el-input v-model="scope.row.exampleValue" placeholder="请输入示例值" />
</el-form-item>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column prop="defaultValue" label="默认值" align="center" show-overflow-tooltip > <el-table-column prop="defaultValue" label="默认值" align="center" show-overflow-tooltip >
<template slot-scope="scope"> <template slot-scope="scope">
<el-input v-model="scope.row.defaultValue" placeholder="请输入默认值" /> <el-form-item :prop=" 'reqParams.' + scope.$index + '.defaultValue' " :rules="rules3.defaultValue">
<el-input v-model="scope.row.defaultValue" placeholder="请输入默认值" />
</el-form-item>
</template> </template>
</el-table-column> </el-table-column>
</el-table> </el-table>
...@@ -237,7 +245,9 @@ ...@@ -237,7 +245,9 @@
</el-table-column> </el-table-column>
<el-table-column prop="exampleValue" label="示例值" align="center" show-overflow-tooltip > <el-table-column prop="exampleValue" label="示例值" align="center" show-overflow-tooltip >
<template slot-scope="scope"> <template slot-scope="scope">
<el-input v-model="scope.row.exampleValue" placeholder="请输入示例值" /> <el-form-item :prop=" 'resParams.' + scope.$index + '.exampleValue' " :rules="rules3.exampleValue">
<el-input v-model="scope.row.exampleValue" placeholder="请输入示例值" />
</el-form-item>
</template> </template>
</el-table-column> </el-table-column>
</el-table> </el-table>
...@@ -281,7 +291,8 @@ export default { ...@@ -281,7 +291,8 @@ export default {
showList: true, showList: true,
showAdd: false, showAdd: false,
showEdit: false, showEdit: false,
showDetail: false showDetail: false,
showCall: false
}, },
// 保存按钮 // 保存按钮
loadingOptions: { loadingOptions: {
...@@ -320,10 +331,10 @@ export default { ...@@ -320,10 +331,10 @@ export default {
{ required: true, message: 'API路径不能为空', trigger: 'blur' } { required: true, message: 'API路径不能为空', trigger: 'blur' }
], ],
reqMethod: [ reqMethod: [
{ required: true, message: '请求方式不能为空', trigger: 'blur' } { required: true, message: '请求方式不能为空', trigger: 'change' }
], ],
resType: [ resType: [
{ required: true, message: '返回格式不能为空', trigger: 'blur' } { required: true, message: '返回格式不能为空', trigger: 'change' }
] ]
}, },
form2: { form2: {
...@@ -335,17 +346,30 @@ export default { ...@@ -335,17 +346,30 @@ export default {
}, },
rules2: { rules2: {
configType: [ configType: [
{ required: true, message: '配置方式不能为空', trigger: 'blur' } { required: true, message: '配置方式不能为空', trigger: 'change' }
], ],
sourceId: [ sourceId: [
{ required: true, message: '数据源不能为空', trigger: 'blur' } { required: true, message: '数据源不能为空', trigger: 'change' }
] ]
}, },
form3: { form3: {
reqParams: [], reqParams: [],
resParams: [] resParams: []
}, },
rules3: {}, rules3: {
paramType: [
{ required: true, message: '参数类型不能为空', trigger: 'change' }
],
whereType: [
{ required: true, message: '操作符不能为空', trigger: 'change' }
],
exampleValue: [
{ required: true, message: '示例值不能为空', trigger: 'blur' }
],
defaultValue: [
{ required: true, message: '默认值不能为空', trigger: 'blur' }
]
},
// 请求方式数据字典 // 请求方式数据字典
reqMethodOptions: [], reqMethodOptions: [],
// 返回格式数据字典 // 返回格式数据字典
......
<template>
<div>
<el-card class="box-card" shadow="always">
<div slot="header" class="clearfix">
<span>{{ title }}</span>
<el-button-group style="float: right;">
<el-button size="mini" icon="el-icon-s-data" round @click="apiDataCall">api调用</el-button>
<el-button size="mini" icon="el-icon-back" round @click="showCard">返回</el-button>
</el-button-group>
</div>
<div :style="classCardbody">
<el-row>
<el-col :span="8">API名称:{{form.apiName}}</el-col>
<el-col :span="8">API版本:{{form.apiVersion}}</el-col>
</el-row>
<el-row>
<el-col :span="8">API路径:{{form.apiUrl}}</el-col>
<el-col :span="8">请求类型:{{form.reqMethod}}</el-col>
<el-col :span="8">返回格式:{{form.resType}}</el-col>
</el-row>
<el-row>
<el-col :span="24">
<el-tabs type="border-card" v-model="activeTabName">
<el-tab-pane label="请求头" name="table0">
<el-table :data="apiHeaderList" stripe border
:max-height="300"
style="width: 100%; margin: 15px 0;">
<el-table-column label="序号" width="55" align="center">
<template slot-scope="scope">
<span>{{ scope.$index +1 }}</span>
</template>
</el-table-column>
<el-table-column prop="authorization" label="Authorization" align="center" show-overflow-tooltip >
</el-table-column>
<el-table-column prop="apiKey" label="api_key" align="center" show-overflow-tooltip >
</el-table-column>
<el-table-column prop="secretKey" label="secret_key" align="center" show-overflow-tooltip >
</el-table-column>
</el-table>
</el-tab-pane>
<el-tab-pane label="请求参数" name="table1">
<el-form ref="form" :rules="rules" :model="form">
<el-table :data="form.reqParams" stripe border
:max-height="300"
style="width: 100%; margin: 15px 0;">
<el-table-column label="序号" width="55" align="center">
<template slot-scope="scope">
<span>{{ scope.$index +1 }}</span>
</template>
</el-table-column>
<el-table-column prop="paramName" label="参数名称" align="center" show-overflow-tooltip >
</el-table-column>
<el-table-column prop="nullable" label="是否允许为空" align="center" show-overflow-tooltip >
<template slot-scope="scope">
<el-checkbox v-model="scope.row.nullable" true-label="1" false-label="0"></el-checkbox>
</template>
</el-table-column>
<el-table-column prop="remark" label="描述" align="center" show-overflow-tooltip >
</el-table-column>
<el-table-column prop="paramType" label="参数类型" align="center" show-overflow-tooltip >
<template slot-scope="scope">
<el-select v-model="scope.row.paramType" placeholder="请选择参数类型">
<el-option
v-for="dict in paramTypeOptions"
:key="dict.id"
:label="dict.itemValue"
:value="dict.itemText"
></el-option>
</el-select>
</template>
</el-table-column>
<el-table-column prop="whereType" label="操作符" align="center" show-overflow-tooltip >
<template slot-scope="scope">
<el-select v-model="scope.row.whereType" placeholder="请选择操作符">
<el-option
v-for="dict in whereTypeOptions"
:key="dict.id"
:label="dict.itemValue"
:value="dict.itemText"
></el-option>
</el-select>
</template>
</el-table-column>
<el-table-column prop="paramValue" label="参数值" align="center" show-overflow-tooltip >
<template slot-scope="scope">
<el-form-item :prop=" 'reqParams.' + scope.$index + '.paramValue' " :rules="rules.paramValue">
<el-input v-model="scope.row.paramValue" placeholder="请输入参数值" />
</el-form-item>
</template>
</el-table-column>
</el-table>
</el-form>
</el-tab-pane>
</el-tabs>
</el-col>
</el-row>
<el-divider content-position="left">返回数据</el-divider>
<el-row>
<el-col :span="24">
<el-table :data="callData.dataList" stripe border
:max-height="200"
style="width: 100%; margin: 15px 0;">
<el-table-column label="序号" width="55" align="center">
<template slot-scope="scope">
<span>{{ scope.$index + 1 }}</span>
</template>
</el-table-column>
<template v-for="(column, index) in callData.columnList">
<el-table-column
:prop="column"
:label="column"
:key="index"
align="center"
show-overflow-tooltip
/>
</template>
</el-table>
<el-pagination
:page-sizes="[10, 20, 50, 100]"
layout="total, sizes, prev, pager, next, jumper"
@size-change="handleSizeChange"
@current-change="handleCurrentChange"
:current-page.sync="callData.pageNum"
:page-size.sync="callData.pageSize"
:total="callData.dataTotal"
></el-pagination>
</el-col>
</el-row>
</div>
</el-card>
</div>
</template>
<script>
import { getDataApi } from '@/api/market/dataapi'
import { getApiHeader, getApiCall, postApiCall } from '@/api/market/apicall'
import storage from '@/utils/storage'
export default {
name: 'DataApiCall',
props: {
data: {
type: Object,
default: function () {
return {}
}
}
},
data () {
return {
classCardbody: {
overflow: 'auto',
height: document.body.offsetHeight - 240 + 'px'
},
title: '数据API调用',
// 展示切换
showOptions: {
data: {},
showList: true,
showAdd: false,
showEdit: false,
showDetail: false,
showCall: false
},
activeTabName: 'table0',
form: {},
rules: {
paramValue: [{ required: true, message: "参数值不能为空", trigger: "blur" }]
},
apiHeader: {},
apiHeaderList: [],
// 操作符数据字典
whereTypeOptions: [],
// 参数类型数据字典
paramTypeOptions: [],
callData: {
dataList: [],
columnList: [],
pageNum: 1,
pageSize: 20,
dataTotal: 0
}
}
},
created () {
console.log('id:' + this.data.id)
this.getDicts('data_where_type').then(response => {
if (response.success) {
this.whereTypeOptions = response.data
}
})
this.getDicts('data_param_type').then(response => {
if (response.success) {
this.paramTypeOptions = response.data
}
})
this.getDataApi(this.data.id)
this.getApiHeader(this.data.id)
},
methods: {
showCard () {
this.$emit('showCard', this.showOptions)
},
/** 获取详情 */
getDataApi: function (id) {
getDataApi(id).then(response => {
if (response.success) {
this.form = response.data
}
})
},
getApiHeader: function (id) {
getApiHeader(id).then(response => {
if (response.success) {
let data = response.data
this.apiHeader = data
let token = storage.ss.get('vue_template_token')
data.authorization = 'Bearer ' + token
this.apiHeaderList.push(data)
}
})
},
handleSizeChange (val) {
this.callData.pageNum = 1
this.callData.pageSize = val
this.apiDataCall()
},
handleCurrentChange (val) {
this.callData.pageNum = val
this.apiDataCall()
},
apiDataCall () {
this.$refs.form.validate(valid => {
if (valid) {
let url = this.form.apiUrl
let header = {api_key: this.apiHeader.apiKey, secret_key: this.apiHeader.secretKey}
let data = {}
data.pageNum = this.callData.pageNum
data.pageSize = this.callData.pageSize
this.form.reqParams.forEach(param => {
this.$set(data, param.paramName, param.paramValue)
})
if (this.form.reqMethod === 'GET') {
getApiCall(url, header, data).then(response => {
if (response.success) {
const { data } = response
let dataList = data.data || []
let columnList = []
if (dataList.length > 0) {
columnList = Object.keys(dataList[0])
}
this.callData.dataList = dataList
this.callData.columnList = columnList
this.callData.dataTotal = data.total
}
})
} else if (this.form.reqMethod === 'POST') {
postApiCall(url, header, data).then(response => {
if (response.success) {
const { data } = response
let dataList = data.data || []
let columnList = []
if (dataList.length > 0) {
columnList = Object.keys(dataList[0])
}
this.callData.dataList = dataList
this.callData.columnList = columnList
this.callData.dataTotal = data.total
}
})
}
}
})
}
}
}
</script>
<style lang="scss" scoped>
</style>
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
<div slot="header" class="clearfix"> <div slot="header" class="clearfix">
<span>{{ title }}</span> <span>{{ title }}</span>
<el-button-group style="float: right;"> <el-button-group style="float: right;">
<el-button size="mini" icon="el-icon-s-data" round @click="apiCall">数据调用</el-button>
<el-button size="mini" icon="el-icon-back" round @click="showCard">返回</el-button> <el-button size="mini" icon="el-icon-back" round @click="showCard">返回</el-button>
</el-button-group> </el-button-group>
</div> </div>
...@@ -13,7 +14,7 @@ ...@@ -13,7 +14,7 @@
<el-step title="执行配置"></el-step> <el-step title="执行配置"></el-step>
<el-step title="参数配置"></el-step> <el-step title="参数配置"></el-step>
</el-steps> </el-steps>
<el-form ref="form1" :model="form1" :rules="rules1" label-width="80px" v-if="active == 1" disabled> <el-form ref="form1" :model="form1" label-width="80px" v-if="active == 1" disabled>
<el-form-item label="API名称" prop="apiName"> <el-form-item label="API名称" prop="apiName">
<el-input v-model="form1.apiName" placeholder="请输入API名称" /> <el-input v-model="form1.apiName" placeholder="请输入API名称" />
</el-form-item> </el-form-item>
...@@ -74,7 +75,7 @@ ...@@ -74,7 +75,7 @@
<el-input v-model="form1.remark" type="textarea" placeholder="请输入内容" /> <el-input v-model="form1.remark" type="textarea" placeholder="请输入内容" />
</el-form-item> </el-form-item>
</el-form> </el-form>
<el-form ref="form2" :model="form2" :rules="rules2" label-width="80px" v-if="active == 2" disabled> <el-form ref="form2" :model="form2" label-width="80px" v-if="active == 2" disabled>
<el-form-item label="配置方式" prop="configType"> <el-form-item label="配置方式" prop="configType">
<el-select v-model="form2.configType" placeholder="请选择配置方式"> <el-select v-model="form2.configType" placeholder="请选择配置方式">
<el-option <el-option
...@@ -161,7 +162,7 @@ ...@@ -161,7 +162,7 @@
</el-col> </el-col>
</el-row> </el-row>
</el-form> </el-form>
<el-form ref="form3" :model="form3" :rules="rules3" label-width="80px" v-if="active == 3" disabled> <el-form ref="form3" :model="form3" label-width="80px" v-if="active == 3" disabled>
<el-form-item label="请求参数"> <el-form-item label="请求参数">
<el-table :data="form3.reqParams" stripe border <el-table :data="form3.reqParams" stripe border
:max-height="300" :max-height="300"
...@@ -205,14 +206,8 @@ ...@@ -205,14 +206,8 @@
</template> </template>
</el-table-column> </el-table-column>
<el-table-column prop="exampleValue" label="示例值" align="center" show-overflow-tooltip > <el-table-column prop="exampleValue" label="示例值" align="center" show-overflow-tooltip >
<template slot-scope="scope">
<el-input v-model="scope.row.exampleValue" placeholder="请输入示例值" />
</template>
</el-table-column> </el-table-column>
<el-table-column prop="defaultValue" label="默认值" align="center" show-overflow-tooltip > <el-table-column prop="defaultValue" label="默认值" align="center" show-overflow-tooltip >
<template slot-scope="scope">
<el-input v-model="scope.row.defaultValue" placeholder="请输入默认值" />
</template>
</el-table-column> </el-table-column>
</el-table> </el-table>
</el-form-item> </el-form-item>
...@@ -232,9 +227,6 @@ ...@@ -232,9 +227,6 @@
<el-table-column prop="dataType" label="数据类型" align="center" show-overflow-tooltip > <el-table-column prop="dataType" label="数据类型" align="center" show-overflow-tooltip >
</el-table-column> </el-table-column>
<el-table-column prop="exampleValue" label="示例值" align="center" show-overflow-tooltip > <el-table-column prop="exampleValue" label="示例值" align="center" show-overflow-tooltip >
<template slot-scope="scope">
<el-input v-model="scope.row.exampleValue" placeholder="请输入示例值" />
</template>
</el-table-column> </el-table-column>
</el-table> </el-table>
</el-form-item> </el-form-item>
...@@ -277,7 +269,8 @@ export default { ...@@ -277,7 +269,8 @@ export default {
showList: true, showList: true,
showAdd: false, showAdd: false,
showEdit: false, showEdit: false,
showDetail: false showDetail: false,
showCall: false
}, },
active: 1, active: 1,
// 表单参数 // 表单参数
...@@ -462,6 +455,15 @@ export default { ...@@ -462,6 +455,15 @@ export default {
} }
} }
}) })
},
apiCall () {
this.showOptions.data.id = this.data.id
this.showOptions.showList = false
this.showOptions.showAdd = false
this.showOptions.showEdit = false
this.showOptions.showDetail = false
this.showOptions.showCall = true
this.$emit('showCard', this.showOptions)
} }
} }
} }
......
...@@ -186,36 +186,44 @@ ...@@ -186,36 +186,44 @@
</el-table-column> </el-table-column>
<el-table-column prop="paramType" label="参数类型" align="center" show-overflow-tooltip > <el-table-column prop="paramType" label="参数类型" align="center" show-overflow-tooltip >
<template slot-scope="scope"> <template slot-scope="scope">
<el-select v-model="scope.row.paramType" placeholder="请选择参数类型"> <el-form-item :prop=" 'reqParams.' + scope.$index + '.paramType' " :rules="rules3.paramType">
<el-option <el-select v-model="scope.row.paramType" placeholder="请选择参数类型">
v-for="dict in paramTypeOptions" <el-option
:key="dict.id" v-for="dict in paramTypeOptions"
:label="dict.itemValue" :key="dict.id"
:value="dict.itemText" :label="dict.itemValue"
></el-option> :value="dict.itemText"
</el-select> ></el-option>
</el-select>
</el-form-item>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column prop="whereType" label="操作符" align="center" show-overflow-tooltip > <el-table-column prop="whereType" label="操作符" align="center" show-overflow-tooltip >
<template slot-scope="scope"> <template slot-scope="scope">
<el-select v-model="scope.row.whereType" placeholder="请选择操作符"> <el-form-item :prop=" 'reqParams.' + scope.$index + '.whereType' " :rules="rules3.whereType">
<el-option <el-select v-model="scope.row.whereType" placeholder="请选择操作符">
v-for="dict in whereTypeOptions" <el-option
:key="dict.id" v-for="dict in whereTypeOptions"
:label="dict.itemValue" :key="dict.id"
:value="dict.itemText" :label="dict.itemValue"
></el-option> :value="dict.itemText"
</el-select> ></el-option>
</el-select>
</el-form-item>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column prop="exampleValue" label="示例值" align="center" show-overflow-tooltip > <el-table-column prop="exampleValue" label="示例值" align="center" show-overflow-tooltip >
<template slot-scope="scope"> <template slot-scope="scope">
<el-input v-model="scope.row.exampleValue" placeholder="请输入示例值" /> <el-form-item :prop=" 'reqParams.' + scope.$index + '.exampleValue' " :rules="rules3.exampleValue">
<el-input v-model="scope.row.exampleValue" placeholder="请输入示例值" />
</el-form-item>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column prop="defaultValue" label="默认值" align="center" show-overflow-tooltip > <el-table-column prop="defaultValue" label="默认值" align="center" show-overflow-tooltip >
<template slot-scope="scope"> <template slot-scope="scope">
<el-input v-model="scope.row.defaultValue" placeholder="请输入默认值" /> <el-form-item :prop=" 'reqParams.' + scope.$index + '.defaultValue' " :rules="rules3.defaultValue">
<el-input v-model="scope.row.defaultValue" placeholder="请输入默认值" />
</el-form-item>
</template> </template>
</el-table-column> </el-table-column>
</el-table> </el-table>
...@@ -237,7 +245,9 @@ ...@@ -237,7 +245,9 @@
</el-table-column> </el-table-column>
<el-table-column prop="exampleValue" label="示例值" align="center" show-overflow-tooltip > <el-table-column prop="exampleValue" label="示例值" align="center" show-overflow-tooltip >
<template slot-scope="scope"> <template slot-scope="scope">
<el-input v-model="scope.row.exampleValue" placeholder="请输入示例值" /> <el-form-item :prop=" 'resParams.' + scope.$index + '.exampleValue' " :rules="rules3.exampleValue">
<el-input v-model="scope.row.exampleValue" placeholder="请输入示例值" />
</el-form-item>
</template> </template>
</el-table-column> </el-table-column>
</el-table> </el-table>
...@@ -281,7 +291,8 @@ export default { ...@@ -281,7 +291,8 @@ export default {
showList: true, showList: true,
showAdd: false, showAdd: false,
showEdit: false, showEdit: false,
showDetail: false showDetail: false,
showCall: false
}, },
// 保存按钮 // 保存按钮
loadingOptions: { loadingOptions: {
...@@ -320,10 +331,10 @@ export default { ...@@ -320,10 +331,10 @@ export default {
{ required: true, message: 'API路径不能为空', trigger: 'blur' } { required: true, message: 'API路径不能为空', trigger: 'blur' }
], ],
reqMethod: [ reqMethod: [
{ required: true, message: '请求方式不能为空', trigger: 'blur' } { required: true, message: '请求方式不能为空', trigger: 'change' }
], ],
resType: [ resType: [
{ required: true, message: '返回格式不能为空', trigger: 'blur' } { required: true, message: '返回格式不能为空', trigger: 'change' }
] ]
}, },
form2: { form2: {
...@@ -335,17 +346,30 @@ export default { ...@@ -335,17 +346,30 @@ export default {
}, },
rules2: { rules2: {
configType: [ configType: [
{ required: true, message: '配置方式不能为空', trigger: 'blur' } { required: true, message: '配置方式不能为空', trigger: 'change' }
], ],
sourceId: [ sourceId: [
{ required: true, message: '数据源不能为空', trigger: 'blur' } { required: true, message: '数据源不能为空', trigger: 'change' }
] ]
}, },
form3: { form3: {
reqParams: [], reqParams: [],
resParams: [] resParams: []
}, },
rules3: {}, rules3: {
paramType: [
{ required: true, message: '参数类型不能为空', trigger: 'change' }
],
whereType: [
{ required: true, message: '操作符不能为空', trigger: 'change' }
],
exampleValue: [
{ required: true, message: '示例值不能为空', trigger: 'blur' }
],
defaultValue: [
{ required: true, message: '默认值不能为空', trigger: 'blur' }
]
},
// 请求方式数据字典 // 请求方式数据字典
reqMethodOptions: [], reqMethodOptions: [],
// 返回格式数据字典 // 返回格式数据字典
......
...@@ -173,7 +173,8 @@ export default { ...@@ -173,7 +173,8 @@ export default {
showList: true, showList: true,
showAdd: false, showAdd: false,
showEdit: false, showEdit: false,
showDetail: false showDetail: false,
showCall: false
}, },
// 遮罩层 // 遮罩层
loading: true, loading: true,
...@@ -272,6 +273,7 @@ export default { ...@@ -272,6 +273,7 @@ export default {
this.showOptions.showAdd = true this.showOptions.showAdd = true
this.showOptions.showEdit = false this.showOptions.showEdit = false
this.showOptions.showDetail = false this.showOptions.showDetail = false
this.showOptions.showCall = false
this.$emit('showCard', this.showOptions) this.$emit('showCard', this.showOptions)
}, },
/** 修改按钮操作 */ /** 修改按钮操作 */
...@@ -281,6 +283,7 @@ export default { ...@@ -281,6 +283,7 @@ export default {
this.showOptions.showAdd = false this.showOptions.showAdd = false
this.showOptions.showEdit = true this.showOptions.showEdit = true
this.showOptions.showDetail = false this.showOptions.showDetail = false
this.showOptions.showCall = false
this.$emit('showCard', this.showOptions) this.$emit('showCard', this.showOptions)
}, },
/** 详情按钮操作 */ /** 详情按钮操作 */
...@@ -290,6 +293,7 @@ export default { ...@@ -290,6 +293,7 @@ export default {
this.showOptions.showAdd = false this.showOptions.showAdd = false
this.showOptions.showEdit = false this.showOptions.showEdit = false
this.showOptions.showDetail = true this.showOptions.showDetail = true
this.showOptions.showCall = false
this.$emit('showCard', this.showOptions) this.$emit('showCard', this.showOptions)
}, },
/** 删除按钮操作 */ /** 删除按钮操作 */
......
...@@ -12,6 +12,9 @@ ...@@ -12,6 +12,9 @@
<transition name="el-zoom-in-bottom"> <transition name="el-zoom-in-bottom">
<data-api-detail v-if="options.showDetail" :data="options.data" @showCard="showCard"></data-api-detail> <data-api-detail v-if="options.showDetail" :data="options.data" @showCard="showCard"></data-api-detail>
</transition> </transition>
<transition name="el-zoom-in-bottom">
<data-api-call v-if="options.showCall" :data="options.data" @showCard="showCard"></data-api-call>
</transition>
</div> </div>
</template> </template>
...@@ -20,10 +23,11 @@ import DataApiList from './DataApiList' ...@@ -20,10 +23,11 @@ import DataApiList from './DataApiList'
import DataApiAdd from './DataApiAdd' import DataApiAdd from './DataApiAdd'
import DataApiEdit from './DataApiEdit' import DataApiEdit from './DataApiEdit'
import DataApiDetail from './DataApiDetail' import DataApiDetail from './DataApiDetail'
import DataApiCall from './DataApiCall'
export default { export default {
name: 'DataApi', name: 'DataApi',
components: { DataApiList, DataApiAdd, DataApiEdit, DataApiDetail }, components: { DataApiList, DataApiAdd, DataApiEdit, DataApiDetail, DataApiCall },
data () { data () {
return { return {
options: { options: {
...@@ -31,7 +35,8 @@ export default { ...@@ -31,7 +35,8 @@ export default {
showList: true, showList: true,
showAdd: false, showAdd: false,
showEdit: false, showEdit: false,
showDetail: false showDetail: false,
showCall: false
} }
} }
}, },
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment