| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655 |
- <!--
- * @Author: wanglj wanglijie@dashoo.cn
- * @Date: 2025-03-11 18:02:10
- * @LastEditors: wanglj wanglijie@dashoo.cn
- * @LastEditTime: 2025-04-10 17:33:26
- * @Description: 首页重构优化 (适配 uni-app)
- -->
- <template>
- <view class="app-container">
- <uv-loading-page :loading="isLogining && !token" text="正在登录中..." iconSize="40"></uv-loading-page>
-
- <view v-if="token">
- <view class="card">
- <view class="card-title">常用功能</view>
- <view class="nav">
- <view class="nav-item" v-for="(item, index) in HOME_NAV_LIST" :key="index" @click="onRouterPush(item.path)" v-hasPermi="[item.permission]">
- <image :src="item.icon" mode="aspectFit" />
- <text>{{ item.name }}</text>
- </view>
- </view>
- </view>
- <view class="section-box mt20" v-hasPermi="['todo:list']">
- <view class="section-header flex justify-between align-center">
- <view class="flex align-center">
- <text class="section-title">待办事项</text>
- <text class="badge">{{ todoStore.total }}</text>
- </view>
- <text class="link" @click="onRouterPush('/pages/todo/index')">查看更多 ></text>
- </view>
- <view class="todo-list">
- <view v-if="!todoStore.list.length && !isLogining" class="home-empty-row">
- <uv-icon name="file-text" size="22" color="#cbd5f5"></uv-icon>
- <text class="home-empty-text">暂无待办事项</text>
- </view>
- <view v-else>
- <view
- class="todo-item"
- v-for="item in todoStore.list"
- :key="item.taskId"
- >
- <view class="todo-img-placeholder"></view>
- <view class="todo-content">
- <view class="todo-title">{{ item.instTitle || '审批任务' }}</view>
- <view class="todo-info">
- <text class="label">发起人:</text>
- <text class="value">{{ item.startUserName || '-' }}</text>
- </view>
- <view class="todo-time">
- <text class="label">发起时间:</text>
- <text class="value">{{ formatDate(item.createdTime, 'YYYY-MM-DD HH:mm') }}</text>
- </view>
- </view>
- <view class="todo-btn" @click="handleApprove(item)">去处理</view>
- </view>
- </view>
- </view>
- </view>
- <!-- 报销提醒 -->
- <!-- <view class="section-box mt20" v-hasPermi="['fund:reimbursement:list']">
- <view class="section-header flex justify-between align-center">
- <text class="section-title">报销提醒</text>
- <text class="link" @click="onRouterPush('/pages/fund/reimbursement-remind/index')">查看更多 ></text>
- </view>
- <view class="fund-list">
- <view v-if="!expendseList.length && !isLogining" class="home-empty-row">
- <uv-icon name="order" size="22" color="#cbd5f5"></uv-icon>
- <text class="home-empty-text">暂无报销提醒</text>
- </view>
- <view v-else>
- <view
- class="fund-item"
- v-for="item in expendseList"
- :key="item.id"
- @click="onRouterPush(`/pages/fund/reimbursement/edit?id=${item.id}`)"
- >
- <view class="fund-title">{{ `项目编号:${item.projectCode || '-'}` }}</view>
- <view class="fund-footer flex justify-between">
- <text class="user">采购人:{{ item.buyerName || '-' }}</text>
- <text class="date">{{ formatDate(item.createdTime) }}</text>
- </view>
- </view>
- </view>
- </view>
- </view> -->
- <!-- 通知公告列表 -->
- <view class="section-box mt20">
- <view class="section-header flex justify-between align-center">
- <text class="section-title">通知公告</text>
- <text class="link" @click="onRouterPush('/pages/notice/index')">查看更多 ></text>
- </view>
- <view class="notice-card">
- <view v-if="!noticeList.length && !isLogining" class="home-empty-row">
- <uv-icon name="file-text" size="22" color="#cbd5f5"></uv-icon>
- <text class="home-empty-text">暂无通知公告</text>
- </view>
- <view v-else>
- <view
- class="notice-item"
- v-for="item in noticeList"
- :key="item.id"
- @click="onRouterPush(`/pages/notice/detail?id=${item.id}`)"
- >
- <view class="notice-content">
- <view class="notice-title">{{ item.noticeTitle }}</view>
- <view class="notice-date">{{ formatDate(item.noticeTime, 'YYYY-MM-DD HH:mm') }}</view>
- </view>
- <view class="notice-action">
- <text>详情</text>
- <text class="arrow">></text>
- </view>
- </view>
- </view>
- </view>
- </view>
- </view>
- </view>
- </template>
- <script name="home" lang="ts" setup>
- import { ref, watch, onMounted } from 'vue';
- import { storeToRefs } from 'pinia';
- import { onShow } from '@dcloudio/uni-app';
- import { useUserStore } from '@/store/modules/user';
- import { useTodoStore } from '@/store/modules/todo';
- import type { TodoItem } from '@/types/todo';
- import { onRouterPush } from '@/utils/router';
- import { formatDate } from '@/utils/date';
- import { HOME_NAV_LIST } from '@/constants';
- import { useFundApi, useExpenseRemindApi } from '@/api/fund';
- import { useSystemApi } from '@/api/system';
- import { useExecutionApi } from '@/api/execution';
- import { useProjectApi } from '@/api/project';
- import to from 'await-to-js';
- const userStore = useUserStore();
- const { token, isLogining } = storeToRefs(userStore);
- const todoStore = useTodoStore();
- const fundApi = useFundApi();
- const expenseRemindApi = useExpenseRemindApi();
- const systemApi = useSystemApi();
- const executionApi = useExecutionApi();
- const projectApi = useProjectApi();
- /**
- * 状态变量定义
- * noticeList: 轮播图通知公告列表
- */
- const noticeList = ref<any[]>([]);
- const fundsList = ref<any[]>([]);
- const expendseList = ref<any[]>([]);
- /**
- * 获取通知公告列表 (GetList)
- */
- const getNoticeList = async () => {
- try {
- const res: any = await systemApi.getNoticeList({
- noticeTitle: "",
- pageNum: 1,
- pageSize: 3,
- noticeStatus: "20"
- });
- if (res.code == 200) {
- noticeList.value = res.data?.list || [];
- }
- } catch (err) {
- console.error(err);
- }
- };
- /**
- * 获取经费认领简要列表
- */
- const getFundList = async () => {
- try {
- const res: any = await fundApi.getList({ pageNum: 1, pageSize: 3, status: '10' });
- if (res.code == 200) {
- fundsList.value = res.data?.list || res.list || [];
- }
- } catch (err) {
- console.error(err);
- }
- };
- /**
- * 获取报销提醒简要列表
- */
- // const getExpendseList = async () => {
- // try {
- // const res: any = await expenseRemindApi.getList({ pageNum: 1, pageSize: 3, expenseStatus: '10' });
- // if (res.code == 200) {
- // expendseList.value = res.data?.list || res.list || [];
- // }
- // } catch (err) {
- // console.error(err);
- // }
- // };
- /**
- * 处理审批跳转逻辑
- * 根据待办事项的属性跳转到相应的详情页面
- * @param item 待办事项对象
- */
- const handleApprove = async (item: TodoItem) => {
- // 审批前增加学术不端行为校验
- uni.showLoading({ title: '校验中...', mask: true });
- // 1. 获取参与者列表,找出发起人
- const [err, res] = await to(executionApi.getParticipantByProcInstID({ id: item.id }));
- if (err || !res?.data) {
- uni.hideLoading();
- // 如果获取失败,出于流程通畅考虑,直接跳转
- onRouterPush(`/pages/todo/detail?mode=approval&id=${item.id || ''}&taskId=${item.taskId || ''}&taskCode=${item.businessCode || ''}&defCode=${item.defCode || ''}`);
- return;
- }
- const participants = res.data as any[];
- const startUser = participants.find(p => p.type === 'start');
- const startUserId = startUser?.userId;
- if (!startUserId) {
- uni.hideLoading();
- onRouterPush(`/pages/todo/detail?mode=approval&id=${item.id || ''}&taskId=${item.taskId || ''}&taskCode=${item.businessCode || ''}&defCode=${item.defCode || ''}`);
- return;
- }
- // 2. 调用学术不端校验接口
- const [err2, res2] = await to(projectApi.checkUserViolationStatus({ personId: startUserId }));
- uni.hideLoading();
- if (!err2 && res2?.data?.hasViolation) {
- const { restrictions } = res2.data;
- let restrictionList = [];
- if (restrictions.limitProjectApply) restrictionList.push('限制项目申报');
- if (restrictions.limitFundApply) restrictionList.push('限制申请经费');
- if (restrictions.limitRewardApply) restrictionList.push('限制成为奖励对象');
- uni.showModal({
- title: '学术不端行为提醒',
- content: `发起人 [${startUser?.userName || '未知'}] 存在学术不端记录,已被限制:${restrictionList.join('、')}。`,
- confirmText: '我知道了',
- showCancel: false
- });
- // 不跳转
- } else {
- onRouterPush(`/pages/todo/detail?mode=approval&id=${item.id || ''}&taskId=${item.taskId || ''}&taskCode=${item.businessCode || ''}&defCode=${item.defCode || ''}`);
- }
- };
- /**
- * 刷新首页所有数据
- */
- const refreshAllData = () => {
- if (!token.value) return;
-
- todoStore.fetchHomeTodoList();
- getFundList();
- // getExpendseList();
- getNoticeList();
- };
- /**
- * 页面生命周期:每次显示页面时刷新待办列表
- */
- onShow(() => {
- if (token.value) {
- refreshAllData();
- } else {
- // 如果没有 token,则跳转登录
- const launchCode = uni.getLaunchOptionsSync()?.query?.code;
- if (!launchCode && !isLogining.value) {
- setTimeout(() => {
- if (!token.value) {
- uni.reLaunch({ url: '/pages/login/index' });
- }
- }, 500);
- }
- }
- });
- // 监听 token,登录成功后立即加载数据
- watch(token, (newVal) => {
- if (newVal) {
- refreshAllData();
- }
- });
- // token 获取后自动加载首页数据
- onMounted(() => {
- if (token.value) {
- refreshAllData();
- }
- });
- </script>
- <style lang="scss" scoped>
- .app-container {
- min-height: calc(100vh - var(--window-top) - var(--window-bottom));
- box-sizing: border-box;
- background-color: #f5f7fa;
- padding: 20rpx;
- .flex {
- display: flex;
- }
- .justify-between {
- justify-content: space-between;
- }
- .align-center {
- align-items: center;
- }
- /* 通用卡片样式 */
- .card {
- min-height: 120rpx;
- border-radius: 16rpx;
- background-color: #fff;
- padding: 24rpx;
- box-shadow: 0px 4rpx 20rpx rgba(0, 0, 0, 0.04);
- .card-title {
- font-size: 32rpx;
- font-weight: bold;
- color: #343A3F;
- display: flex;
- align-items: center;
- .link {
- font-weight: normal;
- font-size: 26rpx;
- color: #999;
- }
- &::before {
- display: inline-block;
- content: '';
- width: 8rpx;
- height: 32rpx;
- background-color: #1c9bfd;
- margin-right: 16rpx;
- border-radius: 4rpx;
- }
- }
- .time {
- color: #f69a4d;
- font-size: 24rpx;
- }
- /* 导航 */
- .nav {
- display: flex;
- flex-wrap: wrap;
- margin-top: 20rpx;
- .nav-item {
- flex: 0 0 25%;
- display: flex;
- flex-direction: column;
- align-items: center;
- justify-content: center;
- margin-bottom: 24rpx;
- text {
- font-size: 26rpx;
- color: #585858;
- margin-top: 14rpx;
- }
- image {
- height: 88rpx;
- width: 88rpx;
- padding: 18rpx;
- border-radius: 20rpx;
- box-sizing: border-box;
- box-shadow: 0 4rpx 12rpx rgba(0, 0, 0, 0.05);
- }
- &:nth-child(1) image {
- background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
- }
- &:nth-child(2) image {
- background: linear-gradient(135deg, #ff9a44 0%, #fc6076 100%);
- }
- &:nth-child(3) image {
- background: linear-gradient(135deg, #43e97b 0%, #38f9d7 100%);
- }
- &:nth-child(4) image {
- background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
- }
- &:nth-child(5) image {
- background: linear-gradient(135deg, #ff0844 0%, #ffb199 100%);
- }
- &:nth-child(6) image {
- background: linear-gradient(135deg, #fccb90 0%, #d57eeb 100%);
- }
- &:nth-child(n+7) image {
- background: linear-gradient(135deg, #2af598 0%, #009efd 100%);
- }
- }
- }
- }
- /* 区块通用样式 (待办事项 & 通知公告) */
- .section-box {
- margin-top: 30rpx;
- .section-header {
- margin-bottom: 24rpx;
- .section-title {
- font-size: 34rpx;
- font-weight: bold;
- color: #343A3F;
- }
- .link {
- font-size: 26rpx;
- color: #888;
- }
- }
- .badge {
- background-color: #ff4d4f;
- color: #fff;
- font-size: 20rpx;
- font-weight: bold;
- width: 32rpx;
- height: 32rpx;
- border-radius: 50%;
- display: flex;
- justify-content: center;
- align-items: center;
- margin-left: 12rpx;
- box-shadow: 0 4rpx 8rpx rgba(255, 77, 79, 0.3);
- }
- .home-empty-row {
- display: flex;
- align-items: center;
- gap: 12rpx;
- padding: 20rpx 0 10rpx;
- color: #94a3b8;
- font-size: 26rpx;
- }
- .home-empty-text {
- color: #94a3b8;
- }
- .todo-list {
- .home-empty-row {
- padding: 24rpx;
- margin-bottom: 24rpx;
- background-color: #fff;
- border-radius: 16rpx;
- box-shadow: 0 4rpx 24rpx rgba(0, 0, 0, 0.05);
- }
- .todo-item {
- display: flex;
- align-items: center;
- padding: 30rpx 24rpx;
- background-color: #fff;
- margin-bottom: 24rpx;
- border: none;
- box-shadow: 0 4rpx 24rpx rgba(0, 0, 0, 0.05);
- border-radius: 16rpx;
- .todo-img-placeholder {
- width: 80rpx;
- height: 80rpx;
- border-radius: 50%;
- border: none;
- margin-right: 24rpx;
- flex-shrink: 0;
- background: linear-gradient(135deg, #e0c3fc 0%, #8ec5fc 100%);
- display: flex;
- align-items: center;
- justify-content: center;
- color: #fff;
- font-size: 24rpx;
- font-weight: bold;
- box-shadow: 0 6rpx 12rpx rgba(142, 197, 252, 0.4);
- &::after {
- content: "审";
- }
- }
- .todo-content {
- flex: 1;
- overflow: hidden;
- .todo-title {
- font-size: 32rpx;
- font-weight: 600;
- color: #343A3F;
- margin-bottom: 12rpx;
- white-space: nowrap;
- overflow: hidden;
- text-overflow: ellipsis;
- }
- .todo-info {
- font-size: 24rpx;
- margin-bottom: 10rpx;
- display: flex;
- align-items: center;
- .label {
- color: #343A3F;
- }
- .value {
- color: #585858;
- }
- .dept {
- margin-left: 16rpx;
- color: #1c9bfd;
- background: rgba(28, 155, 253, 0.1);
- padding: 2rpx 10rpx;
- border-radius: 6rpx;
- }
- }
- .todo-time {
- font-size: 22rpx;
- .label {
- color: #343A3F;
- }
- .value {
- color: #585858;
- }
- }
- }
- .todo-btn {
- background: linear-gradient(135deg, #1fc199 0%, #15a982 100%);
- color: #fff;
- font-size: 26rpx;
- padding: 12rpx 36rpx;
- border-radius: 30rpx;
- margin-left: 20rpx;
- flex-shrink: 0;
- box-shadow: 0 6rpx 12rpx rgba(31, 193, 153, 0.3);
- font-weight: 500;
- }
- }
- }
- /* 通知公告卡片 */
- .notice-card {
- background-color: #fff;
- border-radius: 16rpx;
- padding: 0 30rpx;
- box-shadow: 0 4rpx 24rpx rgba(0, 0, 0, 0.05);
- .notice-item {
- display: flex;
- justify-content: space-between;
- align-items: center;
- padding: 29rpx 0;
- border-bottom: 2rpx solid #f5f5f5;
- &:last-child {
- border-bottom: none;
- }
- .notice-content {
- flex: 1;
- .notice-title {
- font-size: 30rpx;
- color: #343A3F;
- margin-bottom: 12rpx;
- font-weight: 500;
- }
- .notice-date {
- font-size: 24rpx;
- color: #aaa;
- }
- }
- .notice-action {
- display: flex;
- align-items: center;
- color: #aaa;
- font-size: 24rpx;
- .arrow {
- margin-left: 8rpx;
- }
- }
- }
- }
- /* 经费列表摘要 */
- .fund-list {
- background-color: #fff;
- border-radius: 16rpx;
- padding: 0 24rpx;
- box-shadow: 0 4rpx 24rpx rgba(0, 0, 0, 0.05);
- .fund-item {
- padding: 24rpx 0;
- border-bottom: 1rpx solid #f2f2f2;
- &:last-child {
- border-bottom: none;
- }
- .fund-title {
- font-size: 28rpx;
- font-weight: bold;
- color: #333;
- margin-bottom: 8rpx;
- white-space: nowrap;
- overflow: hidden;
- text-overflow: ellipsis;
- }
- .fund-footer {
- font-size: 24rpx;
- color: #999;
- .amount {
- font-weight: 500;
- color: #ff9a44;
- }
- }
- }
- }
- }
- }
- </style>
|