///////////////////////////////////////////////////////////////////////////
|
// Copyright © 2019 zhongsong. All Rights Reserved.
|
// 模块描述:显示坐标
|
///////////////////////////////////////////////////////////////////////////
|
define([
|
'dojo/_base/declare',
|
'dojo/_base/lang',
|
'dojo/_base/array',
|
'dojo/_base/html',
|
'dojo/topic',
|
'jimu/BaseWidget',
|
'jimu/utils',
|
'jimu/css!libs/zTree_v3/css/zTreeStyle/zTreeStyle.css',
|
'libs/zTree_v3/js/jquery.ztree.all'
|
],
|
function (declare,
|
lang,
|
array,
|
html,
|
topic,
|
BaseWidget,
|
aspect,
|
string,
|
utils
|
) {
|
return declare([BaseWidget], {
|
baseClass: 'jimu-widget-legends',
|
name: 'legends',
|
layers: {},
|
startup: function () {
|
// 暴露在外的接口
|
topic.subscribe("getLegendsData", lang.hitch(this, this.onGetLegendsData));
|
topic.subscribe("addLayersLegends", lang.hitch(this, this.addLayersLegends));
|
topic.subscribe("removeLayersLegends", lang.hitch(this, this.removeLayersLegends));
|
|
},
|
onGetLegendsData: function (item) {
|
var val = item == ' ' ? '' : item;
|
var that = this,
|
twoData = []
|
// url = `http://171.34.76.171:8880/pyh-wetResource/monitorRecords/queryMonitorData?name=&start&limit&type=${index}`
|
,
|
token = 'Bearer eyJhbGciOiJIUzUxMiJ9.eyJpc3MiOiJlY2hpc2FuIiwic3ViIjoiYWRtaW4iLCJpYXQiOjE2MjMyMjU5OTcsImV4cCI6MTYyNTgxNzk5N30.zWpoKa5AK7xLIPNm-CXoHY9D5kpk9AiUTGkuAQOZi2Rdl2BfroT4IqxjBpyUPZlgwCjG2CoJqy_7rnnodpmqNw',
|
myGet = function (val, i) {
|
var url = `http://171.34.76.171:8880/pyh-wetResource/monitorRecords/queryMonitorData?name=${val}&start&limit&type=${i}`;
|
axios.get(url, {
|
headers: {
|
'token': token
|
}
|
}).then((res) => {
|
if (res.data.code == 200) {
|
var data = res.data.data.panoramaList || res.data.data.stationList || res.data.data.videoList || [],
|
onceData = {};
|
for (var k in data) {
|
if (i == 0) {
|
onceData[data[k].protectArea] = onceData[data[k].protectArea] == undefined ? 1 : onceData[data[k].protectArea] += 1;
|
} else if (i == 2) {
|
onceData[data[k].protectName] = onceData[data[k].protectName] == undefined ? 1 : onceData[data[k].protectName] += 1;
|
} else if (i == 1) {
|
onceData[data[k].wetlandName_] = onceData[data[k].wetlandName_] == undefined ? 1 : onceData[data[k].wetlandName_] += 1;
|
}
|
}
|
twoData.push(onceData)
|
if (i == 2) {
|
ready(twoData, item);
|
}
|
} else {
|
console.log('请求访问失败')
|
}
|
})
|
},
|
ready = function (d, val) {
|
if (val == '') {
|
d = {};
|
}
|
var init = (data, dom, img) => {
|
var q = data,
|
num = 0,
|
strq, domq = $(dom),
|
h = '';
|
domq.empty();
|
for (var k in q) {
|
num += q[k];
|
h += `<div class="m-init m-i-child"> <i></i> ${k}<i>(${q[k]}个)</i> </div>`;
|
}
|
strq = `<div class="m-init"> <i><img src="./images/addL/${img}.png" /></i> ${img}站点 <i>(${num}个)</i> </div>` + h;
|
domq.append(strq);
|
}
|
// 全景
|
init(d[0], '#legendsInquanjing', '全景');
|
// 监控
|
init(d[2], '#legendsInjiankong', '监控');
|
// 监测
|
init(d[1], '#legendsInjiance', '监测');
|
},
|
doit = () => {
|
var i = 0;
|
myGet(val, i);
|
var i = 1;
|
myGet(val, i);
|
var i = 2;
|
myGet(val, i);
|
|
}
|
|
doit();
|
},
|
addLayersLegends: function (item, obj) {
|
|
if (item == this.name) {
|
if (obj.attList && obj.attList.length > 0) {
|
for (var i = 0; i < obj.attList.length; i++) {
|
var list = $("<li class='m-init' itemid='" + obj.id + "'>" +
|
"<i class='m-init-h'><img src='" + obj.attList[i].uaOriginPath + "' /></i>" +
|
"<span title='" + obj.title + "'>" +
|
obj.title +
|
"</span>" +
|
"</li>")
|
|
$(".jimu-widget-legends .layer-legends").append(list);
|
}
|
}
|
}
|
},
|
removeLayersLegends: function (item, obj) {
|
if (item == this.name) {
|
var liList = $(".jimu-widget-legends .layer-legends li");
|
for (var i = 0; i < liList.length; i++) {
|
if ($(liList[i]).attr('itemid') && $(liList[i]).attr('itemid') == obj.id) {
|
$(liList[i]).remove();
|
}
|
}
|
}
|
},
|
closeToolBox: function (item) {},
|
|
onOpen: function () {
|
//面板打开的时候触发 (when open this panel trigger)
|
},
|
|
onClose: function () {
|
//面板关闭的时候触发 (when this panel is closed trigger)
|
},
|
|
onMinimize: function () {
|
this.resize();
|
},
|
|
onMaximize: function () {
|
this.resize();
|
},
|
|
resize: function () {
|
|
},
|
begin: function () {},
|
|
destroy: function () {
|
//销毁的时候触发
|
//todo
|
//do something before this func
|
this.inherited(arguments);
|
}
|
|
});
|
});
|