/////////////////////////////////////////////////////////////////////////// // 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-searchL', name: 'searchL', layers: {}, states: 'one', searchDatas: '', startup: function () { var that = this; //关键词&&坐标 $("#i-f-gjz").click(function () { that.states = 'one'; // console.log("gjz"); $("#i-f-zb").css({ 'backgroundColor': '#fff', 'color': '#000' }); $("#i-f-gjz").css({ 'backgroundColor': '#3E9FFC', 'color': '#fff' }); // $("#inputTwo").css({ 'display': 'none' }); // $("#local_data").css({ 'display': 'inline-block' }); $("#inputTwo").hide(); $("#local_data").show(); }) $("#i-f-zb").click(function () { that.states = 'two'; // console.log("zb"); $("#i-f-gjz").css({ 'backgroundColor': '#fff', 'color': '#000' }); $("#i-f-zb").css({ 'backgroundColor': '#3E9FFC', 'color': '#fff' }); // $("#local_data").css({ 'display': 'none' }); // $("#inputTwo").css({ 'display': 'inline-block' }); $("#inputTwo").show(); $("#local_data").hide(); }) $(".searchImg").click(function () { // console.log(2324345) that.getInputData(); // console.log(that.searchDatas) if (typeof that.searchDatas == 'string') { var han = /^[\u4e00-\u9fa5]+$/; if (han.test(that.searchDatas) || that.searchDatas == ' ') { that.getData(0, that.searchDatas); $('.searchLMain').show(); } else { layui.use(function () { //亦可加载特定模块:layui.use(['layer', 'laydate', function(){ //得到各种内置组件 var layer = layui.layer //弹层 // layer.msg('请先填写关键字', { icon: 1, time: 1000, shift: 6 }); layer.tips('请先填写关键字', '.searchImg', { tips: [2, '#FF5722'] }); }) $('.searchLMain').hide(); } } else { if (that.searchDatas[0] && that.searchDatas[1]) { console.log(that.searchDatas); } else { layui.use(function () { //亦可加载特定模块:layui.use(['layer', 'laydate', function(){ //得到各种内置组件 var layer = layui.layer //弹层 // layer.msg('请先填写关键字', { icon: 1, time: 1000, shift: 6 }); layer.tips('请先填写完整坐标', '.searchImg', { tips: [2, '#FF5722'] }); }) } } }) $(".searchColce").click(function () { $('.searchLMain').hide(); }) }, getInputData: function () { if (this.states == 'one') { this.searchDatas = $('#local_data').val(); } else if (this.states == 'two') { this.searchDatas = [$('#local_data1').val(), $('#local_data2').val()]; } }, getData: function (index, val) { val = val == ' ' ? '' : val; var d = $('.searchLMain').find('.layui-tab-item').hide; // console.log(d) var that = this, url = `http://171.34.76.171:8880/pyh-wetResource/monitorRecords/queryMonitorData?name=${val}&start&limit&type=${index}` // url = `http://171.34.76.171:8880/pyh-wetResource/monitorRecords/queryMonitorData?name=&start&limit&type=${index}` , token = 'Bearer eyJhbGciOiJIUzUxMiJ9.eyJpc3MiOiJlY2hpc2FuIiwic3ViIjoiYWRtaW4iLCJpYXQiOjE2MjMyMjU5OTcsImV4cCI6MTYyNTgxNzk5N30.zWpoKa5AK7xLIPNm-CXoHY9D5kpk9AiUTGkuAQOZi2Rdl2BfroT4IqxjBpyUPZlgwCjG2CoJqy_7rnnodpmqNw'; 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 || []; // console.log(data) var val = index;//数据的2和1对调 if (index == 1) { val = 2; } else if (index == 2) { val = 1; } that.createDatas(data, val); } else { console.log('请求访问失败') } }) }, createDatas: function (d, n) { this.map.entities.removeAll();//清除图标点 if (d == []) { if (n == 0) { this.beginLayUi(d); } else if (n == 1) { this.beginLayUi(1, d); } else if (n == 2) { this.beginLayUi(1, 1, d); } } else { var i = 1; for (var k in d) { d[k].tableId = i++; //赋图标点 this.shiti(d[k], +n + 1); } var data = d; console.log(data) if (n == 0) { this.beginLayUi(data); } else if (n == 1) { this.beginLayUi(1, data); } else if (n == 2) { this.beginLayUi(1, 1, data); } } }, onOpen: function () { //面板打开的时候触发 var that = this; that.getData(0) layui.use('element', function () { var $ = layui.jquery , element = layui.element; element.on('tab(docDemoTabBrief)', function (elem) { var val = elem.index;//数据的2和1对调 if (elem.index == 1) { val = 2; } else if (elem.index == 2) { val = 1; } that.getData(val, that.searchDatas); }); }); }, onClose: function () { //面板关闭的时候触发 (when this panel is closed trigger) }, onMinimize: function () { this.resize(); }, onMaximize: function () { this.resize(); }, resize: function () { }, goOnPosition(arr, i, data) { console.log(data) this.map.camera.flyTo({ // destination: Cesium.Cartesian3.fromDegrees(Number(lng), Number(lat), Number(gaodu)) destination: Cesium.Cartesian3.fromDegrees(Number(arr[0]), Number(arr[1]), Number(8000)) }); }, //定位实体位置 shiti: function (data, i) { var imgs = i == 1 ? 'images/addL/全景.png' : i == 2 ? 'images/addL/监控.png' : i == 3 ? 'images/addL/监测.png' : ''; this.map.entities.add({ id: data.id, // 实体ID name: data.name, // 实体名称 position: Cesium.Cartesian3.fromDegrees(Number(data.lon), Number(data.lat)), // x,y 实体经纬度 // label: { // show: true, // text: item.siteName, // text 与实体相关的文字 // font: "700 14px '黑体'", // fillColor: Cesium.Color.DEEPSKYBLUE, // // backgroundColor: Cesium.Color.DEEPSKYBLUE, // style: Cesium.LabelStyle.FILL_AND_OUTLINE, // outlineWidth: 2, // outlineColor: Cesium.Color.fromBytes(255, 255, 255), // 文字轮廓的颜色 // verticalOrigin: Cesium.VerticalOrigin.CENTER,//垂直位置 // horizontalOrigin: Cesium.HorizontalOrigin.LEFT,//水平位置 // pixelOffset: new Cesium.Cartesian2(10, -10), // 文字位置 // heightReference: Cesium.HeightReference.CLAMP_TO_GROUND, // distanceDisplayCondition: new Cesium.DistanceDisplayCondition(1, entityConfig.showheight), // disableDepthTestDistance: Number.POSITIVE_INFINITY // }, billboard: { show: true, // image: 'images/addL/监测.png', image: imgs, // image: entityConfig.img, width: 40, // height: 80, clampToGround: true, heightReference: Cesium.HeightReference.CLAMP_TO_GROUND, disableDepthTestDistance: Number.POSITIVE_INFINITY, // rotation: Cesium.Math.toRadians(angle), } }) }, beginLayUi: function (data = 1, data1 = 1, data2 = 1) { // data.push(...data) // console.log(data) var that = this; layui.use(function () { var element = layui.element , table = layui.table //表格 , laypage = layui.laypage; //分页 if (data != 1) { table.render({ elem: '#test' // , url: './data' , height: 475 , page: { //支持传入 laypage 组件的所有参数(某些参数除外,如:jump/elem) - 详见文档 // layout: ['limit', 'count', 'prev', 'page', 'next', 'skip'] //自定义分页布局 layout: ['count', 'prev', 'page', 'next', 'skip'] //自定义分页布局 //,curr: 5 //设定初始在第 5 页 , groups: 3 //只显示 1 个连续页码 , first: false //不显示首页 , last: false //不显示尾页 } , cols: [[ { field: 'tableId', width: 59, align: 'center', unresize: true, title: '序号' } , { field: 'name', width: 90, align: 'center', unresize: true, title: '图层名称' } , { field: 'remarks', width: 95, align: 'center', unresize: true, title: '图层属性1' } , { field: 'createTime', width: 95, align: 'center', unresize: true, title: '图层属性2' } , { fixed: 'right', align: 'center', unresize: true, title: '操作', toolbar: '#demoTable' } ]], data: data, //,skin: 'line' //表格风格 even: true // , page: true //是否显示分页 , limits: false , limit: 10 //每页默认显示的数量 }); table.on('tool(test)', function (obj) { //注:tool 是工具条事件名,test 是 table 原始容器的属性 lay-filter="对应的值" var data = obj.data //获得当前行数据 , layEvent = obj.event; //获得 lay-event 对应的值 if (layEvent === 'detail') { // layer.msg('查看操作'); window.open(obj.data.panAddress); // console.log(obj.data.panAddress) } else if (layEvent === 'edit') { that.goOnPosition([obj.data.lon, obj.data.lat], 1, obj.data); } }); } if (data1 != 1) { table.render({ elem: '#test1' // , url: './data' , height: 475 , page: { //支持传入 laypage 组件的所有参数(某些参数除外,如:jump/elem) - 详见文档 // layout: ['limit', 'count', 'prev', 'page', 'next', 'skip'] //自定义分页布局 layout: ['count', 'prev', 'page', 'next', 'skip'] //自定义分页布局 //,curr: 5 //设定初始在第 5 页 , groups: 3 //只显示 1 个连续页码 , first: false //不显示首页 , last: false //不显示尾页 } , cols: [[ { field: 'tableId', width: 59, align: 'center', unresize: true, title: '序号' } , { field: 'name', width: 90, align: 'center', unresize: true, title: '图层名称' } , { field: 'protectName', width: 95, align: 'center', unresize: true, title: '图层属性1' } , { field: 'serviceUrl', width: 95, align: 'center', unresize: true, title: '图层属性2' } , { fixed: 'right', align: 'center', unresize: true, title: '操作', toolbar: '#demoTable1' } ]], data: data1, //,skin: 'line' //表格风格 even: true // , page: true //是否显示分页 , limits: false , limit: 10 //每页默认显示的数量 }); table.on('tool(test1)', function (obj) { //注:tool 是工具条事件名,test 是 table 原始容器的属性 lay-filter="对应的值" var data = obj.data //获得当前行数据 , layEvent = obj.event; //获得 lay-event 对应的值 if (layEvent === 'detail') { // layer.msg('查看操作'); var dom = $('#poput-m-t-video'), str = `
${obj.data.name}--实时视频
`; dom.empty(); dom.append(str); $('.jimu-widget-searchTabaPopup').css({ 'display': 'block' }); $('.jimu-widget-searchTabaPopup').find('.p-main').eq(0).css({ 'display': 'block' }).siblings().css({ 'display': 'none' }); } else if (layEvent === 'edit') { that.goOnPosition([obj.data.lon, obj.data.lat], 2, obj.data); } // console.log(obj.data.name) }); } if (data2 != 1) { table.render({ elem: '#test2' // , url: './data' , height: 475 , page: { //支持传入 laypage 组件的所有参数(某些参数除外,如:jump/elem) - 详见文档 // layout: ['limit', 'count', 'prev', 'page', 'next', 'skip'] //自定义分页布局 layout: ['count', 'prev', 'page', 'next', 'skip'] //自定义分页布局 //,curr: 5 //设定初始在第 5 页 , groups: 3 //只显示 1 个连续页码 , first: false //不显示首页 , last: false //不显示尾页 } , cols: [[ { field: 'tableId', width: 59, align: 'center', unresize: true, title: '序号' } , { field: 'name', width: 90, align: 'center', unresize: true, title: '图层名称' } , { field: 'stcd', width: 95, align: 'center', unresize: true, title: '图层属性1' } , { field: 'createTime', width: 95, align: 'center', unresize: true, title: '图层属性2' } , { fixed: 'right', align: 'center', unresize: true, title: '操作', toolbar: '#demoTable2' } ]], data: data2, //,skin: 'line' //表格风格 even: true // , page: true //是否显示分页 , limits: false , limit: 10 //每页默认显示的数量 }); table.on('tool(test2)', function (obj) { //注:tool 是工具条事件名,test 是 table 原始容器的属性 lay-filter="对应的值" var data = obj.data //获得当前行数据 , layEvent = obj.event; //获得 lay-event 对应的值 if (layEvent === 'detail') { // layer.msg('查看操作'); // 监测、测站详情 表格 // console.log(obj.data.stcd) // console.log(axios) that.setXiangqing(obj);//渲染详情 that.getshuiwen(obj.data.stcd)//水文实时渲染 that.setbiaoti(obj.data)//表格各分部标题渲染 $('.jimu-widget-searchTabaPopup').css({ 'display': 'block' }); $('.jimu-widget-searchTabaPopup').find('.p-main').eq(1).css({ 'display': 'block' }).siblings().css({ 'display': 'none' }); // console.log(obj.data.name) } else if (layEvent === 'edit') { that.goOnPosition([obj.data.lon, obj.data.lat], 3, obj.data); } }); } //… }); }, setXiangqing(obj) { var str = ''; var XQDom = $('.jimu-widget-searchTabaPopup').find('.xiangqing'); XQDom.empty(); str += ''; str += ``; str += '
测站名称: ${obj.data.name} 建设类型: 建设
经度: ${obj.data.lon} 纬度: ${obj.data.lat}
建站时间: ${obj.data.accessTime} 接入时间: ${obj.data.createTime}
所属保护区: 鄱阳湖南矶湿地国家级自然保护区 地址: 暂无
全景地址: ${obj.data.panoramaUrl}/
测站简介: 暂无
图片:
'; XQDom.append(str); }, getshuiwen: function (stcd) { var that = this; var url = `http://171.34.76.171:8880/pyh-station/monitorData/queryNewestTimeEleDataByStcd?stcd=${stcd}`, token = 'Bearer eyJhbGciOiJIUzUxMiJ9.eyJpc3MiOiJlY2hpc2FuIiwic3ViIjoiYWRtaW4iLCJpYXQiOjE2MjMyNDQxNDQsImV4cCI6MTYyNTgzNjE0NH0.wjtMw7hv8IYGxFKI9b1vo2ozMXD1pE0-02HinfPl-r8l0TYVg1YvMBxW_VzzFKoY1jeC6XByQQT-aC_mAvBnWA'; axios.get(url, { headers: { 'token': token } }).then((res) => { if (res.data.code == 200) { var datashuiziyuan = res.data.data.MONITOR_WATER//水资源数据 that.setshishidata(datashuiziyuan, stcd); var datakongqi = res.data.data.MONITOR_AIR//空气源数据 that.setshishidata(datakongqi, stcd, '#kongqishishi'); var dataqixiang = res.data.data.MONITOR_WEATHER//气象源数据 that.setshishidata(dataqixiang, stcd, '#qixiangshishi'); } }) }, setshishidata: function (data, stcd, id = '#shuiwenshishi') { var str = '', shuiwenDom = $('.jimu-widget-searchTabaPopup').find(id) shuiwenDom.empty(); str = `` for (var k in data) { str += `` } str += `
名称 数值 单位
${data[k].name}${data[k].value}${data[k].unit}
`//占位传stcd 给图表历史查询用 shuiwenDom.append(str); }, setbiaoti: function (data) { var title = $('.jimu-widget-searchTabaPopup').find('.myOUrtitle'); title.empty(); title.append(data.name); var time = $('.jimu-widget-searchTabaPopup').find('.myOUrtime'); time.empty(); time.append(data.createTime); }, destroy: function () { //销毁的时候触发 //todo //do something before this func this.inherited(arguments); } }); });