【类 型】:refacotr

【主	题】:飞机操作模块 取消任务 已送达的功能
【描	述】:
	[原因]:
	[过程]:找当当前飞机正在执行的任务 改变订单状态 站点的飞机注册航线状态 飞机单片机的状态
	[影响]:
【结	束】

# 类型 包含:
# feat:新功能(feature)
# fix:修补bug
# docs:文档(documentation)
# style: 格式(不影响代码运行的变动)
# refactor:重构(即不是新增功能,也不是修改bug的代码变动)
# test:增加测试
# chore:构建过程或辅助工具的变动
This commit is contained in:
tk 2024-07-11 20:29:12 +08:00
parent 5bbbf21d5a
commit 95058b6e63
5 changed files with 79 additions and 52 deletions

View File

@ -98,7 +98,7 @@
<el-button-group>
<el-button size="mini" class="f-s-14" type="danger" icon="iconfont icon-meiyoudingdan-01" key="celBUt"
@click="reQuest">
<font class="m-l-5">未送达</font>
<font class="m-l-5">取消任务</font>
</el-button>
<el-button size="mini" class="f-s-14" type="success" icon="iconfont icon-qiandai" key="bingBut"
@click="overQuest">
@ -301,8 +301,9 @@ export default {
/**
* @description: 已发货 订单列表
*/
overQuestList () {
return this.$store.state.paidOrderList.filter((item) => item.status === 'shipped')
ShippedList () {
const plane = this.plane
return plane ? this.$store.state.paidOrderList.filter((item) => item.shop_id === plane.shop_id && item.shipment_status === '已发货') : []
},
/**
* @description: 当前选中的订单
@ -501,7 +502,7 @@ export default {
}
let res = await this.questAss(this.currentOrder.id, 'shipment_status', '已发货')//
if (res.data.status === 1) {
res = await this.$store.dispatch('fetchLockSite', { id: this.currentOrder.receive_site_id, shop_id: this.plane.shop_id, plane_id: this.plane.id, runing: newRuning })// 线
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) {
this.publishFun(`{"questAss":${routeData}}`)//
this.speakText('提交任务,注册航线。')
@ -548,25 +549,42 @@ export default {
*/
reQuest () {
if (!this.airLock) { // ""
this.$message.warning('当前没有执行任务')
return
}
this.$confirm('确认复位飞机状态,并清除航线的锁定?', '取消任务', {
this.$confirm('取消已发货状态,并使飞机复位?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
this.overQuestList.forEach((item) => {
if (item.runing === this.plane.id) {
/* 插入日志 */
this.$store.dispatch('fetchLog', { content: `订单ID${item.id},送餐任务取消。` })
/* 执行写在这里 */
this.publishFun('{"resetState":1}')//
this.questAss(item.id, 'status', 'pending')//
this.$store.dispatch('fetchLockSite', { id: item.receive_site_id, runing: 'null' })// 线
this.questForm.id = ''//
speakText('任务取消,退回未备货状态')
}
/* 关联当前订单的站点 搜寻注册的飞机 并预设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.questAss(orderId, 'shipment_status', '已接单').then(res => { // 退
if (res.data.status === 1) {
this.$store.dispatch('fetchLockSite', { id: receiveSiteId, shop_id: this.plane.shop_id, runing: newRuning }).then(res => { // 线
if (res.data.status === 1) {
this.publishFun('{"resetState":1}')//
}
})
}
})
}
}).catch(() => {
this.$message.info('取消操作!')
})
@ -576,25 +594,42 @@ export default {
*/
overQuest () {
if (!this.airLock) { // ""
this.$message.warning('当前没有执行任务')
return
}
this.$confirm('确认订单状态改为已送达?', '提示', {
this.$confirm('确认订单已送达?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
//
this.questList.map((item) => {
if (item.runing === this.plane.id) { //
/* 插入日志 */
this.$store.dispatch('fetchLog', { content: `订单ID${item.id} 送餐任务已完成。` })
/* 执行写在这里 */
this.publishFun('{"resetState":1}')//
this.questAss(item.id, 'shipment_status', '已送达')//
this.$store.dispatch('fetchLockSite', { id: item.receive_site_id, runing: 'null' })// 线
this.speakText('任务完成')
}
/* 关联当前订单的站点 搜寻注册的飞机 并预设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.questAss(orderId, 'shipment_status', '已送达').then(res => { //
if (res.data.status === 1) {
this.$store.dispatch('fetchLockSite', { id: receiveSiteId, shop_id: this.plane.shop_id, runing: newRuning }).then(res => { // 线
if (res.data.status === 1) {
this.publishFun('{"resetState":1}')//
}
})
}
})
}
}).catch(() => {
this.$message.info('取消操作!')
})
@ -659,7 +694,9 @@ export default {
watch: {
airLock (val) {
if (val) { // 线
this.makeRouteForMap()
if (this.siteList) {
this.makeRouteForMap()
}
} else { // 线
this.$emit('clearRoute')
}

View File

@ -75,7 +75,7 @@ export default {
mounted () {
this.init().then(() => { //
this.map.on('load', () => {
// sprite
/* 更新样式,添加自定义 sprite */
//
this.map.setFog({
@ -142,7 +142,7 @@ export default {
*/
async init () {
// token
mapboxgl.accessToken = 'pk.eyJ1Ijoic3pkb3QiLCJhIjoiY2xhNXpjd3IxMG9leTNubjg3dnFhZm84ZyJ9.ubUTyh6ZR87qyndE5adgvw'
mapboxgl.accessToken = 'pk.eyJ1Ijoic3pkb3QiLCJhIjoiY2xhN2pkMWFoMHJ4eTN3cXp6bmlzaHZ0NCJ9.3hH-EAUr0wQCaLvIM2lBMQ'
// map
this.map = new mapboxgl.Map({
container: 'map',

View File

@ -1,29 +1,29 @@
<template>
<el-row class="m-15" type="flex" justify="space-between">
<el-col :span="2">
<PublicTag icon="icon-weixing" val="16.88" unit="颗" state="normal" />
<PublicTag icon="icon-weixing" :val="plane.planeState.satCount" unit="颗" state="normal" />
</el-col>
<el-col :span="2">
<PublicTag icon="icon-weixing" val="16.88" unit="颗" state="normal" />
<PublicTag icon="icon-weixing" :val="plane.planeState.voltagBattery" unit="V" state="normal" />
</el-col>
<el-col :span="2">
<PublicTag icon="icon-weixing" val="16.88" unit="颗" state="normal" />
<PublicTag icon="icon-weixing" :val="plane.planeState.loadweight" unit="克" state="normal" />
</el-col>
<el-col :span="2">
<PublicTag icon="icon-gaodu" val="50" unit="米" state="normal" />
<PublicTag icon="icon-gaodu" :val="plane.planeState.state" unit="状" state="normal" />
</el-col>
<el-col :span="3">
<HeartTag :heartBeat="planeState.heartBeat" :heartRandom="planeState.heartRandom"
:getPlaneMode="planeState.getPlaneMode" />
<HeartTag :heartBeat="plane.planeState.heartBeat" :heartRandom="plane.planeState.heartRandom"
:getPlaneMode="plane.planeState.getPlaneMode" />
</el-col>
<el-col :span="2">
<PublicTag icon="icon-mianxingdiaogou" :val="planeState.state" unit="" state="normal" />
<PublicTag icon="icon-mianxingdiaogou" :val="plane.planeState.hookstatus" unit="" state="normal" />
</el-col>
<el-col :span="2">
<PublicTag icon="icon-gaodu" :val="planeState.groundSpeed" unit="米" state="normal" />
<PublicTag icon="icon-gaodu" :val="plane.planeState.positionAlt" unit="米" state="normal" />
</el-col>
<el-col :span="2">
<PublicTag icon="icon-gaodu" val="50" unit="米" state="danger" />
<PublicTag icon="icon-gaodu" :val="plane.planeState.fixType" unit="" state="danger" />
</el-col>
<el-col :span="2">
<PublicTag icon="icon-gaodu" val="50" unit="米" state="danger" />
@ -39,8 +39,6 @@ export default {
name: 'PlaneStatus',
data () {
return {
planesId: this.$route.params.id,
planeState: {}
}
},
props: {
@ -56,18 +54,9 @@ export default {
computed: {
},
watch: {
plane: {
handler (val) {
this.planeState = val.planeState
},
deep: true
}
},
methods: {},
created () {
if (this.plane) {
this.planeState = this.plane.planeState
}
}
}
</script>

View File

@ -401,6 +401,7 @@ const store = new Vuex.Store({
async fetchLockSite ({ dispatch }, form) {
const params = new URLSearchParams()
params.append('id', form.id)
params.append('shop_id', form.shop_id)
params.append('runing', form.runing)
const res = await api.post('lockSite', params)
if (res.data.status === 1) {

View File

@ -69,7 +69,7 @@ export default {
}
this.$refs.mapbox.removePlanes()//
this.$refs.mapbox.makePlane(plane)//
this.$refs.mapbox.goto({ lng: plane.lng, lat: plane.lat })//
// this.$refs.mapbox.goto({ lng: plane.lng, lat: plane.lat })//
},
/**
* @description: 创建航线