开始时间:
@@ -258,7 +286,7 @@
import { ref, computed, onMounted } from 'vue';
import { useRouter } from 'vue-router';
import { useUserStore } from '@/stores/user';
-import {getCampPeriodAdmin, changeCampPeriod} from '@/api/secondTop.js'
+import {getCampPeriodAdmin,changeCampPeriod,getHistoryCampPeriod,switchHistoryCampPeriod} from '@/api/secondTop.js'
// 响应式数据
const currentYear = ref(new Date().getFullYear());
@@ -285,6 +313,8 @@ const nextCampRestDays = ref();
// 历史营期弹框相关
const showHistoryModal = ref(false);
const historyPeriods = ref([]);
+const selectedHistoryPeriod = ref(null); // 当前选中的历史营期
+const isViewingHistory = ref(false); // 是否正在查看历史营期
// 获取本地时区的今日日期字符串
const getTodayString = () => {
@@ -482,35 +512,78 @@ const showHistory = async () => {
// 方法:加载历史营期数据
const loadHistoryPeriods = async () => {
try {
- // 这里可以调用API获取历史营期数据
- // const result = await getHistoryCampPeriods();
- // 模拟历史营期数据
- historyPeriods.value = [
- {
- startDate: '2024-01-15',
- endDate: '2024-01-28',
- dataDays: 10,
- restDays: 4,
+ // 调用API获取历史营期数据
+ const params = {
+ user_level: userStore.userInfo.user_level.toString(),
+ user_name: userStore.userInfo.username
+ };
+
+ const result = await getHistoryCampPeriod(params);
+
+ if (result && result.data && result.data.history_camp_period) {
+ // 将API返回的数据映射到组件需要的格式
+ historyPeriods.value = result.data.history_camp_period.map(period => ({
+ periodNum: period.history_camp_period_num,
+ startDate: period.start_time,
+ endDate: period.end_time,
+ dataDays: period.receipt_data_days,
+ restDays: period.rest_days,
status: 'completed'
- },
- {
- startDate: '2024-02-01',
- endDate: '2024-02-14',
- dataDays: 8,
- restDays: 6,
- status: 'completed'
- },
- {
- startDate: '2024-02-20',
- endDate: '2024-03-05',
- dataDays: 12,
- restDays: 2,
- status: 'completed'
- }
- ];
+ }));
+ } else {
+ historyPeriods.value = [];
+ }
} catch (error) {
console.error('加载历史营期数据失败:', error);
historyPeriods.value = [];
+ alert('加载历史营期数据失败,请重试');
+ }
+};
+
+// 方法:切换到历史营期
+const switchToHistoryPeriod = async (period) => {
+ try {
+ const params = {
+ center_leader: userStore.userInfo.username || "潘加俊",
+ history_camp_period_num: period.periodNum
+ };
+
+ const result = await switchHistoryCampPeriod(params);
+
+ if (result && result.code === 200) {
+ // 设置当前选中的历史营期
+ selectedHistoryPeriod.value = period;
+ isViewingHistory.value = true;
+
+ // 关闭历史营期弹框
+ showHistoryModal.value = false;
+
+ // 重新获取营期数据以更新日历显示
+ await CenterCampPeriodAdmin();
+
+ alert(`已切换到第${period.periodNum}期历史营期`);
+ } else {
+ alert('切换历史营期失败,请重试');
+ }
+ } catch (error) {
+ console.error('切换历史营期失败:', error);
+ alert('切换历史营期失败,请重试');
+ }
+};
+
+// 方法:返回当前营期
+const returnToCurrentPeriod = async () => {
+ try {
+ selectedHistoryPeriod.value = null;
+ isViewingHistory.value = false;
+
+ // 重新获取当前营期数据
+ await CenterCampPeriodAdmin();
+
+ alert('已返回当前营期');
+ } catch (error) {
+ console.error('返回当前营期失败:', error);
+ alert('返回当前营期失败,请重试');
}
};
@@ -1564,4 +1637,105 @@ onMounted(async () => {
background: linear-gradient(135deg, #ffc107, #fd7e14);
color: white;
}
+
+/* 历史营期选中状态样式 */
+.history-item {
+ cursor: pointer;
+ transition: all 0.3s ease;
+ border: 2px solid transparent;
+}
+
+.history-item:hover {
+ background: rgba(0, 123, 255, 0.05);
+ border-color: rgba(0, 123, 255, 0.2);
+ transform: translateY(-2px);
+ box-shadow: 0 4px 12px rgba(0, 123, 255, 0.15);
+}
+
+.history-item.selected {
+ background: rgba(0, 123, 255, 0.1);
+ border-color: #007bff;
+ box-shadow: 0 4px 12px rgba(0, 123, 255, 0.2);
+}
+
+.history-item.selected .period-title {
+ color: #007bff;
+ font-weight: 600;
+}
+
+.selected-badge {
+ display: inline-block;
+ background: linear-gradient(135deg, #007bff, #0056b3);
+ color: white;
+ font-size: 10px;
+ padding: 2px 6px;
+ border-radius: 10px;
+ margin-left: 8px;
+ font-weight: 500;
+}
+
+/* 返回当前营期按钮样式 */
+.current-btn {
+ display: flex;
+ align-items: center;
+ gap: 6px;
+ padding: 8px 12px;
+ background: linear-gradient(135deg, #28a745, #20c997);
+ color: white;
+ border: none;
+ border-radius: 6px;
+ font-size: 13px;
+ font-weight: 500;
+ cursor: pointer;
+ transition: all 0.3s ease;
+ box-shadow: 0 2px 4px rgba(40, 167, 69, 0.2);
+}
+
+.current-btn:hover {
+ background: linear-gradient(135deg, #218838, #1e7e34);
+ transform: translateY(-1px);
+ box-shadow: 0 4px 8px rgba(40, 167, 69, 0.3);
+}
+
+.current-btn:active {
+ transform: translateY(0);
+ box-shadow: 0 2px 4px rgba(40, 167, 69, 0.2);
+}
+
+/* 营期状态指示器样式 */
+.period-indicator {
+ display: flex;
+ justify-content: center;
+ padding: 8px 0;
+ margin-bottom: 8px;
+ border-bottom: 1px solid #e9ecef;
+}
+
+.history-indicator,
+.current-indicator {
+ display: flex;
+ align-items: center;
+ gap: 6px;
+ padding: 6px 12px;
+ border-radius: 20px;
+ font-size: 13px;
+ font-weight: 500;
+}
+
+.history-indicator {
+ background: linear-gradient(135deg, #ffc107, #fd7e14);
+ color: white;
+ box-shadow: 0 2px 4px rgba(255, 193, 7, 0.3);
+}
+
+.current-indicator {
+ background: linear-gradient(135deg, #28a745, #20c997);
+ color: white;
+ box-shadow: 0 2px 4px rgba(40, 167, 69, 0.3);
+}
+
+.history-indicator svg,
+.current-indicator svg {
+ flex-shrink: 0;
+}
\ No newline at end of file
diff --git a/my-vue-app/src/views/secondTop/components/CenterOverview.vue b/my-vue-app/src/views/secondTop/components/CenterOverview.vue
index bd79905..2d06d30 100644
--- a/my-vue-app/src/views/secondTop/components/CenterOverview.vue
+++ b/my-vue-app/src/views/secondTop/components/CenterOverview.vue
@@ -3,18 +3,19 @@
@@ -126,7 +127,7 @@ const emit = defineEmits(['update-check-type'])
const switchStatsMode = (mode) => {
statsMode.value = mode
// 向父组件发送事件,修改CheckType的值
- const checkTypeValue = mode === 'monthly' ? 'month' : 'period'
+ const checkTypeValue = mode === 'monthly' ? 'period':'month'
emit('update-check-type', checkTypeValue)
console.log('切换统计模式:', mode, '发送CheckType值:', checkTypeValue)
}