1. 程式人生 > >第一個項目技術總結

第一個項目技術總結

操作 獲取文件 列表 鍵值對 fin align clas urn data

下拉框:

 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 += "&nbsp;&nbsp;&nbsp"; 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);

第一個項目技術總結