diff --git a/src/components/ControllerTabs.vue b/src/components/ControllerTabs.vue index 02f60c2..78063ea 100644 --- a/src/components/ControllerTabs.vue +++ b/src/components/ControllerTabs.vue @@ -406,6 +406,19 @@ export default { * @description: 执行任务前 先检测订单是否 合法 例如:订单重量会不会超出飞机载重上限 */ checkQuest () { + console.log(this.questForm.id) + if (this.questForm.id === '') { + this.$message.error('未选择订单任务!') + return + } + if (!this.currentOrder) { + this.$message.error('此订单已被申请退款或者订单已经被取消!') + return + } + if (this.currentOrder.bind_route === null) { // 判断站点是否已经绑定站点 未绑定 中断操作 + this.$message.error('此站点,未绑定任务航点') + return + } if (Number(this.currentOrder.total_weight) >= Number(this.plane.weight_max)) { // 检查重量 this.$confirm('此订单总重超出本飞机的载重上限', '检测订单', { confirmButtonText: '仍然提交', @@ -449,64 +462,52 @@ export default { * @description: 执行订单任务 */ runQuest () { - if (this.questForm.id === '') { - this.$message.error('未选择订单任务!') - return - } - if (this.currentOrder) { - /* 插入日志 */ - this.$store.dispatch('fetchLog', { content: `${this.plane.name} 开始执行 订单ID:${this.currentOrder.id}、叫餐号:${this.currentOrder.food_sn}号。` }) - /* 执行写在这里 */ - if (this.currentOrder.bind_route === null) { // 判断站点是否已经绑定站点 未绑定 中断操作 - this.$message.error('此站点,未绑定任务航点') - return - } - let routeData - let newRuning // 执行飞机注册后的 running字段信息 - try { - /* 站点正在执行任务runing 注册 */ - const runing = this.currentOrder.runing.split(',') - let foundEmpty = false - let selIndex // 记录执行飞机注册的索引 此索引对应 要使用的航线的索引 - runing.some((item, index, arr) => { - if (item === '') { - arr[index] = this.planesId - foundEmpty = true - selIndex = index - return true // 找到空位后退出循环 - } - }) - newRuning = runing.join(',') - if (!foundEmpty) { - this.$message({ - type: 'warning', - message: '此站点执行飞机已达上线,如果想执行请为该站点绑定更多航线' - }) - return // 退出外层函数 + /* 插入日志 */ + this.$store.dispatch('fetchLog', { content: `${this.plane.name} 开始执行 订单ID:${this.currentOrder.id}、叫餐号:${this.currentOrder.food_sn}号。` }) + /* 执行写在这里 */ + let routeData // 航线数据内容 + let newRuning // 执行飞机注册后的 running字段信息 + try { + /* 站点正在执行任务runing 注册 */ + const runing = this.currentOrder.runing.split(',') + let foundEmpty = false + let selIndex // 记录执行飞机注册的索引 此索引对应 要使用的航线的索引 + runing.some((item, index, arr) => { + if (item === '') { + arr[index] = this.planesId + foundEmpty = true + selIndex = index + return true // 找到空位后退出循环 } - /* 航线选择 */ - const bindRoute = this.currentOrder.bind_route.split(',') - routeData = this.routeList.find(element => element.id === bindRoute[selIndex]).route_data - routeData = JSON.parse(routeData)// 反序列化 - // 处理声音航点 航点里面的表达式 如$food_sn$ 正则替换成订单对应的字段 - this.currentOrder.telTail = this.currentOrder.tel.substr(-4)// 手动加一个手机尾号telTail字段 从 tel字段截取后四位 - routeData.tasks.forEach((x, index) => { - if (x.sound) { - const str = this.voiceRouteParse(this.currentOrder, x.sound) - routeData.tasks[index].sound = str// 重新写入声音航点 - } + }) + newRuning = runing.join(',') + if (!foundEmpty) { + this.$message({ + type: 'warning', + message: '站点所有航线都已被占用!' }) - routeData = JSON.stringify(routeData)// 重新序列化 - } catch (error) { - this.$message.error('操作失败,请重新尝试') + return // 退出外层函数 } - this.publishFun(`{"questAss":${routeData}}`)// 发送航点信息主题 - this.questAss(this.currentOrder.id, 'shipment_status', '已发货')// 订单改为发货状态 并更新订单列表 - this.$store.dispatch('fetchLockSite', { id: this.currentOrder.receive_site_id, runing: newRuning })// 航线注册飞机 锁定送餐点 - this.speakText('提交任务,锁定航线。') - } else { - this.$message.error('此订单已被申请退款或者订单已经被取消!') + /* 航线选择 */ + const bindRoute = this.currentOrder.bind_route.split(',') + routeData = this.routeList.find(element => element.id === bindRoute[selIndex]).route_data + routeData = JSON.parse(routeData)// 反序列化 + // 处理声音航点 航点里面的表达式 如$food_sn$ 正则替换成订单对应的字段 + this.currentOrder.telTail = this.currentOrder.tel.substr(-4)// 手动加一个手机尾号telTail字段 从 tel字段截取后四位 + routeData.tasks.forEach((x, index) => { + if (x.sound) { + const str = this.voiceRouteParse(this.currentOrder, x.sound) + routeData.tasks[index].sound = str// 重新写入声音航点 + } + }) + routeData = JSON.stringify(routeData)// 重新序列化 + } catch (error) { + this.$message.error('操作失败,请重新尝试') } + this.publishFun(`{"questAss":${routeData}}`)// 发送航点信息主题 + this.questAss(this.currentOrder.id, 'shipment_status', '已发货')// 订单改为发货状态 并更新订单列表 + this.$store.dispatch('fetchLockSite', { id: this.currentOrder.receive_site_id, runing: newRuning })// 航线注册飞机 锁定送餐点 + this.speakText('提交任务,锁定航线。') }, /** * @description: 匹配声音航点字符串 比如$food_sn$ food_sn匹配成 送餐订单里面的对应字段 @@ -666,6 +667,13 @@ export default { } return false }) + }, + questList (val) { + /* 任务列表更新时 判断还有没有当前选择的id 没有就清空 */ + const found = val.some(item => item.id === this.questForm.id) + if (!found) { + this.questForm.id = '' + } } }