cyy
2025-09-28 fb026e6052b4d843d327312db398cf791ac57ab9
pages/task/list.vue
@@ -33,7 +33,7 @@
         <uni-icons color="#ccc" type="info" size="128"></uni-icons>
         <view class="space">没有找到符合条件的任务</view>
      </view>
      <view class="position-add" @click="clickAddTask()" @touchstart='btnAddTouchStart' @touchmove='btnAddTouchMove'
      <view class="position-add" @click="clickAddTask"  @touchstart='btnAddTouchStart' @touchmove='btnAddTouchMove'
         :style="{transform:`translate(${btnAddInfo.x}px,${btnAddInfo.y}px) scale(1)`}">
         <uni-icons class="img" type="plus-filled" size="80" color="#1890FF"></uni-icons>
      </view>
@@ -45,6 +45,8 @@
      showToast,
      showModal,
      session,
      showError,
      showInfo
   } from "@/comm/utils.js"
   import TaskItemView from "./infos/task-item.vue"
   import {
@@ -68,6 +70,7 @@
      },
      data() {
         return {
            loading:false,
            ip: "",
            sceneId: "",
            list: [],
@@ -104,8 +107,10 @@
         this.ip = option.ip || ""
         this.sceneId = option.sceneId || ""
         this.isPageVisible = true
         this.loadData()
         this.$nextTick(()=>{
            this.loadData()
         })
      },
      onShow() {
         this.isPageVisible = true
@@ -159,7 +164,7 @@
            } catch (ex) {
               this.showError(ex)
               showError(ex)
            }
         },
         async loadTaskList() {
@@ -167,20 +172,26 @@
               const res = await tasks(this.ip)
               const list = res?.data || []
               this.list = list
               showToast(`装载了${list.length}任务`)
            } catch (ex) {
               this.showError(ex)
               showError(ex)
            }
         },
         async timerCheckTaskGroupStatus() {
            try {
               if (this.isPageVisible)
                  await this.checkTaskGroupStatus()
                  // setTimeout(this.timerCheckTaskGroupStatus, 1000);
            } catch (ex) {
               this.showError(ex)
               showToast(ex)
               // showError(ex).then((res)=>{
               //    setTimeout(this.timerCheckTaskGroupStatus, 1000);
               // })
            } finally {
               setTimeout(this.timerCheckTaskGroupStatus, 1000);
                  setTimeout(this.timerCheckTaskGroupStatus, 1000);
            }
         },
         async checkTaskGroupStatus() {
@@ -210,7 +221,7 @@
            } catch (ex) {
               this.taskStatus = {}
               this.showError(ex)
               showToast(ex)
            }
         },
         setTaskGroupStatus(cmdID) {
@@ -220,6 +231,7 @@
         },
         clickAddTask() {
            const _this = this
            uni.navigateTo({
               url: `/pages/task/add?ip=${this.ip}&title=新增任务`,
               events: {
@@ -305,7 +317,7 @@
               this.setTaskGroupStatus(cmdID)
            } catch (ex) {
               this.showError(ex)
               showError(ex)
            }
         },
@@ -314,7 +326,7 @@
               await addTaskGroupCmd(this.ip, item.taskGroupID, this.taskStatus.taskGroupCmdID, 2)
               showToast("终止任务成功")
            } catch (ex) {
               this.showError(ex)
               showError(ex)
            }
         },
@@ -345,7 +357,7 @@
                  showToast("未找到未开始或正在执行的子任务")
               }
            } catch (ex) {
               this.showError(ex)
               showError(ex)
            }
         },
@@ -379,19 +391,12 @@
               this.list = [...list]
            } catch (ex) {
               this.showError(ex)
               showError(ex)
            }
         },
         showError(ex) {
            let exStr = JSON.stringify(ex)
            if (exStr == "{}")
               exStr = ex
            let tip = typeof ex.msg == "string" ? ex.msg : typeof ex.errMsg == "string" ? ex.errMsg : exStr
            showModal(tip, "错误", false, "确定")
         },
      }
   }
</script>