var currentTemId;
|
var currentTemName;
|
var currentTemSsbm;
|
var init = false;
|
|
layui.config({
|
base: baseUrl + "/static/layui/lay/modules/" // 配置模块所在的目录
|
}).use(['table','laydate', 'form', 'tree', 'xmSelect'], function() {
|
var table = layui.table;
|
var $ = layui.jquery;
|
var layer = layui.layer;
|
var layDate = layui.laydate;
|
var form = layui.form;
|
var tree = layui.tree;
|
var xmSelect = layui.xmSelect;
|
var selObj, treeData; // 左树选中数据
|
|
var organizationTree;
|
window.loadTree = function(condition){
|
var loadIndex = layer.load(2);
|
$.ajax({
|
url: baseUrl+"/node/tree/auth",
|
headers: {'token': localStorage.getItem('token')},
|
data: {
|
'condition': condition
|
},
|
method: 'POST',
|
success: function (res) {
|
console.log(res)
|
if (res.code === 200){
|
layer.close(loadIndex);
|
// 树形图
|
organizationTree = tree.render({
|
elem: '#organizationTree',
|
id: 'organizationTree',
|
onlyIconControl: true,
|
data: res.data,
|
click: function (obj) {
|
currentTemId = obj.data.id;
|
currentTemName = obj.data.title.split(" - ")[0];
|
currentTemSsbm = obj.data.title.split(" - ")[1];
|
selObj = obj;
|
$('#organizationTree').find('.ew-tree-click').removeClass('ew-tree-click');
|
$(obj.elem).children('.layui-tree-entry').addClass('ew-tree-click');
|
tableIns.reload({
|
where: {node_id: obj.data.id},
|
page: {curr: 1}
|
});
|
}
|
});
|
treeData = res.data;
|
if (isEmpty(condition) && init) {
|
tableIns.reload({
|
where: {node_id: ""},
|
page: {curr: 1}
|
});
|
}
|
if (!init) {
|
init = true;
|
}
|
} else if (res.code === 403){
|
top.location.href = baseUrl+"/";
|
} else {
|
layer.msg(res.msg)
|
}
|
}
|
})
|
}
|
loadTree();
|
|
/* 树形图重置 */
|
$('#treeReset').click(function () {
|
$("#condition").val("");
|
loadTree("");
|
})
|
|
})
|
|
function closeDialog() {
|
layer.closeAll();
|
}
|
|
/* 树形图搜索 */
|
function findData(el) {
|
var condition = $(el).val();
|
loadTree(condition)
|
}
|