From 80f110b56fe5606f1b0c0dfa7db7f3c6cf068d55 Mon Sep 17 00:00:00 2001 From: chenjinsong Date: Fri, 23 Mar 2018 13:46:05 +0800 Subject: [PATCH] =?UTF-8?q?1.=E5=A2=9E=E5=8A=A0=E7=B3=BB=E7=BB=9F=E4=B8=9A?= =?UTF-8?q?=E5=8A=A1=E9=85=8D=E7=BD=AE=E5=88=97=E8=A1=A8=E9=A1=B5--?= =?UTF-8?q?=E6=90=9C=E7=B4=A2=E6=A1=86=E7=9A=84=E4=B8=9A=E5=8A=A1id?= =?UTF-8?q?=E6=90=9C=E7=B4=A2=E7=9A=84=E8=BE=93=E5=85=A5=E9=99=90=E5=88=B6?= =?UTF-8?q?=EF=BC=9A=E5=8F=AA=E8=83=BD=E8=BE=93=E5=85=A5=E6=95=B0=E5=AD=97?= =?UTF-8?q?=202.=E4=BC=98=E5=8C=96=E7=B3=BB=E7=BB=9F=E4=B8=9A=E5=8A=A1?= =?UTF-8?q?=E9=85=8D=E7=BD=AE=E8=A1=A8=E5=8D=95=E9=A1=B5=E7=9A=84=E9=9D=9E?= =?UTF-8?q?=E7=A9=BA=E6=A0=A1=E9=AA=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../WEB-INF/views/systemService/form.jsp | 94 ++++++++++++++----- .../WEB-INF/views/systemService/list.jsp | 10 +- 2 files changed, 82 insertions(+), 22 deletions(-) diff --git a/src/main/webapp/WEB-INF/views/systemService/form.jsp b/src/main/webapp/WEB-INF/views/systemService/form.jsp index e2e3c42ce..1d6a58999 100644 --- a/src/main/webapp/WEB-INF/views/systemService/form.jsp +++ b/src/main/webapp/WEB-INF/views/systemService/form.jsp @@ -10,6 +10,7 @@ $(document).ready(function() { top.window.scrollTo(0, 0); $("#inputForm").validate({ + ignore: [], rules: { 'serviceName':{ required:true @@ -24,9 +25,11 @@ 'serviceType':{ required:true }, - 'serviceDesc':{ - required:true + 'childTableFlag':{ + required:true, + checkChild:true } + }, messages: { 'serviceName':{ @@ -42,21 +45,34 @@ 'serviceType':{ required:'' }, - 'serviceDesc':{ + 'childTableFlag':{ required:'' } }, - submitHandler: function(form){ - $("[for=childTableFlag]").css("display", "none"); + //submitHandler: function(form){ + /* $("[for=childTableFlag]").css("display", "none"); var flag = true; var tables = document.getElementsByClassName("child-required"); + if (tables.length == 0) { + $("[for=childTableFlag]").text("").css("display", "inline"); + if (!$("#serviceIdInput").val()) { + $("[for=serviceId]").css("display", "inline"); + } + return false; + } for (var i = 0; i < tables.length; i++) { if (!tables[i].value || tables[i].value == '') { - $("[for=childTableFlag]").css("display", "inline"); + $("[for=childTableFlag]").text("").css("display", "inline"); flag = false; break; } } + + if (!$("#serviceIdInput").val()) { + $("[for=serviceId]").css("display", "inline"); + flag = false; + } + if (flag) { loading('LOADING...'); $("[disabled=disabled]").attr("disabled", false); @@ -65,8 +81,8 @@ } else { flag = true; return false; - } - }, + } */ + //}, errorContainer: "#messageBox", errorPlacement: function(error, element) { $("#messageBox").text(""); @@ -78,6 +94,17 @@ } }); + $.validator.addMethod( + "checkChild", + function(value, element, params) { + if (value && value == "1") { + return true; + } else { + return false; + } + }, + "" + ); changeType($("#serviceType").val(), $("#serviceType")); //类型、动作不允许修改 @@ -94,6 +121,25 @@ }); } + function childValidate() { + var flag = true; + var c = $(".child-required, .child-required2.selectpicker"); + if (c.length == 0) { + return false; + } + c.each(function(){ + if (!$(this).val()) { + flag = false; + return false; + } + }); + if (flag) { + $("[name=childTableFlag]").val("1"); + } else { + $("[name=childTableFlag]").val("0"); + } + } + function changeType(v, obj) { if ($(obj).val() == '') { $("#addBtn").attr("disabled", true); @@ -156,6 +202,8 @@ } else { $("#serviceIdInput").val(""); } + + childValidate(); } function addDatatable() { @@ -165,7 +213,7 @@ '' + '' + '*'+''+': ' + - ' ' + + ' ' + '' + '
' + '*'+''+': ' + @@ -180,11 +228,11 @@ '
' + '
' + '*MAAT '+''+': ' + - '' + + '' + '
' + '
' + - '*'+''+': ' + - '' + + '' + ''+': ' + + '' + '' + '
' + '' @@ -193,6 +241,8 @@ if ($("#serviceType").val() == '1' || $("#serviceType").val() == '3') { $("#addBtn").attr("disabled", true); } + + childValidate(); } function del(obj) { @@ -271,12 +321,13 @@
- +
- + +
@@ -286,7 +337,7 @@ *: - +
*: @@ -301,11 +352,11 @@
*MAAT : - +
- *: - + : +
@@ -317,14 +368,15 @@
- + +
- +
- +
diff --git a/src/main/webapp/WEB-INF/views/systemService/list.jsp b/src/main/webapp/WEB-INF/views/systemService/list.jsp index ac89c6866..f97d92883 100644 --- a/src/main/webapp/WEB-INF/views/systemService/list.jsp +++ b/src/main/webapp/WEB-INF/views/systemService/list.jsp @@ -29,6 +29,14 @@ function deleteService(id) { } } } + +function checkNum(obj) { + var reg = /^[0-9]*$/; + if (!reg.test(obj.value)) { + top.$.jBox.tip("请输入数字"); + obj.value=obj.value.replace(/[^\d]/g,''); + } +}
- " value="${systemServiceInfo.serviceId }"/> + " value="${systemServiceInfo.serviceId }" onkeyup="checkNum(this)"/>