',
success: function () {
if (length > 4) _that.$fixed_table_thead('.fiexd_thead');
}
});
},
/**
* @description 固定表头
* @param {string} el DOM选择器
* @return void
*/
$fixed_table_thead: function (el) {
$(el).scroll(function () {
var scrollTop = this.scrollTop;
this.querySelector('thead').style.transform = 'translateY(' + (scrollTop-1) + 'px)';
});
},
/**
* @description 删除行内数据
*/
$delete_table_row: function (index) {
this.data.splice(index, 1)
this.$reader_content(this.data);
},
/**
* @description 设置批量操作显示
* @return void 无
*/
$set_batch_view: function () {
if (typeof this.config.batch != "undefined") { //判断是否存在批量操作
var bt_select_btn = $(this.config.el + ' .set_batch_option');
if (typeof this.config.batch.config != "undefined") { // 判断批量操作是多个还是单个
if (this.checkbox_list.length > 0) {
bt_select_btn.removeClass('bt-disabled btn-default').addClass('btn-success').text(lan['public'].please_choose + this.batch_active.title + '(' + lan['public'].selected + this.checkbox_list.length + ')')
} else {
bt_select_btn.addClass('bt-disabled btn-default').removeClass('btn-success').text(lan['public'].please_choose + this.batch_active.title);
}
} else {
var bt_select_val = $(this.config.el + ' .bt_table_select_group .bt_select_value');
if (this.checkbox_list.length > 0) {
bt_select_btn.removeClass('bt-disabled btn-default').addClass('btn-success').prev().removeClass('bt-disabled');
bt_select_val.find('em').html('(' + lan['public'].selected + this.checkbox_list.length + ')');
} else {
bt_select_btn.addClass('bt-disabled btn-default').removeClass('btn-success').prev().addClass('bt-disabled');
bt_select_val.children().eq(0).html(lan['public'].please_choose + '');
bt_select_val.next().find('li').removeClass('active');
this.batch_active = {};
}
}
}
},
/**
* @description 渲染指定类型列内容
* @param {object} data 渲染的数据
* @param {object} rows 渲染的模板
* @return void
*/
$reader_column_type: function (item, rows) {
var value = rows[item.fid], event_list = {}, className = 'click_' + item.fid + '_' + this.random,
config = [], _that = this;
switch (item.type) {
case 'text': //普通文本
config = [value, event_list];
break;
case 'checkbox': //单选内容
config = ['', event_list];
break;
case 'password':
var _copy = '',
_eye_open = '',
className = 'ico_' + _that.random + '_',
html = '**********'
if (item.eye_open) {
html += '';
if (!event_list[className + 'eye_open']) event_list[className + 'eye_open'] = {
type: 'eye_open_password'
};
}
if (item.copy) {
html += ''
if (!event_list[className + 'copy']) event_list[className + 'copy'] = {
type: 'copy_password'
};
}
config = [html, event_list];
break;
case 'link': //超链接类型
className += '_' + item.fid
if (!event_list[className] && item.event) event_list[className] = {
event: item.event,
type: 'rows'
};
config = ['' + value + '', event_list];
break;
case 'input': //可编辑类型
blurName = 'blur_' + item.fid + '_' + this.random;
keyupName = 'keyup_' + item.fid + '_' + this.random;
if (!event_list[blurName] && item.blur) event_list[blurName] = {
event: item.blur,
eventType: 'blur',
type: 'rows'
};
if (!event_list[keyupName] && item.keyup) event_list[keyupName] = {
event: item.keyup,
eventType: 'keyup',
type: 'rows'
};
config = ['', event_list];
break;
case 'status': // 状态类型
var active = '';
$.each(item.config.list, function (index, items) {
if (items[0] === value) active = items;
});
if (!event_list[className] && item.event) event_list[className] = {
event: item.event,
type: 'rows'
};
config = ['' + active[1] + '' + (item.config.icon ? '' : '') + '', event_list];
break;
case 'switch': //开关类型
var active = '', _random = bt.get_random(5);
active = new Number(value) == true ? 'checked' : ''
if (!event_list[className] && item.event) event_list[className] = {
event: item.event,
type: 'rows'
};
config = ['', event_list];
break;
case 'group':
var _html = '';
$.each(item.group, function (index, items) {
className = (item.fid ? item.fid : 'group') + '_' + index + '_' + _that.random;
var _hide = false;
if (items.template) {
var _template = items.template(rows, _that),
$template = $(_template);
if ($template.length > 0) {
_html += $template.addClass(className)[0].outerHTML
} else {
_html += '' + _template + '';
}
} else {
if (typeof items.hide != "undefined") {
_hide = typeof items.hide === "boolean" ? items.hide : items.hide(rows);
if (typeof _hide != "boolean") return false;
}
_html += '' + items.title + '';
}
//当前操作按钮长度等于当前所以值时不向后添加分割
if (!_hide) _html += ((item.group.length == (index + 1)) ? '' : ' | ')
if (!event_list[className] && items.event) event_list[className] = {
event: items.event,
type: 'rows'
};
});
config = [_html, event_list];
break;
default:
config = [value, event_list];
break;
}
return config;
},
/**
* @description 批量执行程序
* @param {object} config 配置文件
* @return void
*/
$batch_success_table: function (config) {
that.$batch_success_table(config);
},
/**
* @description 渲染工具条
* @param {object} data 配置参数
* @return void
*/
$reader_tootls: function (config) {
var _that = this, event_list = {};
/**
* @description 请求方法
* @param {Function} callback 回调函数
* @returns void
*/
function request(active, check_list) {
var loadT = bt.load(active.title + lan.site.executing),
batch_config = {},
list = _that.$get_data_batch_list(active.paramId, check_list);
if (!active.beforeRequest) {
batch_config[active.paramName] = list.join(',');
} else {
batch_config[active.paramName] = active.beforeRequest(check_list);
}
bt_tools.send({
url: active.url || _that.config.batch.url,
data: $.extend(active.param || {}, batch_config)
}, function (res) {
loadT.close();
if (res.status === false && typeof res.success === "undefined") {
bt_tools.msg(res);
return false;
}
if (typeof active.tips === 'undefined' || active.tips) {
var html = '';
$.each(res.error, function (key, item) {
html += '
' + key + '
' + item + '
';
});
$.each(res.success, function (index, item) {
html += '
' + item + '
' + lan['public'].success + '
';
});
_that.$batch_success_table({
title: active.title,
th: active.theadName,
html: html
});
if (active.refresh) _that.$refresh_table_list(true);
} else {
if (!active.success) {
var html = '';
$.each(check_list, function (index, item) {
html += '