',
config = this.config.page,
page = Math.ceil(total / config.number),
tmpPageIndex = 0;
if (config.page > 1 && page > 1) {
html += '
HomePrev';
}
if (page <= 10) {
for (var i = 1; i <= page; i++) {
i == config.page ? (html += '
' + i + '') : (html += '
' + i + '');
}
} else if (config.page < 10) {
for (var i = 1; i <= 10; i++) i == config.page ? (html += '
' + i + '') : (html += '
' + i + '');
html += '
...';
} else if (page - config.page < 7) {
page - 7 > 1 && ((html += '
1'), (html += '
...'));
for (var i = page - 7; i <= page; i++)
i == config.page ? (html += '
' + i + '') : (html += 1 == i ? '
...' : '
' + i + '');
} else {
0 == tmpPageIndex && (tmpPageIndex = config.page),
(tmpPageIndex <= config.page - 5 || tmpPageIndex >= config.page + 5) && (tmpPageIndex = config.page),
(html += '
1'),
(html += '
...');
for (var i = tmpPageIndex - 3; i <= tmpPageIndex + 3; i++)
i == config.page ? (html += '
' + i + '') : (html += '
' + i + '');
(html += '
...'), (html += '
' + page + '');
}
return (
page > 1 && config.page < page && (html += '
NextLast'),
(html += '
Total ' + total + ' ')
);
},
/**
* @deprecated 动态处理合并行内,css样式
* @param {object} rows 当前行数据
* @return {stinrg} className class类名
* @return void
*/
$dynamic_merge_style: function (column, index) {
var str = '';
$.each(column, function (key, item) {
switch (key) {
case 'align':
str += 'text-align:' + item + ';';
break;
case 'width':
str += 'width:' + (typeof item == 'string' ? item : item + 'px') + ';';
break;
case 'style':
str += item;
break;
case 'minWidth':
str += 'min-width:' + (typeof item == 'string' ? item : item + 'px') + ';';
break;
case 'maxWidth':
str += 'max-width:' + (typeof item == 'string' ? item : item + 'px') + ';';
break;
}
});
return {
index: index,
css: str,
};
},
/**
* @description 事件绑定
* @param {array} eventList 事件列表
* @return void
*/
$event_bind: function (eventList) {
var _that = this;
$.each(eventList, function (key, item) {
if (_that.event_list[key] && _that.event_list[key].eventType === item.eventType) return true;
_that.event_list[key] = item;
$(_that.config.el).on(item.eventType || 'click', '.' + key, function (ev) {
var index = $(this).parents('tr').index(),
data1 = $(this).data(),
arry = [],
column_data = _that.config.column[$(this).parents('td').index()];
switch (item.type) {
case 'rows':
_that.event_rows_model = {
el: $(this),
model: column_data,
rows: _that.data[index],
index: index,
};
arry = [_that.event_rows_model.rows, _that.event_rows_model.index, ev, key, _that];
break;
case 'sort':
var model = _that.config.column[data1.index];
if ($(this).hasClass('sort-active'))
$('.sort_' + _that.random + ' .sort-active').data({
sort: 'desc',
});
$('.sort_' + _that.random)
.removeClass('sort-active')
.find('.glyphicon')
.removeClass('glyphicon-triangle-top')
.addClass('glyphicon-triangle-bottom');
$(this).addClass('sort-active');
if (data1.sort == 'asc') {
$(this).data({
sort: 'desc',
});
$(this).find('.glyphicon').removeClass('glyphicon-triangle-top').addClass('glyphicon-triangle-bottom');
} else {
$(this).data({
sort: 'asc',
});
$(this).find('.glyphicon').removeClass('glyphicon-triangle-bottom').addClass('glyphicon-triangle-top');
}
_that.config.sort = _that.config.sortParam({
name: model.fid,
sort: data1.sort,
});
_that.$refresh_table_list(true);
break;
case 'checkbox':
var all = $(_that.config.el + ' [data-checkbox="all"]'),
checkbox_list = $(_that.config.el + ' tbody .checkbox_' + _that.random);
if (data1.checkbox == undefined) {
if (!$(this).hasClass('active')) {
$(this).addClass('active');
_that.checkbox_list.push(index);
if (_that.data.length === _that.checkbox_list.length) {
all.addClass('active').removeClass('selected');
} else if (_that.checkbox_list.length > 0) {
all.addClass('selected');
}
} else {
$(this).removeClass('active');
_that.checkbox_list.splice(_that.checkbox_list.indexOf(index), 1);
if (_that.checkbox_list.length > 0) {
all.addClass('selected').removeClass('active');
} else {
all.removeClass('selected active');
}
}
} else {
if (_that.checkbox_list.length === _that.data.length) {
_that.checkbox_list = [];
checkbox_list.removeClass('active selected').next().prop('checked', 'checked');
all.removeClass('active');
} else {
checkbox_list.each(function (index, item) {
if (!$(this).hasClass('active')) {
$(this).addClass('active').next().prop('checked', 'checked');
_that.checkbox_list.push(index);
}
});
all.removeClass('selected').addClass('active');
}
}
_that.$set_batch_view();
break;
case 'button':
arry.push(ev, _that);
break;
case 'search_focus':
var search_tips = $(_that.config.el + ' .bt_search_tips');
if ($(_that.config.el + ' .bt_search_tips').length > 0) {
search_tips.remove();
}
break;
case 'search_input':
if (ev.keyCode == 13) {
$(_that.config.el + ' .search_btn_' + _that.random).click();
return false;
}
break;
case 'search_btn':
var _search = $(_that.config.el + ' .search_input'),
val = $(_that.config.el + ' .search_input').val(),
_filterBox = $('';
var _value = typeof that.data[item.name] !== 'undefined' && that.data[item.name] != '' ? that.data[item.name] : item.value || '';
switch (item.type) {
case 'text': // 文本选择
case 'checkbox': // 复选框
case 'password': // 密码
case 'radio': // 单选框
case 'number': // 数字
var _event = 'event_' + item.name + '_' + that.random;
switch (item.type) {
case 'checkbox': // 复选框
html +=
'
';
if (typeof item.disabled != 'undefined' && item.disabled) {
//禁止复选框 同时可设置class:'check_disabled',使鼠标手为禁止状态
} else {
that.$check_event_bind(_event + '_label', {
click: { type: 'checkbox_icon', config: item },
});
that.$check_event_bind(_event, {
input: {
type: 'checkbox',
config: item,
event: item.event,
},
});
}
break;
case 'radio':
$.each(item.list, function (keys, rItem) {
var radioRandom = _event + '_radio_' + keys;
html +=
'
';
that.$check_event_bind(radioRandom, { input: { type: 'radio', config: item, event: item.event } });
});
break;
default:
html +=
'
';
break;
}
if (item.btn && !item.disabled) {
html += '
' + item.btn.title + '';
if (typeof item.btn.event !== 'undefined') {
that.$check_event_bind(item.name + '_btn', {
click: {
config: item,
event: item.btn.event,
},
});
}
}
if (item.icon) {
html +=
'
';
if (typeof item.icon.event !== 'undefined') {
that.$check_event_bind(item.name + '_icon', {
click: {
type: 'select_path',
select: item.icon.select || '',
config: item,
children: '.' + item.name + '_icon',
event: item.icon.event,
callback: item.icon.callback,
},
});
}
}
break;
case 'textarea':
html += '
';
$.each(['blur', 'focus', 'input'], function (index, items) {
if (item.tips) {
var added = null,
event = {};
switch (items) {
case 'blur':
added = function (ev, item, element) {
if ($(this).val() === '') $(this).next().show();
layer.close(item.tips.loadT);
$(ev.target).data('layer', '');
};
break;
case 'focus':
added = function (ev, item) {
$(this).next().hide();
item.tips.loadT = layer.tips(tips, $(this), {
tips: [1, '#20a53a'],
time: 0,
area: $(this).width(),
});
};
break;
}
}
that.event_list[item.name][items]
? (that.event_list[item.name][items]['added'] = added)
: (that.event_list[item.name][items] = {
type: item.type,
cust: false,
event: item[items],
added: added,
});
});
if (item.tips) {
var tips = '';
if (typeof item.tips.list === 'undefined') {
tips = item.tips.text;
} else {
tips = item.tips.list.join('');
}
html += '
' + tips + '
';
that.$check_event_bind(item.name + '_tips', {
click: {
type: 'textarea_tips',
config: item,
},
});
}
break;
case 'multipleSelect':
// 使用规则 【配置中必须含有value字段(无需默认值设置空数组)、需要选中的下拉项以数组逗号隔开】
html += that.$reader_multipleSelect(item, style, attribute, index);
that.$check_event_bind('custom_select', {
click: {
type: 'custom_select',
children: '.bt_select_value',
},
});
that.$check_event_bind('custom_select_item', {
click: {
type: 'custom_select_item',
children: 'li.item',
},
});
that.$check_event_bind('icon_trem_close', {
click: {
type: 'icon_trem_close',
children: '.icon-trem-close',
},
});
break;
case 'secondaryMenu': //下拉二级菜单
html += that.$reader_secondaryMenu(item, style, attribute, index);
that.$check_event_bind('secondary_menu_parent', {
'mouseover click': {
type: 'secondary_menu_parent',
children: '.item-parent',
},
});
that.$check_event_bind('secondary_menu_child', {
click: {
type: 'secondary_menu_child',
children: '.item-child',
},
});
break;
case 'select':
html += that.$reader_select(item, style, attribute, index);
that.$check_event_bind('custom_select', {
click: {
type: 'custom_select',
children: '.bt_select_value',
},
});
that.$check_event_bind('custom_select_item', {
click: {
type: 'custom_select_item',
children: 'li.item',
},
});
break;
case 'link':
eventName = 'event_link_' + that.random + '_' + item.name;
html += '
' + item.title + '';
that.$check_event_bind(eventName, {
click: {
type: 'link_event',
event: item.event,
},
});
break;
case 'button':
html +=
// '
';
break;
case 'help':
var _html = '';
$.each(item.list, function (index, items) {
_html += '
' + items + '';
});
html += '
';
break;
case 'other':
html += item.boxcontent;
}
html += item.unit ? '
' + item.unit + '' : '';
html += item.suffix ? '
' + item.suffix + '' : '';
html += '
';
return html;
},
/**
* @descripttion 检测检测名称
* @param {string} eventName 配置
* @param {object} config 事件配置
*/
$check_event_bind: function (eventName, config) {
if (!this.event_list[eventName]) {
if (!this.event_list.hasOwnProperty(eventName)) {
this.event_list[eventName] = config;
}
}
},
/**
* @description 创建事件配置
* @param {object} item 行内配置
* @return {object} 配置信息
*/
$create_event_config: function (item) {
var config = {};
if (typeof item['name'] === 'undefined') return {};
$.each(this.event_type, function (key, items) {
if (item[items]) {
config[items === 'event' ? 'click' : items] = {
type: item.type,
event: item[items],
cust: ['select', 'checkbox', 'radio'].indexOf(item.type) > -1,
config: item,
};
}
});
return config;
},
/**
* @description 渲染样式
* @param {object|string} data 样式配置
* @return {string} 样式
*/
$reader_style: function (data) {
var style = '';
if (typeof data === 'string') return data;
if (typeof data === 'undefined') return '';
$.each(data, function (key, item) {
style += key + ':' + item + ';';
});
return style;
},
/**
* @descripttion 局部刷新form表单元素
* @param {String} name 需要刷新的元素
* @param {String} name 元素新数据
* @return: viod
*/
$local_refresh: function (name, config) {
var formFind = this.element.find('[data-name=' + name + ']');
if (this.element.find('[data-name=' + name + ']').length === 0) formFind = this.element.find('[name=' + name + ']');
formFind.parent().replaceWith(this.$reader_form_find(config));
},
/**
* @description 渲染下拉,内容方法
*/
$reader_select: function (item, style, attribute, index) {
var that = this,
list = '',
option = '',
active = {};
if (typeof item.list === 'function') {
var event = item.list;
event.call(this, this.config.form);
item.list = [];
}
if (!Array.isArray(item.list)) {
var config = item.list;
bt_tools.send(
{
url: config.url,
data: config.param || config.data || {},
},
function (res) {
if (res.status !== false) {
var list = item.list.dataFilter ? item.list.dataFilter(res, that) : res;
if (item.list.success) item.list.success(res, that, that.config.form[index], list);
item.list = list;
if (!item.list.length) {
item.disabled = true;
layer.msg(item.placeholder || '数据获取为空', { icon: 2 });
}
that.$replace_render_content(index);
} else {
bt.msg(res);
}
}
);
return false;
}
if (typeof that.data[item.name] === 'undefined') active = item.list[0];
$.each(item.list, function (key, items) {
if (items.value === item.value || items.value === that.data[item.name]) {
active = items;
return false;
}
});
$.each(item.list, function (key, items) {
list += '