This repository has been archived on 2025-09-14. You can view files and clone it, but cannot push or open issues or pull requests.
Files
k18-ntcs-web-ntc/src/main/webapp/WEB-INF/views/systemService/form.jsp

343 lines
13 KiB
Plaintext
Raw Normal View History

2018-02-27 10:47:33 +08:00
<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/WEB-INF/include/taglib.jsp"%>
<html>
<head>
<title>系统业务管理表单</title>
<link href="${pageContext.request.contextPath}/static/pages/css/systemService.css" rel="stylesheet" type="text/css">
</head>
<body>
<script type="text/javascript">
$(document).ready(function() {
$("#inputForm").validate({
rules: {
'serviceName':{
required:true
},
'serviceId':{
required:true,
remote:"${ctx}/systemService/serviceIdValidate?id=" + encodeURIComponent($("#id").val())
2018-02-27 10:47:33 +08:00
},
'action':{
required:true
},
'serviceType':{
required:true
},
'serviceDesc':{
required:true
}
},
messages: {
'serviceName':{
2018-03-06 11:50:07 +08:00
required:'<spring:message code="required"/>'
2018-02-27 10:47:33 +08:00
},
'serviceId':{
2018-03-06 11:50:07 +08:00
required:'<spring:message code="required"/>',
remote:'<spring:message code="repeat"/>'+'serviceId'
2018-02-27 10:47:33 +08:00
},
'action':{
2018-03-06 11:50:07 +08:00
required:'<spring:message code="required"/>'
2018-02-27 10:47:33 +08:00
},
'serviceType':{
2018-03-06 11:50:07 +08:00
required:'<spring:message code="required"/>'
2018-02-27 10:47:33 +08:00
},
'serviceDesc':{
2018-03-06 11:50:07 +08:00
required:'<spring:message code="required"/>'
2018-02-27 10:47:33 +08:00
}
},
submitHandler: function(form){
$("[for=childTableFlag]").css("display", "none");
var flag = true;
var tables = document.getElementsByClassName("child-required");
for (var i = 0; i < tables.length; i++) {
if (!tables[i].value || tables[i].value == '') {
$("[for=childTableFlag]").css("display", "inline");
flag = false;
break;
}
}
if (flag) {
2018-03-06 11:50:07 +08:00
loading('LOADING...');
$("[disabled=disabled]").attr("disabled", false);
2018-02-27 10:47:33 +08:00
form.submit();
} else {
flag = true;
return false;
}
},
errorContainer: "#messageBox",
errorPlacement: function(error, element) {
2018-03-06 11:50:07 +08:00
$("#messageBox").text("<spring:message code='enter_error'/>");
2018-02-27 10:47:33 +08:00
if (element.is(":checkbox")||element.is(":radio")||element.parent().is(".input-append")){
error.appendTo(element.parent().parent());
} else {
error.insertAfter(element);
}
}
});
changeType($("#serviceType").val(), $("#serviceType"));
//类型、动作不允许修改
if ("${systemServiceInfo.id}") {
$("#action").attr("disabled", true);
$("#serviceType").attr("disabled", true);
$("[name=tableType]").attr("disabled", true);
}
2018-02-27 10:47:33 +08:00
});
function changeType(v, obj) {
if ($(obj).val() == '') {
$("#addBtn").attr("disabled", true);
} else if ($(obj).val() == '1') {
if ($(".table-list").length > 1) {
2018-03-06 11:50:07 +08:00
alert('<spring:message code="single_service_message"/>');
$(obj).val(v);
} else if ($(".table-list").length == 1) {
$("#addBtn").attr("disabled", true);
} else if ($(".table-list").length == 0) {
$("#addBtn").attr("disabled", false);
}
} else if ($(obj).val() == '2') {
$("#addBtn").attr("disabled", false);
} else if ($(obj).val() == '3') {
if ($(".table-list").length > 1) {
2018-03-06 11:50:07 +08:00
alert('<spring:message code="special_service_message"/>');
$(obj).val(v);
} else if ($(".table-list").length == 1) {
$("#addBtn").attr("disabled", true);
} else if ($(".table-list").length == 0) {
$("#addBtn").attr("disabled", false);
}
}
autoServiceId();
}
//自动获取serviceId
function autoServiceId() {
if ("${systemServiceInfo.id}") {
return false;
}
var type = $("[name=tableType]").val();
var action = $("#action").val();
var serviceIdPre;
if ($("#serviceType").val() == "1" && action && type) {
serviceIdPre = type + "0" + (action < 10 ? ("0" + action) : action);
} else if ($("#serviceType").val() == "2" && action) {
type = "60";
serviceIdPre = type + (action < 10 ? ("0" + action) : action);
} else if ($("#serviceType").val() == "3" && action) {
type = "50";
serviceIdPre = type + (action < 10 ? ("0" + action) : action);
} else {
serviceIdPre = "";
}
if (serviceIdPre) {
$.ajax({
type:"get",
url:"${ctx}/systemService/newServiceId?serviceIdPre=" + serviceIdPre,
dataType:"text",
success: function(data) {
if (data) {
$("#serviceIdInput").val(data);
}
}
})
} else {
$("#serviceIdInput").val("");
}
}
2018-02-27 10:47:33 +08:00
function addDatatable() {
$("#datatables").append(
'<div class="table-list col-md-10">' +
'<div>' +
'<input type="hidden" name="sciId" value="0"/>' +
'<input type="hidden" name="sciIsValid" value="1"/>' +
'<span class="child-label col-md-2"><font color="red">*</font>'+'<spring:message code="table_name"/>'+':</span> ' +
2018-02-27 10:47:33 +08:00
'<span><input class="child-required form-control child-input" name="tableName"/></span> ' +
'</div>' +
'<div>' +
'<span class="child-label col-md-2"><font color="red">*</font>'+'<spring:message code="table_type"/>'+':</span> ' +
2018-02-27 10:47:33 +08:00
'<span> ' +
'<select class="child-required child-input" name="tableType" onchange="autoServiceId()"> ' +
2018-03-06 11:50:07 +08:00
'<option value="">'+'<spring:message code="select"/>'+'</option>' +
2018-02-27 10:47:33 +08:00
'<option value="1">IP</option>' +
2018-03-06 11:50:07 +08:00
'<option value="2">'+'<spring:message code="string"/>'+'</option>' +
'<option value="3">'+'<spring:message code="number"/>'+'</option>' +
'<option value="4">'+'<spring:message code="strong_string"/>'+'</option>' +
2018-02-27 10:47:33 +08:00
'</select>' +
'</span> ' +
'</div>' +
'<div>' +
'<span class="child-label col-md-2"><font color="red">*</font>MAAT '+'<spring:message code="table_name"/>'+':</span> ' +
2018-02-27 10:47:33 +08:00
'<span><input class="child-required form-control child-input" name="maatTable"/></span>' +
'</div>' +
'<div>' +
'<span class="child-label col-md-2"><font color="red">*</font>'+'<spring:message code="table_des"/>'+':</span> ' +
'<span><input class="child-required form-control child-input" name="tableDesc"/></span>' +
2018-03-06 11:50:07 +08:00
'<button type="button" class="btn btn-danger del-button" onclick="del2(this)">'+'<spring:message code="delete"/>'+'</button>' +
2018-02-27 10:47:33 +08:00
'</div>' +
'</div>'
);
if ($("#serviceType").val() == '1' || $("#serviceType").val() == '3') {
$("#addBtn").attr("disabled", true);
}
2018-02-27 10:47:33 +08:00
}
function del(obj) {
$(obj).parent().parent().find("[name=sciIsValid]").val("0");
$(obj).parent().parent().css("display", "none").attr("class", "table-delete");
changeType($("#serviceType").val(), $("#serviceType"));
2018-02-27 10:47:33 +08:00
}
function del2(obj) {
$(obj).parent().parent().remove();
changeType($("#serviceType").val(), $("#serviceType"));
2018-02-27 10:47:33 +08:00
}
</script>
<div class="page-content">
<div class="theme-panel hidden-xs hidden-sm">
2018-03-06 11:50:07 +08:00
<button type="button" class="btn btn-default" onclick="history.go(-1)"><spring:message code="back"/></button>
2018-02-27 10:47:33 +08:00
</div>
<h3 class="page-title">
2018-03-06 11:50:07 +08:00
<spring:message code="sysService_manage"/>
2018-02-27 10:47:33 +08:00
</h3>
<div class="row">
<div class="col-md-12">
<div class="portlet box blue">
<div class="portlet-title">
<div class="caption">
2018-03-06 11:50:07 +08:00
<i class="fa fa-gift"></i><spring:message code="add"/></div>
2018-02-27 10:47:33 +08:00
</div>
<div class="portlet-body form">
<div class="form-body">
<!-- BEGIN FORM-->
<form:form id="inputForm" modelAttribute="systemServiceInfo" action="${ctx}/systemService/save" method="post" class="form-horizontal">
<form:hidden path="id" id="id"/>
2018-02-27 10:47:33 +08:00
<sys:message content="${message}"/>
<div class="form-group">
2018-03-06 11:50:07 +08:00
<label class="col-md-3 control-label"><font color="red">*</font><spring:message code="service_name"/>:</label>
2018-02-27 10:47:33 +08:00
<div class="col-md-4">
<form:input path="serviceName" htmlEscape="false" maxlength="30" class="required form-control"/>
</div>
</div>
<div class="form-group">
2018-03-06 11:50:07 +08:00
<label class="col-md-3 control-label"><font color="red">*</font><spring:message code="act"/>:</label>
2018-02-27 10:47:33 +08:00
<div class="col-md-4">
<form:select id="action" path="action" class="required form-control" onchange="autoServiceId()">
2018-03-06 11:50:07 +08:00
<form:option value=""><spring:message code="select"/></form:option>
<form:option value="1"><spring:message code="block"/></form:option>
<form:option value="2"><spring:message code="monitor"/></form:option>
<form:option value="5"><spring:message code="block_white_list"/></form:option>
<form:option value="6"><spring:message code="monitor_white_list"/></form:option>
<form:option value="7"><spring:message code="block_monitor_white_list"/></form:option>
<form:option value="8"><spring:message code="grey_list"/></form:option>
2018-02-27 10:47:33 +08:00
</form:select>
</div>
</div>
<div class="form-group">
2018-03-06 11:50:07 +08:00
<label class="col-md-3 control-label"><font color="red">*</font><spring:message code="type"/>:</label>
2018-02-27 10:47:33 +08:00
<div class="col-md-4">
<form:select id="serviceType" path="serviceType" class="required form-control" onclick="now=this.value" onchange="changeType(now, this)">
2018-03-06 11:50:07 +08:00
<form:option value=""><spring:message code="select"/></form:option>
<form:option value="1"><spring:message code="single_domain"/></form:option>
<form:option value="2"><spring:message code="multi_domain"/></form:option>
<form:option value="3"><spring:message code="special_service"/></form:option>
2018-02-27 10:47:33 +08:00
</form:select>
</div>
</div>
<div class="form-group">
2018-03-06 11:50:07 +08:00
<label class="col-md-3 control-label"><spring:message code="datebase_table"/>:</label>
2018-02-27 10:47:33 +08:00
<div class="col-md-8" id="datatables">
<shiro:hasPermission name="system:service:edit">
<div>
2018-03-06 11:50:07 +08:00
<button id="addBtn" type="button" class="btn btn-default" onclick="addDatatable()"><spring:message code="add"/></button>
<label for="childTableFlag" class="error" style="display:none"><spring:message code="fill_all"/></label>
2018-02-27 10:47:33 +08:00
</div>
</shiro:hasPermission>
<c:forEach items="${systemServiceInfo.serviceConfigInfoList }" var="serviceConfigInfo">
<div class="table-list col-md-10">
<div>
<input type="hidden" name="sciId" value="${serviceConfigInfo.id }"/>
<input type="hidden" name="sciIsValid" value="1"/>
<span class="child-label col-md-2"><font color="red">*</font><spring:message code="table_name"/>:</span>
2018-02-27 10:47:33 +08:00
<span><input class="child-required form-control child-input" name="tableName" value="${serviceConfigInfo.tableName }"/></span>
</div>
<div>
<span class="child-label col-md-2"><font color="red">*</font><spring:message code="table_type"/>:</span>
2018-02-27 10:47:33 +08:00
<span>
<select class="child-required child-input" name="tableType">
2018-03-06 11:50:07 +08:00
<option value=""><spring:message code="select"/></option>
2018-02-27 10:47:33 +08:00
<option value="1" <c:if test="${serviceConfigInfo.tableType eq 1}">selected="selected"</c:if>>IP</option>
2018-03-06 11:50:07 +08:00
<option value="2" <c:if test="${serviceConfigInfo.tableType eq 2}">selected="selected"</c:if>><spring:message code="string"/></option>
<option value="3" <c:if test="${serviceConfigInfo.tableType eq 3}">selected="selected"</c:if>><spring:message code="number"/></option>
<option value="4" <c:if test="${serviceConfigInfo.tableType eq 4}">selected="selected"</c:if>><spring:message code="strong_string"/></option>
2018-02-27 10:47:33 +08:00
</select>
</span>
</div>
<div>
<span class="child-label col-md-2"><font color="red">*</font>MAAT <spring:message code="table_name"/>:</span>
2018-02-27 10:47:33 +08:00
<span><input class="child-required form-control child-input" name="maatTable" value="${serviceConfigInfo.maatTable }"/></span>
</div>
<div>
<span class="child-label col-md-2"><font color="red">*</font><spring:message code="table_des"/>:</span>
<span><input class="child-required form-control child-input" name="tableDesc" value="${serviceConfigInfo.tableDesc }"/></span>
2018-02-27 10:47:33 +08:00
2018-03-06 11:50:07 +08:00
<button type="button" class="btn btn-danger del-button" onclick="del(this)"><spring:message code="delete"/></button>
2018-02-27 10:47:33 +08:00
</div>
</div>
</c:forEach>
</div>
</div>
<div class="form-group">
2018-03-06 11:50:07 +08:00
<label class="col-md-3 control-label"><font color="red">*</font><spring:message code="service_id"/>:</label>
<div class="col-md-4">
<input id="serviceIdInput" class="required form-control" name="serviceId" value="${systemServiceInfo.serviceId }" readonly="readonly">
</div>
</div>
2018-02-27 10:47:33 +08:00
<div class="form-group">
2018-03-06 11:50:07 +08:00
<label class="col-md-3 control-label"><font color="red">*</font><spring:message code="describe"/>:</label>
2018-02-27 10:47:33 +08:00
<div class="col-md-4">
<form:textarea path="serviceDesc" htmlEscape="false" class="required form-control"/>
</div>
</div>
<div class="form-actions">
<div class="row">
<div class="col-md-offset-3 col-md-9">
2018-03-05 17:02:15 +08:00
<shiro:hasPermission name="system:service:edit"><input type="submit" class="btn btn-circle blue" value=<spring:message code="submit"></spring:message>></shiro:hasPermission>
<button type="button" class="btn btn-circle grey-salsa btn-outline" onclick="history.go(-1)"><spring:message code="cancel"></spring:message></button>
2018-02-27 10:47:33 +08:00
</div>
</div>
</div>
</form:form>
<!-- END FORM-->
</div>
</div>
</div>
</div>
</div>
</div>
</body>
</html>