GaugeChart_wev8.js
24.6 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
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
if(typeof(MEC_NS) == 'undefined'){
MEC_NS = {};
}
MEC_NS.GaugeChart = function(typeTmp, idTmp, mecJsonTmp){
this.type = typeTmp;
if(!idTmp){
idTmp = new UUID().toString();
}
this.id = idTmp;
if(!mecJsonTmp){
mecJsonTmp = this.getDefaultMecJson();
}
this.mecJson = mecJsonTmp;
var that = this;
require(['mec'], function(mec){
that.remark = function(){
return mec.remark(that.mecJson.title);
};
});
};
/*获取id。 必需的方法*/
MEC_NS.GaugeChart.prototype.getID = function(){
return this.id;
};
MEC_NS.GaugeChart.prototype.runWhenPageOnLoad = function(){
this.afterDesignHtmlBuild();
};
/*获取设计的html, 页面上怎么显示控件完全依赖于此方法。 必需的方法*/
MEC_NS.GaugeChart.prototype.getDesignHtml = function(){
return getDesignHtml(this);
};
MEC_NS.GaugeChart.loadData = function(callback) {
UrlSelectUtil.nav.loadNavItems(callback);
};
/*页面上显示控件完成后调用此方法,主要用于一些必须要使用js对页面进行后置操作时,无需要此方法可至空。 不必需的方法,有此方法系统自动调用*/
MEC_NS.GaugeChart.prototype.afterDesignHtmlBuild = function(){
var that = this;
var theId = this.id;
var p = replaceObjMutilLanguage(this.mecJson);
p.id = theId;
var chartMLJson = {};
chartMLJson['4205'] = SystemEnv.getHtmlNoteName(4205);//图表信息设置不完整,未配置数据来源SQL
chartMLJson['4206'] = SystemEnv.getHtmlNoteName(4206);//SQL中可能包含待解析的参数变量,需运行时显示
chartMLJson['4208'] = SystemEnv.getHtmlNoteName(4208);//查询数据来源SQL时出现错误,请检查SQL是否拼写正确
p["multiLJson"] = chartMLJson;
var _build = function() {
var newP = JSON.parse(JSON.stringify(p));
newP._mode = "0";
Mobile_NS.GaugeChart.build(newP);
};
if (p.sql || !p.isdefault) return _build();
MADGaugeChart_getDefaultSQL(theId, function (sql) {
p.sql = sql;
that.mecJson.sql = sql;
$("#sql_" + theId).val(sql);
_build();
});
this.mecJson["isdefault"] = false;
};
/*获取构建属性编辑窗体的html,添加和单击控件后会调用此方法,由此方法去构建属性编辑窗体。 必需的方法*/
MEC_NS.GaugeChart.prototype.getAttrDlgHtml = function(){
var styleL = "_style" + _userLanguage;
var theId = this.id;
var htm = "<div id=\"MADGaugeChart_"+theId+"\" class=\"MADGaugeChart_Container\">"
+"<div class=\"title\">"
+SystemEnv.getHtmlNoteName(4650) //基本信息
+"</div>"
+"<div class=\"form-group\">"
+"<div class=\"row\">"
+"<span class=\"col-2 span-control MADGaugeChart_BaseInfo_Label"+styleL+"\">"+SystemEnv.getHtmlNoteName(3978)+"</span>" //标题:
+"<div class=\"col-m-8\"><input class=\"form-control\" data-autobind='title' id=\"title_"+theId+"\" type=\"text\" placeholder=\""+SystemEnv.getHtmlNoteName(4788)+":"+SystemEnv.getHtmlNoteName(5376)+"\" "+MLanguage.ATTR+"/></div>"//某站点用户访问来源
+"</div>"
+"<div class=\"row\">"
+"<span class=\"col-2 span-control MADGaugeChart_BaseInfo_Label"+styleL+"\">"+SystemEnv.getHtmlNoteName(4128)+"</span>" //高度:
+"<div class=\"col-m-8\"><input class=\"form-control\" data-autobind='height' id=\"height_"+theId+"\" type=\"text\"/></div>"
+"</div>"
+"<div class=\"row\">"
+"<span class=\"col-2 span-control MADGaugeChart_BaseInfo_Label"+styleL+"\">"+SystemEnv.getHtmlNoteName(4191)+"</span>" //宽度:
+"<div class=\"col-m-8\"><input class=\"form-control\" data-autobind='width' id=\"width_"+theId+"\" type=\"text\" placeholder=\""+SystemEnv.getHtmlNoteName(4192)+"\"/></div>" //如:600,此处缺省则为页面宽度
+"</div>"
+"</div>"
+"<div class=\"title\">"
+SystemEnv.getHtmlNoteName(4652) //数据来源
+"</div>"
+"<div class=\"MADGaugeChart_DataSource\">"
+"</div>"
+"<div class=\"form-group\">"
+"<div class=\"row\">"
+"<span class=\"col-2 span-control MADGaugeChart_DataSource_Label"+styleL+"\">"+SystemEnv.getHtmlNoteName(4201)+"</span>" //数据源:
+"<div class=\"col-m-8\"><select class=\"form-control\" data-autobind id=\"datasource_"+theId+"\">"
+" <option value=\"\">(local)</option>"
+"</select></div>"
+"</div>"
+"<div class=\"row\">"
+"<span class=\"col-2 span-control MADGaugeChart_BaseInfo_Label"+styleL+"\">SQL:</span>"
+"<div class=\"col-m-8\">"
+"<textarea class=\"area-control requireded\" data-autobind='sql' id=\"sql_"+theId+"\"></textarea>"
+"<a class=\"help-link fl\" href=\"javascript:void(0);\" onclick=\"MADGaugeChart_OpenSQLHelp();\">"+SystemEnv.getHtmlNoteName(4202)+"</a>"
+"<a class=\"help-link fr\" href=\"javascript:void(0);\" onclick=\"MADGaugeChart_fillSQL('"+theId+"');\">"+SystemEnv.getHtmlNoteName(4653)+"</a>"//填充示例SQL
+"</div>"
+"</div>"
+ "<div class=\"row\" style=\"position: relative;\">"
+ "<div class=\"col-2 span-control\">"+SystemEnv.getHtmlNoteName(5378) + "</div>" //图表查询:
+ "<div class=\"col-m-8\" style=\"position: relative;\">"
+ "<input type=\"checkbox\" id=\"advancedSearch_"+theId+"\" onclick=\"MADGaugeChart_DisplayParamsConfig(this, '"+theId+"');\"/>"
+ "<div class=\"edit-after edit-advanced MADGaugeChart_EditParamsConfig MADGaugeChart_EditParamsConfig"
+ styleL + "\" onclick=\"MADGaugeChart_EditParamsConfig('"+theId+"');\"></div>"
+ "<input id=\"searchParams_"+theId+"\" type=\"hidden\"/>"
+ "</div>"
+"<a style=\"padding-left:5px;padding-top: 2px;\" class=\"help-link\" href=\"javascript:void(0);\" onclick=\"MADGaugeChart_OpenSearchHelp();\">"+SystemEnv.getHtmlNoteName(5380)+"</a>" //如何使用图表查询?
+ "</div>"
+"</div>"
+ "<div class=\"title\">"
+ SystemEnv.getHtmlNoteName(4860) //仪表盘轴线颜色
+ "<div class=\"add-before\" data-autobind onclick=\"MADGaugeChart_AddColorItem('"+theId+"');\">"+SystemEnv.getHtmlNoteName(3518)+"</div>" //添加
+ "</div>"
+ "<div class=\"form-group\">"
+ "<div class=\"axis_color_content\">"
+ "<div class=\"tip-control axis_color_empty_tip\">"+SystemEnv.getHtmlNoteName(4463)+"</div>" //单击右上角的添加按钮以添加百分比区域颜色
+ "<ul class=\"content-up\"></ul>"
+ "</div>"
+ "</div>"
+"<div class=\"title\">"+SystemEnv.getHtmlNoteName(4861)+"</div>"//仪表盘标题
+"<div class=\"form-group\">"
+"<div class=\"row\">"
+"<span class=\"col-2 span-control MADBarChart_BaseInfo_Label"+styleL+"\">"+SystemEnv.getHtmlNoteName(4469)+"</span>" //字体大小
+"<div class=\"col-m-8\"><input class=\"form-control\" data-autobind='gaugeTitleFontSize' id=\"gaugeTitleFontSize_"+theId+"\" type=\"text\" placeholder=\""+SystemEnv.getHtmlNoteName(4862)+"\"/></div>" //字体大小,如:12
+"</div>"
+"<div class=\"row\">"
+"<span class=\"col-2 span-control MADBarChart_BaseInfo_Label"+styleL+"\">"+SystemEnv.getHtmlNoteName(4468)+"</span>" //字体颜色
+"<div class=\"col-m-8\"><input class=\"form-control\" data-autobind='gaugeTitleFontColor' id=\"gaugeTitleFontColor_"+theId+"\" type=\"text\" placeholder=\""+SystemEnv.getHtmlNoteName(4863)+"\"/></div>" //字体颜色,如:#333
+"</div>"
+"</div>"
+"<div class=\"title\">"+SystemEnv.getHtmlNoteName(4864)+"</div>"//仪表盘详情
+"<div class=\"form-group\">"
+"<div class=\"row\">"
+"<span class=\"col-2 span-control MADBarChart_BaseInfo_Label"+styleL+"\">"+SystemEnv.getHtmlNoteName(4469)+"</span>" //字体大小
+"<div class=\"col-m-8\"><input class=\"form-control\" data-autobind='gaugeDetailFontSize' id=\"gaugeDetailFontSize_"+theId+"\" type=\"text\" placeholder=\""+SystemEnv.getHtmlNoteName(4862)+"\"/></div>" //字体大小,如:12
+"</div>"
+"<div class=\"row\">"
+"<span class=\"col-2 span-control MADBarChart_BaseInfo_Label"+styleL+"\">"+SystemEnv.getHtmlNoteName(4468)+"</span>" //字体颜色
+"<div class=\"col-m-8\"><input class=\"form-control\" data-autobind='gaugeDetailFontColor' id=\"gaugeDetailFontColor_"+theId+"\" type=\"text\" placeholder=\""+SystemEnv.getHtmlNoteName(4863)+"\"/></div>" //字体颜色,如:#333
+"</div>"
+"</div>"
+"<div class=\"title\">"
+SystemEnv.getHtmlNoteName(4654) //其他设置
+"</div>"
+"<div class=\"form-group\">"
+"<div class=\"row\">"
+"<span class=\"col-2 span-control MADGaugeChart_BaseInfo_Label1"+styleL+"\">"+SystemEnv.getHtmlNoteName(4666)+":</span>" //图表直径
+"<div class=\"col-m-8\" style=\"position: relative;\"><input class=\"form-control\" data-autobind='radius' id=\"radius_"+theId+"\" type=\"text\" style=\"width:50px;display:inline-block;\"/><div style=\"position: absolute;left: 32px;top: 7px;color: #999;font-size: 13px;\">%</div><span class=\"font-12 ml-5\">"+SystemEnv.getHtmlNoteName(4855)+"</span></div>" //(注:取值0-100,控制图形大小)
+"</div>"
+"<div class=\"row\">"
+"<span class=\"col-2 span-control MADBarChart_BaseInfo_Label"+styleL+"\">"+SystemEnv.getHtmlNoteName(4786)+":</span>" //标签字体
+"<div class=\"col-m-8\"><input class=\"form-control\" data-autobind='labelFontSize' id=\"labelFontSize_"+theId+"\" type=\"text\" placeholder=\""+SystemEnv.getHtmlNoteName(4802)+"\"/></div>" //标签字体大小,如:12
+"</div>"
+"<div class=\"row\">"
+"<span class=\"col-2 span-control MADGaugeChart_BaseInfo_Label1"+styleL+"\">"+SystemEnv.getHtmlNoteName(4129)+"</span>" //延迟加载:
+"<div class=\"col pd-4\"><input type=\"checkbox\" id=\"lazyLoad_"+theId+"\"/></div>"
+"</div>"
+ "<div class=\"row\" style=\"position: relative;\">"
+ "<span class=\"col-2 span-control MADL_Desc"+styleL+"\">"+SystemEnv.getHtmlNoteName(4949) + "</span> " //数据格式:
+ "<div class=\"col-m-8 inline-icons\">"
+ "<div class='url-selector'>"
+ "<input type=\"text\" data-autobind='labelFormat' id=\"labelFormat_"+theId+"\" class=\"form-control MADL_Text_3"+styleL+"\" placeholder=\""+SystemEnv.getHtmlNoteName(4950)+"\"/>"
+ "</div>"
+ "</div>"
+ "</div>"
+"</div>"
+"<div class=\"title\">"
+SystemEnv.getHtmlNoteName(4415) //交互设置
+"</div>"
+"<div class=\"form-group\">"
+"<div class=\"row\">"
+"<span class=\"col-2 span-control MADGaugeChart_BaseInfo_Label"+styleL+"\">"+SystemEnv.getHtmlNoteName(3977)+"</span>" //链接地址:
//+"<div class=\"col-m-8\"><div class='url-selector'><input class=\"form-control\" id=\"clickUrl_"+theId+"\" type=\"text\" placeholder=\""+SystemEnv.getHtmlNoteName(4790)+"\"/></div></div>"//单击图表时跳转的链接地址
+ "<div class='sbHolder' id='dataurlSbHolder_"+theId+"' style='position: absolute;width:calc(100% - 72px)'>"
+ "<a href='javascript:void(0);' class='sbToggle sbToggle-btc'></a>"
+ "<input class='panel-input' type='text' readonly='readonly' unselectable='on' autocomplete='off' >"
+ "<input id='clickUrl_"+theId+"' type='hidden' name='dataurl' />"
+ "</div>"
+"</div>"
+"<div class=\"row\">"
+"<div class=\"tip-control\" style=\"display:block;\">"+SystemEnv.getHtmlNoteName(4791)+":"//链接地址中可以使用 {参数名称} 使用如下名称的参数
+"<div style=\"margin-top: 3px;\">_chart_name:"+SystemEnv.getHtmlNoteName(4792)+"。"+SystemEnv.getHtmlNoteName(4788)+" \"搜索引擎\"</div>"//数据名,类目名
+"<div style=\"margin-top: 3px;\">_chart_value:。"+SystemEnv.getHtmlNoteName(4788)+" \"35.75\"</div>"//数据值
+"<div style=\"margin-top: 3px;line-height: 20px;\">"+SystemEnv.getHtmlNoteName(4795)+"</div>"//以上参数中举例的含义,请点击上面的 如何书写SQL? 链接打开页面对照具体实例查看
+"</div>"
+"</div>"
+"</div>"
+"<div class=\"bottom\"><div class=\"save-btn\" onclick=\"refreshMecDesign('"+theId+"');\">"+SystemEnv.getHtmlNoteName(3451)+"</div></div>" //确定
+"</div>";
htm += "<div class=\"MAD_Alert\">"+SystemEnv.getHtmlNoteName(4115)+"</div>"; //已生成到布局
return htm;
};
/*构建属性编辑窗体完成后调用此方法,主要用于一些必须要使用js对页面进行后置操作时,无需要此方法可至空。 不必需的方法,有此方法系统自动调用*/
MEC_NS.GaugeChart.prototype.afterAttrDlgBuild = function(){
var theId = this.id;
var mecHandler = MECHandlerPool.getHandler(theId);
MLanguage.setValue($("#title_" + theId), this.mecJson["title"]);
$("#height_" + theId).val(this.mecJson["height"]);
$("#width_" + theId).val(Mec_FiexdUndefinedVal(this.mecJson["width"]));
$("#clickUrl_" + theId).val(Mec_FiexdUndefinedVal(this.mecJson["clickUrl"]));
UrlSelectUtil.link.setUrlLink( $("#clickUrl_"+theId).parent(),this.mecJson["clickUrl"]);
$("#labelFormat_" + theId).val(Mec_FiexdUndefinedVal(this.mecJson["labelFormat"]));
//动态获取数据源的值,并给数据源添加HTML
$("#datasource_" + theId).val(this.mecJson["datasource"]);
MADGaugeChart_setDataSourceHTML(theId,this.mecJson["datasource"]);
var $sql = $("#sql_" + theId);
$sql[0].value = this.mecJson["sql"];
$sql.focus(function(){
$(this).addClass("MADGaugeChart_Textarea_Focus");
});
$sql.blur(function(){
$(this).removeClass("MADGaugeChart_Textarea_Focus");
});
var advancedSearch = Mec_FiexdUndefinedVal(this.mecJson["advancedSearch"] , "0");
if(advancedSearch == "1"){
$("#advancedSearch_"+theId).attr("checked","checked");
$(".MADGaugeChart_EditParamsConfig", $("#MADGaugeChart_"+theId)).show();
}
$("#searchParams_"+theId).val(Mec_FiexdUndefinedVal(this.mecJson["searchParams"]));
$("#radius_" + theId).val(this.mecJson["radius"]);
$("#labelFontSize_" + theId).val(this.mecJson["labelFontSize"]);
$("#gaugeTitleFontSize_" + theId).val(this.mecJson["gaugeTitleFontSize"]);
$("#gaugeTitleFontColor_" + theId).val(this.mecJson["gaugeTitleFontColor"]);
$("#gaugeDetailFontSize_" + theId).val(this.mecJson["gaugeDetailFontSize"]);
$("#gaugeDetailFontColor_" + theId).val(this.mecJson["gaugeDetailFontColor"]);
var lazyLoad = Mec_FiexdUndefinedVal(this.mecJson["lazyLoad"]);
if(lazyLoad == "1"){
$("#lazyLoad_"+theId).checked();
}
$("#MADGaugeChart_"+theId).switcher({
onClick: function () {
mecHandler.autobind && mecHandler.autobind.update();
}
}).checkbox({
onClick: function () {
mecHandler.autobind && mecHandler.autobind.update();
}
});
var $attrContainer = $("#MADGaugeChart_" + theId);
var axisColor = this.mecJson["axisColor"];
if(!axisColor){
axisColor = [];
}
if(axisColor.length == 0){
$(".axis_color_empty_tip", $attrContainer).show();
}
for(var i = 0; i < axisColor.length; i++){
MADGaugeChart_AddColorItem(theId, axisColor[i]);
}
$("#MADGaugeChart_"+theId + " .axis_color_content > ul").sortable({
revert: false,
axis: "y",
items: "li",
handle: ".bemove",
update: function(){
mecHandler.autobind.update();
}
});
require(['urlSelector', "css!urlSelector_css"],function(){
var label = new URLSelector("labelFormat_"+theId);
label.initStaticData([
{"url":"[℃]", "name":SystemEnv.getHtmlNoteName(4951)},//温度
{"url":"#,##", "name":SystemEnv.getHtmlNoteName(4952)},//千分位
{"url":"0.00", "name":SystemEnv.getHtmlNoteName(4953)},//保留两位小数
{"url":"[¥]#,##0.00", "name":SystemEnv.getHtmlNoteName(3916)}//自定义
]);
label.init({
isStatic: true,
onClick: function () {
mecHandler.autobind.update();
}
});
});
//require("utils").urlSelector("clickUrl_"+theId);
$('#dataurlSbHolder_' + theId).on("click",function (e) {
showUrlSelectPanel(this);
e.stopPropagation();
});
};
/*获取JSON*/
MEC_NS.GaugeChart.prototype.getMecJson = function(){
var theId = this.id;
this.mecJson["id"] = theId;
this.mecJson["mectype"] = this.type;
var $attrContainer = $("#MADGaugeChart_"+theId);
if($attrContainer.length > 0){
this.mecJson["title"] = MLanguage.getValue($("#title_" + theId));
this.mecJson["height"] = $("#height_" + theId).val();
this.mecJson["width"] = $("#width_" + theId).val();
this.mecJson["clickUrl"] = $("#clickUrl_" + theId).val();
this.mecJson["labelFormat"] = $("#labelFormat_" + theId).val();
this.mecJson["datasource"] = $("#datasource_" + theId).val();
this.mecJson["sql"] = $("#sql_" + theId).val();
var axisColor = [];
var $line_li = $(".axis_color_content > ul > li", $attrContainer);
$line_li.each(function(){
var startPercent = $("input[name=startPercent]", $(this)).val().trim();
var endPercent = $("input[name=endPercent]", $(this)).val().trim();
var areaColor = $("input[name=areaColor]", $(this)).val().trim();
axisColor.push({
"start" : startPercent,
"end" : endPercent,
"color" : areaColor
});
});
this.mecJson["axisColor"] = axisColor.sort(function(a,b){return a.start - b.start});
this.mecJson["gaugeTitleFontSize"] = $("#gaugeTitleFontSize_" + theId).val();
this.mecJson["gaugeTitleFontColor"] = $("#gaugeTitleFontColor_" + theId).val();
this.mecJson["gaugeDetailFontSize"] = $("#gaugeDetailFontSize_" + theId).val();
this.mecJson["gaugeDetailFontColor"] = $("#gaugeDetailFontColor_" + theId).val();
this.mecJson["radius"] = $("#radius_" + theId).val();
this.mecJson["labelFontSize"] = $("#labelFontSize_" + theId).val();
this.mecJson["lazyLoad"] = $("#lazyLoad_"+theId).is(':checked') ? "1" : "0";
this.mecJson["advancedSearch"] = $("#advancedSearch_"+theId).is(':checked') ? "1" : "0";
this.mecJson["searchParams"] = $("#searchParams_"+theId).val();
}
return this.mecJson;
};
MEC_NS.GaugeChart.prototype.getDefaultMecJson = function(){
return {
id: this.id,
mectype: this.type,
title: "",
height: "250",
width: "",
gaugeTitleFontSize: "",
gaugeDetailFontSize: "",
gaugeTitleFontColor: "",
gaugeDetailFontColor: "",
labelFontSize: "",
radius: "85",
sql: "",
labelFormat: "",
datasource: "",
isdefault: true,
axisColor: [
{ start: 0, end: 20, color: "#91c7ae" },
{ start: 20, end: 80, color: "#63869e" },
{ start: 80, end: 100, color: "#c23531" },
],
advancedSearch: "0",
searchParams: ""
};
};
MEC_NS.GaugeChart.prototype.validate = function () {
var sql = this.mecJson.sql;
var isValid = !!sql;
if (isValid) {
return true;
} else {
var mec_id = this.id;
var $pluginAttr = $('#MAD_' + mec_id);
$pluginAttr.find('#sql_' + mec_id).parents('.col-m-8').validate({
value: sql,
rules: [{
msg: '"SQL" ' + SystemEnv.getHtmlNoteName(6041)
}],
style: {top:'110px'}
});
return {
isValid: isValid,
msg: SystemEnv.getHtmlNoteName(6074) //请设置SQL!
};
}
};
function MADGaugeChart_OpenSQLHelp(){
var dlg = top.createTopDialog();//获取Dialog对象
dlg.Model = true;
dlg.Width = 540;//定义长度
dlg.Height = 555;
dlg.URL = "/mobilemode/admin/dialog/sqlhelp/gaugeChartSQLHelp.jsp";
dlg.Title = SystemEnv.getHtmlNoteName(4204); //SQL帮助
dlg.btn = false;
dlg.show();
}
function MADGaugeChart_getDefaultSQL(mec_id, callback) {
var datasource = $("#datasource_" + mec_id).val() || "";
require("utils").api("designer/plugin", {
action: "getDbTypeByDataSource",
notification: false,
data: {
datasource: datasource
},
}, function (result) {
var sql = "select '业务指标' as name, '完成率' as label, 79.99 as value, 0 as min, 100 as max";
if (result.data.dbtype == 'oracle') {
sql += " from dual ";
}
callback(sql);
});
}
function MADGaugeChart_fillSQL(mec_id){
var $sql = $("#sql_" + mec_id);
var mecHandler = MECHandlerPool.getHandler(mec_id);
var setDefaultSQL = function() {
MADGaugeChart_getDefaultSQL(mec_id, function(sql) {
$sql.val(sql).trigger('change');
mecHandler.autobind.update();
});
};
if($.trim($sql.val()) != ""){
return confirm(SystemEnv.getHtmlNoteName(4856), setDefaultSQL);//示例SQL会覆盖现有的SQL,确认继续吗?
}
setDefaultSQL();
}
function MADGaugeChart_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 MADGaugeChart_AddColorItem(mec_id, data){
var $attrContainer = $("#MADGaugeChart_" + mec_id);
$(".axis_color_empty_tip", $attrContainer).hide();
var startPercent = "";
var endPercent = "";
var areaColor = "";
if(data){
startPercent = Mec_FiexdUndefinedVal(data["start"]);
endPercent = Mec_FiexdUndefinedVal(data["end"]);
areaColor = Mec_FiexdUndefinedVal(data["color"]);
}
var $ul = $(".axis_color_content > ul", $attrContainer);
var $li = $("<li class=\"c_li\"></li>");
var htm = "<table class=\"table\" style=\"margin:0px;\">";
htm += "<tbody>";
htm += "<tr>";
htm += "<td class=\"bemove\" width=\"20px\"></td>";
htm += "<td width=\"45px\" valign=\"middle\">";
htm += "<input name=\"startPercent\" data-autobind type=\"text\" title=\"\" class='form-control' value=\"" + startPercent + "\" placeholder=\"\"/>";
htm += "</td>";
htm += "<td width='10px' valign=\"middle\">-</td>";
htm += "<td width=\"45px\" valign=\"middle\">";
htm += "<input name=\"endPercent\" data-autobind type=\"text\" title=\"\" class='form-control' value=\"" + endPercent + "\" placeholder=\"\"/>";
htm += "</td>";
htm += "<td>%</td>";
htm += "<td width=\"*\">";
htm += "<input name=\"areaColor\" data-autobind type=\"text\" title=\"\" class='form-control' value=\"" + areaColor + "\" placeholder=\""+SystemEnv.getHtmlNoteName(4464)+"\"/>"; //颜色
htm += "</td>";
htm += "<td width=\"30px\">";
htm += "<button name=\"colorpick\" class=\"colorBox\" type=\"button\" title=\""+SystemEnv.getHtmlNoteName(4236)+"\" style=\"background-color:" + areaColor + ";\"/>"; //取色器
htm += "</td>";
htm += "<td align=\"right\">";
htm += "<span class=\"del-after2\" title=\""+SystemEnv.getHtmlNoteName(3519)+"\" onclick=\"MADGaugeChart_deleteOneItemOnPage('" + mec_id + "',this)\"></span>"; //删除
htm += "</td>";
htm += "</tr>";
htm += "</tbody>";
htm += "</table>";
$($li.html(htm));
$ul.append($li);
MADGaugeChart_bindEventOnCLi($li,mec_id);
}
function MADGaugeChart_bindEventOnCLi(obj,mec_id){
var $li = $(obj);
var mecHandler = MECHandlerPool.getHandler(mec_id);
$(".colorBox", $li).colpick({
colorScheme:'dark',
layout:'rgbhex',
color:'007aff',
onSubmit:function(hsb,hex,rgb,el) {
var eleId = $(el).attr("id");
var colorValue = "#" + hex;
$("input[name=areaColor]", $li).val(colorValue);
$(el).css('background-color', colorValue);
$(el).colpickHide();
mecHandler.autobind.update();
}
});
var $areaColor = $("input[name=areaColor]", $li);
$areaColor.on("keyup", function(){
var areaColor = $("input[name=areaColor]", $li).val().trim();
$("button[name=colorpick]", $li).css("background-color", areaColor);
});
}
function MADGaugeChart_deleteOneItemOnPage(mec_id, obj){
var mecHandler = MECHandlerPool.getHandler(mec_id);
$(obj).closest(".c_li").remove();
var $attrContainer = $("#MADGaugeChart_" + mec_id);
if($(".axis_color_content > ul > li", $attrContainer).length == 0){
$(".axis_color_empty_tip", $attrContainer).show();
}
mecHandler.autobind.update();
}
function MADGaugeChart_DisplayParamsConfig(cbObj, mec_id){
var $attrContainer = $("#MADGaugeChart_"+mec_id);
if(cbObj.checked){
$(".MADGaugeChart_EditParamsConfig", $attrContainer).show();
}else{
$(".MADGaugeChart_EditParamsConfig", $attrContainer).hide();
}
}
function MADGaugeChart_EditParamsConfig(mec_id){
var searchParams = Mec_FiexdUndefinedVal($("#searchParams_" + mec_id).val());
searchParams = compressByLZ(searchParams);
var url = "/mobilemode/admin/dialog/customSearchParamsConfig.jsp?searchParams="+searchParams;
var dlg = top.createTopDialog();//获取Dialog对象
dlg.Model = true;
dlg.Width = 600;//定义长度
dlg.Height = 600;
dlg.URL = url;
dlg.Title = SystemEnv.getHtmlNoteName(5379); //图表查询
dlg.show();
dlg.hookFn = function(result){
$("#searchParams_" + mec_id).val(result["searchParams"]);
};
}
function MADGaugeChart_OpenSearchHelp(){
var url = "/mobilemode/admin/dialog/chartSearchHelp.jsp";
var dlg = top.createTopDialog();//获取Dialog对象
dlg.Model = true;
dlg.Width = 540;//定义长度
dlg.Height = 560;
dlg.URL = url;
dlg.Title = SystemEnv.getHtmlNoteName(5379); //图表查询
dlg.btn = false;
dlg.show();
}