diff --git a/src/pages/WorkOrder.tsx b/src/pages/WorkOrder.tsx index 624469a..51be606 100644 --- a/src/pages/WorkOrder.tsx +++ b/src/pages/WorkOrder.tsx @@ -132,6 +132,75 @@ const WorkOrderPage = () => { const [completeForm] = Form.useForm(); const messageApi = utils.message; + // 排班更多弹窗 + const [scheduleModalVisible, setScheduleModalVisible] = useState(false); + // 排班日历选中日期,默认今天 + const [scheduleDate, setScheduleDate] = useState(dayjs().format('YYYY-MM-DD')); + + + + + // 时间轴刻度 + const timeTicks = ["08:00", "10:00", "12:00", "14:00", "16:00", "18:00"]; + // 一天总分钟 08:00 ~ 18:00 = 600分钟 + const dayTotalMin = (18 - 8) * 60; + + const calcSchedulePosition = (planTime) => { + if (!planTime) return null; + const t = dayjs(planTime); + const hour = t.hour(); + const minute = t.minute(); + + let currentMin; + // 早于8点统一按0分钟计算,贴最左侧 + if (hour < 8) { + currentMin = 0; + } else if (hour >= 18) { + // 18点之后依旧不展示 + return null; + } else { + currentMin = (hour - 8) * 60 + minute; + } + + const leftPercent = (currentMin / dayTotalMin) * 100; + const widthPercent = 15; + return { left: `${leftPercent}%`, width: `${widthPercent}%` }; + }; + + // 过滤所有带计划时间的工单 + // 过滤【当前选中日期】且带计划时间的工单 + const getScheduleOrderList = () => { + return workOrderList.filter(item => { + if (!item.planStartTime) return false; + // 匹配选中日期 + const planDate = dayjs(item.planStartTime).format('YYYY-MM-DD'); + return planDate === scheduleDate; + }); + }; + + // 切换前一天 + const prevScheduleDay = () => { + setScheduleDate(dayjs(scheduleDate).subtract(1, 'day').format('YYYY-MM-DD')); + }; + // 切换后一天 + const nextScheduleDay = () => { + setScheduleDate(dayjs(scheduleDate).add(1, 'day').format('YYYY-MM-DD')); + }; + + + // 获取工单配色(优先级) + const getOrderScheduleStyle = (level) => { + const map = { + ERROR: { bg: "#FFF1F0", border: "#FF4D4F", color: "#FF4D4F" }, + WARNING: { bg: "#FFF7E8", border: "#FA8C16", color: "#FA8C16" }, + INFO: { bg: "#E8FFEA", border: "#00B42A", color: "#00B42A" }, + }; + return map[level] || { bg: "#E8F3FF", border: "#165DFF", color: "#165DFF" }; + }; + + + + // 计算工单统计数据 const calcWorkOrderStat = (list) => { @@ -862,39 +931,139 @@ const WorkOrderPage = () => {