页面代码:
assess-census-detail.js代码:
var headArray = [ "记分标准", "分值", "任务数", "审批中", "审批通过", "审批未通过" ];
var newOpen = null;
$(function() {
$.post(ctx+"/system/assess/census/treeJson.chtml", { yearId: yearId, departmentId: departmentId},
function(data){
var data=eval("(" + data + ")");
queryHandler(data);
});
});
var setting = {
view : {
addDiyDom : addDiyDom,
nameIsHTML : true,
selectedMulti : false,
showTitle : false
},
data : {
simpleData : {
enable : true
}
}
};
/**
* 自定义DOM节点
*/
function addDiyDom(treeId, treeNode) {
var spaceWidth = 15;
var liObj = $("#" + treeNode.tId);
var aObj = $("#" + treeNode.tId + "_a");
var switchObj = $("#" + treeNode.tId + "_switch");
var icoObj = $("#" + treeNode.tId + "_ico");
var spanObj = $("#" + treeNode.tId + "_span");
aObj.attr('title', '');
aObj.append('
var div = $(liObj).find('div').eq(0);
//从默认的位置移除
switchObj.remove();
spanObj.remove();
icoObj.remove();
//在指定的div中添加
div.append(switchObj);
div.append(spanObj);
//隐藏了层次的span
var spaceStr = "";
switchObj.before(spaceStr);
//图标垂直居中
icoObj.css("margin-top","9px");
switchObj.after(icoObj);
var editStr = '';
// 宽度需要和表头保持一致
editStr += '
editStr += '
editStr += '
editStr += '
editStr += '
aObj.append(editStr);
}
// 初始化列表
function queryHandler(zTreeNodes) {
// 初始化树
$.fn.zTree.init($("#dataTree"), setting, zTreeNodes);
// 设置表头
var li_head = '
$.each(headArray, function(i, headObj) {
var width = 10;
if (i == 0) {
width = 48;
}
li_head += '
});
li_head += '
var rows = $("#dataTree").find('li');
if (rows.length > 0) {
rows.eq(0).before(li_head)
} else {
$("#dataTree").append(li_head);
$("#dataTree").append('
}
}