topWarn.vue 4.5 KB

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