1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
<%@ page language="java" pageEncoding="UTF-8" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<c:set var="ctx" value="${pageContext.request.contextPath}"/>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>模型维护</title>
<style>
.table-null .table{
margin-bottom: 0px;
}
.table-null .table > tbody > tr > td, .table-null .table > thead > tr > th{
text-align: center;
width: 25%;
}
.table-null td:first-child{
text-align: right;
width: 36%;
}
.table-null tr td:last-child .form-control,.table-null tr td:last-child table{
width: 400px;
}
.file-box{ position:relative;}
.file{ position:absolute; top:0; height:30px; filter:alpha(opacity:0);opacity:0;width:470px;cursor: pointer; }
</style>
</head>
<body>
<div class="container">
<ol class="breadcrumb">
<li><a href="${ctx}/index">首页</a></li>
<li>分析建模</li>
<li class="active">模型维护</li>
</ol>
</div>
<div id="main-container main-tab-container">
<div id="content" class="container">
<div class="section">
<div class="tab-content">
<div class="tab-pane fade in active" id="home">
<div class="row">
<div class="col-xs-12">
<div class="table-header">模型修改</div>
<form action="#" class="form-horizontal" id="modelUpdateForm" method="post" enctype="multipart/form-data">
<table id="modelMaintainTable" class="table-null">
<tr><td>数据模型ID:</td><td id="dataModelId"></td></tr>
<!-- <tr><td>数据模型名称:</td><td id="dataModelName"></td></tr>
<tr><td>规则定义:</td><td id="ruleDefinition"></td></tr> -->
<tr><td>数据模型名称(<font color="red">必填</font>):</td><td><input type="text" class="form-control" name="dataModelName" id="dataModelName" style="display: inline;" /><span id="writeWarningInf" style="color:red;display: inline;padding-left:10px;"></span></td></tr>
<tr><td>规则定义:</td><td><input type="text" class="form-control" name="ruleDefinition" id="ruleDefinition"/></td></tr>
<!-- <tr><td>数据模型名称(<font color="red">必填</font>):</td><td><input type="text" class="form-control" name="dataModelName" id="dataModelName" style="display: inline;" /><span id="writeWarningInf" style="color:red;display: inline;padding-left:10px;"></span></td></tr>
<tr><td>规则定义:</td><td><input type="text" class="form-control" name="ruleDefinition" id="ruleDefinition"/></td></tr>
--><tr><td>模型执行脚本(<font color="red">必填</font>):</td><td>
<!-- <div class="file-box">
<input type='text' id='modelExeScriptName' class="form-control" />
<input type="file" name="uploadFile" class="file" id="fileField" size="28" onchange="document.getElementById('modelExeScriptName').value=this.value" />
</div> -->
<div class="file-box">
<input type='text' id='modelExeScriptName' class="form-control" style="display: inline;"/>
<input type='button' class="btn btn-default" value='浏 览' style="width:70px"/>
<input type="file" name="uploadFile" class="file" id="fileField" onchange="document.getElementById('modelExeScriptName').value=this.value" />
</div>
</td></tr>
<tr><td>模型类别:</td>
<td><select class="form-control" name="modelType" id="modelType" >
<c:forEach var="modelType" items="${dataModelTypeList}">
<option value="${modelType.dataModelTypeId}">${modelType.dataModelTypeName}</option>
</c:forEach>
</select></td></tr>
<tr><td>部署服务器:</td>
<td><select class="form-control" name="deployedServer" id="deployedServer">
<c:forEach var="deployedServers" items="${deployedServerList}">
<option value="${deployedServers.serverId}">${deployedServers.serverName}</option>
</c:forEach>
</select></td></tr>
<tr><td>模型状态:</td>
<td><select class="form-control" name="modelStatus" id="modelStatus">
<option value="1">正常</option>
<option value="0">失效</option>
</select></td></tr>
<tr><td>业务开始时间(<font color="red">必填</font>):</td><td><input id="businessStartTime" name="businessStartTime" class="form-control" type="text" onFocus="WdatePicker({maxDate:'#F{$dp.$D(\'businessEndTime\')}'})"> </td></tr>
<tr><td>业务结束时间(<font color="red">必填</font>):</td><td><input type="text" class="form-control" id="businessEndTime" name="businessEndTime" onfocus="WdatePicker({minDate:'#F{$dp.$D(\'businessStartTime\')}'})" /></td></tr>
<tr><td>参数:</td>
<td><table class="table table-hover table-striped" id="displayParam">
<thead>
<tr><th>参数名</th><th>参数值</th><th>参数类型</th><th><a href="javascript:deleteAllTr()">删除所有参数</a></th></tr>
</thead>
<tbody id="addTr">
<c:forEach var="modelParameterList" items="${modelParameterList}">
<tr><td>${modelParameterList.parameterName}</td><td>${modelParameterList.parameterValue}</td><td>${modelParameterList.parameterDataType}</td><td><a href="javascript:;" title="参数ID:${modelParameterList.parameterId}" onclick="deleteRow(this,'${modelParameterList.parameterId}')">删除</a> <a href="javascript:;" onclick="updateRow(this)">修改</a></td></tr>
</c:forEach>
</tbody>
</table></td></tr>
<tr><td>参数数据类型:</td>
<td><select class="form-control" id="paramDataType" name="paramDataType">
<c:forEach var="dataTypes" items="${dataTypeList}">
<option value="${dataTypes.dataTypeName}">${dataTypes.dataTypeName}</option>
</c:forEach>
</select></td></tr>
<tr><td>参数名:</td><td><input type="text" class="form-control" name="paramName" id="paramName"/></td></tr>
<tr><td>参数值:</td><td id="addParamVal"><input type="text" class="form-control" name="paramValue" id="paramValue" onkeyup="(this.v=function(){this.value=this.value.replace(/[^0-9]+/,'');}).call(this)" onblur="this.v();" /></td></tr>
<tr><td></td><td>
<button type="button" id="addParam" class="btn btn-primary">添加参数</button></td></tr>
<tr><td></td>
<td><button type="button" id="modelSubmit" class="btn btn-primary">确定</button>
<button type="reset" class="btn btn-default" id="modelReset">清空</button>
<button type="button" class="btn btn-warning" id="modelBack">返回</button>
</td></tr>
</table>
</form>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<script type="text/javascript">
//加载页面时显示
var getDataModelId = "${dataModel.dataModelId}";
var getDataModelName = "${dataModel.dataModelName}";
var getRuleDefinition = "${dataModel.ruleDefinition}";
var getScript = "${dataModel.modelScriptName}";
var getModelTypeId = "${dataModel.dataModelTypeId}";
var getModelStatus = "${dataModel.modelStatus}";
var getServerId = "${dataModel.serverId}";
var getBusinessStartTime = "${dataModel.businessStartTime}";
var getBusinessEndTime = "${dataModel.businessEndTime}";
getBusinessStartTime = getBusinessStartTime.replace(".0","");
getBusinessEndTime = getBusinessEndTime.replace(".0","");
$("#dataModelId").text(getDataModelId);
/* $("#dataModelName").text(getDataModelName);
$("#ruleDefinition").text(getRuleDefinition); */
$("#dataModelName").val(getDataModelName);
$("#ruleDefinition").val(getRuleDefinition);
$("#modelExeScriptName").val(getScript);
$("#modelType").val(getModelTypeId);
$("#deployedServer").val(getServerId);
$("#modelStatus").val(getModelStatus);
$("#businessStartTime").val(getBusinessStartTime);
$("#businessEndTime").val(getBusinessEndTime)
/* $("#businessStartTime").val(formatDate(fillBusinessStartTime ,"yyyy-MM-dd HH:mm:ss"));
$("#businessEndTime").val(formatDate(new Date(getBusinessEndTime),"yyyy-MM-dd HH:mm:ss")) */;
</script>
<script type="text/javascript">
//参数类型变化
$("#paramDataType").change(function(){
$("#addParamVal").empty();
var paramDataType = $(this).find("option:selected").val();
if(paramDataType=="字符"){
var addDataValue = $("<input type='text' class='form-control name=paramValue' id='paramValue'/>");
$("#addParamVal").append(addDataValue);
}else if(paramDataType=="日期"){
var addDataValue = $("<input type='text' class='form-control name=paramValue' id='paramValue' onFocus='WdatePicker({dateFmt:\" yyyy-MM-dd \"})'/>");
$("#addParamVal").append(addDataValue);
}else if(paramDataType=="时间"){
var addDataValue = $("<input type='text' class='form-control name=paramValue' id='paramValue' onFocus='WdatePicker({})'/>");
$("#addParamVal").append(addDataValue);
}else{
var addDataValue = $("<input type='text' class='form-control' name='paramValue' id='paramValue' onkeyup='(this.v=function(){this.value=this.value.replace(/[^0-9]+/,\"\");}).call(this)' onblur='this.v();'/>");
$("#addParamVal").append(addDataValue);
}
});
//模型名称是否重复判断
var isDouble = true;
$("#dataModelName").blur(function(){
if(""!=$.trim($(this).val())){
var modelName = $(this).val();
$.ajax({
type: "GET",
contentType : "application/json",
dataType: "text",
url: "${ctx}/ModelManage/ModelParameterConfiguration/select_modelName/"+encodeURIComponent(modelName)+"/"+getDataModelId,
beforeSend: function(data) { $("#modelSubmit").attr("disabled",true);},
success:function(data){
data = parseInt(data);
if(0==data){
$("#writeWarningInf").html("");
isDouble = false;
$("#modelSubmit").attr("disabled",false);
}else{
$("#writeWarningInf").html("<img src='${ctx}/static/images/x.png'/> 标题已存在");
isDouble = true;
$("#modelSubmit").attr("disabled",true);
}
}
});
}
});
//修改一条参数
function updateRow(elementTag){
$("#addParam").text("修改参数");
$("#addTr").find("tr").removeClass("orange-tr");
$(elementTag).parents("tr").eq(0).addClass("orange-tr");
var paramName = $(elementTag).parents("tr").find("td").eq(0).html();
var paramValue = $(elementTag).parents("tr").find("td").eq(1).html();
var paramType = $(elementTag).parents("tr").find("td").eq(2).html();
$("#paramDataType option[value='"+paramType+"']").attr("selected","selected");
$("#paramDataType").change();
$("#paramName").val(paramName);
$("#paramValue").val(paramValue);
}
//删除一条参数
function deleteRow(elementTag, parameterId){
if(parameterId==""){
$(elementTag).parent().parent().remove();
}else{
$.ajax({
type : "GET",
contentType : "application/json",
url:"${ctx}/ModelManage/ModelParameterConfiguration/deleteParameter?parameterId="+parameterId,
dataType : "text",
beforeSend: function(data){},
success:function(){
$(elementTag).parent().parent().remove();
}
});
}
}
//删除所有参数
function deleteAllTr(){
$.ajax({
type : "GET",
contentType : "application/json",
url:"${ctx}/ModelManage/ModelParameterConfiguration/deleteParameter?dataModelId="+getDataModelId,
dataType : "text",
beforeSend: function(data){},
success:function(){
$("#addTr").empty();
}
});
};
//修改/增加一条参数
$("#addParam").click(function(){
var paramDataType = $("#paramDataType").val();
var paramName = $.trim($("#paramName").val());
var paramValue = $("#paramValue").val();
if(paramName==""){
$.alert("参数名不能为空");
}else{
if($("#addTr").find("tr.orange-tr").html()==null){
var addRow = $("<tr><td>"+paramName+"</td><td>"+paramValue+"</td><td>"+paramDataType+"</td><td><a href='javascript:;' title='' onclick='deleteRow(this,\"\")'>删除</a> <a href='javascript:;' onclick='updateRow(this)'>修改</a></td></tr>");
$("#addTr").append(addRow);
$("#paramName").attr("value","");
$("#paramValue").attr("value","");
}else{
var findTr = $("#addTr").find("tr.orange-tr");
$(findTr).find("td").eq(0).html(paramName);
$(findTr).find("td").eq(1).html(paramValue);
$(findTr).find("td").eq(2).html(paramDataType);
$("#addTr").find("tr").removeClass();
$("#addParam").text("添加参数");
$("#paramName").attr("value","");
$("#paramValue").attr("value","");
}
}
});
//清空按钮
$("#modelReset").click(function(){
deleteAllTr();
});
//表单提交
$("#modelSubmit").click(function(){
if($.trim($("#dataModelName").val())==""){
$.alert("模型名称不能为空");
}else if($("#modelExeScriptName").val()==""){
$.alert("模型执行脚本不能为空");
}else if($("#businessStartTime").val()==""){
$.alert("业务开始时间不能为空");
}else if($("#businessEndTime").val()==""){
$.alert("业务结束时间不能为空");
}else{
if($.trim($("#paramName").val())!=""){
$.dialog({
title: "提醒",
content: "有参数尚未添加,确定提交",
ok: function(){
var i = $("#addTr").find("tr").size();
if(0==i){
var form = $("#modelUpdateForm");
form.attr("action","${ctx}/ModelManage/ModelParameterConfiguration/updateDataModelForm");
form.submit();
form.attr("action","#");
}else{
$("#addTr").find("tr").each(function(){
var paramName = $(this).find("td").eq(0).html();
var paramValue = $(this).find("td").eq(1).html();
var paramType = $(this).find("td").eq(2).html();
var paramId = $(this).find("td").find("a").attr("title");
if(paramId!=""){
$.ajax({
type : "GET",
contentType : "application/json",
url:"${ctx}/ModelManage/ModelParameterConfiguration/updateParameter?paramName="+encodeURIComponent(paramName)+"¶mValue="+encodeURIComponent(paramValue)+"¶mType="+encodeURIComponent(paramType)+"¶mId="+paramId,
dataType : "text",
async: false,
beforeSend: function(data){},
success:function(){
i--;
if(i==0){
var form = $("#modelUpdateForm");
form.attr("action","${ctx}/ModelManage/ModelParameterConfiguration/updateDataModelForm");
form.submit();
form.attr("action","#");
}
}
});
}else{
$.ajax({
type : "GET",
contentType : "application/json",
url:"${ctx}/ModelManage/ModelParameterConfiguration/updateParameter?dataModelId="+getDataModelId+"¶mName="+encodeURIComponent(paramName)+"¶mValue="+encodeURIComponent(paramValue)+"¶mType="+encodeURIComponent(paramType),
dataType : "text",
beforeSend: function(data){ },
success:function(){
i--;
if(i==0){
var form = $("#modelUpdateForm");
form.attr("action","${ctx}/ModelManage/ModelParameterConfiguration/updateDataModelForm");
form.submit();
form.attr("action","#");
}
}
});
}
});
}
},
okValue: "确定",
cancel:function(){},
cancelValue: "取消"
});
}else{
var i = $("#addTr").find("tr").size();
if(0==i){
var form = $("#modelUpdateForm");
form.attr("action","${ctx}/ModelManage/ModelParameterConfiguration/updateDataModelForm");
form.submit();
form.attr("action","#");
}else{
$("#addTr").find("tr").each(function(){
var paramName = $(this).find("td").eq(0).html();
var paramValue = $(this).find("td").eq(1).html();
var paramType = $(this).find("td").eq(2).html();
var paramId = $(this).find("td").find("a").attr("title");
if(paramId!=""){
$.ajax({
type : "GET",
contentType : "application/json",
url:"${ctx}/ModelManage/ModelParameterConfiguration/updateParameter?paramName="+encodeURIComponent(paramName)+"¶mValue="+encodeURIComponent(paramValue)+"¶mType="+encodeURIComponent(paramType)+"¶mId="+paramId,
dataType : "text",
async: false,
beforeSend: function(data){},
success:function(){
i--;
if(i==0){
var form = $("#modelUpdateForm");
form.attr("action","${ctx}/ModelManage/ModelParameterConfiguration/updateDataModelForm");
form.submit();
form.attr("action","#");
}
}
});
}else{
$.ajax({
type : "GET",
contentType : "application/json",
url:"${ctx}/ModelManage/ModelParameterConfiguration/updateParameter?dataModelId="+getDataModelId+"¶mName="+encodeURIComponent(paramName)+"¶mValue="+encodeURIComponent(paramValue)+"¶mType="+encodeURIComponent(paramType),
dataType : "text",
beforeSend: function(data){ },
success:function(){
i--;
if(i==0){
var form = $("#modelUpdateForm");
form.attr("action","${ctx}/ModelManage/ModelParameterConfiguration/updateDataModelForm");
form.submit();
form.attr("action","#");
}
}
});
}
});
}
}
}
});
$("#modelBack").click(function(){
location.href="${ctx}/ModelManage/ModelResult";
});
</script>
</body>
</html>