guoshilong
2022-10-14 d8e0af2ce345f3b40581ad05c596f965ae729c01
pages/taskinfo/list.vue
@@ -10,7 +10,7 @@
         <scroll-view scroll-y :style="{ height: useHeight, width: '100%' }" @scrolltolower="scrolltolower">
            <view class="onveMain">
               <view class="once" v-for="(item, index) in taskinfoList" :key="index">
                  <view class="onve-left">
                  <view class="onve-left" @click="goToDetail(item.id)">
                     <!-- <view class="o-l-img">
                        <image src="" mode=""></image>
                     </view> -->
@@ -29,9 +29,9 @@
                     </view>
                  </view>
                  <view class="onve-right">
                     <u-button class='greens' size="mini" v-if="current == 0">开始任务</u-button>
                     <u-button class='greens' size="mini" v-if="current == 1">完成任务</u-button>
                     <u-button class='o-r-down' plain type="error" size="mini" v-if="current == 1">事件上报
                     <u-button class='greens' size="mini" v-if="current == 0" @click="startTask(item)">开始任务</u-button>
                     <u-button class='greens' size="mini" v-if="current == 1" @click="finishTask(item)">完成任务</u-button>
                     <u-button class='o-r-down' plain type="error" size="mini" v-if="current == 1" @click="goToEventsReported(item.id)">事件上报
                     </u-button>
                  </view>
               </view>
@@ -46,8 +46,8 @@
<script>
   import {
      getList
   } from "@/api/taskinfo/list.js";
      getList,update
   } from "@/api/taskinfo/taskinfo";
   export default {
      data() {
         return {
@@ -74,6 +74,9 @@
            },
            taskinfoList: null
         }
      },
      onShow() {
         this.getList()
      },
      created() {
         this.getList()
@@ -103,6 +106,56 @@
               this.page.total = data.total;
               this.taskinfoList = this.taskinfoList.concat(data.records)
            })
         },
         // 跳转详情页
         goToDetail(id) {
            uni.navigateTo({
               url: '/pages/taskinfo/detail?id=' + id
            })
         },
         //任务开始事件
         startTask(item){
            uni.showModal({
               title:"提示",
               content:"是否开始任务?",
               success:(res)=> {
                  if(res.confirm){
                     item.state = '1'
                     item.routeRange =  '\'' + item.routeRange + '\''
                     update(item).then(res=>{
                        if(res.code == 200){
                           this.page.currentPage = 1
                           this.getList()
                        }
                     })
                  }
               }
            })
         },
         //任务结束事件
         finishTask(item){
            uni.showModal({
               title:"提示",
               content:"是否结束任务?",
               success:(res)=> {
                  if(res.confirm){
                     item.state = '2'
                     item.routeRange =  '\'' + item.routeRange + '\''
                     update(item).then(res=>{
                        if(res.code == 200){
                           this.page.currentPage = 1
                           this.getList()
                        }
                     })
                  }
               }
            })
         },
         //事件上报
         goToEventsReported(id){
            uni.navigateTo({
               url:"/pages/eventgm/eventsReported?id="+id
            })
         }
      }
   }