2019-12-16 17:14:58 +08:00
< template >
< div class = "new-search" >
< div class = "search-input-all input-position" @click ="stop_click" >
<!-- 历史记录 -- >
< div class = "search-history" >
< i class = "el-icon-time" @click ="look_history" > < / i >
< div : class = "localStorage_display?'localStorage_list_box none':'localStorage_list_box'" >
< div class = "list_box_title" >
2019-12-24 17:31:51 +08:00
< span > { { $t ( 'search.recentSearch' ) } } < / span >
2019-12-17 17:17:30 +08:00
< i class = "el-icon-close" @click ="localStorage_display=!localStorage_display" > < / i >
2019-12-16 17:14:58 +08:00
< / div >
< div class = "list_box_content" v-if = "history_once.length>0" >
< ul >
< li v-for = "(val,ind) in history_once" @click="select_history(ind,$event)" :key="ind" >
< span v-for = "(item,key) in val" :key="key" >
< span class = "name" > { { item . name } } : < / span >
< span class = "value" > { { item . val + ' ' } } < / span >
< / span >
< / li >
< / ul >
< / div >
< div class = "list_box_clear" >
< span v-if = "history_once.length>0" @click="clear_history" > {{ other.clearReSearch }} < / span >
2019-12-24 17:31:51 +08:00
< span v-else class = "no_historyList" > { { $t ( 'search.noRecentSearch' ) } } < / span >
2019-12-16 17:14:58 +08:00
< / div >
< / div >
< / div >
<!-- 搜索框 -- >
< div class = "input-center-box" id = "input-center-box" >
< ul class = "sreach_fixe_left" id = "search-ul" >
< li class = "selectinfo_box" v-if = "select_list.length>0" v-for="(val,ind) in select_list" :key="ind" @click="update_sreach(ind,$event)" >
< div class = "select_condition" >
{ { val . name } }
< / div >
2019-12-17 17:17:30 +08:00
< div class = "select_content" v-if = "val.val && ind!=sreach_num" >
< span :style = "val.id==7?'min-width:260px':''" > { { val . valString ? val . valString : val . val } } < / span >
2019-12-16 17:14:58 +08:00
< i class = "el-icon-close" @click ="close_selcet_list(ind,$event)" > < / i >
< / div >
< div v-else-if = "!change_sreach_show && ind==sreach_num && val.id!==7 " class="select_input" >
2020-01-10 20:09:33 +08:00
< input type = "text" autocomplete = "off" id = "sreach_input" v-model = "input_sreach" @keyup="enter(val.name, $event)" @click="stop_click" >
2019-12-16 17:14:58 +08:00
< div class = "select_info_list" v-if = "val.type == 'select'" >
< ul >
< li v-for = "(item,key) in selectInfoList[val.label]" :key="key" @click="tr_selectInfo(val.label,item.value,item.label,$event)" :class="search_select_style_num==key?'search-style-ind':''" > {{ item.label }} < / li >
< / ul >
< / div >
2019-12-17 17:17:30 +08:00
< div class = "select_info_list" v-if = "val.type == 'selectString'" >
2019-12-16 17:14:58 +08:00
< ul >
2019-12-17 17:17:30 +08:00
< li v-for = "(item,key) in selectInfoList[val.label]" :key="key" @click="stringSelectInfo(val, item, $event)" :class="search_select_style_num==key?'search-style-ind':''" > {{ item.label }} < / li >
< / ul >
< / div >
< div class = "select_info_list" v-if = "val.type == 'dc'" >
< ul >
2019-12-20 17:18:30 +08:00
< li v-for = "(item,key) in dcSelect" :key="key" @click="selectObject(val, item, $event)" :class="search_select_style_num==key?'search-style-ind':''" > {{ item.name }} < / li >
< / ul >
< / div >
< div class = "select_info_list" v-if = "val.type == 'asset'" >
< ul >
< li v-for = "(item,key) in assetSelect" :key="key" @click="selectObject(val, item, $event)" :class="search_select_style_num==key?'search-style-ind':''" > {{ item.host }} < / li >
2019-12-16 17:14:58 +08:00
< / ul >
< / div >
<!-- 新增日志模块action下拉选择 -- >
< div class = "select_info_list" v-if = "val.type == 'selectAction'" >
< ul >
< li v-for = "(item,key) in actionSelect" :key="key" @click="tr_selectInfo(val.label,item.id,item.value,$event)" > {{ item.value }} < / li >
< / ul >
< / div >
<!-- 新增protocol下拉选择 -- >
< div class = "select_info_list" v-if = "val.type == 'selectType'" >
< ul >
< li v-for = "(item,key) in schemaTypeSelect" :key="key" @click="tr_selectTypeInfo(item)" > {{ item.value }} < / li >
< / ul >
< / div >
<!-- 新增protocol二层下拉 -- >
< div class = "select_info_list" v-if = "TypeSelect.length!=0&&val.type == 'selectType'&&secondShow" >
< ul >
< li v-for = "(item,key) in TypeSelect" :key="key" @click="tr_selectProtocolInfo(item)" > {{ item.name }} < / li >
< / ul >
< / div >
<!-- 时间计划 -- >
< div class = "select_info_list" v-if = "val.type == 'select'&&val.id==5" >
< ul >
< li v-for = "item in schlist" @click="selectSul(item.name)" > {{ item.name }} < / li >
< / ul >
< / div >
< / div >
< el-date-picker
v - model = "timeFrame"
type = "datetimerange"
range - separator = "To"
start - placeholder = "Start Time"
end - placeholder = "End Time"
@ change = "changeDate"
: class = "dataBackG?'':'dataBackG'"
v - if = "ind==sreach_num&&val.id==7"
>
< / el-date-picker >
< / li >
<!-- 最开始的input框 -- >
< li class = "select_input" v-if = "change_sreach_show" >
< input type = "text" @click ="read_input" v-model = "no_condition" @keyup="enter_one" id="one-input" @keydown="clear_search_list" >
< / li >
< / ul >
< / div >
< div class = "clear-search" @click ="clear_input" >
2019-12-17 17:17:30 +08:00
< i class = "el-icon-close" > < / i >
2019-12-16 17:14:58 +08:00
< / div >
< div : class = "input_list?'input_list none':'input_list'" @click ="stop_click" id = "input_list" >
< ul >
2019-12-17 17:17:30 +08:00
< li v-for = "(val,ind) in searchLabelList" v-if="val.name!='Protocol'" @click="select_name(val.name,ind,val.id,val.type,val.label,val.disabled)" :key="ind" :class="{'search-style-ind':searchStyleNum==ind,'is-disabled':val.disabled}" >
2019-12-16 17:14:58 +08:00
< span > { { val . name } } < / span >
< / li >
2019-12-17 17:17:30 +08:00
<!-- < li v-for = "(val,ind) in searchLabelList" v-if="val.name=='Protocol'" @click="select_type(val.name,ind,val.id,val.type,val.label,val.disabled)" :key="ind" :class="{'search-style-ind':searchStyleNum==ind,'is-disabled':val.disabled}" >
2019-12-16 17:14:58 +08:00
< span > { { val . name } } < / span >
2019-12-17 17:17:30 +08:00
< / li > -- >
2019-12-16 17:14:58 +08:00
< / ul >
< / div >
< / div >
< div class = "new-search-btn" @click ="select" >
< i class = "el-icon-search" > < / i >
< / div >
< / div >
< / template >
< script >
2019-12-17 17:17:30 +08:00
import searchSelectInfo from "./searchSelectInfo" ; //搜索框组件--下拉框内容
2019-12-16 17:14:58 +08:00
export default {
name : "index" ,
data ( ) {
return {
select _conditionsName : '' ,
2019-12-17 17:17:30 +08:00
selectInfoList : searchSelectInfo ,
2019-12-20 17:18:30 +08:00
select _title : '' ,
other : '' ,
2019-12-16 17:14:58 +08:00
localStorage _display : true ,
input _list : true ,
change _sreach _show : true ,
2020-01-13 16:17:05 +08:00
select _list : [ ] , //当前的搜索条件和值
2019-12-17 17:17:30 +08:00
historyList : [ ] ,
2019-12-16 17:14:58 +08:00
actionSelect : [ ] ,
2019-12-17 17:17:30 +08:00
dcSelect : [ ] , //数据中心
2019-12-20 17:18:30 +08:00
assetSelect : [ ] , //资产
2019-12-16 17:14:58 +08:00
schemaTypeSelect : [ ] , //日志检索Protocol下拉菜单
TypeSelect : [ ] , //Protocol二层下拉菜单
secondShow : '' , //二层显示控制
input _sreach : '' ,
sreach _num : 0 ,
2020-01-13 16:17:05 +08:00
searchLabelList : [ //下拉列表里的选项
2019-12-17 17:17:30 +08:00
{ id : 0 , name : this . $t ( 'search.searchTip' ) , icon : 'el-icon-search' } ,
2019-12-16 17:14:58 +08:00
] ,
bool : false ,
no _condition : '' ,
//历史记录列表
history _once : [ ] ,
2019-12-27 17:53:17 +08:00
name : "" ,
id : "" ,
2019-12-16 17:14:58 +08:00
schedata : {
name : '' ,
isValid : 1 ,
pageSize : 30 ,
pageNo : 1
} ,
schlist : [ ] ,
timeFrame : [ new Date ( new Date ( ) - 1 * 60 * 60 * 1000 ) , new Date ( ) ] ,
dataBackG : true ,
delBool : false ,
2019-12-17 17:17:30 +08:00
searchStyleNum : - 1 ,
isSearchNum : - 1 ,
2019-12-16 17:14:58 +08:00
search _select _style _num : - 1 ,
keyBool : false ,
delnum : 0 ,
delcriteriaBool : false ,
selectInfo : false ,
disabaled : true ,
downBool : false
}
} ,
2020-01-10 20:09:33 +08:00
computed : {
alertListAssetId ( ) {
return this . $store . state . assetForAlertList ;
}
} ,
2019-12-16 17:14:58 +08:00
watch : {
2020-01-10 20:09:33 +08:00
select _list : {
//监听下拉列表
handler ( newData , oldData ) {
if ( newData . length == 0 ) {
this . change _sreach _show = true ;
}
2020-01-13 16:17:05 +08:00
if ( this . $route . path == "/alertList" ) {
// 处理alertType--asset联动问题:
// 当已选alertType为asset时, 将可选列表中的asset的disabled恢复为false;
// 当已选alertType不为asset时, 将可选列表中的asset的disabled设为true, 若有已选的asset, 则删除;
let hasType = false ;
for ( let i = 0 ; i < newData . length ; i ++ ) {
if ( newData [ i ] . label == "alertType" && newData [ i ] . valnum ) { //若存在alertType, 判断可选列表中是否有asset, 有的话disabled置为false
hasType = true ;
if ( newData [ i ] . valnum == 3 ) {
for ( let j = 0 ; j < this . searchLabelList . length ; j ++ ) {
if ( this . searchLabelList [ j ] . label == 'asset' ) {
this . searchLabelList [ j ] . disabled = false ;
break ;
}
}
break ;
} else {
for ( let j = 0 ; j < newData . length ; j ++ ) {
if ( newData [ j ] . label == "asset" ) {
this . close _selcet _list ( j ) ;
break ;
}
}
for ( let j = 0 ; j < this . searchLabelList . length ; j ++ ) {
if ( this . searchLabelList [ j ] . label == 'asset' ) {
this . searchLabelList [ j ] . disabled = true ;
break ;
}
}
break ;
}
}
}
if ( ! hasType ) {
for ( let j = 0 ; j < this . searchLabelList . length ; j ++ ) {
if ( this . searchLabelList [ j ] . label == 'asset' ) {
this . searchLabelList [ j ] . disabled = true ;
break ;
}
}
}
}
2020-01-10 20:09:33 +08:00
}
} ,
no _condition : {
handler ( newData , oldData ) {
if ( newData != '' ) {
this . input _list = true
}
}
} ,
alertListAssetId : {
immediate : true ,
handler ( newData , oldData ) {
if ( newData && this . $route . path == '/alertList' ) {
setTimeout ( ( ) => {
//
//1.条件名alertType
//
2020-01-13 16:17:05 +08:00
this . searchLabelList . splice ( 2 , 1 ) ;
2020-01-10 20:09:33 +08:00
this . select _list . push ( {
name : this . $t ( 'alert.list.type' ) ,
id : 3 ,
type : 'select' ,
label : 'alertType' ,
disabled : false
} ) ;
//
//2.条件值asset
//
this . select _list . forEach ( val => {
if ( val . label == 'alertType' ) {
val . val = this . $t ( 'alert.config.typeOption.asset' ) ;
val . valnum = 3 ;
//alertList页type选择asset时, 可以搜索asset
if ( this . $route . path == '/alertList' && val . label == 'alertType' && val . valnum == 3 ) {
for ( let i = 0 ; i < this . searchLabelList . length ; i ++ ) {
if ( this . searchLabelList [ i ] . label == 'asset' ) {
this . searchLabelList [ i ] . disabled = false ;
break ;
}
}
} else if ( this . $route . path == '/alertList' && val . label == 'alertType' && val . valnum != 3 ) {
let ind = - 1 ;
for ( let i = 0 ; i < this . searchLabelList . length ; i ++ ) {
if ( this . searchLabelList [ i ] . label == 'asset' ) {
this . searchLabelList [ i ] . disabled = true ;
break ;
}
}
for ( let i = 0 ; i < this . select _list . length ; i ++ ) {
if ( this . select _list [ i ] . label == 'asset' ) {
ind = i ;
break ;
}
}
if ( ind >= 0 ) {
this . close _selcet _list ( ind ) ;
}
}
2019-12-16 17:14:58 +08:00
}
2020-01-10 20:09:33 +08:00
} ) ;
//
//3.条件名asset
//
2020-01-13 16:17:05 +08:00
//this.input_list = false;
this . searchLabelList . splice ( 3 , 1 ) ;
2020-01-10 20:09:33 +08:00
this . select _list . push ( {
name : this . $t ( 'asset.asset' ) ,
id : 11 ,
type : 'asset' ,
label : 'asset' ,
disabled : false
} ) ;
2020-01-13 16:17:05 +08:00
2020-01-10 20:09:33 +08:00
//
//4.条件值: 指定的asset
2020-01-13 16:17:05 +08:00
setTimeout ( ( ) => {
let assetHost = '' ;
for ( let i = 0 ; i < this . assetSelect . length ; i ++ ) {
if ( this . assetSelect [ i ] . id == newData ) {
assetHost = this . assetSelect [ i ] . host ;
}
2020-01-10 20:09:33 +08:00
}
2020-01-13 16:17:05 +08:00
this . select _list . forEach ( val => {
if ( val . label == 'asset' ) {
val . val = assetHost ;
val . valnum = newData ;
}
} ) ;
this . input _sreach = '' ;
this . sreach _num = this . select _list . length ;
this . change _sreach _show = false ;
this . input _list = true ;
//
//5.点击搜索
//
this . select ( ) ;
} , 50 ) ;
2020-01-10 20:09:33 +08:00
} , 100 ) ;
this . $store . commit ( 'assetForAlertListChange' , '' ) ;
}
2019-12-16 17:14:58 +08:00
}
2020-01-10 20:09:33 +08:00
}
2019-12-16 17:14:58 +08:00
} ,
2019-12-17 17:17:30 +08:00
props : [ 'searchMsg' , 'defaultItem' , 'defaultValue' ] ,
2019-12-16 17:14:58 +08:00
methods : {
// isValidIP(ip) {
// var reg = /^(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])$/
// if(reg.test(ip)){
// }else{
// alert('ip格式不正确')
// }
// } ,
//点击选择protocol类型 (日志新增)
2019-12-17 17:17:30 +08:00
/ * s e l e c t _ t y p e ( v a l , i n d , i d , t y p e , l a b e l , d i s a b l e d ) {
2019-12-16 17:14:58 +08:00
this . downBool = false ;
this . secondShow = false ;
2019-12-17 17:17:30 +08:00
this . searchLabelList . splice ( ind , 1 )
2019-12-16 17:14:58 +08:00
this . select _list . push ( {
name : val ,
id : id ,
type : type ,
label : label ,
disabled : disabled
} )
this . change _sreach _show = false
this . sreach _num = this . select _list . length - 1
this . input _list = ! this . input _list
2019-12-17 17:17:30 +08:00
} , * /
//dc
2019-12-27 17:53:17 +08:00
clearSearch ( ) {
this . select _list = [ ] ;
} ,
2019-12-20 17:18:30 +08:00
selectObject ( column , selectItem , e ) {
2019-12-17 17:17:30 +08:00
this . stop _click ( e ) ;
2019-12-18 17:00:44 +08:00
this . select _list . forEach ( val => {
2019-12-20 17:18:30 +08:00
if ( val . type == 'dc' ) {
2019-12-17 17:17:30 +08:00
val . val = selectItem . name ;
val . valnum = selectItem . id ;
val . valString = '' ;
2019-12-20 17:18:30 +08:00
} else if ( val . type == 'asset' ) {
val . val = selectItem . host ;
val . valnum = selectItem . id ;
val . valString = '' ;
2019-12-17 17:17:30 +08:00
}
2019-12-20 17:18:30 +08:00
} ) ;
2019-12-17 17:17:30 +08:00
//this.select_list.push({type: 'dc', val: selectItem.name, valnum: selectItem.id});
this . input _sreach = '' ;
this . sreach _num = this . select _list . length ;
this . change _sreach _show = true ;
this . input _list = false ;
var _this = this ;
setTimeout ( "document.getElementById(\"one-input\").focus()" , 500 ) ;
setTimeout ( function ( ) {
_this . getHeight ( ) ;
} ) ;
} ,
2019-12-16 17:14:58 +08:00
//一层下拉点击
2019-12-17 17:17:30 +08:00
tr _selectTypeInfo ( val ) {
2019-12-16 17:14:58 +08:00
this . TypeSelect = [ ] ;
2019-12-17 17:17:30 +08:00
val . data . length != 0 ? this . TypeSelect . push ( val . data [ 0 ] ) : '' ;
2019-12-16 17:14:58 +08:00
val . data . length != 0 ? this . secondShow = true : ''
} ,
//二层下拉点击
tr _selectProtocolInfo ( val ) {
this . select _list = [ ] ;
this . select _list . push ( {
name : val . name ,
// id:id,
type : val . type ,
label : val . label ,
// disabled:disabled
} )
this . change _sreach _show = false
this . sreach _num = this . select _list . length - 1
this . input _list = ! this . input _list
// setTimeout("document.getElementById(\"sreach_input\").focus()", 500);
var _this = this
setTimeout ( function ( ) {
_this . getHeight ( )
} , )
} ,
2019-12-17 17:17:30 +08:00
Iskeywords ( ind ) {
if ( this . select _list [ ind ] . id == 29 ) {
this . searchLabelList . forEach ( val => {
if ( val . id == 30 || val . id == 31 || val . id == 32 || val . id == 33 ) {
val . disabled = false
}
} )
} else if ( this . select _list [ ind ] . id == 30 || this . select _list [ ind ] . id == 31 || this . select _list [ ind ] . id == 32 || this . select _list [ ind ] . id == 33 ) {
this . searchLabelList . forEach ( val => {
if ( val . id == 29 ) {
val . disabled = false
}
} )
}
} ,
getDcData ( ) {
this . $get ( 'idc' , { pageNo : 1 , pageSize : 999 } ) . then ( response => {
if ( response . code === 200 ) {
this . dcSelect = response . data . list ;
2019-12-16 17:14:58 +08:00
}
2019-12-17 17:17:30 +08:00
} ) ;
} ,
2019-12-20 17:18:30 +08:00
getAssetData ( ) {
this . $get ( 'asset' , { pageNo : 1 , pageSize : 999 } ) . then ( response => {
if ( response . code === 200 ) {
this . assetSelect = response . data . list ;
}
} ) ;
} ,
2020-01-08 22:19:46 +08:00
getModelData ( ) {
this . $get ( 'asset' , { pageNo : 1 , pageSize : 999 } ) . then ( response => {
if ( response . code === 200 ) {
this . assetSelect = response . data . list ;
}
} ) ;
} ,
2019-12-16 17:14:58 +08:00
//点击确认选择下拉内容
tr _selectInfo ( selectLabel , value , label , e ) {
2019-12-17 17:17:30 +08:00
this . stop _click ( e ) ;
2019-12-16 17:14:58 +08:00
this . select _list . forEach ( val => {
if ( val . label == selectLabel ) {
2019-12-17 17:17:30 +08:00
val . val = label ;
val . valnum = value ;
2019-12-16 17:14:58 +08:00
}
2019-12-17 17:17:30 +08:00
} ) ;
2020-01-13 16:17:05 +08:00
for ( let i = 0 ; i < this . select _list . length ; i ++ ) {
if ( this . select _list [ i ] . label == selectLabel ) {
this . select _list . splice ( i , 1 , Object . assign ( { } , this . select _list [ i ] , { val : label , valnum : value } ) ) ;
/ * t h i s . s e l e c t _ l i s t [ i ] . v a l = l a b e l ;
this . select _list [ i ] . valnum = value ; * /
}
}
2019-12-17 17:17:30 +08:00
this . input _sreach = '' ;
this . sreach _num = this . select _list . length ;
this . change _sreach _show = true ;
this . input _list = false ;
2020-01-10 20:09:33 +08:00
var _this = this ;
2019-12-16 17:14:58 +08:00
setTimeout ( "document.getElementById(\"one-input\").focus()" , 500 ) ;
2019-12-17 17:17:30 +08:00
setTimeout ( function ( ) {
_this . getHeight ( ) ;
} ) ;
} ,
//点击确认value是string类型的下拉内容, param: 字段对象,选中的选项
stringSelectInfo ( column , selectItem , e ) {
this . stop _click ( e ) ;
this . select _list . forEach ( val => {
if ( val . label == column . label ) {
val . val = selectItem . value ;
val . valString = selectItem . label ;
}
} ) ;
this . input _sreach = '' ;
this . sreach _num = this . select _list . length ;
this . change _sreach _show = true ;
this . input _list = false ;
var _this = this ;
setTimeout ( "document.getElementById(\"one-input\").focus()" , 500 ) ;
2019-12-16 17:14:58 +08:00
setTimeout ( function ( ) {
2019-12-17 17:17:30 +08:00
_this . getHeight ( ) ;
} ) ;
2019-12-16 17:14:58 +08:00
} ,
// 点击历史记录图标
look _history ( e ) {
2019-12-17 17:17:30 +08:00
this . stop _click ( e ) ;
this . localStorage _display = ! this . localStorage _display ;
2019-12-16 17:14:58 +08:00
} ,
backtime ( t ) {
2019-12-17 17:17:30 +08:00
let myDate = new Date ( t ) ;
2019-12-16 17:14:58 +08:00
let nt = myDate . getFullYear ( ) + '-' + ( myDate . getMonth ( ) > 8 ? '' : 0 )
+ ( myDate . getMonth ( ) + 1 ) + '-' + ( myDate . getDate ( ) > 9 ? '' : 0 )
+ myDate . getDate ( ) + ' '
+ ( myDate . getHours ( ) > 9 ? '' : '0' ) + myDate . getHours ( ) + ':'
+ ( myDate . getMinutes ( ) > 9 ? '' : 0 ) + myDate . getMinutes ( ) + ':'
2019-12-17 17:17:30 +08:00
+ ( myDate . getSeconds ( ) > 9 ? '' : 0 ) + myDate . getSeconds ( ) ;
return nt ;
2019-12-16 17:14:58 +08:00
} ,
changeDate ( ) {
this . dataBackG = false
this . change _sreach _show = true
if ( this . timeFrame != [ ] ) {
this . select _list [ this . sreach _num ] . val = this . backtime ( this . timeFrame [ 0 ] ) + ' - ' + this . backtime ( this . timeFrame [ 1 ] )
this . input _sreach = ''
this . sreach _num ++
}
} ,
//选择时间计划
selectSul ( name ) {
2019-12-17 17:17:30 +08:00
this . change _sreach _show = true ;
this . select _list [ this . sreach _num ] . val = name ;
this . input _sreach = '' ;
this . sreach _num ++ ;
this . getHeight ( ) ;
2019-12-16 17:14:58 +08:00
} ,
//点击搜索
select ( ) {
2019-12-17 17:17:30 +08:00
let objectInfo = { } ;
this . change _sreach _show = true ;
2019-12-27 17:53:17 +08:00
this . name = '' , this . id = '' ;
2019-12-16 17:14:58 +08:00
if ( this . input _sreach != '' ) {
2019-12-17 17:17:30 +08:00
this . select _list [ this . sreach _num ] . val = this . input _sreach ;
this . input _sreach = '' ;
this . sreach _num = this . select _list . length ;
2019-12-16 17:14:58 +08:00
}
//input有值 默认添加到name中
if ( this . no _condition != '' ) {
let no _condition _bool = false , no _condition _str = '' , route = this . $route . path
if ( this . select _list . length == 0 ) {
//日志模块新增路由判断
if ( route == '/Log_SecurityEventLogs' || route == '/Log_ProxyEventLogs' || route == '/Log_SesssionRecords' || route == '/Log_RadiusLogs' ) {
2019-12-17 17:17:30 +08:00
no _condition _str = 'logId' ;
2019-12-16 17:14:58 +08:00
} else if ( route == '/Device_DeviceList' ) {
2019-12-17 17:17:30 +08:00
no _condition _str = 'sn' ;
2019-12-16 17:14:58 +08:00
} else if ( route == '/system_PolicyConfigurationLog' || route == '/system_LoginLog' ) {
2019-12-17 17:17:30 +08:00
no _condition _str = 'modifyBy' ;
2019-12-16 17:14:58 +08:00
} else {
2019-12-27 17:53:17 +08:00
no _condition _str = 'name' ;
2019-12-16 17:14:58 +08:00
}
2019-12-27 17:53:17 +08:00
if ( no _condition _str == 'name' ) {
this . select _list . push ( { name : this . select _title . name , id : 2 , type : 'input' , val : this . no _condition , label : 'name' } ) ;
2019-12-17 17:17:30 +08:00
this . searchLabelList . forEach ( ( val , ind ) => {
2019-12-16 17:14:58 +08:00
if ( val . id == 2 ) {
2019-12-17 17:17:30 +08:00
this . searchLabelList . splice ( ind , 1 ) ;
2019-12-16 17:14:58 +08:00
}
} )
} else if ( no _condition _str == 'modifyBy' ) {
2019-12-17 17:17:30 +08:00
this . select _list . push ( { name : this . select _title . Operator , id : 6 , type : 'input' , val : this . no _condition , label : 'modifyBy' } ) ;
this . searchLabelList . forEach ( ( val , ind ) => {
2019-12-16 17:14:58 +08:00
if ( val . id == 6 ) {
2019-12-17 17:17:30 +08:00
this . searchLabelList . splice ( ind , 1 ) ;
2019-12-16 17:14:58 +08:00
}
} )
} else if ( no _condition _str == 'sn' ) {
2019-12-17 17:17:30 +08:00
this . select _list . push ( { name : this . select _title . SN , id : 8 , type : 'input' , val : this . no _condition , label : 'sn' } ) ;
this . searchLabelList . forEach ( ( val , ind ) => {
2019-12-16 17:14:58 +08:00
if ( val . id == 8 ) {
2019-12-17 17:17:30 +08:00
this . searchLabelList . splice ( ind , 1 ) ;
2019-12-16 17:14:58 +08:00
}
} )
2019-12-27 17:53:17 +08:00
} else if ( no _condition _str == 'id' ) {
this . select _list . push ( { name : this . select _title . Policy _ID , id : 1 , type : 'input' , val : this . no _condition , label : 'id' } ) ;
2019-12-17 17:17:30 +08:00
this . searchLabelList . forEach ( ( val , ind ) => {
2019-12-16 17:14:58 +08:00
if ( val . id == 1 ) {
2019-12-17 17:17:30 +08:00
this . searchLabelList . splice ( ind , 1 ) ;
2019-12-16 17:14:58 +08:00
}
} )
} else if ( no _condition _str == 'logId' ) { //日志模块新增判断
2019-12-17 17:17:30 +08:00
this . select _list . push ( { name : 'Log ID' , type : 'input' , label : 'Log Id' , val : this . no _condition , } ) ;
this . searchLabelList . forEach ( ( val , ind ) => {
2019-12-16 17:14:58 +08:00
if ( val . id == 1 ) {
2019-12-17 17:17:30 +08:00
this . searchLabelList . splice ( ind , 1 ) ;
2019-12-16 17:14:58 +08:00
}
} )
}
2019-12-17 17:17:30 +08:00
this . sreach _num ++ ;
2019-12-16 17:14:58 +08:00
} else {
2019-12-17 17:17:30 +08:00
let no _condition _bool = false , no _condition _str = '' , route = this . $route . path , bool = true ;
2019-12-16 17:14:58 +08:00
if ( route == '/Log_SesssionRecords' || route == '/Log_EventLogs' ) {
2019-12-27 17:53:17 +08:00
no _condition _str = 'id' ;
2019-12-16 17:14:58 +08:00
} else if ( route == '/Device_DeviceList' ) {
2019-12-17 17:17:30 +08:00
no _condition _str = 'sn' ;
2019-12-16 17:14:58 +08:00
} else if ( route == '/system_PolicyConfigurationLog' || route == '/system_UserManagement' || route == '/system_LoginLog' ) {
2019-12-17 17:17:30 +08:00
no _condition _str = 'modifyBy' ;
2019-12-16 17:14:58 +08:00
} else {
2019-12-27 17:53:17 +08:00
no _condition _str = 'name' ;
2019-12-16 17:14:58 +08:00
}
this . select _list . forEach ( val => {
if ( val . label == no _condition _str ) {
2019-12-17 17:17:30 +08:00
bool = false ;
val . val += ',' + this . no _condition ;
2019-12-16 17:14:58 +08:00
}
2019-12-17 17:17:30 +08:00
} ) ;
2019-12-16 17:14:58 +08:00
if ( bool ) {
2019-12-17 17:17:30 +08:00
this . searchLabelList . forEach ( ( val , ind ) => {
2019-12-16 17:14:58 +08:00
if ( val . label == no _condition _str ) {
2019-12-17 17:17:30 +08:00
val . val = this . no _condition ;
this . select _list . push ( val ) ;
this . searchLabelList . splice ( ind , 1 ) ;
2019-12-16 17:14:58 +08:00
}
2019-12-17 17:17:30 +08:00
} ) ;
this . sreach _num ++ ;
2019-12-16 17:14:58 +08:00
}
}
2019-12-17 17:17:30 +08:00
this . no _condition = '' ;
2019-12-16 17:14:58 +08:00
}
2019-12-17 17:17:30 +08:00
let labelBool = true ;
2019-12-16 17:14:58 +08:00
this . select _list . forEach ( val => {
2019-12-17 17:17:30 +08:00
if ( typeof ( val . val ) !== 'undefined' && val . val ) {
2019-12-16 17:14:58 +08:00
if ( val . type == 'select' ) {
2019-12-17 17:17:30 +08:00
if ( val . label == 'alertType' || val . label == 'promType' ) {
objectInfo . type = val . valnum ;
2020-01-09 14:57:44 +08:00
} else if ( val . label == 'assetState' ) {
objectInfo . state = val . valnum ;
2019-12-17 17:17:30 +08:00
} else if ( typeof ( val . valnum ) == "undefined" || val . valnum == '' ) {
2019-12-16 17:14:58 +08:00
this . selectInfoList [ val . label ] . forEach ( item => {
if ( item . label == val . val ) {
2019-12-17 17:17:30 +08:00
labelBool = false ;
objectInfo [ val . label ] = item . value ;
2019-12-16 17:14:58 +08:00
}
} )
if ( labelBool ) {
2019-12-17 17:17:30 +08:00
objectInfo [ val . label ] = val . val ;
2019-12-16 17:14:58 +08:00
}
} else {
2019-12-17 17:17:30 +08:00
objectInfo [ val . label ] = val . valnum ;
2019-12-16 17:14:58 +08:00
}
2019-12-17 17:17:30 +08:00
} else if ( val . type == 'selectSelf' ) {
objectInfo [ val . label ] = val . valnum ;
2019-12-16 17:14:58 +08:00
} else if ( val . type == 'selectAction' ) { //新增日志判断
2019-12-17 17:17:30 +08:00
objectInfo [ val . label ] = val . valnum ;
} else if ( val . type == 'dc' ) {
objectInfo . idcId = val . valnum ;
2020-01-10 20:09:33 +08:00
} else if ( val . type == 'asset' && this . $route . path == "/project" ) {
2019-12-20 17:18:30 +08:00
objectInfo . assetId = val . valnum ;
2020-01-10 20:09:33 +08:00
} else if ( val . type == 'asset' && this . $route . path == "/alertList" ) {
objectInfo . linkId = val . valnum ;
2019-12-17 17:17:30 +08:00
} else {
objectInfo [ val . label ] = val . val ;
2019-12-16 17:14:58 +08:00
}
}
2019-12-17 17:17:30 +08:00
} ) ;
2019-12-16 17:14:58 +08:00
this . getHeight ( )
//搜索完成后存储在本地历史记录中
if ( this . select _list . length != 0 ) {
2020-01-08 22:19:46 +08:00
if ( JSON . parse ( localStorage . getItem ( 'nz-history-' + this . $route . path ) ) == undefined || JSON . parse ( localStorage . getItem ( 'nz-history-' + this . $route . path ) ) == [ ] ) {
2019-12-17 17:17:30 +08:00
this . historyList . unshift ( this . select _list ) ;
2020-01-08 22:19:46 +08:00
localStorage . setItem ( 'nz-history-' + this . $route . path , JSON . stringify ( this . historyList ) ) ;
2019-12-16 17:14:58 +08:00
} else {
2020-01-08 22:19:46 +08:00
this . historyList = JSON . parse ( localStorage . getItem ( 'nz-history-' + this . $route . path ) ) ;
2019-12-17 17:17:30 +08:00
this . historyList . unshift ( this . select _list ) ;
if ( this . historyList . length > 10 ) {
this . historyList . length = 10 ;
2019-12-16 17:14:58 +08:00
}
2020-01-08 22:19:46 +08:00
localStorage . setItem ( 'nz-history-' + this . $route . path , JSON . stringify ( this . historyList ) ) ;
2019-12-16 17:14:58 +08:00
}
}
2019-12-17 17:17:30 +08:00
this . input _list = true ;
this . restructure _historyDate ( ) ;
this . $emit ( "search" , objectInfo ) ;
2019-12-16 17:14:58 +08:00
} ,
//清空历史记录
clear _history ( ) {
2019-12-17 17:17:30 +08:00
this . historyList = [ ] ;
this . history _once = [ ] ;
2020-01-08 22:19:46 +08:00
localStorage . setItem ( 'nz-history-' + this . $route . path , JSON . stringify ( this . historyList ) ) ;
2019-12-16 17:14:58 +08:00
} ,
//再次点击之前的历史记录
select _history ( ind , e ) {
2019-12-17 17:17:30 +08:00
this . stop _click ( e ) ;
this . input _list = true ;
this . change _sreach _show = true ;
this . localStorage _display = ! this . localStorage _display ;
this . select _list = [ ] ;
2020-01-08 22:19:46 +08:00
JSON . parse ( localStorage . getItem ( 'nz-history-' + this . $route . path ) ) . splice ( ind , 1 ) ;
2019-12-17 17:17:30 +08:00
this . select _list = JSON . parse ( JSON . stringify ( this . history _once [ ind ] ) ) ;
this . sreach _num = this . select _list . length ;
2019-12-16 17:14:58 +08:00
this . select _list . forEach ( val => {
2019-12-17 17:17:30 +08:00
this . searchLabelList . forEach ( ( item , index ) => {
2019-12-16 17:14:58 +08:00
if ( val . id == item . id ) {
2019-12-17 17:17:30 +08:00
this . searchLabelList . splice ( index , 1 ) ;
2019-12-16 17:14:58 +08:00
}
} )
2019-12-17 17:17:30 +08:00
} ) ;
2019-12-16 17:14:58 +08:00
this . select ( )
} ,
// 获取历史记录 数据进行处理以便循环展示
restructure _historyDate ( ) {
2020-01-08 22:19:46 +08:00
if ( localStorage . getItem ( 'nz-history-' + this . $route . path ) !== undefined && localStorage . getItem ( 'nz-history-' + this . $route . path ) !== null ) {
this . history _once = JSON . parse ( localStorage . getItem ( 'nz-history-' + this . $route . path ) ) ;
2019-12-16 17:14:58 +08:00
}
} ,
clear _search _list ( e ) {
var keyCode = window . event ? e . keyCode : e . which ;
} ,
//监听输入框鼠标抬起事件
enter _one ( e ) {
var keyCode = window . event ? e . keyCode : e . which ;
if ( keyCode == 40 ) {
2019-12-17 17:17:30 +08:00
if ( this . searchStyleNum < this .searchLabelList.length -1 ) {
var disabledNum = 0 ;
this . searchLabelList . forEach ( val => {
2019-12-16 17:14:58 +08:00
if ( val . disabled ) {
2019-12-17 17:17:30 +08:00
disabledNum ++ ;
2019-12-16 17:14:58 +08:00
}
2019-12-17 17:17:30 +08:00
} ) ;
this . isSearchNum = this . searchStyleNum ;
this . isSearchNum ++ ;
if ( ! ( this . searchLabelList [ this . isSearchNum ] . disabled ) ) {
this . searchStyleNum ++ ;
2019-12-16 17:14:58 +08:00
} else {
2019-12-17 17:17:30 +08:00
this . searchStyleNum += disabledNum + 1 ;
2019-12-16 17:14:58 +08:00
}
}
2019-12-17 17:17:30 +08:00
if ( this . searchStyleNum >= 7 ) {
document . getElementById ( 'input_list' ) . scrollTop += 28 ;
2019-12-16 17:14:58 +08:00
}
}
if ( keyCode == 38 ) {
2019-12-17 17:17:30 +08:00
if ( this . searchStyleNum >= 0 ) {
var disabledNum = 0 ;
this . searchLabelList . forEach ( val => {
2019-12-16 17:14:58 +08:00
if ( val . disabled ) {
2019-12-17 17:17:30 +08:00
disabledNum ++ ;
2019-12-16 17:14:58 +08:00
}
} )
2019-12-17 17:17:30 +08:00
this . isSearchNum = this . searchStyleNum ;
if ( this . isSearchNum > 0 ) {
this . isSearchNum --
2019-12-16 17:14:58 +08:00
}
2019-12-17 17:17:30 +08:00
if ( ! ( this . searchLabelList [ this . isSearchNum ] . disabled ) ) {
this . searchStyleNum --
2019-12-16 17:14:58 +08:00
} else {
2019-12-17 17:17:30 +08:00
this . searchStyleNum -= disabledNum + 1
2019-12-16 17:14:58 +08:00
}
}
2019-12-17 17:17:30 +08:00
if ( this . searchStyleNum <= this . searchLabelList . length - 8 ) {
2019-12-16 17:14:58 +08:00
document . getElementById ( 'input_list' ) . scrollTop -= 28
}
}
if ( this . no _condition == '' ) {
if ( ! this . keyBool ) {
if ( keyCode == 8 ) {
let arr = this . select _list
if ( ! this . delBool ) {
if ( this . input _sreach == '' ) {
for ( var i = arr . length - 1 ; i >= 0 ; i -- ) {
this . input _list = true
this . change _sreach _show = false
this . sreach _num = i
this . input _sreach = arr [ i ] . val
setTimeout ( "document.getElementById(\"sreach_input\").focus()" , 500 ) ;
this . delBool = true
break ;
}
}
}
}
}
}
if ( keyCode == 13 ) {
2019-12-17 17:17:30 +08:00
if ( this . searchStyleNum <= 0 ) {
2019-12-16 17:14:58 +08:00
this . select ( )
} else {
2019-12-17 17:17:30 +08:00
let val = this . searchLabelList [ this . searchStyleNum ] . name ,
ind = this . searchStyleNum ,
id = this . searchLabelList [ this . searchStyleNum ] . id ,
type = this . searchLabelList [ this . searchStyleNum ] . type ,
label = this . searchLabelList [ this . searchStyleNum ] . label ,
disabled = this . searchLabelList [ this . searchStyleNum ] . disabled
this . searchStyleNum = - 1
2019-12-16 17:14:58 +08:00
this . select _name ( val , ind , id , type , label , disabled )
}
}
} ,
// input框监听是按删除还是回车
2019-12-23 17:39:15 +08:00
enter ( val , e ) {
2019-12-16 17:14:58 +08:00
var keyCode = window . event ? e . keyCode : e . which ;
2019-12-23 17:39:15 +08:00
if ( val == 'ID' && keyCode == 13 ) {
let id = /^[0-9]*$/
if ( ! id . test ( this . input _sreach ) || this . input _sreach > 2147483647 ) {
//如果有不正确的值 进行删除
this . input _sreach = ''
this . $message . error ( this . other . delErrorId )
return false ;
}
}
2019-12-16 17:14:58 +08:00
if ( keyCode !== 8 ) {
this . delBool = false
this . delcriteriaBool = false
}
if ( this . delBool ) {
if ( keyCode == 8 ) {
if ( this . input _sreach == '' ) {
2019-12-17 17:17:30 +08:00
this . searchMsg . searchLabelList . forEach ( ( val , k ) => {
2019-12-16 17:14:58 +08:00
if ( this . select _list [ this . sreach _num ] . id == val . id ) {
2019-12-17 17:17:30 +08:00
this . searchLabelList . splice ( k + 1 , 0 , val )
2019-12-16 17:14:58 +08:00
this . Iskeywords ( this . sreach _num )
}
} )
this . select _list . splice ( this . sreach _num , 1 )
this . change _sreach _show = true
setTimeout ( "document.getElementById(\"one-input\").focus()" , 500 ) ;
this . input _list = false
this . delBool = false
}
}
} else {
if ( keyCode == 8 ) {
if ( this . delcriteriaBool ) {
2019-12-17 17:17:30 +08:00
this . searchMsg . searchLabelList . forEach ( ( val , k ) => {
2019-12-16 17:14:58 +08:00
if ( this . select _list [ this . sreach _num ] . id == val . id ) {
2019-12-17 17:17:30 +08:00
this . searchLabelList . splice ( k + 1 , 0 , val )
2019-12-16 17:14:58 +08:00
this . Iskeywords ( this . sreach _num )
}
} )
this . select _list . splice ( this . sreach _num , 1 )
this . change _sreach _show = true
setTimeout ( "document.getElementById(\"one-input\").focus()" , 500 ) ;
this . input _list = false
this . delcriteriaBool = false
} else {
if ( this . input _sreach == '' ) {
this . delcriteriaBool = true
}
}
}
}
if ( keyCode == 38 || keyCode == 40 ) {
if ( this . select _list [ this . sreach _num ] . type !== 'select' ) {
if ( this . input _sreach !== '' ) {
this . zhezhao _click ( )
setTimeout ( "document.getElementById(\"one-input\").focus()" , 500 ) ;
this . input _list = false
}
} else {
if ( keyCode == 40 ) {
this . selectInfo = true
if ( this . search _select _style _num < this .selectInfoList [ this.select_list [ this.sreach_num ] .label ] .length -1 ) {
this . search _select _style _num ++
}
}
if ( keyCode == 38 ) {
this . selectInfo = true
if ( this . search _select _style _num >= 0 ) {
this . search _select _style _num --
}
}
}
} else if ( keyCode == 13 ) {
2019-12-17 17:17:30 +08:00
this . searchMsg . zheze _none = true
2019-12-16 17:14:58 +08:00
//回车键
if ( ! this . selectInfo ) {
this . select ( )
} else {
this . selectInfo = false
this . tr _selectInfo ( this . select _list [ this . sreach _num ] . label , this . selectInfoList [ this . select _list [ this . sreach _num ] . label ] [ this . search _select _style _num ] . label , this . selectInfoList [ this . select _list [ this . sreach _num ] . label ] [ this . search _select _style _num ] . value , e )
}
}
} ,
// 清空已输入的搜索条件
clear _input ( e ) {
this . stop _click ( e )
this . no _condition = ''
this . input _sreach = ''
this . select _list = [ ]
2019-12-17 17:17:30 +08:00
this . searchLabelList = [ { id : 0 , name : 'Press Enter or click to search' , icon : 'el-icon-search' } , ]
JSON . parse ( JSON . stringify ( this . searchMsg . searchLabelList ) ) . forEach ( val => {
this . searchLabelList . push ( val )
2019-12-16 17:14:58 +08:00
} )
} ,
//修改已有参数
update _sreach ( ind , e ) {
2019-12-17 17:17:30 +08:00
//if(this.select_list[ind].id==6||this.select_list[ind].id==28){
if ( false ) {
2019-12-16 17:14:58 +08:00
this . sreach _num = ind
this . downBool = false
this . change _sreach _show = false
this . input _list = true
} else {
this . input _list = true
this . change _sreach _show = false
this . sreach _num = ind
this . input _sreach = this . select _list [ ind ] . val
if ( this . select _list [ ind ] . type == 'input' ) {
this . downBool = true
} else {
this . downBool = false
}
setTimeout ( "document.getElementById(\"sreach_input\").focus()" , 50 ) ;
this . getHeight ( )
2019-12-17 17:17:30 +08:00
this . searchMsg . zheze _none = false
2019-12-16 17:14:58 +08:00
}
} ,
//删除要搜索的条件
close _selcet _list ( ind , e ) {
2020-01-10 20:09:33 +08:00
if ( e ) {
this . stop _click ( e )
}
2020-01-13 16:17:05 +08:00
// 处理alertType--asset联动问题: 删除alertType时, 将asset也删除
2020-01-10 20:09:33 +08:00
if ( this . select _list [ ind ] . label == 'alertType' ) {
for ( let i = 0 ; i < this . select _list . length ; i ++ ) {
if ( this . select _list [ i ] . label == 'asset' ) {
this . close _selcet _list ( i ) ;
for ( let j = 0 ; j < this . searchLabelList . length ; j ++ ) {
if ( this . searchLabelList [ j ] . label == 'asset' ) {
this . searchLabelList [ j ] . disabled = true ;
break ;
}
}
break ;
}
}
}
2019-12-17 17:17:30 +08:00
this . searchMsg . searchLabelList . forEach ( ( val , key ) => {
2019-12-16 17:14:58 +08:00
if ( this . select _list [ ind ] . id == val . id ) {
2020-01-13 16:17:05 +08:00
this . searchLabelList . splice ( key + 1 , 0 , val ) ;
2019-12-16 17:14:58 +08:00
this . Iskeywords ( ind )
}
2020-01-13 16:17:05 +08:00
} ) ;
this . select _list . splice ( ind , 1 ) ;
this . sreach _num -- ;
2019-12-16 17:14:58 +08:00
} ,
//阻止冒泡事件
stop _click ( e ) {
e . cancelBubble = true ;
e . stopPropagation ( ) ;
} ,
//点击遮罩层
zhezhao _click ( ) {
if ( this . input _sreach != '' ) {
2019-12-17 17:17:30 +08:00
if ( ! this . searchMsg . zheze _none ) {
2019-12-16 17:14:58 +08:00
if ( this . input _sreach != '' ) {
this . change _sreach _show = true
let IDsplit ,
id = /^[0-9]*$/ ,
bool = true
if ( this . select _list [ this . sreach _num ] . id == 1 ) {
//id==1 判断是不是搜索ID 如果是ID 会出现搜索多个ID 分割ID
IDsplit = this . input _sreach . split ( ',' )
//循环分割出来的ID 判断输入的每个ID是否正确
for ( let i = IDsplit . length - 1 ; i >= 0 ; i -- ) {
if ( ! id . test ( IDsplit [ i ] ) || IDsplit [ i ] > 2147483647 ) {
//如果有不正确的值 进行删除
IDsplit . splice ( i , 1 )
this . $message . error ( this . other . delErrorId )
}
if ( IDsplit [ i ] == '' ) {
IDsplit . splice ( i , 1 )
}
}
this . input _sreach = ''
//从新拼接ID内容
IDsplit . forEach ( val => {
this . input _sreach += val + ','
} )
this . input _sreach = this . input _sreach . substr ( 0 , this . input _sreach . length - 1 )
if ( this . input _sreach != '' ) {
this . select _list [ this . sreach _num ] . val = this . input _sreach
this . input _sreach = ''
this . sreach _num ++
this . sreach _num = this . select _list . length
} else {
this . sreach _num = 0
this . change _sreach _show = false
}
} else {
this . select _list [ this . sreach _num ] . val = this . input _sreach
this . input _sreach = ''
this . sreach _num = this . select _list . length
}
} else {
let Bool = false
this . select _list . forEach ( val => {
if ( val . val == '' || val . val == undefined ) {
Bool = true
}
} )
if ( Bool ) {
this . sreach _num = this . select _list . length - 1
} else {
this . sreach _num = this . select _list . length
}
}
if ( this . no _condition != '' ) {
this . change _sreach _show = true
if ( this . select _list . length == 0 ) {
2019-12-27 17:53:17 +08:00
this . select _list . push ( { name : 'Name' , id : 2 , type : 'input' , val : this . no _condition , label : 'name' } )
2019-12-17 17:17:30 +08:00
this . searchLabelList . forEach ( ( val , ind ) => {
2019-12-16 17:14:58 +08:00
if ( val . id == 2 ) {
2019-12-17 17:17:30 +08:00
this . searchLabelList . splice ( ind , 1 )
2019-12-16 17:14:58 +08:00
}
} )
this . sreach _num ++
} else {
let bool = true
this . select _list . forEach ( val => {
if ( val . id == 2 ) {
bool = false
val . val += ',' + this . no _condition
}
} )
if ( bool ) {
2019-12-27 17:53:17 +08:00
this . select _list . push ( { name : 'Name' , id : 2 , type : 'input' , val : this . no _condition , label : 'name' } )
2019-12-17 17:17:30 +08:00
this . searchLabelList . forEach ( ( val , ind ) => {
2019-12-16 17:14:58 +08:00
if ( val . id == 2 ) {
2019-12-17 17:17:30 +08:00
this . searchLabelList . splice ( ind , 1 )
2019-12-16 17:14:58 +08:00
}
} )
this . sreach _num ++
}
}
this . no _condition = ''
this . sreach _num = this . select _list . length
}
setTimeout ( "document.getElementById(\"one-input\").focus()" , 500 ) ;
this . input _list = ! this . input _list
var _this = this
setTimeout ( function ( ) {
_this . getHeight ( )
} , )
2019-12-17 17:17:30 +08:00
this . searchMsg . zheze _none = true
2019-12-16 17:14:58 +08:00
}
}
} ,
//点击搜索框 显示搜索类型
read _input ( e ) {
e . cancelBubble = true ;
e . stopPropagation ( ) ;
this . getHeight ( )
this . input _list = ! this . input _list
} ,
//点击选择 搜索类型
select _name ( val , ind , id , type , label , disabled ) {
// if(id==43||id==45||id==48){ //根据id判断是否开启ip验证
// this.select_conditionsName=true
// }
2019-12-17 17:17:30 +08:00
if ( type == 'input' ) {
this . downBool = true ;
} else {
this . downBool = false ;
}
this . no _condition = '' ;
this . searchMsg . zheze _none = false ;
2019-12-16 17:14:58 +08:00
if ( ! disabled ) {
if ( ind == 0 ) {
this . select ( )
} else if ( id == 7 ) {
2019-12-17 17:17:30 +08:00
this . searchLabelList . splice ( ind , 1 )
2019-12-16 17:14:58 +08:00
this . select _list . push ( {
name : val ,
id : id ,
type : type ,
label : label ,
disabled : disabled
} )
this . change _sreach _show = false
this . input _list = ! this . input _list
} else if ( id == 29 ) {
2019-12-17 17:17:30 +08:00
this . searchLabelList . splice ( ind , 1 )
2019-12-16 17:14:58 +08:00
this . select _list . push ( {
name : val ,
id : id ,
type : type ,
label : label ,
disabled : disabled
} )
this . change _sreach _show = false
this . sreach _num = this . select _list . length - 1
this . input _list = ! this . input _list
setTimeout ( "document.getElementById(\"sreach_input\").focus()" , 500 ) ;
2019-12-17 17:17:30 +08:00
this . searchLabelList . forEach ( val => {
2019-12-16 17:14:58 +08:00
if ( val . id == 30 || val . id == 31 || val . id == 32 || val . id == 33 ) {
val . disabled = true
}
} )
} else if ( id == 30 || id == 31 || id == 32 || id == 33 ) {
2019-12-17 17:17:30 +08:00
this . searchLabelList . splice ( ind , 1 )
2019-12-16 17:14:58 +08:00
this . select _list . push ( {
name : val ,
id : id ,
type : type ,
label : label ,
disabled : disabled
} )
this . change _sreach _show = false
this . sreach _num = this . select _list . length - 1
this . input _list = ! this . input _list
setTimeout ( "document.getElementById(\"sreach_input\").focus()" , 500 ) ;
2019-12-17 17:17:30 +08:00
this . searchLabelList . forEach ( val => {
2019-12-16 17:14:58 +08:00
if ( val . id == 29 ) {
val . disabled = true
}
} )
} else {
2019-12-17 17:17:30 +08:00
this . searchLabelList . splice ( ind , 1 )
2019-12-16 17:14:58 +08:00
this . select _list . push ( {
name : val ,
id : id ,
type : type ,
label : label ,
disabled : disabled
2019-12-20 17:18:30 +08:00
} ) ;
2019-12-16 17:14:58 +08:00
this . change _sreach _show = false
this . sreach _num = this . select _list . length - 1
this . input _list = ! this . input _list
if ( id !== 6 && id !== 28 ) {
setTimeout ( "document.getElementById(\"sreach_input\").focus()" , 500 ) ;
}
}
var _this = this
setTimeout ( function ( ) {
_this . getHeight ( )
} , )
}
} ,
// 判断输入框的高度
getHeight ( ) {
if ( document . getElementById ( 'search-ul' ) . clientHeight < 24 | | document.getElementById ( ' input -center -box ' ) .clientHeight < 24 ) {
document . getElementById ( 'input-center-box' ) . style . height = 30 + 'px'
document . getElementById ( 'search-ul' ) . style . height = 24 + "px"
}
} ,
chlick _sreach ( e ) {
this . stop _click ( e )
2019-12-17 17:17:30 +08:00
this . searchMsg . zheze _none = false
2019-12-16 17:14:58 +08:00
} ,
// 时间计划
schelistget ( ) {
this . schlist = [ ]
this . $get ( "/schedule" , this . schedata ) . then ( data => {
if ( data . code == 200 ) {
this . schlist = data . data . list
}
} )
} ,
} ,
mounted ( ) {
2019-12-17 17:17:30 +08:00
this . defaultItem ? this . select _list . push ( { name : this . defaultItem , label : this . defaultItem } ) : '' ;
this . defaultValue != '' ? this . no _condition = this . defaultValue : '' ;
2019-12-16 17:14:58 +08:00
this . restructure _historyDate ( )
if ( this . $route . path == '/Objects_Objects' ) {
this . schelistget ( )
}
2019-12-17 17:17:30 +08:00
if ( this . $route . path == '/promServer' ) {
this . getDcData ( ) ;
}
2020-01-10 20:09:33 +08:00
if ( this . $route . path == '/project' || this . $route . path == '/alertList' ) {
2019-12-20 17:18:30 +08:00
this . getAssetData ( ) ;
}
2020-01-08 22:19:46 +08:00
if ( this . $route . path == '/asset' ) {
this . getModelData ( ) ;
}
2019-12-17 17:17:30 +08:00
JSON . parse ( JSON . stringify ( this . searchMsg . searchLabelList ) ) . forEach ( val => {
2019-12-16 17:14:58 +08:00
if ( val . name == 'Protocol' ) {
this . schemaTypeSelect = val . doc . data
}
if ( val . prop == 'common_action' ) {
this . actionSelect = val . doc . data
}
this . actionSelect . forEach ( ( item ) => {
item . id = item . code ;
item . label = val . label ;
item . name = val . label ;
2019-12-17 17:17:30 +08:00
} ) ;
this . searchLabelList . push ( val ) ;
} ) ;
var _this = this ;
2019-12-16 17:14:58 +08:00
document . onkeydown = function ( event ) {
var e = event || window . event || arguments . callee . caller . arguments [ 0 ] ;
if ( e . keyCode == 27 ) {
_this . close _search ( e )
}
}
}
}
< / script >
< style scoped >
. new - search {
display : flex ;
position : relative ;
box - shadow : 0 px 0 px 20 px 0 px rgba ( 0 , 0 , 0 , .08 ) ;
2019-12-26 16:31:53 +08:00
line - height : 28 px ;
2019-12-16 17:14:58 +08:00
}
. new - search . search - input - all {
width : 300 px ;
background : # fff ;
color : rgba ( 0 , 0 , 0 , .55 ) ;
2019-12-26 16:31:53 +08:00
height : 28 px ;
line - height : 28 px ;
2019-12-16 17:14:58 +08:00
border - bottom - left - radius : 5 px ;
border - top - left - radius : 5 px ;
display : flex ;
position : relative ;
box - shadow : 0 px 0 px 20 px 0 px rgba ( 0 , 0 , 0 , .08 ) ;
}
. search - input - all . btn - retract {
padding : 0 px 4 px ;
text - align : center ;
}
. search - input - all . search - history {
padding : 0 px 10 px ;
2019-12-26 16:31:53 +08:00
height : 20 px ;
line - height : 20 px ;
2019-12-16 17:14:58 +08:00
text - align : center ;
border - right : 1 px solid # e5e5e5 ;
margin - top : 4 px ;
position : relative ;
}
. search - input - all . input - center - box {
flex : 1 ;
height : 100 % ;
overflow - x : auto ;
overflow - y : hidden ;
}
. input - center - box : : - webkit - scrollbar { /*滚动条整体样式*/
width : 4 px ; /*高宽分别对应横竖滚动条的尺寸*/
height : 6 px ;
}
. input - center - box : : - webkit - scrollbar - thumb { /*滚动条里面小方块*/
border - radius : 3 px ;
- webkit - box - shadow : inset 0 0 5 px rgba ( 0 , 0 , 0 , 0.2 ) ;
background : rgba ( 0 , 0 , 0 , 0.2 ) ;
}
. input - center - box : : - webkit - scrollbar - track { /*滚动条里面轨道*/
- webkit - box - shadow : inset 0 0 5 px rgba ( 0 , 0 , 0 , 0.2 ) ;
border - radius : 0 ;
background : rgba ( 0 , 0 , 0 , 0.1 ) ;
}
. search - input - all . clear - search {
padding : 0 5 px ;
text - align : center ;
2019-12-17 17:17:30 +08:00
font - size : 12 px ;
2019-12-16 17:14:58 +08:00
}
. dataBackG {
background : # f0f0f0 ;
}
. none {
display : none ! important ;
}
. new - search - btn {
padding : 0 4 px ;
cursor : pointer ;
}
. search - text {
display : inline - block ;
margin - right : 20 px ;
}
. sreach _box {
position : relative ;
width : 80 % ;
height : 28 px ;
padding : 20 px ;
background : # fff ;
margin : 200 px auto ;
}
. keyring _sreach _right _btn {
width : 18 % ;
height : 28 px ;
float : right ;
line - height : 28 px ;
text - align : center ;
border : 1 px solid # dfdfdf ;
}
. keyring _sreach _right _btn . right - btn - group {
float : left ;
width : 80 % ;
border - right : 1 px solid # dfdfdf ;
box - sizing : border - box ;
}
. keyring _sreach _right _btn . right - btn - icon {
float : left ;
width : 19 % ;
}
. sreach _box . close _zhezhao {
position : absolute ;
right : 0 ;
top : - 50 px ;
width : 24 px ;
height : 28 px ;
border - radius : 50 % ;
background : # fff ;
text - align : center ;
line - height : 28 px ;
font - size : 12 px ;
}
. localStorage _list _box {
position : absolute ;
left : 10 px ;
top : 36 px ;
width : auto ;
min - width : 250 px ;
max - width : 350 px ;
height : auto ;
border : 1 px solid # dfdfdf ;
background : # fff ;
color : # 2 e2e2e ;
text - align : left ;
border - radius : 3 px ;
box - shadow : 0 2 px 4 px rgba ( 0 , 0 , 0 , 0.1 ) ;
z - index : 9999 ;
font - size : 12 px ;
}
. localStorage _list _box . list _box _title {
width : 100 % ;
height : 40 px ;
line - height : 40 px ;
line - height : 40 px ;
text - align : center ;
position : relative ;
border - bottom : 1 px solid # dfdfdf ;
color : # 2 e2e2e ;
}
. localStorage _list _box . list _box _title i {
position : absolute ;
right : 10 px ;
}
. localStorage _list _box . list _box _content {
text - align : left ;
padding : 5 px 0 ;
box - sizing : border - box ;
border - bottom : 1 px solid # dfdfdf ;
}
. localStorage _list _box ul li {
padding : 5 px 10 px ;
line - height : 20 px ;
}
. localStorage _list _box ul li : hover {
background : # f0f0f0 ;
cursor : pointer ;
}
. localStorage _list _box ul li span {
color : # 2 e2e2e ;
}
. localStorage _list _box ul li . value {
font - weight : 600 ;
}
. localStorage _list _box . list _box _clear {
padding - left : 10 px ;
line - height : 40 px ;
}
. localStorage _list _box . list _box _clear : hover {
background : # f0f0f0 ;
cursor : pointer ;
}
. input - center - box . sreach _fixe _left {
width : auto ;
display : flex ;
height : 100 % ;
min - width : 100 % ;
}
. sreach _list {
display : flex ;
justify - content : flex - start ;
height : 100 % ;
padding - left : 10 px ;
}
. sreach _fixe _left . selectinfo _box {
display : flex ;
flex - shrink : 0 ;
width : auto ;
height : auto ;
margin : 3 px 2 px ;
font - size : 12 px ;
}
. selectinfo _box . select _condition {
float : left ;
height : 16 px ;
padding : 3 px ;
background : # f8f8f8 ;
line - height : 16 px ;
color : rgba ( 0 , 0 , 0 , .55 ) ;
}
. selectinfo _box . select _content {
float : left ;
2019-12-17 17:17:30 +08:00
line - height : 16 px ;
height : 16 px ;
2019-12-16 17:14:58 +08:00
padding : 3 px ;
background : # f0f0f0 ;
color : rgba ( 0 , 0 , 0 , 0.85 ) ;
display : flex ;
}
. select _input {
height : 100 % ;
flex : 1 ;
float : left ;
min - width : 100 px ;
}
. select _input input {
width : 100 % ;
height : 100 % ;
border : none ;
float : left ;
padding - left : 5 px ! important ;
box - sizing : border - box ;
}
. select _input input : focus {
border : none ;
box - shadow : none ;
}
. select _input . select _info _list {
position : absolute ;
left : 100 px ;
top : 36 px ;
height : auto ;
width : auto ;
max - height : 240 px ;
padding : 5 px 0 ;
background : # fff ;
border : 1 px solid # e5e5e5 ;
border - radius : 3 px ;
box - shadow : 0 2 px 4 px rgba ( 0 , 0 , 0 , 0.1 ) ;
overflow - y : auto ;
z - index : 9999 ;
}
. select _info _list ul li {
padding : 5 px 10 px ;
line - height : 20 px ;
}
. select _info _list ul li : hover {
background : # f0f0f0 ;
cursor : pointer ;
}
. sreach _input . input {
flex : 1 ;
height : 100 % ;
padding - left : 10 px ! important ;
box - sizing : border - box ;
position : relative ;
}
. sreach _input . input input {
width : 100 % ;
height : 100 % ;
border : none ;
padding : 0 ! important ;
float : left ;
}
. sreach _box input : focus {
outline : none ;
border - color : transparent ;
box - shadow : none ;
}
. sreach _input input : : placeholder {
color : rgba ( 0 , 0 , 0 , 0.55 )
}
. input _list {
position : absolute ;
left : 47 px ;
top : 36 px ;
width : auto ;
max - width : 400 px ;
max - height : 240 px ;
min - width : 300 px ;
background : # fff ;
border - radius : 3 px ;
box - shadow : 0 2 px 4 px rgba ( 0 , 0 , 0 , 0.1 ) ;
z - index : 9 ;
overflow - y : auto ;
font - size : 12 px ;
}
. input _list ul {
padding : 4 px 0 ;
}
. input _list ul li {
padding : 4 px 10 px ;
line - height : 16 px ;
height : 20 px ;
}
. input _list ul li : hover {
background : # f0f0f0 ;
cursor : pointer ;
}
. search - style - ind {
background : # f0f0f0 ;
cursor : pointer ;
}
. sreach _fixe > i {
margin - right : 15 px ;
}
. is - disabled {
color : # C0C4CC ;
cursor : not - allowed ! important ;
background : # fff ! important ;
}
li {
list - style : none ;
}
< / style >