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