OfficeSystem/pages/index/index.vue

262 lines
7.8 KiB
Vue
Raw Normal View History

2025-10-30 16:42:12 +08:00
<template>
2025-11-13 10:21:17 +08:00
<view>
<!-- 顶部Tabs栏只在非客户管理我的月度考核页面显示 -->
<view class="fixed-tabs" v-if="shouldShowTopTabs">
2025-11-05 10:16:17 +08:00
<uv-tabs :list="topTabs" :current="topTabValue" @click="clickTab"></uv-tabs>
2025-11-04 17:17:11 +08:00
</view>
2025-11-05 10:16:17 +08:00
2025-10-31 10:16:00 +08:00
<!-- 内容区域 -->
2025-10-31 14:14:51 +08:00
<view class="content-wrapper">
2025-11-07 18:01:19 +08:00
<!-- 客户管理底部导航栏选中时显示使用 v-show 避免组件销毁重建 -->
<CustomerManagement v-if="value === customerManagementIndex" ref="customerManagementRef" />
2025-11-10 16:54:46 +08:00
<!-- 我的 -->
<My v-else-if="value === myIndex" />
2025-11-13 10:21:17 +08:00
<!-- 月度考核排行榜 -->
<RankingBoard v-else-if="admin_bst && value === rankingIndex" />
2025-11-07 09:40:39 +08:00
2025-11-13 17:18:37 +08:00
<!-- 工作台 -->
<Workbench v-else-if="value === workIndex" />
2025-11-07 09:40:39 +08:00
<!-- 其他内容底部导航栏未选中客户管理时显示 -->
<template v-else>
<!-- 日程编辑 -->
<ScheduleEditor
v-if="topTabValue === 0"
ref="scheduleEditorRef"
:events="allEvents"
@date-change="handleDateChange"
/>
<!-- 内容看板 -->
<ContentDashboard v-if="topTabValue === 1" />
<!-- 待办事项 -->
<TodoList v-if="topTabValue === 2" />
<!-- 消息内容 -->
<MessageContent v-if="topTabValue === 3" />
2025-11-13 17:18:37 +08:00
2025-11-07 09:40:39 +08:00
</template>
2025-10-31 09:35:40 +08:00
</view>
2025-11-05 10:16:17 +08:00
<!-- 悬浮新建按钮只在日程编辑页显示 -->
<FabPlus v-if="topTabValue === 0 && shouldShowTopTabs" @click="handleAddClick" />
2025-10-30 18:00:30 +08:00
2025-11-03 09:47:11 +08:00
<!-- 新建日程弹窗保留以备后用 -->
2025-10-30 18:00:30 +08:00
<AddEventModal :show="showAdd" @ok="addEvent" @cancel="showAdd = false" />
<!-- 底部导航 -->
2025-10-31 09:35:40 +08:00
<uv-tabbar :value="value" @change="index=>value = index">
<uv-tabbar-item text="首页" icon="home"></uv-tabbar-item>
2025-10-31 10:52:48 +08:00
<uv-tabbar-item text="工作台" icon="calendar"></uv-tabbar-item>
2025-11-13 11:03:36 +08:00
<template v-if="admin_bst">
2025-11-13 10:49:10 +08:00
<uv-tabbar-item text="月度考核 " icon="integral"></uv-tabbar-item>
2025-11-05 11:05:53 +08:00
<uv-tabbar-item text="客户管理" icon="kefu-ermai" ></uv-tabbar-item>
</template>
2025-11-05 09:07:19 +08:00
<uv-tabbar-item text="我的" icon="account"></uv-tabbar-item>
2025-10-31 09:35:40 +08:00
</uv-tabbar>
2025-11-13 10:21:17 +08:00
</view>
2025-10-30 16:42:12 +08:00
</template>
2025-10-30 17:35:16 +08:00
<script setup>
2025-10-31 14:14:51 +08:00
import { ref, computed, watch, onMounted } from 'vue';
import { onShow, onReachBottom } from '@dcloudio/uni-app';
2025-11-06 09:07:22 +08:00
import { useUserStore } from '@/store/user';
2025-11-12 15:33:53 +08:00
import { getUserInfo } from '@/api';
2025-10-30 18:00:30 +08:00
import FabPlus from '@/components/FabPlus.vue';
2025-11-12 15:36:06 +08:00
import AddEventModal from '@/components/index/scheduleEditor/AddEventModal.vue';
import ScheduleEditor from '@/components/index/scheduleEditor/ScheduleEditor.vue';
import ContentDashboard from '@/components/index/ContentDashboard.vue';
import TodoList from '@/components/index/TodoList.vue';
import MessageContent from '@/components/index/MessageContent.vue';
import CustomerManagement from '@/components/customer/CustomerManagement.vue';
import My from '@/components/my/My.vue';
2025-11-22 10:09:36 +08:00
import RankingBoard from '@/components/RankingBoard/RankingBoard.vue';
import Workbench from '@/components/Workbench/Workbench.vue';
2025-10-30 17:19:26 +08:00
2025-11-13 10:49:10 +08:00
2025-10-30 18:00:30 +08:00
// 顶部tabs选项
const topTabs = [
2025-10-31 09:35:40 +08:00
{ name: '日程编辑', value: 0 },
{ name: '内容看板', value: 1 },
{ name: '待办事项', value: 2 },
{ name: '消息内容', value: 3 }
2025-11-13 17:18:37 +08:00
2025-10-30 17:35:16 +08:00
];
2025-11-05 10:16:17 +08:00
// 默认显示内容看板
const topTabValue = ref(1);
2025-10-30 16:42:12 +08:00
2025-10-31 10:52:48 +08:00
function clickTab(item) {
2025-10-31 10:16:00 +08:00
topTabValue.value = item.value;
console.log('切换tab:', item.name);
}
2025-11-05 10:20:41 +08:00
// 当前选择的日期格式YYYY-MM-DD用于新建日程时传递日期
2025-10-31 10:45:23 +08:00
const selectedDate = ref(new Date().toISOString().slice(0, 10));
2025-10-30 17:19:26 +08:00
2025-10-30 18:00:30 +08:00
// 示例日程
2025-10-31 10:45:23 +08:00
const today = new Date().toISOString().slice(0, 10);
2025-10-31 10:52:48 +08:00
// 获取明天的日期
const tomorrow = new Date();
tomorrow.setDate(tomorrow.getDate() + 1);
const tomorrowStr = tomorrow.toISOString().slice(0, 10);
// 获取昨天的日期
const yesterday = new Date();
yesterday.setDate(yesterday.getDate() - 1);
const yesterdayStr = yesterday.toISOString().slice(0, 10);
2025-10-30 18:00:30 +08:00
const allEvents = ref([
2025-10-31 14:14:51 +08:00
{id:1,title:'今天的日程1',startHour:10,startMin:30,color:'#e3fae6',date:today},
{id:5,title:'明天的日程2',startHour:10,startMin:30,color:'#fae1e1',date:tomorrowStr},
{id:6,title:'昨天的日程3',startHour:10,startMin:30,color:'#e3fae6',date:yesterdayStr},
2025-10-30 18:00:30 +08:00
]);
2025-10-30 17:19:26 +08:00
2025-11-05 10:20:41 +08:00
// 处理日期变化(从 ScheduleEditor 组件传来)
2025-11-04 17:10:40 +08:00
const handleDateChange = (dateStr) => {
selectedDate.value = dateStr;
console.log('通过日历组件更新选择日期:', selectedDate.value);
2025-10-31 09:35:40 +08:00
}
2025-10-30 18:00:30 +08:00
// 悬浮按钮/弹窗控制
const showAdd = ref(false);
2025-11-03 09:47:11 +08:00
2025-11-05 10:20:41 +08:00
// ScheduleEditor 组件引用
const scheduleEditorRef = ref(null);
// CustomerManagement 组件引用
const customerManagementRef = ref(null);
2025-11-03 09:47:11 +08:00
// 处理添加按钮点击
const handleAddClick = () => {
2025-11-05 10:20:41 +08:00
// 从 ScheduleEditor 组件获取当前选择的日期
const currentDate = scheduleEditorRef.value?.selectedDate || selectedDate.value;
2025-11-03 09:47:11 +08:00
uni.navigateTo({
2025-11-07 11:40:13 +08:00
url: `/pages/event/add/index?date=${currentDate}`
2025-11-03 09:47:11 +08:00
});
};
2025-11-05 10:20:41 +08:00
2025-11-03 09:47:11 +08:00
// 添加日程
2025-10-30 18:00:30 +08:00
function addEvent(e) {
2025-11-03 09:47:11 +08:00
// e是{title, startHour, startMin, color, date等}如果没有date则使用selectedDate
2025-10-30 18:00:30 +08:00
allEvents.value.push({
2025-11-03 09:47:11 +08:00
...e,
date: e.date || selectedDate.value,
2025-10-30 18:00:30 +08:00
id: Date.now()
});
showAdd.value = false;
}
2025-11-03 09:47:11 +08:00
2025-10-31 09:35:40 +08:00
const value=ref(0);
const admin_bst=ref(false);
// 动态计算各个页面的索引
const rankingIndex = computed(() => 3);
const customerManagementIndex = computed(() => 4);
const myIndex = computed(() => 2);
2025-11-13 17:18:37 +08:00
const workIndex = computed(() => 1);
// 判断是否显示顶部Tabs栏
const shouldShowTopTabs = computed(() => {
2025-11-13 17:18:37 +08:00
if (value.value === customerManagementIndex.value || value.value === myIndex.value||value.value === workIndex.value) {
return false;
}
if (admin_bst.value && value.value === rankingIndex.value) {
return false;
}
return true;
});
watch(value, (newValue, oldValue) => {
console.log('值变化:', oldValue, '→', newValue)
})
2025-11-06 09:07:22 +08:00
// 页面加载时请求接口
onMounted(() => {
const userStore = useUserStore();
console.log('当前 token:', userStore.token);
2025-11-13 11:03:36 +08:00
let roles = userStore.getUserInfo.roles
admin_bst.value = roles.some((role) => ['admin', 'sys_admin','bst'].includes(role));
console.log('admin_bst',admin_bst.value);
2025-11-13 11:03:36 +08:00
2025-11-13 10:49:10 +08:00
2025-11-06 09:46:14 +08:00
// 请求用户信息接口
getUserInfo().then(res => {
2025-11-06 09:07:22 +08:00
console.log('getInfo 接口返回:', res);
}).catch(err => {
console.error('getInfo 接口请求失败:', err);
});
2025-11-06 09:40:48 +08:00
2025-11-06 10:27:40 +08:00
// 看板数据已由 ContentDashboard 组件自己加载,这里不再请求
2025-11-06 09:07:22 +08:00
});
2025-11-03 09:47:11 +08:00
// 页面显示时处理从新建日程页面返回的数据
onShow(() => {
// 从全局存储中读取新添加的日程数据
try {
const newEventData = uni.getStorageSync('newEventData');
if (newEventData) {
addEvent(newEventData);
// 清除存储的数据
uni.removeStorageSync('newEventData');
}
} catch (e) {
console.error('读取新日程数据失败:', e);
}
2025-11-08 15:58:45 +08:00
// 如果当前在客户管理页面,检查是否需要刷新客户列表
if (value.value === customerManagementIndex.value && customerManagementRef.value) {
2025-11-08 15:58:45 +08:00
// 检查是否有刷新标志(从客户详情页删除后设置)
const needRefresh = uni.getStorageSync('customerListNeedRefresh');
if (needRefresh) {
// 刷新客户列表
customerManagementRef.value.refresh();
// 清除刷新标志
uni.removeStorageSync('customerListNeedRefresh');
}
}
2025-11-03 09:47:11 +08:00
});
// 触底加载更多(仅在客户管理页面时生效)
onReachBottom(() => {
// 只有在客户管理页面时才触发加载更多
if (value.value === customerManagementIndex.value && customerManagementRef.value) {
customerManagementRef.value.winB_LoadMore();
}
});
2025-10-30 16:42:12 +08:00
</script>
<style lang="scss" scoped>
2025-10-31 09:35:40 +08:00
.status_bar {
width: 100%;
2025-10-31 10:16:00 +08:00
position: fixed;
top: 0;
left: 0;
z-index: 1000;
}
.fixed-tabs {
position: fixed;
2025-11-05 11:04:47 +08:00
top: 0;
2025-10-31 10:16:00 +08:00
left: 0;
right: 0;
width: 100%;
background: #fff;
z-index: 999;
box-shadow: 0 2rpx 8rpx rgba(0, 0, 0, 0.06);
}
.content-wrapper {
2025-11-13 10:49:10 +08:00
2025-10-31 14:14:51 +08:00
overflow: hidden;
2025-11-13 10:49:10 +08:00
2025-11-13 10:21:17 +08:00
2025-11-13 10:49:10 +08:00
2025-11-05 10:16:17 +08:00
}
2025-10-30 18:00:30 +08:00
:deep(.bottom-tabbar) { z-index: 1000 !important; }
2025-10-30 17:35:16 +08:00
</style>