From 2af5f043b60c1f7ac38ecccc8f5bf44743134325 Mon Sep 17 00:00:00 2001
From: cuiqian2004 <cuiqian2004@163.com>
Date: 星期五, 12 十二月 2025 18:08:00 +0800
Subject: [PATCH] test

---
 pages/task/list.vue |   93 +++++++++++++++++++++++++++-------------------
 1 files changed, 54 insertions(+), 39 deletions(-)

diff --git a/pages/task/list.vue b/pages/task/list.vue
index afa7af0..561dba3 100644
--- a/pages/task/list.vue
+++ b/pages/task/list.vue
@@ -1,7 +1,7 @@
 <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">
@@ -11,11 +11,11 @@
 						@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">
@@ -24,16 +24,16 @@
 						@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>
@@ -45,6 +45,8 @@
 		showToast,
 		showModal,
 		session,
+		showError,
+		showInfo
 	} from "@/comm/utils.js"
 	import TaskItemView from "./infos/task-item.vue"
 	import {
@@ -58,16 +60,15 @@
 	import {
 		v4 as uuidv4
 	} from 'uuid';
-	import {
-		filter
-	} from "rxjs";
+
 	export default {
-		name: "PagesTasklist",
+		name: "PagesTaskList",
 		components: {
 			TaskItemView
 		},
 		data() {
 			return {
+				loading: false,
 				ip: "",
 				sceneId: "",
 				list: [],
@@ -77,7 +78,7 @@
 					[]
 				], // 姣忎釜椤圭洰鐨勫亸绉婚噺
 				options: [{
-					text: '鍒犻櫎',
+					text: this.translate('delete'),
 					style: {
 						backgroundColor: '#F56C6C'
 					}
@@ -104,8 +105,10 @@
 			this.ip = option.ip || ""
 			this.sceneId = option.sceneId || ""
 			this.isPageVisible = true
+			this.$nextTick(() => {
+				this.loadData()
+			})
 
-			this.loadData()
 		},
 		onShow() {
 			this.isPageVisible = true
@@ -159,26 +162,36 @@
 
 				} catch (ex) {
 
-					this.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
 				} catch (ex) {
 
-					this.showError(ex)
+					showError(ex, this.translate('error'))
+				} finally {
+					uni.hideLoading()
 				}
+
 			},
 
 			async timerCheckTaskGroupStatus() {
 				try {
 					if (this.isPageVisible)
 						await this.checkTaskGroupStatus()
+					// setTimeout(this.timerCheckTaskGroupStatus, 1000);
 				} catch (ex) {
-					this.showError(ex)
+					showToast(ex)
+					// showError(ex,this.translate('error')).then((res)=>{
+					// 	setTimeout(this.timerCheckTaskGroupStatus, 1000);
+					// })
 				} finally {
 					setTimeout(this.timerCheckTaskGroupStatus, 1000);
 				}
@@ -210,7 +223,7 @@
 				} catch (ex) {
 
 					this.taskStatus = {}
-					this.showError(ex)
+					showToast(ex)
 				}
 			},
 			setTaskGroupStatus(cmdID) {
@@ -220,8 +233,9 @@
 			},
 			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) {
@@ -279,7 +293,7 @@
 					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) {
@@ -305,16 +319,16 @@
 					this.setTaskGroupStatus(cmdID)
 
 				} catch (ex) {
-					this.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) {
-					this.showError(ex)
+					showError(ex, this.translate('error'))
 				}
 			},
 
@@ -338,14 +352,13 @@
 							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) {
-					this.showError(ex)
+					showError(ex, this.translate('error'))
 				}
 			},
 
@@ -356,12 +369,18 @@
 
 			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 {
@@ -372,25 +391,21 @@
 					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) {
-					this.showError(ex)
+					showError(ex, this.translate('error'))
 				}
 
 			},
 
-
-			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, "纭畾")
+			translate(t) {
+				if (typeof this.$t == "function") return this.$t(`page.${t}`)
+				else return t;
 			},
 		}
 	}

--
Gitblit v1.9.1