topWarn.vue 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190
  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 } 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. }
  25. },
  26. created() {
  27. },
  28. mounted(){
  29. this.getWarn();
  30. // getApp().watch(this.getWarn,'warnData');
  31. getApp().watch(this.lineDataFunction,'lineData');
  32. // this.timeFuncontion();
  33. },
  34. methods: {
  35. //应急变更
  36. lineDataFunction(val){
  37. this.getWarn();
  38. },
  39. buttonClick(){
  40. let self = this;
  41. let list = [];
  42. if(self.closePlan){
  43. list = ['查看', '结束预案'];
  44. }else{
  45. self.goPage();
  46. }
  47. uni.showActionSheet({
  48. itemList: list,
  49. success: function (res) {
  50. if(res.tapIndex == 0){
  51. self.goPage();
  52. }else if(res.tapIndex == 1){
  53. self.offEvacuationClick();
  54. }
  55. },
  56. fail: function (res) {
  57. console.log(res.errMsg);
  58. }
  59. });
  60. },
  61. //结束预案
  62. offEvacuationClick(){
  63. let self = this;
  64. uni.showModal({
  65. content: '确认结束预案?',
  66. cancelColor:"#999",
  67. confirmColor:"#0183FA",
  68. success: function (res) {
  69. if (res.confirm) {
  70. self.closeRiskPlan();
  71. } else if (res.cancel) {
  72. }
  73. }
  74. });
  75. },
  76. async closeRiskPlan(){
  77. const {data} = await closeRiskPlan({id:this.groupId});
  78. if(data.code == 200){
  79. uni.showToast({
  80. title: '操作成功',
  81. icon:"none",
  82. mask:true,
  83. duration: 2000
  84. });
  85. this.pageType = false;
  86. }
  87. },
  88. //页面跳转
  89. goPage(){
  90. let obj = {
  91. buildId: this.buildId,
  92. floorId:this.floorId,
  93. subId:this.subId,
  94. groupId:this.groupId,
  95. }
  96. uni.navigateTo({
  97. url:'/pages_manage/emergencyEvacuationBig?item='+encodeURIComponent(JSON.stringify(obj))
  98. });
  99. },
  100. //获取报警信息
  101. async getWarn(){
  102. let self = this;
  103. const {data} = await selectTriggerInfo();
  104. if(data.data[0]){
  105. this.$set(this,'text',data.data.length>1?'有多个实验室发生预案':'有实验室发生预案');
  106. this.$set(this,'buildId',data.data[0].buildId);
  107. this.$set(this,'floorId',data.data[0].floorId);
  108. this.$set(this,'subId',data.data[0].subId);
  109. if(data.data[0].riskAttribute == 1){
  110. this.$set(this,'closePlan',true);
  111. this.$set(this,'groupId',data.data[0].groupId);
  112. }
  113. this.$set(this,'pageType',true);
  114. // for(let i=0;i<data.data.length;i++){
  115. // if(data.data[i].riskAttribute == '1'&&data.data[i].ifCheck != '1'){
  116. // let obj = {
  117. // buildId: data.data[i].buildId,
  118. // floorId:data.data[i].floorId,
  119. // subId:data.data[i].subId,
  120. // riskPlanId:data.data[i].riskPlanId,
  121. // }
  122. // uni.navigateTo({
  123. // url:'/pages/emergencyEvacuationBig?item='+encodeURIComponent(JSON.stringify(obj))
  124. // });
  125. // return
  126. // }
  127. // }
  128. //没有火焰预案并且没有查看过
  129. for(let i=0;i<data.data.length;i++){
  130. if(data.data[i].riskAttribute != '1'&&data.data[i].ifCheck != '1'){
  131. let obj = {
  132. buildId: data.data[i].buildId,
  133. floorId:data.data[i].floorId,
  134. subId:data.data[i].subId,
  135. groupId:data.data[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>