@ -8,15 +8,16 @@
* /
* /
// 目录树数据缓存
// 目录树数据缓存
const dirCache = new Map ( ) ;
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 ,
const listPage = layui . listPage ,
form = layui . form ,
form = layui . form ,
element = layui . element ,
element = layui . element ,
laydate = layui . laydate ,
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 ( ) ;
initDirectoryTree ( ) ;
@ -273,15 +274,13 @@ layui.use(['layer', 'listPage', 'globalTree', 'gtable', 'form', 'element', 'drop
$ ( '#condition-div' ) . slideToggle ( 100 , 'linear' , conditionSlideToggle )
$ ( '#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 ) {
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 ) {
element . on ( 'tabDelete(condition-tab)' , function ( data ) {
let key = $ ( this ) . parent ( ) . data ( 'key' ) ;
let key = $ ( this ) . parent ( ) . data ( 'key' ) ;
if ( key === 'markTag' ) {
tags = [ ] ;
}
let formVal = form . val ( 'search-form' ) ;
let formVal = form . val ( 'search-form' ) ;
formVal [ key ] = '' ;
formVal [ key ] = '' ;
form . val ( 'search-form' , formVal ) ;
form . val ( 'search-form' , formVal ) ;
@ -310,7 +312,7 @@ layui.use(['layer', 'listPage', 'globalTree', 'gtable', 'form', 'element', 'drop
$ ( '#condition-clear-btn' ) . on ( 'click' , function ( ) {
$ ( '#condition-clear-btn' ) . on ( 'click' , function ( ) {
$ ( '#searchKeyInput' ) . val ( '' ) ;
$ ( '#searchKeyInput' ) . val ( '' ) ;
tags = [ ] ;
tags = [ ] ;
unchecked _tags = [ ] ;
unchecked _tags . clear ( ) ;
conditions = [ ] ;
conditions = [ ] ;
beginSearch ( ) ;
beginSearch ( ) ;
} ) ;
} ) ;
@ -342,9 +344,7 @@ layui.use(['layer', 'listPage', 'globalTree', 'gtable', 'form', 'element', 'drop
function setMarkTagInputValue ( ) {
function setMarkTagInputValue ( ) {
let temp = [ ] ;
let temp = [ ] ;
for ( let tag of tags ) {
for ( let tag of tags ) {
let arr = tag . split ( '-' ) ;
temp . push ( tag . title ) ;
let text = tag . replace ( arr [ 0 ] + '-' + arr [ 1 ] + '-' , '' ) ;
temp . push ( text ) ;
}
}
$ ( '#mark-selector-input' ) . val ( temp . join ( ', ' ) ) ;
$ ( '#mark-selector-input' ) . val ( temp . join ( ', ' ) ) ;
}
}
@ -370,7 +370,7 @@ layui.use(['layer', 'listPage', 'globalTree', 'gtable', 'form', 'element', 'drop
let htm = '' ;
let htm = '' ;
conditions = [ ] ;
conditions = [ ] ;
for ( let key in formVal ) {
for ( let key in formVal ) {
if ( key == 'searchKeyInput' ) continue ;
if ( key === 'searchKeyInput' ) continue ;
let fieldName = key , fieldValue = formVal [ key ] , logicJudgement ;
let fieldName = key , fieldValue = formVal [ key ] , logicJudgement ;
// 如果fieldName是条件下拉框,则跳过
// 如果fieldName是条件下拉框,则跳过
if ( fieldName . startsWith ( 'logic-' ) || fieldName === 'directoryId' || fieldName === 'metadataId' ) continue ;
if ( fieldName . startsWith ( 'logic-' ) || fieldName === 'directoryId' || fieldName === 'metadataId' ) continue ;
@ -397,11 +397,11 @@ layui.use(['layer', 'listPage', 'globalTree', 'gtable', 'form', 'element', 'drop
condition = '包含' ;
condition = '包含' ;
}
}
if ( fieldName == 'secretLevel' ) {
if ( fieldName === 'secretLevel' ) {
hasText = $ ( ` select[name="secretLevel"] option[value=" ${ fieldValue } "] ` ) . text ( ) ;
hasText = $ ( ` select[name="secretLevel"] option[value=" ${ fieldValue } "] ` ) . text ( ) ;
} else if ( fieldName == 'dataFrom' ) {
} else if ( fieldName === 'dataFrom' ) {
hasText = $ ( ` select[name="dataFrom"] option[value=" ${ fieldValue } "] ` ) . text ( ) ;
hasText = $ ( ` select[name="dataFrom"] option[value=" ${ fieldValue } "] ` ) . text ( ) ;
} else if ( fieldName == 'dataType' ) {
} else if ( fieldName === 'dataType' ) {
hasText = $ ( ` select[name="dataType"] option[value=" ${ fieldValue } "] ` ) . text ( ) ;
hasText = $ ( ` select[name="dataType"] option[value=" ${ fieldValue } "] ` ) . text ( ) ;
}
}
conditions . push ( { fieldName , fieldValue , logicJudgement } )
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 ) {
for ( let tag of tags ) {
let tag _arr = tag . split ( '-' ) ;
let checked = 'checked' ;
let tag _type = tag _arr [ 1 ] , tag _text = tag _arr [ 2 ] , temp _tags = temp [ tag _type ] ;
if ( unchecked _tags . has ( tag . id + '' ) ) {
if ( ! temp _tags ) {
temp _tags = [ ]
}
temp _tags . push ( { id : tag _arr [ 0 ] , text : tag _text } ) ;
temp [ tag _type ] = temp _tags ;
}
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 = '' ;
checked = '' ;
}
}
tag _htm += ` <input type="checkbox" title=" ${ item . text } " value=" ${ val } " ${ checked } lay-skin="primary"> ` ;
tag _htm += ` <input type="checkbox" title=" ${ tag . title } " value=" ${ tag . id } " ${ checked } lay-skin="primary"> ` ;
}
}
if ( tag _htm ) {
htm += ` <li data-key="markTag"> ${ tag _type } : ${ tag _htm } </li> ` ;
htm += ` <li data-key="markTag">置标标签: ${ tag _htm } </li> ` ;
}
}
$ ( '#condition-tab ul' ) . html ( htm ) ;
$ ( '#condition-tab ul' ) . html ( htm ) ;
element . render ( 'tab' ) ;
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' ) ;
form . render ( 'checkbox' ) ;
$ ( 'li[data-key="markTag"] .layui-form-checkbox' ) . on ( 'click' , function ( ) {
$ ( 'li[data-key="markTag"] .layui-form-checkbox' ) . on ( 'click' , function ( ) {
let val = $ ( this ) . prev ( ) . val ( ) , index = unchecked _tags . indexOf ( val ) ;
let val = $ ( this ) . prev ( ) . val ( ) ;
if ( ! $ ( this ) . hasClass ( 'layui-form-checked' ) ) {
if ( unchecked _tags . has ( val ) ) {
unchecked _tags . push ( val ) ;
unchecked _tags . delete ( val ) ;
} else if ( index > - 1 ) {
} else {
unchecked _tags . splice ( index , 1 )
unchecked _tags . add ( val ) ;
}
}
beginSearch ( ) ;
beginSearch ( ) ;
} )
} )
@ -453,7 +442,6 @@ layui.use(['layer', 'listPage', 'globalTree', 'gtable', 'form', 'element', 'drop
}
}
}
}
function beginSearch ( ) {
function beginSearch ( ) {
setMarkTagsValue ( )
setMarkTagsValue ( )
metaListTable . where . conditions = conditions ;
metaListTable . where . conditions = conditions ;