index.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752
  1. <template>
  2. <view class="detail-page" @click="closeProvinceDropdown">
  3. <!-- 背景层 -->
  4. <view class="header-bg"></view>
  5. <!-- 顶部内容层 -->
  6. <view class="header-section">
  7. <view class="header-content">
  8. <view class="title-group">
  9. <text class="main-title">感冒灵颗粒</text>
  10. <text class="sub-title">药品流向实时追踪</text>
  11. </view>
  12. <view class="stat-box">
  13. <text class="stat-num">{{ totalCount }}</text>
  14. <text class="stat-unit">家</text>
  15. </view>
  16. </view>
  17. <view class="header-toolbar">
  18. <view class="update-tip">
  19. <text class="tip-icon">🕒</text>
  20. <text
  21. >更新:{{
  22. formatDate(
  23. new Date().setDate(new Date().getDate() - 1),
  24. "YYYY-MM-DD",
  25. ) || "--"
  26. }}</text
  27. >
  28. </view>
  29. <view class="filter-wrap">
  30. <view class="selector" @click.stop="toggleProvinceDropdown">
  31. <text class="selector-text">{{
  32. selectedProvince || "全部省份"
  33. }}</text>
  34. <text
  35. class="selector-arrow"
  36. :class="{ open: dropdownProvinceOpen }"
  37. ></text>
  38. </view>
  39. </view>
  40. </view>
  41. </view>
  42. <!-- 列表区域 -->
  43. <scroll-view
  44. class="list-scroll"
  45. scroll-y="true"
  46. refresher-enabled
  47. :refresher-triggered="isRefreshing"
  48. @refresherrefresh="onRefresh"
  49. @scrolltolower="onLoadMore"
  50. >
  51. <view class="list-container">
  52. <view
  53. class="card-item"
  54. v-for="(item, index) in displayRows"
  55. :key="index"
  56. @click="toDetail(item)"
  57. >
  58. <view class="card-header">
  59. <view class="header-left">
  60. <text class="index-num">{{ index + 1 }}</text>
  61. <text class="company-name">{{ item.receiverName }}</text>
  62. <text
  63. class="level-tag"
  64. :class="getLevelClass(item.customerLevel)"
  65. >
  66. {{ item.customerLevel }}
  67. </text>
  68. </view>
  69. <view class="header-right">
  70. <text class="alert-count">{{ item.alertCount }}次预警</text>
  71. </view>
  72. </view>
  73. <view class="card-body">
  74. <view class="info-grid">
  75. <view class="info-item">
  76. <text class="label">省份</text>
  77. <text class="value">{{ item.receiverProvince }}</text>
  78. </view>
  79. <view class="info-item">
  80. <text class="label">责任人</text>
  81. <text class="value">{{ item.manager }}</text>
  82. </view>
  83. <view class="info-item">
  84. <text class="label">性质</text>
  85. <text class="value">{{ item.customerNature }}</text>
  86. </view>
  87. </view>
  88. </view>
  89. </view>
  90. <view class="loading-more" v-if="loading">
  91. <image
  92. class="loading-icon"
  93. src="../../../static/images/loading.png"
  94. />
  95. <text class="loading-text">加载中...</text>
  96. </view>
  97. <view v-if="!loading && displayRows.length === 0" class="empty-data">
  98. <EmptyView text="无相关数据" />
  99. </view>
  100. <view v-if="!hasMore && displayRows.length > 0" class="no-more">
  101. <text>没有更多数据了</text>
  102. </view>
  103. </view>
  104. </scroll-view>
  105. <!-- 独立的下拉菜单层 -->
  106. <view class="dropdown-layer" v-if="dropdownProvinceOpen" @click.stop>
  107. <view class="dropdown">
  108. <view class="dropdown-search-bar">
  109. <input
  110. class="dropdown-search-input"
  111. v-model="provinceSearchText"
  112. @input="onProvinceSearch"
  113. placeholder="搜索省份..."
  114. placeholder-style="color: #999"
  115. />
  116. </view>
  117. <scroll-view scroll-y="true" class="dropdown-scroll-view">
  118. <view
  119. class="dropdown-item"
  120. v-for="(p, i) in filteredProvinceList"
  121. :key="p || i"
  122. :class="{
  123. active: p === selectedProvince || (!selectedProvince && i === 0),
  124. }"
  125. @click.stop="selectProvince(p)"
  126. >
  127. {{ p || "全部省份" }}
  128. <text
  129. v-if="p === selectedProvince || (!selectedProvince && i === 0)"
  130. class="check-mark"
  131. >✓</text
  132. >
  133. </view>
  134. <view v-if="filteredProvinceList.length === 0" class="dropdown-empty"
  135. >暂无数据</view
  136. >
  137. </scroll-view>
  138. </view>
  139. </view>
  140. <!-- 底部按钮区 -->
  141. <view class="footer-btn-area">
  142. <button class="action-btn history-btn" @click="handleHistory">
  143. 历史记录
  144. </button>
  145. <button class="action-btn export-btn" @click="handleExport">
  146. 导出至邮箱
  147. </button>
  148. </view>
  149. </view>
  150. </template>
  151. <script>
  152. import EmptyView from "../../../wigets/empty.vue";
  153. import request from "../../../request/index.js";
  154. import { formatDate } from "../../../utils/utils.js";
  155. const PROVINCES = ["北京市", "上海市", "广东省", "浙江省", "江苏省"];
  156. export default {
  157. components: {
  158. EmptyView,
  159. },
  160. data() {
  161. return {
  162. isRefreshing: false,
  163. loading: false,
  164. rows: [],
  165. totalCount: 60, // Simulated total count
  166. hasMore: true,
  167. pageNum: 1,
  168. pageSize: 20,
  169. dropdownProvinceOpen: false,
  170. provinceSearchText: "",
  171. provinceList: ["", ...PROVINCES],
  172. selectedProvince: "",
  173. };
  174. },
  175. computed: {
  176. displayRows() {
  177. if (!this.selectedProvince) return this.rows;
  178. return this.rows.filter(
  179. (item) => item.receiverProvince === this.selectedProvince,
  180. );
  181. },
  182. filteredProvinceList() {
  183. const keyword = (this.provinceSearchText || "").trim();
  184. if (!keyword) return this.provinceList;
  185. return this.provinceList.filter((p) =>
  186. (p || "全部省份").includes(keyword),
  187. );
  188. },
  189. },
  190. created() {
  191. this.resetFetch();
  192. },
  193. methods: {
  194. formatDate,
  195. getLevelClass(level) {
  196. if (level === "VIP") return "tag-vip";
  197. if (level === "二级") return "tag-l2";
  198. if (level === "三级") return "tag-l3";
  199. return "tag-default";
  200. },
  201. generateFakeData() {
  202. const newRows = [];
  203. const levels = ["VIP", "二级", "三级"];
  204. const natures = ["协议客户", "非协议客户"];
  205. const managers = ["张明华", "李建华", "王丽萍", "陈大文"];
  206. const startIdx = (this.pageNum - 1) * this.pageSize;
  207. const endIdx = Math.min(startIdx + this.pageSize, this.totalCount);
  208. if (startIdx >= this.totalCount) {
  209. this.hasMore = false;
  210. return [];
  211. }
  212. for (let i = startIdx; i < endIdx; i++) {
  213. newRows.push({
  214. id: i,
  215. receiverName: `测试收货企业${i + 1}有限公司`,
  216. receiverProvince: PROVINCES[i % PROVINCES.length],
  217. customerLevel: levels[i % levels.length],
  218. customerNature: natures[i % natures.length],
  219. manager: managers[i % managers.length],
  220. alertCount: Math.floor(Math.random() * 10) + 1,
  221. });
  222. }
  223. return newRows;
  224. },
  225. toggleProvinceDropdown() {
  226. this.dropdownProvinceOpen = !this.dropdownProvinceOpen;
  227. },
  228. closeProvinceDropdown() {
  229. this.dropdownProvinceOpen = false;
  230. },
  231. selectProvince(province) {
  232. this.selectedProvince = province || "";
  233. this.dropdownProvinceOpen = false;
  234. },
  235. onProvinceSearch() {},
  236. async onRefresh() {
  237. this.isRefreshing = true;
  238. this.pageNum = 1;
  239. this.hasMore = true;
  240. // Simulate network request
  241. setTimeout(() => {
  242. this.rows = this.generateFakeData();
  243. this.isRefreshing = false;
  244. }, 1000);
  245. },
  246. onLoadMore() {
  247. if (this.loading || !this.hasMore) return;
  248. this.loading = true;
  249. this.pageNum++;
  250. // Simulate network request
  251. setTimeout(() => {
  252. const more = this.generateFakeData();
  253. if (more.length > 0) {
  254. this.rows = [...this.rows, ...more];
  255. } else {
  256. this.hasMore = false;
  257. }
  258. this.loading = false;
  259. }, 800);
  260. },
  261. resetFetch() {
  262. this.loading = true;
  263. this.pageNum = 1;
  264. this.hasMore = true;
  265. // Simulate initial load
  266. setTimeout(() => {
  267. this.rows = this.generateFakeData();
  268. this.loading = false;
  269. }, 500);
  270. },
  271. toDetail(item) {
  272. uni.navigateTo({
  273. url: `/traceCodePackages/traceabilityReport/pages/ganmaoling/detail/index?id=${item.id}&name=${encodeURIComponent(item.receiverName)}`,
  274. });
  275. },
  276. handleExport() {
  277. uni.showModal({
  278. title: "导出至邮箱",
  279. editable: true,
  280. placeholderText: "请输入邮箱地址",
  281. success: (res) => {
  282. if (res.confirm) {
  283. if (!res.content) {
  284. uni.showToast({
  285. title: "请输入邮箱",
  286. icon: "none",
  287. });
  288. return;
  289. }
  290. uni.showToast({
  291. title: "导出请求已发送",
  292. icon: "success",
  293. });
  294. }
  295. },
  296. });
  297. },
  298. handleHistory() {
  299. uni.showToast({
  300. title: "历史记录功能开发中",
  301. icon: "none",
  302. });
  303. },
  304. },
  305. };
  306. </script>
  307. <style scoped>
  308. .detail-page {
  309. display: flex;
  310. flex-direction: column;
  311. height: calc(100vh - 116rpx - env(safe-area-inset-bottom));
  312. box-sizing: border-box;
  313. background: #f5f7fa;
  314. position: relative;
  315. }
  316. /* Header Background Layer */
  317. .header-bg {
  318. position: absolute;
  319. top: 0;
  320. left: 0;
  321. width: 100%;
  322. height: 320rpx; /* Fixed height for background */
  323. background: linear-gradient(135deg, #1890ff 0%, #096dd9 100%);
  324. border-bottom-left-radius: 40rpx;
  325. border-bottom-right-radius: 40rpx;
  326. z-index: 1;
  327. box-shadow: 0 10rpx 30rpx rgba(24, 144, 255, 0.2);
  328. }
  329. /* Header Content Layer */
  330. .header-section {
  331. padding: 40rpx 40rpx 80rpx;
  332. position: relative;
  333. z-index: 3; /* Above List */
  334. color: #fff;
  335. /* Transparent background to allow overlap effect */
  336. }
  337. .header-content {
  338. display: flex;
  339. justify-content: space-between;
  340. align-items: center;
  341. position: relative;
  342. z-index: 2;
  343. margin-bottom: 24rpx;
  344. }
  345. .title-group {
  346. display: flex;
  347. flex-direction: column;
  348. }
  349. .main-title {
  350. font-size: 40rpx;
  351. font-weight: bold;
  352. margin-bottom: 8rpx;
  353. letter-spacing: 2rpx;
  354. }
  355. .sub-title {
  356. font-size: 24rpx;
  357. opacity: 0.8;
  358. }
  359. .stat-box {
  360. display: flex;
  361. align-items: baseline;
  362. }
  363. .stat-num {
  364. font-size: 56rpx;
  365. font-weight: bold;
  366. margin-right: 8rpx;
  367. font-family: "DINAlternate-Bold", sans-serif;
  368. }
  369. .stat-unit {
  370. font-size: 24rpx;
  371. opacity: 0.8;
  372. }
  373. .header-toolbar {
  374. display: flex;
  375. justify-content: space-between;
  376. align-items: center;
  377. position: relative;
  378. z-index: 3;
  379. }
  380. .update-tip {
  381. display: inline-flex;
  382. align-items: center;
  383. background: rgba(255, 255, 255, 0.15);
  384. padding: 8rpx 20rpx;
  385. border-radius: 30rpx;
  386. font-size: 22rpx;
  387. backdrop-filter: blur(10px);
  388. }
  389. .tip-icon {
  390. margin-right: 8rpx;
  391. font-size: 20rpx;
  392. }
  393. /* Filter Styles */
  394. .filter-wrap {
  395. position: relative;
  396. }
  397. .selector {
  398. display: flex;
  399. align-items: center;
  400. color: #fff;
  401. font-size: 26rpx;
  402. font-weight: 500;
  403. padding: 8rpx 20rpx;
  404. background: rgba(255, 255, 255, 0.2);
  405. border-radius: 30rpx;
  406. border: 1rpx solid rgba(255, 255, 255, 0.3);
  407. }
  408. .selector-text {
  409. max-width: 200rpx;
  410. overflow: hidden;
  411. white-space: nowrap;
  412. text-overflow: ellipsis;
  413. }
  414. .selector-arrow {
  415. margin-left: 10rpx;
  416. width: 0;
  417. height: 0;
  418. border-left: 8rpx solid transparent;
  419. border-right: 8rpx solid transparent;
  420. border-top: 10rpx solid #fff;
  421. transition: transform 0.3s;
  422. }
  423. .selector-arrow.open {
  424. transform: rotate(180deg);
  425. }
  426. /* Dropdown Layer (Absolute on top of everything) */
  427. .dropdown-layer {
  428. position: absolute;
  429. top: 220rpx; /* Adjust based on header layout */
  430. right: 40rpx;
  431. z-index: 999;
  432. }
  433. .dropdown {
  434. width: 360rpx;
  435. background: #fff;
  436. border-radius: 12rpx;
  437. box-shadow: 0 8rpx 30rpx rgba(0, 0, 0, 0.15);
  438. overflow: hidden;
  439. }
  440. .dropdown-search-bar {
  441. padding: 16rpx;
  442. border-bottom: 1rpx solid #f0f0f0;
  443. }
  444. .dropdown-search-input {
  445. background: #f5f7fa;
  446. height: 64rpx;
  447. border-radius: 32rpx;
  448. padding: 0 24rpx;
  449. font-size: 26rpx;
  450. }
  451. .dropdown-scroll-view {
  452. max-height: 400rpx;
  453. }
  454. .dropdown-item {
  455. padding: 20rpx 30rpx;
  456. font-size: 28rpx;
  457. color: #333;
  458. display: flex;
  459. justify-content: space-between;
  460. align-items: center;
  461. transition: background 0.2s;
  462. }
  463. .dropdown-item:active {
  464. background: #f5f7fa;
  465. }
  466. .dropdown-item.active {
  467. color: #1890ff;
  468. font-weight: 500;
  469. background: #e6f7ff;
  470. }
  471. .check-mark {
  472. font-size: 24rpx;
  473. }
  474. .dropdown-empty {
  475. padding: 40rpx;
  476. text-align: center;
  477. color: #999;
  478. font-size: 26rpx;
  479. }
  480. /* List Section */
  481. .list-scroll {
  482. flex: 1;
  483. height: 0;
  484. padding: 0 24rpx;
  485. box-sizing: border-box;
  486. margin-top: -50rpx; /* Overlap effect */
  487. position: relative;
  488. z-index: 2; /* Between bg and header content */
  489. }
  490. .list-container {
  491. padding-top: 10rpx;
  492. padding-bottom: calc(200rpx + env(safe-area-inset-bottom));
  493. }
  494. .card-item {
  495. background: #fff;
  496. border-radius: 20rpx;
  497. padding: 30rpx;
  498. margin-bottom: 24rpx;
  499. box-shadow: 0 8rpx 24rpx rgba(0, 0, 0, 0.05);
  500. transition: transform 0.2s;
  501. }
  502. .card-item:active {
  503. transform: scale(0.99);
  504. }
  505. .card-header {
  506. display: flex;
  507. justify-content: space-between;
  508. align-items: flex-start;
  509. margin-bottom: 24rpx;
  510. }
  511. .header-left {
  512. flex: 1;
  513. display: flex;
  514. align-items: center;
  515. flex-wrap: wrap;
  516. margin-right: 20rpx;
  517. gap: 12rpx;
  518. }
  519. .index-num {
  520. font-size: 24rpx;
  521. color: #999;
  522. font-family: monospace;
  523. }
  524. .company-name {
  525. font-size: 32rpx;
  526. font-weight: 600;
  527. color: #333;
  528. line-height: 1.4;
  529. }
  530. .level-tag {
  531. font-size: 20rpx;
  532. padding: 4rpx 12rpx;
  533. border-radius: 8rpx;
  534. white-space: nowrap;
  535. line-height: 1.2;
  536. }
  537. .header-right {
  538. flex-shrink: 0;
  539. }
  540. .tag-vip {
  541. background: linear-gradient(135deg, #e6f7ff, #bae7ff);
  542. color: #096dd9;
  543. }
  544. .tag-l2 {
  545. background: linear-gradient(135deg, #f6ffed, #d9f7be);
  546. color: #389e0d;
  547. }
  548. .tag-l3 {
  549. background: linear-gradient(135deg, #fff7e6, #ffe7ba);
  550. color: #d46b08;
  551. }
  552. .tag-default {
  553. background: #f5f5f5;
  554. color: #999;
  555. }
  556. .card-body {
  557. background: #f9fbfd;
  558. border-radius: 12rpx;
  559. padding: 24rpx;
  560. }
  561. .info-grid {
  562. display: flex;
  563. flex-wrap: wrap;
  564. gap: 24rpx;
  565. }
  566. .info-item {
  567. display: flex;
  568. align-items: center;
  569. min-width: 45%;
  570. }
  571. .info-item .label {
  572. font-size: 24rpx;
  573. color: #999;
  574. margin-right: 12rpx;
  575. }
  576. .info-item .value {
  577. font-size: 26rpx;
  578. color: #666;
  579. font-weight: 500;
  580. }
  581. .alert-count {
  582. font-size: 22rpx;
  583. color: #ff4d4f;
  584. background: rgba(255, 77, 79, 0.1);
  585. padding: 6rpx 16rpx;
  586. border-radius: 20rpx;
  587. font-weight: 600;
  588. }
  589. /* Loading & Footer */
  590. .loading-more {
  591. display: flex;
  592. justify-content: center;
  593. align-items: center;
  594. padding: 30rpx 0;
  595. }
  596. .loading-text {
  597. font-size: 24rpx;
  598. color: #999;
  599. }
  600. .loading-icon {
  601. width: 32rpx;
  602. height: 32rpx;
  603. margin-right: 12rpx;
  604. animation: spin 1s linear infinite;
  605. }
  606. .empty-data {
  607. padding-top: 120rpx;
  608. }
  609. .no-more {
  610. text-align: center;
  611. color: #ccc;
  612. font-size: 24rpx;
  613. padding: 30rpx 0;
  614. }
  615. @keyframes spin {
  616. from {
  617. transform: rotate(0deg);
  618. }
  619. to {
  620. transform: rotate(360deg);
  621. }
  622. }
  623. .footer-btn-area {
  624. padding: 24rpx 32rpx calc(24rpx + env(safe-area-inset-bottom));
  625. background: #fff;
  626. box-shadow: 0 -4rpx 20rpx rgba(0, 0, 0, 0.08);
  627. position: fixed;
  628. z-index: 100;
  629. bottom: 0;
  630. width: 100%;
  631. box-sizing: border-box;
  632. display: flex;
  633. gap: 24rpx;
  634. }
  635. .action-btn {
  636. flex: 1;
  637. height: 88rpx;
  638. line-height: 88rpx;
  639. border-radius: 44rpx;
  640. font-size: 30rpx;
  641. font-weight: 600;
  642. text-align: center;
  643. border: none;
  644. transition: all 0.3s;
  645. }
  646. .action-btn::after {
  647. border: none;
  648. }
  649. .action-btn:active {
  650. transform: scale(0.96);
  651. }
  652. .history-btn {
  653. background: #fff;
  654. color: #1890ff;
  655. border: 2rpx solid #1890ff;
  656. box-shadow: 0 4rpx 12rpx rgba(24, 144, 255, 0.1);
  657. }
  658. .export-btn {
  659. background: linear-gradient(135deg, #1890ff 0%, #096dd9 100%);
  660. color: #fff;
  661. box-shadow: 0 6rpx 16rpx rgba(24, 144, 255, 0.35);
  662. }
  663. </style>