赣州市洪水风险预警系统二维版本
xiebin
2023-03-02 b39483c96ae572121d3c619c0b9d37634e682cc4
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
define([
    "dojo",
    "dojo/_base/declare",
    "dojo/_base/lang",
    "base/BaseWidget",
    "dojo/text!widgets/Statistics/template.html",
    "widgets/Statistics/config",
    "base/AppEvent",
    "base/ConfigData",
    "dojo/dom",
    "dojo/dom-construct",
    "dojo/dom-attr",
    "dojo/dom-style",
    "dojo/on",
    "dojo/_base/array",
    "esri/tasks/query",
    "esri/tasks/QueryTask",
    "esri/symbols/SimpleFillSymbol",
    "esri/symbols/SimpleLineSymbol",
    "esri/symbols/CartographicLineSymbol",
    "esri/graphic",
    "esri/Color",
    "esri/toolbars/draw",
    "esri/tasks/StatisticDefinition",
    "dojo/domReady!"
], function (dojo,
             declare,
             lang,
             BaseWidget,
             template,
             config,
             AppEvent,
             ConfigData,
             dom,
             domConstruct,
             domAttr,
             domStyle,
             on,
             arrayUtils,
             Query,
             QueryTask,
             SimpleFillSymbol,
             SimpleLineSymbol,
             CartographicLineSymbol,
             Graphic,
             Color,
             draw,
             StatisticDefinition) {
    var Widget = declare([BaseWidget], {
        widgetName: "StatisticsWidget",
        label: "统计分析",
        templateString: template,
        _map: null,
        statisticsArea: null,
        loading: false,
        statisticsCondition: null,
        statisticsData: null,
        _layui: null,
        constructor: function (options, srcRefNode) {
            this._map = options.map;
            StatisticsObj = this;
            $(window).resize(function () {
                setTimeout(function () {
                    if ($('#statistics-extent').is(':visible')) {
                        var maxheight = $('#tabcontainer').height() - 345;
                        $('.statistics-details').css('height', maxheight);
                        $(".statistics-details").mCustomScrollbar("update"); //更新滚动条
                    } else {
                        var maxheight = $('#tabcontainer').height() - 250;
                        $('.statistics-details').css('height', maxheight);
                        $(".statistics-details").mCustomScrollbar("update"); //更新滚动条
                    }
                }, 500);
            });
            //初始化layui弹窗
            layui.use('layer', function () {
                StatisticsObj._layui = layui.layer;
            });
        },
        postCreate: function () {
 
        },
        startup: function () {
            this.inherited(arguments);
            //初始化图层目录树
            StatisticsObj._getservices();
            // 运行右侧统计部件,和统计详情展示部件
            AppEvent.dispatchAppEvent(AppEvent.RUN_WIDGET, "echartsWidget");
            // AppEvent.dispatchAppEvent(AppEvent.RUN_WIDGET, "detailsWidget");
            //绑定右侧选择栏选择事件,并派发开始统计方法
            StatisticsObj.appendEventHandlers();
        },
        open: function () {
            var maxheight = $('#tabcontainer').height() - 345;
            $('.statistics-details').css('height', maxheight);
            this.inherited(arguments);
        },
        _getservices: function () {
            //动态构建图层目录树
            var ztreeObj = [];
            var statistcsLayerName = [];
            for (var configKey in config.statistics) {
                statistcsLayerName.push(configKey);
            }
            var resultObj = config.treeData;
            for (var i = 0; i < resultObj.length; i++) {
                if (resultObj[i].resourcesPid == 0 || statistcsLayerName.indexOf(resultObj[i].resourcesName) != -1) {
                    var searchCatalog = {};
                    searchCatalog.id = resultObj[i].resourcesId;
                    searchCatalog.pId = resultObj[i].resourcesPid;
                    searchCatalog.name = resultObj[i].resourcesName;
                    searchCatalog.path = resultObj[i].resourcesUrl;
                    ztreeObj.push(searchCatalog);
                }
            }
            var setting = {
                check: {
                    enable: false,
                },
                data: {
                    simpleData: {
                        enable: true
                    }
                },
                callback: {
                    onClick: StatisticsObj._zTreeOnClick,
                    beforeClick: StatisticsObj._beforeClick
                }
            };
            $.fn.zTree.init($("#statisticsTree"), setting, ztreeObj);
        },
        _beforeClick: function (treeId, treeNode) {
            if (!treeNode.path && treeNode.isParent) {
                var treeObj = $.fn.zTree.getZTreeObj(treeId);
                treeObj.expandNode(treeNode, !treeNode.open, false, true, true);
            }
            return treeNode.path && !treeNode.isParent;
        },
        _zTreeOnClick: function (event, treeId, treeNode) {
            //目录树点击事件
            if (treeNode.path != undefined && treeNode.path != null && treeNode.path != "") {
                // 获取目录树相关属性,填充到input栏
                $('.statistics-layer-input').val(treeNode.name);
                $('.statistics-layer-input').attr('data', treeNode.path);
                // 动态获取统计单元配置
                StatisticsObj.getStatisticsCondition(treeNode.name);
                //关闭选择框
                $(".statistics-tree-box").fadeOut(1);
            }
        },
        getStatisticsCondition: function (e) {// 动态获取统计单元配置
            for (var statisticsKey in config.statistics) {// 动态获取统计配置
                if (e.indexOf(statisticsKey) != -1) {
                    StatisticsObj.statisticsCondition = config.statistics[statisticsKey];
                    break;
                }
            }
            //添加对应统计单元
            // var optionStr = '<option data="">选择统计单元</option>';
            var optionStr = '';
            StatisticsObj.statisticsCondition.condition.map(function (value, index) {
                if (value) {
                    optionStr += '<option data="' + StatisticsObj.statisticsCondition.conditionFields[index] + '">' + value + '</option>';
                }
            });
            $('#statistics-condition').html(optionStr);
            //根据第一项判断是否显示范围选择栏
            if (StatisticsObj.statisticsCondition.condition[0] == '行政区') {
                $("#statistics-extent").hide();
                $("#statistics-city option:first").attr('selected', true);
                $("#statistics-county option:first").attr('selected', true);
                setTimeout(function () {
                    var maxheight = $('#tabcontainer').height() - 250;
                    $('.statistics-details').css('height', maxheight);
                    $(".statistics-details").mCustomScrollbar("update"); //更新滚动条
                }, 200);
            } else {
                $("#statistics-extent").show();
                var maxheight = $('#tabcontainer').height() - 345;
                $('.statistics-details').css('height', maxheight);
                $(".statistics-details").mCustomScrollbar("update"); //更新滚动条
            }
        },
        getFeaturesIds: function (url) {//先获取所有要素的OID
            $("#bg").show();
            $.get(url + '?f=pjson', function (e) {
                var displayField = JSON.parse(e).displayField;
                var statisType = $('#statistics-condition option:selected').attr('data');
                AppEvent.dispatchAppEvent("clearcolor");
                if ($('#bg').is(":hidden")) $('#bg').show();
                var queryTask = new QueryTask(url);
                //统计湿地个数
                var queryCount = new Query();
                queryCount.where = $('#statistics-county').val() != '县区/全市' ? "COUNTY LIKE '" + $('#statistics-county').val() + "'" :
                    $("#statistics-city").val() != '市/全省' ? "CITY LIKE '" + $('#statistics-city').val() + "'" : '1=1';
                if (StatisticsObj.statisticsArea) {//添加查询范围
                    queryCount.geometry = StatisticsObj.statisticsArea;
                    queryCount.where = '1=1';//有自定义范围时,将where设为查询所有
                }
                queryCount.outFields = [displayField, statisType];
                queryCount.returnGeometry = false;
                queryTask.execute(queryCount, lang.hitch(this, function (result) {
                    var resultCount = {};
                    var resultFeature = {};
                    var datas = result.features;
                    for (var dictionaryKey in config.dictionary) {//判断是否包括需要字典转换的属性,包括的话直接进行转换
                        datas.map(function (value) {
                            if (value.attributes.hasOwnProperty(dictionaryKey)) {
                                value.attributes[dictionaryKey] = config.dictionary[dictionaryKey][value.attributes[dictionaryKey]];
                                return;
                            }
                        });
                    }
                    datas.map(function (value) {
                        if (resultFeature.hasOwnProperty(value.attributes[statisType])) {
                            resultFeature[value.attributes[statisType]].push(value.attributes[displayField]);
                        } else {
                            resultFeature[value.attributes[statisType]] = [value.attributes[displayField]];
                        }
                    });
                    for (var resultFeatureKey in resultFeature) {
                        resultCount[resultFeatureKey] = 0;
                        resultFeature[resultFeatureKey].map(function (item, index) {
                            if (resultFeature[resultFeatureKey].indexOf(item) === index) {
                                resultCount[resultFeatureKey]++;
                            }
                        });
                    }
 
                    //统计其他信息
                    var query = new Query();
                    query.where = $('#statistics-county').val() != '县区/全市' ? "COUNTY LIKE '" + $('#statistics-county').val() + "'" :
                        $("#statistics-city").val() != '市/全省' ? "CITY LIKE '" + $('#statistics-city').val() + "'" : '1=1';
                    if (StatisticsObj.statisticsArea) {//添加查询范围
                        query.geometry = StatisticsObj.statisticsArea;
                        query.where = '1=1';//有自定义范围时,将where设为查询所有
                    }
                    //添加统计参数
                    var statDefs = [];
                    for (var itemKey in StatisticsObj.statisticsCondition.item) {
                        var StatDef = new StatisticDefinition();
                        if (StatisticsObj.statisticsCondition.item[itemKey] == '湿地个数') {
                            StatDef.statisticType = "count";
                            StatDef.onStatisticField = displayField;
                            StatDef.outStatisticFieldName = "湿地个数";
                        } else {
                            StatDef.statisticType = "sum";
                            StatDef.onStatisticField = StatisticsObj.statisticsCondition.itemFields[itemKey];
                            StatDef.outStatisticFieldName = StatisticsObj.statisticsCondition.item[itemKey];
                        }
                        statDefs.push(StatDef);
                    }
                    query.returnGeometry = false;
                    query.groupByFieldsForStatistics = [statisType];
                    query.outStatistics = statDefs;
                    queryTask.execute(query, function (results) {
                        if (results.features.length > 0) {
                            var data = results.features;
                            for (var dictionaryKey in config.dictionary) {//判断是否包括需要字典转换的属性,包括的话直接进行转换
                                data.map(function (value) {
                                    if (value.attributes.hasOwnProperty(dictionaryKey)) {
                                        value.attributes[dictionaryKey] = config.dictionary[dictionaryKey][value.attributes[dictionaryKey]];
                                        return;
                                    }
                                });
                            }
                            //构造左下方概览列表
                            var detailsStr = '';
                            for (var dataKey in data) {
                                detailsStr += '<li title="点击查看统计详情">' +
                                    '<h3 class="detail-title">' + $('#statistics-condition').val() + ':' +
                                    data[dataKey].attributes[statisType] + '</h3>';
                                data[dataKey].attributes['湿地个数'] = resultCount[data[dataKey].attributes[statisType]];
                                for (var attributesKey in data[dataKey].attributes) {
                                    if (attributesKey != statisType) {
                                        var unit = attributesKey == '湿地个数' ? '(个)' : '(公顷)';
                                        var statisValue = attributesKey == '湿地个数' ? data[dataKey].attributes[attributesKey] : Number(data[dataKey].attributes[attributesKey]).toFixed(2)
                                        detailsStr += '<p class="region">' + attributesKey + ':<span>' +
                                            statisValue + unit + '</span></p>';
                                    }
                                }
                                detailsStr += '</li>';
                            }
                            //展开统计列表
                            $("#echartsWidget").height('100%');
                            $("#below_bar").show();
                            StatisticsObj.statisticsData = data;
                            //传递数据构造统计图
                            AppEvent.dispatchAppEvent("menuclick", {
                                name: $('.statistics-layer-input').val(),
                                url: $('.statistics-layer-input').attr('data'),
                                data: StatisticsObj.statisticsData
                            });
                            //加载自定义滚动条
                            $(".statistics-details").mCustomScrollbar("destroy"); //清除滚动条
                            $('.statistics-details').html(detailsStr);
                            $('.statistics-results').show();
                            $(".statistics-details").mCustomScrollbar({
                                scrollButtons: {
                                    enable: true, //是否添加 滚动条两端按钮支持 值:true,false
                                    scrollType: "continuous", //滚动按钮滚动类型 值:”continuous”(当你点击滚动控制按钮时断断续续滚动) “pixels”(根据每次点击的像素数来滚动)
                                    scrollSpeed: 50, //设置点击滚动按钮时候的滚动速度(默认 20)
                                    scrollAmount: 60 //设置点击滚动按钮时候每次滚动的数值 像素单位 默认 40像素
                                },
                                autoHideScrollbar: true,
                                horizontalScroll: false, //是否创建一个水平滚动条 默认是垂直滚动条
                                set_width: false, //:设置你内容的宽度 值可以是像素或者百分比
                                set_height: false, //:设置你内容的高度 值可以是像素或者百分比
                                mouseWheel: true, //鼠标滚动的支持 值为:true.false
                            });
                            //统计列表点击事件
                            $('.statistics-details li').unbind().click(function (e) {
                                AppEvent.dispatchAppEvent('showDetails', {
                                    name: $('.statistics-layer-input').val(),
                                    url: $('.statistics-layer-input').attr('data'),
                                    conditionValue: $(this).children('h3').text().split(':')[1],
                                    statisticsArea: StatisticsObj.statisticsArea,
                                    statisticsCondition: StatisticsObj.statisticsCondition,
                                });
                            });
                            $('#bg').hide();
                        } else {
                            $(".statistics-details").mCustomScrollbar("destroy"); //清除滚动条
                            $('.statistics-details').html('<li><h3 class="detail-title">无统计结果</h3></li>');
                            $('.statistics-results').show();
                            $('#bg').hide();
                        }
                    }, function (er) {
                        console.log(er);
                        $(".statistics-details").mCustomScrollbar("destroy"); //清除滚动条
                        $('.statistics-details').html('<li><h3 class="detail-title">统计出错,请稍后重试</h3></li>');
                        $('.statistics-results').show();
                        $('#bg').hide();
                    });
                }));
            });
        },
        // getFeatures: function (url, ids) {//根据要素的OID要素填充到列表中
        //     //获取当前图层的displayfield
        //     $.get(url + '?f=pjson', function (e) {
        //         StatisticsObj.loading = true;
        //         var displayField = JSON.parse(e).displayField;
        //         //根据要素的OID列表查询要素详细信息
        //         var ids = ids;
        //         var queryTask = new QueryTask(url);
        //         var query = new Query();
        //         query.returnGeometry = false;
        //         query.outFields = ['OBJECTID', displayField, StatisticsObj.statisticsCondition.cityFields[0]];
        //         if ($('.statistics-layer-input').val().indexOf('城') != -1) {//城区湿地图层要多输出一个字段
        //             query.outFields.push("WETLAND_NO");
        //         }
        //         query.objectIds = ids;
        //         queryTask.execute(query, function (data) {
        //             var data = data.features;
        //             var detailsStr = '';
        //             if ($('.statistics-layer-input').val().indexOf('城') != -1) {//城区湿地图层显示的名称要组装一下
        //                 for (var dataKey in data) {
        //                     detailsStr += '<li title="点击查看统计详情" data="' + data[dataKey].attributes.OBJECTID + '">' +
        //                         '<h3 class="detail-title">' + data[dataKey].attributes[displayField] + "第" + data[dataKey].attributes["WETLAND_NO"] + "号湿地斑块"
        //                         + '</h3><p class="region">所在行政区:<span>' + data[dataKey].attributes[StatisticsObj.statisticsCondition.cityFields[0]] + '</span></p></li>'
        //                 }
        //             } else {
        //                 for (var dataKey in data) {
        //                     detailsStr += '<li title="点击查看统计详情" data="' + data[dataKey].attributes.OBJECTID + '">' +
        //                         '<h3 class="detail-title">' + data[dataKey].attributes[displayField] + '</h3><p class="region">所在行政区:<span>' +
        //                         data[dataKey].attributes[StatisticsObj.statisticsCondition.cityFields[0]] + '</span></p></li>'
        //                 }
        //             }
        //             //加载自定义滚动条
        //             $(".statistics-details").mCustomScrollbar("destroy"); //清除滚动条
        //             $('.statistics-details').html(detailsStr);
        //             $(".statistics-details").mCustomScrollbar({
        //                 scrollButtons: {
        //                     enable: true, //是否添加 滚动条两端按钮支持 值:true,false
        //                     scrollType: "continuous", //滚动按钮滚动类型 值:”continuous”(当你点击滚动控制按钮时断断续续滚动) “pixels”(根据每次点击的像素数来滚动)
        //                     scrollSpeed: 50, //设置点击滚动按钮时候的滚动速度(默认 20)
        //                     scrollAmount: 60 //设置点击滚动按钮时候每次滚动的数值 像素单位 默认 40像素
        //                 },
        //                 autoHideScrollbar: true,
        //                 horizontalScroll: false, //是否创建一个水平滚动条 默认是垂直滚动条
        //                 set_width: false, //:设置你内容的宽度 值可以是像素或者百分比
        //                 set_height: false, //:设置你内容的高度 值可以是像素或者百分比
        //                 mouseWheel: true, //鼠标滚动的支持 值为:true.false
        //             });
        //             //统计列表点击事件
        //             $('.statistics-details li').unbind().click(function (e) {
        //                 AppEvent.dispatchAppEvent('showDetails', {
        //                     id: $(this).attr('data'),
        //                     path: $('.statistics-layer-input').attr('data'),
        //                     item: StatisticsObj.itemsFields
        //                 });
        //             });
        //             StatisticsObj.loading = false;
        //             $('#bg').hide();
        //         }, function (err) {
        //             console.log(err);
        //             $(".statistics-details").mCustomScrollbar("destroy"); //清除滚动条
        //             $('.statistics-details').html('<li><h3 class="detail-title">统计出错,请稍后重试</h3></li>');
        //             $('#bg').hide();
        //         });
        //     });
        // },
        appendEventHandlers: function () {// 绑定各类按钮事件
            //绑定dom操作事件
            $("#StatisticsWidget .statistics-layer-input").click(function () {
                $(".statistics-tree-box").fadeToggle(1);
            });
            $("#StatisticsWidget .statistics-layer-input").blur(function () {
                $(".statistics-tree-box").fadeOut(1);
            });
            $(".statistics-tree-box").mouseenter(function () {
                $("#StatisticsWidget .statistics-layer-input").unbind("blur");
            });
            $(".statistics-tree-box").mouseleave(function () {
                $("#StatisticsWidget .statistics-layer-input").focus();
                $("#StatisticsWidget .statistics-layer-input").blur(function () {
                    $(".statistics-tree-box").fadeOut(1);
                });
            });
 
            //统计范围,区域选择tab标签点击事件
            $("#statistics-selectScope1").unbind("click").click(function () {//行政区
                if (!$(this).hasClass("selectTab")) {
                    $("#statistics-selectScope2").removeClass("selectTab");
                    $(this).addClass("selectTab");
                    $('#statistics-drawTools').slideUp("fast");
                    $('#statistics-seek1').slideDown("fast");
                }
                //清除自定义绘制的范围
                if (StatisticsObj.statisticsArea) {
                    StatisticsObj.statisticsArea = null;
                    StatisticsObj._map.graphics.clear();
                }
            });
            $("#statistics-selectScope2").unbind("click").click(function () {//自定义
                if (!$(this).hasClass("selectTab")) {
                    $("#statistics-selectScope1").removeClass("selectTab");
                    $(this).addClass("selectTab");
                    $('#statistics-seek1').slideUp("fast");
                    $('#statistics-drawTools').slideDown("fast");
                }
            });
 
            //统计单元选择事件
            $('#statistics-condition').change(function (e) {
                if (e.target.value == '行政区') {
                    $("#statistics-extent").hide();
                    $("#statistics-city option:first").attr('selected', true);
                    $("#statistics-county option:first").attr('selected', true);
                    setTimeout(function () {
                        var maxheight = $('#tabcontainer').height() - 250;
                        $('.statistics-details').css('height', maxheight);
                        $(".statistics-details").mCustomScrollbar("update"); //更新滚动条
                    }, 200);
                } else {
                    $("#statistics-extent").show();
                    var maxheight = $('#tabcontainer').height() - 345;
                    $('.statistics-details').css('height', maxheight);
                    $(".statistics-details").mCustomScrollbar("update"); //更新滚动条
                }
            });
            //搜索栏清空按钮点击事件--还原各选项,并清空结果
            $('.clear_inputs').click(function () {
                var maxheight = $('#tabcontainer').height() - 345;
                StatisticsObj._map.graphics.clear();
                StatisticsObj.statisticsArea = null;
                $("#echartsWidget").height(0);
                $('.statistics-layer-input').val('');
                $("#statistics-city option:first").attr('selected', true);
                $("#statistics-county option:first").attr('selected', true);
                $("#statistics-condition option:first").attr('selected', true);
                $(".statistics-details").mCustomScrollbar("destroy"); //清除滚动条
                $('.statistics-details').html('').css('height', maxheight);
                $('.statistics-results').hide();
                $('#bg').hide();
                $("#statistics-extent").show();
            });
            //搜索栏查询按钮点击事件
            $('.search_inputs').click(function () {
                if ($('#statistics-condition option:selected').attr('data')) {
                    StatisticsObj.getFeaturesIds($('.statistics-layer-input').attr('data'));
                } else {
                    StatisticsObj._layui.msg('请完善统计条件', {icon: 0, offset: ['50%', '50%']});
                }
            });
            //选择市区触发事件--查询对应的县区
            on(dom.byId("statistics-city"), "change", function () {
                $('#statistics-county').html("<option selected=\"selected\">县区/全市</option>");
                StatisticsObj._countyQuery("statistics-city", "statistics-county");
            });
            //初始化绘制工具
            StatisticsObj.drawStatisticsArea();
        },
        drawStatisticsArea: function () {//统计范围绘制--方法主体
            // 添加线样式
            var lineSymbol = new CartographicLineSymbol(
                CartographicLineSymbol.STYLE_SOLID,
                new Color([250, 0, 0]), 10,
                CartographicLineSymbol.CAP_ROUND,
                CartographicLineSymbol.JOIN_MITER, 5
            );
 
            // 添加面样式
            var fillSymbol = new SimpleFillSymbol(
                SimpleFillSymbol.STYLE_SOLID,
                new SimpleLineSymbol(
                    SimpleLineSymbol.STYLE_SOLID,
                    new Color('#fb003b'),
                    1
                ),
                new Color([0, 0, 0, 0.15])
            );
 
            //定义绘制工具初始化函数
            var tb = new draw(StatisticsObj._map);
            tb.on("draw-end", function (evt) {//定义绘制结束回调函数--添加绘制图形至地图GraphicLayer图层中
                //deactivate the toolbar and clear existing graphics
                tb.deactivate();
                $('.drawTools-active').removeClass('drawTools-active');
                StatisticsObj._map.enableMapNavigation();
 
                // 选择绘制的形状
                var symbol;
                if (evt.geometry.type === "point" || evt.geometry.type === "multipoint") {
                    symbol = markerSymbol;
                } else if (evt.geometry.type === "line" || evt.geometry.type === "polyline") {
                    symbol = lineSymbol;
                } else {
                    symbol = fillSymbol;
                }
                StatisticsObj.statisticsArea = evt.geometry;
                StatisticsObj._map.graphics.add(new Graphic(evt.geometry, symbol));
            });
 
            // 绘制按钮点击事件,获取需要绘制的形状
            on(dom.byId("statistics-drawTools"), "click", function (evt) {
                if (evt.target.id === "statistics-drawTools") {
                    return;
                }
                if (evt.target.id === "clearAll") { //清除按钮清除事件
                    StatisticsObj._map.graphics.clear();
                    StatisticsObj.statisticsArea = null;
                    tb.deactivate();
                    $('.drawTools-active').removeClass('drawTools-active');
                    StatisticsObj._map.enableMapNavigation();
                    return;
                }
                $('.drawTools-active').removeClass('drawTools-active');
                $(evt.target).addClass('drawTools-active');
                StatisticsObj._map.graphics.clear();
                StatisticsObj.statisticsArea = null;
                var tool = evt.target.id.toLowerCase();
                StatisticsObj._map.disableMapNavigation();
                tb.activate(tool);
            });
        },
        //COUNTY查询--在县区选择栏中动态添加所包含的县区
        _countyQuery: function (city, county) {
            var city_selected = city;
            var count_selected = county;
            var Url = ConfigData.areaQueryURL + "/2";
            var queryTask = new QueryTask(Url);
            var query = new Query();
            query.returnGeometry = false;
            query.outFields = [
                "COUNTY"
            ];
            var queryParam;
            if ($('#' + city_selected + ' option:selected').text() != "市/全省") {
                queryParam = "CITY like '%" + $('#' + city_selected + ' option:selected').text() + "%'";
            }
            if (queryParam == null) {
                return;
            }
            query.where = queryParam;
            queryTask.execute(query, function (results) {
                var optionVal = results.features;
                for (var i in optionVal) {
                    $('#' + count_selected).append("<option>" + optionVal[i].attributes["COUNTY"] + "</option>");
                }
            });
        },
    });
    return Widget;
});