|
@@ -102,6 +102,15 @@
|
|
|
import { ref, computed, onMounted } from 'vue';
|
|
import { ref, computed, onMounted } from 'vue';
|
|
|
import workspaceApi from '@/reqApi/workspace';
|
|
import workspaceApi from '@/reqApi/workspace';
|
|
|
|
|
|
|
|
|
|
+interface CalendarDay {
|
|
|
|
|
+ date: number;
|
|
|
|
|
+ month: number;
|
|
|
|
|
+ year: number;
|
|
|
|
|
+ dateStr: string;
|
|
|
|
|
+ isCurrentMonth: boolean;
|
|
|
|
|
+ hasSchedule: boolean;
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
const weekdays = ['日', '一', '二', '三', '四', '五', '六'];
|
|
const weekdays = ['日', '一', '二', '三', '四', '五', '六'];
|
|
|
const today = new Date();
|
|
const today = new Date();
|
|
|
const todayStr = `${today.getFullYear()}-${String(today.getMonth() + 1).padStart(2, '0')}-${String(today.getDate()).padStart(2, '0')}`;
|
|
const todayStr = `${today.getFullYear()}-${String(today.getMonth() + 1).padStart(2, '0')}-${String(today.getDate()).padStart(2, '0')}`;
|
|
@@ -109,16 +118,16 @@ const todayStr = `${today.getFullYear()}-${String(today.getMonth() + 1).padStart
|
|
|
const currentYear = ref(today.getFullYear());
|
|
const currentYear = ref(today.getFullYear());
|
|
|
const currentMonth = ref(today.getMonth() + 1);
|
|
const currentMonth = ref(today.getMonth() + 1);
|
|
|
const selectedDate = ref(todayStr);
|
|
const selectedDate = ref(todayStr);
|
|
|
-const calendarDays = ref([]);
|
|
|
|
|
-const scheduleEvents = ref({});
|
|
|
|
|
|
|
+const calendarDays = ref<CalendarDay[]>([]);
|
|
|
|
|
+const scheduleEvents = ref<{ [key: string]: Array<{ id: string; title: string }> }>({});
|
|
|
const isLoading = ref(false);
|
|
const isLoading = ref(false);
|
|
|
const showAddModal = ref(false);
|
|
const showAddModal = ref(false);
|
|
|
const scheduleContent = ref('');
|
|
const scheduleContent = ref('');
|
|
|
-const editItem = ref(null);
|
|
|
|
|
|
|
+const editItem = ref<{ id: string; title: string } | null>(null);
|
|
|
|
|
|
|
|
-const expandedItems = ref({});
|
|
|
|
|
|
|
+const expandedItems = ref<{ [key: string]: boolean }>({});
|
|
|
|
|
|
|
|
-const toggleExpand = (id) => {
|
|
|
|
|
|
|
+const toggleExpand = (id: string) => {
|
|
|
expandedItems.value[id] = !expandedItems.value[id];
|
|
expandedItems.value[id] = !expandedItems.value[id];
|
|
|
};
|
|
};
|
|
|
|
|
|
|
@@ -200,13 +209,13 @@ const fetchScheduleList = async () => {
|
|
|
}
|
|
}
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
-const updateScheduleEvents = (data) => {
|
|
|
|
|
|
|
+const updateScheduleEvents = (data: { [key: string]: any[] }) => {
|
|
|
Object.keys(scheduleEvents.value).forEach(key => {
|
|
Object.keys(scheduleEvents.value).forEach(key => {
|
|
|
delete scheduleEvents.value[key];
|
|
delete scheduleEvents.value[key];
|
|
|
});
|
|
});
|
|
|
Object.keys(data).forEach(dateKey => {
|
|
Object.keys(data).forEach(dateKey => {
|
|
|
const list = data[dateKey] || [];
|
|
const list = data[dateKey] || [];
|
|
|
- scheduleEvents.value[dateKey] = list.map(item => ({
|
|
|
|
|
|
|
+ scheduleEvents.value[dateKey] = list.map((item: any) => ({
|
|
|
id: String(item.id),
|
|
id: String(item.id),
|
|
|
title: item.content || ''
|
|
title: item.content || ''
|
|
|
}));
|
|
}));
|
|
@@ -234,13 +243,13 @@ const handleNextMonth = () => {
|
|
|
fetchScheduleList();
|
|
fetchScheduleList();
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
-const handleDayClick = (day) => {
|
|
|
|
|
|
|
+const handleDayClick = (day: CalendarDay) => {
|
|
|
selectedDate.value = day.dateStr;
|
|
selectedDate.value = day.dateStr;
|
|
|
currentYear.value = day.year;
|
|
currentYear.value = day.year;
|
|
|
currentMonth.value = day.month;
|
|
currentMonth.value = day.month;
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
-const handleDateChange = (e) => {
|
|
|
|
|
|
|
+const handleDateChange = (e: { detail: { value: string } }) => {
|
|
|
const date = e.detail.value;
|
|
const date = e.detail.value;
|
|
|
const [year, month, day] = date.split('-');
|
|
const [year, month, day] = date.split('-');
|
|
|
currentYear.value = parseInt(year);
|
|
currentYear.value = parseInt(year);
|
|
@@ -261,13 +270,13 @@ const handleAddSchedule = () => {
|
|
|
showAddModal.value = true;
|
|
showAddModal.value = true;
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
-const handleEdit = (item) => {
|
|
|
|
|
|
|
+const handleEdit = (item: { id: string; title: string }) => {
|
|
|
editItem.value = item;
|
|
editItem.value = item;
|
|
|
scheduleContent.value = item.title;
|
|
scheduleContent.value = item.title;
|
|
|
showAddModal.value = true;
|
|
showAddModal.value = true;
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
-const handleDelete = async (id) => {
|
|
|
|
|
|
|
+const handleDelete = async (id: string) => {
|
|
|
uni.showModal({
|
|
uni.showModal({
|
|
|
title: '提示',
|
|
title: '提示',
|
|
|
content: '确定要删除这条日程吗?',
|
|
content: '确定要删除这条日程吗?',
|
|
@@ -330,6 +339,8 @@ onMounted(() => {
|
|
|
.page {
|
|
.page {
|
|
|
height: 100vh;
|
|
height: 100vh;
|
|
|
background-color: #F5F7FA;
|
|
background-color: #F5F7FA;
|
|
|
|
|
+ padding-bottom: env(safe-area-inset-bottom);
|
|
|
|
|
+ box-sizing: border-box;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
.nav_bar {
|
|
.nav_bar {
|
|
@@ -337,7 +348,10 @@ onMounted(() => {
|
|
|
display: flex;
|
|
display: flex;
|
|
|
align-items: center;
|
|
align-items: center;
|
|
|
justify-content: space-between;
|
|
justify-content: space-between;
|
|
|
- padding: 24rpx;
|
|
|
|
|
|
|
+ padding-top: calc(24rpx + env(safe-area-inset-top));
|
|
|
|
|
+ padding-bottom: 24rpx;
|
|
|
|
|
+ padding-left: 24rpx;
|
|
|
|
|
+ padding-right: 24rpx;
|
|
|
|
|
|
|
|
.nav_back {
|
|
.nav_back {
|
|
|
display: flex;
|
|
display: flex;
|