【类 型】:refactor

【主	题】:任务提交前 检查
【描	述】:
	[原因]:排除意外情况
	[过程]:
	[影响]:
【结	束】

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

View File

@ -406,6 +406,19 @@ export default {
* @description: 执行任务前 先检测订单是否 合法 例如订单重量会不会超出飞机载重上限
*/
checkQuest () {
console.log(this.questForm.id)
if (this.questForm.id === '') {
this.$message.error('未选择订单任务!')
return
}
if (!this.currentOrder) {
this.$message.error('此订单已被申请退款或者订单已经被取消!')
return
}
if (this.currentOrder.bind_route === null) { //
this.$message.error('此站点,未绑定任务航点')
return
}
if (Number(this.currentOrder.total_weight) >= Number(this.plane.weight_max)) { //
this.$confirm('此订单总重超出本飞机的载重上限', '检测订单', {
confirmButtonText: '仍然提交',
@ -449,64 +462,52 @@ export default {
* @description: 执行订单任务
*/
runQuest () {
if (this.questForm.id === '') {
this.$message.error('未选择订单任务!')
return
}
if (this.currentOrder) {
/* 插入日志 */
this.$store.dispatch('fetchLog', { content: `${this.plane.name} 开始执行 订单ID${this.currentOrder.id}、叫餐号:${this.currentOrder.food_sn}号。` })
/* 执行写在这里 */
if (this.currentOrder.bind_route === null) { //
this.$message.error('此站点,未绑定任务航点')
return
}
let routeData
let newRuning // running
try {
/* 站点正在执行任务runing 注册 */
const runing = this.currentOrder.runing.split(',')
let foundEmpty = false
let selIndex // 使线
runing.some((item, index, arr) => {
if (item === '') {
arr[index] = this.planesId
foundEmpty = true
selIndex = index
return true // 退
}
})
newRuning = runing.join(',')
if (!foundEmpty) {
this.$message({
type: 'warning',
message: '此站点执行飞机已达上线,如果想执行请为该站点绑定更多航线'
})
return // 退
/* 插入日志 */
this.$store.dispatch('fetchLog', { content: `${this.plane.name} 开始执行 订单ID${this.currentOrder.id}、叫餐号:${this.currentOrder.food_sn}号。` })
/* 执行写在这里 */
let routeData // 线
let newRuning // running
try {
/* 站点正在执行任务runing 注册 */
const runing = this.currentOrder.runing.split(',')
let foundEmpty = false
let selIndex // 使线
runing.some((item, index, arr) => {
if (item === '') {
arr[index] = this.planesId
foundEmpty = true
selIndex = index
return true // 退
}
/* 航线选择 */
const bindRoute = this.currentOrder.bind_route.split(',')
routeData = this.routeList.find(element => element.id === bindRoute[selIndex]).route_data
routeData = JSON.parse(routeData)//
// $food_sn$
this.currentOrder.telTail = this.currentOrder.tel.substr(-4)// telTail tel
routeData.tasks.forEach((x, index) => {
if (x.sound) {
const str = this.voiceRouteParse(this.currentOrder, x.sound)
routeData.tasks[index].sound = str//
}
})
newRuning = runing.join(',')
if (!foundEmpty) {
this.$message({
type: 'warning',
message: '站点所有航线都已被占用!'
})
routeData = JSON.stringify(routeData)//
} catch (error) {
this.$message.error('操作失败,请重新尝试')
return // 退
}
this.publishFun(`{"questAss":${routeData}}`)//
this.questAss(this.currentOrder.id, 'shipment_status', '已发货')//
this.$store.dispatch('fetchLockSite', { id: this.currentOrder.receive_site_id, runing: newRuning })// 线
this.speakText('提交任务,锁定航线。')
} else {
this.$message.error('此订单已被申请退款或者订单已经被取消!')
/* 航线选择 */
const bindRoute = this.currentOrder.bind_route.split(',')
routeData = this.routeList.find(element => element.id === bindRoute[selIndex]).route_data
routeData = JSON.parse(routeData)//
// $food_sn$
this.currentOrder.telTail = this.currentOrder.tel.substr(-4)// telTail tel
routeData.tasks.forEach((x, index) => {
if (x.sound) {
const str = this.voiceRouteParse(this.currentOrder, x.sound)
routeData.tasks[index].sound = str//
}
})
routeData = JSON.stringify(routeData)//
} catch (error) {
this.$message.error('操作失败,请重新尝试')
}
this.publishFun(`{"questAss":${routeData}}`)//
this.questAss(this.currentOrder.id, 'shipment_status', '已发货')//
this.$store.dispatch('fetchLockSite', { id: this.currentOrder.receive_site_id, runing: newRuning })// 线
this.speakText('提交任务,锁定航线。')
},
/**
* @description: 匹配声音航点字符串 比如$food_sn$ food_sn匹配成 送餐订单里面的对应字段
@ -666,6 +667,13 @@ export default {
}
return false
})
},
questList (val) {
/* 任务列表更新时 判断还有没有当前选择的id 没有就清空 */
const found = val.some(item => item.id === this.questForm.id)
if (!found) {
this.questForm.id = ''
}
}
}