topWarn.vue 4.5 KB

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