fix:修复module编辑页面bug & 删除图表后前端保存指针错误的问题 & 优化自动提示输入框

This commit is contained in:
wangwenrui
2020-10-13 11:39:47 +08:00
parent 0674199733
commit cfad6dd3d7
6 changed files with 35 additions and 23 deletions

View File

@@ -325,7 +325,7 @@
this.rightBox.module.show = true; this.rightBox.module.show = true;
this.editModule = { this.editModule = {
name: '', name: '',
project: this.$store.state.currentProject, project: {},
port: 9100, port: 9100,
path: '', path: '',
param: '', param: '',

View File

@@ -166,7 +166,7 @@
currentProjectTitle: '', currentProjectTitle: '',
currentProject: {id: '', name: '', remark: ''}, //endpoint弹框、module列表用来回显project currentProject: {id: '', name: '', remark: ''}, //endpoint弹框、module列表用来回显project
module: {}, //编辑的module module: {}, //编辑的module
blankModule: {id: '', type: '', name: '', project: {}, port: '', path: '', param: '', paramObj: [], snmpParam: ''}, //空白module blankModule: {name: '', project: {}, port: 9100, path: '', param: '', type: 'http', paramObj: [], snmpParam: '', walk: [], version: 2, max_repetitions: 25, retries: 3, timeout: 10, community: 'public', username: '', security_level: 'noAuthNoPriv', password: '', auth_protocol: 'MD5', priv_protocol: 'DES', priv_password: '', context_name: ''}, //空白module
currentModule: {id: '', type: '', name: '', project: {}, port: '', path: '', param: '', paramObj: [], snmpParam: ''}, //用来回显的module currentModule: {id: '', type: '', name: '', project: {}, port: '', path: '', param: '', paramObj: [], snmpParam: ''}, //用来回显的module
ready: false, ready: false,
rightBox: {module: {show: false}}, rightBox: {module: {show: false}},
@@ -241,6 +241,7 @@
immediate: true, immediate: true,
deep: true, deep: true,
handler(n, o) { handler(n, o) {
console.log(n)
bus.$emit("current-project-change", n); //告知project.vue bus.$emit("current-project-change", n); //告知project.vue
}, },
}, },
@@ -340,7 +341,9 @@
}); });
}, },
newModule() { newModule() {
return JSON.parse(JSON.stringify(this.blankModule)); let module=JSON.parse(JSON.stringify(this.blankModule));
module.project = this.$store.state.currentProject
return module
}, },
//弹出module编辑页 //弹出module编辑页
editModule(module) { editModule(module) {

View File

@@ -3,7 +3,7 @@
<div :id="id" class="editor-core" ref="editor" :style="{height: styleType == 2 ? 'auto' : ''}"></div> <div :id="id" class="editor-core" ref="editor" :style="{height: styleType == 2 ? 'auto' : ''}"></div>
<span class="nz-input-append editor-clear" style="display: none" @click="clearContent"><i class="nz-icon nz-icon-circle-close"></i></span> <span class="nz-input-append editor-clear" style="display: none" @click="clearContent"><i class="nz-icon nz-icon-circle-close"></i></span>
<div class="metric-editor-popper" :style="{left:popperPos.left+'px'}"> <div class="metric-editor-popper" :style="{left:popperPos.left+'px'}">
<div class="metric-popper-main" v-show="showType&&Object.keys(showSuggestions).length>0"> <div class="metric-popper-main" v-show="showType">
<el-scrollbar style="height: 100%;width:100%" class="el-scrollbar-small" ref="scroll"> <el-scrollbar style="height: 100%;width:100%" class="el-scrollbar-small" ref="scroll">
<div v-for="(key, index) in orders" > <div v-for="(key, index) in orders" >
<div v-html="key" class="popper-group" v-show="showSuggestions[key]"></div> <div v-html="key" class="popper-group" v-show="showSuggestions[key]"></div>
@@ -153,7 +153,6 @@
this.packageTypeInfo(); this.packageTypeInfo();
}else if(type == 'range'){ }else if(type == 'range'){
this.noStyleSuggestions={range:suggestions.getRateRange()} this.noStyleSuggestions={range:suggestions.getRateRange()}
this.showSuggestions=this.deepClone(this.noStyleSuggestions)
} }
}, },
packageTypeInfo:function(){ packageTypeInfo:function(){
@@ -267,7 +266,6 @@
this.$set(this.noStyleSuggestions,'metrics',this.tempStoreMetric) this.$set(this.noStyleSuggestions,'metrics',this.tempStoreMetric)
// this.$set(this.noStyleSuggestions,'operators',suggestions.getOperators()) // this.$set(this.noStyleSuggestions,'operators',suggestions.getOperators())
this.$set(this.noStyleSuggestions,'functions',suggestions.getFunctions()) this.$set(this.noStyleSuggestions,'functions',suggestions.getFunctions())
this.showSuggestions=this.deepClone(this.noStyleSuggestions)
}, },
queryValues:function(){ queryValues:function(){
let labelValuesReg=/\{((\w*?(=|!=|=~|!~).*?,{0,1})+?)\}/ let labelValuesReg=/\{((\w*?(=|!=|=~|!~).*?,{0,1})+?)\}/
@@ -298,7 +296,6 @@
let values=this.labelValues.get(label); let values=this.labelValues.get(label);
this.noStyleSuggestions={values:values} this.noStyleSuggestions={values:values}
this.showSuggestions=this.deepClone(this.noStyleSuggestions)
} }
} }
}, },
@@ -362,11 +359,9 @@
}) })
this.noStyleSuggestions={labels:labels} this.noStyleSuggestions={labels:labels}
this.showSuggestions=this.deepClone(this.noStyleSuggestions);
//console.log('change labels',this.showSuggestions) //console.log('change labels',this.showSuggestions)
}else{ }else{
this.noStyleSuggestions={}; this.noStyleSuggestions={};
this.showSuggestions=this.deepClone(this.noStyleSuggestions)
} }
}) })
}, },
@@ -532,12 +527,12 @@
filterItems:function(input){ //过滤下拉选显示 filterItems:function(input){ //过滤下拉选显示
let suggestions=this.deepClone(this.noStyleSuggestions) let suggestions=this.deepClone(this.noStyleSuggestions)
let hasResolve=false;
new Promise((resolve => { new Promise((resolve => {
let counter = 0; let start = new Date().getTime();
let result={};
this.orders.forEach(key=>{ this.orders.forEach(key=>{
let typeValues=suggestions[key]; let typeValues=suggestions[key];
this.showSuggestions[key]=[]; result[key]=[];
typeValues&&typeValues.forEach(item=>{ typeValues&&typeValues.forEach(item=>{
let index=item.insertText.toLowerCase().indexOf(input.toLowerCase()); let index=item.insertText.toLowerCase().indexOf(input.toLowerCase());
//console.log('index',index,'input',input) //console.log('index',index,'input',input)
@@ -549,20 +544,17 @@
let middle=label.substring(index,index+input.length) let middle=label.substring(index,index+input.length)
let suf=label.substring(index+input.length,label.length) let suf=label.substring(index+input.length,label.length)
item.label=`${pre}<mark>${middle}</mark>${suf}` item.label=`${pre}<mark>${middle}</mark>${suf}`
this.showSuggestions[key].push(item); result[key].push(item);
if(++counter > 20){
hasResolve=true;
resolve();
}
} }
}); });
if(this.showSuggestions[key].length<1){ if(result[key].length<1){
delete this.showSuggestions[key] delete result[key]
} }
}) })
if(!hasResolve){ this.showSuggestions=result;
let end = new Date().getTime();
console.log("filter time:",(end - start),'ms')
resolve(); resolve();
}
})).then(()=>{ })).then(()=>{
if(Object.keys(this.showSuggestions).length>0){ if(Object.keys(this.showSuggestions).length>0){
this.showType=true; this.showType=true;

View File

@@ -322,11 +322,28 @@
message: this.$t("tip.deleteSuccess") message: this.$t("tip.deleteSuccess")
}); });
let chartList=this.$refs.chartList.dataList; let chartList=this.$refs.chartList.dataList;
let nextChart=null,prevChart=null
for (let i =0;i< chartList.length;i++){ for (let i =0;i< chartList.length;i++){
if(chartList[i].id === data.id){ if(chartList[i].id === data.id){
chartList.splice(i,1); chartList.splice(i,1);
break;
} }
if(data.next != -1){
if(chartList[i].id === data.next){
nextChart = chartList[i]
}
}
if(data.prev != 0){
if(chartList[i].id === data.prev){
prevChart = chartList[i]
}
}
}
if(nextChart&&prevChart){ //删除图表为中间位置
prevChart.next = nextChart.id;
nextChart.prev = prevChart.id;
}else{
if(!nextChart) prevChart.next = -1;
if(!prevChart) nextChart.prev = 0;
} }
// this.getTableData(); //删除相关图表后,刷新面板数据 // this.getTableData(); //删除相关图表后,刷新面板数据
} else { } else {