AppMain.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401
  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. const h = this.$createElement;
  179. this.$msgbox({
  180. title: '',
  181. message: h('p', null, [
  182. h('i', { style: 'color: #ea9518;font-size:100px;' ,class:"el-icon-warning-outline"}),
  183. h('p', { style:'font-size:16px;margin:20px 0;' }, self.text+',是否立即查看? '),
  184. ]),
  185. showCancelButton: true,
  186. confirmButtonText: '查看',
  187. cancelButtonText: '取消',
  188. beforeClose: (action, instance, done) => {
  189. if (action === 'confirm') {
  190. //执行
  191. this.$router.push({
  192. path: "/emergencyManagement/evacuation/newPerformEvacuation",
  193. query: {
  194. buildId: self.buildId,
  195. floorId:self.floorId,
  196. subId:self.subId,
  197. }
  198. })
  199. done();
  200. } else {
  201. // this.$router.push({
  202. // path: "/emergencyEvacuationBig",
  203. // query: {
  204. // subId: self.subjectId,
  205. // text:self.textName,
  206. // buttonId:self.buttonId,
  207. // buildingId:self.buildingId,
  208. // address:self.address,
  209. // type:"2",
  210. // }
  211. // })
  212. //取消
  213. done();
  214. }
  215. }
  216. }).then(action => {
  217. //成功回掉
  218. });
  219. },
  220. //查询当前用户下的预案触发数据
  221. selectTriggerInfo(){
  222. let self = this;
  223. selectTriggerInfo().then(response => {
  224. if(response.data[0]){
  225. this.$set(this,'text',response.data.length>1?'有多个实验室发生预案':'有实验室发生预案');
  226. this.$set(this,'buildId',response.data[0].buildId);
  227. this.$set(this,'floorId',response.data[0].floorId);
  228. this.$set(this,'subId',response.data[0].subId);
  229. this.$set(this,'groupId',response.data[0].groupId);
  230. if(response.data[0].riskAttribute == 1){
  231. this.$set(this,'closePlan',true);
  232. }
  233. this.$set(this,'textType',true);
  234. for(let i=0;i<response.data.length;i++){
  235. if(response.data[i].riskAttribute == '1'&&response.data[i].ifcheck != '1'){
  236. this.$router.push({
  237. path: "/emergencyManagement/evacuation/newPerformEvacuation",
  238. query: {
  239. buildId: response.data[i].buildId,
  240. floorId:response.data[i].floorId,
  241. subId:response.data[i].subId,
  242. riskPlanId:response.data[i].riskPlanId,
  243. }
  244. })
  245. return
  246. }
  247. }
  248. //没有火焰预案并且没有查看过
  249. for(let i=0;i<response.data.length;i++){
  250. if(response.data[i].riskAttribute != '1'&&response.data[i].ifcheck != '1'){
  251. this.$router.push({
  252. path: "/emergencyManagement/evacuation/newPerformEvacuation",
  253. query: {
  254. buildId: response.data[i].buildId,
  255. floorId:response.data[i].floorId,
  256. subId:response.data[i].subId,
  257. riskPlanId:response.data[i].riskPlanId,
  258. }
  259. })
  260. return
  261. }
  262. }
  263. }else{
  264. this.$set(this,'textType',false);
  265. }
  266. })
  267. },
  268. }
  269. }
  270. </script>
  271. <style lang="scss" scoped>
  272. .app-main {
  273. /* 50= navbar 50 */
  274. /*min-height: calc(100vh - 50px);*/
  275. width: 100%;
  276. position: relative;
  277. overflow: hidden;
  278. display: flex;
  279. flex-direction: column;
  280. }
  281. .work-color-a{
  282. background: rgba(30,144,255,0.2);
  283. p{
  284. color:#0045AF;
  285. }
  286. }
  287. .work-color-b{
  288. background: rgba(255,0,0,0.2);
  289. p{
  290. color:#FF0000;
  291. }
  292. }
  293. .app-main-top-text-box-two{
  294. margin:10px 20px 0 10px;
  295. border-radius:10px;
  296. padding:0 0 0 20px;
  297. display: flex;
  298. p{
  299. line-height:60px;
  300. font-size:16px;
  301. margin:0;
  302. }
  303. p:nth-child(1){
  304. flex:1;
  305. }
  306. p:nth-child(2){
  307. width:100px;
  308. cursor: pointer;
  309. }
  310. p:nth-child(3){
  311. font-size:22px;
  312. margin-right:20px;
  313. cursor: pointer;
  314. }
  315. }
  316. .app-main-top-text-box{
  317. background: rgba(255,0,0,0.2);
  318. margin:10px 20px 0 10px;
  319. border-radius:10px;
  320. padding:0 0 0 20px;
  321. display: flex;
  322. p{
  323. line-height:60px;
  324. font-size:16px;
  325. margin:0;
  326. }
  327. p:nth-child(1){
  328. flex:1;
  329. color:#FF0000;
  330. }
  331. p:nth-child(2){
  332. width:100px;
  333. color:#0045AF;
  334. cursor: pointer;
  335. text-align: center;
  336. }
  337. p:nth-child(3){
  338. color:#0045AF;
  339. text-align: center;
  340. width:30px;
  341. font-weight:500;
  342. }
  343. p:nth-child(4){
  344. width:100px;
  345. color:#0045AF;
  346. cursor: pointer;
  347. text-align: center;
  348. }
  349. }
  350. .app-main-position-max-box{
  351. position: fixed;
  352. height:100%;
  353. width:100%;
  354. background: rgba(0,0,0,0.2);
  355. z-index: 100;
  356. .app-main-position-big-box{
  357. .app-main-position-box{
  358. position: absolute;
  359. top: 50%;
  360. left: 50%;
  361. background: #fff;
  362. width:500px;
  363. height:300px;
  364. margin-left:-250px;
  365. margin-top:-150px;
  366. border-radius:10px;
  367. box-shadow: 0 0 8px 2px rgba(0, 0, 0, 0.1);
  368. .app-main-position-box-bottom-button-box{
  369. display: flex;
  370. }
  371. }
  372. }
  373. }
  374. .fixed-header+.app-main {
  375. padding-top: 50px;
  376. }
  377. .hasTagsView {
  378. .app-main {
  379. /* 84 = navbar + tags-view = 50 + 34 */
  380. /*min-height: calc(100vh - 84px);*/
  381. }
  382. .fixed-header+.app-main {
  383. padding-top: 84px;
  384. }
  385. }
  386. </style>
  387. <style lang="scss">
  388. // fix css style bug in open el-dialog
  389. .el-popup-parent--hidden {
  390. .fixed-header {
  391. padding-right: 15px;
  392. }
  393. }
  394. </style>