From 35fefed0792c40cb99b8d15fa5811bbb5992bff9 Mon Sep 17 00:00:00 2001 From: D:/workspace/chenjingjing/git/gx_tieta/gx_tieta/.gitignore <chenjingjing@LAPTOP-E51P2139> Date: 星期一, 21 一月 2019 10:42:24 +0800 Subject: [PATCH] 修改 --- gx_tieta/WebRoot/pages/js/mylayui.js | 173 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 files changed, 170 insertions(+), 3 deletions(-) diff --git a/gx_tieta/WebRoot/pages/js/mylayui.js b/gx_tieta/WebRoot/pages/js/mylayui.js index 5d26de4..f78d1de 100644 --- a/gx_tieta/WebRoot/pages/js/mylayui.js +++ b/gx_tieta/WebRoot/pages/js/mylayui.js @@ -401,7 +401,7 @@ // 璁剧疆鍘熷瀷鍑芥暟 LayuiTbl.prototype = { - updateTr: function(index, data) { + updateTr: function(index, data) { var layui = this.layui; var preData = this.cache[index]; var _data = $.extend(preData||{}, data||{}); @@ -445,6 +445,23 @@ } } + ,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'); @@ -485,13 +502,13 @@ return false; } - ,getIndex: function(field, value) { + ,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) + // console.log(_cache) if(field in _cache && _cache[field] == value) { index = i; break; @@ -500,8 +517,158 @@ 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