diff --git a/nezha-fronted/src/assets/stylus/main.scss b/nezha-fronted/src/assets/stylus/main.scss
index cd3dee6a2..2792f9db4 100644
--- a/nezha-fronted/src/assets/stylus/main.scss
+++ b/nezha-fronted/src/assets/stylus/main.scss
@@ -472,6 +472,9 @@ li{
padding-top: 24px;
font-size: 14px;
}
+.orange-font{
+ color:#FA901C;
+}
.content-left .sidebar-info-item {
line-height: 20px;
padding: 0 0 0 10px;
diff --git a/nezha-fronted/src/components/common/elementSet.vue b/nezha-fronted/src/components/common/elementSet.vue
index ec02d5365..1909bf1fa 100644
--- a/nezha-fronted/src/components/common/elementSet.vue
+++ b/nezha-fronted/src/components/common/elementSet.vue
@@ -8,14 +8,17 @@
v-for="(item,index) in custom"
:key="index"
class="custom-label"
- :class="!allowedAll&&!item.allowed && (index==0 || index == 1 || item.NotSet) ? 'custom-label-disabled' : ''"
@click="handler(item,index)"
:id="'element-set-el-'+index"
+ :class="{'custom-title orange-font':item.type == 'title','custom-label-disabled':!allowedAll&&!item.allowed && (index==0 || index == 1 || item.NotSet)}"
>
{{item.label}}
+
+
+
@@ -160,6 +163,9 @@ export default {
cursor: default;
font-size: 14px;
}
+.custom-title{
+ padding: 2px 0 2px 2px;
+}
.custom-label-disabled {
cursor: not-allowed;
background: #f1f3f4;
diff --git a/nezha-fronted/src/components/common/leftMenu.vue b/nezha-fronted/src/components/common/leftMenu.vue
index 1d168cd2f..18f624341 100644
--- a/nezha-fronted/src/components/common/leftMenu.vue
+++ b/nezha-fronted/src/components/common/leftMenu.vue
@@ -101,6 +101,28 @@
+
+
+
+
@@ -251,7 +251,10 @@
formData:null,
accountValidResult: true,
changeProtocolSwitch: true,
- exporterDisableSwitch: false
+ exporterDisableSwitch: false,
+ tagKeys:[],
+ tagValues:[],
+ tagValuesCache:new Map(),
}
},
watch: {
@@ -618,13 +621,61 @@
}else{
this.exporterDisableSwitch = false;
}
- }
+ },
+ loadKeys:function(){
+ this.$get('/asset/tagKey').then(res=>{
+ if(res.code == 200){
+ this.tagKeys = res.data.list.map(item=>{
+ return {value:item}
+ })
+ }
+ })
+ },
+ loadValues:function(tag){
+ let tagVal=tag.tag && tag.tag!=''?tag.tag:tag.value
+ if(!tagVal || tagVal ==''){this.tagValues=[]; return; }
+
+ let value = this.tagValuesCache.get(tagVal)
+ if(!value){
+ value = [];
+ this.$get('/asset/tagValue?key='+tagVal).then(res => {
+ if(res.code == 200){
+ value = res.data.list.map(item=>{
+ return {value:item}
+ })
+
+ this.tagValues=Object.assign([],value)
+ this.tagValuesCache.set(tag.tag,Object.assign([],value))
+ }
+ })
+ }else{
+ this.tagValues=Object.assign([],value)
+ }
+ },
+ filterKey:function(input,callback){
+ if(!input || input == ''){
+ callback(this.tagKeys)
+ }else{
+ let result=this.tagKeys.filter(item=>{return item.value.toLowerCase().indexOf(input.toLowerCase()) != -1})
+ callback(result)
+ }
+ },
+ filterValue:function(input,callback){
+ console.log(this.tagValues)
+ if(!input || input == ''){
+ callback(this.tagValues)
+ }else{
+ let result=this.tagValues.filter(item=>{return item.value.toLowerCase().indexOf(input.toLowerCase()) != -1})
+ callback(result)
+ }
+ },
},
mounted() {
this.getUserData();
this.getVendorData();
this.getAssetTypeData();
this.getDcData();
+ this.loadKeys();
this.showAccountOp = false;
}
}
diff --git a/nezha-fronted/src/components/page/asset/asset.vue b/nezha-fronted/src/components/page/asset/asset.vue
index 68f1414a2..b83c1c638 100644
--- a/nezha-fronted/src/components/page/asset/asset.vue
+++ b/nezha-fronted/src/components/page/asset/asset.vue
@@ -59,6 +59,10 @@
:prop="$tableSet.propTitle(item.prop,'asset')"
:sort-orders="['ascending', 'descending']"
>
+
+ {{item.label}} [Tag]
+ {{item.label}}
+
{{scope.row.id}}
@@ -118,6 +122,9 @@
{{scope.row.idc.tel}}
+
+ {{filterTags(scope)}}
+
@@ -358,6 +365,7 @@
},
assetPingSwitch: localStorage.getItem('nz-sys-asset-ping-switch'),
+ tagKeys:[],
}
},
watch: {
@@ -497,6 +505,7 @@
if (refresh) {
this.getTableData();
bus.$emit('asset-list-change')
+ this.loadKeys();
}
},
pageNo(val) {
@@ -642,6 +651,47 @@
this.$nextTick(()=>{
bus.$emit(event,param)
})
+ },
+ loadKeys:function(){
+ this.$get('/asset/tagKey').then(res=>{
+ if(res.code == 200){
+ this.tagKeys = res.data.list.map(item=>{
+ return {label:item,prop:'tags',show:false,allowed: true,type:'tag'}
+
+ })
+ this.resetTableTitle()
+ }
+ })
+ },
+ resetTableTitle:function(){
+ let title = this.tools.customTableTitle;
+
+ let tableTitle = title.slice(0,this.tableTitle.length);
+
+ let tagTitle = title.slice(this.tableTitle.length,title.length);
+
+ let $self=this;
+ let newTags = this.tagKeys.filter(item=>{ return !tagTitle.find(t =>{return item.label == t.label})})
+ let keepTags = tagTitle.filter(item=>{ return $self.tagKeys.find(t =>{return item.label == t.label})})
+
+ let result = tableTitle.concat([{label:'Tag',show:false,NotSet:true,type:'title',prop:'table-tag'}])
+
+ result = result.concat(keepTags).concat(newTags)
+
+ this.tools.customTableTitle = JSON.parse(JSON.stringify(result))
+
+ },
+ filterTags:function(scope){
+ console.log(scope)
+ let tag=scope.column.label.split(' [Tag]')[0]
+ let tagVals=scope.row.tags
+ if(tagVals){
+ console.log('tags',tagVals,tag)
+ let showTag=tagVals.find(item=>{return item.tag == tag})
+ if(showTag){
+ return showTag.value
+ }
+ }
}
},
@@ -672,6 +722,11 @@
}
}
this.tools.customTableTitle = tableTitle;
+
+ this.loadKeys();
+
+ console.log('load end')
+
//初始化数据
this.getUserData();
this.getTableData();