$(document).ready(function() { autoFlashHeight(); $('#filing').height($(".sjs-height-0").height() - $('#add-slibing').parent().parent().height() - 10); class FilingObj { constructor(setting) { // 原始数据整理后的树结构,用来整理zTree显示 this.dragTree = createDragTree({ id: 'id', pid: 'tree_pid', level: 'tree_level', order: 'tree_order', rootId: '-1' }); // 界面显示的zTree this.setting = setting; this.filingTree = null; this.pageCount = 15; this.expandKey = 'filing-' + window.location.pathname.split('/')[2]; const cache = getLocalCache(this.expandKey); this.expandCache = cache ? _.uniq(cache.split(',')) : []; this.curFilingKey = 'cur-filing-' + window.location.pathname.split('/')[2]; } calcTotalFileCount() { this.dragTree.recursiveFun(this.dragTree.children, x => { if (x.children && x.children.length > 0) { x.total_file_count = x.children.map(y => { return y.total_file_count; }).reduce((pre, value) => { return pre + value }, 0); } else { x.total_file_count = x.file_count; } }); } _loadFilingSourceNode() { const self = this; const loadChildren = function(children) { for (const child of children) { if (child.children && child.children.length > 0) loadChildren(child.children); child.source_node = self.dragTree.getItems(child.id); } }; const nodes = this.filingTree.getNodes(); loadChildren(nodes); } loadFiling() { const self = this; if (this.filingTree) $.fn.zTree.destroy(this.setting.treeId); const sortNodes = this.dragTree.nodes.map(x => { const result = { id: x.id, tree_pid: x.tree_pid, name: x.name + (x.total_file_count > 0 ? `(${x.total_file_count})` : ''), spid: x.spid, }; if (x.is_fixed) result.isParent = true; if (x.is_folder || x.is_fixed) result.open = self.expandCache.indexOf(result.id) >= 0; return result; }); this.filingTree = $.fn.zTree.init($('#filing'), this.setting, sortNodes); this._loadFilingSourceNode(); const curCache = getLocalCache(this.curFilingKey); const curNode = curCache ? this.filingTree.getNodeByParam('id', curCache) : null; if (curNode){ this.filingTree.selectNode(curNode); filingObj.setCurFiling(curNode); } } analysisFiling(data) { this.dragTree.loadDatas(data); this.calcTotalFileCount(); this.loadFiling(); } _getFileNameHtml(file) { const editHtml = file.canEdit ? `` : ''; const viewHtml = file.viewpath ? `` : ''; const downHtml = ``; const delHtml = file.canEdit ? `` : ''; return `
添加单位下全部用户
${u.name}${u.mobile}
`); html.push(`${u.role}`); html.push(`