Commit 691a6922 by shaojiawen

update:创建事件通知

parent 8c59eff0
......@@ -88,6 +88,36 @@ import apiVersionShow from '@/components/api/api-version-show.vue';
</div>
</div>
</div>
<!-- <div class="anchor-wrap">
<div class="el-tabs el-tabs--right">
<div class="el-tabs__header is-right">
<div class="el-tabs__nav-wrap is-right">
<div class="el-tabs__nav-scroll">
<div
role="tablist"
class="el-tabs__nav is-right"
style="transform: translateY(0px);">
<div
class="el-tabs__active-bar is-right"
:style="{ transform: `translateY(${activeInfo * 24}px)`, height: '24px' }" />
<div
id="tab-0"
:class="['el-tabs__item h-24 is-right', activeInfo == 0 ? 'is-active' : '']"
@click="goAuthor('#base', 0)">
基础配置
</div>
<div
id="tab-1"
:class="['el-tabs__item h-24 is-right', activeInfo == 1 ? 'is-active' : '']"
@click="goAuthor('#frontend', 1)">
前端配置
</div>
</div>
</div>
</div>
</div>
</div>
</div> -->
<div
id="base"
class="base-info-wrap info-wrap">
......
......@@ -421,7 +421,11 @@ export default {
*/
handleEdit(index, row) {
const that = this;
that.$router.push(`/createApi?projectId=${row.projectId}&projectName=${that.$route.query.projectName}&interfaceGroupId=${row.interfaceGroupId}&interfaceGroupName=${that.$route.query.interfaceGroupName}&interfaceId=${that.$route.query.interfaceId}&interfaceName=${that.$route.query.interfaceName}&interfaceVersionId=${row.interfaceVersionId}`);
if(that.$route.query.apiType != 2){
that.$router.push(`/createApi?projectId=${row.projectId}&projectName=${that.$route.query.projectName}&interfaceGroupId=${row.interfaceGroupId}&interfaceGroupName=${that.$route.query.interfaceGroupName}&interfaceId=${that.$route.query.interfaceId}&interfaceName=${that.$route.query.interfaceName}&interfaceVersionId=${row.interfaceVersionId}`);
return;
}
that.$router.push(`/createEventApi?projectId=${row.projectId}&projectName=${that.$route.query.projectName}&interfaceGroupId=${row.interfaceGroupId}&interfaceGroupName=${that.$route.query.interfaceGroupName}&interfaceId=${that.$route.query.interfaceId}&interfaceName=${that.$route.query.interfaceName}&interfaceVersionId=${row.interfaceVersionId}`);
},
/**
* @description: 下线
......
......@@ -71,10 +71,8 @@ export default {
interfaceId: '',
interfaceVersionId: '',
interfaceName: '',
// target: '1',
// optType: 'get',
// interfaceUrl: '',
interfaceDescribe: ''
interfaceDescribe: '',
code: ''
},
rules: {
interfaceName: [ { required: true, message: '请输入API名称', trigger: 'blur' } ],
......@@ -85,11 +83,14 @@ export default {
mounted() {
const that = this;
/* eslint-disable */
if (that.$route.query.interfaceId && !Object.keys(that.$store.state.baseInfo).length) {
console.log(that.$route.query.interfaceId);
console.log(that.$store.state.baseEventInfo);
console.log(Object.keys(that.$store.state.baseEventInfo));
if (that.$route.query.interfaceId && !Object.keys(that.$store.state.baseEventInfo).length) {
that.getData();
}
if (Object.keys(that.$store.state.baseInfo).length) {
that.apiInfoData = that.$store.state.baseInfo;
if (Object.keys(that.$store.state.baseEventInfo).length) {
that.apiInfoData = that.$store.state.baseEventInfo;
}
},
methods: {
......@@ -97,7 +98,6 @@ export default {
const that = this;
that.$refs[formName].validate(valid => {
if (valid) {
console.log(that.apiInfoData)
// if (formName == 'baseForm') {
that.$emit('submitNext', that.apiInfoData);
that.$store.dispatch('saveBaseEventInfo', that.apiInfoData);
......@@ -108,146 +108,6 @@ export default {
});
},
/**
* 处理 isRootKey
*/
async handleArrObjData(item) {
const that = this;
for (let childKey in item) {
item[childKey]['isRootKey'] = !item[childKey]['isRootKey'] || item[childKey]['isRootKey'] == '' || item[childKey]['isRootKey'] == 0 ? false : true; // 是否是后端参数字段
if (item[childKey].type == 'array' && Object.keys(item[childKey].items.properties).length) {
await that.handleArrObjData(item[childKey].items.properties);
}
if (item[childKey].type == 'object' && Object.keys(item[childKey].properties).length) {
await that.handleArrObjData(item[childKey].properties);
}
}
return item;
},
/**
* 处理数据存入 store
*/
// 前端通用数据处理
async handleQuery(front, allData, type) {
const that = this;
let newObj = {
type: 'object',
level: 1,
properties: {}
};
// 最开始处理的时候, frontParams 和 endParams是同一份数据,所有前后端公用一份参数数据
for (let key in allData.frontParams.properties) {
if (allData.frontParams.properties[key].frontOriginType == type && !allData.endParams.properties[key].constFlag) {
allData.frontParams.properties[key].isRootKey = allData.frontParams.properties[key].isRootKey == 1 || allData.frontParams.properties[key].isRootKey == true ? true : false;
that.$set(newObj.properties, allData.frontParams.properties[key].currentKey, allData.frontParams.properties[key]);
}
// 如果有数组出现
if (allData.frontParams.properties[key].type == 'array' && Object.keys(allData.frontParams.properties[key].items.properties).length) {
await that.handleArrObjData(allData.frontParams.properties[key].items.properties, allData.frontParams.properties[key].isRootKey);
}
// 如果有对象出现
if (allData.frontParams.properties[key].type == 'object' && Object.keys(allData.frontParams.properties[key].properties).length) {
await that.handleArrObjData(allData.frontParams.properties[key].properties, allData.frontParams.properties[key].isRootKey);
}
}
return newObj;
},
/**
* 处理常量参数
*/
handleConst(back, allData) {
const that = this;
let newObj = {
type: 'object',
level: 1,
properties: {}
};
for (let key in allData.endParams.properties) {
if (allData.endParams.properties[key].constFlag) {
allData.endParams.properties[key].constFlag = allData.endParams.properties[key].constFlag ? true : false;
that.$set(newObj.properties, allData.endParams.properties[key].currentKey, allData.endParams.properties[key]);
}
}
return newObj;
},
/**
* 获取已经保存的数据,处理前端数据
*/
async handleFrontData(data) {
const that = this;
let allData = JSON.parse(JSON.stringify(data));
let front = {
protocol: allData.protocol,
requestType: allData.requestType,
frontBodyType: allData.frontBodyType || 'json',
frontParams: {},
headerData: {},
queryData: {},
bodyJsonData: {},
bodyFormData: {}
};
front.queryData = await that.handleQuery(front, allData, 'query');
front.headerData = await that.handleQuery(front, allData, 'header');
if (allData.requestType == 'POST' && allData.frontBodyType == 'form') {
front.bodyFormData = await that.handleQuery(front, allData, 'form');
}
if (allData.requestType == 'POST' && allData.frontBodyType == 'json') {
// console.log('body', allData);
front.bodyJsonData = await that.handleQuery(front, allData, 'body');
}
// console.log('base:', allData.requestType, allData.frontBodyType, front);
that.$store.dispatch('saveFrontInfo', front);
},
/**
* 获取已经保存的数据,处理前端数据
*/
async handleBackData(data) {
const that = this;
let allData = JSON.parse(JSON.stringify(data));
let back = {
interfaceType: String(allData.interfaceType), // 后端服务
version: allData.version, // api 版本号
backendRequestType: allData.backendRequestType,
backendHttpPath: allData.backendHttpPath || '', // 请求路径
dubboInterface: allData.dubboInterface || '', // dubbo接口名称
dubboMethod: allData.dubboMethod || '', // dubbo请求方法
dubboVersion: allData.dubboVersion || '', // dubbo 请求版本号
proxyCode: allData.proxyCode || '', // 注册中心
timeout: allData.timeout, // 超时
backHeaderData: {},
backQueryData: {},
backBodyJsonData: {},
backBodyFormData: {},
constData: {}
};
back.backQueryData = await that.handleQuery(back, allData, 'query');
back.backHeaderData = await that.handleQuery(back, allData, 'header');
if (allData.requestType == 'POST' && allData.frontBodyType == 'form') {
back.backBodyFormData = await that.handleQuery(back, allData, 'form');
}
if (allData.requestType == 'POST' && allData.frontBodyType == 'json') {
back.backBodyJsonData = await that.handleQuery(back, allData, 'body');
}
// console.log('back:', back);
// 常量
back.constData = await that.handleConst(back, allData);
that.$store.dispatch('saveBackInfo', back);
},
handleResultData(data) {
const that = this;
let allData = JSON.parse(JSON.stringify(data));
let result = {
resultParams: allData.resultParams,
sucReturn: allData.sucReturn, // 成功返回示例
errReturn: allData.errReturn, // 失败返回示例
// 错误码
errCode: allData.errCode,
// 场景 code
sceneCode: allData.sceneCode
};
// console.log(result);
that.$store.dispatch('saveResultInfo', result);
},
/**
* 获取数据
*/
getData() {
......@@ -260,20 +120,13 @@ export default {
.then(res => {
let resData = res.data;
if (resData.code == '0000') {
resData.result.frontParams = JSON.parse(resData.result.endParams); // 编辑获取的时候使用后端数据
resData.result.endParams = JSON.parse(resData.result.endParams); // 编辑获取的时候使用后端数据
resData.result.errCode = JSON.parse(resData.result.errCode);
resData.result.resultParams = JSON.parse(resData.result.resultParams);
that.apiInfoData.interfaceId = resData.result.interfaceId;
that.apiInfoData.interfaceVersionId = resData.result.interfaceVersionId;
that.apiInfoData.interfaceName = resData.result.interfaceName;
that.apiInfoData.target = String(resData.result.target);
that.apiInfoData.optType = resData.result.optType;
that.apiInfoData.interfaceUrl = resData.result.interfaceUrl;
that.apiInfoData.code = resData.result.code;
that.apiInfoData.interfaceDescribe = resData.result.interfaceDescribe;
that.handleFrontData(resData.result);
that.handleBackData(resData.result);
that.handleResultData(resData.result);
that.$store.dispatch('saveFieldEventInfo', resData.result);
that.$nextTick(() => {
that.submitForm('baseForm');
});
......
......@@ -22,7 +22,7 @@ import resultTable from '@/components/createApi/result-table.vue';
<div class="cell">
<el-input
v-model="itemValue.currentKey"
:disabled="itemValue.type == 'array' || itemValue.type == 'object'"
:disabled="(itemValue.type == 'array' || itemValue.type == 'object')&&!isNotRoot"
@blur="blurKey(itemValue, itemName)" />
</div>
</td>
......@@ -118,6 +118,9 @@ export default {
},
isDescription: {
type: Boolean
},
isNotRoot: {
type: Boolean
}
},
data() {
......
......@@ -53,6 +53,9 @@ export default new Vuex.Store({
saveBaseEvent: (state, data) => {
state.baseEventInfo = data;
},
saveFieldEvent: (state, data) => {
state.fieldEventInfo = data;
},
saveFront: (state, data) => {
state.frontInfo = data;
},
......@@ -74,6 +77,7 @@ export default new Vuex.Store({
state.backInfo = {};
state.resultInfo = {};
state.baseEventInfo = {};
state.fieldEventInfo = {};
},
clearLog: state => {
localStorage.removeItem('logInfo');
......@@ -111,6 +115,9 @@ export default new Vuex.Store({
saveBaseEventInfo(context, data) {
context.commit('saveBaseEvent', data);
},
saveFieldEventInfo(context, data) {
context.commit('saveFieldEvent', data);
},
clearTempBackData(context, data) {
context.commit('clearTempBack');
},
......
......@@ -240,7 +240,7 @@ export default {
*/
toApiListManage(index, row) {
const that = this;
that.$router.push(`/apiListManage?interfaceId=${row.interfaceId}&interfaceName=${row.interfaceName}&projectId=${row.projectId}&projectName=${row.projectName}&interfaceGroupId=${row.interfaceGroupId}&interfaceGroupName=${row.interfaceGroupName}`);
that.$router.push(`/apiListManage?interfaceId=${row.interfaceId}&interfaceName=${row.interfaceName}&projectId=${row.projectId}&projectName=${row.projectName}&interfaceGroupId=${row.interfaceGroupId}&interfaceGroupName=${row.interfaceGroupName}&apiType=${row.type}`);
},
/**
......
......@@ -44,20 +44,6 @@
@submitBack="submitBack"
@submitNext="submitNext" />
</div>
<!-- <div
v-if="activeStep == '3'"
class="create-api-back">
<create-backend
@submitBack="submitBack"
@submitNext="submitNext" />
</div> -->
<!-- <div
v-if="activeStep == '4'"
class="create-api-result">
<create-result
@submitBack="submitBack"
@submitNext="submitNext" />
</div> -->
</div>
</div>
</div>
......@@ -67,16 +53,12 @@
import navBread from '@/components/nav/nav-bread.vue';
import createEventBase from '@/components/createApi/create-event-base.vue';
import createEventField from '@/components/createApi/create-event-field.vue';
// import createBackend from '@/components/createApi/create-backend.vue';
// import createResult from '@/components/createApi/create-result.vue';
export default {
name: 'CreateApi',
name: 'CreateEventApi',
components: {
navBread,
createEventBase,
createEventField,
// createBackend,
// createResult
createEventField
},
data() {
return {
......
......@@ -268,7 +268,7 @@ export default {
*/
toApiListManage(index, row) {
const that = this;
that.$router.push(`/apiListManage?interfaceId=${row.interfaceId}&interfaceName=${row.interfaceName}&projectId=${row.projectId}&projectName=${row.projectName}&interfaceGroupId=${row.interfaceGroupId}&interfaceGroupName=${row.interfaceGroupName}`);
that.$router.push(`/apiListManage?interfaceId=${row.interfaceId}&interfaceName=${row.interfaceName}&projectId=${row.projectId}&projectName=${row.projectName}&interfaceGroupId=${row.interfaceGroupId}&interfaceGroupName=${row.interfaceGroupName}&apiType=${row.type}`);
},
/**
......
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