index.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514
  1. <!--
  2. * @Author: wanglj wanglijie@dashoo.cn
  3. * @Date: 2025-03-11 18:02:10
  4. * @LastEditors: wanglj wanglijie@dashoo.cn
  5. * @LastEditTime: 2025-04-10 17:33:26
  6. * @Description: 首页重构优化 (适配 uni-app)
  7. -->
  8. <template>
  9. <view class="app-container">
  10. <view class="card">
  11. <view class="card-title">常用功能</view>
  12. <view class="nav">
  13. <view class="nav-item" v-for="(item, index) in HOME_NAV_LIST" :key="index" @click="onRouterPush(item.path)">
  14. <image :src="item.icon" mode="aspectFit" />
  15. <text>{{ item.name }}</text>
  16. </view>
  17. </view>
  18. </view>
  19. <view class="section-box mt20" v-if="todoStore.list.length">
  20. <view class="section-header flex justify-between align-center">
  21. <view class="flex align-center">
  22. <text class="section-title">待办事项</text>
  23. <text class="badge">{{ todoStore.total }}</text>
  24. </view>
  25. <text class="link" @click="onRouterPush('/pages/todo/index')">查看更多 ></text>
  26. </view>
  27. <view class="todo-list">
  28. <view class="todo-item" v-for="item in todoStore.list" :key="item.taskId">
  29. <view class="todo-img-placeholder"></view>
  30. <view class="todo-content">
  31. <view class="todo-title">{{ item.instTitle || '审批任务' }}</view>
  32. <view class="todo-info">
  33. <text class="label">发起人:</text>
  34. <text class="value">{{ item.startUserName || '-' }}</text>
  35. </view>
  36. <view class="todo-time">
  37. <text class="label">发起时间:</text>
  38. <text class="value">{{ formatDate(item.createdTime, 'YYYY-MM-DD HH:mm') }}</text>
  39. </view>
  40. </view>
  41. <view class="todo-btn" @click="handleApprove(item)">去处理</view>
  42. </view>
  43. </view>
  44. </view>
  45. <!-- 报销提醒 -->
  46. <view class="section-box mt20" v-if="expendseList.length">
  47. <view class="section-header flex justify-between align-center">
  48. <text class="section-title">报销提醒</text>
  49. <text class="link" @click="onRouterPush('/pages/fund/reimbursement-remind/index')">查看更多 ></text>
  50. </view>
  51. <view class="fund-list">
  52. <view class="fund-item" v-for="item in expendseList" :key="item.id"
  53. @click="onRouterPush(`/pages/fund/reimbursement/edit?id=${item.id}`)">
  54. <view class="fund-title">{{ `项目编号:${item.projectCode || '-'}` }}</view>
  55. <view class="fund-footer flex justify-between">
  56. <text class="user">采购人:{{ item.buyerName || '-' }}</text>
  57. <text class="date">{{ formatDate(item.createdTime) }}</text>
  58. </view>
  59. </view>
  60. </view>
  61. </view>
  62. <!-- 通知公告列表 -->
  63. <view class="section-box mt20">
  64. <view class="section-header flex justify-between align-center">
  65. <text class="section-title">通知公告</text>
  66. <text class="link" @click="onRouterPush('/pages/notice/index')">查看更多 ></text>
  67. </view>
  68. <view class="notice-card">
  69. <view class="notice-item" v-for="item in noticeList" :key="item.id"
  70. @click="onRouterPush(`/pages/notice/detail?id=${item.id}`)">
  71. <view class="notice-content">
  72. <view class="notice-title">{{ item.noticeTitle }}</view>
  73. <view class="notice-date">{{ formatDate(item.noticeTime, 'YYYY-MM-DD HH:mm') }}</view>
  74. </view>
  75. <view class="notice-action">
  76. <text>详情</text>
  77. <text class="arrow">></text>
  78. </view>
  79. </view>
  80. </view>
  81. </view>
  82. </view>
  83. </template>
  84. <script name="home" lang="ts" setup>
  85. import { ref } from 'vue';
  86. import { onShow } from '@dcloudio/uni-app';
  87. import { useTodoStore } from '@/store/modules/todo';
  88. import type { TodoItem } from '@/types/todo';
  89. import { onRouterPush } from '@/utils/router';
  90. import { formatDate } from '@/utils/date';
  91. import { HOME_NAV_LIST } from '@/constants';
  92. import { useFundApi, useExpenseRemindApi } from '@/api/fund';
  93. import { useSystemApi } from '@/api/system';
  94. const todoStore = useTodoStore();
  95. const fundApi = useFundApi();
  96. const expenseRemindApi = useExpenseRemindApi();
  97. const systemApi = useSystemApi();
  98. /**
  99. * 状态变量定义
  100. * noticeList: 轮播图通知公告列表
  101. */
  102. const noticeList = ref<any[]>([]);
  103. const fundsList = ref<any[]>([]);
  104. const expendseList = ref<any[]>([]);
  105. /**
  106. * 获取通知公告列表 (GetList)
  107. */
  108. const getNoticeList = async () => {
  109. try {
  110. const res: any = await systemApi.getNoticeList({
  111. noticeTitle: "",
  112. pageNum: 1,
  113. pageSize: 3,
  114. noticeStatus: "20"
  115. });
  116. if (res.code == 200) {
  117. noticeList.value = res.data?.list || [];
  118. }
  119. } catch (err) {
  120. console.error(err);
  121. }
  122. };
  123. /**
  124. * 获取经费认领简要列表
  125. */
  126. const getFundList = async () => {
  127. try {
  128. const res: any = await fundApi.getList({ pageNum: 1, pageSize: 3, status: '10' });
  129. if (res.code == 200) {
  130. fundsList.value = res.data?.list || res.list || [];
  131. }
  132. } catch (err) {
  133. console.error(err);
  134. }
  135. };
  136. /**
  137. * 获取报销提醒简要列表
  138. */
  139. const getExpendseList = async () => {
  140. try {
  141. const res: any = await expenseRemindApi.getList({ pageNum: 1, pageSize: 3, expenseStatus: '10' });
  142. if (res.code == 200) {
  143. expendseList.value = res.data?.list || res.list || [];
  144. }
  145. } catch (err) {
  146. console.error(err);
  147. }
  148. };
  149. /**
  150. * 处理审批跳转逻辑
  151. * 根据待办事项的属性跳转到相应的详情页面
  152. * @param item 待办事项对象
  153. */
  154. const handleApprove = (item: TodoItem) => {
  155. onRouterPush(`/pages/todo/detail?mode=approval&id=${item.id || ''}&taskId=${item.taskId || ''}&taskCode=${item.businessCode || ''}&defCode=${item.defCode || ''}`);
  156. };
  157. /**
  158. * 页面生命周期:每次显示页面时刷新待办列表
  159. */
  160. onShow(() => {
  161. // 调用 store 中的 action 获取最新的首页待办信息
  162. todoStore.fetchHomeTodoList();
  163. getFundList();
  164. getExpendseList();
  165. getNoticeList();
  166. });
  167. </script>
  168. <style lang="scss" scoped>
  169. .app-container {
  170. min-height: calc(100vh - var(--window-top) - var(--window-bottom));
  171. box-sizing: border-box;
  172. background-color: #f5f7fa;
  173. padding: 20rpx;
  174. .flex {
  175. display: flex;
  176. }
  177. .justify-between {
  178. justify-content: space-between;
  179. }
  180. .align-center {
  181. align-items: center;
  182. }
  183. /* 通用卡片样式 */
  184. .card {
  185. min-height: 120rpx;
  186. border-radius: 16rpx;
  187. background-color: #fff;
  188. padding: 24rpx;
  189. box-shadow: 0px 4rpx 20rpx rgba(0, 0, 0, 0.04);
  190. .card-title {
  191. font-size: 32rpx;
  192. font-weight: bold;
  193. color: #343A3F;
  194. display: flex;
  195. align-items: center;
  196. .link {
  197. font-weight: normal;
  198. font-size: 26rpx;
  199. color: #999;
  200. }
  201. &::before {
  202. display: inline-block;
  203. content: '';
  204. width: 8rpx;
  205. height: 32rpx;
  206. background-color: #1c9bfd;
  207. margin-right: 16rpx;
  208. border-radius: 4rpx;
  209. }
  210. }
  211. .time {
  212. color: #f69a4d;
  213. font-size: 24rpx;
  214. }
  215. /* 导航 */
  216. .nav {
  217. display: flex;
  218. flex-wrap: wrap;
  219. margin-top: 20rpx;
  220. .nav-item {
  221. flex: 0 0 25%;
  222. display: flex;
  223. flex-direction: column;
  224. align-items: center;
  225. justify-content: center;
  226. margin-bottom: 24rpx;
  227. text {
  228. font-size: 26rpx;
  229. color: #585858;
  230. margin-top: 14rpx;
  231. }
  232. image {
  233. height: 88rpx;
  234. width: 88rpx;
  235. padding: 18rpx;
  236. border-radius: 20rpx;
  237. box-sizing: border-box;
  238. box-shadow: 0 4rpx 12rpx rgba(0, 0, 0, 0.05);
  239. }
  240. &:nth-child(1) image {
  241. background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
  242. }
  243. &:nth-child(2) image {
  244. background: linear-gradient(135deg, #ff9a44 0%, #fc6076 100%);
  245. }
  246. &:nth-child(3) image {
  247. background: linear-gradient(135deg, #43e97b 0%, #38f9d7 100%);
  248. }
  249. &:nth-child(4) image {
  250. background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  251. }
  252. &:nth-child(5) image {
  253. background: linear-gradient(135deg, #ff0844 0%, #ffb199 100%);
  254. }
  255. &:nth-child(6) image {
  256. background: linear-gradient(135deg, #fccb90 0%, #d57eeb 100%);
  257. }
  258. &:nth-child(n+7) image {
  259. background: linear-gradient(135deg, #2af598 0%, #009efd 100%);
  260. }
  261. }
  262. }
  263. }
  264. /* 区块通用样式 (待办事项 & 通知公告) */
  265. .section-box {
  266. margin-top: 30rpx;
  267. .section-header {
  268. margin-bottom: 24rpx;
  269. .section-title {
  270. font-size: 34rpx;
  271. font-weight: bold;
  272. color: #343A3F;
  273. }
  274. .link {
  275. font-size: 26rpx;
  276. color: #888;
  277. }
  278. }
  279. .badge {
  280. background-color: #ff4d4f;
  281. color: #fff;
  282. font-size: 20rpx;
  283. font-weight: bold;
  284. width: 32rpx;
  285. height: 32rpx;
  286. border-radius: 50%;
  287. display: flex;
  288. justify-content: center;
  289. align-items: center;
  290. margin-left: 12rpx;
  291. box-shadow: 0 4rpx 8rpx rgba(255, 77, 79, 0.3);
  292. }
  293. .todo-list {
  294. .todo-item {
  295. display: flex;
  296. align-items: center;
  297. padding: 30rpx 24rpx;
  298. background-color: #fff;
  299. margin-bottom: 24rpx;
  300. border: none;
  301. box-shadow: 0 4rpx 24rpx rgba(0, 0, 0, 0.05);
  302. border-radius: 16rpx;
  303. .todo-img-placeholder {
  304. width: 80rpx;
  305. height: 80rpx;
  306. border-radius: 50%;
  307. border: none;
  308. margin-right: 24rpx;
  309. flex-shrink: 0;
  310. background: linear-gradient(135deg, #e0c3fc 0%, #8ec5fc 100%);
  311. display: flex;
  312. align-items: center;
  313. justify-content: center;
  314. color: #fff;
  315. font-size: 24rpx;
  316. font-weight: bold;
  317. box-shadow: 0 6rpx 12rpx rgba(142, 197, 252, 0.4);
  318. &::after {
  319. content: "审";
  320. }
  321. }
  322. .todo-content {
  323. flex: 1;
  324. overflow: hidden;
  325. .todo-title {
  326. font-size: 32rpx;
  327. font-weight: 600;
  328. color: #343A3F;
  329. margin-bottom: 12rpx;
  330. white-space: nowrap;
  331. overflow: hidden;
  332. text-overflow: ellipsis;
  333. }
  334. .todo-info {
  335. font-size: 24rpx;
  336. margin-bottom: 10rpx;
  337. display: flex;
  338. align-items: center;
  339. .label {
  340. color: #343A3F;
  341. }
  342. .value {
  343. color: #585858;
  344. }
  345. .dept {
  346. margin-left: 16rpx;
  347. color: #1c9bfd;
  348. background: rgba(28, 155, 253, 0.1);
  349. padding: 2rpx 10rpx;
  350. border-radius: 6rpx;
  351. }
  352. }
  353. .todo-time {
  354. font-size: 22rpx;
  355. .label {
  356. color: #343A3F;
  357. }
  358. .value {
  359. color: #585858;
  360. }
  361. }
  362. }
  363. .todo-btn {
  364. background: linear-gradient(135deg, #1fc199 0%, #15a982 100%);
  365. color: #fff;
  366. font-size: 26rpx;
  367. padding: 12rpx 36rpx;
  368. border-radius: 30rpx;
  369. margin-left: 20rpx;
  370. flex-shrink: 0;
  371. box-shadow: 0 6rpx 12rpx rgba(31, 193, 153, 0.3);
  372. font-weight: 500;
  373. }
  374. }
  375. }
  376. /* 通知公告卡片 */
  377. .notice-card {
  378. background-color: #fff;
  379. border-radius: 16rpx;
  380. padding: 0 30rpx;
  381. box-shadow: 0 4rpx 24rpx rgba(0, 0, 0, 0.05);
  382. .notice-item {
  383. display: flex;
  384. justify-content: space-between;
  385. align-items: center;
  386. padding: 29rpx 0;
  387. border-bottom: 2rpx solid #f5f5f5;
  388. &:last-child {
  389. border-bottom: none;
  390. }
  391. .notice-content {
  392. flex: 1;
  393. .notice-title {
  394. font-size: 30rpx;
  395. color: #343A3F;
  396. margin-bottom: 12rpx;
  397. font-weight: 500;
  398. }
  399. .notice-date {
  400. font-size: 24rpx;
  401. color: #aaa;
  402. }
  403. }
  404. .notice-action {
  405. display: flex;
  406. align-items: center;
  407. color: #aaa;
  408. font-size: 24rpx;
  409. .arrow {
  410. margin-left: 8rpx;
  411. }
  412. }
  413. }
  414. }
  415. /* 经费列表摘要 */
  416. .fund-list {
  417. background-color: #fff;
  418. border-radius: 16rpx;
  419. padding: 0 24rpx;
  420. box-shadow: 0 4rpx 24rpx rgba(0, 0, 0, 0.05);
  421. .fund-item {
  422. padding: 24rpx 0;
  423. border-bottom: 1rpx solid #f2f2f2;
  424. &:last-child {
  425. border-bottom: none;
  426. }
  427. .fund-title {
  428. font-size: 28rpx;
  429. font-weight: bold;
  430. color: #333;
  431. margin-bottom: 8rpx;
  432. white-space: nowrap;
  433. overflow: hidden;
  434. text-overflow: ellipsis;
  435. }
  436. .fund-footer {
  437. font-size: 24rpx;
  438. color: #999;
  439. .amount {
  440. font-weight: 500;
  441. color: #ff9a44;
  442. }
  443. }
  444. }
  445. }
  446. }
  447. }
  448. </style>