From 86cecc9e342cc718527debe5994f0134e61ef86b Mon Sep 17 00:00:00 2001 From: tk Date: Tue, 9 Jul 2024 21:55:00 +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=E6=8F=90=E4=BA=A4=E4=BB=BB=E5=8A=A1=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=E9=87=8D=E7=BD=AE=E5=A4=9A=E8=88=AA?= =?UTF-8?q?=E7=BA=BF=E7=BB=91=E5=AE=9A=20=09[=E8=BF=87=E7=A8=8B]=EF=BC=9A?= =?UTF-8?q?=E6=8F=90=E4=BA=A4=E4=BB=BB=E5=8A=A1=20=E4=BB=8Eruning=E5=AD=97?= =?UTF-8?q?=E6=AE=B5=E5=88=A4=E6=96=AD=20=E6=98=AF=E5=90=A6=E6=9C=89?= =?UTF-8?q?=E6=B3=A8=E5=86=8C=E7=A9=BA=E4=BD=8D=20=E6=9C=89=E7=9A=84?= =?UTF-8?q?=E8=AF=9D=E6=B3=A8=E5=86=8C=20=E5=B9=B6=E4=B8=94=E6=89=BE?= =?UTF-8?q?=E5=87=BA=E5=AF=B9=E5=BA=94=E8=88=AA=E7=BA=BF=E7=9A=84=E7=B4=A2?= =?UTF-8?q?=E5=BC=95=20=EF=BC=88=E7=94=A8=E4=BA=8E=E5=90=91=E9=A3=9E?= =?UTF-8?q?=E6=9C=BA=E6=8F=90=E4=BA=A4=E8=88=AA=E7=82=B9=EF=BC=89=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 | 81 +++++++++++++++---------------- src/store/index.js | 20 +------- src/utils/api/index.js | 4 +- 3 files changed, 42 insertions(+), 63 deletions(-) diff --git a/src/components/ControllerTabs.vue b/src/components/ControllerTabs.vue index 3f7d218..e840eee 100644 --- a/src/components/ControllerTabs.vue +++ b/src/components/ControllerTabs.vue @@ -466,11 +466,33 @@ export default { 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 // 退出外层函数 + } + /* 航线选择 */ const bindRoute = this.currentOrder.bind_route.split(',') - routeData = this.routeList.find(element => element.id === bindRoute[0]).route_data + routeData = this.routeList.find(element => element.id === bindRoute[selIndex]).route_data routeData = JSON.parse(routeData)// 反序列化 - /* 处理声音航点 航点里面的表达式 如$food_sn$ 正则替换成订单对应的字段 */ + // 处理声音航点 航点里面的表达式 如$food_sn$ 正则替换成订单对应的字段 this.currentOrder.telTail = this.currentOrder.tel.substr(-4)// 手动加一个手机尾号telTail字段 从 tel字段截取后四位 routeData.tasks.forEach((x, index) => { if (x.sound) { @@ -484,46 +506,11 @@ export default { } this.publishFun(`{"questAss":${routeData}}`)// 发送航点信息主题 this.questAss(this.currentOrder.id, 'shipment_status', '已发货')// 订单改为发货状态 并更新订单列表 - this.$store.dispatch('fetchLockSite', { id: this.currentOrder.receive_site_id, runing: this.plane.id })// 航线注册飞机 锁定送餐点 + this.$store.dispatch('fetchLockSite', { id: this.currentOrder.receive_site_id, runing: newRuning })// 航线注册飞机 锁定送餐点 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匹配成 送餐订单里面的对应字段 @@ -615,13 +602,17 @@ export default { }) }, /** - * @description: 在地图上绘制航线 - */ + * @description: 在地图上绘制航线 + */ makeRouteForMap () { let bindRoute let routeData - this.siteList.forEach(item => { - if (item.runing === this.planesId) { + let found = false + + this.siteList.some(item => { + const runing = item.runing.split(',') + if (runing.includes(this.planesId.toString())) { + found = true // 获取航点信息 if (item.bind_route !== null) { // 判断站点是否已经绑定站点 bindRoute = item.bind_route.split(',') @@ -632,8 +623,14 @@ export default { } else { this.$message.error('此站点,未绑定任务航点') } + return true // 找到匹配项后退出循环 } + return false // 继续循环 }) + + if (!found) { + this.$message.error('未找到匹配的站点') + } }, /** * @description: 判断 已接订单下拉框 的任务 有疑问的 坐标集 class样式显示成红色 diff --git a/src/store/index.js b/src/store/index.js index 59db64a..41f2752 100644 --- a/src/store/index.js +++ b/src/store/index.js @@ -1,5 +1,6 @@ import Vue from 'vue' import Vuex from 'vuex' +// import router from '@/router' import app from './modules/app' import settings from './modules/settings' import user from './modules/user' @@ -453,25 +454,6 @@ const store = new Vuex.Store({ } else { Message.error(res.data.msg) } - // else if (res.data.status === -1) { // -1状态 服务器判断runing字段 正在有飞机正在执行 - // MessageBox.confirm(res.data.msg, '提示', { - // confirmButtonText: '强制更新', - // cancelButtonText: '取消', - // type: 'warning' - // }).then(() => { - // params.append('isCoerce', 1) - // api.post('saveSite', params).then(res => { - // if (res.data.status === 1) { - // Message.success(res.data.msg) - // dispatch('fetchSiteList')// 刷新站点列表 - // } else { - // Message.error(res.data.msg) - // } - // }) - // }).catch(() => { - // Message.info('取消操作') - // }) - // } return res }, /** diff --git a/src/utils/api/index.js b/src/utils/api/index.js index c7259bb..648ec7d 100644 --- a/src/utils/api/index.js +++ b/src/utils/api/index.js @@ -16,7 +16,7 @@ async function get (controller, prefix = 'Plane') { const path = init(prefix) try { const res = await axios.get(path + controller) - if (res.data.status === -1) { // 权限过期 + if (res.data.status === 'noPermission') { // 权限过期 localStorage.removeItem('token') router.go(0) } @@ -37,7 +37,7 @@ async function post (controller, params, prefix = 'Plane') { const path = init(prefix) try { const res = await axios.post(path + controller, params) - if (res.data.status === -1) { // 权限过期 + if (res.data.status === 'noPermission') { // 权限过期 localStorage.removeItem('token') router.go(0) }