Index.cshtml 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469
  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. var DMAID = 0;
  131. function GetTree() {
  132. var item = {
  133. height: $(window).height() - 52,
  134. url: "../../DMAManage/Partitions/GetTreeJson",
  135. showcheck: false,
  136. isexpand: true,
  137. onnodeclick: function (item) {
  138. PointTreeCode = item.id;
  139. DMAID = item.value;
  140. $.ajax({
  141. url: "../../DMAManage/PartitionManage/GetDMAData",
  142. type: "get",
  143. data: { DMACode: item.id},
  144. datatype: "json",
  145. success: function (data) {
  146. var data = JSON.parse(data);
  147. $("#DMAID").val(data.DMAID);
  148. $("#DMACode").val(data.DMACode);
  149. $("#DMAName").val(data.DMAName);
  150. $("#FillColor").val(data.FillColor);
  151. $(".minicolors-swatch-color").css({"background-color": data.FillColor});
  152. $("#PipeConnectionPoint").val(data.PipeConnectionPoint);
  153. $("#MainPipeLength").val(data.MainPipeLength);
  154. $("#BranchPipeLength").val(data.BranchPipeLength);
  155. $("#PipeFactor").val(data.PipeFactor);
  156. $("#N1").val(data.N1);
  157. $("#PipeVolume").val(data.PipeVolume);
  158. $("#r_title").html('<i style="font-size: 20px;margin-right: 5px" class="fa fa-home"></i>编辑:' + data.DMAName);
  159. $("#formLi").css({ "width": "40%", "display": "block" });
  160. $("#mapLi").css({ "width": "60%" });
  161. }
  162. });
  163. if (showPolygon) {
  164. map.removeOverlay(showPolygon);
  165. }
  166. var id = item.id.replace(/^\s+|\s+$/gm, '');
  167. if (overlays[id] && $('#cdma').is(':checked')) {
  168. // 选中高亮显示
  169. addOnePolygon();
  170. }
  171. }
  172. };
  173. //初始化
  174. $("#itemTree").treeview(item);
  175. }
  176. // 初始化百度地图
  177. function initBaiduMap() {
  178. map = new BMap.Map("allmap");
  179. var geoc = new BMap.Geocoder(); //地址解析对象
  180. var point = new BMap.Point("@System.Configuration.ConfigurationManager.AppSettings["LngAndLat"].Split('|')[0]", "@System.Configuration.ConfigurationManager.AppSettings["LngAndLat"].Split('|')[1]");
  181. map.centerAndZoom(point, 12); // 中心点
  182. map.enableScrollWheelZoom(true); //开启鼠标滚轮缩放
  183. var bottom_left_control = new BMap.ScaleControl({ anchor: BMAP_ANCHOR_BOTTOM_LEFT });// 左上角,添加比例尺
  184. map.addControl(bottom_left_control);
  185. map.addControl(new BMap.MapTypeControl({
  186. mapTypes: [
  187. BMAP_NORMAL_MAP,
  188. BMAP_HYBRID_MAP
  189. //BMAP_PERSPECTIVE_MAP
  190. ],
  191. anchor: BMAP_ANCHOR_TOP_LEFT
  192. }));
  193. // 获取分区数据
  194. $.ajax({
  195. url: "/DMAManage/PartitionDraw/GetAllPartitions",
  196. type: "get",
  197. data: {},
  198. datatype: "json",
  199. success: function (data) {
  200. var data = JSON.parse(data);
  201. drawAll(data, map);
  202. }
  203. });
  204. }
  205. // 绘制所有可以显示的区域
  206. function drawAll(data) {
  207. for (var i = 0; i < data.length; i++) {
  208. var DMACode = data[i].DMACode.replace(/^\s+|\s+$/gm, '');
  209. if (data[i].DMACoordinate) {
  210. var points = data[i].DMACoordinate.split("|");
  211. var paths = [];
  212. for (var j = 0 ; j < points.length; j++) {
  213. paths.push(new BMap.Point(points[j].split(",")[0], points[j].split(",")[1]));
  214. }
  215. var polygon = new BMap.Polygon(paths, { strokeColor: $("#FillColor").val(), strokeWeight: 1, strokeOpacity: 0.5, fillColor: data[i].FillColor });
  216. map.addOverlay(polygon);
  217. overlays[DMACode] = polygon;
  218. }
  219. }
  220. }
  221. // 修改提交表单
  222. function confirmData() {
  223. if (!$('#form1').Validform()) {
  224. return false;
  225. }
  226. var postData = $("#form1").GetWebControls(keyValue);
  227. //postData 格式化 将&nbsp; 替换为 ""
  228. for (var i in postData) {
  229. if (postData[i] == "&nbsp;") {
  230. postData[i] = "";
  231. }
  232. }
  233. $.SaveForm({
  234. url: "../../DMAManage/PartitionManage/EditDMAData",
  235. param: {"data": JSON.stringify(postData) },
  236. loading: "正在保存数据...",
  237. success: function () {
  238. GetTree();
  239. var pg = PointTreeCode.replace(/^\s+|\s+$/gm, '');
  240. if (overlays[pg]) {
  241. overlays[pg].setFillColor($('#FillColor').val());
  242. }
  243. }
  244. })
  245. }
  246. // 新建分区
  247. function addDMA() {
  248. if (PointTreeCode.length > 35) {
  249. return alert("只能创建8级分区!");
  250. }
  251. dialogOpen({
  252. id: "Form",
  253. title: '新建分区',
  254. url: '/DMAManage/PartitionManage/AddDMAForm?keyValue=' + PointTreeCode + "&DMAID=" + DMAID,
  255. width: "750px",
  256. height: "500px",
  257. callBack: function (iframeId) {
  258. top.frames[iframeId].AcceptClick();
  259. }
  260. });
  261. }
  262. // 删除分区
  263. function deleteDMA() {
  264. var DMAID = $("#DMAID").val();
  265. var dmaCode = $("#DMACode").val();
  266. $.RemoveForm({
  267. url: "/DMAManage/PartitionManage/DeleteDMAData",
  268. param: { keyValue: DMAID + "|" +dmaCode },
  269. success: function (data) {
  270. $("#formLi").css({ "width": "0%", "display": "none" });
  271. $("#mapLi").css({ "width": "100%" });
  272. $("#r_title").html('<i style="font-size: 20px;margin-right: 5px" class="fa fa-home"></i>分区管理');
  273. GetTree();
  274. map.removeOverlay(overlays[dmaCode.replace(/^\s+|\s+$/gm, '')]);
  275. if (showPolygon) {
  276. map.removeOverlay(showPolygon);
  277. }
  278. }
  279. })
  280. }
  281. // checkbox change事件监听
  282. function checkBoxChange() {
  283. // dma分区是否展示
  284. $("#cdma").change(function (e) {
  285. if ($('#cdma').is(':checked')) {
  286. showAllDMA();
  287. } else {
  288. for (var overlay in overlays) {
  289. map.removeOverlay(overlays[overlay]);
  290. }
  291. if (showPolygon) {
  292. map.removeOverlay(showPolygon);
  293. }
  294. }
  295. });
  296. }
  297. // 显示所有dma分区
  298. function showAllDMA() {
  299. for (var overlay in overlays) {
  300. map.addOverlay(overlays[overlay]);
  301. }
  302. // 选中高亮显示
  303. addOnePolygon();
  304. }
  305. // 获取中心点
  306. function getCenterPoint(path) {
  307. var x = 0.0;
  308. var y = 0.0;
  309. for (var i = 0; i < path.length; i++) {
  310. x = x + parseFloat(path[i].lng);
  311. y = y + parseFloat(path[i].lat);
  312. }
  313. x = x / path.length;
  314. y = y / path.length;
  315. return { lng: x, lat: y }
  316. }
  317. // 设置单个区域
  318. function addOnePolygon() {
  319. var paths = overlays[PointTreeCode].getPath();
  320. var polygon = new BMap.Polygon(paths, { strokeColor: "red", strokeWeight: 3, strokeOpacity: 1, FillOpacity: "0.0", fillColor: "none" });
  321. map.addOverlay(polygon);
  322. showPolygon = polygon;
  323. var center = getCenterPoint(paths);
  324. map.setZoom(12);
  325. map.panTo(new BMap.Point(center.lng, center.lat), 2000);
  326. }
  327. </script>
  328. <div class="ui-layout" id="layout" style="height: 100%; width: 100%;">
  329. <div class="ui-layout-west">
  330. <div class="west-Panel">
  331. <div class="panel-Title">分区列表</div>
  332. <div id="itemTree"></div>
  333. </div>
  334. </div>
  335. <div class="ui-layout-center">
  336. <div class="center-Panel">
  337. <div id="tabs">
  338. <div id="tabs-1">
  339. <div class="titlePanel">
  340. <div class="title-search">
  341. <table>
  342. <tr>
  343. <td id="r_title" style="padding-left: 10px;font-size: 16px;font-weight: bold;color: #4C58A4">
  344. <i style="font-size: 20px;margin-right: 5px" class="fa fa-home"></i>分区管理
  345. </td>
  346. </tr>
  347. </table>
  348. </div>
  349. <div class="toolbar">
  350. <div class="btn-group">
  351. <a id="pAdd" class="btn btn-default" onclick="addDMA()"><i class="fa fa-plus"></i>&nbsp;新建分区</a>
  352. <a id="pReplace" class="btn btn-default" onclick="reload();"><i class="fa fa-refresh"></i>&nbsp;刷新</a>
  353. </div>
  354. </div>
  355. </div>
  356. <div class="partitionsContainer">
  357. <ul>
  358. <li id="formLi" style="width: 0%; display: none">
  359. <table id="form1" class="form" style="width: 95%">
  360. <tr style="display: none">
  361. <th class="formTitle">分区ID</th>
  362. <td class="formValue">
  363. <input id="DMAID" type="text" class="form-control" readonly />
  364. </td>
  365. </tr>
  366. <tr>
  367. <th class="formTitle">分区编码</th>
  368. <td class="formValue">
  369. <input id="DMACode" type="text" class="form-control" isvalid="no" checkexpession="NotNull" errormsg="分区编码" placeholder="请输入分区编码" readonly />
  370. </td>
  371. </tr>
  372. <tr>
  373. <th class="formTitle">分区名称<font face="宋体">*</font></th>
  374. <td class="formValue">
  375. <input id="DMAName" type="text" class="form-control" isvalid="yes" checkexpession="NotNull" errormsg="请输入分区名称" placeholder="请输入分区名称"/>
  376. </td>
  377. </tr>
  378. <tr>
  379. <th class="formTitle">填充颜色</th>
  380. <td class="formValue" >
  381. <input type="text" style="height: 35px" id="FillColor" class="form-control fill_Color">
  382. </td>
  383. </tr>
  384. <tr>
  385. <th class="formTitle">管道连接点数(个)</th>
  386. <td class="formValue">
  387. <input id="PipeConnectionPoint" type="text" class="form-control" checkexpession="NumOrNull" isvalid="yes" placeholder="请输入管道连接点数"/>
  388. </td>
  389. </tr>
  390. <tr>
  391. <th class="formTitle">主供水管道长度(KM)</th>
  392. <td class="formValue" >
  393. <input id="MainPipeLength" type="text" class="form-control" checkexpession="DoubleOrNull" isvalid="yes" placeholder="请输入主供水管道长度" />
  394. </td>
  395. </tr>
  396. <tr>
  397. <th class="formTitle">支供水管道长度(KM)</th>
  398. <td class="formValue" >
  399. <input id="BranchPipeLength" type="text" class="form-control" checkexpession="DoubleOrNull" isvalid="yes" placeholder="请输入支供水管道长度" />
  400. </td>
  401. </tr>
  402. <tr>
  403. <th class="formTitle">管道设施状况因子</th>
  404. <td class="formValue" >
  405. <input id="PipeFactor" type="text" class="form-control" checkexpession="DoubleOrNull" isvalid="yes" placeholder="请输入管道设施状况因子" />
  406. </td>
  407. </tr>
  408. <tr>
  409. <th class="formTitle">渗透幂指数 N1</th>
  410. <td class="formValue" >
  411. <input id="N1" type="text" class="form-control" checkexpession="DoubleOrNull" isvalid="yes" placeholder="请输入渗透幂指数" />
  412. </td>
  413. </tr>
  414. <tr>
  415. <th class="formTitle">干管用户管道容积(M3)</th>
  416. <td class="formValue" >
  417. <input id="PipeVolume" type="text" class="form-control" checkexpession="DoubleOrNull" isvalid="yes" placeholder="请输入干管用户管道容积" />
  418. </td>
  419. </tr>
  420. </table>
  421. <div style="margin-top: 30px">
  422. <a id="pConfirm" class="btn btn-primary" onclick="confirmData()">&nbsp;&nbsp;确定&nbsp;&nbsp;</a>
  423. <a style="margin-left: 50px" id="pDelete" class="btn btn-danger" onclick="deleteDMA()">&nbsp;&nbsp;删除&nbsp;&nbsp;</a>
  424. </div>
  425. </li>
  426. <li id="mapLi" style="width: 100%">
  427. <div id='allmap' style='width: 100%; height: 100%;'></div>
  428. <div style="position:absolute;top: 80px;right: 20px;background-color: white;width: 130px;height: 90px;">
  429. <div class="checkbox-wrap">
  430. <input type="checkbox" checked name="choose" id="cdma">
  431. <label class="clable" for="cdma">DMA分区</label>
  432. <input type="checkbox" checked name="choose" id="cpipe">
  433. <label class="clable" for="cpipe">管网</label>
  434. </div>
  435. </div>
  436. </li>
  437. </ul>
  438. </div>
  439. </div>
  440. </div>
  441. </div>
  442. </div>
  443. </div>