Countdown_wev8.js
13.4 KB
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
if(typeof(MEC_NS) == 'undefined'){
MEC_NS = {};
}
MEC_NS.Countdown = function(type, id, mecJson){
this.type = type;
if(!id){
id = new UUID().toString();
}
this.id = id;
if(!mecJson){
mecJson = this.getDefaultMecJson();
}
this.mecJson = mecJson;
}
/*获取id。 必需的方法*/
MEC_NS.Countdown.prototype.getID = function(){
return this.id;
};
MEC_NS.Countdown.prototype.runWhenPageOnLoad = function(){
var theId = this.id;
$("#timeContainer_"+theId).children().remove();
this.afterDesignHtmlBuild();
};
/*获取设计的html, 页面上怎么显示控件完全依赖于此方法。 必需的方法*/
MEC_NS.Countdown.prototype.getDesignHtml = function(){
var theId = this.id;
var countdowndate;
var rightActionTypeV = this.mecJson["rightActionType"];
var datasource = this.mecJson["datasource"];
var rightAction_SQL = this.mecJson["rightAction_SQL"];
var parameter = this.mecJson["parameter"];
if(rightActionTypeV==1){
countdowndate = this.mecJson["countdowndate1"];
if(countdowndate==""){
var htm = "<div class=\"Design_Countdown_Tip\">"+SystemEnv.getHtmlNoteName(4273)+"</div>"; //信息设置不完整,未配置截止日期
return htm;
}
}else if(rightActionTypeV==2){
var theThis = this;
if($.trim(rightAction_SQL) == ""){
var htm = "<div class=\"Design_Countdown_Tip\">"+SystemEnv.getHtmlNoteName(4274)+"</div>"; //信息设置不完整,未配置数据来源SQL
return htm;
}else{
if($.trim(rightAction_SQL).toLowerCase().indexOf("select ") == 0){
var regexp = /\{(.*)\}/;
if(regexp.test(rightAction_SQL)){
var htm = "<div class=\"Design_Countdown_Tip\">"+SystemEnv.getHtmlNoteName(4275)+"</div>"; //SQL中包含自定义变量,预览时显示
return htm;
}
rightAction_SQL = $m_encrypt(rightAction_SQL);// 系统安全编码
if(rightAction_SQL == ""){// 系统安全关键字验证不通过
var tipHtm = "<div class=\"Design_Countdown_Tip\">"+SystemEnv.getHtmlNoteName(4207)+"</div>"; //数据来源SQL未通过系统安全测试,请检查关键字
return tipHtm;
}
var flag;
MADCD_DataGet(theId, datasource, rightAction_SQL, function(status,date){
if(status == "0"){
flag = 0;
}else if(status == "-1"){
flag = -1;
}else if(status == "1"){
countdowndate = date;
}
});
if(flag==0){
var htm = "<div class=\"Design_Countdown_Tip\">"+SystemEnv.getHtmlNoteName(4208)+"</div>"; //查询数据来源SQL时出现错误,请检查SQL是否拼写正确
return htm;
}else if(flag==-1) {
var htm = "<div class=\"Design_Countdown_Tip\">"+SystemEnv.getHtmlNoteName(4276)+"</div>"; //查询数据来源SQL时出现异常
return htm;
}
}
}
}else if(rightActionTypeV==3){
if(parameter==""){
var htm = "<div class=\"Design_Countdown_Tip\">"+SystemEnv.getHtmlNoteName(4277)+"</div>"; //信息设置不完整,未配置参数
return htm;
}else {
var htm = "<div id=\"timeContainer_"+theId+"\" data-timer=\"90\" style=\"height: 86px; overflow: hidden; position: relative; z-index: 0; \"></div>";
return htm;
}
}
var htm = "<div id=\"timeContainer_"+theId+"\" data-date=\""+ countdowndate +"\" style=\"height: 86px; overflow: hidden; position: relative; z-index: 0; \"></div>";
return htm;
};
/*获取构建属性编辑窗体的html,添加和单击控件后会调用此方法,由此方法去构建属性编辑窗体。 必需的方法*/
MEC_NS.Countdown.prototype.getAttrDlgHtml = function(){
var styleL = "_style" + _userLanguage;
var theId = this.id;
var htm = "<div id=\"MADCD_"+theId+"\">"
+ "<div class=\"MADCD_Title\">"+SystemEnv.getHtmlNoteName(3614)+"</div>" //截止日期
+ "<div class=\"MADCD_BaseInfo\">"
+ "<div class=\"MADCD_BaseInfo_Entry\">"
+ "<span class=\"MADCD_BaseInfo_Entry_Label\">"+SystemEnv.getHtmlNoteName(4278)+"</span>" //执行操作:
+ "<span class=\"MADCD_BaseInfo_Entry_Content\">"
+ "<span class=\"cbboxEntry cbboxEntry1 cbboxEntry"+styleL+"\">"
+ "<input type=\"checkbox\" name=\"rightActionType_"+theId+"\" value=\"1\" onclick=\"MADCD_ChangeRAT(this, '"+theId+"');\"/><span class=\"cbboxLabel\">"+SystemEnv.getHtmlNoteName(4279)+"</span>" //选择时间
+ "</span>"
+ "<span class=\"cbboxEntry cbboxEntry2 cbboxEntry"+styleL+"\">"
+ "<input type=\"checkbox\" name=\"rightActionType_"+theId+"\" value=\"2\" onclick=\"MADCD_ChangeRAT(this, '"+theId+"');\"/><span class=\"cbboxLabel\">"+SystemEnv.getHtmlNoteName(4280)+"</span>" //手动输入SQL
+ "</span>"
+ "<span class=\"cbboxEntry cbboxEntry1 cbboxEntry"+styleL+"\">"
+ "<input type=\"checkbox\" name=\"rightActionType_"+theId+"\" value=\"3\" onclick=\"MADCD_ChangeRAT(this, '"+theId+"');\"/><span class=\"cbboxLabel\">"+SystemEnv.getHtmlNoteName(4281)+"</span>" //获取参数
+ "</span>"
+ "</span>"
+ "</div>"
+ "<div class=\"rightActionContent actionContent\" id=\"rightActionContent_"+theId+"_1\" style=\"display: none;\">"
+"<div class=\"MADCD_DataSource\">"
+"<div style=\"position: relative;padding-left: 60px;\">"
+"<span class=\"MADCD_DataSource_Label MADCD_DataSource_Label1 MADCD_DataSource_Label1"+styleL+"\">"+SystemEnv.getHtmlNoteName(4282)+"</span>" //截止日期:
+ "<input type=\"text\" id=\"countdowndate_"+theId+"\" class=\"MADCD_Text MADCD_Text"+styleL+"\" style=\"width: 145px;\" onfocus=\"WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss',minDate:'%y-%M-%d %H:%m:%s'})\"/>"
+"</div>"
+"</div>"
+ "</div>"
+ "<div class=\"rightActionContent actionContent\" id=\"rightActionContent_"+theId+"_2\" style=\"display: none;\">"
+"<div class=\"MADCD_DataSource\">"
+"<div style=\"position: relative;padding-left: 60px;\">"
+"<span class=\"MADCD_DataSource_Label MADCD_DataSource_Label"+styleL+"\" style=\"position: absolute;top: -1px;left: 0px;\">"+SystemEnv.getHtmlNoteName(4201)+"</span>" //数据源:
+"<select class=\"MADCD_Select MADCD_Select"+styleL+"\" id=\"datasource_"+theId+"\">"
+" <option value=\"\">(local)</option>"
+"</select>"
+"</div>"
+"</div>"
+ "<textarea id=\"rightAction_SQL_"+theId+"\" class=\"MADCD_Textarea\" placeholder=\""+SystemEnv.getHtmlNoteName(4283)+"\"></textarea>" //请在此处输入SQL...
+"<div style=\"padding-top: 3px;\">"+SystemEnv.getHtmlNoteName(4284)+"</div>" //请输入一个能返回类似2014-12-12 12:12:12这种日期时间的数据的SQL。
+ "</div>"
+ "<div class=\"rightActionContent actionContent\" id=\"rightActionContent_"+theId+"_3\" style=\"display: none;\">"
+"<div class=\"MADCD_DataSource\">"
+"<div style=\"position: relative;padding-left: 60px;\">"
+"<span class=\"MADCD_DataSource_Label\" style=\"position: absolute;top: 3px;left: 0px;\">"+SystemEnv.getHtmlNoteName(4285)+"</span>" //获取参数:
+ "<input type=\"text\" id=\"parameter_"+theId+"\" class=\"MADCD_Text\" style=\"width: 243px;\" />"
+"</div>"
+"</div>"
+ "</div>"
+ "</div>"
+ "<div class=\"MADCD_Bottom\"><div class=\"MADCD_SaveBtn\" onclick=\"refreshMecDesign('"+theId+"');\">"+SystemEnv.getHtmlNoteName(3451)+"</div></div>" //确定
+ "</div>";
htm += "<div class=\"MAD_Alert\">"+SystemEnv.getHtmlNoteName(4115)+"</div>"; //已生成到布局
return htm;
};
/*页面上显示控件完成后调用此方法,主要用于一些必须要使用js对页面进行后置操作时,无需要此方法可至空。 不必需的方法,有此方法系统自动调用*/
MEC_NS.Countdown.prototype.afterDesignHtmlBuild = function(){
var theId = this.id;
if($("#timeContainer_"+theId).length > 0){
var $htm = $("#timeContainer_"+theId);
/*$htm[0].value = this.getHtm();*/
/*此处拿时间差距*/
$htm.TimeCircles({
time : {
Days: {
show: false,
text: "天",
color: "#FC6"
},
Hours: {
show: false,
text: "时",
color: "#9CF"
},
Minutes: {
show: false,
text: "分",
color: "#BFB"
},
Seconds: {
show: false,
text: "秒",
color: "#F99"
}
},
refresh_interval: 0.1,
count_past_zero: true,
circle_bg_color: "#ddd",
fg_width: 0.03,
bg_width: 0.2
});
}
};
/*构建属性编辑窗体完成后调用此方法,主要用于一些必须要使用js对页面进行后置操作时,无需要此方法可至空。 不必需的方法,有此方法系统自动调用*/
MEC_NS.Countdown.prototype.afterAttrDlgBuild = function(){
var theId = this.id;
var rightActionTypeV = this.mecJson["rightActionType"];
var $rightActionType = $("input[type='checkbox'][name='rightActionType_"+theId+"'][value='"+rightActionTypeV+"']");
if($rightActionType.length > 0){
//MADCD_ChangeRAT($rightActionType[0], theId);
$rightActionType.attr("checked", "checked");
$rightActionType.triggerHandler("click");
}
var countdowndate = this.mecJson["countdowndate1"]; //截止日期
$("#countdowndate_"+theId).val(countdowndate);
//动态获取数据源的值,并给数据源添加HTML
$("#datasource_" + theId).val(this.mecJson["datasource"]);
MADCD_setDataSourceHTML(theId,this.mecJson["datasource"]);
var $sql = $("#rightAction_SQL_"+theId);
$sql[0].value = this.mecJson["rightAction_SQL"];
$sql.focus(function(){
$(this).addClass("MADCD_Textarea_Focus");
});
$sql.blur(function(){
$(this).removeClass("MADCD_Textarea_Focus");
});
$("#parameter_" + theId).val(this.mecJson["parameter"]);
$("#MADCD_"+theId).jNice();
};
/*获取JSON*/
MEC_NS.Countdown.prototype.getMecJson = function(){
var theId = this.id;
this.mecJson["id"] = theId;
this.mecJson["mectype"] = this.type;
var $attrContainer = $("#MADCD_"+theId);
if($attrContainer.length > 0){
var rightActionType = $("input[type='checkbox'][name='rightActionType_"+theId+"']:checked").val();
this.mecJson["rightActionType"] = rightActionType;
var countdowndate;
var datasource;
var rightAction_SQL;
var parameter;
if(rightActionType==1) {
countdowndate = $("#countdowndate_"+theId).val(); //截止日期
this.mecJson["countdowndate1"] = countdowndate;
}else if(rightActionType==2) {
datasource = $("#datasource_" + theId).val();
rightAction_SQL = $("#rightAction_SQL_"+theId).val();
this.mecJson["datasource"] = datasource;
this.mecJson["rightAction_SQL"] = rightAction_SQL;
}else if(rightActionType==3) {
parameter = $("#parameter_"+theId).val();
this.mecJson["parameter"] = parameter;
}
}
return this.mecJson;
};
MEC_NS.Countdown.prototype.getDefaultMecJson = function(){
var theId = this.id;
var defMecJson = {};
defMecJson["id"] = theId;
defMecJson["mectype"] = this.type;
defMecJson["rightActionType"] = 1;
defMecJson["countdowndate1"] = "";
defMecJson["datasource"] = "";
defMecJson["rightAction_SQL"] = "";
defMecJson["parameter"] = "";
return defMecJson;
};
function MADCD_ChangeRAT(cbObj, mec_id){
setTimeout(function(){ //checkbox用了插件,不延时checkbox的checked状态获取不准确
var objV = cbObj.value;
if(!cbObj.checked){
changeCheckboxStatus(cbObj, true);
return;
}else{
$("input[type='checkbox'][name='rightActionType_"+mec_id+"']").each(function(){
if(this.value != objV){
changeCheckboxStatus(this, false);
}
});
}
$("#MADCD_"+mec_id+" .rightActionContent").hide();
$("#rightActionContent_" + mec_id + "_" + objV).show();
},100);
}
function MADCD_OpenSQLHelp(){
var url = "/mobilemode/chartSQLHelp.jsp";
var dlg = top.createTopDialog();//获取Dialog对象
dlg.Model = true;
dlg.Width = 540;//定义长度
dlg.Height = 555;
dlg.URL = url;
dlg.Title = SystemEnv.getHtmlNoteName(4204); //SQL帮助
dlg.show();
}
function MADCD_setDataSourceHTML(mec_id,val){
var $MADL_DataSource = $("#datasource_" + mec_id);
var url = jionActionUrl("com.weaver.formmodel.mobile.servlet.MobileAppBaseAction", "action=getDataSource");
FormmodeUtil.doAjaxDataLoad(url, function(datas){
for(var i = 0; i < datas.length; i++){
var data = datas[i];
var pointid = data;
var selected = "";
if (pointid=="" || typeof(pointid)=="undefined") continue;
if (pointid == val) selected = "selected";
var dataSourceSelectHtml = "<option value=\""+pointid+"\" "+selected+">";
dataSourceSelectHtml += pointid;
dataSourceSelectHtml += "</option>";
$MADL_DataSource.append(dataSourceSelectHtml);
}
});
}
function MADCD_DataGet(theId, datasource, sql, fn){
var url = jionActionUrl("com.weaver.formmodel.mobile.mec.servlet.MECAdminAction", "&sql="+encodeURIComponent(sql));
$.ajax({
type:"POST",
async:false,
url:url,
data:{action:"getDataBySQLWithCountdown",datasource:datasource},
success : function (responseText){
var jObj = $.parseJSON(responseText);
var status = jObj["status"];
var date = jObj["date"];
fn.call(this, status, date);
}
});
/*$.post(url, null, function(responseText){
var jObj = $.parseJSON(responseText);
var status = jObj["status"];
if(status == "0"){
var tipHtm = "<div class=\"Design_Countdown_Tip\">查询数据来源SQL时出现错误,请检查SQL是否拼写正确</div>";
$TimeContainer.html(tipHtm);
}else if(status == "-1"){
var tipHtm = "<div class=\"Design_Countdown_Tip\">出现异常</div>";
$TimeContainer.html(tipHtm);
}else if(status == "1"){
var date = jObj["date"];
fn.call(this, date);
}
});*/
}