@ -8,16 +8,17 @@
* /
// 目录树数据缓存
const dirCache = new Map ( ) ;
layui . use ( [ 'layer' , 'listPage' , 'globalTree' , 'gtable' , 'form' , 'element' , 'dropdown' , 'laydate' , 'dict' ] , function ( ) {
layui . use ( [ 'layer' , 'listPage' , 'globalTree' , 'gtable' , 'form' , 'element' , 'dropdown' , 'laydate' , 'dict' , 'datalabel' ] , function ( ) {
const listPage = layui . listPage ,
form = layui . form ,
element = layui . element ,
laydate = layui . laydate ,
globalTree = layui . globalTree ;
globalTree = layui . globalTree ,
DataLabel = layui . datalabel ;
let metaListTable , dirFileTable , tagSelector , tags = [ ] , unchecked _tags = [ ] , conditions = [ ] ;
// 初始化
let metaListTable , dirFileTable , tagSelector , tags = [ ] , conditions = [ ] ;
const unchecked _tags = new Set ( ) ;
// 初始化
initDirectoryTree ( ) ;
@ -105,7 +106,7 @@ layui.use(['layer', 'listPage', 'globalTree', 'gtable', 'form', 'element', 'drop
* @ param basicData
* /
function setCurrentPosition ( basicData ) {
let directoryPath = basicData . directoryPath . replaceAll ( '/' , ' / ' ) ;
let directoryPath = basicData . directoryPath . replaceAll ( '/' , ' / ' ) ;
$ ( '.current-position label' ) . text ( directoryPath ) ;
}
@ -273,15 +274,13 @@ layui.use(['layer', 'listPage', 'globalTree', 'gtable', 'form', 'element', 'drop
$ ( '#condition-div' ) . slideToggle ( 100 , 'linear' , conditionSlideToggle )
} ) ;
if ( ! tagSelector ) {
tagSelector = new MarkerSelector ( '#mark-selector-input' ) ;
}
tagSelector . bindBtnEvent ( )
tagSelector . onOkBtn ( data => {
tags = data
setMarkTagInputValue ( ) ;
} ) ;
$ ( '#mark-selector-input' ) . on ( 'click' , function ( ) {
DataLabel . openChooseDialog ( null , null , null , true ) . then ( ( labels ) => {
tags = labels || [ ] ;
setMarkTagInputValue ( ) ;
} )
} )
// 监听标签点击事件
element . on ( 'tab(condition-tab)' , function ( data ) {
// 点击后移除选中样式
@ -296,6 +295,9 @@ layui.use(['layer', 'listPage', 'globalTree', 'gtable', 'form', 'element', 'drop
// 监听条件标签删除事件
element . on ( 'tabDelete(condition-tab)' , function ( data ) {
let key = $ ( this ) . parent ( ) . data ( 'key' ) ;
if ( key === 'markTag' ) {
tags = [ ] ;
}
let formVal = form . val ( 'search-form' ) ;
formVal [ key ] = '' ;
form . val ( 'search-form' , formVal ) ;
@ -310,7 +312,7 @@ layui.use(['layer', 'listPage', 'globalTree', 'gtable', 'form', 'element', 'drop
$ ( '#condition-clear-btn' ) . on ( 'click' , function ( ) {
$ ( '#searchKeyInput' ) . val ( '' ) ;
tags = [ ] ;
unchecked _tags = [ ] ;
unchecked _tags . clear ( ) ;
conditions = [ ] ;
beginSearch ( ) ;
} ) ;
@ -342,9 +344,7 @@ layui.use(['layer', 'listPage', 'globalTree', 'gtable', 'form', 'element', 'drop
function setMarkTagInputValue ( ) {
let temp = [ ] ;
for ( let tag of tags ) {
let arr = tag . split ( '-' ) ;
let text = tag . replace ( arr [ 0 ] + '-' + arr [ 1 ] + '-' , '' ) ;
temp . push ( text ) ;
temp . push ( tag . title ) ;
}
$ ( '#mark-selector-input' ) . val ( temp . join ( ', ' ) ) ;
}
@ -370,7 +370,7 @@ layui.use(['layer', 'listPage', 'globalTree', 'gtable', 'form', 'element', 'drop
let htm = '' ;
conditions = [ ] ;
for ( let key in formVal ) {
if ( key == 'searchKeyInput' ) continue ;
if ( key === 'searchKeyInput' ) continue ;
let fieldName = key , fieldValue = formVal [ key ] , logicJudgement ;
// 如果fieldName是条件下拉框,则跳过
if ( fieldName . startsWith ( 'logic-' ) || fieldName === 'directoryId' || fieldName === 'metadataId' ) continue ;
@ -397,11 +397,11 @@ layui.use(['layer', 'listPage', 'globalTree', 'gtable', 'form', 'element', 'drop
condition = '包含' ;
}
if ( fieldName == 'secretLevel' ) {
if ( fieldName === 'secretLevel' ) {
hasText = $ ( ` select[name="secretLevel"] option[value=" ${ fieldValue } "] ` ) . text ( ) ;
} else if ( fieldName == 'dataFrom' ) {
} else if ( fieldName === 'dataFrom' ) {
hasText = $ ( ` select[name="dataFrom"] option[value=" ${ fieldValue } "] ` ) . text ( ) ;
} else if ( fieldName == 'dataType' ) {
} else if ( fieldName === 'dataType' ) {
hasText = $ ( ` select[name="dataType"] option[value=" ${ fieldValue } "] ` ) . text ( ) ;
}
conditions . push ( { fieldName , fieldValue , logicJudgement } )
@ -409,40 +409,29 @@ layui.use(['layer', 'listPage', 'globalTree', 'gtable', 'form', 'element', 'drop
}
}
let temp = [ ] ;
let tag _htm = '' ;
for ( let tag of tags ) {
let tag _arr = tag . split ( '-' ) ;
let tag _type = tag _arr [ 1 ] , tag _text = tag _arr [ 2 ] , temp _tags = temp [ tag _type ] ;
if ( ! temp _tags ) {
temp _tags = [ ]
let checked = 'checked' ;
if ( unchecked _tags . has ( tag . id + '' ) ) {
checked = '' ;
}
temp _tags . push ( { id : tag _arr [ 0 ] , text : tag _text } ) ;
temp [ tag _type ] = temp _tags ;
tag _htm += ` <input type="checkbox" title=" ${ tag . title } " value=" ${ tag . id } " ${ checked } lay-skin="primary"> ` ;
}
for ( let type in temp ) {
let tag _type = type , tag _items = temp [ type ] , tag _htm = '' ;
for ( let item of tag _items ) {
let val = item . id + '-' + item . text , checked = 'checked' ;
if ( unchecked _tags . includes ( val ) ) {
checked = '' ;
}
tag _htm += ` <input type="checkbox" title=" ${ item . text } " value=" ${ val } " ${ checked } lay-skin="primary"> ` ;
}
htm += ` <li data-key="markTag"> ${ tag _type } : ${ tag _htm } </li> ` ;
if ( tag _htm ) {
htm += ` <li data-key="markTag">置标标签: ${ tag _htm } </li> ` ;
}
$ ( '#condition-tab ul' ) . html ( htm ) ;
element . render ( 'tab' ) ;
$ ( '#condition-tab ul li[data-key="markTag"] i' ) . remove ( ) ;
$ ( '#condition-tab ul li[data-key="markTag"] i' ) . css ( { 'margin-left' : '-10px' } ) ;
form . render ( 'checkbox' ) ;
$ ( 'li[data-key="markTag"] .layui-form-checkbox' ) . on ( 'click' , function ( ) {
let val = $ ( this ) . prev ( ) . val ( ) , index = unchecked _tags . indexOf ( val ) ;
if ( ! $ ( this ) . hasClass ( 'layui-form-checked' ) ) {
unchecked _tags . push ( val ) ;
} else if ( index > - 1 ) {
unchecked _tags . splice ( index , 1 )
let val = $ ( this ) . prev ( ) . val ( ) ;
if ( unchecked _tags . has ( val ) ) {
unchecked _tags . delete ( val ) ;
} else {
unchecked _tags . add ( val ) ;
}
beginSearch ( ) ;
} )
@ -453,7 +442,6 @@ layui.use(['layer', 'listPage', 'globalTree', 'gtable', 'form', 'element', 'drop
}
}
function beginSearch ( ) {
setMarkTagsValue ( )
metaListTable . where . conditions = conditions ;