You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
simple-yewu/frontend/web/assets/js/myfunc.js

64 lines
1.7 KiB

/**
* 选择框初始化
* @param selects
* @structure{
* name: {
* option_infos: [{
* id: id,
* name: name.
* }],
* selected: selected-id
* }
* @structure}
*/
function selectInfoInit(selects){
$.each(selects,function(name,data){
var html = '<option value="0">---请选择---</option>';
$.each(data['option_infos'],function(i,item){
var val = item['code']?item['code']:item['id'];
var selected = data['selected'] && data['selected'] == val? 'selected': '';
html += '<option value="'+ val +'" '+ selected +'>'+ item.name +'</option>'
});
$('#'+ name + '_info').html(html);
});
}
/**
* 数据表格初始化
* @param tables
* @structure{
* name: {
* data: table-data,
* data: [
* url: url,
* queryPrams: function
* ]
* selected: selected-id
* }
* @structure}
*/
function tableInfoInit(tables){
$.each(tables,function(name,data){
var $table = $('#'+ name +'_table');
var options = {};
if(data['url']){
options = {
url: data.url,
pagination: true,
sidePagination: 'server',
queryParams: function (param) {
typeof data['queryParamsFunc'] == 'function' && data['queryParamsFunc'](param);
},
responseHandler: function (param) {
typeof data['responseFunc'] == 'function' && data['responseFunc'](param);
},
};
}else {
options = {
data: data
}
}
$table.bootstrapTable('destroy');
$table.bootstrapTable(options);
});
}