81041
2019-01-07 d4ebdb224370b399f156d8da142019fb44216c64
gx_tieta/WebRoot/pages/js/mylayui.js
@@ -403,7 +403,6 @@
LayuiTbl.prototype = {
    updateTr: function(index, data) {
        var layui = this.layui;
        var preData = this.cache[index];
        var _data = $.extend(preData||{}, data||{});
        var tds = this._getBodyTds(index);
@@ -437,6 +436,13 @@
        });
    }
   ,updateCol: function(major, field, data) {         // 更新列的值
      // 判断当前属性是否是data的属性
      if(field in data) {
         var index = this.getIndex(major, data[major]);      // 获取需要更新的行
         if(index != undefined) {                     // 获取到
            this.updateTr(index, data);                  // 更新表格的数据
         }
      }
      
   }
    ,_getBodyTds: function(index) {
@@ -463,8 +469,11 @@
            // 判断当前内容是否为对应的需要更新的数据
            if(key == _col.field) {
                // 判断是否有模板
                templet = _col.templet?$(_col.templet).html():_col.toolbar?$(_col.toolbar).html():value.toString();
               console.log(key+'***'+_col.field);
               console.log(_col.templet);
                templet = _col.templet?$(_col.templet).html():_col.toolbar?$(_col.toolbar).html():typeof value == 'number'?value.toString():value;
                //console.log(templet);
                templet = templet?templet:typeof value == 'number'?value.toString():value;
                // 根据模板构成content
                laytpl(templet).render(data, function(html) {
                    rs = html;
@@ -476,8 +485,23 @@
        return false;
    }
    ,_getIndex: function(field, value) {
    ,getIndex: function(field, value) {
       // 遍历cache的值
       var cache = this.cache;
       var index = undefined;
       for(var i=0; i<cache.length; i++) {
          var _cache = cache[i];
          console.log(_cache)
          if(field in _cache && _cache[field] == value) {
             index = i;
             break;
          }
       }
       
       return index;
    }
    ,setCache: function(cache) {
       this.cache = cache;
    }
};