This commit is contained in:
aaron 2025-03-25 09:50:15 +08:00
parent 43c2b86d05
commit a850b61ed9

View File

@ -82,7 +82,11 @@
<!-- 配送时段 --> <!-- 配送时段 -->
<el-table-column label="配送时段" min-width="120"> <el-table-column label="配送时段" min-width="120">
<template #default="scope"> <template #default="scope">
<div v-if="scope.row.delivery_date && scope.row.time_period_name"> <div v-if="scope.row.delivery_date && scope.row.time_period_name"
:class="{
'time-in-progress': getDeliveryTimeStatus(scope.row.delivery_date, scope.row.time_period_name) === 'in-progress',
'time-expired': getDeliveryTimeStatus(scope.row.delivery_date, scope.row.time_period_name) === 'expired'
}">
<div>{{ scope.row.delivery_date }}</div> <div>{{ scope.row.delivery_date }}</div>
<div>{{ scope.row.time_period_name }}</div> <div>{{ scope.row.time_period_name }}</div>
</div> </div>
@ -240,6 +244,36 @@ export default {
} }
} }
//
const getDeliveryTimeStatus = (deliveryDate, timePeriodName) => {
if (!deliveryDate || !timePeriodName) return 'normal';
//
const [year, month, day] = deliveryDate.split('-').map(Number);
// ( "12:00-14:00")
const timeRange = timePeriodName.match(/(\d{1,2}):(\d{2})-(\d{1,2}):(\d{2})/);
if (!timeRange) return 'normal';
const [_, startHour, startMinute, endHour, endMinute] = timeRange.map(Number);
//
const startTime = new Date(year, month - 1, day, startHour, startMinute);
const endTime = new Date(year, month - 1, day, endHour, endMinute);
//
const now = new Date();
//
if (now >= startTime && now <= endTime) {
return 'in-progress'; //
} else if (now > endTime) {
return 'expired'; //
} else {
return 'upcoming'; //
}
};
// //
onMounted(() => { onMounted(() => {
window.addEventListener('resize', handleResize) window.addEventListener('resize', handleResize)
@ -373,7 +407,8 @@ export default {
handleReset, handleReset,
handleStatusChange, handleStatusChange,
handleSizeChange, handleSizeChange,
handleCurrentChange handleCurrentChange,
getDeliveryTimeStatus
} }
} }
} }
@ -386,6 +421,17 @@ export default {
overflow: hidden; overflow: hidden;
} }
/* 配送时段状态样式 */
.time-in-progress {
color: #e6a23c;
font-weight: bold;
}
.time-expired {
color: #f56c6c;
font-weight: bold;
}
.page-header { .page-header {
margin-bottom: 20px; margin-bottom: 20px;
display: flex; display: flex;