AppMain.vue 8.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347
  1. <template>
  2. <section class="app-main">
  3. <div class="app-main-top-text-box" v-if="textType">
  4. <p>{{text}}</p>
  5. <p @click="buttonClick">执行疏散</p>
  6. <p v-if="closePlan">丨</p>
  7. <p v-if="closePlan" @click="offButton">结束预案</p>
  8. </div>
  9. <div class="app-main-top-text-box-two" :class="workType == 1?'work-color-a':(workType == 2?'work-color-b':'')" v-if="!textType&&(workType == 1 || workType == 2)">
  10. <p>{{textWork}}</p>
  11. <p @click="goWorkPage">立即完成</p>
  12. <p class="el-icon-circle-close" @click="workClickOff"></p>
  13. </div>
  14. <transition name="fade-transform" mode="out-in">
  15. <!--<keep-alive :include="cachedViews">-->
  16. <router-view :key="key" />
  17. <!--</keep-alive>-->
  18. </transition>
  19. </section>
  20. </template>
  21. <script>
  22. import { getListStatus,closeRiskPlan } from '@/api/bigData/index.js'
  23. import mqtt from 'mqtt'
  24. export default {
  25. name: 'AppMain',
  26. computed: {
  27. cachedViews() {
  28. return this.$store.state.tagsView.cachedViews
  29. },
  30. key() {
  31. return this.$route.path
  32. }
  33. },
  34. data() {
  35. return {
  36. //MQTT请求参数-传感器
  37. mtopic:"lab/bigview",
  38. mtopicTwo:"manage/work"+localStorage.getItem('userId'),
  39. textType:false,
  40. closePlan:false,
  41. text:"",
  42. textWork:"",
  43. workType:"",
  44. userType:"",
  45. buttonId:"",
  46. buildingId:"",
  47. address:"",
  48. }
  49. },
  50. created() {
  51. this.getListStatus();
  52. },
  53. mounted(){
  54. this.userType = localStorage.getItem('userType')
  55. this.subscriptionMQTT();
  56. },
  57. methods:{
  58. workClickOff(){
  59. this.workType = "";
  60. },
  61. goWorkPage(){
  62. let self = this;
  63. const h = this.$createElement;
  64. this.$msgbox({
  65. title: '',
  66. message: h('p', null, [
  67. h('p', { style:'font-size:16px;margin:20px 0;' }, self.textWork),
  68. ]),
  69. showCancelButton: true,
  70. confirmButtonText: '完成',
  71. cancelButtonText: '取消',
  72. beforeClose: (action, instance, done) => {
  73. if (action === 'confirm') {
  74. //执行
  75. this.$router.push({
  76. path: "/laboratory/gradeManageWork"
  77. })
  78. done();
  79. } else {
  80. //取消
  81. done();
  82. }
  83. }
  84. }).then(action => {
  85. //成功回掉
  86. });
  87. },
  88. //MQTT订阅
  89. subscriptionMQTT(){
  90. let self = this;
  91. this.client = mqtt.connect(process.env.VUE_APP_BASE_MQTT_API, {
  92. username: process.env.VUE_APP_BASE_MQTT_USERNAME,
  93. password: process.env.VUE_APP_BASE_MQTT_PASSWORD
  94. });
  95. this.client.on("connect", e =>{
  96. console.log("连接成功");
  97. this.client.subscribe(this.mtopic, (err) => {
  98. if (!err) {
  99. console.log("警报通道订阅成功:" + this.mtopic);
  100. }
  101. });
  102. this.client.subscribe(this.mtopicTwo, (err) => {
  103. if (!err) {
  104. console.log("工作通道订阅成功:" + this.mtopicTwo);
  105. }
  106. });
  107. });
  108. this.client.on("message", (topic, message) => {
  109. if (message){
  110. console.log("topic",topic);
  111. let data = JSON.parse(message)
  112. console.log("data",data);
  113. if(topic == this.mtopic){
  114. //报警
  115. this.getListStatus();
  116. }
  117. if(topic == this.mtopicTwo){
  118. //工作通知
  119. console.log("工作通知",data);
  120. this.textWork = data.msg;
  121. this.workType = data.type;
  122. }
  123. }
  124. });
  125. },
  126. //结束预案
  127. closeRiskPlan(){
  128. closeRiskPlan({id:this.closeId}).then(response => {
  129. this.msgSuccess("操作成功");
  130. this.getListStatus();
  131. });
  132. },
  133. //查询报警信息
  134. async getListStatus(){
  135. let self = this;
  136. const { data } = await getListStatus();
  137. console.log("getListStatusgetListStatusgetListStatusgetListStatus",data);
  138. if(data.code==200){
  139. if(data.data[0].floorId != 7){
  140. self.text = data.data[0].buildName + data.data[0].floorName + data.data[0].roomName + data.data[0].subjectName + '发生应急预案';
  141. self.textName = data.data[0].subjectName;
  142. self.subjectId = data.data[0].subjectId;
  143. self.textType = self.userType != '22';
  144. self.closePlan =data.data[0].closePlan;
  145. self.closeId = data.data[0].id;
  146. self.buttonId = data.data[0].floorId;
  147. self.buildingId = data.data[0].buildId;
  148. self.address = data.data[0].deptName +'-'+data.data[0].buildName+''+data.data[0].floorName;
  149. }
  150. }
  151. },
  152. //结束预案
  153. offButton(){
  154. let self = this;
  155. this.$confirm('确定要结束预案吗?', "警告", {
  156. confirmButtonText: "确定",
  157. cancelButtonText: "取消",
  158. type: "warning"
  159. }).then(function() {
  160. self.closeRiskPlan();
  161. }).then(() => {
  162. }).catch(() => {});
  163. },
  164. //执行按钮
  165. buttonClick(){
  166. let self = this;
  167. const h = this.$createElement;
  168. this.$msgbox({
  169. title: '',
  170. message: h('p', null, [
  171. h('i', { style: 'color: #ea9518;font-size:100px;' ,class:"el-icon-warning-outline"}),
  172. h('p', { style:'font-size:16px;margin:20px 0;' }, self.text+',是否联动执行疏散? '),
  173. ]),
  174. showCancelButton: true,
  175. confirmButtonText: '执行',
  176. cancelButtonText: '查看',
  177. beforeClose: (action, instance, done) => {
  178. if (action === 'confirm') {
  179. //执行
  180. this.$router.push({
  181. path: "/emergencyEvacuationBig",
  182. query: {
  183. subId: self.subjectId,
  184. text:self.textName,
  185. buttonId:self.buttonId,
  186. buildingId:self.buildingId,
  187. address:self.address,
  188. type:"1",
  189. }
  190. })
  191. done();
  192. } else {
  193. this.$router.push({
  194. path: "/emergencyEvacuationBig",
  195. query: {
  196. subId: self.subjectId,
  197. text:self.textName,
  198. buttonId:self.buttonId,
  199. buildingId:self.buildingId,
  200. address:self.address,
  201. type:"2",
  202. }
  203. })
  204. //取消
  205. done();
  206. }
  207. }
  208. }).then(action => {
  209. //成功回掉
  210. });
  211. },
  212. //跳转分级管控工作
  213. }
  214. }
  215. </script>
  216. <style lang="scss" scoped>
  217. .app-main {
  218. /* 50= navbar 50 */
  219. /*min-height: calc(100vh - 50px);*/
  220. width: 100%;
  221. position: relative;
  222. overflow: hidden;
  223. display: flex;
  224. flex-direction: column;
  225. }
  226. .work-color-a{
  227. background: rgba(30,144,255,0.2);
  228. p{
  229. color:#0045AF;
  230. }
  231. }
  232. .work-color-b{
  233. background: rgba(255,0,0,0.2);
  234. p{
  235. color:#FF0000;
  236. }
  237. }
  238. .app-main-top-text-box-two{
  239. margin:10px 20px 0 10px;
  240. border-radius:10px;
  241. padding:0 0 0 20px;
  242. display: flex;
  243. p{
  244. line-height:60px;
  245. font-size:16px;
  246. margin:0;
  247. }
  248. p:nth-child(1){
  249. flex:1;
  250. }
  251. p:nth-child(2){
  252. width:100px;
  253. cursor: pointer;
  254. }
  255. p:nth-child(3){
  256. font-size:22px;
  257. margin-right:20px;
  258. cursor: pointer;
  259. }
  260. }
  261. .app-main-top-text-box{
  262. background: rgba(255,0,0,0.2);
  263. margin:10px 20px 0 10px;
  264. border-radius:10px;
  265. padding:0 0 0 20px;
  266. display: flex;
  267. p{
  268. line-height:60px;
  269. font-size:16px;
  270. margin:0;
  271. }
  272. p:nth-child(1){
  273. flex:1;
  274. color:#FF0000;
  275. }
  276. p:nth-child(2){
  277. width:100px;
  278. color:#0045AF;
  279. cursor: pointer;
  280. text-align: center;
  281. }
  282. p:nth-child(3){
  283. color:#0045AF;
  284. text-align: center;
  285. width:30px;
  286. font-weight:500;
  287. }
  288. p:nth-child(4){
  289. width:100px;
  290. color:#0045AF;
  291. cursor: pointer;
  292. text-align: center;
  293. }
  294. }
  295. .app-main-position-max-box{
  296. position: fixed;
  297. height:100%;
  298. width:100%;
  299. background: rgba(0,0,0,0.2);
  300. z-index: 100;
  301. .app-main-position-big-box{
  302. .app-main-position-box{
  303. position: absolute;
  304. top: 50%;
  305. left: 50%;
  306. background: #fff;
  307. width:500px;
  308. height:300px;
  309. margin-left:-250px;
  310. margin-top:-150px;
  311. border-radius:10px;
  312. box-shadow: 0 0 8px 2px rgba(0, 0, 0, 0.1);
  313. .app-main-position-box-bottom-button-box{
  314. display: flex;
  315. }
  316. }
  317. }
  318. }
  319. .fixed-header+.app-main {
  320. padding-top: 50px;
  321. }
  322. .hasTagsView {
  323. .app-main {
  324. /* 84 = navbar + tags-view = 50 + 34 */
  325. /*min-height: calc(100vh - 84px);*/
  326. }
  327. .fixed-header+.app-main {
  328. padding-top: 84px;
  329. }
  330. }
  331. </style>
  332. <style lang="scss">
  333. // fix css style bug in open el-dialog
  334. .el-popup-parent--hidden {
  335. .fixed-header {
  336. padding-right: 15px;
  337. }
  338. }
  339. </style>