代码优化

This commit is contained in:
BianLzhaoMin 2025-03-11 14:58:39 +08:00
parent ff4a303c97
commit 125354749e
4 changed files with 167 additions and 65 deletions

2
components.d.ts vendored
View File

@ -23,6 +23,7 @@ declare module 'vue' {
ElCollapse: typeof import('element-plus/es')['ElCollapse']
ElCollapseItem: typeof import('element-plus/es')['ElCollapseItem']
ElConfigProvider: typeof import('element-plus/es')['ElConfigProvider']
ElCountdown: typeof import('element-plus/es')['ElCountdown']
ElDatePicker: typeof import('element-plus/es')['ElDatePicker']
ElDialog: typeof import('element-plus/es')['ElDialog']
ElEmpty: typeof import('element-plus/es')['ElEmpty']
@ -44,6 +45,7 @@ declare module 'vue' {
ElSelect: typeof import('element-plus/es')['ElSelect']
ElStep: typeof import('element-plus/es')['ElStep']
ElSteps: typeof import('element-plus/es')['ElSteps']
ElSwitch: typeof import('element-plus/es')['ElSwitch']
ElTable: typeof import('element-plus/es')['ElTable']
ElTableColumn: typeof import('element-plus/es')['ElTableColumn']
ElTag: typeof import('element-plus/es')['ElTag']

View File

@ -72,7 +72,7 @@ const props = defineProps({
},
isDisabled: {
type: Boolean,
default: true,
default: false,
},
})

View File

@ -1,5 +1,5 @@
<script setup lang="ts">
import { ref,watch } from 'vue'
import { ref, watch } from 'vue'
import { getOrderListInfoApi } from 'http/api/usercenter/seekorder'
import { getOverhaulApi } from 'http/api/rent-termination/index'
@ -12,7 +12,7 @@ const repairRecordList = ref<any>([])
const fileListAll = ref<any>([])
const viewFileInfoList = ref<any>([])
const overhaulDetails = ref<any>({
'totalCost': 0,
totalCost: 0,
})
const innerVisible = ref(false)
import moment from 'moment'
@ -34,14 +34,18 @@ const getList = async () => {
const res: any = await getOrderListInfoApi({ orderId: props.orderId })
console.log(res, '详情')
orderDetails.value = res.data
if (props.orderStatus == 20){
isOrderComplete.value= 'text-decoration: line-through'
} else if(props.orderStatus == 4 && orderDetails.value.detailsList.length>0 && orderDetails.value.detailsList.some((item:any) => item.orderStatus == 20)){
isOrderComplete.value= 'text-decoration: line-through'
if (props.orderStatus == 20) {
isOrderComplete.value = 'text-decoration: line-through'
} else if (
props.orderStatus == 4 &&
orderDetails.value.detailsList.length > 0 &&
orderDetails.value.detailsList.some((item: any) => item.orderStatus == 20)
) {
isOrderComplete.value = 'text-decoration: line-through'
}
if (props.orderStatus == 20) {
isOrderComplete.value= 'text-decoration: line-through'
isOrderComplete.value = 'text-decoration: line-through'
const { data: result }: any = await getOverhaulApi(props.orderId)
orderDetailDtoList.value = result.orderDetailDtoList
repairRecordList.value = result.repairRecordList
@ -50,27 +54,27 @@ const getList = async () => {
fileListAll.value = result.fileInfoList
overhaulDetails.value = result
}
if(props.orderStatus == 4){
orderDetails.value.detailsList.forEach((item:any) => {
if (item.orderStatus!= 20) {
if (props.orderStatus == 4) {
orderDetails.value.detailsList.forEach((item: any) => {
if (item.orderStatus != 20) {
// cost totalCost
overhaulDetails.value.totalCost += item.costs;
console.log("yyyyyyyyy",overhaulDetails.value.totalCost)
overhaulDetails.value.totalCost += item.costs
console.log('yyyyyyyyy', overhaulDetails.value.totalCost)
}
});
if(orderDetails.value.detailsList.length>0){
})
if (orderDetails.value.detailsList.length > 0) {
orderDetails.value.detailsList.forEach((itemTwo: any) => {
if (itemTwo.orderStatus == 20) {
console.log('zzzzzzzzzzzzzzzzzzz',itemTwo)
console.log('zzzzzzzzzzzzzzzzzzz', itemTwo)
flag.value = true
let time = momentInit(itemTwo.takeOverTime).diff(itemTwo.rentOverTime, 'day')
if(time==0){
if (time == 0) {
time = 1
}
// cost total
overhaulDetails.value.totalCost += itemTwo.dayLeasePrice*time;
overhaulDetails.value.totalCost += itemTwo.dayLeasePrice * time
}
});
})
}
}
}
@ -308,12 +312,17 @@ const isOrderCompleteTwo = (goods: any) => {
"
style="min-height: 100px"
>
<el-image
:src="goods.url"
style="width: 110px; height: 80px"
alt="#"
fit="cover"
/>
<div style="display: flex; flex-direction: column; align-items: center">
<span style="font-weight: bold; font-size: 13px; padding: 4px 0">
接单人{{ goods.receivingUser }}
</span>
<el-image
:src="goods.url"
style="width: 110px; height: 80px"
alt="#"
fit="cover"
/>
</div>
<div
style="
min-height: 100px;
@ -327,20 +336,38 @@ const isOrderCompleteTwo = (goods: any) => {
>
<el-row style="font-weight: bold">
{{ goods.deviceName }}
<span style="padding-left: 10px">
接单时间{{ goods.receivingTime }}
</span>
</el-row>
<el-row>
<el-col :span="3"> 租期 :</el-col>
<el-col :span="3"> 租期:</el-col>
<el-col :span="8">
<span style="margin-right: 10px" :style="isOrderCompleteTwo(goods)">
<span
style="margin-right: 10px"
:style="isOrderCompleteTwo(goods)"
>
{{ goods.days }}{{ ' ' + '天' }}
</span>
<span v-if="goods.orderStatus == 20">
{{
isNaN(momentInit(goods.takeOverTime).diff(goods.rentOverTime, 'day'))
isNaN(
momentInit(goods.takeOverTime).diff(
goods.rentOverTime,
'day',
),
)
? '-'
: momentInit(goods.takeOverTime).diff(goods.rentOverTime, 'day') == 0
: momentInit(goods.takeOverTime).diff(
goods.rentOverTime,
'day',
) == 0
? 1
: momentInit(goods.takeOverTime).diff(goods.rentOverTime, 'day')
: momentInit(goods.takeOverTime).diff(
goods.rentOverTime,
'day',
)
}}{{ ' ' + '天' }}
</span>
</el-col>
@ -355,6 +382,11 @@ const isOrderCompleteTwo = (goods: any) => {
<el-col :span="3"> 数量 </el-col>
<el-col :span="8"> {{ goods.num }}{{ ' ' + '台' }} </el-col>
</el-row>
<el-row>
<el-col :span="4"> 累计租金 </el-col>
<el-col :span="12"> {{ goods.totalCost }}{{ ' ' + '元' }} </el-col>
</el-row>
</div>
</div>
</el-col>
@ -380,20 +412,36 @@ const isOrderCompleteTwo = (goods: any) => {
flex-direction: column;
"
>
<div
style="
width: 100%;
display: flex;
justify-content: space-around;
padding-bottom: 14px;
font-weight: bold;
font-size: 13px;
"
>
<span>出库人{{ goods.preOutboundUser }}</span>
<span>出库时间{{ goods.preOutboundTime }}</span>
</div>
<div>租期</div>
<div
style="font-weight: bold; margin-top: 10px"
:style="isOrderCompleteTwo(goods)"
>
{{ goods.rentBeginTime }}{{ goods.rentEndTime }}
{{
goods.preOutboundTime
? goods.preOutboundTime
: goods.rentBeginTime
}}
{{ goods.rentEndTime }}
</div>
<div
style="font-weight: bold; margin-top: 10px"
v-if="goods.orderStatus == 20"
>
{{ goods.takeOverTime }}{{
goods.rentOverTime
}}
{{ goods.takeOverTime }}{{ goods.rentOverTime }}
</div>
</div>
</div>
@ -402,7 +450,10 @@ const isOrderCompleteTwo = (goods: any) => {
<el-col :span="5" class="order-items-info" style="border: none; font-size: 13px">
<div>总费用</div>
<div class="red-font" :style="isOrderComplete">{{ orderDetails.cost }} </div>
<div class="red-font" v-if="props.orderStatus == 20 ||(props.orderStatus==4 && flag)">
<div
class="red-font"
v-if="props.orderStatus == 20 || (props.orderStatus == 4 && flag)"
>
{{ overhaulDetails.totalCost }}
</div>
</el-col>

View File

@ -12,7 +12,7 @@ const repairRecordList = ref<any>([])
const fileListAll = ref<any>([])
const viewFileInfoList = ref<any>([])
const overhaulDetails = ref<any>({
'totalCost': 0,
totalCost: 0,
})
const innerVisible = ref(false)
import moment from 'moment'
@ -33,14 +33,18 @@ const getList = async () => {
const res: any = await getOrderListInfoApi({ orderId: props.orderId })
console.log(res, '详情')
orderDetails.value = res.data
if (props.orderStatus == 20){
isOrderComplete.value= 'text-decoration: line-through'
} else if(props.orderStatus == 4 && orderDetails.value.detailsList.length>0 && orderDetails.value.detailsList.some((item:any) => item.orderStatus == 20)){
isOrderComplete.value= 'text-decoration: line-through'
if (props.orderStatus == 20) {
isOrderComplete.value = 'text-decoration: line-through'
} else if (
props.orderStatus == 4 &&
orderDetails.value.detailsList.length > 0 &&
orderDetails.value.detailsList.some((item: any) => item.orderStatus == 20)
) {
isOrderComplete.value = 'text-decoration: line-through'
}
if (props.orderStatus == 20) {
isOrderComplete.value= 'text-decoration: line-through'
isOrderComplete.value = 'text-decoration: line-through'
const { data: result }: any = await getOverhaulApi(props.orderId)
orderDetailDtoList.value = result.orderDetailDtoList
repairRecordList.value = result.repairRecordList
@ -49,25 +53,25 @@ const getList = async () => {
fileListAll.value = result.fileInfoList
overhaulDetails.value = result
}
if(props.orderStatus == 4){
orderDetails.value.detailsList.forEach((item:any) => {
if (item.orderStatus!= 20) {
if (props.orderStatus == 4) {
orderDetails.value.detailsList.forEach((item: any) => {
if (item.orderStatus != 20) {
// cost totalCost
overhaulDetails.value.totalCost += item.costs;
overhaulDetails.value.totalCost += item.costs
}
});
if(orderDetails.value.detailsList.length>0){
})
if (orderDetails.value.detailsList.length > 0) {
orderDetails.value.detailsList.forEach((itemTwo: any) => {
if (itemTwo.orderStatus == 20) {
flag.value = true
let time = momentInit(itemTwo.takeOverTime).diff(itemTwo.rentOverTime, 'day')
if(time==0){
if (time == 0) {
time = 1
}
// cost total
overhaulDetails.value.totalCost += itemTwo.dayLeasePrice*time;
overhaulDetails.value.totalCost += itemTwo.dayLeasePrice * time
}
});
})
}
}
}
@ -313,12 +317,17 @@ const isOrderCompleteTwo = (goods: any) => {
"
style="min-height: 100px"
>
<el-image
:src="goods.url"
style="width: 110px; height: 80px"
alt="#"
fit="cover"
/>
<div style="display: flex; flex-direction: column; align-items: center">
<span style="font-weight: bold; font-size: 13px; padding: 4px 0">
接单人{{ goods.receivingUser }}
</span>
<el-image
:src="goods.url"
style="width: 110px; height: 80px"
alt="#"
fit="cover"
/>
</div>
<div
style="
min-height: 100px;
@ -332,20 +341,38 @@ const isOrderCompleteTwo = (goods: any) => {
>
<el-row style="font-weight: bold">
{{ goods.deviceName }}
<span style="padding-left: 10px">
接单时间{{ goods.receivingTime }}
</span>
</el-row>
<el-row>
<el-col :span="3"> 租期 :</el-col>
<el-col :span="8">
<span style="margin-right: 10px" :style="isOrderCompleteTwo(goods)">
<span
style="margin-right: 10px"
:style="isOrderCompleteTwo(goods)"
>
{{ goods.days }}{{ ' ' + '天' }}
</span>
<span v-if="props.orderStatus == 20">
{{
isNaN(momentInit(goods.takeOverTime).diff(goods.rentOverTime, 'day'))
isNaN(
momentInit(goods.takeOverTime).diff(
goods.rentOverTime,
'day',
),
)
? '-'
: momentInit(goods.takeOverTime).diff(goods.rentOverTime, 'day') == 0
: momentInit(goods.takeOverTime).diff(
goods.rentOverTime,
'day',
) == 0
? 1
: momentInit(goods.takeOverTime).diff(goods.rentOverTime, 'day')
: momentInit(goods.takeOverTime).diff(
goods.rentOverTime,
'day',
)
}}{{ ' ' + '天' }}
</span>
</el-col>
@ -360,6 +387,10 @@ const isOrderCompleteTwo = (goods: any) => {
<el-col :span="3"> 数量 </el-col>
<el-col :span="8"> {{ goods.num }}{{ ' ' + '台' }} </el-col>
</el-row>
<el-row>
<el-col :span="4"> 累计租金 </el-col>
<el-col :span="12"> {{ goods.totalCost }}{{ ' ' + '元' }} </el-col>
</el-row>
</div>
</div>
</el-col>
@ -385,20 +416,35 @@ const isOrderCompleteTwo = (goods: any) => {
flex-direction: column;
"
>
<div
style="
width: 100%;
display: flex;
justify-content: space-around;
padding-bottom: 14px;
font-weight: bold;
font-size: 13px;
"
>
<span>出库人{{ goods.preOutboundUser }}</span>
<span>出库时间{{ goods.preOutboundTime }}</span>
</div>
<div>租期</div>
<div
style="font-weight: bold; margin-top: 10px"
:style="isOrderCompleteTwo(goods)"
>
{{ goods.rentBeginTime }}{{ goods.rentEndTime }}
{{
goods.preOutboundTime
? goods.preOutboundTime
: goods.rentBeginTime
}}{{ goods.rentEndTime }}
</div>
<div
style="font-weight: bold; margin-top: 10px"
v-if="goods.orderStatus == 20"
>
{{ goods.takeOverTime }}{{
goods.rentOverTime
}}
{{ goods.takeOverTime }} {{ goods.rentOverTime }}
</div>
</div>
</div>
@ -407,7 +453,10 @@ const isOrderCompleteTwo = (goods: any) => {
<el-col :span="5" class="order-items-info" style="border: none; font-size: 13px">
<div>总费用</div>
<div class="red-font" :style="isOrderComplete">{{ orderDetails.cost }} </div>
<div class="red-font" v-if="props.orderStatus == 20 ||(props.orderStatus==4 && flag)">
<div
class="red-font"
v-if="props.orderStatus == 20 || (props.orderStatus == 4 && flag)"
>
{{ overhaulDetails.totalCost }}
</div>
</el-col>