From 136ee3ca0f1fec67f3d783f1aac6c75505b80e46 Mon Sep 17 00:00:00 2001 From: tk Date: Tue, 18 Jun 2024 16:24:50 +0800 Subject: [PATCH] =?UTF-8?q?=E3=80=90=E7=B1=BB=09=E5=9E=8B=E3=80=91?= =?UTF-8?q?=EF=BC=9Afix=20=E3=80=90=E4=B8=BB=09=E9=A2=98=E3=80=91=EF=BC=9A?= =?UTF-8?q?=E6=8F=90=E4=BA=A4=E8=AE=A2=E5=8D=95=E6=98=AF=20=E6=A3=80?= =?UTF-8?q?=E6=B5=8B=E8=AE=A2=E5=8D=95=E9=87=8D=E9=87=8F=20=E3=80=90?= =?UTF-8?q?=E6=8F=8F=09=E8=BF=B0=E3=80=91=EF=BC=9A=20=09[=E5=8E=9F?= =?UTF-8?q?=E5=9B=A0]=EF=BC=9A=E6=A3=80=E6=B5=8B=E8=AE=A2=E5=8D=95?= =?UTF-8?q?=E9=87=8D=E9=87=8F=E8=B6=85=E8=BF=87=E9=A3=9E=E6=9C=BA=E6=89=BF?= =?UTF-8?q?=E8=BD=BD=E9=87=8D=E9=87=8F=E4=B8=8A=E9=99=90=20=20=E7=BB=99?= =?UTF-8?q?=E6=8F=90=E7=A4=BA=20=E5=A2=9E=E5=8A=A0=E5=AE=89=E5=85=A8?= =?UTF-8?q?=E4=BF=9D=E9=9A=9C=20=09[=E8=BF=87=E7=A8=8B]=EF=BC=9A=20=09[?= =?UTF-8?q?=E5=BD=B1=E5=93=8D]=EF=BC=9A=20=E3=80=90=E7=BB=93=09=E6=9D=9F?= =?UTF-8?q?=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 | 149 ++++++++++++++++++++++-------- 1 file changed, 112 insertions(+), 37 deletions(-) diff --git a/src/components/ControllerTabs.vue b/src/components/ControllerTabs.vue index 3434d29..e4e7925 100644 --- a/src/components/ControllerTabs.vue +++ b/src/components/ControllerTabs.vue @@ -61,7 +61,8 @@ - + {{ item.id }} {{ item.receiver }} {{ item.receive_site_name }} @@ -75,7 +76,7 @@ 航线锁定 + icon="f-s-14 iconfont icon-chakanzhihangrizhi" @click="checkQuest"> 提交任务 item.status === 'shipped') }, + /** + * @description: 当前选中的订单 + */ + currentOrder () { + if (this.questForm && this.questForm.id !== undefined) { + return this.questList.find((item) => item.id === this.questForm.id) || null + } + return null + }, /** * @description: 航线列表 */ @@ -395,6 +405,35 @@ export default { this.$message.warning('与飞机通信未接通,请稍后') } }, + /** + * @description: 执行任务前 先检测订单是否 合法 例如:订单重量会不会超出飞机载重上限 + */ + checkQuest () { + // 检查重量 + if (Number(this.currentOrder.total_weight) >= Number(this.plane.weight_max)) { + this.$confirm('此订单总重超出本飞机的载重上限', '检测订单', { + confirmButtonText: '仍然提交', + cancelButtonText: '放弃提交', + type: 'warning' + }) + .then(() => { + this.$message({ + type: 'warning', + message: '存在超重风险,仍然提交订单' + }) + this.runQuest()// 提交订单 + }) + .catch(action => { + this.$message({ + type: 'info', + message: '取消提交订单' + }) + }) + } else { + // 合法 直接提交订单 + this.runQuest() + } + }, /** * @description: 执行订单任务 */ @@ -403,42 +442,73 @@ export default { this.$message.error('未选择订单任务!') return } - let i - this.questList.map((item) => { - if (this.questForm.id === item.id) { - i = true - /* 插入日志 */ - this.$store.dispatch('fetchLog', { content: `${this.plane.name} 开始执行 订单ID:${item.id}、叫餐号:${item.food_sn}号。` }) - /* 执行写在这里 */ - if (item.bind_route === null) { // 判断站点是否已经绑定站点 未绑定 中断操作 - this.$message.error('此站点,未绑定任务航点') - return - } - let routeData - try { - const bindRoute = item.bind_route.split(',') - routeData = this.routeList.find(element => element.id === bindRoute[0]).route_data - routeData = JSON.parse(routeData)// 反序列化 - /* 处理声音航点 航点里面的表达式 如$food_sn$ 正则替换成订单对应的字段 */ - item.telTail = item.tel.substr(-4)// 手动加一个手机尾号telTail字段 从 tel字段截取后四位 - routeData.tasks.forEach((x, index) => { - if (x.sound) { - const str = this.voiceRouteParse(item, x.sound) - routeData.tasks[index].sound = str// 重新写入声音航点 - } - }) - routeData = JSON.stringify(routeData)// 重新序列化 - } catch (error) { - this.$message.error('操作失败,请重新尝试') - } - this.publishFun(`{"questAss":${routeData}}`)// 发送航点信息主题 - this.questAss(item.id, 'status', 'shipped')// 订单改为发货状态 并更新订单列表 - this.$store.dispatch('fetchLockSite', { id: item.receive_site_id, runing: this.plane.id })// 航线注册飞机 锁定送餐点 - this.speakText('提交任务,锁定航线。') + 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 } - }) - if (i) { return } - this.$message.error('此订单已被申请退款或者订单已经被取消!') + let routeData + try { + const bindRoute = this.currentOrder.bind_route.split(',') + routeData = this.routeList.find(element => element.id === bindRoute[0]).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, 'status', 'shipped')// 订单改为发货状态 并更新订单列表 + this.$store.dispatch('fetchLockSite', { id: this.currentOrder.receive_site_id, runing: this.plane.id })// 航线注册飞机 锁定送餐点 + this.speakText('提交任务,锁定航线。') + } else { + this.$message.error('此订单已被申请退款或者订单已经被取消!') + } + // let i + // this.questList.map((item) => { + // if (this.questForm.id === item.id) { + // i = true + // /* 插入日志 */ + // this.$store.dispatch('fetchLog', { content: `${this.plane.name} 开始执行 订单ID:${item.id}、叫餐号:${item.food_sn}号。` }) + // /* 执行写在这里 */ + // if (item.bind_route === null) { // 判断站点是否已经绑定站点 未绑定 中断操作 + // this.$message.error('此站点,未绑定任务航点') + // return + // } + // let routeData + // try { + // const bindRoute = item.bind_route.split(',') + // routeData = this.routeList.find(element => element.id === bindRoute[0]).route_data + // routeData = JSON.parse(routeData)// 反序列化 + // /* 处理声音航点 航点里面的表达式 如$food_sn$ 正则替换成订单对应的字段 */ + // item.telTail = item.tel.substr(-4)// 手动加一个手机尾号telTail字段 从 tel字段截取后四位 + // routeData.tasks.forEach((x, index) => { + // if (x.sound) { + // const str = this.voiceRouteParse(item, x.sound) + // routeData.tasks[index].sound = str// 重新写入声音航点 + // } + // }) + // routeData = JSON.stringify(routeData)// 重新序列化 + // } catch (error) { + // this.$message.error('操作失败,请重新尝试') + // } + // this.publishFun(`{"questAss":${routeData}}`)// 发送航点信息主题 + // this.questAss(item.id, 'status', 'shipped')// 订单改为发货状态 并更新订单列表 + // this.$store.dispatch('fetchLockSite', { id: item.receive_site_id, runing: this.plane.id })// 航线注册飞机 锁定送餐点 + // this.speakText('提交任务,锁定航线。') + // } + // }) + // if (i) { return } }, /** * @description: 匹配声音航点字符串 比如$food_sn$ food_sn匹配成 送餐订单里面的对应字段 @@ -577,6 +647,11 @@ export default {