topWarn.vue 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192
  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. if(data.data[0]){
  110. this.warnList=this.warnList.concat(data.data)
  111. }
  112. this.gasWarnFun();
  113. },
  114. //气瓶预警
  115. async gasWarnFun(){
  116. const {data} = await airbottleBluetoothGetBeaconNotice();
  117. this.warnList=this.warnList.concat(data.data)
  118. if(this.warnList[0]){
  119. this.$set(this,'text',this.warnList.length>1?'有多个实验室发生预案':'有实验室发生预案');
  120. this.$set(this,'buildId',this.warnList[0].buildId);
  121. this.$set(this,'floorId',this.warnList[0].floorId);
  122. this.$set(this,'subId',this.warnList[0].subId);
  123. if(this.warnList[0].riskAttribute == 1){
  124. this.$set(this,'closePlan',true);
  125. this.$set(this,'groupId',this.warnList[0].groupId);
  126. }
  127. this.$set(this,'pageType',true);
  128. //没有火焰预案并且没有查看过
  129. for(let i=0;i<this.warnList.length;i++){
  130. if(this.warnList[i].riskAttribute != '1'&&this.warnList[i].ifCheck != '1'){
  131. let obj = {
  132. buildId: this.warnList[i].buildId,
  133. floorId:this.warnList[i].floorId,
  134. subId:this.warnList[i].subId,
  135. groupId:this.warnList[i].groupId,
  136. }
  137. uni.navigateTo({
  138. url:'/pages_manage/emergencyEvacuationBig?item='+encodeURIComponent(JSON.stringify(obj))
  139. });
  140. return
  141. }
  142. }
  143. }else{
  144. this.$set(this,'pageType',false);
  145. }
  146. },
  147. timeFuncontion(){
  148. let self = this;
  149. var t1 = setInterval(refreshCount, 300);
  150. function refreshCount() {
  151. let txt = self.text
  152. let start = txt.substring(0, 1);//取该字符串的第一个字符
  153. let end = txt.substring(1);//取该字符串的从1之后的所有字符
  154. let newText = end + start;//拼接新的字符串
  155. self.$set(self,'text',newText)
  156. }
  157. }
  158. }
  159. }
  160. </script>
  161. <style lang="stylus" scoped>
  162. .top-warn{
  163. height:80rpx;
  164. line-height:80rpx;
  165. background rgba(2550,0,0,0.2)
  166. margin:20rpx 0;
  167. display flex;
  168. overflow hidden
  169. view:nth-child(1){
  170. padding-left:20rpx;
  171. color:#FF0000;
  172. flex:1;
  173. view{
  174. padding-left:20rpx;
  175. white-space:nowrap;
  176. }
  177. }
  178. view:nth-child(2){
  179. width:140rpx;
  180. color:#0183FA;
  181. text-align center;
  182. }
  183. }
  184. </style>