文件
fenleixinxi/public/assets/js/backend/format.js

43 行
1.5 KiB
JavaScript

此文件含有模棱两可的 Unicode 字符

此文件含有可能会与其他字符混淆的 Unicode 字符。 如果您是想特意这样的,可以安全地忽略该警告。 使用 Escape 按钮显示他们。

define(['jquery'], function ($) {
var Format = {
/**
* 列表序号(跨分页连续)
*/
serial: function (value, row, index) {
var table = this.table ? $(this.table) : null;
var pageSize = 0;
var pageNumber = 1;
if (table && table.length && table.data('bootstrap.table')) {
var options = table.bootstrapTable('getOptions') || {};
pageSize = parseInt(options.pageSize, 10) || 0;
pageNumber = parseInt(options.pageNumber, 10) || 1;
}
return pageSize > 0 ? (pageNumber - 1) * pageSize + index + 1 : index + 1;
},
/**
* 状态徽标
*/
status: function (text, tone) {
if (text === null || typeof text === 'undefined' || text === '') {
text = '-';
}
return '<span class="fc-status fc-status-' + (tone || 'default') + '">' + text + '</span>';
},
/**
* 生成状态字段的 formatter
* @param map 值 => 文案
* @param tones 值 => 颜色(success/warning/danger/info/default)
*/
statusFormatter: function (map, tones) {
tones = tones || {};
return function (value) {
var text = map[value] !== undefined ? map[value] : '-';
return Format.status(text, tones[value] || 'default');
};
}
};
return Format;
});