Home.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393
  1. <template>
  2. <div class="home">
  3. <div v-wechat-title="$route.meta.title"></div>
  4. <el-row class="contentClass contnetLift">
  5. <template>
  6. <info class="info" :resInfo="data.info" :websocket="data.winfo" />
  7. <!-- <access-control class="accessControl" v-else-if="item.styleValue === 2" :key="item.styleValue" :resInfo="item"></access-control> -->
  8. <parking-lot class="parkingLot" :resInfo="data.parkingLot" :websocket="data.wparkingLot" />
  9. <!-- <monitor class="monitor" /> -->
  10. <!-- <conference-room class="conferenceRoom" v-else-if="item.styleValue === 5" :key="item.styleValue" :resInfo="item"></conference-room>
  11. <give-an-alarm class="giveAnAlarm" v-else-if="item.styleValue === 6" :key="item.styleValue" :resInfo="item"></give-an-alarm> -->
  12. </template>
  13. </el-row>
  14. <el-row class="contnetCenter" >
  15. <!-- <iframe src="https://www.thingjs.com/s/cd7b1592538e0f4a9572c55e?params=105b0f77fd24654d4eebc434e9" frameborder="0" id="iframe"></iframe> -->
  16. </el-row>
  17. <el-row class="contentClass contnetRight">
  18. <emergencyDisasterPrevention class="emergencyDisasterPrevention" :resInfo="data.emergencyDisasterPrevention" />
  19. <access-control class="accessControl" :resInfo="data.accessControl" :websocket="data.waccessControl" />
  20. <computerRoom class="computerRoom" :resInfo="data.computerRoom" :websocket="data.wcomputerRoom" />
  21. <giveAnAlarm class="giveAnAlarm" :resInfo="data.giveAnAlarm" :websocket="data.wgiveAnAlarm" @giveAnAlarmClick="giveAnAlarmClick" />
  22. </el-row>
  23. <SpringFrame v-if="springFrameState" :resInfo="item" :close2="item.close" @close="SpringFrameChange" />
  24. </div>
  25. </template>
  26. <script>
  27. // 党校
  28. import info from "../components/SD-school/info"; // 综合信息统计
  29. import accessControl from "../components/SD-school/access-control"; // 门禁进出入统计
  30. import parkingLot from "../components/SD-school/parking-lot"; // 停车场统计
  31. import monitor from "../components/SD-school/monitor"; // 视频监控
  32. import emergencyDisasterPrevention from "../components/SD-school/emergency-disaster-prevention" //应急防灾
  33. import computerRoom from "../components/SD-school/computer-room"; // 机房温度
  34. // import conferenceRoom from "../components/SD-school/conference-room"; // 会议室统计
  35. import giveAnAlarm from "../components/SD-school/give-an-alarm"; // 综合告警列表
  36. import SpringFrame from "../components/SD-school/Spring-frame"; // 弹框
  37. import {
  38. accessControlApi,
  39. computerRoomApi,
  40. emergencyDisasterPreventionApi,
  41. parkingLotApi,
  42. infoApi,
  43. typeApi,
  44. shebeifyApi,
  45. tbDevice,
  46. } from "@/plugins/api";
  47. export default {
  48. name: "Home",
  49. components: {
  50. info,
  51. parkingLot,
  52. monitor,
  53. emergencyDisasterPrevention,
  54. accessControl,
  55. computerRoom,
  56. giveAnAlarm,
  57. SpringFrame,
  58. },
  59. data() {
  60. return {
  61. // isLeft: true,
  62. // isRight: true,
  63. // resList:[],
  64. // imageList:[],
  65. data:{//主页各系统板块初始数据及websocket数据
  66. "accessControl":[],
  67. "parkingLot":[],
  68. "computerRoom":[],
  69. "emergencyDisasterPrevention":[],
  70. "parkingLot":[],
  71. "info":[],
  72. "giveAnAlarm":[],
  73. "winfo":[],
  74. "wparkingLot":[],
  75. "wemergencyDisasterPrevention":[],
  76. "waccessControl":[],
  77. "wcomputerRoom":[],
  78. "wgiveAnAlarm":[],
  79. },
  80. springFrameState:true,//弹框
  81. item:{ //弹框下各系统板块
  82. "warningState":false,
  83. "meetingState":true,
  84. "equipmentState":false,
  85. "videoState":false,
  86. "xinfaState":false,
  87. "warningMessage":{},
  88. "equipmentMessage":{},
  89. "videoMessage":{},
  90. "xinfaMessage":{},
  91. "time":null,
  92. "close":false,
  93. "xinfaMessage":{},
  94. // "alertMessage":{ //
  95. // name:null,
  96. // data:{}
  97. // },
  98. // "time":false
  99. // "music":false
  100. },
  101. };
  102. },
  103. created() {
  104. this.getData()
  105. },
  106. mounted() {
  107. var that = this;
  108. window.addEventListener("message",function (event) {
  109. console.log(event)
  110. var isDOM = typeof event.data === "object";
  111. // // 监听父窗口发送过来的数据向服务器发送post请求
  112. var data = event.data;
  113. if (isDOM == true) {
  114. if ("param" in data == true) {
  115. if (data.param.name === "1楼会议室" && data.param.id === "109") { //会议室弹框开启
  116. // setTimeout(()=>{
  117. // that.springFrameState = false
  118. // },1)
  119. // setTimeout(()=>{
  120. // that.springFrameState = true
  121. // that.item.meetingState = true
  122. // },2)
  123. console.log("会议室弹框暂时关闭")
  124. }else if(data.param.id =="B1" || data.param.id =="F1" || data.param.id =="F2" || data.param.id =="F3" || data.param.id =="F4"
  125. || data.param.id =="F5" || data.param.id =="F6" || data.param.id =="F7" || data.param.id =="F8" || data.param.id =="F9"
  126. || data.param.id =="F10" || data.param.id =="F11" || data.param.id =="F12" || data.param.id =="F13"){ //楼层id过滤
  127. console.log("楼层")
  128. }else{
  129. tbDevice(data.param.id).then(res =>{ //设备信息查询
  130. console.log(res)
  131. setTimeout(()=>{
  132. that.springFrameState = false
  133. },1)
  134. setTimeout(()=>{
  135. console.log(res.data.detail)
  136. let name = data.param.name
  137. if(name.indexOf("摄像头")>-1){ //摄像头
  138. console.log("摄像头")
  139. that.springFrameState = true
  140. that.item.videoState = true
  141. that.item.videoMessage = res.data.detail
  142. }else{//设备
  143. console.log("设备")
  144. if(res.data.detail){
  145. if(res.data.detail.manufacturer == 3){
  146. console.log("信发")
  147. that.springFrameState = true
  148. that.item.xinfaState = true
  149. that.item.xinfaMessage = res.data.detail
  150. }else{
  151. console.log("信发、摄像头外设备")
  152. that.springFrameState = true
  153. that.item.equipmentState = true
  154. that.item.equipmentMessage = res.data.detail
  155. }
  156. }else{
  157. console.log("信发、摄像头外设备")
  158. that.springFrameState = true
  159. that.item.equipmentState = true
  160. that.item.equipmentMessage = res.data.detail
  161. }
  162. }
  163. },2)
  164. })
  165. }
  166. }
  167. }
  168. },false)
  169. },
  170. methods: {
  171. postMsg(newValue) {
  172. var myframe = document.getElementById("iframe"); //获取iframe
  173. myframe.contentWindow.postMessage({ state: false, name: "门禁" }, "*"); //childDomain是子页面的源(协议+主机+端口号)
  174. },
  175. async getData(){
  176. accessControlApi().then(res =>{ // 门禁进出入统计
  177. this.data.accessControl = res.data
  178. })
  179. computerRoomApi().then(res =>{ // 机房温度
  180. this.data.computerRoom = res.data
  181. })
  182. emergencyDisasterPreventionApi().then(res =>{ //应急防灾
  183. this.data.emergencyDisasterPrevention = res.data
  184. })
  185. parkingLotApi().then(res =>{ //停车场统计
  186. this.data.parkingLot = res.data
  187. })
  188. infoApi().then(res =>{ //综合信息统计 告警信息
  189. this.data.info = res.data
  190. })
  191. // typeApi().then(res =>{ //综合信息统计 告警信息
  192. shebeifyApi({"current":"1","size":"10"}).then(res =>{
  193. this.data.giveAnAlarm = res.data.records
  194. })
  195. // })
  196. console.log(this.$store.state.wsUrl)
  197. console.log("ws://" + this.$store.state.wsUrl + "/top/WS/alarmPush")
  198. if ("WebSocket" in window) {
  199. this.ws = new WebSocket("ws://" + this.$store.state.wsUrl + "/top/WS/alarmPush");
  200. console.log(this.ws)
  201. this.ws.onopen = ()=> {
  202. console.log("websocket连接成功");
  203. //this.sendWs({aa:22});
  204. };
  205. this.ws.onmessage = (res) => { //接收websocket消息
  206. let data = JSON.parse(res.data)
  207. console.log(data)
  208. if(data.describe == "parkingLotALL"){ //停车总数
  209. this.data.wparkingLot = data
  210. }else if(data.describe == "meeting"){ //会议数据
  211. this.item.meetingState = true
  212. }else if(data.describe == "emergencyDisasterPreventionALL"){ //应急防灾总数
  213. this.data.emergencyDisasterPrevention = data.data
  214. }else if(data.describe == "accessControlAll"){ //门禁总数
  215. this.data.waccessControl = data
  216. }else if(data.describe == "computerRoom"){ //机房温度
  217. computerRoomApi().then(res =>{
  218. this.data.computerRoom = res.data
  219. })
  220. }else if(data.describe == "infoAdd"){ //手推告警记录
  221. infoApi().then(res =>{ //综合信息统计 告警信息
  222. this.data.info = res.data
  223. console.log(this.data.info)
  224. })
  225. this.data.wgiveAnAlarm = data
  226. }else if(data.describe == "accessControlSwitch"){ //三维建筑门禁开关
  227. let state = JSON.parse(res.data).data.state
  228. var myframe = document.getElementById("iframe"); //获取iframe
  229. myframe.contentWindow.postMessage({ state: state, name: "门禁" , id: "F13XCMJ2"}, "*"); //childDomain是子页面的源(协议+主机+端口号)
  230. }else{ //综合信息统计 、综合列表告警
  231. infoApi().then(res =>{ //综合信息统计 告警信息
  232. this.data.info = res.data
  233. })
  234. this.data.wgiveAnAlarm = data
  235. }
  236. };
  237. this.ws.onclose = ()=> { //关闭websocket
  238. // 关闭 websocket
  239. //console.log("连接已关闭...");
  240. //断线重新连接
  241. setTimeout(() => {
  242. this.getData();
  243. }, 2000);
  244. }
  245. } else {
  246. // 浏览器不支持 WebSocket
  247. console.log("您的浏览器不支持 WebSocket!");
  248. }
  249. },
  250. sendWs(val){
  251. if (this.ws && this.ws.readyState == 1) {
  252. this.ws.send(JSON.stringify(val));
  253. console.log('发送成功')
  254. } else {
  255. setTimeout(() => {
  256. this.sendWs(val);
  257. }, 100);
  258. }
  259. },
  260. giveAnAlarmClick(val){ //告警列表数据传值
  261. setTimeout(()=>{
  262. this.springFrameState = false
  263. },0)
  264. setTimeout(()=>{
  265. this.item.warningMessage = val
  266. this.item.warningState = true
  267. this.springFrameState = true
  268. },1)
  269. },
  270. SpringFrameChange(){
  271. this.springFrameState = false
  272. this.item.warningState = false
  273. this.item.meetingState = false
  274. this.item.equipmentState = false
  275. this.item.videoState = false
  276. },
  277. // roomBox(val){
  278. // val === 'left' ? this.isLeft = !this.isLeft : (this.isRight = !this.isRight)
  279. // },
  280. // changeImage(val){
  281. // this.imageList.unshift(...val)
  282. // },
  283. footerImage(val){
  284. this.footerList.unshift(...val)
  285. this.footerList = this.footerList.slice(0,7)
  286. }
  287. },
  288. };
  289. </script>
  290. <style lang="scss" scoped>
  291. .home {
  292. .iframe{
  293. position: absolute;
  294. width:100%;
  295. height:100%;
  296. z-index: -1;
  297. top:0;
  298. left:0;
  299. right:0
  300. }
  301. width: 100%;
  302. height: 100%;
  303. display: flex;
  304. justify-content: space-between;
  305. padding: 20px 0 20px 15px;
  306. box-sizing: border-box;
  307. position: relative;
  308. iframe{
  309. position: absolute;
  310. left: 0;
  311. top: 0;
  312. width: 100%;
  313. height: 100%;
  314. }
  315. .contentBox{
  316. width: 100%;
  317. height: 100%;
  318. display: flex;
  319. justify-content: space-between;
  320. }
  321. .contentClass {
  322. width: 25%;
  323. min-width: 500px;
  324. height: 102%;
  325. display: flex;
  326. flex-direction: column;
  327. position: relative;
  328. }
  329. .contnetCenter{
  330. flex: 1;
  331. }
  332. .info {
  333. width: 100%;
  334. height: 40%;
  335. }
  336. .accessControl {
  337. width: 100%;
  338. height: 28%;
  339. }
  340. .monitor {
  341. width: 100%;
  342. height: 32%;
  343. }
  344. .parkingLot,
  345. .conferenceRoom,
  346. .giveAnAlarm,
  347. .equipment,
  348. .giveAnAlarmAf,
  349. .warningInfo,
  350. .screenEquipment,
  351. .currentState,
  352. .monitorInfo {
  353. width: 100%;
  354. height: 31%;
  355. overflow: hidden;
  356. // flex: 1;
  357. }
  358. .emergencyDisasterPrevention,.computerRoom{
  359. width: 100%;
  360. height:25%;
  361. }
  362. .contnetRight{
  363. margin-left:15px;
  364. }
  365. .contnetCenter{
  366. height:100.4%;
  367. border-radius: 6px;
  368. }
  369. .accessControl{
  370. height:20%;
  371. }
  372. .giveAnAlarm{
  373. height:45%;
  374. }
  375. }
  376. </style>