订单提交
This commit is contained in:
parent
e33fffc973
commit
f5bdfcfc6b
|
|
@ -4,3 +4,7 @@ export const getBookCarDetailByMaId = (data: object) => {
|
|||
return post(`/material-mall/bookCar/getBookCarDetailByMaId`, data)
|
||||
}
|
||||
|
||||
// 预约车列表提交
|
||||
export const submitBookCarApi = (data: any) => {
|
||||
return post('/material-mall/order/submitBookCar', data)
|
||||
}
|
||||
|
|
@ -15,7 +15,7 @@
|
|||
<el-row class="cart-th">
|
||||
<el-col :span="2">
|
||||
<div>
|
||||
<el-checkbox v-model="allChecked" @change="onChangeAll"> 全选 </el-checkbox>
|
||||
<el-checkbox v-model="allChecked" @change="onChangeAll" :key="allKey"> 全选 </el-checkbox>
|
||||
</div>
|
||||
</el-col>
|
||||
<el-col :span="8">
|
||||
|
|
@ -174,14 +174,14 @@
|
|||
import Header from '../../components/header/index.vue'
|
||||
import FooterInfo from '../../components/FooterInfo/index.vue'
|
||||
import { ElMessage } from 'element-plus'
|
||||
import { getBookCarDetailByMaId } from '../../http/api/order/index'
|
||||
import { getBookCarDetailByMaId,submitBookCarApi } from '../../http/api/order/index'
|
||||
import moment from 'moment'
|
||||
import { useRoute, useRouter } from 'vue-router'
|
||||
const router = useRouter()
|
||||
const route = useRoute()
|
||||
const pageParams = route.params
|
||||
console.log(pageParams.maId)
|
||||
|
||||
const allKey = ref(0)
|
||||
const protocolChecked = ref<boolean>(false)
|
||||
|
||||
const orderList = ref<any>([])
|
||||
|
|
@ -256,7 +256,7 @@ const allChecked = computed(() => {
|
|||
return orderList.value.every((e: any) => e.isChecked === true)
|
||||
})
|
||||
|
||||
// 已勾选的所有装备
|
||||
// 已勾选的装备数量
|
||||
const amountDevice = computed(() => {
|
||||
let amountNum = 0
|
||||
orderList.value.forEach((e) => {
|
||||
|
|
@ -266,6 +266,16 @@ const amountDevice = computed(() => {
|
|||
})
|
||||
return amountNum
|
||||
})
|
||||
// 已勾选的装备数量
|
||||
const amountDeviceList = computed(() => {
|
||||
let selectList: any = []
|
||||
orderList.value.forEach((e: any) => {
|
||||
if (e.isChecked) {
|
||||
selectList.push(e)
|
||||
}
|
||||
})
|
||||
return selectList
|
||||
})
|
||||
|
||||
// 计算订单总价格
|
||||
const orderAmountPice = computed(() => {
|
||||
|
|
@ -279,16 +289,58 @@ const orderAmountPice = computed(() => {
|
|||
})
|
||||
|
||||
// 提交按钮
|
||||
const onCartSubmit = () => {
|
||||
const onCartSubmit = async () => {
|
||||
|
||||
ElMessage.closeAll()
|
||||
if (amountDevice.value < 1) {
|
||||
ElMessage({
|
||||
showClose: false,
|
||||
message: '请选择装备',
|
||||
type: 'error',
|
||||
})
|
||||
return
|
||||
}
|
||||
if (!protocolChecked.value) {
|
||||
ElMessage({
|
||||
showClose: false,
|
||||
message: '请阅读公司合同',
|
||||
type: 'error',
|
||||
})
|
||||
return
|
||||
}
|
||||
console.log('提交订单')
|
||||
// 组装参数
|
||||
const detailsList = amountDeviceList.value.map((e: any) => {
|
||||
console.log(e)
|
||||
return {
|
||||
maId: e.maId,
|
||||
id: e.id,
|
||||
rentBeginTime: e.lease_date[0] + ' ' + '00:00:00',
|
||||
rentEndTime: e.lease_date[1] + ' ' + '00:00:00',
|
||||
manageType: e.manageType,
|
||||
days: e.lease_day,
|
||||
num: e.goods_num,
|
||||
costs: e.goods_num * e.dayLeasePrice * e.lease_day,
|
||||
}
|
||||
})
|
||||
|
||||
const submitParams = {
|
||||
cost: orderAmountPice.value,
|
||||
detailsList,
|
||||
}
|
||||
|
||||
const res: any = await submitBookCarApi(submitParams)
|
||||
if (res.code === 200) {
|
||||
ElMessage({
|
||||
showClose: false,
|
||||
message: '提交成功',
|
||||
type: 'success',
|
||||
})
|
||||
allKey.value++
|
||||
router.push({
|
||||
path: `/equipDetail/${pageParams.maId}`,
|
||||
})
|
||||
}
|
||||
|
||||
}
|
||||
</script>
|
||||
|
|
|
|||
Loading…
Reference in New Issue