diff --git a/src/components/ControllerTabs.vue b/src/components/ControllerTabs.vue index fd1879a..be33dc4 100644 --- a/src/components/ControllerTabs.vue +++ b/src/components/ControllerTabs.vue @@ -678,33 +678,26 @@ export default { type: 'warning' }).then(() => { /* 关联当前订单的站点 搜寻注册的飞机 并预设newRuning 用于注销runing字段航线 */ - let newRuning // 确保newRuning在函数块外定义 - let receiveSiteId - let orderId - const found = this.ShippedList.some((element) => { - const runing = (element.runing ?? '').split(',') - return runing.some((item, index, arr) => { - if (item === this.plane.id.toString()) { - arr[index] = '' // 将匹配的id替换为空字符串 - newRuning = runing.join(',') - orderId = element.id - receiveSiteId = element.receive_site_id - return true // 找到id后退出内层循环 - } - }) - }) - /* 确认 把订单从发货退回到已接单 站点runing字段飞机航线注销 重置飞机状态 */ - if (found) { - this.$store.dispatch('fetchLockSite', { id: receiveSiteId, shop_id: this.plane.shop_id, runing: newRuning }).then(res => { // 订单改为已完成状态 - if (res.data.status === 1) { - this.questAss(orderId, 'shipment_status', '已送达').then(res => { // 注销航线 - if (res.data.status === 1) { - this.publishFun('{"resetState":1}')// 发送设置飞机状态主题 状态设为闲置 - } - }) - } - }) + // 分割字符串成数组 + const runingArray = this.executeOrder.runing.split(',') + // 遍历数组并替换相等的值 + for (let i = 0; i < runingArray.length; i++) { + if (runingArray[i] === this.executeOrder.by_plane_id) { + runingArray[i] = '' + } } + // 将数组重新组合成字符串 + const newRuning = runingArray.join(',') + /* 确认 把订单从发货退回到已接单 站点runing字段飞机航线注销 重置飞机状态 */ + this.$store.dispatch('fetchLockSite', { id: this.executeOrder.receive_site_id, shop_id: this.plane.shop_id, runing: newRuning }).then(res => { // 订单改为已完成状态 + if (res.data.status === 1) { + this.questAss(this.executeOrder.id, 'shipment_status', '已送达').then(res => { // 注销航线 + if (res.data.status === 1) { + this.publishFun('{"resetState":1}')// 发送设置飞机状态主题 状态设为闲置 + } + }) + } + }) }).catch(() => { this.$message.info('取消操作!') })