index.vue 17 KB

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