【类 型】:fix 任务提交 取消 完成 用事务 操作表
【原 因】:会同时操作 站点表的航线绑定 还是造作订单表 的订单状态等 【过 程】: 【影 响】:
This commit is contained in:
parent
b0de7b20ac
commit
7096eb0ff2
@ -82,15 +82,13 @@
|
||||
:loading="true" disabled>
|
||||
<font class="m-l-5">航点写入中···</font>
|
||||
</el-button>
|
||||
<el-button size="mini" class="f-s-14"
|
||||
v-else-if="plane.planeState.state & 4" type="warning"
|
||||
<el-button size="mini" class="f-s-14" v-else-if="plane.planeState.state & 4" type="warning"
|
||||
icon="f-s-14 iconfont icon-jiesuo"
|
||||
@click="publishFun('{setPlaneState:{bit:3,state:1,count:2,param:[1,0]}}'); speakText('解锁飞机')">
|
||||
<font class="m-l-5">解锁飞机</font>
|
||||
</el-button>
|
||||
<el-button size="mini" class="f-s-14"
|
||||
v-else-if="plane.planeState.state & 16"
|
||||
type="success" icon="f-s-14 iconfont icon-yangshi_icon_tongyong_departure"
|
||||
<el-button size="mini" class="f-s-14" v-else-if="plane.planeState.state & 16" type="success"
|
||||
icon="f-s-14 iconfont icon-yangshi_icon_tongyong_departure"
|
||||
@click="publishFun('{setPlaneState:{bit:5,state:1}'); speakText('准备起飞,执行送餐任务')">
|
||||
<font class="m-l-5">执行任务</font>
|
||||
</el-button>
|
||||
@ -259,7 +257,7 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { questAss } from '@/utils/api/table'
|
||||
import { lockSite } from '@/utils/api/table'
|
||||
import mqtt from '@/utils/mqtt'
|
||||
import { speakText } from '@/utils/index'
|
||||
|
||||
@ -348,7 +346,6 @@ export default {
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
questAss,
|
||||
speakText,
|
||||
/**
|
||||
* @description: 摄像头 滑动条松开
|
||||
@ -417,90 +414,99 @@ export default {
|
||||
}
|
||||
},
|
||||
/**
|
||||
* @description: 执行任务前 先检测订单是否 合法 例如:订单重量会不会超出飞机载重上限
|
||||
*/
|
||||
* @description: 执行任务前 先检测订单是否合法,例如:订单重量会不会超出飞机载重上限
|
||||
*/
|
||||
checkQuest () {
|
||||
let checkOrder // 提交要检查的任务
|
||||
// 有正在执行的 检查正在执行的 否则检查当前选中的
|
||||
let checkOrder // 要检查的订单
|
||||
// 如果有正在执行的订单,检查正在执行的;否则检查当前选中的订单
|
||||
if (this.executeOrder) {
|
||||
checkOrder = this.executeOrder
|
||||
} else {
|
||||
checkOrder = this.currentOrder
|
||||
}
|
||||
// 检查是否选则了 订单
|
||||
|
||||
// 检查是否选择了订单
|
||||
if (this.questForm.id === '' && !checkOrder) {
|
||||
this.$message.error('未选择订单任务!')
|
||||
return
|
||||
}
|
||||
// 退款状态检查
|
||||
|
||||
// 检查订单是否在退款状态
|
||||
if (checkOrder.refund_status === '申请中') {
|
||||
this.$message.error('此订单已被申请退款或者订单已经被取消!')
|
||||
return
|
||||
}
|
||||
// 判断站点是否已经绑定站点 未绑定 中断操作
|
||||
|
||||
// 检查站点是否已经绑定任务航点
|
||||
if (checkOrder.bind_route === null) {
|
||||
this.$message.error('此站点,未绑定任务航点')
|
||||
return
|
||||
}
|
||||
|
||||
/* 如果是正在执行订单 直接调用重新提交 */
|
||||
// 如果有正在执行的订单,直接调用重新提交
|
||||
if (this.executeOrder) {
|
||||
this.continueQuest()
|
||||
return
|
||||
}
|
||||
|
||||
/* 综合检查 这部分针对 新提交订单 */
|
||||
// 飞机载重 上限检查
|
||||
/* 综合检查,针对新提交订单 */
|
||||
// 飞机载重上限检查
|
||||
const weightCheck = new Promise((resolve, reject) => {
|
||||
if (Number(checkOrder.total_weight) >= Number(this.plane.weight_max)) {
|
||||
// 如果订单总重超出飞机载重上限,显示确认弹窗
|
||||
this.$confirm('此订单总重超出本飞机的载重上限', '检测订单', {
|
||||
confirmButtonText: '继续',
|
||||
cancelButtonText: '放弃',
|
||||
type: 'warning'
|
||||
})
|
||||
.then(() => {
|
||||
resolve()
|
||||
resolve() // 用户选择继续
|
||||
})
|
||||
.catch(action => {
|
||||
.catch(() => {
|
||||
this.$message({
|
||||
type: 'info',
|
||||
message: '取消提交订单'
|
||||
})
|
||||
reject(new Error('Weight check failed'))
|
||||
reject(new Error('Weight check failed')) // 用户取消操作
|
||||
})
|
||||
} else {
|
||||
resolve()
|
||||
resolve() // 如果重量没有超出限制,直接通过检查
|
||||
}
|
||||
})
|
||||
|
||||
// 检查站点是否有飞机正在执行
|
||||
const runningCheck = new Promise((resolve, reject) => {
|
||||
if ((checkOrder.runing ?? '').split(',').some(item => item !== '')) {
|
||||
this.$confirm('此订单的目标站点,已经有飞机正在执行任务。请注意安全!', '检测订单', {
|
||||
confirmButtonText: '继续',
|
||||
cancelButtonText: '放弃',
|
||||
type: 'warning'
|
||||
})
|
||||
.then(() => {
|
||||
resolve()
|
||||
const runningCheck = weightCheck.then(() => {
|
||||
return new Promise((resolve, reject) => {
|
||||
if ((checkOrder.runing ?? '').split(',').some(item => item !== '')) {
|
||||
// 如果站点已经有飞机在执行任务,显示确认弹窗
|
||||
this.$confirm('此订单的目标站点,已经有飞机正在执行任务。请注意安全!', '检测订单', {
|
||||
confirmButtonText: '继续',
|
||||
cancelButtonText: '放弃',
|
||||
type: 'warning'
|
||||
})
|
||||
.catch(action => {
|
||||
this.$message({
|
||||
type: 'info',
|
||||
message: '取消提交订单'
|
||||
.then(() => {
|
||||
resolve() // 用户选择继续
|
||||
})
|
||||
reject(new Error('Running check failed'))
|
||||
})
|
||||
} else {
|
||||
resolve()
|
||||
}
|
||||
.catch(() => {
|
||||
this.$message({
|
||||
type: 'info',
|
||||
message: '取消提交订单'
|
||||
})
|
||||
reject(new Error('Running check failed')) // 用户取消操作
|
||||
})
|
||||
} else {
|
||||
resolve() // 如果没有飞机正在执行任务,直接通过检查
|
||||
}
|
||||
})
|
||||
})
|
||||
// 选择订单检查 执行订单任务
|
||||
Promise.all([weightCheck, runningCheck])
|
||||
|
||||
// 选择订单检查并执行任务
|
||||
runningCheck
|
||||
.then(() => {
|
||||
this.runQuest()
|
||||
this.runQuest() // 如果所有检查通过,执行任务
|
||||
})
|
||||
.catch((error) => {
|
||||
console.log(error.message)
|
||||
console.log(error.message) // 处理检查失败的情况
|
||||
})
|
||||
},
|
||||
/**
|
||||
@ -582,12 +588,17 @@ export default {
|
||||
this.$message.error('操作失败,航线异常')
|
||||
return
|
||||
}
|
||||
let res = await this.$store.dispatch('fetchLockSite', { id: this.currentOrder.receive_site_id, shop_id: this.plane.shop_id, runing: newRuning })// 航线注册飞机 锁定送餐点
|
||||
// 站点表 和 订单表 同时修改 没问题 向飞机提交航点
|
||||
const res = await lockSite({
|
||||
site_id: this.currentOrder.receive_site_id,
|
||||
shop_id: this.plane.shop_id,
|
||||
runing: newRuning,
|
||||
order_id: this.currentOrder.id,
|
||||
shipment_status: '已发货',
|
||||
by_plane_id: this.plane.id
|
||||
})
|
||||
if (res.data.status === 1) {
|
||||
res = await this.questAss(this.currentOrder.id, ['shipment_status', 'by_plane_id'], ['已发货', this.plane.id])// 订单改为发货状态和执行订 并更新订单列表
|
||||
if (res.data.status === 1) {
|
||||
this.publishFun(routeData)// 发送航点信息主题
|
||||
}
|
||||
this.publishFun(routeData)// 发送航点信息主题
|
||||
}
|
||||
},
|
||||
/**
|
||||
@ -626,78 +637,93 @@ export default {
|
||||
/**
|
||||
* @description: 取消任务
|
||||
*/
|
||||
reQuest () {
|
||||
async reQuest () {
|
||||
if (!this.executeOrder) { // 只有飞机锁定状态 才向下执行 "取消"操作
|
||||
this.$message.warning('当前没有执行任务')
|
||||
return
|
||||
}
|
||||
this.$confirm('取消已发货状态,并使飞机复位?', '提示', {
|
||||
confirmButtonText: '确定',
|
||||
cancelButtonText: '取消',
|
||||
type: 'warning'
|
||||
}).then(() => {
|
||||
/* 关联当前订单的站点 搜寻注册的飞机 并预设newRuning 用于注销runing字段航线 */
|
||||
// 分割字符串成数组
|
||||
const runingArray = this.executeOrder.runing.split(',')
|
||||
// 遍历数组并替换相等的值
|
||||
for (let i = 0; i < runingArray.length; i++) {
|
||||
if (runingArray[i] === this.executeOrder.by_plane_id) {
|
||||
runingArray[i] = ''
|
||||
try {
|
||||
const confirmation = await this.$confirm('取消已发货状态,并使飞机复位?', '提示', {
|
||||
confirmButtonText: '确定',
|
||||
cancelButtonText: '取消',
|
||||
type: 'warning'
|
||||
})
|
||||
|
||||
if (confirmation) {
|
||||
// 分割字符串成数组
|
||||
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(',')
|
||||
// 站点表 和 订单表 同时修改 没问题 让飞机状态复位
|
||||
const res = await lockSite({
|
||||
site_id: this.executeOrder.receive_site_id,
|
||||
shop_id: this.plane.shop_id,
|
||||
runing: newRuning,
|
||||
order_id: this.executeOrder.id,
|
||||
shipment_status: '已接单',
|
||||
by_plane_id: 'null'
|
||||
})
|
||||
|
||||
if (res.data.status === 1) {
|
||||
this.publishFun('{"resetState":1}') // 发送设置飞机状态主题 状态设为闲置
|
||||
}
|
||||
}
|
||||
// 将数组重新组合成字符串
|
||||
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', 'by_plane_id'], ['已接单', 'null']).then(res => { // 注销航线
|
||||
if (res.data.status === 1) {
|
||||
this.publishFun('{"resetState":1}')// 发送设置飞机状态主题 状态设为闲置
|
||||
}
|
||||
})
|
||||
}
|
||||
})
|
||||
}).catch(() => {
|
||||
} catch (error) {
|
||||
this.$message.info('取消操作!')
|
||||
})
|
||||
}
|
||||
},
|
||||
/**
|
||||
* @description: 已送达任务
|
||||
*/
|
||||
overQuest () {
|
||||
if (!this.executeOrder) { // 只有飞机锁定状态 才向量下执行 "已送达"操作
|
||||
* @description: 已送达任务
|
||||
*/
|
||||
async overQuest () {
|
||||
if (!this.executeOrder) {
|
||||
this.$message.warning('当前没有执行任务')
|
||||
return
|
||||
}
|
||||
this.$confirm('确认订单已送达?', '提示', {
|
||||
confirmButtonText: '确定',
|
||||
cancelButtonText: '取消',
|
||||
type: 'warning'
|
||||
}).then(() => {
|
||||
/* 关联当前订单的站点 搜寻注册的飞机 并预设newRuning 用于注销runing字段航线 */
|
||||
// 分割字符串成数组
|
||||
const runingArray = this.executeOrder.runing.split(',')
|
||||
// 遍历数组并替换相等的值
|
||||
for (let i = 0; i < runingArray.length; i++) {
|
||||
if (runingArray[i] === this.executeOrder.by_plane_id) {
|
||||
runingArray[i] = ''
|
||||
|
||||
try {
|
||||
const confirmation = await this.$confirm('确认订单已送达?', '提示', {
|
||||
confirmButtonText: '确定',
|
||||
cancelButtonText: '取消',
|
||||
type: 'warning'
|
||||
})
|
||||
|
||||
if (confirmation) {
|
||||
// 分割字符串成数组
|
||||
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(',')
|
||||
|
||||
// 站点表 和 订单表 同时修改 没问题 让飞机状态复位
|
||||
const res = await lockSite({
|
||||
site_id: this.executeOrder.receive_site_id,
|
||||
shop_id: this.plane.shop_id,
|
||||
runing: newRuning,
|
||||
order_id: this.executeOrder.id,
|
||||
shipment_status: '已送达',
|
||||
by_plane_id: this.plane.id
|
||||
})
|
||||
|
||||
if (res.data.status === 1) {
|
||||
this.publishFun('{"resetState":1}') // 发送设置飞机状态主题 状态设为闲置
|
||||
}
|
||||
}
|
||||
// 将数组重新组合成字符串
|
||||
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(() => {
|
||||
} catch (error) {
|
||||
console.error('Confirmation dialog error:', error)
|
||||
this.$message.info('取消操作!')
|
||||
})
|
||||
}
|
||||
},
|
||||
/**
|
||||
* @description: 在地图上绘制航线
|
||||
|
@ -395,27 +395,6 @@ const store = new Vuex.Store({
|
||||
Message.warning(res.data.msg)
|
||||
}
|
||||
},
|
||||
/**
|
||||
* @description: 锁定站点
|
||||
* @param {*} form 表单.站点信息
|
||||
* @return {*} 服务器返回信息
|
||||
*/
|
||||
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) {
|
||||
await dispatch('fetchSiteList')// 刷新站点列表
|
||||
dispatch('fetchRouteList')// 刷新航线列表
|
||||
dispatch('fetchPaidOrderList')// 刷订单点列表
|
||||
Message.success(res.data.msg)
|
||||
} else {
|
||||
Message.error(res.data.msg)
|
||||
}
|
||||
return res
|
||||
},
|
||||
/**
|
||||
* @description: 创建新站点
|
||||
* @param {*} form 表单.站点信息
|
||||
|
@ -19,6 +19,30 @@ export async function apiCrosFrequency (params) {
|
||||
}
|
||||
return res
|
||||
}
|
||||
/**
|
||||
* @description: 锁定站点 相关操作 同步操作订单表 和站点表接口
|
||||
* @param {*} form 表单.站点信息
|
||||
* @return {*} 服务器返回信息
|
||||
*/
|
||||
export async function lockSite (form) {
|
||||
const params = new URLSearchParams()
|
||||
params.append('site_id', form.site_id)
|
||||
params.append('shop_id', form.shop_id)
|
||||
params.append('runing', form.runing)
|
||||
params.append('order_id', form.order_id)
|
||||
params.append('shipment_status', form.shipment_status)
|
||||
params.append('by_plane_id', form.by_plane_id)
|
||||
const res = await api.post('lockSite', params)
|
||||
if (res.data.status === 1) {
|
||||
await store.dispatch('fetchSiteList')// 刷新站点列表
|
||||
store.dispatch('fetchRouteList')// 刷新航线列表
|
||||
store.dispatch('fetchPaidOrderList')// 刷订单点列表
|
||||
Message.success(res.data.msg)
|
||||
} else {
|
||||
Message.error(res.data.msg)
|
||||
}
|
||||
return res
|
||||
}
|
||||
/**
|
||||
* @description: 向改变订单承接任务api 提交数据,参数可以是数组 提交多个字段和字段内容 () ,并更新订单列表
|
||||
* @param {*} id 订单id
|
||||
|
Loading…
Reference in New Issue
Block a user