Skip to content

Commit 5a3b2a4

Browse files
committed
APIAuto:支持新增标签,自动刷新标签列表,解决场景用例单独显示子项时未显示
1 parent 96b0dac commit 5a3b2a4

2 files changed

Lines changed: 75 additions & 20 deletions

File tree

  • APIJSON-Java-Server/APIJSONBoot-MultiDataSource/src/main/resources/static/api

‎APIJSON-Java-Server/APIJSONBoot-MultiDataSource/src/main/resources/static/api/index.html‎

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -230,10 +230,10 @@
230230
</div>
231231
</div>
232232

233-
<div v-show="isChainShow && ! isLocalShow" :style="{width: chainShowType == 0 ? '40%' : '100%', 'border-right': chainShowType != 0 ? 'none' : '#DDD 1px solid' }" style="float: left; min-width: 30px; width: 40%; height: 100%;">
234-
<input v-show="isChainGroupShow()" id="vChainGroupAdd" style="width: 100%; text-align: center" @keyup="doOnKeyUp(event, 'chainGroupAdd', false, {'groupName': vChainGroupAdd.value})" placeholder="输入名称,回车来添加" />
233+
<div v-show="isChainShow && isChainGroupShow() && ! isLocalShow" :style="{width: chainShowType == 0 ? '40%' : '100%', 'border-right': chainShowType != 0 ? 'none' : '#DDD 1px solid' }" style="float: left; min-width: 30px; width: 40%; height: 100%;">
234+
<input id="vChainGroupAdd" style="width: 100%; text-align: center" @keyup="doOnKeyUp(event, 'chainGroupAdd', false, {'groupName': vChainGroupAdd.value})" placeholder="输入名称,回车来添加" />
235235

236-
<ul v-show="isChainGroupShow()" class="historys" style="width: 100%; height: 100%;overflow: hidden;overflow-y: scroll;padding-bottom: 50px">
236+
<ul class="historys" style="width: 100%; height: 100%;overflow: hidden;overflow-y: scroll;padding-bottom: 50px">
237237
<li v-for="(item, index) in chainGroups" :id="'chainGroup' + index" >
238238
<div style="display: inline-table; width: 100%">
239239
<input v-show="isCaseGroupEditable" style="min-width: 60px; width: 40%; margin-right: 6px" v-model="item.Chain.groupName" @keyup="doOnKeyUp(event, 'chainGroup', false, item)" />
@@ -250,16 +250,7 @@
250250
</li>
251251
</ul>
252252

253-
<div style="display: inline-flex; width: 100%; bottom: 36px; padding: 4px 10px 4px 10px; position: absolute; background-color: white; z-index: 102">
254-
<input id="vChainTagAdd" style="width: 64px; height: 30px; text-align: center" @keyup="doOnKeyUp(event, 'chainTagAdd', false, {'name': vChainTagAdd.value})" placeholder="新增标签,回车来添加" />
255-
<ul style="display: inline-flex; padding: 0px; width: 100%; height: 30px; overflow: hidden;overflow-x: scroll;">
256-
<li style="margin: 0px; padding: 2px; border: #DDD 1px solid; border-radius: 2px " v-for="(item, index) in chainTags" :id="'tag' + index" >
257-
<a href="javascript:void(0)" style="position: relative; min-width: 6px; width: auto; height: 30px; " @click="selectChainTag(index, item)" :style="{ color: item.selected ? 'red' : 'gray' }" >{{ item.name }}</a>
258-
</li>
259-
</ul>
260-
</div>
261-
262-
<div v-show="isChainGroupShow()" style="bottom: 0px; padding: 4px 10px 4px 10px; position: absolute; background-color: white; z-index: 102">
253+
<div style="bottom: 0px; padding: 4px 10px 4px 10px; position: absolute; background-color: white; z-index: 102">
263254
<button @click="pageDown('chainGroup')"><</button>
264255
<input id="vChainGroupPage" v-model="chainGroupPage" style="width: 30px;text-align: center" type="number" @keyup="doOnKeyUp(event, 'chainGroup', true)" placeholder="页码" />
265256
<button @click="pageUp('chainGroup')">></button>
@@ -268,6 +259,14 @@
268259
</div>
269260
</div>
270261

262+
<div v-show="isChainShow && ! isLocalShow" style="left: 0px; display: inline-flex; width: 100%; bottom: 36px; padding: 4px 10px 4px 10px; position: absolute; background-color: white; z-index: 102">
263+
<input id="vChainTagAdd" style="width: 64px; height: 30px; text-align: center" @keyup="doOnKeyUp(event, 'chainTagAdd', false, {'name': vChainTagAdd.value})" placeholder="新增标签,回车来添加" />
264+
<ul style="display: inline-flex; padding: 0px; width: 100%; height: 30px; overflow: hidden;overflow-x: scroll;">
265+
<li style="margin: 0px; padding: 2px; border: #DDD 1px solid; border-radius: 2px " v-for="(item, index) in chainTags" :id="'tag' + index" >
266+
<a href="javascript:void(0)" style="position: relative; min-width: 6px; width: auto; height: 30px; " @click="selectChainTag(index, item)" :style="{ color: item.selected ? 'red' : 'gray' }" >{{ item.name }}</a>
267+
</li>
268+
</ul>
269+
</div>
271270

272271
<div v-show="isLocalShow || isCaseItemShow()" :style="{width: isCaseGroupShow() && ! isLocalShow ? '60%' : '100%'}" style="float: right; flex-grow: 1; height: 100%;">
273272
<input id="vChainAdd" v-show="isChainShow && currentChainGroupIndex >= 0" style="width: 100%; text-align: center" @keyup="doOnKeyUp(event, 'chainAdd', false, {'groupName': vChainAdd.value})" placeholder="输入名称,回车来搜索及添加" />

‎APIJSON-Java-Server/APIJSONBoot-MultiDataSource/src/main/resources/static/api/js/main.js‎

Lines changed: 63 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1222,7 +1222,7 @@ https://github.com/Tencent/APIJSON/issues
12221222
history: {name: '请求0'},
12231223
remotes: [],
12241224
locals: [],
1225-
chainTags: [{name: 'Home', selected: true}, {name: 'Category', selected: false}, {name: 'Search', selected: true}, {name: 'Moment'}, {name: 'Chat'}, {name: 'Tommy'}, {name: 'Lemon'}],
1225+
chainTags: [{name: 'Home', selected: false}, {name: 'Category'}, {name: 'Search'}, {name: 'Moment'}, {name: 'Chat'}, {name: 'Tommy'}, {name: 'Lemon'}],
12261226
chainPaths: [],
12271227
casePaths: [],
12281228
chainGroups: [],
@@ -4883,22 +4883,23 @@ https://github.com/Tencent/APIJSON/issues
48834883
var tagList = chain.tagList || []
48844884
var chainTags = this.chainTags || []
48854885
for (var j = 0; j < chainTags.length; j ++) {
4886-
var tag = chainTags[i] || {}
4886+
var tag = chainTags[j] || {}
48874887
tag.selected = false
48884888
}
48894889

48904890
for (var i = 0; i < tagList.length; i ++) {
48914891
var name = tagList[i]
4892-
if (StringUtil.isEmpty(name)) {
4892+
if (StringUtil.isEmpty(name, true)) {
48934893
continue
48944894
}
48954895

48964896
var find = false
48974897
for (var j = 0; j < chainTags.length; j ++) {
4898-
var tag = chainTags[i] || {}
4898+
var tag = chainTags[j] || {}
48994899
if (tag.name == name) {
49004900
tag.selected = true
49014901
find = true
4902+
break
49024903
}
49034904
}
49044905

@@ -5085,6 +5086,14 @@ https://github.com/Tencent/APIJSON/issues
50855086
}
50865087
},
50875088
},
5089+
'Chain-tagList[]': {
5090+
'count': 0,
5091+
'Chain': {
5092+
'userId': userId,
5093+
'@column': "groupId;any_value(tagList):tagList",
5094+
'@group': 'groupId'
5095+
}
5096+
},
50885097
'@role': IS_NODE ? null : 'LOGIN',
50895098
key: IS_NODE ? this.key : undefined // 突破常规查询数量限制
50905099
}
@@ -5128,6 +5137,34 @@ https://github.com/Tencent/APIJSON/issues
51285137
App.chainPaths.push(item.Chain)
51295138
}
51305139
App.remotes = App.testCases = item['[]'] || []
5140+
5141+
var tagLists = data['Chain-tagList[]'] || []
5142+
var chainTags = App.chainTags || []
5143+
for (var i = 0; i < tagLists.length; i ++) {
5144+
var tagList = tagLists[i] || []
5145+
for (var j = 0; j < tagList.length; j ++) {
5146+
var name = tagList[i]
5147+
if (StringUtil.isEmpty(name, true)) {
5148+
continue
5149+
}
5150+
5151+
var find = false
5152+
for (var k = 0; k < chainTags.length; k ++) {
5153+
var tag = chainTags[k] || {}
5154+
if (tag.name == name) {
5155+
find = true
5156+
break
5157+
}
5158+
}
5159+
5160+
if (! find) {
5161+
chainTags.push({name: name})
5162+
}
5163+
}
5164+
}
5165+
5166+
App.chainTags = chainTags
5167+
51315168
App.isTestCaseShow = true
51325169
// App.showTestCase(true, false, null)
51335170
})
@@ -8077,7 +8114,27 @@ Content-Type: ` + contentType) + (StringUtil.isEmpty(headerStr, true) ? '' : hea
80778114
return
80788115
}
80798116

8080-
if (type == 'chainGroupAdd' || type == 'chainGroup') {
8117+
if (type == 'chainTagAdd') {
8118+
var name = StringUtil.trim(item.name)
8119+
if (StringUtil.isEmpty(name)) {
8120+
alert('请输入有效标签名!')
8121+
return
8122+
}
8123+
8124+
var chainTags = this.chainTags = this.chainTags || []
8125+
for (var j = 0; j < chainTags.length; j ++) {
8126+
var tag = chainTags[j] || {}
8127+
if (tag.name == name) {
8128+
if (find) {
8129+
alert(name + ' 已存在,请勿重复添加!')
8130+
return
8131+
}
8132+
}
8133+
}
8134+
8135+
chainTags.push({name: name})
8136+
}
8137+
else if (type == 'chainGroupAdd' || type == 'chainGroup') {
80818138
var isAdd = type == 'chainGroupAdd'
80828139
var groupName = item == null ? null : item.groupName
80838140
if (StringUtil.isEmpty(groupName)) {
@@ -13732,8 +13789,7 @@ Content-Type: ` + contentType) + (StringUtil.isEmpty(headerStr, true) ? '' : hea
1373213789
// alert(event.key) 小写字母 i 而不是 KeyI
1373313790

1373413791
var>
13735-
if (target == vAskAI || vSearch || vTestCaseSearch || vCaseGroupSearch
13736-
|| vChainGroupSearch || vChainGroupAdd || vChainAdd) {
13792+
if ([vInput, vRandom, vHeader, vScript].indexOf(target) < 0) {
1373713793
return
1373813794
}
1373913795

0 commit comments

Comments
 (0)