81041
2018-12-13 e22fd0bac62d20d94e58409ea15049c67f6ff1eb
gx_tieta/WebRoot/pages/js/mylayui.js
@@ -9,6 +9,7 @@
      // 设置option的文本/属性值/data值
      option.text(_list.txt);
      option.val(_list.val);
      option.attr('selected', _list.selected);
      option.data('data', _list.data);
      Object.keys(_list.attr).forEach(function(key){
         var val = _list.attr[key];
@@ -19,7 +20,7 @@
}
// 构造生成select列表的对象数组
function getLayuiSelect(txt, val, attr, data) {
function getLayuiSelect(txt, val, attr, data, isSelected) {
   var obj = {
      val: '',
      txt: '',
@@ -32,7 +33,83 @@
   obj.txt = txt;      // option的文本值   
   obj.attr = attr;   // option的自定义的属性
   obj.data = data;   // option的data值
   obj.selected = isSelected?true:false;
   
   // 返回构造的对象
   return obj;
}
//格式化时间
Date.prototype.format =function(format)
{
    var o = {
    "M+" : this.getMonth()+1, //month
   "d+" : this.getDate(),    //day
   "h+" : this.getHours(),   //hour
   "m+" : this.getMinutes(), //minute
   "s+" : this.getSeconds(), //second
   "q+" : Math.floor((this.getMonth()+3)/3),  //quarter
   "S" : this.getMilliseconds() //millisecond
    };
    if(/(y+)/.test(format)) format=format.replace(RegExp.$1,
    (this.getFullYear()+"").substr(4- RegExp.$1.length));
    for(var k in o)if(new RegExp("("+ k +")").test(format))
    format = format.replace(RegExp.$1,
    RegExp.$1.length==1? o[k] :
    ("00"+ o[k]).substr((""+ o[k]).length));
    return format;
};
// 页面中分页信息对象
var TblPage = function() {
   this.size = 10;
   this.curr = 1;
   this.all = 0;
   this.num = 1;
};
// 初始化分页信息对象
TblPage.prototype.init = function() {
   this.size = 10;
   this.curr = 1;
   this.all = 0;
   this._setNum();
};
// 设置分页信息对象
TblPage.prototype.set = function(curr, all, size) {
   this.size = size;
   this.curr = curr;
   this.all = all;
   this._setNum();
};
TblPage.prototype.getPage = function() {
   var temp = {
      pageSize: this.size
      ,pageCurr: this.curr
      ,pageAll: this.all
   };
   return temp;
};
// 设置分页信息的当前页
TblPage.prototype.setCurr = function(curr) {
   this.curr = curr;
};
//设置分页信息的每页显示的条数
TblPage.prototype.setSize = function(size) {
   this.size = size;
   this._setNum();
};
//设置分页信息的总条数
TblPage.prototype.setAll = function(all) {
   this.all = all;
   this._setNum();
};
// 设置共有多少页
TblPage.prototype._setNum = function() {
   this.num = Math.ceil(this.all/this.size);
}