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 | 88 ++++++++++++++++++++++++-------------------
1 files changed, 49 insertions(+), 39 deletions(-)
diff --git a/pages/task/list.vue b/pages/task/list.vue
index e7d9573..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>
@@ -60,17 +60,15 @@
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: [],
@@ -80,7 +78,7 @@
[]
], // 姣忎釜椤圭洰鐨勫亸绉婚噺
options: [{
- text: '鍒犻櫎',
+ text: this.translate('delete'),
style: {
backgroundColor: '#F56C6C'
}
@@ -107,10 +105,10 @@
this.ip = option.ip || ""
this.sceneId = option.sceneId || ""
this.isPageVisible = true
- this.$nextTick(()=>{
+ this.$nextTick(() => {
this.loadData()
})
-
+
},
onShow() {
this.isPageVisible = true
@@ -164,34 +162,38 @@
} 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) {
showToast(ex)
- // showError(ex).then((res)=>{
+ // showError(ex,this.translate('error')).then((res)=>{
// setTimeout(this.timerCheckTaskGroupStatus, 1000);
// })
} finally {
- setTimeout(this.timerCheckTaskGroupStatus, 1000);
+ setTimeout(this.timerCheckTaskGroupStatus, 1000);
}
},
async checkTaskGroupStatus() {
@@ -231,9 +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) {
@@ -291,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) {
@@ -317,16 +319,16 @@
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'))
}
},
@@ -350,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) {
- showError(ex)
+ showError(ex, this.translate('error'))
}
},
@@ -368,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 {
@@ -384,19 +391,22 @@
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>
--
Gitblit v1.9.1