Skip to content

Commit 96b0dac

Browse files
committed
APIAuto:新增支持给场景用例打标签
1 parent 4cb62b4 commit 96b0dac

2 files changed

Lines changed: 120 additions & 8 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: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -230,22 +230,36 @@
230230
</div>
231231
</div>
232232

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="输入名称,回车来添加" />
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="输入名称,回车来添加" />
235235

236-
<ul class="historys" style="width: 100%; height: 100%;overflow: hidden;overflow-y: scroll;padding-bottom: 50px">
236+
<ul v-show="isChainGroupShow()" 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)" />
240-
<a href="javascript:void(0)" @click="selectChainGroup(index, item.Chain)" :style="{ color: index == currentChainGroupIndex ? 'black' : 'gray' }" >{{ isCaseGroupEditable ? '' : item.Chain.groupName }}</a><a style="right: 0px; position: absolute; z-index: 100; width: fit-content; background-color: white; margin-right: 24px" class="hint--left" :data-hint="item.Chain.groupName">{{' (' + (item.Chain.count - 1) + ') '}}</a>
240+
<a href="javascript:void(0)" @click="selectChainGroup(index, item.Chain)" :style="{ color: index == currentChainGroupIndex ? 'black' : 'gray' }" >{{ isCaseGroupEditable ? '' : item.Chain.groupName }}</a>
241+
<ul style="display: inline-flex; position: absolute; top: 6px; right: 84px; padding: 0px; height: 27px; overflow: scroll hidden;">
242+
<li style="margin: 0px; padding: 2px; border: #DDD 1px solid; border-radius: 2px " v-for="(tag, ind) in item.Chain.tagList" :id="'tag' + index" >
243+
<a href="javascript:void(0)" style="position: relative; min-width: 6px; width: auto; height: 30px; " @click="removeChainTag(ind, tag, index, item)" >{{ tag }}</a>
244+
</li>
245+
</ul><button class="hint--left" data-hint="点底部标签来添加,或分组标签来移除" style="position: absolute; right: 60px; top: 6px;" href="javascript:void(0)" @click="addChainTag(index, item)"> + </button><a style="right: 0px; position: absolute; z-index: 100; width: fit-content; background-color: white; margin-right: 24px" class="hint--left" :data-hint="item.Chain.groupName">{{' (' + (item.Chain.count - 1) + ') '}}</a>
241246
<svg class="icon" @click="remove(item, index, true, false, false, true)" style="background-color: white; width: 27px; height: 18px; right: -2px; top: 10px; padding-left: 3px; padding-right: 4px; padding-top: 2px; padding-bottom: 2px;" >
242247
<use xlink:href="svg/icon.svg#trash"></use>
243248
</svg>
244249
</div>
245250
</li>
246251
</ul>
247252

248-
<div style="bottom: 0px; padding: 4px 10px 4px 10px; position: absolute; background-color: white; z-index: 102">
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">
249263
<button @click="pageDown('chainGroup')"><</button>
250264
<input id="vChainGroupPage" v-model="chainGroupPage" style="width: 30px;text-align: center" type="number" @keyup="doOnKeyUp(event, 'chainGroup', true)" placeholder="页码" />
251265
<button @click="pageUp('chainGroup')">></button>

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

Lines changed: 101 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1222,6 +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'}],
12251226
chainPaths: [],
12261227
casePaths: [],
12271228
chainGroups: [],
@@ -4869,6 +4870,94 @@ https://github.com/Tencent/APIJSON/issues
48694870
isChainItemShow: function () {
48704871
return this.chainShowType != 2 || (this.chainGroups.length <= 0 && this.chainPaths.length > 0)
48714872
},
4873+
removeChainTag: function (ind, tag, index, item) {
4874+
var chain = (item || {}).Chain || {}
4875+
var tagList = chain.tagList || [];
4876+
tagList.splice(ind, 1)
4877+
this.setChainTag(index, chain, tagList)
4878+
},
4879+
addChainTag: function (index, group) {
4880+
this.isCaseGroupEditable = true
4881+
this.currentChainGroupIndex = index
4882+
var chain = (group || {}).Chain || {}
4883+
var tagList = chain.tagList || []
4884+
var chainTags = this.chainTags || []
4885+
for (var j = 0; j < chainTags.length; j ++) {
4886+
var tag = chainTags[i] || {}
4887+
tag.selected = false
4888+
}
4889+
4890+
for (var i = 0; i < tagList.length; i ++) {
4891+
var name = tagList[i]
4892+
if (StringUtil.isEmpty(name)) {
4893+
continue
4894+
}
4895+
4896+
var find = false
4897+
for (var j = 0; j < chainTags.length; j ++) {
4898+
var tag = chainTags[i] || {}
4899+
if (tag.name == name) {
4900+
tag.selected = true
4901+
find = true
4902+
}
4903+
}
4904+
4905+
if (! find) {
4906+
chainTags.push({name: name, selected: true})
4907+
}
4908+
}
4909+
4910+
this.chainTags = chainTags
4911+
},
4912+
setChainTag(index, item, tagList, isAdd) {
4913+
var chain = item || {} // (item || {}).Chain || {}
4914+
this.request(true, REQUEST_TYPE_POST, REQUEST_TYPE_JSON, this.server + '/put', {
4915+
Chain: {
4916+
'id': chain.id,
4917+
'groupId': chain.groupId,
4918+
'groupId{}': [chain.groupId],
4919+
'groupName': chain.groupName,
4920+
'tagList': tagList
4921+
},
4922+
tag: 'Chain-group'
4923+
}, {}, function (url, res, err) {
4924+
App.onResponse(url, res, err)
4925+
var isOk = JSONResponse.isSuccess(res.data)
4926+
4927+
var msg = isOk ? '' : ('\nmsg: ' + StringUtil.get((res.data || {}).msg))
4928+
if (err != null) {
4929+
msg += '\nerr: ' + err.msg
4930+
}
4931+
alert((isAdd ? '新增' : '移除') + (isOk ? '成功' : '失败') + (isAdd ? '! \n' :'!\ngroupId: ' + chain.groupId) + '\ngroupName: ' + chain.groupName + '\n' + msg)
4932+
4933+
App.isCaseGroupEditable = ! isOk
4934+
if (isOk) {
4935+
App.selectChainGroup(App.currentChainGroupIndex, null)
4936+
}
4937+
})
4938+
},
4939+
selectChainTag: function (index, tag) {
4940+
tag.selected = ! tag.selected
4941+
var groupIndex = this.currentChainGroupIndex
4942+
if (this.isCaseGroupEditable != true || groupIndex < 0) {
4943+
this.selectChainGroup(groupIndex)
4944+
return
4945+
}
4946+
4947+
var group = this.chainGroups[groupIndex] || {}
4948+
var chain = group.Chain || {}
4949+
var tagList = chain.tagList || []
4950+
if (tag.selected) {
4951+
tagList.push(tag.name)
4952+
} else {
4953+
var ind = tagList.indexOf(tag.name)
4954+
if (ind >= 0) {
4955+
tagList.splice(ind, 1)
4956+
}
4957+
}
4958+
4959+
this.setChainTag(groupIndex, chain, tagList, true)
4960+
},
48724961
selectChainGroup: function (index, group) {
48734962
this.currentChainGroupIndex = index
48744963
this.currentDocIndex = -1
@@ -4885,7 +4974,7 @@ https://github.com/Tencent/APIJSON/issues
48854974
this.chainPaths = [group] // .push(group)
48864975
}
48874976

4888-
this.casePaths = this.chainPaths
4977+
this.casePaths = this.chainPaths
48894978

48904979
var groupId = group == null ? 0 : group.groupId
48914980
if (groupId != null && groupId > 0) { // group != null && groupId == 0) {
@@ -4904,6 +4993,14 @@ https://github.com/Tencent/APIJSON/issues
49044993
var page = this.chainGroupPage = this.chainGroupPages[key] || 0
49054994
var count = this.chainGroupCount = this.chainGroupCounts[key] || 0
49064995
var search = this.chainGroupSearch = this.chainGroupSearches[key] || ''
4996+
var chainTags = this.chainTags || []
4997+
var tags = []
4998+
for (var i = 0; i < chainTags.length; i ++) {
4999+
var tag = chainTags[i] || {}
5000+
if (tag.selected) {
5001+
tags.push(tag.name)
5002+
}
5003+
}
49075004

49085005
search = StringUtil.isEmpty(search, true) ? null : '%' + StringUtil.trim(search).replaceAll('_', '\\_').replaceAll('%', '\\%') + '%'
49095006
var req = {
@@ -4915,8 +5012,9 @@ https://github.com/Tencent/APIJSON/issues
49155012
'userId': userId,
49165013
'toGroupId': groupId,
49175014
'groupName$': search,
4918-
// '@raw': '@column',
4919-
'@column': "groupId;any_value(groupName):groupName;count(*):count",
5015+
'tagList&<>': tags == null || tags.length <= 0 ? null : tags,
5016+
'@raw': '@column',
5017+
'@column': "groupId;any_value(groupName):groupName;any_value(tagList):tagList;count(*):count",
49205018
'@group': 'groupId',
49215019
'@order': 'groupId-',
49225020
// 'documentId>': 0

0 commit comments

Comments
 (0)