diff --git a/src/components/ControllerTabs.vue b/src/components/ControllerTabs.vue index b7a7240..0fc79c9 100644 --- a/src/components/ControllerTabs.vue +++ b/src/components/ControllerTabs.vue @@ -56,7 +56,7 @@ - + @@ -66,15 +66,22 @@ + - - 注册航线 - - - 提交任务 + 上传航点 @@ -306,7 +313,7 @@ export default { return plane ? this.$store.state.paidOrderList.filter((item) => item.shop_id === plane.shop_id && item.shipment_status === '已发货') : [] }, /** - * @description: 当前选中的订单 + * @description: 当前选框 中的订单 */ currentOrder () { if (this.questForm && this.questForm.id !== undefined) { @@ -314,6 +321,13 @@ export default { } return null }, + /** + * @description: 当前执行的订单 + */ + executeOrder () { + const plane = this.plane + return plane ? this.ShippedList.find((item) => item.by_plane_id === plane.id) : null + }, /** * @description: 航线列表 */ @@ -401,11 +415,7 @@ export default { * @description: 执行任务前 先检测订单是否 合法 例如:订单重量会不会超出飞机载重上限 */ checkQuest () { - if (this.questForm.id === '') { - this.$message.error('未选择订单任务!') - return - } - if (!this.currentOrder) { + if (!this.currentOrder && !this.executeOrder) { this.$message.error('此订单已被申请退款或者订单已经被取消!') return } @@ -503,7 +513,7 @@ export default { } let res = await this.$store.dispatch('fetchLockSite', { id: this.currentOrder.receive_site_id, shop_id: this.plane.shop_id, runing: newRuning })// 航线注册飞机 锁定送餐点 if (res.data.status === 1) { - res = await this.questAss(this.currentOrder.id, 'shipment_status', '已发货')// 订单改为发货状态 并更新订单列表 + res = await this.questAss(this.currentOrder.id, ['shipment_status', 'by_plane_id'], ['已发货', this.plane.id])// 订单改为发货状态和执行订 并更新订单列表 if (res.data.status === 1) { this.publishFun(routeData)// 发送航点信息主题 this.speakText('提交任务,注册航线。') @@ -578,7 +588,7 @@ export default { 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 => { // 注销航线 + this.questAss(orderId, ['shipment_status', 'by_plane_id'], ['已接单', '']).then(res => { // 注销航线 if (res.data.status === 1) { this.publishFun('{"resetState":1}')// 发送设置飞机状态主题 状态设为闲置 } @@ -591,8 +601,8 @@ export default { }) }, /** - * @description: 已送达任务 - */ + * @description: 已送达任务 + */ overQuest () { if (!this.airLock) { // 只有飞机锁定状态 才向量下执行 "已送达"操作 this.$message.warning('当前没有执行任务') @@ -676,20 +686,11 @@ export default { } }, created () { - // 初始化 - // 当站点列表 航线列表都载入之后 判断飞机的锁定状态airLock - if (this.siteList && this.routeList) { - this.airLock = this.siteList.some(item => { - if (item.runing) { - const runingArray = item.runing.split(',').map(str => str.trim()) // 将 item.runing 分割成数组并去除空格 - return runingArray.includes(this.plane.id.toString()) // 比较数组中的元素和 this.plane.id - } - return false - }) - } - // 主动获取飞机状态 - if (this.plane) { - this.publishFun('{getPlaneState:1}') + // 判断当前飞机有没有挂载的任务 判断是否是锁定状态 + if (this.executeOrder === null) { + this.airLock = false + } else { + this.airLock = true } }, watch: { @@ -704,15 +705,6 @@ export default { this.$store.dispatch('fetchPaidOrderList')// 刷新订单列表 this.$store.dispatch('fetchSiteList')// 刷新站点列表 }, - siteList (val) { - this.airLock = this.siteList.some(item => { - if (item.runing) { - const runingArray = (item.runing ?? '').split(',').map(str => str.trim()) // 将 item.runing 分割成数组并去除空格 - return runingArray.includes(this.plane.id.toString()) // 比较数组中的元素和 this.plane.id - } - return false - }) - }, questList (val) { /* 任务列表更新时 判断还有没有当前选择的id 没有就清空 */ const found = val.some(item => item.id === this.questForm.id) @@ -720,12 +712,15 @@ export default { this.questForm.id = '' } }, - plane (val) { - this.publishFun('{getPlaneState:1}') - }, - ShippedList (val) { - // console.log(val) + executeOrder (val) { + // 判断当前飞机有没有挂载的任务 判断是否是锁定状态 + if (val === null) { + this.airLock = false + } else { + this.airLock = true + } } + } }