【类 型】:factor

【主	题】:判断飞机是否已经挂载任务
【描	述】:
	[原因]:之前用站点表的runing字段判断 比较麻烦效率低
	[过程]:改为用订单列表的by_plane_id字段判断
	[影响]:
【结	束】

# 类型 包含:
# feat:新功能(feature)
# fix:修补bug
# docs:文档(documentation)
# style: 格式(不影响代码运行的变动)
# refactor:重构(即不是新增功能,也不是修改bug的代码变动)
# test:增加测试
# chore:构建过程或辅助工具的变动
This commit is contained in:
tk 2024-07-12 19:37:29 +08:00
parent 7b350c154a
commit c1f18a4040

View File

@ -56,7 +56,7 @@
</div> </div>
<!-- 内容 --> <!-- 内容 -->
<el-form label-position="left" ref="questForm" :model="questForm" label-width="80px"> <el-form label-position="left" ref="questForm" :model="questForm" label-width="80px">
<el-form-item label="已接订单"> <el-form-item label="订单选择" v-if="!airLock">
<el-select v-model="questForm.id" :filterable="isMobile" placeholder="请选择,也可输入搜索" :disabled="airLock"> <el-select v-model="questForm.id" :filterable="isMobile" placeholder="请选择,也可输入搜索" :disabled="airLock">
<el-option v-for="item in questList" :key="item.id" :label="item.id" :value="item.id" <el-option v-for="item in questList" :key="item.id" :label="item.id" :value="item.id"
:class="isWaring(item) ? 'danger-color' : ''"> :class="isWaring(item) ? 'danger-color' : ''">
@ -66,15 +66,22 @@
</el-option> </el-option>
</el-select> </el-select>
</el-form-item> </el-form-item>
<template v-else>
<el-form-item label="订单ID:">
{{ executeOrder.id }}
</el-form-item>
<el-form-item label="收货站点:">
{{ executeOrder.receive_site_name }}
</el-form-item>
<el-form-item label="联系电话:">
{{ executeOrder.tel }}
</el-form-item>
</template>
<el-form-item label="飞机操作"> <el-form-item label="飞机操作">
<el-button-group> <el-button-group>
<el-button size="mini" class="f-s-14" v-if="plane.planeState.state & 1 && airLock" key="pubBut" <el-button size="mini" class="f-s-14" v-if="plane.planeState.state & 1" type="primary"
type="info" icon="iconfont el-icon-loading" disabled>
<font class="m-l-5">注册航线</font>
</el-button>
<el-button size="mini" class="f-s-14" v-if="plane.planeState.state & 1 && !airLock" type="primary"
icon="f-s-14 iconfont icon-chakanzhihangrizhi" @click="checkQuest"> icon="f-s-14 iconfont icon-chakanzhihangrizhi" @click="checkQuest">
<font class="m-l-5">提交任务</font> <font class="m-l-5">上传航点</font>
</el-button> </el-button>
<el-button size="mini" class="f-s-14" v-if="plane.planeState.state & 2" key="wirteBut" type="info" <el-button size="mini" class="f-s-14" v-if="plane.planeState.state & 2" key="wirteBut" type="info"
:loading="true" disabled> :loading="true" disabled>
@ -306,7 +313,7 @@ export default {
return plane ? this.$store.state.paidOrderList.filter((item) => item.shop_id === plane.shop_id && item.shipment_status === '已发货') : [] return plane ? this.$store.state.paidOrderList.filter((item) => item.shop_id === plane.shop_id && item.shipment_status === '已发货') : []
}, },
/** /**
* @description: 当前选中的订单 * @description: 当前选中的订单
*/ */
currentOrder () { currentOrder () {
if (this.questForm && this.questForm.id !== undefined) { if (this.questForm && this.questForm.id !== undefined) {
@ -314,6 +321,13 @@ export default {
} }
return null return null
}, },
/**
* @description: 当前执行的订单
*/
executeOrder () {
const plane = this.plane
return plane ? this.ShippedList.find((item) => item.by_plane_id === plane.id) : null
},
/** /**
* @description: 航线列表 * @description: 航线列表
*/ */
@ -401,11 +415,7 @@ export default {
* @description: 执行任务前 先检测订单是否 合法 例如订单重量会不会超出飞机载重上限 * @description: 执行任务前 先检测订单是否 合法 例如订单重量会不会超出飞机载重上限
*/ */
checkQuest () { checkQuest () {
if (this.questForm.id === '') { if (!this.currentOrder && !this.executeOrder) {
this.$message.error('未选择订单任务!')
return
}
if (!this.currentOrder) {
this.$message.error('此订单已被申请退款或者订单已经被取消!') this.$message.error('此订单已被申请退款或者订单已经被取消!')
return 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 })// 线 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) { 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) { if (res.data.status === 1) {
this.publishFun(routeData)// this.publishFun(routeData)//
this.speakText('提交任务,注册航线。') this.speakText('提交任务,注册航线。')
@ -578,7 +588,7 @@ export default {
if (found) { if (found) {
this.$store.dispatch('fetchLockSite', { id: receiveSiteId, shop_id: this.plane.shop_id, runing: newRuning }).then(res => { // 退 this.$store.dispatch('fetchLockSite', { id: receiveSiteId, shop_id: this.plane.shop_id, runing: newRuning }).then(res => { // 退
if (res.data.status === 1) { 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) { if (res.data.status === 1) {
this.publishFun('{"resetState":1}')// this.publishFun('{"resetState":1}')//
} }
@ -591,8 +601,8 @@ export default {
}) })
}, },
/** /**
* @description: 已送达任务 * @description: 已送达任务
*/ */
overQuest () { overQuest () {
if (!this.airLock) { // "" if (!this.airLock) { // ""
this.$message.warning('当前没有执行任务') this.$message.warning('当前没有执行任务')
@ -676,20 +686,11 @@ export default {
} }
}, },
created () { created () {
// //
// 线 airLock if (this.executeOrder === null) {
if (this.siteList && this.routeList) { this.airLock = false
this.airLock = this.siteList.some(item => { } else {
if (item.runing) { this.airLock = true
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}')
} }
}, },
watch: { watch: {
@ -704,15 +705,6 @@ export default {
this.$store.dispatch('fetchPaidOrderList')// this.$store.dispatch('fetchPaidOrderList')//
this.$store.dispatch('fetchSiteList')// 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) { questList (val) {
/* 任务列表更新时 判断还有没有当前选择的id 没有就清空 */ /* 任务列表更新时 判断还有没有当前选择的id 没有就清空 */
const found = val.some(item => item.id === this.questForm.id) const found = val.some(item => item.id === this.questForm.id)
@ -720,12 +712,15 @@ export default {
this.questForm.id = '' this.questForm.id = ''
} }
}, },
plane (val) { executeOrder (val) {
this.publishFun('{getPlaneState:1}') //
}, if (val === null) {
ShippedList (val) { this.airLock = false
// console.log(val) } else {
this.airLock = true
}
} }
} }
} }