| | |
| | | <template> |
| | | <view class="pages-task-list"> |
| | | <view class="list-content" v-if="list.length > 0"> |
| | | <view class="list-header" v-if="fixedList.length > 0">固定任务</view> |
| | | <view class="list-header" v-if="fixedList.length > 0">{{translate("fixed_task")}}</view> |
| | | <uni-swipe-action class="list"> |
| | | <uni-swipe-action-item class="list-item" v-for="(item,index) in fixedList" :key="index" |
| | | :auto-close="true" :disabled="taskStatus.taskGroupID == item.taskGroupID"> |
| | |
| | | @click-repeat="clickRepeatTask"> |
| | | </TaskItemView> |
| | | <template v-slot:right> |
| | | <view class="btn-del" @click="clickDelSetTask(item)">删除</view> |
| | | <view class="btn-del" @click="clickDelSetTask(item)">{{translate("delete")}}</view> |
| | | </template> |
| | | </uni-swipe-action-item> |
| | | </uni-swipe-action> |
| | | <view class="list-header" v-if="tempList.length > 0">临时任务</view> |
| | | <view class="list-header" v-if="tempList.length > 0">{{translate("temporary_task")}}</view> |
| | | <uni-swipe-action class="list"> |
| | | <uni-swipe-action-item class="list-item" v-for="(item,index) in tempList" :key="index" |
| | | :auto-close="true" :disabled="taskStatus.taskGroupID == item.taskGroupID"> |
| | |
| | | @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> |
| | | <view class="btn-del" @click="clickDelSetTask(item)">{{translate("delete")}}</view> |
| | | </template> |
| | | </uni-swipe-action-item> |
| | | </uni-swipe-action> |
| | | </view> |
| | | <view class="list-no-content" v-else> |
| | | <uni-icons color="#ccc" type="info" size="128"></uni-icons> |
| | | <view class="space">没有找到符合条件的任务</view> |
| | | <view class="space">{{translate("not_task_found")}}</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> |
| | |
| | | import { |
| | | v4 as uuidv4 |
| | | } from 'uuid'; |
| | | import { |
| | | filter |
| | | } from "rxjs"; |
| | | |
| | | export default { |
| | | name: "PagesTasklist", |
| | | name: "PagesTaskList", |
| | | components: { |
| | | TaskItemView |
| | | }, |
| | | data() { |
| | | return { |
| | | loading:false, |
| | | loading: false, |
| | | ip: "", |
| | | sceneId: "", |
| | | list: [], |
| | |
| | | [] |
| | | ], // 每个项目的偏移量 |
| | | options: [{ |
| | | text: '删除', |
| | | text: this.translate('delete'), |
| | | style: { |
| | | backgroundColor: '#F56C6C' |
| | | } |
| | |
| | | this.ip = option.ip || "" |
| | | this.sceneId = option.sceneId || "" |
| | | this.isPageVisible = true |
| | | this.$nextTick(()=>{ |
| | | this.$nextTick(() => { |
| | | this.loadData() |
| | | }) |
| | | |
| | | |
| | | }, |
| | | onShow() { |
| | | this.isPageVisible = true |
| | |
| | | |
| | | } catch (ex) { |
| | | |
| | | showError(ex) |
| | | showError(ex, this.translate('error')) |
| | | } |
| | | }, |
| | | async loadTaskList() { |
| | | try { |
| | | uni.showLoading({ |
| | | title: this.translate("loading") |
| | | }) |
| | | const res = await tasks(this.ip) |
| | | const list = res?.data || [] |
| | | this.list = list |
| | | showToast(`装载了${list.length}任务`) |
| | | } catch (ex) { |
| | | |
| | | showError(ex) |
| | | showError(ex, this.translate('error')) |
| | | } finally { |
| | | uni.hideLoading() |
| | | } |
| | | |
| | | |
| | | }, |
| | | |
| | | async timerCheckTaskGroupStatus() { |
| | | try { |
| | | if (this.isPageVisible) |
| | | await this.checkTaskGroupStatus() |
| | | setTimeout(this.timerCheckTaskGroupStatus, 1000); |
| | | // setTimeout(this.timerCheckTaskGroupStatus, 1000); |
| | | } catch (ex) { |
| | | showError(ex).then((res)=>{ |
| | | setTimeout(this.timerCheckTaskGroupStatus, 1000); |
| | | }) |
| | | showToast(ex) |
| | | // showError(ex,this.translate('error')).then((res)=>{ |
| | | // setTimeout(this.timerCheckTaskGroupStatus, 1000); |
| | | // }) |
| | | } finally { |
| | | |
| | | setTimeout(this.timerCheckTaskGroupStatus, 1000); |
| | | } |
| | | }, |
| | | async checkTaskGroupStatus() { |
| | |
| | | } catch (ex) { |
| | | |
| | | this.taskStatus = {} |
| | | showError(ex) |
| | | showToast(ex) |
| | | } |
| | | }, |
| | | setTaskGroupStatus(cmdID) { |
| | |
| | | }, |
| | | clickAddTask() { |
| | | const _this = this |
| | | |
| | | |
| | | uni.navigateTo({ |
| | | url: `/pages/task/add?ip=${this.ip}&title=新增任务`, |
| | | url: `/pages/task/add?ip=${this.ip}&title=${this.translate("new_task")}`, |
| | | events: { |
| | | // 为指定事件添加一个监听器,获取被打开页面传送到当前页面的数据 |
| | | add_task: function(data) { |
| | |
| | | return |
| | | } |
| | | uni.navigateTo({ |
| | | url: `/pages/task/update?ip=${this.ip}&title=更新任务&task=${JSON.stringify(item)}`, |
| | | url: `/pages/task/update?ip=${this.ip}&title=${this.translate("update_task")}&task=${JSON.stringify(item)}`, |
| | | events: { |
| | | // 为指定事件添加一个监听器,获取被打开页面传送到当前页面的数据 |
| | | update_task: function(data) { |
| | |
| | | this.setTaskGroupStatus(cmdID) |
| | | |
| | | } catch (ex) { |
| | | showError(ex) |
| | | showError(ex, this.translate('error')) |
| | | } |
| | | }, |
| | | |
| | | async clickStopTask(item) { |
| | | try { |
| | | await addTaskGroupCmd(this.ip, item.taskGroupID, this.taskStatus.taskGroupCmdID, 2) |
| | | showToast("终止任务成功") |
| | | showToast(this.translate("task_terminated_success")) |
| | | } catch (ex) { |
| | | showError(ex) |
| | | showError(ex, this.translate('error')) |
| | | } |
| | | }, |
| | | |
| | |
| | | this.taskStatus.taskGroupCmdID, |
| | | taskList |
| | | ) |
| | | |
| | | showToast("跳过子任务成功") |
| | | showToast(this.translate("skip_sub_task_success")) |
| | | |
| | | } else { |
| | | showToast("未找到未开始或正在执行的子任务") |
| | | showToast(this.translate("no_sub_task_found_not_started_or_executing")) |
| | | } |
| | | } catch (ex) { |
| | | showError(ex) |
| | | showError(ex, this.translate('error')) |
| | | } |
| | | }, |
| | | |
| | |
| | | |
| | | async clickPauseTask(item) {}, |
| | | clickDelSetTask(item) { |
| | | showModal("确认删除任务设置", "警告", true, "确定", "取消").then((res) => { |
| | | if (res) { |
| | | this.deleteTask(item) |
| | | showModal({ |
| | | title: this.translate('ask_confirm_delete'), |
| | | content: this.translate('history_task_will_be_retained'), |
| | | confirmText: this.translate('delete'), |
| | | cancelText: this.translate('cancel'), |
| | | }) |
| | | .then((res) => { |
| | | if (res) { |
| | | this.deleteTask(item) |
| | | |
| | | } |
| | | }) |
| | | } |
| | | }) |
| | | }, |
| | | async deleteTask(item) { |
| | | try { |
| | |
| | | const index = list.findIndex((a) => |
| | | a.taskGroupID == item.taskGroupID |
| | | ) |
| | | showToast("删除任务成功") |
| | | showToast(this.translate("delete_success")) |
| | | if (index < 0) |
| | | return |
| | | list.splice(index, 1) |
| | | this.list = [...list] |
| | | |
| | | } catch (ex) { |
| | | showError(ex) |
| | | showError(ex, this.translate('error')) |
| | | } |
| | | |
| | | }, |
| | | |
| | | |
| | | translate(t) { |
| | | if (typeof this.$t == "function") return this.$t(`page.${t}`) |
| | | else return t; |
| | | }, |
| | | } |
| | | } |
| | | </script> |