| | |
| | | <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')}"> |
| | |
| | | </a> |
| | | <template class="time" v-if="item.actionType === 3"> |
| | | <a @click.stop="()=>{item.wait = 0}" v-if="item.wait===undefined"> |
| | | 等待时间 |
| | | {{translate("wait_time")}} |
| | | </a> |
| | | <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> |
| | |
| | | return { |
| | | indicatorStyle: `height: 75rpx;`, |
| | | ip: '', |
| | | navigationBarTitle: '新增任务', |
| | | navigationBarTitle: this.translate("new_task"), |
| | | info: { |
| | | taskGroupName: "", |
| | | cycleTime: 1, |
| | |
| | | |
| | | |
| | | 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: { |
| | |
| | | |
| | | 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) { |
| | |
| | | const info = await stations(this.ip) |
| | | this.stationList = info.station_list || [] |
| | | } catch (ex) { |
| | | 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("未选择按钮号!") |
| | | showToast(this.translate("select_button_number")) |
| | | return |
| | | } |
| | | uni.showLoading({ |
| | | title: "任务新增中" |
| | | title: this.translate("adding_task") |
| | | }) |
| | | const taskList = [] |
| | | const task = { |
| | |
| | | const item = this.pathwayList[i] |
| | | if (item.stationID) { |
| | | if (!item.actionType) { |
| | | showToast("目标点未选择操作类型!") |
| | | showToast(this.translate("target_point_no_operation_type")) |
| | | return |
| | | } |
| | | task.taskList.push({ |
| | |
| | | } |
| | | |
| | | if (taskList.length == 0) { |
| | | showToast("必须添加至少一个目标点!") |
| | | showToast(this.translate("at_least_one_target_point_added")) |
| | | return |
| | | } |
| | | await addTask(this.ip, task) |
| | |
| | | delta: 1, //返回层数,2则上上页 |
| | | }) |
| | | } catch (ex) { |
| | | showError(ex) |
| | | showError(ex, this.translate('error')) |
| | | } finally { |
| | | uni.hideLoading() |
| | | } |
| | |
| | | } |
| | | 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, //返回层数,2则上上页 |
| | |
| | | if (curIndex > -1) { |
| | | return this.actionList[curIndex].name |
| | | } else { |
| | | return "操作" |
| | | return this.translate("task_action") |
| | | } |
| | | } else { |
| | | return "操作" |
| | | return this.translate("task_action") |
| | | } |
| | | }, |
| | | |
| | |
| | | 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, |
| | |
| | | if (this.pathwayList.length > 1) { |
| | | this.pathwayList.splice(index, 1) |
| | | } else { |
| | | showToast("必须有一个目标点") |
| | | showToast(this.translate("at_least_one_target_point_added")) |
| | | } |
| | | }, |
| | | onInputCycleTime(event) { |
| | |
| | | closeMenu() { |
| | | this.$refs.refPopupMenu.close() |
| | | }, |
| | | |
| | | translate(t) { |
| | | if (typeof this.$t == "function") return this.$t(`page.${t}`) |
| | | else return t; |
| | | }, |
| | | |
| | | } |
| | | } |
| | |
| | | .right-input { |
| | | text-align: right; |
| | | flex: 1; |
| | | color: #1890FF; |
| | | } |
| | | |
| | | .text { |