Index.cshtml 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332
  1. 
  2. @{
  3. ViewBag.Title = "历史记录查询";
  4. Layout = "~/Views/Shared/_LayoutIndex.cshtml";
  5. }
  6. <style>
  7. .partitionsContainer ul {
  8. width: 100%;
  9. height: 100%;
  10. }
  11. .partitionsContainer li {
  12. float: left;
  13. height: 100%;
  14. line-height: 30px;
  15. text-align: center;
  16. list-style: none;
  17. border: 1px solid gray;
  18. }
  19. table tr td {
  20. height: 50px;
  21. }
  22. .formTitle {
  23. width: 130px !important;
  24. }
  25. .checkbox-wrap{
  26. width: 100%;
  27. position: relative;
  28. margin: 0 auto;
  29. background-color: white;
  30. }
  31. input[type="checkbox"]{
  32. display: none;
  33. }
  34. input[type="checkbox"]+label {
  35. display: inline-block;
  36. width: 80%;
  37. margin-top: 10px;
  38. margin-left: 5px;
  39. text-align: left;
  40. -webkit-box-sizing: border-box;
  41. }
  42. label::before {
  43. content: "";
  44. display: inline-block;
  45. width: 20px;
  46. height: 20px;
  47. background: #4C58A4;
  48. vertical-align: middle;
  49. -webkit-border-radius: 10%;
  50. margin-right: 5px;
  51. -webkit-box-sizing:border-box;
  52. -webkit-transition:background ease-in .5s
  53. }
  54. input[type="checkbox"]:checked+label::before{
  55. /* background-color: rgb(53, 183, 111); */
  56. content: "√";
  57. color: #fff;
  58. font-size: 20px;
  59. text-align: center;
  60. line-height: 20px;
  61. cursor: pointer;
  62. /* border: 5px #EEEEEE solid; */
  63. }
  64. .clable {
  65. font-size: 14px;
  66. color: #808080;
  67. font-weight: bold;
  68. cursor: pointer;
  69. }
  70. </style>
  71. <script type="text/javascript" src="http://api.map.baidu.com/api?v=2.0&ak=@System.Configuration.ConfigurationManager.AppSettings["BaiduMapAK"]"></script>
  72. <script type="text/javascript" src="http://api.map.baidu.com/library/DrawingManager/1.4/src/DrawingManager_min.js"></script>
  73. <link rel="stylesheet" href="http://api.map.baidu.com/library/DrawingManager/1.4/src/DrawingManager_min.css" />
  74. <script>
  75. "use strict"
  76. var keyValue = request('keyValue');
  77. var overlays = {};
  78. var showPolygon = [];
  79. var map;
  80. $(document).ready(function () {
  81. InitialPage();
  82. GetTree();
  83. initBaiduMap();
  84. InitialColor();
  85. checkBoxChange();
  86. });
  87. // 初始化颜色
  88. function InitialColor() {
  89. $('.fill_Color').each(function () {
  90. $(this).minicolors({
  91. control: $(this).attr('data-control') || 'hue',
  92. defaultValue: $(this).attr('data-defaultValue') || '',
  93. inline: $(this).attr('data-inline') === 'true',
  94. letterCase: $(this).attr('data-letterCase') || 'lowercase',
  95. opacity: $(this).attr('data-opacity'),
  96. position: $(this).attr('data-position') || 'bottom left',
  97. change: function (hex, opacity) {
  98. if (!hex) return;
  99. if (opacity) hex += ', ' + opacity;
  100. try {
  101. console.log(hex);
  102. } catch (e) { }
  103. },
  104. theme: 'bootstrap'
  105. });
  106. });
  107. }
  108. //初始化页面
  109. function InitialPage() {
  110. // 设置
  111. $(".partitionsContainer").css({ "height": ($(window).height() - 80) + "px" });
  112. //layout布局
  113. $('#layout').layout({
  114. applyDemoStyles: true,
  115. onresize: function () {
  116. $(window).resize();
  117. }
  118. });
  119. // resize重设(表格、树形)宽高
  120. $(window).resize(function (e) {
  121. window.setTimeout(function () {
  122. $("#itemTree").setTreeHeight($(window).height() - 52);
  123. $(".partitionsContainer").css({ "height": ($(window).height() - 80) + "px" });
  124. }, 200);
  125. e.stopPropagation();
  126. });
  127. }
  128. //加载树
  129. var PointTreeCode = 0;
  130. function GetTree() {
  131. var item = {
  132. height: $(window).height() - 52,
  133. url: "../../DMAManage/Partitions/GetTreeJson",
  134. showcheck: false,
  135. isexpand: true,
  136. onnodeclick: function (item) {
  137. PointTreeCode = item.id;
  138. $.ajax({
  139. url: "../../DMAManage/PartitionManage/GetDMAData",
  140. type: "get",
  141. data: { DMACode: item.id},
  142. datatype: "json",
  143. success: function (data) {
  144. var data = JSON.parse(data);
  145. $("#r_title").html('<i style="font-size: 20px;margin-right: 5px" class="fa fa-home"></i>' + data.DMAName);
  146. }
  147. });
  148. removeAllPolygon();
  149. var id = item.id.replace(/^\s+|\s+$/gm, '');
  150. if (overlays[id] && overlays[id].polygon && $('#cdma').is(':checked')) {
  151. addOnePolygon();
  152. }
  153. }
  154. };
  155. //初始化
  156. $("#itemTree").treeview(item);
  157. }
  158. // 初始化百度地图
  159. function initBaiduMap() {
  160. map = new BMap.Map("allmap");
  161. var geoc = new BMap.Geocoder(); //地址解析对象
  162. var point = new BMap.Point("@System.Configuration.ConfigurationManager.AppSettings["LngAndLat"].Split('|')[0]", "@System.Configuration.ConfigurationManager.AppSettings["LngAndLat"].Split('|')[1]");
  163. map.centerAndZoom(point, 12); // 中心点
  164. map.enableScrollWheelZoom(true); //开启鼠标滚轮缩放
  165. var bottom_left_control = new BMap.ScaleControl({ anchor: BMAP_ANCHOR_BOTTOM_LEFT });// 左上角,添加比例尺
  166. map.addControl(bottom_left_control);
  167. map.addControl(new BMap.MapTypeControl({
  168. mapTypes: [
  169. BMAP_NORMAL_MAP,
  170. BMAP_HYBRID_MAP
  171. //BMAP_PERSPECTIVE_MAP
  172. ],
  173. anchor: BMAP_ANCHOR_TOP_LEFT
  174. }));
  175. // 获取分区数据
  176. $.ajax({
  177. url: "/DMAManage/PartitionDraw/GetAllPartitions",
  178. type: "get",
  179. data: {},
  180. datatype: "json",
  181. success: function (data) {
  182. var data = JSON.parse(data);
  183. drawAll(data, map);
  184. }
  185. });
  186. }
  187. // 绘制所有可以显示的区域
  188. function drawAll(data) {
  189. for (var i = 0; i < data.length; i++) {
  190. var DMACode = data[i].DMACode.replace(/^\s+|\s+$/gm, '');
  191. if (data[i].DMACoordinate) {
  192. var points = data[i].DMACoordinate.split("|");
  193. var paths = [];
  194. for (var j = 0 ; j < points.length; j++) {
  195. paths.push(new BMap.Point(points[j].split(",")[0], points[j].split(",")[1]));
  196. }
  197. var polygon = new BMap.Polygon(paths, { strokeColor: data[i].FillColor, strokeWeight: 1, strokeOpacity: 0.5, fillColor: data[i].FillColor });
  198. map.addOverlay(polygon);
  199. overlays[DMACode] = { color: data[i].FillColor, polygon: polygon};
  200. }
  201. }
  202. }
  203. // checkbox change事件监听
  204. function checkBoxChange() {
  205. // dma分区是否展示
  206. $("#cdma").change(function (e) {
  207. if ($('#cdma').is(':checked')) {
  208. if (overlays[PointTreeCode]) {
  209. addOnePolygon();
  210. }
  211. if (PointTreeCode === 0) {
  212. showAllDMA();
  213. }
  214. } else {
  215. removeAllPolygon();
  216. }
  217. });
  218. }
  219. // 设置单个区域
  220. function addOnePolygon() {
  221. var paths = overlays[PointTreeCode].polygon.getPath();
  222. var polygon = new BMap.Polygon(paths, { strokeColor: overlays[PointTreeCode].color, strokeWeight: 3, strokeOpacity: 0.5, FillOpacity: 0.5, fillColor: overlays[PointTreeCode].color });
  223. map.addOverlay(polygon);
  224. showPolygon = polygon;
  225. var center = getCenterPoint(paths);
  226. map.setZoom(14);
  227. map.panTo(new BMap.Point(center.lng, center.lat), 2000);
  228. }
  229. // 获取中心点
  230. function getCenterPoint(path) {
  231. var x = 0.0;
  232. var y = 0.0;
  233. for (var i = 0; i < path.length; i++) {
  234. x = x + parseFloat(path[i].lng);
  235. y = y + parseFloat(path[i].lat);
  236. }
  237. x = x / path.length;
  238. y = y / path.length;
  239. return { lng: x, lat: y }
  240. }
  241. // 清除所有的区域
  242. function removeAllPolygon() {
  243. for (var overlay in overlays) {
  244. map.removeOverlay(overlays[overlay].polygon);
  245. }
  246. if (showPolygon) {
  247. map.removeOverlay(showPolygon);
  248. }
  249. }
  250. // 显示所有dma分区
  251. function showAllDMA() {
  252. for (var overlay in overlays) {
  253. map.addOverlay(overlays[overlay].polygon);
  254. }
  255. }
  256. // 设置显示全部
  257. function getAllPolygon() {
  258. map.setZoom(12);
  259. showAllDMA();
  260. }
  261. </script>
  262. <div class="ui-layout" id="layout" style="height: 100%; width: 100%;">
  263. <div class="ui-layout-west">
  264. <div class="west-Panel">
  265. <div class="panel-Title">分区列表</div>
  266. <div id="itemTree"></div>
  267. </div>
  268. </div>
  269. <div class="ui-layout-center">
  270. <div class="center-Panel">
  271. <div id="tabs">
  272. <div id="tabs-1">
  273. <div class="titlePanel">
  274. <div class="title-search">
  275. <table>
  276. <tr>
  277. <td id="r_title" style="padding-left: 10px;font-size: 16px;font-weight: bold;color: #4C58A4">
  278. <i style="font-size: 20px;margin-right: 5px" class="fa fa-home"></i>分区总览
  279. </td>
  280. </tr>
  281. </table>
  282. </div>
  283. <div class="toolbar">
  284. <div class="btn-group">
  285. <a id="pAll" class="btn btn-default" onclick="getAllPolygon()"><i class="fa fa-file-text-o"></i>&nbsp;全部</a>
  286. <a id="pReplace" class="btn btn-default" onclick="reload();"><i class="fa fa-refresh"></i>&nbsp;刷新</a>
  287. </div>
  288. </div>
  289. </div>
  290. <div class="partitionsContainer">
  291. <ul>
  292. <li id="mapLi" style="width: 100%">
  293. <div id='allmap' style='width: 100%; height: 100%;'></div>
  294. <div style="position:absolute;top: 80px;right: 20px;background-color: white;width: 130px;height: 90px;">
  295. <div class="checkbox-wrap">
  296. <input type="checkbox" checked name="choose" id="cdma">
  297. <label class="clable" for="cdma">DMA分区</label>
  298. <input type="checkbox" checked name="choose" id="cpipe">
  299. <label class="clable" for="cpipe">管网</label>
  300. </div>
  301. </div>
  302. </li>
  303. </ul>
  304. </div>
  305. </div>
  306. </div>
  307. </div>
  308. </div>
  309. </div>