【类 型】:fix

【主	题】:提交订单是 检测订单重量
【描	述】:
	[原因]:检测订单重量超过飞机承载重量上限  给提示 增加安全保障
	[过程]:
	[影响]:
【结	束】

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

View File

@ -61,7 +61,8 @@
<el-form label-position="left" ref="questForm" :model="questForm" label-width="80px">
<el-form-item label="订单任务">
<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="Number(item.total_weight) >= Number(plane.weight_max) ? 'danger-color' : ''">
<span class="l">{{ item.id }}</span>
<span class="l m-l-5">{{ item.receiver }}</span>
<span class="l m-l-5">{{ item.receive_site_name }}</span>
@ -75,7 +76,7 @@
<font class="m-l-5">航线锁定</font>
</el-button>
<el-button size="mini" class="f-s-14" v-if="planeState & 1 && !airLock" type="primary"
icon="f-s-14 iconfont icon-chakanzhihangrizhi" @click="runQuest">
icon="f-s-14 iconfont icon-chakanzhihangrizhi" @click="checkQuest">
<font class="m-l-5">提交任务</font>
</el-button>
<el-button size="mini" class="f-s-14" v-if="planeState & 2" key="wirteBut" type="info"
@ -312,6 +313,15 @@ export default {
overQuestList () {
return this.$store.state.orderList.filter((item) => item.status === 'shipped')
},
/**
* @description: 当前选中的订单
*/
currentOrder () {
if (this.questForm && this.questForm.id !== undefined) {
return this.questList.find((item) => item.id === this.questForm.id) || null
}
return null
},
/**
* @description: 航线列表
*/
@ -395,6 +405,35 @@ export default {
this.$message.warning('与飞机通信未接通,请稍后')
}
},
/**
* @description: 执行任务前 先检测订单是否 合法 例如订单重量会不会超出飞机载重上限
*/
checkQuest () {
//
if (Number(this.currentOrder.total_weight) >= Number(this.plane.weight_max)) {
this.$confirm('此订单总重超出本飞机的载重上限', '检测订单', {
confirmButtonText: '仍然提交',
cancelButtonText: '放弃提交',
type: 'warning'
})
.then(() => {
this.$message({
type: 'warning',
message: '存在超重风险,仍然提交订单'
})
this.runQuest()//
})
.catch(action => {
this.$message({
type: 'info',
message: '取消提交订单'
})
})
} else {
//
this.runQuest()
}
},
/**
* @description: 执行订单任务
*/
@ -403,42 +442,73 @@ export default {
this.$message.error('未选择订单任务!')
return
}
let i
this.questList.map((item) => {
if (this.questForm.id === item.id) {
i = true
/* 插入日志 */
this.$store.dispatch('fetchLog', { content: `${this.plane.name} 开始执行 订单ID${item.id}、叫餐号:${item.food_sn}号。` })
/* 执行写在这里 */
if (item.bind_route === null) { //
this.$message.error('此站点,未绑定任务航点')
return
}
let routeData
try {
const bindRoute = item.bind_route.split(',')
routeData = this.routeList.find(element => element.id === bindRoute[0]).route_data
routeData = JSON.parse(routeData)//
/* 处理声音航点 航点里面的表达式 如$food_sn$ 正则替换成订单对应的字段 */
item.telTail = item.tel.substr(-4)// telTail tel
routeData.tasks.forEach((x, index) => {
if (x.sound) {
const str = this.voiceRouteParse(item, x.sound)
routeData.tasks[index].sound = str//
}
})
routeData = JSON.stringify(routeData)//
} catch (error) {
this.$message.error('操作失败,请重新尝试')
}
this.publishFun(`{"questAss":${routeData}}`)//
this.questAss(item.id, 'status', 'shipped')//
this.$store.dispatch('fetchLockSite', { id: item.receive_site_id, runing: this.plane.id })// 线
this.speakText('提交任务,锁定航线。')
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
}
})
if (i) { return }
this.$message.error('此订单已被申请退款或者订单已经被取消!')
let routeData
try {
const bindRoute = this.currentOrder.bind_route.split(',')
routeData = this.routeList.find(element => element.id === bindRoute[0]).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, 'status', 'shipped')//
this.$store.dispatch('fetchLockSite', { id: this.currentOrder.receive_site_id, runing: this.plane.id })// 线
this.speakText('提交任务,锁定航线。')
} else {
this.$message.error('此订单已被申请退款或者订单已经被取消!')
}
// let i
// this.questList.map((item) => {
// if (this.questForm.id === item.id) {
// i = true
// /* */
// this.$store.dispatch('fetchLog', { content: `${this.plane.name} ID${item.id}${item.food_sn}` })
// /* */
// if (item.bind_route === null) { //
// this.$message.error('')
// return
// }
// let routeData
// try {
// const bindRoute = item.bind_route.split(',')
// routeData = this.routeList.find(element => element.id === bindRoute[0]).route_data
// routeData = JSON.parse(routeData)//
// /* $food_sn$ */
// item.telTail = item.tel.substr(-4)// telTail tel
// routeData.tasks.forEach((x, index) => {
// if (x.sound) {
// const str = this.voiceRouteParse(item, x.sound)
// routeData.tasks[index].sound = str//
// }
// })
// routeData = JSON.stringify(routeData)//
// } catch (error) {
// this.$message.error(',')
// }
// this.publishFun(`{"questAss":${routeData}}`)//
// this.questAss(item.id, 'status', 'shipped')//
// this.$store.dispatch('fetchLockSite', { id: item.receive_site_id, runing: this.plane.id })// 线
// this.speakText('线')
// }
// })
// if (i) { return }
},
/**
* @description: 匹配声音航点字符串 比如$food_sn$ food_sn匹配成 送餐订单里面的对应字段
@ -577,6 +647,11 @@ export default {
<style lang="scss" scoped>
@import "@/styles/theme.scss";
.danger-color {
color: $danger-color;
font-weight: bold;
}
.tab-container {
height: 365px;
width: 80px;