下拉框:
1
//反选复选框
function queryFlowCtgy() { 2 $.get("/flow/flowDfne/queryFlowCtgyTrees.afca", {}, function (data) { 3 showCategory(data.data, 0); 4 if (categoryId != null && categoryId != undefined) {//categoryId是后台返回来得值,用来设置被选项
5 $(".category").find("option[value=" + categoryId + "]").prop("selected", true); 6 } 7 form.render('select'); 8 }, "json"); 9 } 10 //形成列表 11 function showCategory(data, count) { 12 $(data).each(function (i, n) { 13 var t = ""; 14 for (var j = 0; j < count; j++) { 15 t += "  "; 16 } 17 if (n.children.length > 0) { 18 $(".category").append("<option value='" + n.id + "'>" + t + n.title + "</option>"); 19 showCategory(n.children, count + 1) 20 } else { 21 $(".category").append("<option value='" + n.id + "'>" + t + n.title + "</option>"); 22 } 23 }); 24 form.render('select'); 25 }
1 // 点击行选中复选框 2 $(document).on('click', '#pubTable table.layui-table tbody tr', function () { 3 var obj = event ? event.target : event.srcElement; 4 var tag = obj.tagName; 5 var checkbox = $(this).find('td div.laytable-cell-checkbox div.layui-form-checkbox i'); 6 if (checkbox.length != 0) { 7 if (tag == "DIV") { 8 checkbox.click(); 9 } 10 } 11 });
$(document).on("click", "#pubTable td div.laytable-cell-checkbox div.layui-form-checkbox", function (e) {
e.stopPropagation();
});
table 文件上传,获取文件的大小:
1 { 2 field: 'fileSize', 3 title: '文件大小', 4 align: 'center', 5 templet: function (d) { 6 if (d.fileSize != null) { 7 var size = d.fileSize / 1024 * 100; 8 if (size > 1024) { 9 size = size / 1024; 10 return Math.round(size) / 100 + "M"; 11 } else { 12 return Math.round(size) / 100 + "K"; 13 } 14 } else { 15 return d.fileSize; 16 } 17 }
对象操作:
将对象中的值保存成键值对: var fileLssuedLog = {}; fileLssuedLog["hostId"] = n.hostName; 对象里面保存:键:对象 node["resourceId"] = "task_" + (elementId);