Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
A
api-gateway
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
API
api-gateway
Commits
691a6922
Commit
691a6922
authored
Mar 12, 2021
by
shaojiawen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update:创建事件通知
parent
8c59eff0
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
66 additions
and
371 deletions
+66
-371
api-version-show.vue
src/components/api/api-version-show.vue
+30
-0
version-list.vue
src/components/api/version-list.vue
+5
-1
create-event-base.vue
src/components/createApi/create-event-base.vue
+10
-157
create-event-field.vue
src/components/createApi/create-event-field.vue
+6
-190
result-table.vue
src/components/createApi/result-table.vue
+4
-1
store.js
src/store/store.js
+7
-0
apiList.vue
src/views/index/apiList.vue
+1
-1
createEventApi.vue
src/views/index/createEventApi.vue
+2
-20
groupApiList.vue
src/views/index/groupApiList.vue
+1
-1
No files found.
src/components/api/api-version-show.vue
View file @
691a6922
...
@@ -88,6 +88,36 @@ import apiVersionShow from '@/components/api/api-version-show.vue';
...
@@ -88,6 +88,36 @@ import apiVersionShow from '@/components/api/api-version-show.vue';
</div>
</div>
</div>
</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
<div
id=
"base"
id=
"base"
class=
"base-info-wrap info-wrap"
>
class=
"base-info-wrap info-wrap"
>
...
...
src/components/api/version-list.vue
View file @
691a6922
...
@@ -421,7 +421,11 @@ export default {
...
@@ -421,7 +421,11 @@ export default {
*/
*/
handleEdit
(
index
,
row
)
{
handleEdit
(
index
,
row
)
{
const
that
=
this
;
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: 下线
* @description: 下线
...
...
src/components/createApi/create-event-base.vue
View file @
691a6922
...
@@ -71,10 +71,8 @@ export default {
...
@@ -71,10 +71,8 @@ export default {
interfaceId
:
''
,
interfaceId
:
''
,
interfaceVersionId
:
''
,
interfaceVersionId
:
''
,
interfaceName
:
''
,
interfaceName
:
''
,
// target: '1',
interfaceDescribe
:
''
,
// optType: 'get',
code
:
''
// interfaceUrl: '',
interfaceDescribe
:
''
},
},
rules
:
{
rules
:
{
interfaceName
:
[
{
required
:
true
,
message
:
'请输入API名称'
,
trigger
:
'blur'
}
],
interfaceName
:
[
{
required
:
true
,
message
:
'请输入API名称'
,
trigger
:
'blur'
}
],
...
@@ -85,11 +83,14 @@ export default {
...
@@ -85,11 +83,14 @@ export default {
mounted
()
{
mounted
()
{
const
that
=
this
;
const
that
=
this
;
/* eslint-disable */
/* 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
();
that
.
getData
();
}
}
if
(
Object
.
keys
(
that
.
$store
.
state
.
baseInfo
).
length
)
{
if
(
Object
.
keys
(
that
.
$store
.
state
.
base
Event
Info
).
length
)
{
that
.
apiInfoData
=
that
.
$store
.
state
.
baseInfo
;
that
.
apiInfoData
=
that
.
$store
.
state
.
base
Event
Info
;
}
}
},
},
methods
:
{
methods
:
{
...
@@ -97,7 +98,6 @@ export default {
...
@@ -97,7 +98,6 @@ export default {
const
that
=
this
;
const
that
=
this
;
that
.
$refs
[
formName
].
validate
(
valid
=>
{
that
.
$refs
[
formName
].
validate
(
valid
=>
{
if
(
valid
)
{
if
(
valid
)
{
console
.
log
(
that
.
apiInfoData
)
// if (formName == 'baseForm') {
// if (formName == 'baseForm') {
that
.
$emit
(
'submitNext'
,
that
.
apiInfoData
);
that
.
$emit
(
'submitNext'
,
that
.
apiInfoData
);
that
.
$store
.
dispatch
(
'saveBaseEventInfo'
,
that
.
apiInfoData
);
that
.
$store
.
dispatch
(
'saveBaseEventInfo'
,
that
.
apiInfoData
);
...
@@ -108,146 +108,6 @@ export default {
...
@@ -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
()
{
getData
()
{
...
@@ -260,20 +120,13 @@ export default {
...
@@ -260,20 +120,13 @@ export default {
.
then
(
res
=>
{
.
then
(
res
=>
{
let
resData
=
res
.
data
;
let
resData
=
res
.
data
;
if
(
resData
.
code
==
'0000'
)
{
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
);
resData
.
result
.
resultParams
=
JSON
.
parse
(
resData
.
result
.
resultParams
);
that
.
apiInfoData
.
interfaceId
=
resData
.
result
.
interfaceId
;
that
.
apiInfoData
.
interfaceId
=
resData
.
result
.
interfaceId
;
that
.
apiInfoData
.
interfaceVersionId
=
resData
.
result
.
interfaceVersionId
;
that
.
apiInfoData
.
interfaceVersionId
=
resData
.
result
.
interfaceVersionId
;
that
.
apiInfoData
.
interfaceName
=
resData
.
result
.
interfaceName
;
that
.
apiInfoData
.
interfaceName
=
resData
.
result
.
interfaceName
;
that
.
apiInfoData
.
target
=
String
(
resData
.
result
.
target
);
that
.
apiInfoData
.
code
=
resData
.
result
.
code
;
that
.
apiInfoData
.
optType
=
resData
.
result
.
optType
;
that
.
apiInfoData
.
interfaceUrl
=
resData
.
result
.
interfaceUrl
;
that
.
apiInfoData
.
interfaceDescribe
=
resData
.
result
.
interfaceDescribe
;
that
.
apiInfoData
.
interfaceDescribe
=
resData
.
result
.
interfaceDescribe
;
that
.
handleFrontData
(
resData
.
result
);
that
.
$store
.
dispatch
(
'saveFieldEventInfo'
,
resData
.
result
);
that
.
handleBackData
(
resData
.
result
);
that
.
handleResultData
(
resData
.
result
);
that
.
$nextTick
(()
=>
{
that
.
$nextTick
(()
=>
{
that
.
submitForm
(
'baseForm'
);
that
.
submitForm
(
'baseForm'
);
});
});
...
...
src/components/createApi/create-event-field.vue
View file @
691a6922
...
@@ -92,6 +92,7 @@ import createBase from '@/components/api/create-base.vue';
...
@@ -92,6 +92,7 @@ import createBase from '@/components/api/create-base.vue';
<result-table
<result-table
ref=
"resultBodyTable"
ref=
"resultBodyTable"
:is-description=
"true"
:is-description=
"true"
:is-not-root=
"true"
:item-data=
"resultParams"
:item-data=
"resultParams"
@
refreshData=
"refreshData"
/>
@
refreshData=
"refreshData"
/>
<div
<div
...
@@ -156,7 +157,7 @@ export default {
...
@@ -156,7 +157,7 @@ export default {
},
},
mounted
()
{
mounted
()
{
const
that
=
this
;
const
that
=
this
;
if
(
Object
.
keys
(
that
.
$store
.
state
.
f
ro
ntInfo
).
length
)
{
if
(
Object
.
keys
(
that
.
$store
.
state
.
f
ieldEve
ntInfo
).
length
)
{
that
.
handleStoreData
();
that
.
handleStoreData
();
}
}
},
},
...
@@ -199,17 +200,15 @@ export default {
...
@@ -199,17 +200,15 @@ export default {
resultParams
:
JSON
.
stringify
(
that
.
resultParams
),
// 配置结果
resultParams
:
JSON
.
stringify
(
that
.
resultParams
),
// 配置结果
// 编辑
// 编辑
interfaceId
:
that
.
$store
.
state
.
baseEventInfo
.
interfaceId
,
// api id
interfaceId
:
that
.
$store
.
state
.
baseEventInfo
.
interfaceId
,
// api id
//
interfaceVersionId: that.$store.state.baseEventInfo.interfaceVersionId // api 版本 id
interfaceVersionId
:
that
.
$store
.
state
.
baseEventInfo
.
interfaceVersionId
// api 版本 id
};
};
// console.log(para);
// return;
postRequest
(
that
.
$store
.
state
.
baseEventInfo
.
interfaceId
?
'/gateway-manage/update-api'
:
'/gateway-manage/create-api'
,
para
)
postRequest
(
that
.
$store
.
state
.
baseEventInfo
.
interfaceId
?
'/gateway-manage/update-api'
:
'/gateway-manage/create-api'
,
para
)
.
then
(
res
=>
{
.
then
(
res
=>
{
let
resData
=
res
.
data
;
let
resData
=
res
.
data
;
if
(
resData
.
code
==
'0000'
)
{
if
(
resData
.
code
==
'0000'
)
{
showMsg
.
showmsg
(
'保存成功'
,
'success'
);
showMsg
.
showmsg
(
'保存成功'
,
'success'
);
that
.
$store
.
dispatch
(
'clearApiData'
);
that
.
$store
.
dispatch
(
'clearApiData'
);
that
.
$router
.
push
(
`/apiListManage?interfaceId=
${
resData
.
result
.
interfaceId
}
&interfaceName=
${
resData
.
result
.
interfaceName
}
&projectId=
${
that
.
$route
.
query
.
projectId
}
&projectName=
${
that
.
$route
.
query
.
projectName
}
&interfaceGroupId=
${
that
.
$route
.
query
.
interfaceGroupId
}
&interfaceGroupName=
${
that
.
$route
.
query
.
interfaceGroupName
}
`
);
that
.
$router
.
push
(
`/apiListManage?interfaceId=
${
resData
.
result
.
interfaceId
}
&interfaceName=
${
resData
.
result
.
interfaceName
}
&projectId=
${
that
.
$route
.
query
.
projectId
}
&projectName=
${
that
.
$route
.
query
.
projectName
}
&interfaceGroupId=
${
that
.
$route
.
query
.
interfaceGroupId
}
&interfaceGroupName=
${
that
.
$route
.
query
.
interfaceGroupName
}
&apiType=
${
2
}
`
);
return
;
return
;
}
}
errMsg
.
errorMsg
(
resData
);
errMsg
.
errorMsg
(
resData
);
...
@@ -221,97 +220,6 @@ export default {
...
@@ -221,97 +220,6 @@ export default {
});
});
});
});
},
},
/**
* @description: 处理properties
* @param {Object} item
* @author: 无尘
*/
async
handleProperties
(
item
)
{
const
that
=
this
;
for
(
let
childKey
in
item
)
{
// 为了以后切换type可以监听到属性,需要预制属性
if
(
item
[
childKey
].
type
!=
'array'
&&
item
[
childKey
].
type
!=
'object'
)
{
item
[
childKey
].
properties
=
{};
}
if
(
item
[
childKey
].
type
==
'array'
&&
Object
.
keys
(
item
[
childKey
].
items
.
properties
).
length
)
{
await
that
.
handleProperties
(
item
[
childKey
].
items
.
properties
,
item
[
childKey
]);
}
if
(
item
[
childKey
].
type
==
'object'
&&
Object
.
keys
(
item
[
childKey
].
properties
).
length
)
{
await
that
.
handleProperties
(
item
[
childKey
].
properties
,
item
[
childKey
]);
}
}
},
/**
* @description: 处理 isRootKey
* @param {Object} item
* @param {String} parentKey
* @returns {Object}
* @author: 无尘
*/
async
handleArrObjData
(
item
,
parentKey
)
{
const
that
=
this
;
for
(
let
childKey
in
item
)
{
item
[
childKey
][
'isRootKey'
]
=
!
item
[
childKey
][
'isRootKey'
]
||
item
[
childKey
][
'isRootKey'
]
==
''
||
item
[
childKey
][
'isRootKey'
]
==
0
?
false
:
true
;
// 是否是后端参数字段
// 是否禁用,不能选择,这里暂时设置一下,后面后端配置中会去重新设置 isRootKeyFlag 这个字段值
item
[
childKey
][
'isRootKeyFlag'
]
=
!
parentKey
.
isRootKey
||
item
[
childKey
][
'isRootKey'
]
?
false
:
true
;
if
(
item
[
childKey
][
'isRootKey'
])
{
parentKey
.
isRootKeyFlag
=
true
;
// 这里是必须的
}
// 为了以后切换type可以监听到属性,需要预制属性
if
(
item
[
childKey
].
type
!=
'array'
&&
item
[
childKey
].
type
!=
'object'
)
{
item
[
childKey
].
properties
=
{};
}
if
(
item
[
childKey
].
type
==
'array'
&&
Object
.
keys
(
item
[
childKey
].
items
.
properties
).
length
)
{
await
that
.
handleArrObjData
(
item
[
childKey
].
items
.
properties
,
item
[
childKey
]);
}
if
(
item
[
childKey
].
type
==
'object'
&&
Object
.
keys
(
item
[
childKey
].
properties
).
length
)
{
await
that
.
handleArrObjData
(
item
[
childKey
].
properties
,
item
[
childKey
]);
}
}
return
item
;
},
/**
* @description: 前端通用数据处理
* @param {Object} allData
* @param {String} type
* @returns {Object}
* @author: 无尘
*/
async
handleQuery
(
allData
,
type
)
{
const
that
=
this
;
let
newObj
=
{
type
:
'object'
,
level
:
1
,
properties
:
{},
required
:
[]
};
for
(
let
key
in
allData
.
properties
)
{
allData
.
properties
[
key
].
isRootKey
=
allData
.
properties
[
key
].
isRootKey
==
1
||
allData
.
properties
[
key
].
isRootKey
==
true
?
true
:
false
;
allData
.
properties
[
key
][
'isRootKeyFlag'
]
=
false
;
// form 判断
if
(
allData
.
properties
[
key
].
frontOriginType
==
'form'
)
{
that
.
apiInfoData
.
requestType
=
'POST'
;
that
.
apiInfoData
.
frontBodyType
=
'form'
;
}
if
(
allData
.
properties
[
key
].
frontOriginType
==
type
)
{
that
.
$set
(
newObj
.
properties
,
allData
.
properties
[
key
].
currentKey
,
allData
.
properties
[
key
]);
}
// 为了以后切换type可以监听到属性,需要预制属性
if
(
allData
.
properties
[
key
].
type
!=
'array'
&&
allData
.
properties
[
key
].
type
!=
'object'
)
{
allData
.
properties
[
key
].
properties
=
{};
}
// console.log(allData.properties[key]);
// 如果有数组出现
if
(
allData
.
properties
[
key
].
type
==
'array'
&&
Object
.
keys
(
allData
.
properties
[
key
].
items
.
properties
).
length
)
{
await
that
.
handleArrObjData
(
allData
.
properties
[
key
].
items
.
properties
,
allData
.
properties
[
key
]);
}
// 如果有对象出现
if
(
allData
.
properties
[
key
].
type
==
'object'
&&
Object
.
keys
(
allData
.
properties
[
key
].
properties
).
length
)
{
await
that
.
handleArrObjData
(
allData
.
properties
[
key
].
properties
,
allData
.
properties
[
key
]);
}
}
return
newObj
;
},
refreshData
(
data
)
{
refreshData
(
data
)
{
const
that
=
this
;
const
that
=
this
;
...
@@ -340,30 +248,6 @@ export default {
...
@@ -340,30 +248,6 @@ export default {
}
}
});
});
},
},
/**
* @description: 处理 提交的 isRootKey
* @param {Object} item
* @param {Object} parentItem
* @returns {Object}
* @author: 无尘
*/
async
handleRootKey
(
item
,
parentItem
)
{
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
][
'isRootKey'
])
{
parentItem
[
'isRootKey'
]
=
false
;
}
if
(
item
[
childKey
].
type
==
'array'
&&
Object
.
keys
(
item
[
childKey
].
items
.
properties
).
length
)
{
await
that
.
handleRootKey
(
item
[
childKey
].
items
.
properties
,
item
[
childKey
]);
}
if
(
item
[
childKey
].
type
==
'object'
&&
Object
.
keys
(
item
[
childKey
].
properties
).
length
)
{
await
that
.
handleRootKey
(
item
[
childKey
].
properties
,
item
[
childKey
]);
}
}
return
item
;
},
/**
/**
* @description: 下一步之前处理数据
* @description: 下一步之前处理数据
* @author: 唐尼
* @author: 唐尼
...
@@ -371,8 +255,6 @@ export default {
...
@@ -371,8 +255,6 @@ export default {
async
handleData
()
{
async
handleData
()
{
const
that
=
this
;
const
that
=
this
;
that
.
apiInfoData
.
resultParams
=
that
.
resultParams
;
that
.
apiInfoData
.
resultParams
=
that
.
resultParams
;
console
.
log
(
that
.
apiInfoData
);
// that.$emit('submitNext', that.apiInfoData);
await
that
.
toPostApi
();
await
that
.
toPostApi
();
},
},
/**
/**
...
@@ -381,74 +263,8 @@ export default {
...
@@ -381,74 +263,8 @@ export default {
*/
*/
async
handleStoreData
()
{
async
handleStoreData
()
{
const
that
=
this
;
const
that
=
this
;
that
.
apiInfoData
=
JSON
.
parse
(
JSON
.
stringify
(
that
.
$store
.
state
.
frontInfo
));
that
.
apiInfoData
=
JSON
.
parse
(
JSON
.
stringify
(
that
.
$store
.
state
.
fieldEventInfo
));
that
.
headerData
=
that
.
apiInfoData
.
headerData
;
that
.
resultParams
=
that
.
apiInfoData
.
resultParams
;
that
.
queryData
=
that
.
apiInfoData
.
queryData
;
const
bodyJsonData
=
{
type
:
'object'
,
level
:
1
,
properties
:
{
bodyRoot
:
{
level
:
2
,
currentKey
:
'bodyRoot'
,
frontOriginType
:
'body'
,
// 来源类型 query,body,header
backendOriginType
:
'body'
,
type
:
'object'
,
isBackendField
:
0
,
// 是否后端字段
defaultVal
:
'val'
,
// 默认值
isRootKey
:
false
,
// 是否是后端参数字段
isRootKeyFlag
:
false
,
// 禁用标志
rootKey
:
''
,
// 后端参数字段
objectClass
:
''
,
// 如果是object 并且是dubbo
description
:
'描述'
,
example
:
'示例'
,
check
:
true
,
properties
:
{}
}
},
required
:
[]
};
const
bodyFormData
=
{
type
:
'object'
,
level
:
1
,
properties
:
{
bodyForm
:
{
level
:
2
,
currentKey
:
'bodyForm'
,
frontOriginType
:
'form'
,
// 来源类型 query,body,header,form
backendOriginType
:
'form'
,
type
:
'string'
,
isBackendField
:
0
,
// 是否后端字段
defaultVal
:
'val'
,
// 默认值
isRootKey
:
false
,
// 是否是后端参数字段
isRootKeyFlag
:
false
,
// 禁用标志
rootKey
:
''
,
// 后端参数字段
objectClass
:
''
,
// 如果是object 并且是dubbo
description
:
'描述'
,
example
:
'示例'
,
check
:
true
,
properties
:
{}
}
},
required
:
[]
};
// 为了处理修改 type 后添加子属性响应问题
if
(
Object
.
keys
(
that
.
apiInfoData
.
bodyJsonData
).
length
)
{
for
(
const
key
in
that
.
apiInfoData
.
bodyJsonData
.
properties
.
bodyRoot
.
properties
)
{
if
(
that
.
apiInfoData
.
bodyJsonData
.
properties
.
bodyRoot
.
properties
[
key
].
type
!=
'array'
&&
that
.
apiInfoData
.
bodyJsonData
.
properties
.
bodyRoot
.
properties
[
key
].
type
!=
'object'
){
that
.
apiInfoData
.
bodyJsonData
.
properties
.
bodyRoot
.
properties
[
key
].
properties
=
{};
}
if
(
that
.
apiInfoData
.
bodyJsonData
.
properties
.
bodyRoot
.
properties
[
key
].
type
==
'array'
&&
Object
.
keys
(
that
.
apiInfoData
.
bodyJsonData
.
properties
.
bodyRoot
.
properties
[
key
].
items
.
properties
).
length
)
{
await
that
.
handleProperties
(
that
.
apiInfoData
.
bodyJsonData
.
properties
.
bodyRoot
.
properties
[
key
].
items
.
properties
);
}
if
(
that
.
apiInfoData
.
bodyJsonData
.
properties
.
bodyRoot
.
properties
[
key
].
type
==
'object'
&&
Object
.
keys
(
that
.
apiInfoData
.
bodyJsonData
.
properties
.
bodyRoot
.
properties
[
key
].
properties
).
length
)
{
await
that
.
handleProperties
(
that
.
apiInfoData
.
bodyJsonData
.
properties
.
bodyRoot
.
properties
[
key
].
properties
);
}
}
}
// console.log('状态中:json//',JSON.stringify(that.apiInfoData.bodyJsonData));
that
.
bodyJsonData
=
Object
.
keys
(
that
.
apiInfoData
.
bodyJsonData
).
length
?
that
.
apiInfoData
.
bodyJsonData
:
bodyJsonData
;
that
.
bodyFormData
=
Object
.
keys
(
that
.
apiInfoData
.
bodyFormData
).
length
?
that
.
apiInfoData
.
bodyFormData
:
bodyFormData
;
}
}
}
}
};
};
...
...
src/components/createApi/result-table.vue
View file @
691a6922
...
@@ -22,7 +22,7 @@ import resultTable from '@/components/createApi/result-table.vue';
...
@@ -22,7 +22,7 @@ import resultTable from '@/components/createApi/result-table.vue';
<div
class=
"cell"
>
<div
class=
"cell"
>
<el-input
<el-input
v-model=
"itemValue.currentKey"
v-model=
"itemValue.currentKey"
:disabled=
"
itemValue.type == 'array' || itemValue.type == 'object'
"
:disabled=
"
(itemValue.type == 'array' || itemValue.type == 'object')&&!isNotRoot
"
@
blur=
"blurKey(itemValue, itemName)"
/>
@
blur=
"blurKey(itemValue, itemName)"
/>
</div>
</div>
</td>
</td>
...
@@ -118,6 +118,9 @@ export default {
...
@@ -118,6 +118,9 @@ export default {
},
},
isDescription
:
{
isDescription
:
{
type
:
Boolean
type
:
Boolean
},
isNotRoot
:
{
type
:
Boolean
}
}
},
},
data
()
{
data
()
{
...
...
src/store/store.js
View file @
691a6922
...
@@ -53,6 +53,9 @@ export default new Vuex.Store({
...
@@ -53,6 +53,9 @@ export default new Vuex.Store({
saveBaseEvent
:
(
state
,
data
)
=>
{
saveBaseEvent
:
(
state
,
data
)
=>
{
state
.
baseEventInfo
=
data
;
state
.
baseEventInfo
=
data
;
},
},
saveFieldEvent
:
(
state
,
data
)
=>
{
state
.
fieldEventInfo
=
data
;
},
saveFront
:
(
state
,
data
)
=>
{
saveFront
:
(
state
,
data
)
=>
{
state
.
frontInfo
=
data
;
state
.
frontInfo
=
data
;
},
},
...
@@ -74,6 +77,7 @@ export default new Vuex.Store({
...
@@ -74,6 +77,7 @@ export default new Vuex.Store({
state
.
backInfo
=
{};
state
.
backInfo
=
{};
state
.
resultInfo
=
{};
state
.
resultInfo
=
{};
state
.
baseEventInfo
=
{};
state
.
baseEventInfo
=
{};
state
.
fieldEventInfo
=
{};
},
},
clearLog
:
state
=>
{
clearLog
:
state
=>
{
localStorage
.
removeItem
(
'logInfo'
);
localStorage
.
removeItem
(
'logInfo'
);
...
@@ -111,6 +115,9 @@ export default new Vuex.Store({
...
@@ -111,6 +115,9 @@ export default new Vuex.Store({
saveBaseEventInfo
(
context
,
data
)
{
saveBaseEventInfo
(
context
,
data
)
{
context
.
commit
(
'saveBaseEvent'
,
data
);
context
.
commit
(
'saveBaseEvent'
,
data
);
},
},
saveFieldEventInfo
(
context
,
data
)
{
context
.
commit
(
'saveFieldEvent'
,
data
);
},
clearTempBackData
(
context
,
data
)
{
clearTempBackData
(
context
,
data
)
{
context
.
commit
(
'clearTempBack'
);
context
.
commit
(
'clearTempBack'
);
},
},
...
...
src/views/index/apiList.vue
View file @
691a6922
...
@@ -240,7 +240,7 @@ export default {
...
@@ -240,7 +240,7 @@ export default {
*/
*/
toApiListManage
(
index
,
row
)
{
toApiListManage
(
index
,
row
)
{
const
that
=
this
;
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
}
`
);
},
},
/**
/**
...
...
src/views/index/createEventApi.vue
View file @
691a6922
...
@@ -44,20 +44,6 @@
...
@@ -44,20 +44,6 @@
@
submitBack=
"submitBack"
@
submitBack=
"submitBack"
@
submitNext=
"submitNext"
/>
@
submitNext=
"submitNext"
/>
</div>
</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>
</div>
</div>
</div>
...
@@ -67,16 +53,12 @@
...
@@ -67,16 +53,12 @@
import
navBread
from
'@/components/nav/nav-bread.vue'
;
import
navBread
from
'@/components/nav/nav-bread.vue'
;
import
createEventBase
from
'@/components/createApi/create-event-base.vue'
;
import
createEventBase
from
'@/components/createApi/create-event-base.vue'
;
import
createEventField
from
'@/components/createApi/create-event-field.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
{
export
default
{
name
:
'CreateApi'
,
name
:
'Create
Event
Api'
,
components
:
{
components
:
{
navBread
,
navBread
,
createEventBase
,
createEventBase
,
createEventField
,
createEventField
// createBackend,
// createResult
},
},
data
()
{
data
()
{
return
{
return
{
...
...
src/views/index/groupApiList.vue
View file @
691a6922
...
@@ -268,7 +268,7 @@ export default {
...
@@ -268,7 +268,7 @@ export default {
*/
*/
toApiListManage
(
index
,
row
)
{
toApiListManage
(
index
,
row
)
{
const
that
=
this
;
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
}
`
);
},
},
/**
/**
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment