\
-
'+lan.site.category_manager+' \
+ $.each(item.list, function (index, items) {
+ var _btn = item.type + '_' + _that.random + '_' + index,
+ html = '';
+ if (items.type == 'division') {
+ template += '
';
+ } else {
+ if (!items.group) {
+ template += '
' + (items.icon ? ' ' : '') + '' + items.title + ' ';
+ } else {
+ template += '
\
+ '+lan.site.category_manager+' \
\
'
- if(item.list){
- $.each(item.list,function(index,items){
- html += '
'+ items[item.key] +' ';
- });
+ if (item.list) {
+ $.each(item.list, function (index, items) {
+ html += '
' + items[item.key] + ' ';
+ });
+ }
+ if (items.init) setTimeout(function () {
+ items.init(_btn)
+ }, 400);
}
- if(items.init) setTimeout(function(){ items.init(_btn) },400);
}
- if(!event_list[_btn]) event_list[_btn] = {event:items.event,type:'button'};
+ if (!event_list[_btn]) event_list[_btn] = {
+ event: items.event,
+ type: 'button'
+ };
});
break;
case 'search':
this.config.search = item;
- var _input = 'search_input_'+this.random,_btn = 'search_btn_'+ this.random;
- template = '
';
- if(!event_list[_input]) event_list[_input] = {eventType:'keyup',type:'search_input'};
- if(!event_list[_btn]) event_list[_btn] = {type:'search_btn'};
+ var _input = 'search_input_' + this.random,
+ _focus = 'search_focus_' + this.random,
+ _btn = 'search_btn_' + this.random;
+ template = '
';
+ if (!event_list[_input]) event_list[_input] = {
+ eventType: 'keyup',
+ type: 'search_input'
+ };
+ if (!event_list[_focus]) event_list[_focus] = {
+ type: 'search_focus',
+ eventType: 'focus'
+ };
+ if (!event_list[_btn]) event_list[_btn] = {
+ type: 'search_btn'
+ };
break;
case 'batch':
this.config.batch = item;
- var batch_list = [],_html = '',active = item.config;
- if(typeof item.config != 'undefined'){
+ var batch_list = [],
+ _html = '',
+ active = item.config;
+ if (typeof item.config != 'undefined') {
_that.batch_active = active;
- $(_that.config.el).on('click','.set_batch_option',function(e){
- var check_list =[];
- for(var i=0;i<_that.checkbox_list.length;i++){
+ $(_that.config.el).on('click', '.set_batch_option', function (e) {
+ var check_list = [];
+ for (var i = 0; i < _that.checkbox_list.length; i++) {
check_list.push(_that.data[_that.checkbox_list[i]]);
}
- if($(this).hasClass('bt-disabled')){
- layer.tips(_that.config.batch.disabledTips || 'Select batch operation',$(this),{tips: [1,'red'],time: 2000});
+ if ($(this).hasClass('bt-disabled')) {
+ layer.tips(_that.config.batch.disabledTips || 'Select batch operation', $(this), {
+ tips: [1, 'red'],
+ time: 2000
+ });
return false;
}
- switch(typeof active.confirm){
+ switch (typeof active.confirm) {
case 'function':
- active.confirm(active,function(param,callback){
- active.param = $.extend(active.param,param);
- execute_batch(active,check_list,callback);
+ active.confirm(active, function (param, callback) {
+ active.param = $.extend(active.param, param);
+ execute_batch(active, check_list, callback);
});
break;
case 'undefined':
- execute_batch(active,check_list);
+ execute_batch(active, check_list);
break;
case 'object':
var config = active.confirm;
bt.open({
- title:config.title || 'Batch execute',
- area:config.area || '350px',
- btn:config.btn || ['Confirm','Cancel'],
- content:config.content,
- success:function(layero,index){
- config.success(layero,index,active);
+ title: config.title || 'Batch execute',
+ area: config.area || '350px',
+ btn: config.btn || ['Confirm', 'Cancel'],
+ content: config.content,
+ success: function (layero, index) {
+ config.success(layero, index, active);
},
- yes:function(index,layero){
- config.yes(index,layero,function(param,callback){
- active.param = $.extend(active.param,param);
- request(active,check_list);
+ yes: function (index, layero) {
+ config.yes(index, layero, function (param, callback) {
+ active.param = $.extend(active.param, param);
+ request(active, check_list);
});
}
});
break;
}
});
- }else{
- $.each(item.selectList,function(index,items){
- if(items.group){
- $.each(items.group,function(indexs,itemss){
- batch_list.push($.extend({},items,itemss));
- _html += '
'+ itemss.title +' ';
+ } else {
+ $.each(item.selectList, function (index, items) {
+ if (items.group) {
+ $.each(items.group, function (indexs, itemss) {
+ batch_list.push($.extend({}, items, itemss));
+ _html += '
' + itemss.title + ' ';
});
delete items.group;
- }else {
+ } else {
batch_list.push(items);
- _html += '
'+ items.title +' ';
+ _html += '
' + items.title + ' ';
}
});
// 打开批量类型列表
- $(_that.config.el).on('click','.bt_table_select_group .bt_select_value',function(e){
- var _this = this,$parent = $(this).parent(),bt_selects = $parent.find('.bt_selects'),area = $parent.offset(),_win_area = _that.$get_win_area();
- if($parent.hasClass('bt-disabled')){
- layer.tips(_that.config.batch.disabledSelectValue,$parent,{tips: [1,'red'],time: 2000})
+ $(_that.config.el).unbind().on('click', '.bt_table_select_group .bt_select_value', function (e) {
+ var _this = this, $parent = $(this).parent(),bt_selects = $parent.find('.bt_selects'),area = $parent.offset(),_win_area = _that.$get_win_area();
+ if ($parent.hasClass('bt-disabled')) {
+ layer.tips(_that.config.batch.disabledSelectValue, $parent,{tips: [1, 'red'],time: 2000})
return false;
}
- if($parent.hasClass('active')){
+ if ($parent.hasClass('active')) {
$parent.removeClass('active');
- }else{
+ } else {
$parent.addClass('active');
}
- if(bt_selects.height() > (_win_area[1] - area.top)){
+ if (bt_selects.height() > (_win_area[1] - area.top)) {
bt_selects.addClass('top');
- }else{
+ } else {
bt_selects.removeClass('top');
}
- $(document).one('click',function(){
+ $(document).one('click', function () {
$(_that.config.el).find('.bt_table_select_group').removeClass('active');
return false;
});
return false;
});
// 选择批量的类型
- $(_that.config.el).on('click','.bt_table_select_group .item',function(e){
- var _text = $(this).text(),_index = $(this).index();
+ $(_that.config.el).on('click', '.bt_table_select_group .item', function (e) {
+ var _text = $(this).text(),
+ _index = $(this).index();
$(this).addClass('active').siblings().removeClass('active');
- $(_that.config.el +' .bt_select_tips').html(_text + lan['public'].in_bulk+'
('+lan.site.have_been_selected+ _that.checkbox_list.length +') ');
+ $(_that.config.el + ' .bt_select_tips').html('Batch execute' + _text + '
('+lan.site.have_been_selected + _that.checkbox_list.length + ') ');
_that.batch_active = batch_list[_index];
- if(!_that.checked) $('.bt_table_select_group').removeClass('active');
+ if (!_that.checked) $('.bt_table_select_group').removeClass('active');
});
// 执行批量操作
- $(_that.config.el).on('click','.set_batch_option',function(e){
- var check_list = [],active = _that.batch_active;
- if($(this).hasClass('bt-disabled')){
- layer.tips(_that.config.batch.disabledSelectValue,$(this),{tips: [1,'red'],time: 2000});
+ $(_that.config.el).on('click', '.set_batch_option', function (e) {
+ var check_list = [],
+ active = _that.batch_active;
+ if ($(this).hasClass('bt-disabled')) {
+ layer.tips(_that.config.batch.disabledSelectValue, $(this), {
+ tips: [1, 'red'],
+ time: 2000
+ });
return false;
}
- for(var i=0;i<_that.checkbox_list.length;i++){
+ for (var i = 0; i < _that.checkbox_list.length; i++) {
check_list.push(_that.data[_that.checkbox_list[i]]);
}
- if(JSON.stringify(active) === '{}'){
+ if (JSON.stringify(active) === '{}') {
var bt_table_select_group = $(_that.config.el + ' .bt_table_select_group');
- layer.tips(lan['public'].select_opt_type,bt_table_select_group,{tips:[1,'red'],time: 2000});
- bt_table_select_group.css('border','1px solid red');
- setTimeout(function(){
+ layer.tips(lan['public'].select_opt_type, bt_table_select_group, {
+ tips: [1, 'red'],
+ time: 2000
+ });
+ bt_table_select_group.css('border', '1px solid red');
+ setTimeout(function () {
bt_table_select_group.removeAttr('style');
- },2000);
+ }, 2000);
return false;
}
- switch(typeof active.confirm){
+ switch (typeof active.confirm) {
case 'function':
- active.confirm(active,function(param,callback){
- active.param = $.extend(active.param,param);
- execute_batch(active,check_list,callback);
+ active.confirm(active, function (param, callback) {
+ active.param = $.extend(active.param, param);
+ execute_batch(active, check_list, callback);
});
break;
case 'undefined':
- execute_batch(active,check_list);
+ execute_batch(active, check_list);
break;
case 'object':
var config = active.confirm;
bt.open({
- title:config.title || lan['public'].bulk_opt,
- area:config.area || '350px',
- btn:config.btn || [lan['public'].confirm,lan['public'].cancel],
- content:config.content,
- success:function(layero,index){
- config.success(layero,index,active);
+ title: config.title || lan['public'].bulk_opt,
+ area: config.area || '350px',
+ btn: config.btn || [lan['public'].confirm,lan['public'].cancel],
+ content: config.content,
+ success: function (layero, index) {
+ config.success(layero, index, active);
},
- yes:function(index,layero){
- config.yes(index,layero,function(param,callback){
- active.param = $.extend(active.param,param);
- request(active,check_list);
+ yes: function (index, layero) {
+ config.yes(index, layero, function (param, callback) {
+ active.param = $.extend(active.param, param);
+ request(active, check_list);
});
}
});
@@ -625,89 +758,46 @@ var bt_tools = {
}
});
}
- // template = '
';
- template = '
'+ (typeof item.config != 'undefined'?'
'+ item.config.title +' ':'
'+lan['public'].select_opt_type+' '+ item.buttonValue +' ') +'
';
+ template = '
' + (typeof item.config != 'undefined' ? '
Batch' + item.config.title + ' ' : '
'+lan['public'].select_opt_type+' ' + item.buttonValue + ' ') + '
';
break;
- // case 'batch_btn':
- // _that.batch = item;
- // $(_that.config.el).on('click','.set_batch_option',function(e){
- // var check_list = [],active = {},index = $(this).index()-1;
- // _that.batch_active = _that.batch.selectList[index];
- // active = _that.batch_active;
- // if($(this).hasClass('bt-disabled')){
- // layer.tips(_that.batch.disabledSelectValue,$(this),{tips: [1,'red'],time: 2000});
- // return false;
- // }
- // for(var i=0;i<_that.checkbox_list.length;i++){
- // check_list.push(_that.data[_that.checkbox_list[i]]);
- // }
- // switch(typeof active.confirm){
- // case 'function':
- // active.confirm(active,function(param,callback){
- // active.param = $.extend(active.param,param);
- // execute_batch(active,check_list,callback);
- // });
- // break;
- // case 'undefined':
- // execute_batch(active,check_list);
- // break;
- // case 'object':
- // var config = active.confirm;
- // bt.open({
- // title:config.title || lan['public'].exec,
- // area:config.area || '350px',
- // btn:config.btn || [lan['public'].confirm,lan['public'].cancel],
- // content:config.content,
- // success:function(layero,index){
- // config.success(layero,index,active);
- // },
- // yes:function(index,layero){
- // config.yes(index,layero,function(param,callback){
- // active.param = $.extend(active.param,param);
- // request(active,check_list);
- // });
- // }
- // });
- // break;
- // }
- // });
- // template = '
'+lan['public'].exec+'
';
- // break;
case 'page':
this.config.page = item;
- var pageNumber = bt.get_cookie(this.config.cookiePrefix+'_'+ this.config.page.numberParam);
- if(this.config.cookiePrefix && pageNumber) this.config.page.number = pageNumber;
- template = this.$reader_page(this.config.page,'
1 '+lan.public_backup.total+'
');
- break;
+ var pageNumber = bt.get_cookie('page_number');
+ if (this.config.cookiePrefix && pageNumber) this.config.page.number = pageNumber;
+ template = this.$reader_page(this.config.page,'
1 '+lan.public_backup.total+'
');
+ break;
}
- if(template){
- var tools_group = $(_that.config.el + ' .tootls_'+ item.positon[1]);
- if(tools_group.length){
- var tools_item = tools_group.find('.pull-'+ item.positon[0]);
+ if (template) {
+ var tools_group = $(_that.config.el + ' .tootls_' + item.positon[1]);
+ if (tools_group.length) {
+ var tools_item = tools_group.find('.pull-' + item.positon[0]);
tools_item.append(template);
- }else{
- var tools_group_elment = '
'+ (item.positon[0]=='left'?template:'') +'
'+ (item.positon[0]=='right'?template:'') +'
';
- if(item.positon[1] === 'top'){
+ } else {
+ var tools_group_elment = '
' + (item.positon[0] == 'left' ? template : '') + '
' + (item.positon[0] == 'right' ? template : '') + '
';
+ if (item.positon[1] === 'top') {
$(_that.config.el).append(tools_group_elment);
- if($(_that.config.el +' .divtable').length === 0) $(_that.config.el).append('
');
- }else{
- if($(_that.config.el +' .divtable').length === 0) $(_that.config.el).append('
');
+ if ($(_that.config.el + ' .divtable').length === 0) $(_that.config.el).append('
');
+ } else {
+ if ($(_that.config.el + ' .divtable').length === 0) $(_that.config.el).append('
');
$(_that.config.el).append(tools_group_elment);
}
}
}
}
- if(!this.init) this.$event_bind(event_list);
+ if (!this.init) this.$event_bind(event_list);
},
+ $clear_table_checkbox:function(){
+ $(this.config.el).find('.bt_table .cust—checkbox').removeClass('selected active');
+ },
/**
* @description 获取数据批量列表
* @param {string} 需要获取的字段
* @return {array} 当前需要批量列表
*/
- $get_data_batch_list:function(fid,data){
+ $get_data_batch_list: function (fid, data) {
var arry = [];
- $.each(data || this.data,function(index,item){
+ $.each(data || this.data, function (index, item) {
arry.push(item[fid])
});
return arry;
@@ -718,688 +808,41 @@ var bt_tools = {
* @param {object} config 配置文件
* @param {object} page 分页
* @return void
- */
- $reader_page:function(config,page){
- var _that = this,$page = $(page),template = '',eventList = {};
- $page.find('a').addClass('page_link_'+ this.random);
+ */
+ $reader_page:function (config,page){
+ if(typeof page === 'number'){
+ page = this.$custom_page(page);
+ }
+ var _that = this,$page = $(page), template = '', eventList = {};
+ $page.find('a').addClass('page_link_' + this.random);
template += $page.html();
- if(config.numberStatus){
- var className = 'page_select_'+ this.random;
- template += '
';
- $.each(config.numberList,function(index,item){
- template+= ''+ item +lan.site.items_page+' ';
+ if (config.numberStatus) {
+ var className = 'page_select_' + this.random,number = bt.get_cookie('page_number');
+ template += '';
+ $.each(config.numberList, function(index, item) {
+ template += '' + item + lan.site.items_page+' ';
});
template += ' ';
- eventList[className] = {eventType:"change",type:'page_select'};
+ eventList[className] = {eventType: "change",type: 'page_select'};
}
- if(config.jump){
- var inputName = 'page_jump_input-'+ this.random;
- var btnName = 'page_jump_btn_'+ this.random;
- template += ''+lan['public'].jump_to_page+' '+lan['public'].confirm+'
'
- eventList[inputName] = {eventType:'keyup',type:'page_jump_input'};
- eventList[btnName] = {type:'page_jump_btn'};
+ if (config.jump) {
+ var inputName = 'page_jump_input_' + this.random;
+ var btnName = 'page_jump_btn_' + this.random;
+ template += ''+lan['public'].jump_to_page+' '+lan['public'].confirm+'
'
+ eventList[inputName] = {
+ eventType: 'keyup',
+ type: 'page_jump_input'
+ };
+ eventList[btnName] = {
+ type: 'page_jump_btn'
+ };
}
- eventList['page_link_'+ this.random] = {type:'cut_page_number'};
- _that.config.page.total = parseInt($page.find('.Pcount').html().match(/([0-9]*)/g)[1]);
+ eventList['page_link_' + this.random] = {
+ type: 'cut_page_number'
+ };
+ _that.config.page.total = $page.length == 0?0:(typeof page == "number"?page:parseInt($page.find('.Pcount').html().match(/([0-9]*)/g)[1]));
_that.$event_bind(eventList);
- return ''+ template +'
';
- },
-
- /**
- * @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 = [];
- switch(item.type){
- case 'rows':
- _that.event_rows_model = {
- el:$(this),
- model:_that.config.column[$(this).parents('td').index()],
- 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();
- _that.config.search.value = val;
- _search.append(''+ val +'
');
- _that.$refresh_table_list(true);
- break;
- case 'page_select':
- var limit = parseInt($(this).val());
- _that.config.page.number = limit;
- _that.config.page.page = 1;
- _that.$refresh_table_list(true);
- return false;
- break;
- case 'page_jump_input':
- if(ev.keyCode == 13){
- $(_that.config.el +' .page_jump_btn_'+ _that.random).click();
- $(this).focus();
- }
- return false;
- break;
- case 'page_jump_btn':
- var jump_page = parseInt($(_that.config.el +' .page_jump_input-'+ _that.random).val()),max_number = Math.ceil(_that.config.page.total/ _that.config.page.number);
- if(jump_page > max_number) jump_page = _that.config.page.page;
- _that.config.page.page = jump_page;
- _that.$refresh_table_list(true);
- break;
- case 'cut_page_number':
- var page = parseInt($(this).attr('href').match(/([0-9]*)$/)[0])
- _that.config.page.page = page;
- _that.$refresh_table_list(true);
- return false;
- break;
- case 'eye_open_password':
- if($(this).hasClass('glyphicon-eye-open')){
- $(this).addClass('glyphicon-eye-close').removeClass('glyphicon-eye-open');
- $(this).prev().text(_that.data[index].password);
- }else{
- $(this).addClass('glyphicon-eye-open').removeClass('glyphicon-eye-close');
- $(this).prev().html('********** ');
- }
- return false;
- break;
- case 'copy_password':
- bt.pub.copy_pass(_that.data[index].password);
- return false;
- break;
- }
- if(item.event) item.event.apply(this,arry);
- });
- });
- },
-
- /**
- * @description 样式绑定
- * @param {array} style_list 样式列表
- * @return void
- */
- $style_bind:function(style_list,status){
- var str = '',_that = this;
- $.each(style_list,function(index,item){
- if(item.css != ''){
- if(!item.className){
- str += _that.config.el +' thead th:nth-child('+ (item.index + 1) +'),'+ _that.config.el+' tbody tr td:nth-child'+ (item.span?' span':'') +'('+ (item.index + 1) +'){'+ item.css +'}'
- }else{
- str += item.className + '{'+ item.css +'}';
- }
- }
- });
- if($('#bt_table_'+ _that.random ).length == 0) $(_that.config.el).append('');
- },
-
- /**
- * @deprecated 获取WIN高度或宽度
- * @returns 返回当期的宽度和高度
- */
- $get_win_area:function(){
- return [window.innerWidth,window.innerHeight];
- },
-
- /**
- * @description 请求数据,
- * @param {object} param 参数和请求路径
- * @return void
- */
- $http:function(success){
- var param = {},config = this.config,_page = config.page,_search = config.search,_sort = config.sort || {};
- if(_page){
- param[_page.numberParam] = _page.number,param[_page.pageParam] = _page.page;
- if(this.config.cookiePrefix) bt.set_cookie(this.config.cookiePrefix+'_'+ _page.numberParam,_page.number);
- }
- if(_search) param[_search.searchParam] = _search.value;
- if(this.config.beforeRequest) config.param = this.config.beforeRequest(config.param);
- bt_tools.send({
- url:config.url,
- data:$.extend(config.param,param,_sort),
- },function(res){
- if(config.dataFilter){
- var data = config.dataFilter(res);
- if(success) success(data.data,data.page);
- }else {
- if(success) success(res.data,res.page);
- }
- });
- }
- }
- return new ReaderTable(config);
- },
- /**
- * @description 选择文件目录
- * @param {object|string} data 当前 {path:[string] 选择路径,title:[string] title标题,ext:[array]限制的文件类型},或选择目录地址,可以为空,为空这默认使用当前目录作为选择目录
- * @param {function} 回调函数,选择完成后的操作
- * @return void
- */
- select_file:function(data,callback){
- if(typeof data === 'string') data = {path:data,type:2,title:lan['public'].select_fileordir,ext:[],limit:''};
- if(typeof data === 'function') type = callback,callback = data,data = {path:bt.get_cookie('Path')};
- if(typeof type !== 'number') type = 0;
- var that = this,select_file = {
- type:type,
- type_tips:type == 0?lan['public'].dir:(type == 1?lan.site.file:lan['public'].fileordir),
- select_list:[],
- select_path:bt.get_cookie('Path') || (bt.os == 'Windows'?setup_path:'/www/wwwroot'),
- select_config:{},
- scroll_width:0,
- reader_view:function(){
- var _this = this;
- this.scroll_width = select_file.getScrollbarWidth();
- layer.open({
- type:1,
- title: data.title || (lan['public'].select + _this.type_tips),
- shadeClose:false,
- closeBtn:1,
- area:['650px','550px'],
- content:'
'+lan.bt.adddir+'
'+lan['public'].name+' '+lan['public'].modify_time+' '+lan.site.redirect_type+'
选择'+ _this.type_tips +' 取消
',
- success:function(){
- _this.evnet_bind();
- _this.render_file_list(function(){
- _this.set_path_width();
- });
- $('.select_list_thaed').css('right',_this.scroll_width+'px');
- }
- });
- },
- /**
- * @description 事件绑定
- */
- evnet_bind:function(){
- var _this = this;
- $('#select_dir_list').on('click','tr',function(){
- var index = $(this).data('index');
- $(this).addClass('active').siblings().removeClass('active');
- $('[name="select_name"]').val(_this.select_list[index].filename);
- });
- $('.select_list_body').on('scroll',function(e){
- var top = $(this).scrollTop(),left = $(this).scrollLeft();
- if(top > 0){
- $('.select_list_shadow').show();
- }else{
- $('.select_list_shadow').hide();
- }
- if(left >= 0){
- $('.select_list_thaed').css('left',(4-left ) +'px');
- }
- e.stopPropagation();
- e.preventDefault();
- });
- $('.file_path_refresh').on('click',function(){
- _this.render_file_list();
- });
- $('.select_dir_list thead th .icon-drag').on('mousedown',function(ev){
- var x = ev.clientX,th = $(this).parent(),th_index = th.index(),th_width = th[0].clientWidth,min_width = parseInt($(this).parent().attr('data-min')),timeOut = null;
- if(ev.which === 1){
- var document_mousemove = function(e){
- var move_x = e.clientX,offset_x = move_x - x,_width = th_width + offset_x;
- timeOut = setTimeout(function(){
- _this.set_select_width(th_index,'width:'+_width+'px');
- },0);
- },
- document_mouseup = function(){
- $(this).unbind(document_mousemove);
- $(this).unbind(document_mouseup);
- };
- $(document).on('mousemove',document_mousemove).one('mouseup',function(){
- $(this).unbind(document_mousemove);
- $(this).unbind(this);
- })
- }
- ev.stopPropagation();
- });
- $('.select_dir_list thead th>span').on('click',function(ev){
- var th = $(this).parent(),type = th.data('type'),is_active = th.hasClass('active'),is_sort = th.hasClass('sort');
- if(is_active){
- th.addClass('sort').removeClass('active');
- }else if(is_sort){
- th.addClass('active').removeClass('sort');
- }else{
- th.addClass('active');
- }
- th.siblings().removeClass('active sort');
- _this.render_file_list({sort:type,reverse:is_active?1:0});
- ev.stopPropagation();
- });
- $('.search_path_views input').on('keyup',function(){
- var val = $(this).val();
- });
- },
- /**
- * @description 设置当前路径宽度
- * @param {}
- */
- set_path_width:function(width){
- var _width = 0,_dir_view = $('.file_dir_view')[0].offsetWidth,_item = $('.file_dir_view .file_dir_item'),_arry = [],_width =0;
- $('.file_dir_view .file_dir_item').each(function(){
- _arry.push($(this)[0].offsetWidth);
- });
- var arry = _arry.reverse();
- for(var i=0;i -1?('本地磁盘('+ item.path.match(/[A-Z]+/)[0])+ ':)':item.path)
- mount_html += ''+
- ' '+
- ''+ name +' '+
- '
';
- });
- $.each(arry,function(index,item){
- var mtime = bt.format_data(item.mtime),type = (item.type == 'dir'?'文件夹':'文件');
- dir_html += '\
- '+ item.filename +' \
- '+ mtime +' \
- '+ (item.type == 'dir'?'文件夹':'文件') +' \
- ';
- });
- $('#select_mount_list').html(mount_html);
- $('#select_dir_list').html(dir_html);
- if(callback) callback(rdata);
- });
- },
- /**
- * @description 渲染路径列表
- * @param {Function} callback 回调函数
- * @return void
- */
- render_path_list:function(path,callback){
- var html = '', path_before = '',dir_list = path.split("/").splice(1),first_dir = path.split("/")[0];
- if(bt.os === 'Windows'){
- if(dir_list.length == 0) dir_list = [];
- dir_list.unshift('本地磁盘('+ first_dir +') ');
- }else{
- if(path == '/') dir_list = [];
- dir_list.unshift('根目录');
- }
- for(var i = 0; i < dir_list.length; i++){
- path_before += '/' + dir_list[i];
- if (i == 0) path_before = '';
- html += '\
-
' + dir_list[i] + ' \
-
\
-
\
-
';
- }
- $('.path_input').val('').attr('data-path',path);
- var file_dir_view = $('#select_file_directory .file_path_input .file_dir_view');
- file_dir_view.html(html);
- if(callback) callback(path);
- },
-
- /**
- * @description 设置标题宽度
- * @param {string} th_index 表头序列号
- * @param {string} style class样式
- */
- set_select_width:function(th_index,style){
- var _this = this,className = '.select_dir_list tbody td:nth-child('+ (th_index+1) +')>span,.select_dir_list thead th:nth-child('+ (th_index+1) +')>span',style_index = $('#th-index-'+th_index);
- if(style_index.length > 0){
- style_index.html(className +'{'+ style +'}');
- }else{
- $('#select_file_style').append('');
- }
- },
- /**
- * @description 样式转换文件样式
- * @param {string} style 样式
- */
- cut_style_object:function(style){
- var object = {},arry = style.split(';');
- return object;
- },
- /**
- * @description 获取滚动条宽度
- */
- getScrollbarWidth:function() {
- var odiv = document.createElement('div'),//创建一个div
- styles = {
- width: '100px',
- height: '100px',
- overflowY: 'scroll'//让他有滚动条
- }, i, scrollbarWidth;
- for (i in styles) odiv.style[i] = styles[i];
- document.body.appendChild(odiv);//把div添加到body中
- scrollbarWidth = odiv.offsetWidth - odiv.clientWidth;//相减
- odiv.remove();//移除创建的div
- return scrollbarWidth;//返回滚动条宽度
- }
- }
- select_file.reader_view();
- },
- /**
- * @description 渲染Form表单
- * @param {*} config
- * @return 当前实例对象
- */
- form: function (config) {
- var _that = this;
- function ReaderForm(config) {
- this.config = config;
- this.data = config.data || {};
- this.$load();
- }
- ReaderForm.prototype = {
- element: null,
- style_list: [], // 样式列表
- event_list: {}, // 事件列表,已绑定事件
- event_type: ['click', 'event', 'focus', 'keyup', 'blur', 'change'],
- hide_list: [],
- form_element: {},
- form_config: {},
- random: bt.get_random(5),
- $load: function () {
- var that = this;
- if (that.el) {
- this.$reader_content(function () {
- that.$event_bind();
- });
- }
- },
-
- /**
- * @description 渲染Form内容
- * @param {Function} callback 回调函数
- */
- $reader_content: function (callback) {
- var that = this,
- html = '',
- _content = '',
- event_list = {};
- $.each(that.config.form, function (index, item) {
- html += that.$reader_content_row(index, item);
- });
- that.element = $('');
- _content = $('
');
- _content.append(that.element);
- if (callback) callback();
- return _content[0].outerHTML;
- },
-
- /**
- * @description 渲染行内容
- * @param {object} data Form数据
- * @param {number} index 下标
- * @return {string} HTML结构
- */
- $reader_content_row: function (index, data) {
- var that = this,help = data.help,labelWidth = this.config.formLabelWidth || data.formLabelWidth;
- return '' +
- (data.label ? '
' + data.label + ' ' : '') +
- '
' +
- that.$reader_form_element(data.group, index) +
- (help ? ('
' + help.list.join('') + '
') : '') +
- '
' +
- '
';
- },
-
- /**
- * @description 渲染form类型
- * @param {object} data 表单数据
- * @param {number} index 下标
- * @return {string} HTML结构
- */
- $reader_form_element: function (data, index) {
- var that = this,html = '';
- if (!Array.isArray(data)) data = [data];
- $.each(data, function (key, item) {
- item.find_index = index;
- html+= that.$reader_form_find(item);
- that.form_config[item.name] = item;
- });
- return html;
- },
- /**
- * @descripttion 渲染单个表单元素
- * @param {Object} item 配置
- * @return: viod
- */
- $reader_form_element:function(data,index){
- var that = this,config = [],html = '',event_list = {};
- if(!Array.isArray(data)) data = [data];
- $.each(data,function(key,item){
- var style = that.$reader_style(item.style) + _that.$verify(item.width,'width','style'),
- attribute = that.$verify_group(item,['name','value','placeholder','disabled','readonly','autofocus','autocomplete','min','max']),
- event_group = that.$create_event_config(item),
- eventName = '';
- html += item.label?''+ item.label +' ':'';
- if(typeof item['name'] !== "undefined") event_list[item.name] = event_group;
- switch(item.type){
- case 'text': // 文本选择
- case 'checkbox': // 复选框
- case 'password': // 密码
- case 'radio': // 单选框
- case 'number': // 数字
- var _event = 'event_'+ item.name +'_'+ that.random,is_checkbox = item.type === 'checkbox'?true:false;
- if(item.type === 'radio'){
- $.each(item.label_tips,function(index,items){
- if(item.block) html += '';
- html += ' ';
- html += ''+ items +' ';
- if(item.block) html += '
';
- })
- }else{
- if(item.block) html += '';
- html += ' ';
- if(item.type == 'checkbox') html += ''+ item.label_tips +' ';
- if(item.block) html += '
';
- that.event_list[_event] = {'click':{event:item.event}}
- }
- if(item.icon){
- html += ' ';
- event_list[item.name+'_icon'] = {'click':{type:'select_path',config:item}};
- }
- break;
- case 'textarea':
- html += '';
- $.each(['blur','focus','input'],function(index,items){
- if(item.tips){
- var added = null;
- switch(items){
- case 'blur':
- added = function(ev,item){
- if($(this).val() === '') $(this).next().show();
- layer.close(item.tips.loadT);
- }
- 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;
- }
- }
- event_list[item.name][items]?(event_list[item.name][items]['added'] = added):(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 +'
';
- event_list[item.name+'_tips'] = {'click':{type:'textarea_tips',config:item}};
- }
- break;
- case 'select':
- html += that.$reader_select(item,style,attribute,index);
- that.event_list['custom_select'] = {'click':{type:'custom_select',children:'.bt_select_value'}};
- that.event_list['custom_select_item'] = {'click':{type:'custom_select_item',children:'li.item'}};
- break;
- case 'link':
- eventName = 'event_' + bt.get_random(6);
- html += ''+ item.title +' ';
- that.event_list[eventName] = {'click':{type:'link_event',event:item.event}}
- break;
- case 'help':
- var _html = '';
- $.each(item.list,function(index,items){
- _html += ''+items +' ';
- })
- html += '';
- break;
- }
- that.form_config[item.name] = item;
- });
- $.extend(that.event_list,event_list);
- return html;
- },
- /**
- * @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 ? true : false),
- config: item
- };
- }
- });
- return config;
+ return '' + template + '
';
},
/**
* @description 渲染样式
@@ -1416,368 +859,1012 @@ var bt_tools = {
return style;
},
/**
- * @descripttion 局部刷新form表单元素
- * @param {String} name 需要刷新的元素
- * @param {String} name 元素新数据
- * @return: viod
- */
- $local_refresh:function(name,config){
- this.element.find('[data-name='+name+']').replaceWith(this.$reader_form_find(config))
- },
- /**
- * @description 渲染下拉,内容方法
- */
- $reader_select: function (item, style, attribute, index) {
- var that = this,
- list = '',
- option = '',
- active = {};
- if (!Array.isArray(item.list)) {
- var config = item.list;
- bt_tools.send({
- url: config.url,
- data: config.param || {}
- }, function (res) {
- if (res.status !== false) {
- item.list = item.list.dataFilter ? item.list.dataFilter(res) : res;
- that.$replace_render_content(index);
- } else {
- bt.msg(res);
- }
- });
+ * @description 自定义分页
+ * @param {}
+ */
+ $custom_page:function(total){
+ var html = '',
+ config = this.config.page,
+ page = Math.ceil(total / config.number),
+ tmpPageIndex = 0;
+ if(config.page > 1 && page > 1){
+ html += '
首页 上一页 ';
}
- $.each(item.list, function (key, items) {
- try{
- if (items.value === item.value) {
- active = items;
- } else {
- active = item.list[0];
- }
- }catch(er){}
- list += '
' + items.title + ' ';
- option += '
' + items.title + ' ';
- });
- if (!active.title && Array.isArray(item.list)) active = item.list[0];
- return '
' +
- '
' + (active.title || 'Getting data...') + ' ' +
- '
' +
- '
' + (option || '') + ' ' +
- '
';
+ 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 += '
下一页 尾页 '),
+ html += '
共' + total + "条 "
},
- /**
- * @description 替换渲染内容
- */
- $replace_render_content: function (index) {
- var that = this,
- config = this.config.form[index];
- $('[data-form=' + that.random + ']').find('.line:eq(' + index + ')').replaceWith(that.$reader_content_row(index, config));
- },
/**
- * @description 事件绑定功能
- * @param {Array} eventList 事件列表
- * @param {Function} callback 回调函数
+ * @deprecated 动态处理合并行内,css样式
+ * @param {object} rows 当前行数据
+ * @return {stinrg} className class类名
* @return void
*/
- $event_bind: function (eventList, callback) {
- var that = this,_event = {};
- that.element = $(typeof eventList === 'object' ? that.element : ('[data-form=' + that.random + ']'));
- if (typeof eventList === 'undefined') _event = that.event_list;
- console.log(_event);
- $.each(_event, function (key, item) {
- if ($.isEmptyObject(item)) return true;
- $.each(item, function (keys, items) {
- var childNode = '';
- if (typeof items.cust === "boolean") {
- childNode = '[' + (items.cust ? 'data-' : '') + 'name=' + key + ']';
- } else {
- childNode = '.' + key;
- }
- (function (items, key) {
- if (items.onEvent === false) {
- switch (items.type) {
- case 'input_checked':
- $(childNode).on(keys != 'event' ? keys : 'click', function (ev) {
- items.event.apply(this, [ev, that]);
- });
- break;
+ $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 = [];
+ switch (item.type) {
+ case 'rows':
+ _that.event_rows_model = {
+ el: $(this),
+ model: _that.config.column[$(this).parents('td').index()],
+ rows: _that.data[index],
+ index: index
}
- return true;
- } else {
- that.element.on(keys != 'event' ? keys : 'click', items.children ? items.children : childNode, function (ev) {
- var form = that.$get_form_element(true), value = that.$get_form_value(), config = that.form_config[key];
- switch (items.type) {
- case 'textarea_tips':
- $(this).hide().prev().focus();
- break;
- case 'custom_select':
- if ($(this).parent().hasClass('bt-disabled')) return false;
- var select_value = $(this).next();
- if (!select_value.hasClass('show')) {
- $('.bt_select_list').removeClass('show');
- select_value.addClass('show');
- } else {
- select_value.removeClass('show');
- }
- $(document).click(function () {
- that.element.find('.bt_select_list').removeClass('show');
- $(this).unbind('click');
- return false;
- });
- return false;
- break;
- case 'custom_select_item':
- config = that.form_config[$(this).parents('.bt_select_updown').attr('data-name')], item_config = config.list[$(this).index()]
- if ($(this).hasClass('disabled')) {
- $(this).parent().removeClass('show');
- if (item_config.tips) layer.msg(item_config.tips, {
- icon: 2
- });
- return true;
- }
- if (!$(this).hasClass('active') && !$(this).hasClass('disabled')) {
- $(this).parent().prev().find('.bt_select_content').text($(this).text());
- $(this).addClass('active').siblings().removeClass('active');
- $(this).parent().next().val(item_config.value.toString());
- $(this).parent().removeClass('show');
- $(this).parent().next().trigger("change");
- }
- break;
- case 'select_path':
- bt.select_path('event_' + $(this).prev().attr('name') + '_' + that.random,items.config.icon.select||"");
- break;
- case 'checkbox':
- var checked = $(this).is(':checked');
- if(checked){
- $(this).prev().addClass('active');
- }else{
- $(this).prev().removeClass('active');
- }
- break;
- }
- if (items.event) items.event.apply(this, [value,form, that, config, ev]); // 事件
- if (items.added) items.added.apply(this, [ev,config,form]);
+ 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'
});
- }
- }(items, key));
+ $('.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();
+ val = val.replace(/\s+/g,"");
+ _search.val(val);
+ _that.config.search.value = val;
+ _search.append('' + val + '
');
+ _that.$refresh_table_list(true);
+ break;
+ case 'page_select':
+ var limit = parseInt($(this).val());
+ bt.set_cookie('page_number',limit);
+ _that.config.page.number = limit;
+ _that.config.page.page = 1;
+ _that.$refresh_table_list(true);
+ return false;
+ break;
+ case 'page_jump_input':
+ if (ev.keyCode === 13) {
+ $(_that.config.el + ' .page_jump_btn_' + _that.random).click();
+ $(this).focus();
+ }
+ return false;
+ break;
+ case 'page_jump_btn':
+ var jump_page = parseInt($(_that.config.el + ' .page_jump_input_' + _that.random).val()),
+ max_number = Math.ceil(_that.config.page.total / _that.config.page.number);
+ if(isNaN(jump_page)) jump_page = 1
+ if (jump_page > max_number) jump_page = _that.config.page.page;
+ _that.config.page.page = jump_page;
+ _that.$refresh_table_list(true);
+ break;
+ case 'cut_page_number':
+ var page = parseInt($(this).attr('href').match(/([0-9]*)$/)[0])
+ _that.config.page.page = page;
+ _that.$refresh_table_list(true);
+ return false;
+ break;
+ case 'eye_open_password':
+ if ($(this).hasClass('glyphicon-eye-open')) {
+ $(this).addClass('glyphicon-eye-close').removeClass('glyphicon-eye-open');
+ $(this).prev().text(_that.data[index].password);
+ } else {
+ $(this).addClass('glyphicon-eye-open').removeClass('glyphicon-eye-close');
+ $(this).prev().html('********** ');
+ }
+ return false;
+ break;
+ case 'copy_password':
+ bt.pub.copy_pass(_that.data[index].password);
+ return false;
+ break;
+ }
+ if (item.event) item.event.apply(this, arry);
});
});
- if (callback) callback();
},
/**
- * @description 获取表单数据
- * @return {object} 表单数据
- */
- $get_form_value:function(){
- return this.element.serializeObject();
- },
-
- /**
- * @description 设置指定数据
- *
- */
- $set_find_value: function (name, value) {
- var config = {},that = this;
- typeof name != 'string' ? config = name : config[name] = value;
- $.each(config, function (key, item) {
- that.form_element[key].val(item);
- });
- },
-
- /**
- * @description 获取Form,jquery节点
- * @param {Boolean} afresh 是否强制刷新
- * @return {object}
- */
- $get_form_element: function (afresh) {
- var form = {},
- that = this;
- if (afresh || $.isEmptyObject(that.form_element)) {
- this.element.find(':input').each(function (index) {
- form[$(this).attr('name')] = $(this);
- });
- that.form_element = form;
- return form;
- } else {
- return that.form_element;
- }
- },
-
- /**
- * @description 验证值整个列表是否存在,存在则转换成属性字符串格式
- */
- $verify_group: function (config, group) {
- var that = this,
- str = '';
- $.each(group, function (index, item) {
- if (typeof config[item] === "undefined") return true;
- if (['disabled', 'readonly'].indexOf(item) > -1) {
- str += ' ' + (config[item] ? (item + '="' + item + '"') : '');
- } else {
- str += ' ' + item + '="' + config[item] + '"';
- }
- });
- return str;
- },
-
- /**
- * @description 验证绑定事件
- * @param {String} value
- */
- $verify_bind_event: function (eventName, row, group) {
- var event_list = {};
- $.each(group, function (index, items) {
- var event_fun = row[items];
- if (event_fun) {
- if (typeof event_list[eventName] === "object") {
- if (!Array.isArray(event_list[eventName])) event_list[eventName] = [event_list[eventName]];
- event_list[eventName].push({
- event: event_fun,
- eventType: items
- });
+ * @description 样式绑定
+ * @param {array} style_list 样式列表
+ * @return void
+ */
+ $style_bind: function (style_list, status) {
+ var str = '',
+ _that = this;
+ $.each(style_list, function (index, item) {
+ if (item.css != '') {
+ if (!item.className) {
+ str += _that.config.el + ' thead th:nth-child(' + (item.index + 1) + '),' + _that.config.el + ' tbody tr td:nth-child' + (item.span ? ' span' : '') + '(' + (item.index + 1) + '){' + item.css + '}'
} else {
- event_list[eventName] = {
- event: event_fun,
- eventType: items
- };
+ str += item.className + '{' + item.css + '}';
}
}
});
- return event_list;
+ if ($('#bt_table_' + _that.random).length == 0) $(_that.config.el).append('');
},
/**
- * @description 验证值是否存在
- * @param {String} value 内容/值
- * @param {String|Boolean} attr 属性
- * @param {String} type 属性
+ * @deprecated 获取WIN高度或宽度
+ * @return 返回当期的宽度和高度
*/
- $verify: function (value, attr, type) {
- if (!value) return '';
- if (type === true) return value ? ' ' + attr : '';
- if (type === 'style') return attr ? attr + ':' + value + ';' : value;
- return attr ? ' ' + attr + '="' + value + '"' : ' ' + value;
+ $get_win_area: function () {
+ return [window.innerWidth, window.innerHeight];
},
+
/**
- * @description 验证form表单
+ * @description 请求数据,
+ * @param {object} param 参数和请求路径
+ * @return void
*/
- $verify_form:function(){
- var form_list = {},form = this.config.form,form_value = this.$get_form_value(),form_element = this.$get_form_element(true);
- for(var key = 0; key< form.length; key++){
- var item = form[key];
- if(!Array.isArray(item.group)) item.group = [item.group];
- for(var i=0;i'+ item.separate +' '
+ }else{
+ html += that.$reader_content_row(index, item);
+ }
+ });
+ that.element = $('';
+ 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 += '
'+ item.title +' ';
+ 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;
+ 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 '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 += '
'+ item.title +' '
+ break;
+ case 'help':
+ var _html = '';
+ $.each(item.list, function (index, items) {
+ _html += '
' + items + ' ';
+ })
+ html += '
';
+ break;
+ }
+ html += item.unit?'
'+ item.unit +' ':'';
+ html += '
'
+ return html;
+ },
+
+ /**
+ * @descripttion 检测检测名称
+ * @param {string} eventName 配置
+ * @param {object} config 事件配置
+ */
+ $check_event_bind:function(eventName,config){
+ if(!this.event_list[eventName]){
+ // console.log(eventName)
+ if(!this.event_list.hasOwnProperty(eventName)){
+ // console.log('1')
+ 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 += '