var layer; var chart = null; var timer; var screen = true; $(function () { layui.use(['layer', 'laydate', 'form'], function () { layer = layui.layer; //隐藏仓储信息 if(tag == 2){ $("#basic_info").css("display", "none"); } // 初始页面 init(); $("body").dblclick(function () { if (screen) { requestFullScreen(); } else { exitFullscreen(); } }); }); // 初始化WebSocket initWS(deptId, bizType, bizTag, userId); }); function init() { initWeather(); initChart(); renderDepotGrain(); depotChange(); renderChartFood(); } function renderChartFood() { if (chartFood == null) { return; } $("#depotNum").html(chartFood.depotNum); $("#realStorage").html(chartFood.realStorage); $("#depotType").html(chartFood.depotType); var foodChart = chart; if (chartFood.listFoodVariety.length > 0) { foodChart.option.series[0].data = chartFood.listFoodVariety; } if (chartFood.listFoodYear.length > 0) { foodChart.option.series[1].data = chartFood.listFoodYear; } if (chartFood.listFoodLocation.length > 0) { foodChart.option.series[2].data = chartFood.listFoodLocation; } foodChart.chart.setOption(foodChart.option, true); chart = foodChart; } // socket信息返回處理 function socketOnMessage(pocket) { if (pocket.bizId == "grain") { var data = pocket.data; mapGrain = data; } if (pocket.bizId == "weather") { weatherInfo = pocket.data; initWeather() } } /** * 渲染仓库 */ function renderDepotGrain() { if (listDepot == null || listDepot.length <= 0) { return; } var html = ''; $.each(listDepot, function (index, item) { html += '
'; }); $("#depotList").html(html); } function initWeather() { if (weatherInfo) { var wendu = ''; if (weatherInfo.temp) { wendu = weatherInfo.temp.replace("℃", ""); } $("#weather_wendu").html(wendu + "℃"); var shidu = ''; if (weatherInfo.humidity) { shidu = weatherInfo.humidity.replace("%", ""); } $("#weather_shidu").html(shidu + "%"); var tianqi = ''; if (weatherInfo.weather) { tianqi = weatherInfo.weather; } $("#weather_tianqi").html(tianqi); var time = ''; if (weatherInfo.updateTimeStr) { time = weatherInfo.updateTimeStr; } $("#weather_time").text(time); } } function depotChange() { var swiper = new Swiper(".mySwiper", { autoplay: true, speed: 3000, slidesPerView: 3, grid: { rows: 2, }, spaceBetween: 30, pagination: { el: ".swiper-pagination", clickable: true, } }); } //初始粮食饼图 function initChart() { var dom = document.getElementById("chart"); var pieChart = echarts.init(dom); var option = { color: ['#E6B83D', '#4260C9', '#36B994'], series: [ // 粮食品种饼图数据 { type: 'pie', radius: ['15%', '45%'], avoidLabelOverlap: false, left: '0%', right: '66.6667%', top: 0, bottom: 0, itemStyle: { borderRadius: 2, borderColor: '#04162D', borderWidth: 6 }, labelLine: { length: -5 }, label: { formatter: '{c}{e| kg}\n{per|{d}%}\n{b|{b}}', backgroundColor: '#033959', color: '#fff', borderRadius: 4, padding: [8, 8], fontSize: 18, fontWeight: 'bolder', fontFamily: 'Microsoft YaHei', rich: { b: { color: '#fff', fontSize: 14, fontWeight: 'bolder', lineHeight: 16 }, per: { color: '#fff', lineHeight: 22, fontSize: 14, }, e: { fontSize: 12, } } }, data: [ {value: 1280, name: '陈谷'}, {value: 720, name: '新谷'}, {value: 320, name: '小麦'} ] }, // 粮食品种饼图数据 // 粮食年份饼图数据 { type: 'pie', radius: ['15%', '45%'], avoidLabelOverlap: false, left: '33.333%', right: '33.333%', top: 0, bottom: 0, itemStyle: { borderRadius: 2, borderColor: '#04162D', borderWidth: 6 }, labelLine: { length: -5 }, label: { formatter: '{c}{e| kg}\n{per|{d}%}\n{b|{b}}', backgroundColor: '#033959', color: '#fff', borderRadius: 4, padding: [8, 8], fontSize: 18, fontWeight: 'bolder', fontFamily: 'Microsoft YaHei', rich: { b: { color: '#fff', fontSize: 14, fontWeight: 'bolder', lineHeight: 16 }, per: { color: '#fff', lineHeight: 22, fontSize: 14, }, e: { fontSize: 12, } } }, data: [ {value: 790, name: '2021年粳谷'}, {value: 640, name: '2021年小麦'}, {value: 320, name: '2020年粳谷'}, {value: 720, name: '2020年小麦'} ] }, // 粮食年份饼图数据 // 粮食产地饼图数据 { type: 'pie', radius: ['15%', '45%'], avoidLabelOverlap: false, left: '66.666%', right: '0%', top: 0, bottom: 0, itemStyle: { borderRadius: 2, borderColor: '#04162D', borderWidth: 6 }, labelLine: { length: -5 }, label: { formatter: '{c}{e| kg}\n{per|{d}%}\n{b|{b}}', backgroundColor: '#033959', color: '#fff', borderRadius: 4, padding: [8, 8], fontSize: 18, fontWeight: 'bolder', fontFamily: 'Microsoft YaHei', rich: { b: { color: '#fff', fontSize: 14, fontWeight: 'bolder', lineHeight: 16 }, per: { color: '#fff', lineHeight: 22, fontSize: 14, }, e: { fontSize: 12, } } }, data: [ {value: 2280, name: '江苏省'}, {value: 420, name: '嘉定区'} ] } // 粮食产地饼图数据 ] }; pieChart.setOption(option); chart = {"chart": pieChart, "option": option}; } // 改变浏览器大小图表重绘 window.onresize = function () { chart.chart.resize(); }; // 退出全屏 function exitFullscreen() { var de = document; if (de.exitFullscreen) { de.exitFullscreen(); } else if (de.mozCancelFullScreen) { de.mozCancelFullScreen(); } else if (de.webkitCancelFullScreen) { de.webkitCancelFullScreen(); } screen = true; } // 进入全屏 function requestFullScreen() { var de = document.documentElement; if (de.requestFullscreen) { de.requestFullscreen(); } else if (de.mozRequestFullScreen) { de.mozRequestFullScreen(); } else if (de.webkitRequestFullScreen) { de.webkitRequestFullScreen(); } screen = false; }