AppMain.vue 8.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349
  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]){
  140. if(data.data[0].floorId != 7){
  141. self.text = data.data[0].buildName + data.data[0].floorName + data.data[0].roomName + data.data[0].subjectName + '发生应急预案';
  142. self.textName = data.data[0].subjectName;
  143. self.subjectId = data.data[0].subjectId;
  144. self.textType = self.userType != '22';
  145. self.closePlan =data.data[0].closePlan;
  146. self.closeId = data.data[0].id;
  147. self.buttonId = data.data[0].floorId;
  148. self.buildingId = data.data[0].buildId;
  149. self.address = data.data[0].deptName +'-'+data.data[0].buildName+''+data.data[0].floorName;
  150. }
  151. }
  152. }
  153. },
  154. //结束预案
  155. offButton(){
  156. let self = this;
  157. this.$confirm('确定要结束预案吗?', "警告", {
  158. confirmButtonText: "确定",
  159. cancelButtonText: "取消",
  160. type: "warning"
  161. }).then(function() {
  162. self.closeRiskPlan();
  163. }).then(() => {
  164. }).catch(() => {});
  165. },
  166. //执行按钮
  167. buttonClick(){
  168. let self = this;
  169. const h = this.$createElement;
  170. this.$msgbox({
  171. title: '',
  172. message: h('p', null, [
  173. h('i', { style: 'color: #ea9518;font-size:100px;' ,class:"el-icon-warning-outline"}),
  174. h('p', { style:'font-size:16px;margin:20px 0;' }, self.text+',是否联动执行疏散? '),
  175. ]),
  176. showCancelButton: true,
  177. confirmButtonText: '执行',
  178. cancelButtonText: '查看',
  179. beforeClose: (action, instance, done) => {
  180. if (action === 'confirm') {
  181. //执行
  182. this.$router.push({
  183. path: "/emergencyEvacuationBig",
  184. query: {
  185. subId: self.subjectId,
  186. text:self.textName,
  187. buttonId:self.buttonId,
  188. buildingId:self.buildingId,
  189. address:self.address,
  190. type:"1",
  191. }
  192. })
  193. done();
  194. } else {
  195. this.$router.push({
  196. path: "/emergencyEvacuationBig",
  197. query: {
  198. subId: self.subjectId,
  199. text:self.textName,
  200. buttonId:self.buttonId,
  201. buildingId:self.buildingId,
  202. address:self.address,
  203. type:"2",
  204. }
  205. })
  206. //取消
  207. done();
  208. }
  209. }
  210. }).then(action => {
  211. //成功回掉
  212. });
  213. },
  214. //跳转分级管控工作
  215. }
  216. }
  217. </script>
  218. <style lang="scss" scoped>
  219. .app-main {
  220. /* 50= navbar 50 */
  221. /*min-height: calc(100vh - 50px);*/
  222. width: 100%;
  223. position: relative;
  224. overflow: hidden;
  225. display: flex;
  226. flex-direction: column;
  227. }
  228. .work-color-a{
  229. background: rgba(30,144,255,0.2);
  230. p{
  231. color:#0045AF;
  232. }
  233. }
  234. .work-color-b{
  235. background: rgba(255,0,0,0.2);
  236. p{
  237. color:#FF0000;
  238. }
  239. }
  240. .app-main-top-text-box-two{
  241. margin:10px 20px 0 10px;
  242. border-radius:10px;
  243. padding:0 0 0 20px;
  244. display: flex;
  245. p{
  246. line-height:60px;
  247. font-size:16px;
  248. margin:0;
  249. }
  250. p:nth-child(1){
  251. flex:1;
  252. }
  253. p:nth-child(2){
  254. width:100px;
  255. cursor: pointer;
  256. }
  257. p:nth-child(3){
  258. font-size:22px;
  259. margin-right:20px;
  260. cursor: pointer;
  261. }
  262. }
  263. .app-main-top-text-box{
  264. background: rgba(255,0,0,0.2);
  265. margin:10px 20px 0 10px;
  266. border-radius:10px;
  267. padding:0 0 0 20px;
  268. display: flex;
  269. p{
  270. line-height:60px;
  271. font-size:16px;
  272. margin:0;
  273. }
  274. p:nth-child(1){
  275. flex:1;
  276. color:#FF0000;
  277. }
  278. p:nth-child(2){
  279. width:100px;
  280. color:#0045AF;
  281. cursor: pointer;
  282. text-align: center;
  283. }
  284. p:nth-child(3){
  285. color:#0045AF;
  286. text-align: center;
  287. width:30px;
  288. font-weight:500;
  289. }
  290. p:nth-child(4){
  291. width:100px;
  292. color:#0045AF;
  293. cursor: pointer;
  294. text-align: center;
  295. }
  296. }
  297. .app-main-position-max-box{
  298. position: fixed;
  299. height:100%;
  300. width:100%;
  301. background: rgba(0,0,0,0.2);
  302. z-index: 100;
  303. .app-main-position-big-box{
  304. .app-main-position-box{
  305. position: absolute;
  306. top: 50%;
  307. left: 50%;
  308. background: #fff;
  309. width:500px;
  310. height:300px;
  311. margin-left:-250px;
  312. margin-top:-150px;
  313. border-radius:10px;
  314. box-shadow: 0 0 8px 2px rgba(0, 0, 0, 0.1);
  315. .app-main-position-box-bottom-button-box{
  316. display: flex;
  317. }
  318. }
  319. }
  320. }
  321. .fixed-header+.app-main {
  322. padding-top: 50px;
  323. }
  324. .hasTagsView {
  325. .app-main {
  326. /* 84 = navbar + tags-view = 50 + 34 */
  327. /*min-height: calc(100vh - 84px);*/
  328. }
  329. .fixed-header+.app-main {
  330. padding-top: 84px;
  331. }
  332. }
  333. </style>
  334. <style lang="scss">
  335. // fix css style bug in open el-dialog
  336. .el-popup-parent--hidden {
  337. .fixed-header {
  338. padding-right: 15px;
  339. }
  340. }
  341. </style>