From 3d47d2c32e80244a6397b36a399461692f498483 Mon Sep 17 00:00:00 2001 From: tk Date: Wed, 10 Jul 2024 14:11:51 +0800 Subject: [PATCH] =?UTF-8?q?=E3=80=90=E7=B1=BB=09=E5=9E=8B=E3=80=91?= =?UTF-8?q?=EF=BC=9Arefactor=20=E3=80=90=E4=B8=BB=09=E9=A2=98=E3=80=91?= =?UTF-8?q?=EF=BC=9A=E4=BB=BB=E5=8A=A1=E6=8F=90=E4=BA=A4=E5=89=8D=20?= =?UTF-8?q?=E6=A3=80=E6=9F=A5=20=E3=80=90=E6=8F=8F=09=E8=BF=B0=E3=80=91?= =?UTF-8?q?=EF=BC=9A=20=09[=E5=8E=9F=E5=9B=A0]=EF=BC=9A=E6=8E=92=E9=99=A4?= =?UTF-8?q?=E6=84=8F=E5=A4=96=E6=83=85=E5=86=B5=20=09[=E8=BF=87=E7=A8=8B]?= =?UTF-8?q?=EF=BC=9A=20=09[=E5=BD=B1=E5=93=8D]=EF=BC=9A=20=E3=80=90?= =?UTF-8?q?=E7=BB=93=09=E6=9D=9F=E3=80=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit # 类型 包含: # feat:新功能(feature) # fix:修补bug # docs:文档(documentation) # style: 格式(不影响代码运行的变动) # refactor:重构(即不是新增功能,也不是修改bug的代码变动) # test:增加测试 # chore:构建过程或辅助工具的变动 --- src/components/ControllerTabs.vue | 116 ++++++++++++++++-------------- 1 file changed, 62 insertions(+), 54 deletions(-) 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 = '' + } } }