AppMain.vue 10 KB

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