topWarn.vue 4.8 KB

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