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 {