OfficeSystem/pages/index/index.vue
WindowBird 5c8cacf998 temp
2025-10-31 10:45:23 +08:00

162 lines
4.2 KiB
Vue
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<template>
<!-- 顶部Tabs栏 -->
<view class="fixed-tabs" >
<uv-tabs :list="topTabs" @click="click"></uv-tabs>
</view>
<!-- 内容区域 -->
<view class="content-wrapper" :style="{ paddingTop: ( tabsHeight) + 'px' }">
<view>
<uv-calendar ref="calendar" mode="single" @change="handleConfirm" closeOnClickConfirm="false"></uv-calendar>
<button @click="openCalendar">选择日期</button>
</view>
<!-- 时间轴表格 -->
<TimeTable :hours="hours" :events="eventsInDay" />
</view>
<!-- 悬浮新建按钮 -->
<FabPlus @click="showAdd = true" />
<!-- 新建日程弹窗 -->
<AddEventModal :show="showAdd" @ok="addEvent" @cancel="showAdd = false" />
<!-- 底部导航 -->
<uv-tabbar :value="value" @change="index=>value = index">
<uv-tabbar-item text="首页" icon="home"></uv-tabbar-item>
<uv-tabbar-item text="放映厅" icon="photo"></uv-tabbar-item>
<uv-tabbar-item text="直播 " icon="play-right"></uv-tabbar-item>
<uv-tabbar-item text="我的" icon="account"></uv-tabbar-item>
</uv-tabbar>
</template>
<script setup>
import { ref, computed } from 'vue';
import TimeTable from '@/components/TimeTable.vue';
import FabPlus from '@/components/FabPlus.vue';
import AddEventModal from '@/components/AddEventModal.vue';
// 获取状态栏高度
const tabsHeight = ref(44); // tabs 高度单位px
// 顶部tabs选项
const topTabs = [
{ name: '日程编辑', value: 0 },
{ name: '内容看板', value: 1 },
{ name: '待办事项', value: 2 },
{ name: '消息内容', value: 3 }
];
const topTabValue = ref(0);
function click(item) {
topTabValue.value = item.value;
console.log('切换tab:', item.name);
}
// 当前选择的日期格式YYYY-MM-DD
const selectedDate = ref(new Date().toISOString().slice(0, 10));
// 小时段
const hours = Array.from({length: 24}, (_,i)=>i); // 8~20点
// 示例日程
const today = new Date().toISOString().slice(0, 10);
const allEvents = ref([
{id:1,title:'日程标题',startHour:15,startMin:30,color:'#e3fae6',date:today},
{id:2,title:'日程标题',startHour:16,startMin:0,color:'#fae1e1',date:today},
{id:3,title:'日程标题',startHour:23,startMin:0,color:'#e3fae6',date:today},
]);
// 根据当前选择日期过滤
const eventsInDay = computed(() =>
allEvents.value.filter(e=>e.date===selectedDate.value)
);
const calendar = ref(null)
// 打开日历方法
const openCalendar = () => {
if (calendar.value) {
calendar.value.open()
}
}
const handleConfirm = (e) => {
console.log('日历选择:', e);
// 处理日历返回的日期,可能是对象或字符串
let dateStr = '';
if (typeof e === 'string') {
dateStr = e;
} else if (e?.date) {
dateStr = e.date;
} else if (e?.value) {
dateStr = e.value;
} else if (Array.isArray(e) && e.length > 0) {
// 如果是数组,取第一个
dateStr = typeof e[0] === 'string' ? e[0] : (e[0]?.date || e[0]?.value || '');
}
// 格式化日期为 YYYY-MM-DD
if (dateStr) {
const date = new Date(dateStr);
if (!isNaN(date.getTime())) {
selectedDate.value = date.toISOString().slice(0, 10);
console.log('更新选择日期:', selectedDate.value);
}
}
}
// 悬浮按钮/弹窗控制
const showAdd = ref(false);
function addEvent(e) {
// e是{title, startHour, startMin, color}补充date
allEvents.value.push({
...e, date: selectedDate.value,
id: Date.now()
});
showAdd.value = false;
}
const value=ref(0);
// 底部导航
const tabbarItems = [
{ label: '任务列表', value: 0, icon: 'list' },
{ label: '首页', value: 1, icon: 'home' },
{ label: '工作台', value: 2, icon: 'calendar' },
{ label: '月度考核', value: 3, icon: 'integral' },
{ label: '管理', value: 4, icon: 'account' }
];
const tabbarVal = ref(1);
</script>
<style lang="scss" scoped>
.status_bar {
width: 100%;
position: fixed;
top: 0;
left: 0;
z-index: 1000;
}
.fixed-tabs {
position: fixed;
left: 0;
right: 0;
width: 100%;
background: #fff;
z-index: 999;
box-shadow: 0 2rpx 8rpx rgba(0, 0, 0, 0.06);
}
.content-wrapper {
min-height: 100vh;
}
:deep(.bottom-tabbar) { z-index: 1000 !important; }
.schedule-timeline {
padding-bottom: 130rpx !important;
}
</style>