index.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583
  1. <template>
  2. <view class="detail-page" @click="closeProvinceDropdown">
  3. <view class="tip"
  4. >数据更新时间:{{
  5. formatDate(
  6. new Date().setDate(new Date().getDate() - 1),
  7. "YYYY-MM-DD",
  8. ) || "--"
  9. }}
  10. <view
  11. class="filter"
  12. :style="{
  13. position: 'relative',
  14. zIndex: dropdownProvinceOpen ? 9 : 'auto',
  15. }"
  16. >
  17. <view class="selector-wrap">
  18. <view class="selector" @click.stop="toggleProvinceDropdown">
  19. <text class="selector-text">{{
  20. selectedProvince ? selectedProvince : "全部省份"
  21. }}</text>
  22. <text
  23. class="selector-arrow"
  24. :class="{ open: dropdownProvinceOpen }"
  25. ></text>
  26. </view>
  27. <view class="dropdown" v-show="dropdownProvinceOpen" @click.stop>
  28. <view class="dropdown-search-bar">
  29. <input
  30. class="dropdown-search-input"
  31. v-model="provinceSearchText"
  32. @input="onProvinceSearch"
  33. placeholder="搜索省份..."
  34. />
  35. </view>
  36. <scroll-view scroll-y="true" class="dropdown-scroll-view">
  37. <view
  38. class="dropdown-item"
  39. v-for="(p, i) in filteredProvinceList"
  40. :key="p || i"
  41. :style="
  42. p === selectedProvince || (!selectedProvince && i === 0)
  43. ? {
  44. backgroundColor: '#2c69ff',
  45. color: '#fff',
  46. }
  47. : {}
  48. "
  49. @click.stop="selectProvince(p)"
  50. >{{ p || "全部省份" }}</view
  51. >
  52. <view
  53. v-if="filteredProvinceList.length === 0"
  54. class="dropdown-item"
  55. style="text-align: center; color: #999"
  56. >暂无数据</view
  57. >
  58. </scroll-view>
  59. </view>
  60. </view>
  61. </view>
  62. </view>
  63. <scroll-view
  64. class="list-scroll"
  65. scroll-y="true"
  66. refresher-enabled
  67. :refresher-triggered="isRefreshing"
  68. @refresherrefresh="onRefresh"
  69. @scrolltolower="onLoadMore"
  70. >
  71. <view class="list-container">
  72. <view
  73. class="card-item"
  74. v-for="(item, index) in displayRows"
  75. :key="index"
  76. @click="toDetail(item)"
  77. >
  78. <view class="left-info">
  79. <view class="row1-name">
  80. <view style="display: flex; align-items: center; gap: 10rpx">
  81. <text style="text-decoration: underline"
  82. >{{ index + 1 }}.{{ item.receiverName }}</text
  83. >
  84. <text
  85. class="level-tag"
  86. :class="getLevelClass(item.customerLevel)"
  87. >
  88. {{ item.customerLevel }}
  89. </text>
  90. </view>
  91. <view class="right-info">
  92. <text class="alert-count">{{ item.alertCount }}次预警</text>
  93. </view></view
  94. >
  95. <view class="row2-info">
  96. <text class="province">省份:{{ item.receiverProvince }} </text>
  97. </view>
  98. <view class="row3-nature">
  99. <text class="province">责任人:{{ item.manager }}</text>
  100. <text class="province">性质:{{ item.customerNature }}</text>
  101. </view>
  102. </view>
  103. </view>
  104. <view class="loading-more" v-if="loading">
  105. <image
  106. class="loading-icon"
  107. src="../../../static/images/loading.png"
  108. />
  109. </view>
  110. <view v-if="!loading && displayRows.length === 0" class="empty-data">
  111. <EmptyView text="无相关数据" />
  112. </view>
  113. <view v-if="!hasMore && displayRows.length > 0" class="no-more">
  114. <text>没有更多数据了</text>
  115. </view>
  116. </view>
  117. </scroll-view>
  118. <view class="footer-btn-area">
  119. <button class="export-btn" @click="handleExport">导出至邮箱</button>
  120. </view>
  121. </view>
  122. </template>
  123. <script>
  124. import EmptyView from "../../../wigets/empty.vue";
  125. import request from "../../../request/index.js";
  126. import { formatDate } from "../../../utils/utils.js";
  127. const PROVINCES = ["北京市", "上海市", "广东省", "浙江省", "江苏省"];
  128. export default {
  129. components: {
  130. EmptyView,
  131. },
  132. data() {
  133. return {
  134. isRefreshing: false,
  135. loading: false,
  136. rows: [],
  137. totalCount: 60, // Simulated total count
  138. hasMore: true,
  139. pageNum: 1,
  140. pageSize: 20,
  141. dropdownProvinceOpen: false,
  142. provinceSearchText: "",
  143. provinceList: ["", ...PROVINCES],
  144. selectedProvince: "",
  145. };
  146. },
  147. computed: {
  148. displayRows() {
  149. if (!this.selectedProvince) return this.rows;
  150. return this.rows.filter(
  151. (item) => item.receiverProvince === this.selectedProvince,
  152. );
  153. },
  154. filteredProvinceList() {
  155. const keyword = (this.provinceSearchText || "").trim();
  156. if (!keyword) return this.provinceList;
  157. return this.provinceList.filter((p) =>
  158. (p || "全部省份").includes(keyword),
  159. );
  160. },
  161. },
  162. created() {
  163. this.resetFetch();
  164. },
  165. methods: {
  166. formatDate,
  167. getLevelClass(level) {
  168. if (level === "VIP") return "tag-vip";
  169. if (level === "二级") return "tag-l2";
  170. if (level === "三级") return "tag-l3";
  171. return "tag-default";
  172. },
  173. generateFakeData() {
  174. const newRows = [];
  175. const levels = ["VIP", "二级", "三级"];
  176. const natures = ["协议客户", "非协议客户"];
  177. const managers = ["张明华", "李建华", "王丽萍", "陈大文"];
  178. const startIdx = (this.pageNum - 1) * this.pageSize;
  179. const endIdx = Math.min(startIdx + this.pageSize, this.totalCount);
  180. if (startIdx >= this.totalCount) {
  181. this.hasMore = false;
  182. return [];
  183. }
  184. for (let i = startIdx; i < endIdx; i++) {
  185. newRows.push({
  186. id: i,
  187. receiverName: `测试收货企业${i + 1}有限公司`,
  188. receiverProvince: PROVINCES[i % PROVINCES.length],
  189. customerLevel: levels[i % levels.length],
  190. customerNature: natures[i % natures.length],
  191. manager: managers[i % managers.length],
  192. alertCount: Math.floor(Math.random() * 10) + 1,
  193. });
  194. }
  195. return newRows;
  196. },
  197. toggleProvinceDropdown() {
  198. this.dropdownProvinceOpen = !this.dropdownProvinceOpen;
  199. },
  200. closeProvinceDropdown() {
  201. this.dropdownProvinceOpen = false;
  202. },
  203. selectProvince(province) {
  204. this.selectedProvince = province || "";
  205. this.dropdownProvinceOpen = false;
  206. },
  207. onProvinceSearch() {},
  208. async onRefresh() {
  209. this.isRefreshing = true;
  210. this.pageNum = 1;
  211. this.hasMore = true;
  212. // Simulate network request
  213. setTimeout(() => {
  214. this.rows = this.generateFakeData();
  215. this.isRefreshing = false;
  216. }, 1000);
  217. },
  218. onLoadMore() {
  219. if (this.loading || !this.hasMore) return;
  220. this.loading = true;
  221. this.pageNum++;
  222. // Simulate network request
  223. setTimeout(() => {
  224. const more = this.generateFakeData();
  225. if (more.length > 0) {
  226. this.rows = [...this.rows, ...more];
  227. } else {
  228. this.hasMore = false;
  229. }
  230. this.loading = false;
  231. }, 800);
  232. },
  233. resetFetch() {
  234. this.loading = true;
  235. this.pageNum = 1;
  236. this.hasMore = true;
  237. // Simulate initial load
  238. setTimeout(() => {
  239. this.rows = this.generateFakeData();
  240. this.loading = false;
  241. }, 500);
  242. },
  243. toDetail(item) {
  244. uni.navigateTo({
  245. url: `/traceCodePackages/traceabilityReport/pages/ganmaoling/detail/index?id=${item.id}&name=${encodeURIComponent(item.receiverName)}`,
  246. });
  247. },
  248. handleExport() {
  249. uni.showModal({
  250. title: "导出至邮箱",
  251. editable: true,
  252. placeholderText: "请输入邮箱地址",
  253. success: (res) => {
  254. if (res.confirm) {
  255. if (!res.content) {
  256. uni.showToast({
  257. title: "请输入邮箱",
  258. icon: "none",
  259. });
  260. return;
  261. }
  262. uni.showToast({
  263. title: "导出请求已发送",
  264. icon: "success",
  265. });
  266. }
  267. },
  268. });
  269. },
  270. },
  271. };
  272. </script>
  273. <style scoped>
  274. .detail-page {
  275. display: flex;
  276. flex-direction: column;
  277. height: calc(100vh - 116rpx - env(safe-area-inset-bottom));
  278. box-sizing: border-box;
  279. background: #f3f6f9;
  280. }
  281. .filter {
  282. background: #f3f6f9;
  283. padding: 8rpx 24rpx 0;
  284. }
  285. .selector-wrap {
  286. position: relative;
  287. display: flex;
  288. justify-content: flex-end;
  289. }
  290. .selector {
  291. position: relative;
  292. display: flex;
  293. align-items: center;
  294. color: #2c69ff;
  295. padding-right: 30rpx;
  296. }
  297. .selector-text {
  298. font-size: 30rpx;
  299. max-width: 240rpx;
  300. overflow: hidden;
  301. white-space: nowrap;
  302. text-overflow: ellipsis;
  303. display: inline-block;
  304. }
  305. .selector-arrow {
  306. position: absolute;
  307. right: 0rpx;
  308. bottom: 14rpx;
  309. font-size: 30rpx;
  310. display: inline-block;
  311. width: 15rpx;
  312. height: 15rpx;
  313. border: 5rpx solid #2c69ff;
  314. border-top: none;
  315. border-left: none;
  316. transform-origin: 50% 50%;
  317. transform: rotate(45deg);
  318. transition: transform 0.2s;
  319. }
  320. .selector-arrow.open {
  321. bottom: 7rpx;
  322. transform: rotate(225deg);
  323. }
  324. .dropdown {
  325. position: absolute;
  326. right: 0rpx;
  327. top: 54rpx;
  328. width: 310rpx;
  329. max-height: 380rpx;
  330. background: #fff;
  331. border: 1rpx solid #eef0f4;
  332. border-radius: 12rpx;
  333. box-shadow: 0 8rpx 24rpx rgba(0, 0, 0, 0.08);
  334. z-index: 93;
  335. overflow: hidden;
  336. }
  337. .dropdown-search-bar {
  338. padding: 10rpx;
  339. border-bottom: 1rpx solid #f0f2f5;
  340. background: #fff;
  341. z-index: 94;
  342. }
  343. .dropdown-search-input {
  344. width: 100%;
  345. height: 60rpx;
  346. background: #f5f7fa;
  347. border-radius: 8rpx;
  348. padding: 0 20rpx;
  349. font-size: 28rpx;
  350. box-sizing: border-box;
  351. }
  352. .dropdown-scroll-view {
  353. flex: 1;
  354. width: 100%;
  355. max-height: 260rpx;
  356. overflow-y: auto;
  357. }
  358. .dropdown-item {
  359. padding: 16rpx 24rpx;
  360. font-size: 28rpx;
  361. color: #333;
  362. text-wrap: wrap;
  363. }
  364. .dropdown-item + .dropdown-item {
  365. border-top: 1rpx solid #f0f2f5;
  366. }
  367. .tip {
  368. font-size: 24rpx;
  369. color: #999;
  370. padding: 24rpx;
  371. background: #f3f6f9;
  372. }
  373. .list-scroll {
  374. flex: 1;
  375. height: 0;
  376. /* Important for flex expansion */
  377. padding: 0 24rpx;
  378. box-sizing: border-box;
  379. }
  380. .list-container {
  381. padding-bottom: calc(200rpx + env(safe-area-inset-bottom));
  382. }
  383. .card-item {
  384. display: flex;
  385. justify-content: space-between;
  386. /* Align top */
  387. background: #fff;
  388. border-radius: 16rpx;
  389. padding: 30rpx;
  390. margin-bottom: 20rpx;
  391. box-shadow: 0 2rpx 10rpx rgba(0, 0, 0, 0.05);
  392. }
  393. .left-info {
  394. flex: 1;
  395. }
  396. .row1-name {
  397. font-size: 30rpx;
  398. font-weight: bold;
  399. color: #1890ff;
  400. margin-bottom: 16rpx;
  401. display: flex;
  402. align-items: center;
  403. justify-content: space-between;
  404. gap: 20rpx;
  405. }
  406. .row2-info {
  407. display: flex;
  408. align-items: center;
  409. margin-bottom: 12rpx;
  410. }
  411. .province {
  412. font-size: 26rpx;
  413. color: #666;
  414. margin-right: 20rpx;
  415. }
  416. .level-tag {
  417. font-size: 22rpx;
  418. padding: 4rpx 12rpx;
  419. border-radius: 6rpx;
  420. background: #f0f0f0;
  421. color: #666;
  422. }
  423. .tag-vip {
  424. background: #e6f7ff;
  425. color: #1890ff;
  426. }
  427. .tag-l2 {
  428. background: #f6ffed;
  429. color: #52c41a;
  430. }
  431. .tag-l3 {
  432. background: #fff7e6;
  433. color: #fa8c16;
  434. }
  435. .row3-nature {
  436. font-size: 26rpx;
  437. color: #666;
  438. margin-bottom: 12rpx;
  439. display: flex;
  440. align-items: center;
  441. gap: 20rpx;
  442. }
  443. .row4-manager {
  444. font-size: 26rpx;
  445. color: #666;
  446. }
  447. .right-info {
  448. display: flex;
  449. align-items: center;
  450. align-self: center;
  451. /* Center vertically relative to card */
  452. }
  453. .alert-count {
  454. background: #fff2f0;
  455. color: #ff4d4f;
  456. font-size: 24rpx;
  457. padding: 8rpx 20rpx;
  458. border-radius: 30rpx;
  459. font-weight: bold;
  460. }
  461. .loading-more {
  462. display: flex;
  463. justify-content: center;
  464. align-items: center;
  465. padding: 20rpx 0;
  466. }
  467. .loading-icon {
  468. width: 32rpx;
  469. height: 32rpx;
  470. margin-right: 10rpx;
  471. animation: spin 1s linear infinite;
  472. }
  473. .empty-data {
  474. display: flex;
  475. justify-content: center;
  476. padding-top: 100rpx;
  477. }
  478. .no-more {
  479. text-align: center;
  480. color: #999;
  481. font-size: 24rpx;
  482. padding: 20rpx 0;
  483. }
  484. @keyframes spin {
  485. from {
  486. transform: rotate(0deg);
  487. }
  488. to {
  489. transform: rotate(360deg);
  490. }
  491. }
  492. .footer-btn-area {
  493. padding: 24rpx 32rpx calc(24rpx + env(safe-area-inset-bottom));
  494. background: #fff;
  495. box-shadow: 0 -4rpx 16rpx rgba(0, 0, 0, 0.05);
  496. position: fixed;
  497. z-index: 10;
  498. bottom: 0;
  499. width: 100%;
  500. box-sizing: border-box;
  501. }
  502. .export-btn {
  503. background: linear-gradient(135deg, #1890ff 0%, #096dd9 100%);
  504. color: #fff;
  505. border-radius: 44rpx;
  506. font-size: 32rpx;
  507. font-weight: 500;
  508. height: 88rpx;
  509. line-height: 88rpx;
  510. border: none;
  511. box-shadow: 0 6rpx 16rpx rgba(24, 144, 255, 0.35);
  512. transition: all 0.3s;
  513. }
  514. .export-btn:active {
  515. transform: scale(0.98);
  516. box-shadow: 0 2rpx 8rpx rgba(24, 144, 255, 0.35);
  517. }
  518. .export-btn::after {
  519. border: none;
  520. }
  521. </style>