index.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766
  1. <template>
  2. <scroll-view class="entry-page" scroll-y>
  3. <view class="hero">
  4. <image class="hero-bg" src="/static/entry/bg.png" mode="widthFix" />
  5. <view class="hero-mask"></view>
  6. <view class="hero-content">
  7. <view class="status-row"> </view>
  8. <view class="profile-row">
  9. <view class="avatar-wrap">
  10. <text class="avatar-text">{{ avatarText }}</text>
  11. </view>
  12. <view class="profile-main">
  13. <view class="greeting">{{ greetingText }},{{ displayName }}</view>
  14. <view class="project-pill">
  15. <text class="project-name">{{ projectName }}</text>
  16. <uni-icons type="down" size="13" color="#ffffff" />
  17. </view>
  18. </view>
  19. <view
  20. class="notice-wrap"
  21. @click="navigatorTo('/pages/message/index')"
  22. >
  23. <uni-badge :text="messageCount" absolute="rightTop" size="small">
  24. <view class="notice-button">
  25. <image
  26. src="~@/static/home/message.png"
  27. style="
  28. width: 15px;
  29. height: 15px;
  30. background-color: transparent;
  31. "
  32. @click="navigatorTo('/pages/message/index')"
  33. />
  34. </view>
  35. </uni-badge>
  36. </view>
  37. <view class="hero-title"> 工作台 </view>
  38. </view>
  39. </view>
  40. </view>
  41. <view class="content-shell">
  42. <view class="section-card">
  43. <view class="section-title">核心功能</view>
  44. <scroll-view class="core-scroll" scroll-x show-scrollbar="false">
  45. <view class="core-list">
  46. <view
  47. v-for="item in coreFeatures"
  48. :key="item.title"
  49. class="core-item"
  50. :class="{ active: item.active }"
  51. >
  52. <view class="core-icon">
  53. <image
  54. :src="item.iconText"
  55. mode="aspectFit"
  56. style="
  57. width: 40px;
  58. height: 40px;
  59. background-color: transparent;
  60. "
  61. />
  62. </view>
  63. <view class="core-name">{{ item.title }}</view>
  64. <view class="core-desc">{{ item.desc }}</view>
  65. <view class="core-indicator" v-if="item.active"></view>
  66. </view>
  67. </view>
  68. </scroll-view>
  69. </view>
  70. <view class="section-card">
  71. <view class="section-title">PMS常用</view>
  72. <view class="tool-grid">
  73. <view
  74. v-for="item in commonTools"
  75. :key="item.title"
  76. class="tool-item"
  77. @click="navigatorTo(item.path)"
  78. >
  79. <image class="tool-icon" :src="item.icon" mode="aspectFit" />
  80. <view class="tool-title">{{ item.title }}</view>
  81. </view>
  82. </view>
  83. </view>
  84. <view class="section-card">
  85. <view class="section-head">
  86. <view class="section-title">日报入口</view>
  87. <view class="section-tip">
  88. <uni-icons type="personadd" size="16" color="#246BFF" />
  89. <text>按角色显示</text>
  90. </view>
  91. </view>
  92. <view class="daily-list">
  93. <view
  94. v-for="item in visibleDailyEntries"
  95. :key="item.title"
  96. class="daily-item"
  97. @click="navigatorTo(item.path)"
  98. >
  99. <image class="daily-icon" :src="item.icon" mode="aspectFit" />
  100. <view class="daily-content">
  101. <view class="daily-title">{{ item.title }}</view>
  102. <view class="daily-subtitle">{{ item.subtitle }}</view>
  103. </view>
  104. <uni-icons type="right" size="14" color="#8090a8" />
  105. </view>
  106. </view>
  107. </view>
  108. </view>
  109. </scroll-view>
  110. </template>
  111. <script setup>
  112. import { computed, ref } from "vue";
  113. import { onShow } from "@dcloudio/uni-app";
  114. import dayjs from "dayjs";
  115. import { getLoginUserInfo } from "@/api/login";
  116. import { getUnreadMessageCount } from "@/api/message";
  117. import { getOvertimeTaskList } from "@/api/task";
  118. import { getUserInfo } from "@/utils/auth";
  119. const userInfo = ref({});
  120. const messageCount = ref(0);
  121. const todoStats = ref({
  122. maintenance: 0,
  123. fault: 0,
  124. });
  125. const coreFeatures = [
  126. {
  127. title: "PMS",
  128. desc: "设备生命周期管理",
  129. iconText: "/static/entry/pms.png",
  130. iconBg: "linear-gradient(135deg, #eaf2ff 0%, #d8e7ff 100%)",
  131. iconColor: "#246BFF",
  132. active: true,
  133. },
  134. {
  135. title: "QHSE",
  136. desc: "质量健康安全环保",
  137. iconText: "/static/entry/qhse.png",
  138. iconBg: "linear-gradient(135deg, #ecfff7 0%, #d8f8ea 100%)",
  139. iconColor: "#1eb980",
  140. },
  141. {
  142. title: "组态管理",
  143. desc: "流程与仪表组态",
  144. iconText: "/static/entry/zutai.png",
  145. iconBg: "linear-gradient(135deg, #f1edff 0%, #e0d9ff 100%)",
  146. iconColor: "#6d5efc",
  147. },
  148. {
  149. title: "智慧连油",
  150. desc: "润滑管理平台",
  151. iconText: "/static/entry/lianyou.png",
  152. iconBg: "linear-gradient(135deg, #e7fbff 0%, #d4f7fb 100%)",
  153. iconColor: "#10a8c6",
  154. },
  155. {
  156. title: "生产运营双周会",
  157. desc: "双周会管理与跟踪",
  158. iconText: "/static/entry/yunying.png",
  159. iconBg: "linear-gradient(135deg, #fff3e8 0%, #ffe3cc 100%)",
  160. iconColor: "#ff8a1f",
  161. },
  162. ];
  163. const commonTools = [
  164. {
  165. title: "运行记录",
  166. icon: "/static/entry/record.png",
  167. path: "/pages/recordFilling/list",
  168. },
  169. {
  170. title: "保养工单",
  171. icon: "/static/entry/baoyang.png",
  172. path: "/pages/maintenance/index",
  173. },
  174. {
  175. title: "设备维修",
  176. icon: "/static/entry/weixiu.png",
  177. path: "/pages/repair/index",
  178. },
  179. {
  180. title: "巡检工单",
  181. icon: "/static/entry/xunjian.png",
  182. path: "/pages/inspection/index",
  183. },
  184. {
  185. title: "故障上报",
  186. icon: "/static/entry/guzhang.png",
  187. path: "/pages/fault/index",
  188. },
  189. {
  190. title: "库存管理",
  191. icon: "/static/entry/kucun.png",
  192. path: "/pages/inventory/index",
  193. },
  194. {
  195. title: "保养查询",
  196. icon: "/static/entry/byquery.png",
  197. path: "/pages/maintenance/search",
  198. },
  199. {
  200. title: "设备台账",
  201. icon: "/static/entry/taizhang.png",
  202. path: "/pages/ledger/index",
  203. },
  204. {
  205. title: "设备状态变更",
  206. icon: "/static/entry/status.png",
  207. path: "/pages/statusChange/index",
  208. },
  209. {
  210. title: "设备责任人",
  211. icon: "/static/entry/zeren.png",
  212. path: "/pages/deviceUser/index",
  213. },
  214. ];
  215. const dailyEntries = computed(() => [
  216. {
  217. title: "瑞恒日报",
  218. subtitle: "进入瑞恒日报",
  219. path: "/pages/ruihen/index?type=edit",
  220. icon: "/static/entry/ruiheng.png",
  221. visible: !!userInfo.value.rhReportFlag,
  222. },
  223. {
  224. title: "瑞都日报",
  225. subtitle: "进入瑞都日报",
  226. path: "/pages/ruiDu/index",
  227. icon: "/static/entry/ruidu.png",
  228. visible: !!userInfo.value.rdReportFlag,
  229. },
  230. {
  231. title: "瑞鹰日报",
  232. subtitle: "进入瑞鹰日报",
  233. path: "/pages/ruiying/index?type=edit",
  234. icon: "/static/home/rh.png",
  235. visible: !!userInfo.value.ryReportFlag,
  236. },
  237. ]);
  238. const visibleDailyEntries = computed(() => {
  239. const list = dailyEntries.value.filter((item) => item.visible);
  240. if (list.length) return list.slice(0, 3);
  241. return dailyEntries.value
  242. .map((item) => ({ ...item, visible: true }))
  243. .slice(0, 3);
  244. });
  245. const todoCards = computed(() => [
  246. {
  247. title: "保养工单",
  248. icon: "/static/home/baoyang.png",
  249. count: todoStats.value.maintenance,
  250. color: "#1eb980",
  251. },
  252. {
  253. title: "故障上报",
  254. icon: "/static/home/guzhang.png",
  255. count: todoStats.value.fault,
  256. color: "#ff4d4f",
  257. },
  258. ]);
  259. const currentTimeText = computed(() => dayjs().format("H:mm"));
  260. const greetingText = computed(() => {
  261. const hour = dayjs().hour();
  262. if (hour < 12) return "上午好";
  263. if (hour < 18) return "下午好";
  264. return "晚上好";
  265. });
  266. const displayName = computed(
  267. () => userInfo.value.nickname || userInfo.value.username || "张工",
  268. );
  269. const avatarText = computed(() =>
  270. String(displayName.value || "张").slice(0, 1),
  271. );
  272. const projectName = computed(
  273. () =>
  274. userInfo.value.deptName ||
  275. userInfo.value.postGroup ||
  276. userInfo.value.stationName ||
  277. "智慧工厂示例项目",
  278. );
  279. const parseCachedUserInfo = () => {
  280. const cache = getUserInfo();
  281. if (!cache) return {};
  282. try {
  283. const parsed = typeof cache === "string" ? JSON.parse(cache) : cache;
  284. if (typeof parsed === "string") {
  285. return JSON.parse(parsed)?.user || {};
  286. }
  287. return parsed?.user || parsed || {};
  288. } catch (error) {
  289. return {};
  290. }
  291. };
  292. const buildTodoStats = (list) => {
  293. const stats = {
  294. maintenance: 0,
  295. fault: 0,
  296. };
  297. list.forEach((item) => {
  298. const typeText = String(item?.type || "");
  299. if (typeText.includes("保养")) {
  300. stats.maintenance += 1;
  301. }
  302. if (typeText.includes("故障")) {
  303. stats.fault += 1;
  304. }
  305. });
  306. return stats;
  307. };
  308. const loadPageData = async () => {
  309. userInfo.value = parseCachedUserInfo();
  310. try {
  311. const [userRes, messageRes, todoRes] = await Promise.all([
  312. getLoginUserInfo(),
  313. getUnreadMessageCount(),
  314. getOvertimeTaskList({ pageNo: 1, pageSize: 50 }),
  315. ]);
  316. if (userRes?.code === 0 && userRes.data) {
  317. userInfo.value = userRes.data;
  318. }
  319. if (messageRes?.code === 0) {
  320. messageCount.value = messageRes.data || 0;
  321. }
  322. if (todoRes?.code === 0) {
  323. const todoList = todoRes.data?.list || [];
  324. todoStats.value = buildTodoStats(todoList);
  325. }
  326. } catch (error) {
  327. messageCount.value = messageCount.value || 0;
  328. }
  329. };
  330. const navigatorTo = (url) => {
  331. if (!url) return;
  332. uni.navigateTo({ url });
  333. };
  334. onShow(() => {
  335. loadPageData();
  336. });
  337. </script>
  338. <style lang="scss" scoped>
  339. .entry-page {
  340. height: 100vh;
  341. background: linear-gradient(180deg, #edf4ff 0%, #f7f9fc 28%, #f6f8fb 100%);
  342. }
  343. .hero {
  344. position: relative;
  345. height: 640rpx;
  346. overflow: hidden;
  347. }
  348. .hero-bg {
  349. position: absolute;
  350. inset: 0;
  351. width: 100%;
  352. height: 100%;
  353. }
  354. .hero-mask {
  355. position: absolute;
  356. inset: 0;
  357. height: 55%;
  358. background: linear-gradient(
  359. to bottom,
  360. rgba(255, 255, 255, 0) 0%,
  361. rgb(45, 114, 212, 0.4) 88%,
  362. rgb(45, 114, 212, 0.4) 89%,
  363. rgb(45, 114, 212, 0.7) 91%,
  364. rgb(41, 113, 214, 0.2) 95%,
  365. #f9fbfd 100%
  366. );
  367. pointer-events: none;
  368. }
  369. .hero-content {
  370. position: relative;
  371. z-index: 2;
  372. padding: calc(var(--status-bar-height) + 24rpx) 28rpx 0;
  373. }
  374. .hero-title {
  375. position: absolute;
  376. left: 0%;
  377. bottom: -110%;
  378. // background: #f7f9fc;
  379. background: linear-gradient(
  380. to right,
  381. #f7f9fc 0%,
  382. #f7f9fc 50%,
  383. rgba(253, 253, 254, 0.3) 85%,
  384. rgba(253, 253, 254, 0.2) 90%,
  385. rgba(253, 253, 254, 0) 100%
  386. );
  387. border-radius: 16rpx 0rpx 0rpx 0rpx;
  388. padding-top: 20rpx;
  389. padding-bottom: 50rpx;
  390. padding-left: 28rpx;
  391. width: 50%;
  392. height: 80rpx;
  393. font-size: 40rpx;
  394. font-weight: 700;
  395. }
  396. .status-row {
  397. display: flex;
  398. align-items: center;
  399. justify-content: space-between;
  400. margin-bottom: 42rpx;
  401. }
  402. .profile-row {
  403. display: flex;
  404. align-items: center;
  405. }
  406. .avatar-wrap {
  407. width: 82rpx;
  408. height: 82rpx;
  409. border-radius: 50%;
  410. background: rgba(255, 255, 255, 0.3);
  411. border: 2rpx solid rgba(255, 255, 255, 0.7);
  412. display: flex;
  413. align-items: center;
  414. justify-content: center;
  415. backdrop-filter: blur(8px);
  416. }
  417. .avatar-text {
  418. color: #ffffff;
  419. font-size: 34rpx;
  420. font-weight: 700;
  421. }
  422. .profile-main {
  423. flex: 1;
  424. min-width: 0;
  425. margin-left: 22rpx;
  426. }
  427. .greeting {
  428. color: #ffffff;
  429. font-size: 30rpx;
  430. font-weight: 700;
  431. line-height: 1.2;
  432. text-shadow: 0 6rpx 18rpx rgba(0, 31, 90, 0.18);
  433. }
  434. .project-pill {
  435. display: inline-flex;
  436. align-items: center;
  437. gap: 12rpx;
  438. max-width: 100%;
  439. margin-top: 18rpx;
  440. padding: 12rpx 18rpx;
  441. border-radius: 18rpx;
  442. background: rgba(255, 255, 255, 0.18);
  443. color: #ffffff;
  444. backdrop-filter: blur(8px);
  445. }
  446. .project-name {
  447. max-width: 360rpx;
  448. overflow: hidden;
  449. text-overflow: ellipsis;
  450. white-space: nowrap;
  451. font-size: 20rpx;
  452. }
  453. .notice-wrap {
  454. margin-left: 12rpx;
  455. padding-right: 28rpx;
  456. }
  457. .notice-button {
  458. width: 30rpx;
  459. height: 30rpx;
  460. display: flex;
  461. align-items: center;
  462. justify-content: center;
  463. }
  464. .notice-glyph {
  465. font-size: 32rpx;
  466. line-height: 1;
  467. }
  468. .content-shell {
  469. position: relative;
  470. z-index: 2;
  471. margin-top: -325rpx;
  472. padding: 0 24rpx calc(env(safe-area-inset-bottom) + 34rpx);
  473. }
  474. .page-title {
  475. margin: 0 6rpx 22rpx;
  476. color: #071426;
  477. font-size: 72rpx;
  478. font-weight: 800;
  479. letter-spacing: 1rpx;
  480. }
  481. .section-card {
  482. margin-bottom: 22rpx;
  483. padding: 26rpx 22rpx 24rpx;
  484. border-radius: 20rpx;
  485. background: rgba(255, 255, 255, 0.94);
  486. box-shadow: 0 14rpx 24rpx rgba(13, 43, 91, 0.02);
  487. border: 1rpx solid #eef3fc;
  488. }
  489. .section-head {
  490. display: flex;
  491. align-items: center;
  492. justify-content: space-between;
  493. gap: 16rpx;
  494. }
  495. .section-title {
  496. color: #101c2e;
  497. font-size: 36rpx;
  498. font-weight: 700;
  499. }
  500. .section-tip {
  501. display: flex;
  502. align-items: center;
  503. gap: 8rpx;
  504. color: #5572a3;
  505. font-size: 24rpx;
  506. }
  507. .core-scroll {
  508. margin-top: 22rpx;
  509. white-space: nowrap;
  510. }
  511. .core-list {
  512. display: inline-flex;
  513. gap: 18rpx;
  514. padding-bottom: 4rpx;
  515. }
  516. .core-item {
  517. position: relative;
  518. width: 188rpx;
  519. min-height: 238rpx;
  520. padding: 24rpx 18rpx 20rpx;
  521. border-radius: 22rpx;
  522. background: #f9fbfd;
  523. border: 1rpx solid #e5edf8;
  524. box-sizing: border-box;
  525. display: flex;
  526. flex-direction: column;
  527. align-items: center;
  528. }
  529. .core-item.active {
  530. border-color: #246bff;
  531. background: linear-gradient(180deg, #ffffff 0%, #dfebfd 100%);
  532. box-shadow: inset 0 0 0 2rpx rgba(36, 107, 255, 0.08);
  533. }
  534. .core-icon {
  535. width: 84rpx;
  536. height: 84rpx;
  537. border-radius: 24rpx;
  538. display: flex;
  539. align-items: center;
  540. justify-content: center;
  541. text {
  542. font-size: 42rpx;
  543. font-weight: 800;
  544. }
  545. }
  546. .core-name {
  547. margin-top: 22rpx;
  548. color: #111d2f;
  549. font-size: 20rpx;
  550. font-weight: 700;
  551. white-space: normal;
  552. }
  553. .core-desc {
  554. margin-top: 10rpx;
  555. color: #6f7f96;
  556. font-size: 18rpx;
  557. line-height: 1.5;
  558. white-space: normal;
  559. }
  560. .core-indicator {
  561. position: absolute;
  562. left: 50%;
  563. bottom: 16rpx;
  564. width: 34rpx;
  565. height: 8rpx;
  566. margin-left: -17rpx;
  567. border-radius: 999rpx;
  568. background: #246bff;
  569. }
  570. .tool-grid {
  571. display: grid;
  572. grid-template-columns: repeat(5, minmax(0, 1fr));
  573. gap: 18rpx;
  574. margin-top: 22rpx;
  575. }
  576. .tool-item {
  577. min-height: 140rpx;
  578. padding: 22rpx 10rpx 18rpx;
  579. border-radius: 20rpx;
  580. background: linear-gradient(180deg, #ffffff 0%, #fbfcff 100%);
  581. border: 1rpx solid #e5edf8;
  582. display: flex;
  583. flex-direction: column;
  584. align-items: center;
  585. justify-content: center;
  586. box-sizing: border-box;
  587. }
  588. .tool-icon {
  589. width: 54rpx;
  590. height: 54rpx;
  591. }
  592. .tool-title {
  593. margin-top: 16rpx;
  594. color: #111d2f;
  595. font-size: 22rpx;
  596. line-height: 1.3;
  597. text-align: center;
  598. }
  599. .daily-list {
  600. display: grid;
  601. grid-template-columns: repeat(3, minmax(0, 1fr));
  602. gap: 5rpx;
  603. margin-top: 22rpx;
  604. }
  605. .daily-item {
  606. padding: 30rpx 0rpx;
  607. border-radius: 16rpx;
  608. background: linear-gradient(180deg, #ffffff 0%, #fbfcff 100%);
  609. border: 1rpx solid #e5edf8;
  610. display: flex;
  611. // flex-direction: column;
  612. // align-items: center;
  613. gap: 10rpx;
  614. // min-width: 0;
  615. }
  616. .daily-icon {
  617. width: 64rpx;
  618. height: 64rpx;
  619. flex-shrink: 0;
  620. }
  621. .daily-content {
  622. flex: 1;
  623. min-width: 0;
  624. }
  625. .daily-title {
  626. color: #111d2f;
  627. font-size: 22rpx;
  628. font-weight: 700;
  629. }
  630. .daily-subtitle {
  631. margin-top: 8rpx;
  632. color: #6f7f96;
  633. font-size: 16rpx;
  634. white-space: nowrap;
  635. overflow: hidden;
  636. text-overflow: ellipsis;
  637. }
  638. .todo-list {
  639. display: grid;
  640. grid-template-columns: repeat(2, minmax(0, 1fr));
  641. gap: 18rpx;
  642. margin-top: 22rpx;
  643. }
  644. .todo-item {
  645. min-width: 0;
  646. padding: 22rpx 20rpx;
  647. border-radius: 22rpx;
  648. background: linear-gradient(180deg, #ffffff 0%, #fbfcff 100%);
  649. border: 1rpx solid #e5edf8;
  650. display: flex;
  651. align-items: center;
  652. gap: 16rpx;
  653. }
  654. .todo-icon {
  655. width: 58rpx;
  656. height: 58rpx;
  657. flex-shrink: 0;
  658. }
  659. .todo-content {
  660. flex: 1;
  661. min-width: 0;
  662. }
  663. .todo-title {
  664. color: #111d2f;
  665. font-size: 26rpx;
  666. font-weight: 700;
  667. }
  668. .todo-subtitle {
  669. margin-top: 8rpx;
  670. color: #6f7f96;
  671. font-size: 22rpx;
  672. }
  673. .todo-right {
  674. display: flex;
  675. align-items: flex-end;
  676. gap: 6rpx;
  677. }
  678. .todo-count {
  679. font-size: 48rpx;
  680. font-weight: 800;
  681. line-height: 1;
  682. }
  683. .todo-unit {
  684. margin-bottom: 6rpx;
  685. color: #6f7f96;
  686. font-size: 22rpx;
  687. }
  688. </style>