From 417c6db1ab7698f625bcc6452c2936981fade14b Mon Sep 17 00:00:00 2001 From: hdw <496960745@qq.com> Date: 星期四, 06 十二月 2018 12:19:34 +0800 Subject: [PATCH] 打开系统设置面板检测数据的正确性 --- gx_tieta/WebRoot/js/whyc-jqueryui.js | 44 ++++++++++++++++++++++++++++++++++++++++---- 1 files changed, 40 insertions(+), 4 deletions(-) diff --git a/gx_tieta/WebRoot/js/whyc-jqueryui.js b/gx_tieta/WebRoot/js/whyc-jqueryui.js index 44229af..10db128 100644 --- a/gx_tieta/WebRoot/js/whyc-jqueryui.js +++ b/gx_tieta/WebRoot/js/whyc-jqueryui.js @@ -484,12 +484,14 @@ var TestVal = function(ele, options) { this.ele = ele; this.opts = options; + this.ele.data('testVal', options); }; var _proto = TestVal.prototype; // 鏍规嵁鏁版嵁鐨勬纭�т慨鏀规枃鏈鐨勬牱寮� _proto.changeVal = function() { var testVal = this; + this.ele.off('input propertychange blur focus'); // 鏂囨湰妗嗗唴瀹规敼鍙� this.ele.on('input propertychange', function() { @@ -515,9 +517,17 @@ ele.myTooltip('hide'); ele.removeClass('error-data'); - testVal.opts.btn.removeClass('whyc-btn-disabled'); + // 閬嶅巻testVal.opts.btn鐨勫�� + testVal.opts.btn.each(function() { + if(!$(this).hasClass('error-data')) { + $(this).removeClass('whyc-btn-disabled'); + } + + $(this).removeClass('error-data'); + }); }else { ele.next('i').addClass('error-data'); + //console.log(testVal.opts.msg); ele.myTooltip({ position: testVal.opts.position, thing: 'show', @@ -525,6 +535,15 @@ content: '<span style="color:#FF0000">'+testVal.opts.msg+'</span>' }); ele.addClass('error-data'); + + // 閬嶅巻testVal.opts.btn鐨勫�� + testVal.opts.btn.each(function() { + if(!$(this).hasClass('whyc-btn-disabled') && !$(this).hasClass('error-data')) { + $(this).addClass('whyc-btn-disabled'); + }else { + $(this).addClass('whyc-btn-disabled error-data'); + } + }); testVal.opts.btn.addClass('whyc-btn-disabled'); } @@ -548,10 +567,11 @@ return flag; }; + _proto.error = function() { console.info(this.opts.msg); }; - $.fn.testVal = function(options) { + $.fn.testVal = function(options, attr, val) { var defaults = { pattern: "", event: "changeVal", @@ -563,13 +583,29 @@ max: 0, position: 'bottom' }; - var opts = $.extend(true, {}, defaults, options||{}); + var opts = {}; + // 鍒ゆ柇鏄惁涓烘洿鏂伴厤缃」 + if(isString(options)) { + var oldOpts = this.data('testVal'); + opts = $.extend({}, opts, oldOpts); + if(attr == 'allOpts') { + opts = $.extend({}, opts, val); + }else { + opts[attr] = val; + } + + }else if(isObject(options)){ + opts = $.extend(true, {}, defaults, options||{}); + } + // console.log(opts); if(opts.pattern.constructor.name != 'RegExp') { opts.event = "error"; opts.msg = '璇疯緭鍏ユ纭殑姝e垯琛ㄨ揪寮忔牸寮忥紒锛侊紒' } - + //console.log(opts); var testVal = new TestVal(this, opts); + this.data('testVal', testVal.opts); + testVal[opts.event](); return this; -- Gitblit v1.9.1