代码优化
This commit is contained in:
parent
4be105707b
commit
356912fd37
|
|
@ -7,8 +7,8 @@ VITE_API_URL = '/proxyApi'
|
|||
# 开发环境接口地址
|
||||
# VITE_proxyTarget = 'http://10.40.92.74:8080' #盛旭
|
||||
|
||||
# VITE_proxyTarget = 'http://192.168.2.246:28080' # 马帅
|
||||
VITE_proxyTarget = 'http://192.168.0.244:28580' # 马帅
|
||||
VITE_proxyTarget = 'http://192.168.2.246:28080' # 马帅
|
||||
# VITE_proxyTarget = 'http://192.168.0.244:28580' # 马帅
|
||||
# VITE_proxyTarget = 'http://192.168.2.129:18080' # 马帅
|
||||
|
||||
# VITE_proxyTarget = 'http://10.40.92.185:9206' # 赵福海 ( 设备类型)
|
||||
|
|
|
|||
|
|
@ -37,7 +37,16 @@ const navMenuList = computed(() => {
|
|||
})
|
||||
|
||||
const navMenuClick = (name: any) => {
|
||||
router.push({ name })
|
||||
if (name == 'goodsManagement' || name == 'orderManagementCz' || name == 'orderManagement') {
|
||||
store.editcurrentMenuItem(name)
|
||||
setTimeout(() => {
|
||||
router.push({
|
||||
name: 'my-user',
|
||||
})
|
||||
}, 500)
|
||||
} else {
|
||||
router.push({ name })
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
|
|
|
|||
|
|
@ -96,13 +96,18 @@ const onSelectRoles = (type: number) => {
|
|||
if (type === 1) {
|
||||
rolesName.value = '1'
|
||||
userStore.editMenuList(1)
|
||||
userStore.editcurrentMenuItem('goodsManagement')
|
||||
// userStore.editUserMenuList(1)
|
||||
localStorage.setItem('rolesType', '1')
|
||||
|
||||
// window.location.reload()
|
||||
} else {
|
||||
rolesName.value = '2'
|
||||
userStore.editMenuList(2)
|
||||
// userStore.editUserMenuList(2)
|
||||
localStorage.setItem('rolesType', '2')
|
||||
userStore.editcurrentMenuItem('sourcingNeed')
|
||||
// window.location.reload()
|
||||
}
|
||||
|
||||
window.location.reload()
|
||||
|
|
@ -163,7 +168,15 @@ const onCarts = () => {
|
|||
</div>
|
||||
</div>
|
||||
<div class="header-item">
|
||||
<a>个人中心</a>
|
||||
<a
|
||||
@click="
|
||||
() => {
|
||||
router.push({ name: 'my-user' })
|
||||
}
|
||||
"
|
||||
>
|
||||
个人中心</a
|
||||
>
|
||||
</div>
|
||||
<!-- <div class="header-item last-item">
|
||||
<img src="../../assets/img/home/phone.png" alt="" />
|
||||
|
|
|
|||
|
|
@ -117,12 +117,14 @@ const onSelectRoles = (type: number) => {
|
|||
userStore.editMenuList(1)
|
||||
userStore.editUserMenuList(1)
|
||||
localStorage.setItem('rolesType', '1')
|
||||
userStore.editcurrentMenuItem('goodsManagement')
|
||||
window.location.reload()
|
||||
} else {
|
||||
rolesName.value = '2'
|
||||
userStore.editMenuList(2)
|
||||
userStore.editUserMenuList(2)
|
||||
localStorage.setItem('rolesType', '2')
|
||||
userStore.editcurrentMenuItem('sourcingNeed')
|
||||
window.location.reload()
|
||||
}
|
||||
isRolesSelect.value = false
|
||||
|
|
|
|||
|
|
@ -203,7 +203,7 @@ const routes: Array<RouteRecordRaw> = [
|
|||
children: [
|
||||
|
||||
{
|
||||
path: 'orderManagementCz',
|
||||
path: '/orderManagementCz',
|
||||
name: 'orderManagementCz',
|
||||
component: () => import('views/user/orderManagementCz/index.vue'),
|
||||
meta: {
|
||||
|
|
@ -214,7 +214,7 @@ const routes: Array<RouteRecordRaw> = [
|
|||
},
|
||||
},
|
||||
{
|
||||
path: 'goodsManagement',
|
||||
path: '/goodsManagement',
|
||||
name: 'goodsManagement',
|
||||
component: () => import('views/user/goodsManagement/index.vue'),
|
||||
meta: {
|
||||
|
|
@ -225,7 +225,7 @@ const routes: Array<RouteRecordRaw> = [
|
|||
},
|
||||
},
|
||||
{
|
||||
path: 'accept-orders',
|
||||
path: '/accept-orders',
|
||||
name: 'accept-orders',
|
||||
component: () => import('views/user/accept-orders/index.vue'),
|
||||
meta: {
|
||||
|
|
@ -236,7 +236,7 @@ const routes: Array<RouteRecordRaw> = [
|
|||
},
|
||||
},
|
||||
{
|
||||
path: 'sourcingNeed',
|
||||
path: '/sourcingNeed',
|
||||
name: 'sourcingNeed',
|
||||
component: () => import('views/user/sourcingNeed/index.vue'),
|
||||
meta: {
|
||||
|
|
@ -247,7 +247,7 @@ const routes: Array<RouteRecordRaw> = [
|
|||
},
|
||||
},
|
||||
{
|
||||
path: 'orderManagement',
|
||||
path: '/orderManagement',
|
||||
name: 'orderManagement',
|
||||
component: () => import('views/user/orderManagement/index.vue'),
|
||||
meta: {
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ export const useStore = defineStore('myUser', {
|
|||
state: () => {
|
||||
return {
|
||||
currentMenuType: true,
|
||||
currentMenuItem: 'baseInfo',
|
||||
currentMenuItem: 'goodsManagement',
|
||||
menuList: [
|
||||
{ title: '基础信息', name: 'baseInfo' },
|
||||
{ title: '订单管理', name: 'orderManagement' },
|
||||
|
|
|
|||
|
|
@ -223,6 +223,8 @@ import {
|
|||
import moment, { max } from 'moment'
|
||||
import { InfoFilled } from '@element-plus/icons-vue'
|
||||
import CustomDatePickerButton from './components/date-picker-button.vue'
|
||||
import { useRoute, useRouter } from 'vue-router'
|
||||
const router = useRouter()
|
||||
|
||||
const protocolChecked = ref<boolean>(false)
|
||||
const allKey = ref(0)
|
||||
|
|
@ -445,9 +447,15 @@ const onCartSubmit = async () => {
|
|||
message: '提交成功',
|
||||
type: 'success',
|
||||
})
|
||||
allKey.value++
|
||||
|
||||
getBookCarDetailsData()
|
||||
userStore.editcurrentMenuItem('goodsManagement')
|
||||
setTimeout(() => {
|
||||
router.push({
|
||||
name: 'my-user',
|
||||
})
|
||||
}, 500)
|
||||
// allKey.value++
|
||||
// getBookCarDetailsData()
|
||||
}
|
||||
// console.log(res, '预约车提交结果')
|
||||
}
|
||||
|
|
|
|||
|
|
@ -83,7 +83,7 @@
|
|||
:disabled="pageData.isBookCar == 0"
|
||||
:style="pageData.isBookCar == 0 ? 'opacity:0.5' : ''"
|
||||
style="background-color: #1abc9c"
|
||||
v-authBtn="() => openLease"
|
||||
@click="onHandelLessee"
|
||||
>
|
||||
立即承租
|
||||
</el-button>
|
||||
|
|
@ -667,11 +667,11 @@ const rules = reactive({
|
|||
// }
|
||||
|
||||
const openLease = () => {
|
||||
console.log(pageData.value)
|
||||
onAddCart()
|
||||
router.push({
|
||||
path: `/orderConfirm/${pageData.value.maId}`,
|
||||
})
|
||||
// console.log(pageData.value)
|
||||
// onAddCart()
|
||||
// router.push({
|
||||
// path: `/orderConfirm/${pageData.value.maId}`,
|
||||
// })
|
||||
}
|
||||
//切换收藏状态
|
||||
const collectChange = async () => {
|
||||
|
|
@ -758,6 +758,30 @@ const addressCascader = {
|
|||
},
|
||||
}
|
||||
|
||||
const onHandelLessee = () => {
|
||||
// onAddCart()
|
||||
// router.push({
|
||||
// path: `/orderConfirm/${props.id}`,
|
||||
// })
|
||||
// console.log('立即租赁')
|
||||
|
||||
ElMessageBox.confirm('是否确定立即承租该装备?', '温馨提示', {
|
||||
confirmButtonText: '确定',
|
||||
cancelButtonText: '取消',
|
||||
type: 'success',
|
||||
})
|
||||
.then(async () => {
|
||||
router.push({
|
||||
// path: `/orderConfirm/${props.id}`,
|
||||
name: 'order-confirm',
|
||||
query: {
|
||||
id: route.query.id,
|
||||
},
|
||||
})
|
||||
})
|
||||
.catch(() => {})
|
||||
}
|
||||
|
||||
//获取地址列表
|
||||
const getAddressData = async (code = '') => {
|
||||
let params = {}
|
||||
|
|
|
|||
|
|
@ -47,11 +47,11 @@
|
|||
<el-row style="border-bottom: 1px solid #ccc">
|
||||
<el-col :span="1">
|
||||
<div style="text-align: center">
|
||||
<el-checkbox
|
||||
<!-- <el-checkbox
|
||||
v-model="item.isChecked"
|
||||
@change="onChangeCompany($event, index, item)"
|
||||
>
|
||||
</el-checkbox>
|
||||
</el-checkbox> -->
|
||||
</div>
|
||||
</el-col>
|
||||
<el-col :span="22" class="cart-user-info">
|
||||
|
|
@ -78,14 +78,28 @@
|
|||
</el-col>
|
||||
<el-col :span="4">
|
||||
<div class="lease-date">
|
||||
<div>{{ item.lease_date_string }}</div>
|
||||
<el-date-picker
|
||||
<!-- <div>{{ item.lease_date_string }}</div> -->
|
||||
<div style="margin-bottom: 8px">
|
||||
{{ item.rentBeginTime }}
|
||||
<span v-if="item.rentBeginTime && item.rentEndTime">-</span>
|
||||
{{ item.rentEndTime }}
|
||||
</div>
|
||||
<!-- <el-date-picker
|
||||
style="width: 100px; margin-top: 10px"
|
||||
v-model="item.lease_date"
|
||||
type="daterange"
|
||||
size="small"
|
||||
value-format="YYYY-MM-DD"
|
||||
@change="onLeaseDateChange($event, item)"
|
||||
/> -->
|
||||
<CustomDatePickerButton
|
||||
:modelValue="item.lease_date"
|
||||
:companyIndex="index"
|
||||
:goodsIndex="index"
|
||||
type="primary"
|
||||
size="large"
|
||||
placeholder="选择日期"
|
||||
@onLeaseDateChange="onLeaseDateChange"
|
||||
/>
|
||||
</div>
|
||||
</el-col>
|
||||
|
|
@ -119,7 +133,7 @@
|
|||
<div>
|
||||
<el-button
|
||||
@click="onDeleteGoods(index)"
|
||||
type="text"
|
||||
link
|
||||
style="color: #ff4800; font-weight: bold"
|
||||
>
|
||||
删除
|
||||
|
|
@ -175,6 +189,7 @@ import Header from '../../components/header/index.vue'
|
|||
import FooterInfo from '../../components/FooterInfo/index.vue'
|
||||
import { ElMessage } from 'element-plus'
|
||||
import { getBookCarDetailByMaId, submitBookCarApi } from '../../http/api/order/index'
|
||||
import CustomDatePickerButton from '../cart/components/date-picker-button.vue'
|
||||
import { getDetail } from 'http/api/equip'
|
||||
import moment from 'moment'
|
||||
import { useRoute, useRouter } from 'vue-router'
|
||||
|
|
@ -196,24 +211,14 @@ const getOrderListData = async () => {
|
|||
orderList.value = []
|
||||
// orderList.value = res.data
|
||||
|
||||
const { companyName, person, picUrl, personPhone, deviceName, code, typeName, dayLeasePrice } =
|
||||
res.data
|
||||
|
||||
// 组装参数
|
||||
const orderInfo = {
|
||||
companyName,
|
||||
person,
|
||||
personPhone,
|
||||
deviceName,
|
||||
code,
|
||||
typeName,
|
||||
picUrl,
|
||||
rentBeginTime: '',
|
||||
rentEndTime: '',
|
||||
lease_date: '',
|
||||
dayLeasePrice,
|
||||
days: 0,
|
||||
num: 1,
|
||||
...res.data,
|
||||
}
|
||||
|
||||
orderList.value.push(orderInfo)
|
||||
|
|
@ -237,9 +242,22 @@ onMounted(() => {
|
|||
})
|
||||
|
||||
// 日期change事件
|
||||
const onLeaseDateChange = (e: any, item: any) => {
|
||||
item.lease_date_string = `${e[0]}至${e[1]}`
|
||||
item.lease_day = moment(e[1]).diff(e[0], 'day')
|
||||
// const onLeaseDateChange = (e: any, item: any) => {
|
||||
// item.lease_date_string = `${e[0]}至${e[1]}`
|
||||
// item.lease_day = moment(e[1]).diff(e[0], 'day')
|
||||
// }
|
||||
const onLeaseDateChange = (value: any, companyIndex: number, goodsIndex: number) => {
|
||||
orderList.value.forEach((e: any) => {
|
||||
if (!value) {
|
||||
e.rentBeginTime = ''
|
||||
e.rentEndTime = ''
|
||||
e.days = 0
|
||||
} else {
|
||||
e.rentBeginTime = value[0]
|
||||
e.rentEndTime = value[1]
|
||||
e.days = moment(value[1]).diff(value[0], 'day')
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
// 删除按钮
|
||||
|
|
@ -283,13 +301,13 @@ const allChecked = computed(() => {
|
|||
|
||||
// 已勾选的装备数量
|
||||
const amountDevice = computed(() => {
|
||||
let amountNum = 0
|
||||
orderList.value.forEach((e) => {
|
||||
if (e.isChecked) {
|
||||
amountNum++
|
||||
}
|
||||
})
|
||||
return amountNum
|
||||
// let amountNum = 0
|
||||
// orderList.value.forEach((e) => {
|
||||
// if (e.isChecked) {
|
||||
// amountNum++
|
||||
// }
|
||||
// })
|
||||
return 1
|
||||
})
|
||||
// 已勾选的装备数量
|
||||
const amountDeviceList = computed(() => {
|
||||
|
|
@ -306,26 +324,27 @@ const amountDeviceList = computed(() => {
|
|||
const orderAmountPice = computed(() => {
|
||||
let orderAmountPice = 0
|
||||
orderList.value.forEach((e) => {
|
||||
if (e.isChecked) {
|
||||
orderAmountPice = e.goods_num * e.dayLeasePrice * e.lease_day + orderAmountPice
|
||||
}
|
||||
// if (e.isChecked) {
|
||||
|
||||
// }
|
||||
orderAmountPice = e.num * e.dayLeasePrice * e.days
|
||||
})
|
||||
return orderAmountPice
|
||||
})
|
||||
|
||||
// 提交按钮
|
||||
const onCartSubmit = async () => {
|
||||
ElMessage.closeAll()
|
||||
if (amountDevice.value < 1) {
|
||||
ElMessage({
|
||||
showClose: false,
|
||||
message: '请选择装备',
|
||||
type: 'error',
|
||||
})
|
||||
return
|
||||
}
|
||||
console.log(amountDeviceList.value[0].lease_date == undefined)
|
||||
if (amountDeviceList.value[0].lease_date == undefined) {
|
||||
// ElMessage.closeAll()
|
||||
// if (amountDevice.value < 1) {
|
||||
// ElMessage({
|
||||
// showClose: false,
|
||||
// message: '请选择装备',
|
||||
// type: 'error',
|
||||
// })
|
||||
// return
|
||||
// }
|
||||
// console.log(amountDeviceList.value[0].lease_date == undefined)
|
||||
if (orderList.value[0].days < 1) {
|
||||
ElMessage({
|
||||
showClose: false,
|
||||
message: '请选择租期',
|
||||
|
|
@ -342,25 +361,21 @@ const onCartSubmit = async () => {
|
|||
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 orderInfo = orderList.value[0]
|
||||
const submitInfo = {
|
||||
maId: orderInfo.maId,
|
||||
id: orderInfo.id,
|
||||
rentBeginTime: orderInfo.rentBeginTime + ' ' + '00:00:00',
|
||||
rentEndTime: orderInfo.rentEndTime + ' ' + '00:00:00',
|
||||
manageType: orderInfo.manageType,
|
||||
days: orderInfo.days,
|
||||
num: orderInfo.num,
|
||||
costs: orderInfo.num * orderInfo.days * orderInfo.dayLeasePrice,
|
||||
}
|
||||
|
||||
const submitParams = {
|
||||
cost: orderAmountPice.value,
|
||||
detailsList,
|
||||
detailsList: [submitInfo],
|
||||
}
|
||||
console.log('submitParams', submitParams)
|
||||
const res: any = await submitBookCarApi(submitParams)
|
||||
|
|
@ -370,10 +385,16 @@ const onCartSubmit = async () => {
|
|||
message: '提交成功',
|
||||
type: 'success',
|
||||
})
|
||||
allKey.value++
|
||||
router.push({
|
||||
path: `/equipDetail/${pageParams.maId}`,
|
||||
})
|
||||
userStore.editcurrentMenuItem('goodsManagement')
|
||||
setTimeout(() => {
|
||||
router.push({
|
||||
name: 'my-user',
|
||||
})
|
||||
}, 500)
|
||||
|
||||
// router.push({
|
||||
// path: `/equipDetail/${pageParams.maId}`,
|
||||
// })
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
|
|
|||
|
|
@ -71,8 +71,11 @@ const menuList: any = computed(() => {
|
|||
return allList.filter((e) => e.permission.includes(isType.value))
|
||||
})
|
||||
|
||||
const activeItem = computed(() => {
|
||||
return store.currentMenuItem
|
||||
})
|
||||
router.push({
|
||||
name: menuList.value[0].name,
|
||||
name: activeItem.value,
|
||||
})
|
||||
|
||||
onMounted(() => {
|
||||
|
|
|
|||
Loading…
Reference in New Issue