|
|
@ -1146,9 +1146,9 @@ layui.define(['laytpl', 'laypage', 'form', 'util'], function(exports){ |
|
|
|
|
|
|
|
|
|
|
|
// 数据合计行
|
|
|
|
// 数据合计行
|
|
|
|
Class.prototype.renderTotal = function(data, totalRowData){ |
|
|
|
Class.prototype.renderTotal = function(data, totalRowData){ |
|
|
|
var that = this |
|
|
|
var that = this; |
|
|
|
,options = that.config |
|
|
|
var options = that.config; |
|
|
|
,totalNums = {}; |
|
|
|
var totalNums = {}; |
|
|
|
|
|
|
|
|
|
|
|
if(!options.totalRow) return; |
|
|
|
if(!options.totalRow) return; |
|
|
|
|
|
|
|
|
|
|
@ -1172,29 +1172,33 @@ layui.define(['laytpl', 'laypage', 'form', 'util'], function(exports){ |
|
|
|
that.eachCols(function(i3, item3){ |
|
|
|
that.eachCols(function(i3, item3){ |
|
|
|
var field = item3.field || i3; |
|
|
|
var field = item3.field || i3; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 合计数据的特定字段
|
|
|
|
|
|
|
|
var TOTAL_NUMS = totalRowData && totalRowData[item3.field]; |
|
|
|
|
|
|
|
|
|
|
|
// td 内容
|
|
|
|
// td 内容
|
|
|
|
var content = function(){ |
|
|
|
var content = function(){ |
|
|
|
var text = item3.totalRowText || '' |
|
|
|
var text = item3.totalRowText || ''; |
|
|
|
,decimals = 'totalRowDecimals' in item3 ? item3.totalRowDecimals : 2 |
|
|
|
var decimals = 'totalRowDecimals' in item3 ? item3.totalRowDecimals : 2; |
|
|
|
,thisTotalNum = parseFloat(totalNums[field]).toFixed(decimals) |
|
|
|
var thisTotalNum = parseFloat(totalNums[field]).toFixed(decimals); |
|
|
|
,tplData = { |
|
|
|
var tplData = { |
|
|
|
LAY_COL: item3 |
|
|
|
LAY_COL: item3 |
|
|
|
} |
|
|
|
}; |
|
|
|
,getContent; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
tplData[field] = thisTotalNum; |
|
|
|
tplData[field] = thisTotalNum; |
|
|
|
|
|
|
|
|
|
|
|
// 获取自动计算的合并内容
|
|
|
|
// 获取自动计算的合并内容
|
|
|
|
getContent = item3.totalRow ? (parseTempData.call(that, { |
|
|
|
var getContent = item3.totalRow ? (parseTempData.call(that, { |
|
|
|
item3: item3 |
|
|
|
item3: item3 |
|
|
|
,content: thisTotalNum |
|
|
|
,content: thisTotalNum |
|
|
|
,tplData: tplData |
|
|
|
,tplData: tplData |
|
|
|
}) || text) : text; |
|
|
|
}) || text) : text; |
|
|
|
|
|
|
|
|
|
|
|
// 如果直接传入了合计行数据,则不输出自动计算的结果
|
|
|
|
// 如果直接传入了合计行数据,则不输出自动计算的结果
|
|
|
|
return totalRowData ? (totalRowData[item3.field] || getContent) : getContent; |
|
|
|
return TOTAL_NUMS || getContent; |
|
|
|
}() |
|
|
|
}(); |
|
|
|
,td = ['<td data-field="'+ field +'" data-key="'+ options.index + '-'+ item3.key +'" '+ function(){ |
|
|
|
|
|
|
|
|
|
|
|
// td 容器
|
|
|
|
|
|
|
|
var td = ['<td data-field="'+ field +'" data-key="'+ options.index + '-'+ item3.key +'" '+ function(){ |
|
|
|
var attr = []; |
|
|
|
var attr = []; |
|
|
|
if(item3.align) attr.push('align="'+ item3.align +'"'); // 对齐方式
|
|
|
|
if(item3.align) attr.push('align="'+ item3.align +'"'); // 对齐方式
|
|
|
|
if(item3.minWidth) attr.push('data-minwidth="'+ item3.minWidth +'"'); // 单元格最小宽度
|
|
|
|
if(item3.minWidth) attr.push('data-minwidth="'+ item3.minWidth +'"'); // 单元格最小宽度
|
|
|
@ -1219,8 +1223,8 @@ layui.define(['laytpl', 'laypage', 'form', 'util'], function(exports){ |
|
|
|
// 如果 totalRow 参数为字符类型,则解析为自定义模版
|
|
|
|
// 如果 totalRow 参数为字符类型,则解析为自定义模版
|
|
|
|
if(typeof totalRow === 'string'){ |
|
|
|
if(typeof totalRow === 'string'){ |
|
|
|
return laytpl(totalRow).render($.extend({ |
|
|
|
return laytpl(totalRow).render($.extend({ |
|
|
|
TOTAL_NUMS: totalNums[field] |
|
|
|
TOTAL_NUMS: TOTAL_NUMS || totalNums[field], |
|
|
|
,LAY_COL: item3 |
|
|
|
LAY_COL: item3 |
|
|
|
}, item3)); |
|
|
|
}, item3)); |
|
|
|
} |
|
|
|
} |
|
|
|
return content; |
|
|
|
return content; |
|
|
|