| | |
| | | <view class="list-content" v-if="list.length > 0"> |
| | | <view class="list-header" v-if="fixedList.length > 0">固定任务</view> |
| | | <uni-swipe-action class="list"> |
| | | <uni-swipe-action-item :class="index== 0 ?'':'list-item'" v-for="(item,index) in fixedList" :key="index" |
| | | <uni-swipe-action-item class="list-item" v-for="(item,index) in fixedList" :key="index" |
| | | :auto-close="true" :disabled="taskStatus.taskGroupID == item.taskGroupID"> |
| | | <TaskItemView :taskData="item" :taskStatus="taskStatus" @click-item="clickEditTask" |
| | | @click-play="clickPlayTask" @click-pause="clickPauseTask" @click-stop="clickStopTask" |
| | | @click-skip="clickSkipTask" @click-repeat="clickRepeatTask"> |
| | | <TaskItemView :taskData="item" :taskStatus="taskStatus" :showTaskRunning="showTaskRunning" |
| | | @click-btn="clickTaskBtn" @click-item="clickEditTask" @click-play="clickPlayTask" |
| | | @click-pause="clickPauseTask" @click-stop="clickStopTask" @click-skip="clickSkipTask" |
| | | @click-repeat="clickRepeatTask"> |
| | | </TaskItemView> |
| | | <template v-slot:right> |
| | | <view class="btn-del" @click="clickDelSetTask(item)">删除</view> |
| | |
| | | </uni-swipe-action> |
| | | <view class="list-header" v-if="tempList.length > 0">临时任务</view> |
| | | <uni-swipe-action class="list"> |
| | | <uni-swipe-action-item :class="index== 0 ?'':'list-item'" v-for="(item,index) in tempList" :key="index" |
| | | <uni-swipe-action-item class="list-item" v-for="(item,index) in tempList" :key="index" |
| | | :auto-close="true" :disabled="taskStatus.taskGroupID == item.taskGroupID"> |
| | | <TaskItemView :taskData="item" :taskStatus="taskStatus" @click-item="clickEditTask" |
| | | @click-play="clickPlayTask" @click-pause="clickPauseTask" @click-stop="clickStopTask" |
| | | @click-skip="clickSkipTask" @click-repeat="clickRepeatTask"> |
| | | </TaskItemView> |
| | | <TaskItemView :taskData="item" :taskStatus="taskStatus" :showTaskRunning="showTaskRunning" |
| | | @click-btn="clickTaskBtn" @click-item="clickEditTask" @click-play="clickPlayTask" |
| | | @click-pause="clickPauseTask" @click-stop="clickStopTask" @click-skip="clickSkipTask" |
| | | @click-repeat="clickRepeatTask"></TaskItemView> |
| | | <template v-slot:right> |
| | | <view class="btn-del" @click="clickDelSetTask(item)">删除</view> |
| | | </template> |
| | |
| | | import { |
| | | v4 as uuidv4 |
| | | } from 'uuid'; |
| | | import { |
| | | filter |
| | | } from "rxjs"; |
| | | export default { |
| | | name: "PagesTasklist", |
| | | components: { |
| | |
| | | x: 0, |
| | | y: 0 |
| | | }, |
| | | showTaskRunning: false, |
| | | } |
| | | }, |
| | | computed: { |
| | |
| | | onLoad(option) { |
| | | this.ip = option.ip || "" |
| | | this.sceneId = option.sceneId || "" |
| | | this.isPageVisible = true |
| | | |
| | | this.loadData() |
| | | }, |
| | | onShow() { |
| | | this.isPageVisible = true |
| | | |
| | | |
| | | }, |
| | | onHide() { |
| | | this.isPageVisible = false |
| | | |
| | | }, |
| | | onUnload() { |
| | | this.isPageVisible = false |
| | | }, |
| | | methods: { |
| | | setData(obj) { |
| | |
| | | } |
| | | this.btnAddInfo = btninfo |
| | | } |
| | | const res = await tasks(this.ip) |
| | | const list = res?.data || [] |
| | | this.list = list |
| | | if (this.list.length > 0) { |
| | | this.timerCheckTaskGroupStatus() |
| | | } |
| | | this.loadTaskList() |
| | | this.timerCheckTaskGroupStatus() |
| | | |
| | | } catch (ex) { |
| | | |
| | | this.showError(ex) |
| | | } |
| | | }, |
| | | async loadTaskList() { |
| | | try { |
| | | const res = await tasks(this.ip) |
| | | const list = res?.data || [] |
| | | this.list = list |
| | | } catch (ex) { |
| | | |
| | | this.showError(ex) |
| | | } |
| | | }, |
| | | |
| | | async timerCheckTaskGroupStatus() { |
| | | if (this.timerCheckStatusId) { |
| | | return |
| | | try { |
| | | if (this.isPageVisible) |
| | | await this.checkTaskGroupStatus() |
| | | } catch (ex) { |
| | | this.showError(ex) |
| | | } finally { |
| | | setTimeout(this.timerCheckTaskGroupStatus, 1000); |
| | | } |
| | | if (this.list.length == 0) { |
| | | return |
| | | } |
| | | await this.checkTaskGroupStatus() |
| | | this.timerCheckStatusId = setTimeout(() => { |
| | | this.timerCheckStatusId = 0 |
| | | this.timerCheckTaskGroupStatus() |
| | | }, 1000) |
| | | }, |
| | | async checkTaskGroupStatus() { |
| | | try { |
| | | const key = `task_cmd_id_${this.ip.replace(".","_")}` |
| | | const cmdID = session.getValue(key) |
| | | if (cmdID) { |
| | | const info = await taskGroupStatus(this.ip) || {} |
| | | if (info.taskGroupCmdID == cmdID) { |
| | | |
| | | const list = info.taskStatusList || [] |
| | | const info = await taskGroupStatus(this.ip) || {} |
| | | if (info.taskGroupID) { |
| | | if (this.list.length == 0) { |
| | | await this.loadTaskList() |
| | | } |
| | | const curIndex = this.list.findIndex((a) => a.taskGroupID == info.taskGroupID) |
| | | if (curIndex > -1) { |
| | | let list = info.taskStatusList || [] |
| | | list = list.filter((a) => a.cycleNumber == info.curCycleNumber) |
| | | for (let i in list) { |
| | | if (list[i].status != 1 && list[i].status != 0) { |
| | | this.taskStatus = {} |
| | | if (list[i].status == 1 || list[i].status == 0) { |
| | | this.taskStatus = info |
| | | return |
| | | } |
| | | } |
| | | this.taskStatus = info |
| | | this.taskStatus = {} |
| | | return |
| | | } |
| | | |
| | | } |
| | | |
| | | this.taskStatus = {} |
| | | |
| | | } catch (ex) { |
| | |
| | | events: { |
| | | // 为指定事件添加一个监听器,获取被打开页面传送到当前页面的数据 |
| | | add_task: function(data) { |
| | | _this.loadData() |
| | | _this.loadTaskList() |
| | | }, |
| | | } |
| | | }) |
| | |
| | | |
| | | session.setValue('task_btn_add', this.btnAddInfo) |
| | | }, |
| | | |
| | | |
| | | clickTaskBtn(item) { |
| | | this.showTaskRunning = !this.showTaskRunning |
| | | }, |
| | | clickEditTask(item) { |
| | | const _this = this |
| | | if (this.taskStatus.taskGroupID == item.taskGroupID) { |
| | |
| | | async clickStopTask(item) { |
| | | try { |
| | | await addTaskGroupCmd(this.ip, item.taskGroupID, this.taskStatus.taskGroupCmdID, 2) |
| | | showToast("终止任务成功") |
| | | } catch (ex) { |
| | | this.showError(ex) |
| | | } |
| | |
| | | try { |
| | | |
| | | |
| | | const taskStatusList = this.taskStatus.taskStatusList || [] |
| | | let taskStatusList = this.taskStatus.taskStatusList || [] |
| | | taskStatusList = taskStatusList.filter((a) => a.cycleNumber == this.taskStatus.curCycleNumber) |
| | | let curIdx = taskStatusList.findIndex((a) => a.status == 1) |
| | | if (curIdx < 0) |
| | | curIdx = taskStatusList.findIndex((a) => a.status == 0) |
| | |
| | | }) |
| | | await cancelTask(this.ip, |
| | | item.taskGroupID, |
| | | this.taskStatus.taskGroupCmdID, |
| | | this.taskStatus.taskGroupCmdID, |
| | | taskList |
| | | ) |
| | | |
| | |
| | | |
| | | async clickPauseTask(item) {}, |
| | | clickDelSetTask(item) { |
| | | showModal("确认删除任务设置", "警告").then((res) => { |
| | | showModal("确认删除任务设置", "警告", true, "确定", "取消").then((res) => { |
| | | if (res) { |
| | | this.deleteTask(item) |
| | | |
| | |
| | | const index = list.findIndex((a) => |
| | | a.taskGroupID == item.taskGroupID |
| | | ) |
| | | console.log(index, item, list) |
| | | showToast("删除任务成功") |
| | | if (index < 0) |
| | | return |
| | | list.splice(index, 1) |
| | |
| | | let exStr = JSON.stringify(ex) |
| | | if (exStr == "{}") |
| | | exStr = ex |
| | | let tip = typeof ex.msg == "string" ? ex.msg : exStr |
| | | showModal(tip, "错误", false) |
| | | let tip = typeof ex.msg == "string" ? ex.msg : typeof ex.errMsg == "string" ? ex.errMsg : exStr |
| | | showModal(tip, "错误", false, "确定") |
| | | }, |
| | | } |
| | | } |
| | |
| | | .list-content { |
| | | display: flex; |
| | | width: 100%; |
| | | padding: 0 10px; |
| | | padding: 10rpx 10px; |
| | | flex: 1; |
| | | flex-direction: column; |
| | | overflow-y: auto; |
| | | overflow-x: hidden; |
| | | |
| | | .list-header { |
| | | margin: 10px; |
| | | margin: 10rpx 10px; |
| | | // border-bottom: 1px solid #ddd; |
| | | } |
| | | |
| | | .btn-del { |
| | | // margin: 10rpx; |
| | | display: flex; |
| | | padding: 0 10rpx; |
| | | background-color: #FF4D4F; |
| | | font-weight: 700; |
| | | color: #fff; |
| | | justify-content: center; |
| | | align-items: center; |
| | | } |
| | | |
| | | .list { |
| | |
| | | |
| | | .list-item { |
| | | |
| | | border-top: 1px solid #ddd; |
| | | border-bottom: 1px solid #ddd; |
| | | } |
| | | |
| | | .list-item:first-child { |
| | | border-top-right-radius: 10px; |
| | | /* 右下角 */ |
| | | } |
| | | |
| | | .list-item:last-child { |
| | | border-bottom: 0; |
| | | border-bottom-right-radius: 10px; |
| | | /* 右下角 */ |
| | | } |
| | | |
| | | } |
| | | |
| | | .btn-del { |
| | | margin: 10rpx; |
| | | display: flex; |
| | | padding: 0 10rpx; |
| | | background-color: #FF4D4F; |
| | | font-weight: 700; |
| | | color: #fff; |
| | | justify-content: center; |
| | | align-items: center; |
| | | } |
| | | |
| | | |
| | | } |
| | | |