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/add.vue | 172 ++++++++++++++++++++++++++++++++++-----------------------
1 files changed, 103 insertions(+), 69 deletions(-)
diff --git a/pages/task/add.vue b/pages/task/add.vue
index a4e2980..65bfb07 100644
--- a/pages/task/add.vue
+++ b/pages/task/add.vue
@@ -1,85 +1,90 @@
<template>
<view class="pages-task-add">
- <uni-nav-bar :fixed="true" status-bar right-text="" left-text="" leftWidth="72rpx" rightWidth="72rpx"
- :title="navigationBarTitle">
+ <uni-nav-bar :fixed="true" status-bar
+ :title="navigationBarTitle" @clickLeft="clickCancel" @clickRight="clickSave">
<view class="uni-navbar-container-inner">
<text class="uni-nav-bar-text">{{navigationBarTitle }}</text>
</view>
<template v-slot:right>
<view class="uni-navbar-btn-text">
- <a @click="clickSave" class="uni-nav-bar-right-text">
- 淇濆瓨
+ <a class="uni-nav-bar-right-text">
+ {{translate('save')}}
</a>
</view>
</template>
<template v-slot:left>
<view class="uni-navbar-btn-text">
- <a @click="clickCancel" class="uni-nav-bar-left-text">
- 鍙栨秷
+ <a class="uni-nav-bar-left-text">
+ {{translate('cancel')}}
</a>
</view>
- </template>
+ </template>
</uni-nav-bar>
<view class="content">
- <view class="header">浠诲姟灞炴�</view>
+ <view class="header">{{translate("task_properties")}}</view>
<view class="group">
<view class="item">
- <view>鍚嶇О锛�/view>
- <input class="right-input" placeholder="杈撳叆浠诲姟鍚嶇О" v-model="info.taskGroupName" />
+ <view>{{translate("name")}}</view>
+ <input class="right-input" :placeholder="translate('input_task_name')"
+ v-model="info.taskGroupName" />
</view>
<view class="item">
- <view>灞炴�锛�/view>
- <view class="right" v-if="info.tasktype > 0">{{info.tasktype ==1 ? '鍥哄畾':'涓存椂'}}</view>
- <view class="right" v-else>閫夋嫨灞炴�</view>
+ <view>{{translate("properties")}}</view>
+ <view class="right" v-if="info.tasktype > 0">
+ {{info.tasktype ==1 ? translate("fixed"):translate("temporary")}}
+ </view>
+ <view class="right" v-else>{{translate("select_properties")}}</view>
<a @click="clickType">
<uni-icons class="icon" type="right" size="20"></uni-icons>
</a>
</view>
<view class="item" v-if="info.tasktype == 1">
- <view>閲嶅娆℃暟锛�/view>
+ <view>{{translate("number_repetitions")}}</view>
<input class="right-input" type="number" :value="info.cycleTime" :maxlength="4"
@input="onInputCycleTime" />
</view>
<view class="item">
- <view>鎸夐挳鍙凤細</view>
- <view class="right">{{info.taskButton ?info.taskButton:""}}</view>
+ <view>{{translate("button_number")}}</view>
+ <view class="right">{{info.taskButton ?info.taskButton:translate("select_button_number")}}</view>
<a @click="clickTaskButton">
<uni-icons class="icon" type="right" size="20"></uni-icons>
</a>
</view>
</view>
- <view class="header">浠诲姟璺嚎</view>
+ <view class="header">{{translate("task_route")}}</view>
<view class="group">
<uni-swipe-action class="list">
<uni-swipe-action-item class="list-item" v-for="(item,index) in pathwayList" :key="index"
:auto-close="true">
<view class="item">
- <view>鐩爣鐐箋{index+1}}锛�/view>
+ <view>{{translate("target_point") + " "}}{{index+1}}锛�/view>
<view class="right"></view>
<a @click.stop="(e)=>{ this.clickPathwayPoint(e,index,'stationID')}">
- {{item.stationID ?stationName(item.stationID) : "鐩爣鐐�}}
+ {{item.stationID ?stationName(item.stationID) :translate("target_point")}}
</a>
<a @click.stop="(e)=>{ clickPathwayPoint(e,index,'actionType')}">
{{actionTypeText(item.actionType)}}
</a>
- <view v-if="item.actionType === 3">
+ <template class="time" v-if="item.actionType === 3">
<a @click.stop="()=>{item.wait = 0}" v-if="item.wait===undefined">
- 绛夊緟鏃堕棿
+ {{translate("wait_time")}}
</a>
- <view v-else class="time"> <input class="input" type="number" v-model="item.wait"
- :maxlength="4" />绉�/view>
- </view>
+ <input v-else class="input" type="number" v-model="item.wait" :maxlength="4" />
+ </template>
+ <span v-if="item.actionType === 3 && item.wait!==undefined">
+ {{translate("second")}}
+ </span>
</view>
<template v-slot:right>
- <view class="btn-del" @click="clickDelPathWay(index)">鍒犻櫎</view>
+ <view class="btn-del" @click="clickDelPathWay(index)">{{translate("delete")}}</view>
</template>
</uni-swipe-action-item>
</uni-swipe-action>
<view class="item">
- <a-button class="button" @click="clickAddPathway">+ 娣诲姞鐩爣鐐�+ <a-button class="button" @click="clickAddPathway">{{"+ "+translate("add_target_point")}}
</a-button>
</view>
</view>
@@ -103,7 +108,9 @@
<script>
import {
showToast,
- showModal
+ showModal,
+ showError,
+ showInfo
} from "@/comm/utils.js"
import {
Button
@@ -126,11 +133,12 @@
return {
indicatorStyle: `height: 75rpx;`,
ip: '',
- navigationBarTitle: '鏂板浠诲姟',
+ navigationBarTitle: this.translate("new_task"),
info: {
taskGroupName: "",
cycleTime: 1,
taskButton: 0,
+ tasktype: 1
},
pathwayList: [{}],
pickerView: {
@@ -143,18 +151,22 @@
actionList: [{
- name: "瀵艰埅",
- type: 1,
- }, {
- name: "鍙栬揣",
- type: 2,
- }, {
- name: "鍗歌揣",
- type: 3,
- }, {
- name: "浜哄伐",
- type: 4,
- }]
+ name: this.translate("navigation"),
+ type: 1,
+ },
+ // {
+ // name: "鍙栬揣",
+ // type: 2,
+ // },
+ {
+ name: this.translate("auto_unload"),
+ type: 3,
+ },
+ // {
+ // name: "浜哄伐",
+ // type: 4,
+ // },
+ ],
}
},
computed: {
@@ -163,7 +175,7 @@
onLoad(option) {
const _this = this
- this.navigationBarTitle = option.title || "鏂板浠诲姟"
+ this.navigationBarTitle = option.title || this.translate("new_task")
this.ip = option.ip || ""
uni.getSystemInfo({
success(e) {
@@ -203,20 +215,27 @@
const info = await stations(this.ip)
this.stationList = info.station_list || []
} catch (ex) {
- this.showError(ex)
+ showError(ex, this.translate('error'))
}
},
async clickSave() {
try {
const name = this.info.taskGroupName.trim()
if (!name) {
- showToast("鏈緭鍏ヤ换鍔″悕绉帮紒")
+ showToast(this.translate("input_task_name"))
return
}
if (!this.info.tasktype) {
- showToast("鏈�鎷╀换鍔″睘鎬э紒")
+ showToast(this.translate("select_task_properties"))
return
}
+ if (!this.info.taskButton) {
+ showToast(this.translate("select_button_number"))
+ return
+ }
+ uni.showLoading({
+ title: this.translate("adding_task")
+ })
const taskList = []
const task = {
taskGroupID: uuidv4(),
@@ -228,8 +247,13 @@
}
const taskStartTimeStamp = `${new Date().getTime()}`
- this.pathwayList.forEach((item) => {
+ for (let i in this.pathwayList) {
+ const item = this.pathwayList[i]
if (item.stationID) {
+ if (!item.actionType) {
+ showToast(this.translate("target_point_no_operation_type"))
+ return
+ }
task.taskList.push({
stationID: item.stationID,
actionType: item.actionType || 0,
@@ -245,12 +269,15 @@
})
}
- })
+
+ }
+
if (taskList.length == 0) {
- showToast("鐩爣鐐规湭閫夋嫨绔欏彴锛�)
+ showToast(this.translate("at_least_one_target_point_added"))
return
}
await addTask(this.ip, task)
+
task.taskList = taskList
const eventChannel = this.getOpenerEventChannel();
eventChannel.emit('add_task', task);
@@ -258,7 +285,9 @@
delta: 1, //杩斿洖灞傛暟锛�鍒欎笂涓婇〉
})
} catch (ex) {
- this.showError(ex)
+ showError(ex, this.translate('error'))
+ } finally {
+ uni.hideLoading()
}
},
clickCancel() {
@@ -280,7 +309,14 @@
}
if (flag) {
- showModal(`褰撳墠缂栬緫鐨勫唴瀹瑰皢涓嶄細琚繚瀛榒, "纭畾瑕侀�鍑虹紪杈戝悧?",true,"纭畾","鍙栨秷").then((res) => {
+ showModal(
+ {
+ title: this.translate("ask_exit_task_edit"),
+ content: `${this.translate('current_edited_content_will_be_deleted')}`,
+ confirmText: this.translate('ok'),
+ cancelText: this.translate('cancel'),
+ }).then((
+ res) => {
if (res) {
uni.navigateBack({
delta: 1, //杩斿洖灞傛暟锛�鍒欎笂涓婇〉
@@ -331,10 +367,10 @@
if (curIndex > -1) {
return this.actionList[curIndex].name
} else {
- return "鎿嶄綔"
+ return this.translate("task_action")
}
} else {
- return "鎿嶄綔"
+ return this.translate("task_action")
}
},
@@ -408,10 +444,12 @@
this.pickerView = {
type: "type",
list: [{
- name: "鍥哄畾"
- }, {
- name: "涓存椂"
- }],
+ name: this.translate("fixed")
+ },
+ // {
+ // name:this.translate("temporary")
+ // },
+ ],
value: [this.info.tasktype - 1],
top: e.target.offsetTop + 30,
right: 0,
@@ -439,7 +477,7 @@
if (this.pathwayList.length > 1) {
this.pathwayList.splice(index, 1)
} else {
- showToast("蹇呴』鏈変竴涓洰鏍囩偣")
+ showToast(this.translate("at_least_one_target_point_added"))
}
},
onInputCycleTime(event) {
@@ -468,12 +506,9 @@
closeMenu() {
this.$refs.refPopupMenu.close()
},
- showError(ex) {
- let exStr = JSON.stringify(ex)
- if (exStr == "{}")
- exStr = ex
- let tip = typeof ex.msg == "string" ? ex.msg : exStr
- showModal(tip, "閿欒", false,"纭畾")
+ translate(t) {
+ if (typeof this.$t == "function") return this.$t(`page.${t}`)
+ else return t;
},
}
@@ -515,6 +550,7 @@
padding: 20rpx 10rpx;
display: flex;
flex-direction: row;
+ align-items: center;
.right {
flex: 1;
@@ -529,6 +565,7 @@
.right-input {
text-align: right;
flex: 1;
+ color: #1890FF;
}
.text {
@@ -545,15 +582,12 @@
margin-left: 20rpx;
}
- .time {
- display: flex;
- flex-direction: row;
+ .input {
margin-left: 20rpx;
-
- .input {
- width: 75rpx;
- }
+ margin-right: 10rpx;
+ width: 75rpx;
}
+
}
.btn-del {
--
Gitblit v1.9.1