From 2fe250ece8de95b3f70172fe5b45793ab6a3084a Mon Sep 17 00:00:00 2001
From: D:/workspace/chenjingjing/git/gx_tieta/gx_tieta/.gitignore <chenjingjing@LAPTOP-E51P2139>
Date: 星期五, 18 一月 2019 17:30:50 +0800
Subject: [PATCH] 未审批可更改

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

diff --git a/gx_tieta/WebRoot/pages/js/mylayui.js b/gx_tieta/WebRoot/pages/js/mylayui.js
index b760837..f78d1de 100644
--- a/gx_tieta/WebRoot/pages/js/mylayui.js
+++ b/gx_tieta/WebRoot/pages/js/mylayui.js
@@ -112,4 +112,563 @@
 // 璁剧疆鍏辨湁澶氬皯椤�
 TblPage.prototype._setNum = function() {
 	this.num = Math.ceil(this.all/this.size);
+}
+
+// 瀹氫箟椤甸潰涓垎椤靛厓绱犵殑瀵硅薄
+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';
+	}
+};
+
+// 鐪�-甯�-鍖鸿仈鍔�
+var LinkAge = function(url, province, city, county, callback) {
+    this.province = province;
+    this.city = city;
+    this.county = county;
+    this.url = url;
+    this.callback= callback;
+    this.data = {};
+    this._init();
+};
+LinkAge.prototype = {
+    _init: function() {
+    	// 璁剧疆鍥炶皟鍑芥暟
+    	if(typeof this.callback === 'function') {
+            this.callback = this.callback;
+        }else {
+            this.callback = function() {};
+        }
+    	
+        this._setData();
+        this._updateDom();
+        // this._addEvent();
+    }
+    ,_setData: function() {
+        var _this = this;
+        // 璇锋眰json鏁版嵁
+        $.ajax({
+            type: 'post'
+            ,async: false
+            ,url: this.url
+            ,data: null
+            ,dataType: 'json'
+            ,success: function(res) {
+                _this.data = res;
+            },
+            error: function(res) {
+                console.log(res)
+            }
+        });
+    }
+    ,_getProvinces: function() {
+        var provinces = this._analyseData(this.data);
+        return provinces;
+    }
+    ,_getCities: function(province) {
+        var cities = this.data[province].child;
+        var rsCities = this._analyseData(cities);
+        return rsCities;
+    }
+    ,_getCounty: function(province, city) {
+        var cities = this.data[province].child;
+        var counties = cities[city].child;
+        var rsCounties = this._analyseData(counties);
+        return rsCounties;
+    }
+    ,_analyseData: function(data) {
+        var rsData = [];
+        // 瑙f瀽鏁版嵁
+        Object.keys(data).forEach(function(key) {
+            var _data = data[key];
+            if(_data)
+            var tmp = {
+                id: key
+                ,name: _data.name
+            };
+
+            if(!_data.child && _data == '甯傝緰鍖�') {
+
+            }else {
+                tmp.id = key;
+                tmp.name = _data.child?_data.name:_data;
+                rsData.push(tmp);
+            }
+            
+        });
+
+        return rsData;
+    }
+    ,_updateDom: function() {
+        // 鐪�
+        var proData = this._getProvinces();
+        var proOptions = this._createDom(proData);
+        this.province.html(proOptions);
+        
+        // 甯�
+        var citiesData = this._getCities(this.province.find('option:selected').attr('num'));
+        var citiesOptions = this._createDom(citiesData);
+        this.city.html(citiesOptions);
+
+        // 鍖�/鍘�
+        var countiesData = this._getCounty(this.province.find('option:selected').attr('num'), this.city.find('option:selected').attr('num'));
+        var countiesOptions = this._createDom(countiesData);
+        this.county.html(countiesOptions);
+        
+        this.callback();
+    }
+    ,_createDom: function(data) {
+        var options = '';
+        for(var i=0; i<data.length; i++) {
+            var _data = data[i];
+            options += '<option num="'+_data.id+'" value="'+_data.name+'">'+_data.name+'</option>';
+        }
+
+        return options;
+    }
+    ,_addEvent: function() {
+        var _this = this;
+        // 鍒囨崲鐪佽皟鏁村競鍜屽尯/鍘�
+        this.province.off('change.LinkAge.event').on('change.LinkAge.event', function() {
+            var val = $(this).find('option:selected').attr('num');
+            console.log(val);
+            // 甯�
+            var citiesData = _this._getCities(val);
+            var citiesOptions = _this._createDom(citiesData);
+            _this.city.html(citiesOptions);
+
+
+            // 鍖�/鍘�
+            var countiesData = _this._getCounty(val, _this.city.find('option:selected').attr('num'));
+            var countiesOptions = _this._createDom(countiesData);
+            _this.county.html(countiesOptions);
+            
+            _this.callback();
+        });
+
+        // 鍒囨崲甯�
+        this.city.off('change.LinkAge.event').on('change.LinkAge.event', function() {
+            var val = $(this).find('option:selected').attr('num');
+            console.log(val);
+            // 鍖�/鍘�
+            var countiesData = _this._getCounty(_this.province.find('option:selected').attr('num'), val);
+            var countiesOptions = _this._createDom(countiesData);
+            _this.county.html(countiesOptions);
+            _this.callback();
+        });
+    }
+};
+
+//layui琛ㄦ牸鍐呭鏇存柊
+var LayuiTbl = function(options, layui, laytpl, cache) {
+    this.opts = options;
+    this.cache = cache;
+    this.layui = layui;
+    this.tpl = laytpl;
+    this.ele = options.elem;
+    this.col = options.cols[0];
+};
+
+// 璁剧疆鍘熷瀷鍑芥暟
+LayuiTbl.prototype = {
+	updateTr: function(index, data) {
+        var layui = this.layui;
+        var preData = this.cache[index];
+        var _data = $.extend(preData||{}, data||{});
+        var tds = this._getBodyTds(index);
+        var tdRs = this._getFixedRTds(index);
+        //console.log(_data);
+        // 閬嶅巻
+        var _this = this;
+        layui.each(_data, function(key, value) {
+            // 閬嶅巻tds鐨勫��
+            tds.each(function(k) {
+                var _field = $(this).data('field');
+                if(key == _field) {
+                    var cell = $(this).find('.layui-table-cell');
+                    var content = _this._getContent(key, value, _data);
+                    cell.html(content);
+                }
+            });
+        });
+        
+        // 淇敼娴姩
+        layui.each(_data, function(key, value) {
+            // 閬嶅巻tds鐨勫��
+        	tdRs.each(function(k) {
+                var _field = $(this).data('field');
+                if(key == _field) {
+                    var cell = $(this).find('.layui-table-cell');
+                    var content = _this._getContent(key, value, _data);
+                    cell.html(content);
+                }
+            });
+        });
+    }
+	,updateCol: function(major, field, data) {			// 鏇存柊鍒楃殑鍊�
+		// 鍒ゆ柇褰撳墠灞炴�ф槸鍚︽槸data鐨勫睘鎬�
+		if(field in data) {
+			var index = this.getIndex(major, data[major]);		// 鑾峰彇闇�瑕佹洿鏂扮殑琛�
+			if(index != undefined) {							// 鑾峰彇鍒�
+				this.updateTr(index, data);						// 鏇存柊琛ㄦ牸鐨勬暟鎹�
+			}
+		}
+		
+	}
+	,update: function(field, data) {
+		for(var i=0; i<data.length; i++) {
+			var _data = data[i];
+			if(field in _data) {								// 鍒ゆ柇瀵硅薄涓槸鍚﹀瓨鍦ㄦ爣璇嗕綅
+				var _field = _data[field];						// 鑾峰彇鏍囪瘑浣嶇殑鍊�
+				var index = this.getIndex(field, _field);		// 鑾峰彇瀵硅薄鎵�鍦ㄧ殑琛�
+				if(index != undefined) {						// 鍒ゆ柇鏄惁鑾峰彇鍒颁簡琛屽彿
+					this.updateTr(index, _data);				// 鏇存柊鎸囧畾鐨勮
+				}else {
+					console.log(' 绗�'+i+'涓璞℃病鏈夊璞$殑琛ㄦ牸琛�');
+					console.log(_data);
+				}
+			}else {
+				console.log(' 绗�'+i+'涓璞$殑'+field+'涓婚敭鏍囪瘑涓嶅瓨鍦�');
+			}
+		}
+	}
+    ,_getBodyTds: function(index) {
+        var layuiTableView = $(this.ele).next('.layui-table-view');
+        var layuiTableBody = layuiTableView.find('.layui-table-body .layui-table tbody');
+        var trList = layuiTableBody.find('tr');
+
+        return trList.eq(index).find('td');
+    }
+    ,_getFixedRTds: function(index) {
+    	var layuiTableView = $(this.ele).next('.layui-table-view');
+    	var layuiFixedR = layuiTableView.find('.layui-table-fixed.layui-table-fixed-r .layui-table tbody');
+    	var trList = layuiFixedR.find('tr');
+    	return trList.eq(index).find('td');
+    }
+    ,_getContent: function(key, value, data) {
+        var col = this.col;             //  鎵�鏈夌殑鍒�
+        var laytpl = this.tpl;
+        var rs = '';
+        var templet = '';
+        // 閬嶅巻鎵�鏈夌殑鍒�
+        for(var i=0; i<col.length; i++) {
+            var _col = col[i];
+            // 鍒ゆ柇褰撳墠鍐呭鏄惁涓哄搴旂殑闇�瑕佹洿鏂扮殑鏁版嵁
+            if(key == _col.field) {
+                // 鍒ゆ柇鏄惁鏈夋ā鏉�
+            	// console.log(key+'***'+_col.field);
+            	// console.log(_col.templet);
+                templet = _col.templet?$(_col.templet).html():_col.toolbar?$(_col.toolbar).html():typeof value == 'number'?value.toString():value;
+                //console.log(templet);
+                templet = templet?templet:typeof value == 'number'?value.toString():value;
+                // 鏍规嵁妯℃澘鏋勬垚content
+                laytpl(templet).render(data, function(html) {
+                    rs = html;
+                });
+
+                return rs;
+            }
+        }
+
+        return false;
+    }
+    ,getIndex: function(field, value) {		// 鑾峰彇tr鐨勪笅鏍�
+    	// 閬嶅巻cache鐨勫��
+    	var cache = this.cache;
+    	var index = undefined;
+    	for(var i=0; i<cache.length; i++) {
+    		var _cache = cache[i];
+    		// console.log(_cache)
+    		if(field in _cache && _cache[field] == value) {
+    			index = i;
+    			break;
+    		}
+    	}
+    	
+    	return index;
+    }
+    ,getTr: function(field, value) {		// 鑾峰彇Tr鐨勬暟鎹�
+    	// 閬嶅巻cache鐨勫��
+    	var cache = this.cache;
+    	var rs = {
+    		code: 0
+    		,data: {}
+    		,msg: '鑾峰彇鏍囪瘑浣�'+field+'锛屽�间负'+value+'瀵瑰簲鐨則r鐨勬暟鎹け璐�'
+    	};
+    	// 閬嶅巻cache鐨勫��
+    	for(var i=0; i<cache.length; i++) {
+    		var _cache = cache[i];
+    		if(field in _cache && _cache[field] == value) {
+    			rs.code = 1;
+    			rs.data = _cache;
+    			rs.msg = '鑾峰彇鏍囪瘑浣�'+field+'锛屽�间负'+value+'瀵瑰簲鐨則r鐨勬暟鎹垚鍔�'
+    			break;
+    		}
+    	}
+    	
+    	return rs;
+    }
+    ,setCache: function(cache) {
+    	this.cache = cache;
+    }
+};
+
+//鑾峰彇layui鐨刦orm琛ㄥ崟鐨勫��(鏀寔input鍜宻elect)
+var LayuiForm = function(ele) {
+    this.ele = ele;
+};
+// 瀹氫箟鍘熷瀷鏂规硶
+LayuiForm.prototype = {
+    get: function(callback) {
+        var ele = $('#'+this.ele);
+        var isGood = this._checkForm(ele);
+        if(isGood) {
+            var iptsVals = this._getIpts(ele);
+            var selVals = this._getSels(ele);
+            //  鑾峰彇鎵�鏈夌殑form鍊�
+            var rs = $.extend({}, iptsVals, selVals);
+            callback(rs);
+        }
+    }
+    ,_getIpts: function(ele) {
+        var ipts = ele.find('input');
+        var iptVals = {};
+        ipts.each(function() {
+            var name = $(this).attr('name');
+            if(name) {
+                iptVals[name] = $(this).val();
+            }
+        });
+
+        return iptVals;
+    }
+    ,_getSels: function(ele) {
+        var sels = ele.find('select');
+        var selVals = {};
+        sels.each(function() {
+            var name = $(this).attr('name');
+            if(name) {
+                selVals[name] = $(this).val();
+            }
+        });
+
+        return selVals;
+    }
+
+    ,_checkForm: function(ele) {
+        var isGood = true;
+        var ipts = ele.find('input');
+        var sels = ele.find('select');
+        //  閬嶅巻鎵�鏈夌殑input鏌ヨ鏄惁鏈夋暟鎹笉姝g‘鐨�
+        ipts.each(function() {
+            if($(this).hasClass('layui-form-danger')) {
+                isGood = false;
+            }
+        });
+
+        //  閬嶅巻鎵�鏈夌殑select鏌ヨ鏄惁鏈夋暟鎹笉姝g‘鐨�
+        sels.each(function() {
+            if($(this).hasClass('layui-form-danger')) {
+                isGood = false;
+            }
+        });
+
+        // 杩斿洖缁撴灉
+        return isGood;
+    }
+};
+
+// 缁熻鏁版嵁閫変腑涓暟/鎬讳釜鏁�
+var QuantNumber = function(ele) {
+	this.ele = ele;
+	this.mol = 0;
+	this.den = 0;
+	this._init();
+}
+// 璁剧疆鍘熷瀷鏂规硶
+QuantNumber.prototype = {
+	_init: function() {
+		this._setEleTxt();
+	}
+	,set: function(mol, den) {
+		this.mol = mol;
+		this.den = den;
+		this._setEleTxt();
+	}
+	,setMol: function(val) {
+		this.mol = val;
+		this._setEleTxt();
+	}
+	,setDen: function(val) {
+		this.den = val;
+		this._setEleTxt();
+	}
+	,_setEleTxt: function() {
+		var str = this.mol+'/'+this.den;
+		this.ele.text(str)
+	}
+};
+
+
+//鑾峰彇鐢垫睜鍝佺墝鍒楄〃
+function getBattProducers() {
+	let producers = [];
+	// 璇锋眰鍚庡彴鏌ヨ鐢垫睜鍝佺墝
+	$.ajax({
+		type: 'post'
+		,async: false
+		,url: 'BattInfAction!serchByBattProducer'
+		,data: null
+		,dataType: 'json'
+		,success: function(res) {
+			let rs = JSON.parse(res.result);
+			// 鍒ゆ柇鏌ヨ缁撴灉
+			if(rs.code == 1) {
+				let data = rs.data;
+				// 閬嶅巻鏌ヨ缁撴灉
+				for(let i=0; i<data.length; i++) {
+					let _data = data[i];
+					if(_data.BattProducer) {		// 澶勭悊涓虹┖鐨勫搧鐗�
+						producers.push(_data.BattProducer);
+					}
+				}
+				producers.push('鍏朵粬');
+			}
+		}
+		,complete: function() {
+			
+		}
+	});
+	
+	return producers;
 }
\ No newline at end of file

--
Gitblit v1.9.1