FloorClick.js 8.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262
  1. //创建楼层选择器
  2. function creatFloorChoose() {
  3. var floorsign =
  4. `
  5. <div value='close' onclick="handleSide()" class ="closeIocn" id='rightSideSwitch'></div>
  6. <div id="floorChooseDiv" class="showFloorBtn" style="height:95%">
  7. </div>`;
  8. $('#div2d').append($(floorsign));
  9. var car = app.query(".Floor")
  10. var html = ``
  11. for(let i = 0 ; i < car.length; i++){
  12. html +=
  13. `
  14. <div onclick="floorclick('${car[i].id}')" class = "showFloorBtns" id='${car[i].id}'>${car[i].id}</div>
  15. `
  16. }
  17. $('#floorChooseDiv').append($(html));
  18. $('head').append($(`
  19. <style>
  20. .showFloorBtns{
  21. margin-bottom:6px;
  22. border:1px solid rgb(24,118,208);
  23. border-radius:4px;
  24. text-align:center;
  25. height:28px;
  26. line-height:28px;
  27. width:40px;
  28. color:rgba(255,255,255,0.5);
  29. background-color:rgba(24,144,255,0.3);
  30. // display:inline-block;
  31. }
  32. .showFloorBtn{
  33. position: absolute;
  34. // top:10px;
  35. top:calc(2%);
  36. right:-52px;
  37. // height:800px;
  38. width:50px;
  39. border-radius:0px;
  40. margin-top:0px;
  41. overflow-y: auto;
  42. cursor:pointer;
  43. scrollbar-width: none; /* firefox */
  44. -ms-overflow-style: none; /* IE 10+ */
  45. }
  46. .closeIocn{
  47. // margin-bottom:6px;
  48. // border:1px solid rgb(24,118,208);
  49. border-radius:4px;
  50. text-align:center;
  51. height:30px;
  52. line-height:28px;
  53. width:40px;
  54. color:rgba(255,255,255,0.5);
  55. background-image: url(/uploads/wechat/163607/file/杨浦16/icons/yCR8dP.png);
  56. background-repeat:no-repeat;
  57. background-position:center center;
  58. position: absolute;
  59. top: calc(50%);
  60. right: 0;
  61. }
  62. .active{
  63. background-color:red;
  64. }
  65. .showFloorBtn::-webkit-scrollbar {
  66. display: none;
  67. }
  68. </style>
  69. `));
  70. }
  71. //楼层切换
  72. function floorclick(id) {
  73. // test();
  74. // delMydiv();
  75. // floormen = id.id;
  76. // building = app.buildings[0];
  77. // var num = floormen.substring(1, 3);
  78. // var s = parseInt(num);
  79. // var floor = building.floors[s - 1];
  80. var floor = app.query("#" + id)[0];
  81. app.level.change(floor);
  82. // creatbutType(s);
  83. creatbutElement(id)
  84. }
  85. // 点击右侧侧边栏开关
  86. function handleSide() {
  87. if ($('#rightSideSwitch').attr('value') == 'close') {
  88. $('.closeIocn').animate({ right: 48 }, 300);
  89. $('.showFloorBtn').animate({ right: 0 }, 300);
  90. // $('#rightSideSwitch').attr('value', 'open');
  91. $('#rightSideSwitch').attr('value', 'open').css('background-image', 'url(/uploads/wechat/163607/file/杨浦16/icons/yCRGIf.png)');
  92. } else if ($('#rightSideSwitch').attr('value') == 'open') {
  93. $('.closeIocn').animate({ right: 0 }, 300);
  94. $('.showFloorBtn').animate({ right: -52 }, 300);
  95. $('#rightSideSwitch').attr('value', 'close').css('background-image', 'url(/uploads/wechat/163607/file/杨浦16/icons/yCR8dP.png)');
  96. // $('#rightSideSwitch').attr('value', 'close');
  97. }
  98. }
  99. //设备类型div删除
  100. function delMydiv() {
  101. var mydiv = document.getElementById("bottomBtnsRight")
  102. if (mydiv) {
  103. if (mydiv != null)
  104. mydiv.parentNode.removeChild(mydiv);
  105. }
  106. }
  107. //设备类型选择器
  108. function creatbutElement(floorNum) {
  109. if(floorNum == "B1"){
  110. floorNum = "F-1"
  111. }
  112. delMydiv();
  113. var devType = [];
  114. var data = cleanObj(buildingStore);
  115. for (var i = 0; i < data.length; i++) {
  116. var floorData = data[i]
  117. var floorId = floorData.min_level;
  118. var num = floorNum.substring(1, 3);
  119. var s = parseInt(num)
  120. if (floorId == s) {
  121. var dataArray = floorData.item;
  122. if (dataArray) {
  123. for (var q = 0; q < dataArray.length; q++) {
  124. var eee = dataArray[q].dwtype;
  125. devType.push(eee);
  126. }
  127. }
  128. break;
  129. }
  130. }
  131. var darray = uniq(devType);
  132. var textAndPictureMarkerHtml =
  133. `<div class="bottomBtnsRight" id="bottomBtnsRight">
  134. </div>`;
  135. $('#div2d').append($(textAndPictureMarkerHtml));
  136. var cont = 1;
  137. console.log(darray)
  138. darray.forEach(function (name) {
  139. if (name == "YTVA") {
  140. var yTVAHtml =
  141. `<div onclick="icon_click('YTVA',` + s + `)" class="bottomBtn" value='视频告警监测'>
  142. <span class="bottomBtnText">视频告警监测<span>
  143. </div>
  144. `;
  145. $('#bottomBtnsRight').append($(yTVAHtml));
  146. } else if (name == "YTWP") {
  147. var yTVAHtml =
  148. `<div onclick="icon_click('YTWP',` + s + `)" class="bottomBtn" value='水压检测'>
  149. <span class="bottomBtnText">水压监测<span>
  150. </div>
  151. `;
  152. $('#bottomBtnsRight').append($(yTVAHtml));
  153. } else if (name == "YTCI") {
  154. var yTVAHtml =
  155. `<div onclick="icon_click('YTCI',` + s + `)" class="bottomBtn" value='环境监测'>
  156. <span class="bottomBtnText">环境监测<span>
  157. </div>
  158. `;
  159. $('#bottomBtnsRight').append($(yTVAHtml));
  160. } else if (name == "YTEF") {
  161. var yTVAHtml =
  162. `<div onclick="icon_click('YTEF',` + s + `)" class="bottomBtn" value='电气火灾监测'>
  163. <span class="bottomBtnText">电气火灾监测<span>
  164. </div>
  165. `;
  166. $('#bottomBtnsRight').append($(yTVAHtml));
  167. } else if (name == "YTFC") {
  168. var yTVAHtml =
  169. `<div onclick="icon_click('YTFC',` + s + `)" class="bottomBtn" value='消防控制柜'>
  170. <span class="bottomBtnText">消防控制柜<span>
  171. </div>
  172. `;
  173. $('#bottomBtnsRight').append($(yTVAHtml));
  174. } else if (name == "YTSM") {
  175. var yTVAHtml =
  176. `<div onclick="icon_click('YTSM',` + s + `)" class="bottomBtn" value='烟感'>
  177. <span class="bottomBtnText">烟感<span>
  178. </div>
  179. `;
  180. $('#bottomBtnsRight').append($(yTVAHtml));
  181. }
  182. else if (name == "YTLL") {
  183. var yTVAHtml =
  184. `<div onclick="icon_click('YTLL',` + s + `)" class="bottomBtn" value='液位'>
  185. <span class="bottomBtnText">液位<span>
  186. </div>
  187. `;
  188. $('#bottomBtnsRight').append($(yTVAHtml));
  189. }
  190. else if (name == "YTWI") {
  191. var yTVAHtml =
  192. `<div onclick="icon_click('YTWI',` + s + `)" class="bottomBtn" value='水浸'>
  193. <span class="bottomBtnText">水浸<span>
  194. </div>
  195. `;
  196. $('#bottomBtnsRight').append($(yTVAHtml));
  197. }else if (name == "YTWG") {
  198. var yTVAHtml =
  199. `<div onclick="icon_click('YTWG',` + s + `)" class="bottomBtn" value='网关'>
  200. <span class="bottomBtnText">网关<span>
  201. </div>
  202. `;
  203. $('#bottomBtnsRight').append($(yTVAHtml));
  204. }else if (name == "YTRU") {
  205. var yTVAHtml =
  206. `<div onclick="icon_click('YTRU',` + s + `)" class="bottomBtn" value='路由'>
  207. <span class="bottomBtnText">路由<span>
  208. </div>
  209. `;
  210. $('#bottomBtnsRight').append($(yTVAHtml));
  211. }
  212. })
  213. $('head').append($(`
  214. <style>
  215. .bottomBtn{
  216. text-align: center;
  217. left:200px;
  218. width: 100px;
  219. height: 31px;
  220. margin-top: 7px;
  221. top:650px;
  222. // display: inline-block;
  223. background-image: url(${baseURL}ySL6MT.png);
  224. }
  225. .bottomBtnsRight{
  226. position: relative;
  227. // top:481px;
  228. bottom:-459px;
  229. justify-content: left;
  230. // width: calc(100% - 203px);
  231. height: 40px;
  232. }
  233. .bottomBtnText{
  234. font-size: 12px;
  235. display: inline-block;
  236. text-align:center;
  237. padding-left: 15px;
  238. color:rgba(255,255,255,0.5);
  239. letter-spacing: 2px;
  240. line-height: 36px;
  241. }
  242. </style>
  243. `));
  244. }
  245. //创建设备点位标识
  246. function icon_click(deviceType, floorNum) {
  247. buildingStore;
  248. deviceList = [];
  249. for (var i = 0; i < buildingStore.length; i++) {
  250. if (floorNum == buildingStore[i].min_level) {
  251. deviceList.push(buildingStore[i]);
  252. }
  253. }
  254. create_ui(deviceType, floorNum, deviceList);
  255. }