From b8c1269fe493177cb0a6659fbc032193032737aa Mon Sep 17 00:00:00 2001
From: hdw <hdw@192.168.137.1>
Date: 星期四, 20 十二月 2018 14:05:56 +0800
Subject: [PATCH] 机房验收

---
 gx_tieta/WebRoot/pages/js/mylayui.js |  140 ++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 139 insertions(+), 1 deletions(-)

diff --git a/gx_tieta/WebRoot/pages/js/mylayui.js b/gx_tieta/WebRoot/pages/js/mylayui.js
index b760837..94808f7 100644
--- a/gx_tieta/WebRoot/pages/js/mylayui.js
+++ b/gx_tieta/WebRoot/pages/js/mylayui.js
@@ -112,4 +112,142 @@
 // 璁剧疆鍏辨湁澶氬皯椤�
 TblPage.prototype._setNum = function() {
 	this.num = Math.ceil(this.all/this.size);
-}
\ No newline at end of file
+}
+
+// 瀹氫箟椤甸潰涓垎椤靛厓绱犵殑瀵硅薄
+var PagePage = function(opts) {
+	this.search = '';		// 鏌ヨ
+	this.home = '';				// 棣栭〉
+	this.pre = '';				// 涓婁竴椤�
+	this.next = '';				// 涓嬩竴椤�
+	this.last = '';				// 灏鹃〉
+	this.size = '';				// 姣忛〉鏄剧ず鏉℃暟
+	this.num = '';				// 璺宠浆鐨勯〉鏁�
+	this.go = '';				// 椤甸潰璺宠浆
+	this.current = '';			// 褰撳墠椤�/鎬婚〉鏁�
+	this.total = '';			// 鏁版嵁鎬婚噺
+	this.page = opts.page;		// 鍒嗛〉淇℃伅
+	this._initDom(opts);
+	this.callback = "";
+}
+
+// 璁剧疆PagePage鐨勬柟娉�
+PagePage.prototype = {
+	_initDom: function(opts) {
+		this.search = this._getEle(opts.search);
+		this.home = this._getEle(opts.home);
+		this.pre = this._getEle(opts.pre);
+		this.next = this._getEle(opts.next);
+		this.last = this._getEle(opts.last);
+		this.num = this._getEle(opts.num);
+		this.go = this._getEle(opts.go);
+		this.current = this._getEle(opts.current);
+		this.total = this._getEle(opts.total);
+		this.size = this._getEle(opts.size);
+		//console.log(this.search);
+		this.addEvent();
+	}
+	,_getEle: function(ele) {
+		//console.log(ele);
+		var len = ele?ele.length:0;
+		//console.log(len);
+		var rsEle = len?ele:$('#PagePageTmp');
+		return rsEle;
+	}
+	,addEvent: function() {
+		var _this = this;
+		
+		//  鐐瑰嚮鏌ヨ
+		this.search.off('click.PagePage.event').on('click.PagePage.event', function() {
+			if(_this._checkCallback()) {
+				_this.callback();
+			} 
+		});
+		
+		// 鐐瑰嚮棣栭〉
+		this.home.off('click.PagePage.event').on('click.PagePage.event', function() {
+			var Page = _this.page;
+			if(Page.curr != 1){
+				Page.setCurr(1);
+				_this.callback();
+			}
+		});
+		
+		// 鐐瑰嚮涓婁竴椤�
+		this.pre.off('click.PagePage.event').on('click.PagePage.event', function() {
+			var Page = _this.page;
+			if(Page.curr > 1){
+				Page.setCurr(Page.curr-1);
+				_this.callback();
+			}
+		});
+		
+		// 鐐瑰嚮涓嬩竴椤�
+		this.next.off('click.PagePage.event').on('click.PagePage.event', function() {
+			var Page = _this.page;
+			if(Page.num > Page.curr){
+				Page.setCurr(Page.curr+1);
+				_this.callback();
+			}
+		});
+		
+		// 璁剧疆姣忛〉鏄剧ず鏉℃暟
+		this.size.off('blur.PagePage.event').on('blur.PagePage.event', function() {
+			var Page = _this.page;
+			var value= $(this).val();
+			//褰撹緭鍏ョ殑鏁板ぇ浜�0鏃�
+			if(value>0){
+				if(value != Page.size){
+					Page.setSize(parseInt(value));
+					Page.setCurr(1);
+				}
+			}else{
+				//褰撹緭鍏ラ潪娉曟暟瀛楁椂
+				alert("璇疯緭鍏ュ悎娉曠殑鏁板瓧");						/* 璇疯緭鍏ュ悎娉曠殑鏁存暟 */
+				$(this).val(Page.size);					
+			}
+		});
+		
+		// 灏鹃〉
+		this.last.off('click.PagePage.event').on('click.PagePage.event', function() {
+			var Page = _this.page;
+			if(Page.curr < Page.num){
+				Page.setCurr(Page.num);
+				_this.callback();
+			}
+		});
+		
+		// 璺宠浆
+		this.go.off('click.PagePage.event').on('click.PagePage.event', function() {
+			var Page = _this.page;
+			var tarpage= _this.num.val();
+			if(tarpage > Page.num){
+				Page.setCurr(Page.num);
+			}else if(tarpage > 0 && tarpage!= Page.curr){
+				Page.setCurr(parseInt(tarpage));
+			}
+			_this.callback();
+		});
+		
+	}
+	,setCallback:function(callback) {
+		this.callback = callback;
+	}
+	,setPage: function(page) {
+		this.page = page;
+	}
+	,init:function(page, callback) {
+		this.setPage(page);
+		this.setCallback(callback);
+		this.setVal();
+	}
+	,setVal: function() {
+		this.current.text(this.page.curr+'/'+this.page.num);
+		this.total.text(this.page.all);
+		this.size.val(this.page.size);
+	}
+	,_checkCallback: function() {
+		return typeof this.callback === 'function';
+	}
+};
+

--
Gitblit v1.9.1