topWarn.vue 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195
  1. <!-- 顶部警告 -->
  2. <template>
  3. <view class="top-warn" v-if="pageType">
  4. <view>{{text}}</view>
  5. <!-- <view @click="buttonClick" v-if="whetherRoute">查看</view> -->
  6. </view>
  7. </template>
  8. <script>
  9. import { selectTriggerInfo,evacuate,closeRiskPlan,airbottleBluetoothGetBeaconNotice} from '@/api/index.js'
  10. export default {
  11. data() {
  12. return {
  13. pageType:false,
  14. text:"",
  15. buildId:"",
  16. floorId:"",
  17. subId:"",
  18. closePlan:false,// true 火焰报警,false 没有火焰报警
  19. whetherRoute:true,
  20. subjectId:"",
  21. buildingId:"",
  22. subjectName:"",
  23. groupId:"",
  24. warnList:[],
  25. }
  26. },
  27. created() {
  28. },
  29. mounted(){
  30. //this.getWarn();
  31. // getApp().watch(this.getWarn,'warnData');
  32. getApp().watch(this.lineDataFunction,'lineData');
  33. // this.timeFuncontion();
  34. },
  35. methods: {
  36. //应急变更
  37. lineDataFunction(val){
  38. this.getWarn();
  39. },
  40. buttonClick(){
  41. let self = this;
  42. let list = [];
  43. if(self.closePlan){
  44. list = ['查看', '结束预案'];
  45. }else{
  46. self.goPage();
  47. }
  48. uni.showActionSheet({
  49. itemList: list,
  50. success: function (res) {
  51. if(res.tapIndex == 0){
  52. self.goPage();
  53. }else if(res.tapIndex == 1){
  54. self.offEvacuationClick();
  55. }
  56. },
  57. fail: function (res) {
  58. console.log(res.errMsg);
  59. }
  60. });
  61. },
  62. //结束预案
  63. offEvacuationClick(){
  64. let self = this;
  65. uni.showModal({
  66. content: '确认结束预案?',
  67. cancelColor:"#999",
  68. confirmColor:"#0183FA",
  69. success: function (res) {
  70. if (res.confirm) {
  71. self.closeRiskPlan();
  72. } else if (res.cancel) {
  73. }
  74. }
  75. });
  76. },
  77. async closeRiskPlan(){
  78. const {data} = await closeRiskPlan({id:this.groupId});
  79. if(data.code == 200){
  80. uni.showToast({
  81. title: '操作成功',
  82. icon:"none",
  83. mask:true,
  84. duration: 2000
  85. });
  86. this.pageType = false;
  87. }
  88. },
  89. //页面跳转
  90. goPage(){
  91. let obj = {
  92. buildId: this.buildId,
  93. floorId:this.floorId,
  94. subId:this.subId,
  95. groupId:this.groupId,
  96. }
  97. uni.navigateTo({
  98. url:'/pages_manage/emergencyEvacuationBig?item='+encodeURIComponent(JSON.stringify(obj))
  99. });
  100. },
  101. //获取报警信息
  102. async getWarn(){
  103. let self = this;
  104. this.planWarnFun();
  105. },
  106. //预案预警
  107. async planWarnFun(){
  108. const {data} = await selectTriggerInfo();
  109. let list = [];
  110. if(data.data[0]){
  111. list = data.data
  112. }
  113. this.gasWarnFun(list);
  114. },
  115. //气瓶预警
  116. async gasWarnFun(list){
  117. const {data} = await airbottleBluetoothGetBeaconNotice();
  118. let newList = list.concat(data.data)
  119. this.$set(this,'warnList',newList);
  120. // this.warnList=this.warnList.concat(data.data)
  121. if(this.warnList[0]){
  122. this.$set(this,'text',this.warnList.length>1?'有多个实验室发生预案':'有实验室发生预案');
  123. this.$set(this,'buildId',this.warnList[0].buildId);
  124. this.$set(this,'floorId',this.warnList[0].floorId);
  125. this.$set(this,'subId',this.warnList[0].subId);
  126. if(this.warnList[0].riskAttribute == 1){
  127. this.$set(this,'closePlan',true);
  128. this.$set(this,'groupId',this.warnList[0].groupId);
  129. }
  130. this.$set(this,'pageType',true);
  131. //没有火焰预案并且没有查看过
  132. // for(let i=0;i<this.warnList.length;i++){
  133. // if(this.warnList[i].riskAttribute != '1'&&this.warnList[i].ifCheck != '1'){
  134. // let obj = {
  135. // buildId: this.warnList[i].buildId,
  136. // floorId:this.warnList[i].floorId,
  137. // subId:this.warnList[i].subId,
  138. // groupId:this.warnList[i].groupId,
  139. // }
  140. // uni.navigateTo({
  141. // url:'/pages_manage/emergencyEvacuationBig?item='+encodeURIComponent(JSON.stringify(obj))
  142. // });
  143. // return
  144. // }
  145. // }
  146. }else{
  147. this.$set(this,'pageType',false);
  148. }
  149. },
  150. timeFuncontion(){
  151. let self = this;
  152. var t1 = setInterval(refreshCount, 300);
  153. function refreshCount() {
  154. let txt = self.text
  155. let start = txt.substring(0, 1);//取该字符串的第一个字符
  156. let end = txt.substring(1);//取该字符串的从1之后的所有字符
  157. let newText = end + start;//拼接新的字符串
  158. self.$set(self,'text',newText)
  159. }
  160. }
  161. }
  162. }
  163. </script>
  164. <style lang="stylus" scoped>
  165. .top-warn{
  166. height:80rpx;
  167. line-height:80rpx;
  168. background rgba(2550,0,0,0.2)
  169. margin:20rpx 0;
  170. display flex;
  171. overflow hidden
  172. view:nth-child(1){
  173. padding-left:20rpx;
  174. color:#FF0000;
  175. flex:1;
  176. view{
  177. padding-left:20rpx;
  178. white-space:nowrap;
  179. }
  180. }
  181. view:nth-child(2){
  182. width:140rpx;
  183. color:#0183FA;
  184. text-align center;
  185. }
  186. }
  187. </style>