Zlpt_Portal_h5/src/pages/order-settlement/index.vue

356 lines
13 KiB
Vue

<template>
<!-- 订单详情-->
<view class="h5-container order-reduction">
<view
style="
padding: 15px 0;
display: flex;
align-items: center;
justify-content: space-between;
"
>
<view>
<van-icon name="arrow-left" @click="onClickLeft" />
<text style="color: #000"> {{ pagesType == 1 ? '费用结算' : '费用清单' }} </text>
</view>
<view v-if="pagesType == 1">
<van-button
size="mini"
type="primary"
class="primary-lease"
style="margin-right: 6px; padding: 10px 20px"
@click="onSubmitSett"
>
确认提交
</van-button>
</view>
</view>
<van-cell-group inset>
<view>订单编号:{{ orderDetails.code }}</view>
<view>装备数量:{{ orderDetails.maNumber }}</view>
<view>结算单位:{{ orderDetails.leaseCompany }}</view>
<view style="text-align: right">
总租金:
<text style="text-align: right; font-size: 18px; color: #ee0a24">
¥{{ orderDetails.totalCost }}
</text>
</view>
</van-cell-group>
<scroll-view scroll-y style="background-color: #fff; padding: 10px; box-sizing: border-box">
<view>
<TitleTip :title="`租赁费用明细`" />
</view>
<view
:key="item.id"
class="items-container"
v-for="(item, index) in orderDetailDtoList"
>
<view class="count-title">
<text></text>
<text style="font-weight: bold">设备{{ index + 1 }}</text>
</view>
<van-cell-group inset>
<van-cell title="装备编号" :value="item.code" />
<van-cell title="装备名称" :value="item.deviceName" />
<van-cell title="装备型号" :value="item.typeName" />
<van-cell title="装备数量" :value="item.num" />
<van-cell title="租赁单价(元/天)" :value="item.dayLeasePrice" />
<van-cell title="租赁天数" :value="item.dateDays" />
<van-cell
title="租期"
:value="`${item.preOutboundTime}至${item.rentOverTime}`"
/>
<van-cell title="租赁费用" :value="item.costs" />
<van-cell title="改价后费用" :value="item.changeCost" />
<!-- <van-cell title="操作改价" /> -->
<van-field
v-model="item.costs"
name="密码"
label="操作改价"
placeholder="请输入改价后费用"
v-if="pagesType == 1"
/>
</van-cell-group>
</view>
<view>
<TitleTip :title="`维修费用明细`" />
</view>
<view :key="item.id" class="items-container" v-for="(item, index) in repairRecordList">
<view class="count-title">
<text></text>
<text style="font-weight: bold">设备{{ index + 1 }}</text>
</view>
<van-cell-group inset>
<van-cell title="装备编号" :value="item.code" />
<van-cell title="装备名称" :value="item.deviceName" />
<van-cell title="装备型号" :value="item.typeName" />
<van-cell title="维修数量" :value="item.repairNum" />
<van-cell title="维修费用(元)" :value="item.repairPrice" />
<van-cell title="改价后费用(元)" :value="item.repairChangePrice" />
<van-cell title="附件" center>
<template #right-icon>
<view
class="view-file"
v-if="item.fileList[0]?.fileName"
@click="onPreviewFile(item.fileList)"
>
点击查看
</view>
<view v-else> 暂无附件 </view>
</template>
</van-cell>
<van-field
v-model="item.repairPrice"
label="操作改价"
placeholder="请输入改价后费用"
v-if="pagesType == 1"
/>
</van-cell-group>
</view>
<van-empty description="暂无数据" v-if="repairRecordList.length === 0" />
<view>
<TitleTip :title="`报废费用明细`" />
</view>
<view :key="item.id" class="items-container" v-for="(item, index) in scrapRecordList">
<view class="count-title">
<text></text>
<text style="font-weight: bold">设备{{ index + 1 }}</text>
</view>
<van-cell-group inset>
<van-cell title="装备编号" :value="item.code" />
<van-cell title="装备名称" :value="item.deviceName" />
<van-cell title="装备型号" :value="item.typeName" />
<van-cell title="报废数量" :value="item.scrapNum" />
<van-cell title="报废原因" :value="item.scrapReason" />
<van-cell title="报废费用(元)" :value="item.scrapPrice" />
<van-cell title="改价后费用(元)" :value="item.scrapChangePrice" />
<van-cell title="附件" center>
<template #right-icon>
<view
class="view-file"
v-if="item.fileList[0]?.fileName"
@click="onPreviewFile(item.fileList)"
>
点击查看
</view>
<view v-else> 暂无附件 </view>
</template>
</van-cell>
<van-field
v-model="item.scrapPrice"
name="密码"
label="操作改价"
placeholder="请输入改价后费用"
v-if="pagesType == 1"
/>
</van-cell-group>
</view>
<van-empty description="暂无数据" v-if="scrapRecordList.length === 0" />
<view>
<TitleTip :title="`丢失费用明细`" />
</view>
<view :key="item.id" class="items-container" v-for="(item, index) in lossRecordList">
<view class="count-title">
<text></text>
<text style="font-weight: bold">设备{{ index + 1 }}</text>
</view>
<van-cell-group inset>
<van-cell title="装备编号" :value="item.code" />
<van-cell title="装备名称" :value="item.deviceName" />
<van-cell title="装备型号" :value="item.typeName" />
<van-cell title="丢失数量" :value="item.lossNum" />
<van-cell title="丢失费用(元)" :value="item.lossPrice" />
<van-cell title="改价后费用(元)" :value="item.lossChangePrice" />
<van-cell title="附件" center>
<template #right-icon>
<view
class="view-file"
v-if="item.fileList[0]?.fileName"
@click="onPreviewFile(item.fileList)"
>
点击查看
</view>
<view v-else> 暂无附件 </view>
</template>
</van-cell>
<van-field
v-model="item.lossPrice"
name="密码"
label="操作改价"
placeholder="请输入改价后费用"
v-if="pagesType == 1"
/>
</van-cell-group>
</view>
<van-empty description="暂无数据" v-if="lossRecordList.length === 0" />
</scroll-view>
</view>
</template>
<script setup>
import TitleTip from '@/components/TitleTip'
import { getOverhaulAPI, setChangePriceAPI } from '@/services/order/index.js'
import { showImagePreview } from 'vant'
import { onLoad } from '@dcloudio/uni-app'
import { ref } from 'vue'
const orderDetails = ref({})
const orderId = ref('')
const orderDetailDtoList = ref({})
const repairRecordList = ref([])
const scrapRecordList = ref([])
const lossRecordList = ref([])
const fileListAll = ref([])
const pagesType = ref(1)
const onClickLeft = () => {
uni.navigateBack()
}
onLoad(async (options) => {
pagesType.value = options?.type
orderId.value = options.orderId
const { data: res } = await getOverhaulAPI({ orderId: options.orderId })
orderDetailDtoList.value = res.orderDetailDtoList
repairRecordList.value = res.repairRecordList.map((e) => {
return {
...e,
fileList: [],
}
})
scrapRecordList.value = res.scrapRecordList.map((e) => {
return {
...e,
fileList: [],
}
})
lossRecordList.value = res.lossRecordList.map((e) => {
return {
...e,
fileList: [],
}
})
fileListAll.value = res.fileInfoList
orderDetails.value = res
fileListAll.value.forEach((e) => {
repairRecordList.value.forEach((j) => {
if (e.modelId == j.maId && e.fileType == 0) {
j.fileList.push({
fileName: e.fileName,
fileUrl: e.fileUrl,
})
}
})
scrapRecordList.value.forEach((j) => {
if (e.modelId == j.maId && e.fileType == 1) {
j.fileList.push({
fileName: e.fileName,
fileUrl: e.fileUrl,
})
}
})
lossRecordList.value.forEach((j) => {
if (e.modelId == j.maId && e.fileType == 2) {
j.fileList.push({
fileName: e.fileName,
fileUrl: e.fileUrl,
})
}
})
})
})
const onSubmitSett = () => {
showConfirmDialog({
title: '提示',
message: '改价只能申请一次,此次提交后将无法再对检修金额进行修改',
})
.then(async () => {
const rentPriceList = orderDetailDtoList.value?.map((e) => {
return {
orderId: orderId.value,
maId: e.maId,
changeCost: e.costs,
}
})
const repairPriceList = repairRecordList.value?.map((e) => {
return {
orderId: orderId.value,
maId: e.maId,
repairChangePrice: e.repairPrice,
}
})
const scrapPriceList = scrapRecordList.value?.map((e) => {
return {
orderId: orderId.value,
maId: e.maId,
scrapChangePrice: e.scrapPrice,
}
})
const lossPriceList = lossRecordList.value?.map((e) => {
return {
orderId: orderId.value,
maId: e.maId,
lossChangePrice: e.lossPrice,
}
})
const changePriceParams = {
rentPriceList,
lossPriceList,
scrapPriceList,
repairPriceList,
orderId: orderId.value,
}
const res = await setChangePriceAPI(changePriceParams)
if (res.code === 200) {
showToast(`已提交`)
setTimeout(() => {
uni.navigateBack()
}, 500)
}
})
.catch(() => {})
}
const onPreviewFile = (fileList) => {
showImagePreview([fileList[0].fileUrl])
}
</script>
<style lang="scss" scoped>
.order-reduction {
padding: 10px;
color: #333;
box-sizing: border-box;
background: linear-gradient(to bottom, #c0e9ce, #e4f2f2, #f9f9f9);
}
.van-cell-group view {
padding: 6px 10px;
}
:deep(.van-cell-group--inset) {
margin: 0;
margin-bottom: 10px;
}
.items-container {
margin-bottom: 10px;
box-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
.count-title text:first-child {
display: inline-block;
width: 10px;
height: 10px;
border-radius: 5px;
background-color: #ff660f;
margin-right: 8px;
}
}
</style>