index.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588
  1. <template>
  2. <Water></Water>
  3. <view class="history-page">
  4. <view class="header-section">
  5. <view class="header-title">历史记录</view>
  6. <view class="filter-tabs">
  7. <view class="tab-item" v-for="(tab, index) in timeFilters" :key="index"
  8. :class="{ active: currentFilter === tab.value }" @click="switchFilter(tab.value)">
  9. {{ tab.label }}
  10. </view>
  11. </view>
  12. </view>
  13. <scroll-view class="list-scroll" scroll-y="true" refresher-enabled :refresher-triggered="isRefreshing"
  14. @refresherrefresh="onRefresh">
  15. <view class="list-container">
  16. <view class="date-group" v-for="groupItem in groupedRows" :key="groupItem.date">
  17. <view class="date-group-card">
  18. <view class="group-left">
  19. <!-- <text class="calendar-icon">📅</text> -->
  20. <text class="date-label">{{ groupItem.date }}</text>
  21. </view>
  22. <button class="group-export-btn" @click.stop="handleExportByDate(groupItem)">
  23. 导出
  24. </button>
  25. </view>
  26. <view class="card-item" v-for="(item, index) in groupItem.list" :key="index" @click="toDetail(item)">
  27. <view class="card-header">
  28. <view class="header-left">
  29. <text class="company-name">{{ item.queryCustomer }}</text>
  30. </view>
  31. <view class="header-right">
  32. <text class="status-tag">黑名单</text>
  33. </view>
  34. </view>
  35. <view class="card-body">
  36. <view class="code-row">
  37. <text class="label">信用代码:</text>
  38. <text class="value code-text">{{ item.socialCreditCode }}</text>
  39. </view>
  40. <view class="info-grid">
  41. <view class="info-item">
  42. <text class="label">省份</text>
  43. <text class="value">{{ item.province }}</text>
  44. </view>
  45. </view>
  46. </view>
  47. </view>
  48. </view>
  49. <view v-if="loading" class="loading-more">
  50. <image class="loading-icon" src="../../../../static/images/loading.png" />
  51. <text class="loading-text">加载中...</text>
  52. </view>
  53. <view v-if="!loading && rows.length === 0" class="empty-data">
  54. <EmptyView text="暂无历史记录" />
  55. </view>
  56. </view>
  57. </scroll-view>
  58. <!-- 蒙层 -->
  59. <view class="report-export-create-modal-mask" v-if="emailModalOpen" @click="closeEmailModal"
  60. @touchmove.stop.prevent></view>
  61. <!-- 邮箱导出弹窗 -->
  62. <view class="report-export-create-modal report-export-create-email-modal"
  63. :class="{ 'report-export-create-modal--open': emailModalOpen }" v-if="emailModalOpen">
  64. <view class="report-export-create-modal-title">
  65. <text>发送至邮箱</text>
  66. <view class="report-export-create-modal-close" @click.stop="closeEmailModal">×</view>
  67. </view>
  68. <view class="report-export-create-modal-body">
  69. <view class="export-date-tip">导出日期:{{ currentExportDate }}</view>
  70. <up-input v-model="emailForm.email" border="none" :customStyle="{
  71. backgroundColor: '#ebf3fb',
  72. height: '80rpx',
  73. paddingLeft: '20rpx',
  74. }" placeholder="请填写邮箱" @input="emailError = false" disabled>
  75. <template #suffix>
  76. <view style="margin-right: 20rpx; color: #666">@999.com.cn</view>
  77. </template>
  78. </up-input>
  79. <text v-if="emailError" class="report-export-error-text">请输入邮箱</text>
  80. </view>
  81. <view class="report-export-create-modal-footer">
  82. <view class="report-export-create-modal-btn cancel-btn" @click.stop="closeEmailModal">取消</view>
  83. <view class="report-export-create-modal-btn confirm-btn" @click.stop="handleSendEmail">发送</view>
  84. </view>
  85. </view>
  86. </view>
  87. </template>
  88. <script>
  89. import EmptyView from "../../../../wigets/empty.vue";
  90. import { formatDate } from "../../../../utils/utils.js";
  91. import request from "../../../../request/index.js";
  92. import Water from "@/components/water/water.vue";
  93. export default {
  94. components: {
  95. EmptyView,
  96. Water
  97. },
  98. data() {
  99. return {
  100. isRefreshing: false,
  101. loading: false,
  102. rows: [],
  103. currentFilter: "all",
  104. timeFilters: [
  105. { label: "全部", value: "all" },
  106. { label: "近7天", value: "7" },
  107. { label: "近15天", value: "15" },
  108. { label: "近30天", value: "30" },
  109. ],
  110. emailModalOpen: false,
  111. emailForm: {
  112. email: "",
  113. },
  114. emailError: false,
  115. currentExportDate: "",
  116. };
  117. },
  118. computed: {
  119. groupedRows() {
  120. const groups = {};
  121. this.rows.forEach((item) => {
  122. const date = item.billTime || "未知日期";
  123. if (!groups[date]) {
  124. groups[date] = [];
  125. }
  126. groups[date].push(item);
  127. });
  128. // 按日期倒序排列
  129. return Object.keys(groups)
  130. .sort((a, b) => new Date(b.replace(/-/g, "/")) - new Date(a.replace(/-/g, "/")))
  131. .map((date) => ({
  132. date,
  133. list: groups[date],
  134. }));
  135. },
  136. },
  137. created() {
  138. this.resetFetch();
  139. const userEmail = uni.getStorageSync('traceCode_useremail')
  140. this.emailForm.email = userEmail
  141. },
  142. methods: {
  143. formatDate,
  144. switchFilter(value) {
  145. if (this.currentFilter === value) return;
  146. this.currentFilter = value;
  147. this.resetFetch();
  148. },
  149. fetchList() {
  150. if (this.loading) return;
  151. this.loading = true;
  152. const today = new Date();
  153. let fromDateStr = "";
  154. const toDateStr = formatDate(today, "YYYY-MM-DD");
  155. if (this.currentFilter === "all") {
  156. // 全部:最近2个月
  157. const twoMonthsAgo = new Date();
  158. twoMonthsAgo.setMonth(today.getMonth() - 2);
  159. fromDateStr = formatDate(twoMonthsAgo, "YYYY-MM-DD");
  160. } else {
  161. const days = parseInt(this.currentFilter);
  162. const pastDate = new Date();
  163. pastDate.setDate(today.getDate() - days);
  164. fromDateStr = formatDate(pastDate, "YYYY-MM-DD");
  165. }
  166. request("/blacklist-report/get-export-company-data", {
  167. fromDate: fromDateStr,//'2024-01-01',
  168. toDate: toDateStr,//'2026-01-01',
  169. path: "traceabilityReport/pages/blacklist/history/index.vue",
  170. }).then((res) => {
  171. if (res.code == 200) {
  172. this.rows = res.data || [];
  173. }
  174. this.loading = false;
  175. this.isRefreshing = false;
  176. });
  177. },
  178. async onRefresh() {
  179. this.isRefreshing = true;
  180. this.fetchList();
  181. },
  182. resetFetch() {
  183. this.rows = [];
  184. this.fetchList();
  185. },
  186. toDetail(item) {
  187. uni.navigateTo({
  188. url: `/traceCodePackages/traceabilityReport/pages/blacklist/detail/index?id=${item.socialCreditCode}&dateStr=${item.billTime}&name=${encodeURIComponent(item.queryCustomer)}`,
  189. });
  190. },
  191. handleExportByDate(data) {
  192. this.currentExportDate = data.date;
  193. this.emailModalOpen = true;
  194. this.emailError = false;
  195. this.taskId = data.list[0]?.taskId || ''
  196. },
  197. closeEmailModal() {
  198. this.emailModalOpen = false;
  199. this.taskId = ''
  200. },
  201. handleSendEmail() {
  202. if (!this.emailForm.email) {
  203. this.emailError = true;
  204. return;
  205. }
  206. uni.showLoading({ title: "发送中..." });
  207. request("/report/sendemail", {
  208. taskId: this.taskId,
  209. emailAddress: this.emailForm.email + "@999.com.cn",
  210. path: "traceabilityReport/pages/blacklist/history/index.vue",
  211. }).then((res) => {
  212. uni.hideLoading();
  213. if (res.code == 200) {
  214. uni.showToast({
  215. title: "发送成功",
  216. icon: "success",
  217. });
  218. this.closeEmailModal();
  219. } else {
  220. uni.showToast({
  221. title: res.msg || "发送失败",
  222. icon: "none",
  223. });
  224. }
  225. });
  226. },
  227. },
  228. };
  229. </script>
  230. <style scoped>
  231. .history-page {
  232. display: flex;
  233. flex-direction: column;
  234. height: 100vh;
  235. background: #f5f7fa;
  236. }
  237. .company-name {
  238. font-size: 32rpx;
  239. font-weight: 600;
  240. color: #096dd9;
  241. line-height: 1.4;
  242. text-decoration: underline;
  243. }
  244. .header-section {
  245. background: linear-gradient(135deg, #2b32b2 0%, #1488cc 100%);
  246. padding: 30rpx 30rpx 60rpx;
  247. color: #fff;
  248. border-bottom-left-radius: 40rpx;
  249. border-bottom-right-radius: 40rpx;
  250. box-shadow: 0 10rpx 30rpx rgba(20, 136, 204, 0.2);
  251. z-index: 10;
  252. position: relative;
  253. }
  254. .header-title {
  255. font-size: 36rpx;
  256. font-weight: bold;
  257. text-align: center;
  258. margin-bottom: 30rpx;
  259. }
  260. .filter-tabs {
  261. display: flex;
  262. background: rgba(255, 255, 255, 0.2);
  263. border-radius: 16rpx;
  264. padding: 8rpx;
  265. }
  266. .tab-item {
  267. flex: 1;
  268. text-align: center;
  269. font-size: 26rpx;
  270. padding: 12rpx 0;
  271. border-radius: 12rpx;
  272. color: rgba(255, 255, 255, 0.8);
  273. transition: all 0.3s;
  274. }
  275. .tab-item.active {
  276. background: #fff;
  277. color: #2b32b2;
  278. font-weight: 600;
  279. box-shadow: 0 4rpx 12rpx rgba(0, 0, 0, 0.1);
  280. }
  281. .list-scroll {
  282. flex: 1;
  283. height: 0;
  284. margin-top: -40rpx;
  285. z-index: 11;
  286. padding: 0 24rpx;
  287. box-sizing: border-box;
  288. }
  289. .list-container {
  290. padding-top: 65rpx;
  291. padding-bottom: 40rpx;
  292. }
  293. .date-group {
  294. margin-bottom: 40rpx;
  295. }
  296. .date-group-card {
  297. display: flex;
  298. align-items: center;
  299. justify-content: space-between;
  300. background: #fff;
  301. padding: 20rpx 30rpx;
  302. border-radius: 16rpx;
  303. margin-bottom: 20rpx;
  304. box-shadow: 0 4rpx 12rpx rgba(0, 0, 0, 0.03);
  305. border-left: 8rpx solid #1488cc;
  306. }
  307. .group-left {
  308. display: flex;
  309. align-items: center;
  310. }
  311. .calendar-icon {
  312. font-size: 32rpx;
  313. margin-right: 16rpx;
  314. }
  315. .date-label {
  316. font-size: 30rpx;
  317. font-weight: 600;
  318. color: #333;
  319. }
  320. .group-export-btn {
  321. margin: 0;
  322. padding: 0 24rpx;
  323. height: 52rpx;
  324. line-height: 50rpx;
  325. font-size: 24rpx;
  326. color: #1488cc;
  327. background: #fff;
  328. border: 2rpx solid #1488cc;
  329. border-radius: 26rpx;
  330. font-weight: 500;
  331. }
  332. .group-export-btn::after {
  333. border: none;
  334. }
  335. .group-export-btn:active {
  336. opacity: 0.7;
  337. transform: scale(0.95);
  338. }
  339. .card-item {
  340. background: #fff;
  341. border-radius: 20rpx;
  342. padding: 30rpx;
  343. margin-bottom: 24rpx;
  344. box-shadow: 0 8rpx 24rpx rgba(0, 0, 0, 0.05);
  345. }
  346. .card-header {
  347. display: flex;
  348. justify-content: space-between;
  349. align-items: center;
  350. margin-bottom: 20rpx;
  351. padding-bottom: 20rpx;
  352. border-bottom: 1rpx solid #f5f5f5;
  353. }
  354. .date-text {
  355. font-size: 28rpx;
  356. font-weight: 600;
  357. color: #333;
  358. }
  359. .status-tag {
  360. font-size: 20rpx;
  361. padding: 4rpx 12rpx;
  362. border-radius: 8rpx;
  363. background: #fff1f0;
  364. color: #f5222d;
  365. font-weight: 500;
  366. }
  367. .card-body {
  368. font-size: 26rpx;
  369. }
  370. .row {
  371. display: flex;
  372. margin-bottom: 16rpx;
  373. }
  374. .code-row {
  375. display: flex;
  376. align-items: center;
  377. margin-bottom: 16rpx;
  378. }
  379. .code-text {
  380. font-family: monospace;
  381. color: #333 !important;
  382. font-weight: 600 !important;
  383. }
  384. .info-grid {
  385. display: flex;
  386. justify-content: space-between;
  387. }
  388. .info-item {
  389. display: flex;
  390. align-items: center;
  391. width: 48%;
  392. }
  393. .label {
  394. color: #999;
  395. margin-right: 12rpx;
  396. }
  397. .value {
  398. color: #666;
  399. font-weight: 500;
  400. }
  401. .loading-more,
  402. .no-more,
  403. .empty-data {
  404. display: flex;
  405. justify-content: center;
  406. align-items: center;
  407. padding: 30rpx 0;
  408. color: #999;
  409. font-size: 24rpx;
  410. }
  411. .loading-icon {
  412. width: 32rpx;
  413. height: 32rpx;
  414. margin-right: 12rpx;
  415. animation: spin 1s linear infinite;
  416. }
  417. @keyframes spin {
  418. from {
  419. transform: rotate(0deg);
  420. }
  421. to {
  422. transform: rotate(360deg);
  423. }
  424. }
  425. /* 弹窗样式 */
  426. .report-export-create-modal-mask {
  427. position: fixed;
  428. top: 0;
  429. left: 0;
  430. right: 0;
  431. bottom: 0;
  432. background: rgba(0, 0, 0, 0.6);
  433. z-index: 999;
  434. backdrop-filter: blur(2px);
  435. }
  436. .report-export-create-modal {
  437. position: fixed;
  438. z-index: 1000;
  439. background: #fff;
  440. transition: all 0.3s ease;
  441. }
  442. .report-export-create-email-modal {
  443. top: 50%;
  444. left: 50%;
  445. transform: translate(-50%, -50%);
  446. width: 620rpx;
  447. border-radius: 24rpx;
  448. opacity: 0;
  449. visibility: hidden;
  450. overflow: hidden;
  451. }
  452. .report-export-create-email-modal.report-export-create-modal--open {
  453. opacity: 1;
  454. visibility: visible;
  455. }
  456. .report-export-create-modal-title {
  457. padding: 36rpx 32rpx;
  458. font-size: 36rpx;
  459. color: #333;
  460. text-align: center;
  461. font-weight: 600;
  462. border-bottom: 1rpx solid #f0f0f0;
  463. position: relative;
  464. }
  465. .report-export-create-modal-close {
  466. position: absolute;
  467. right: 32rpx;
  468. top: 50%;
  469. transform: translateY(-50%);
  470. font-size: 44rpx;
  471. color: #999;
  472. line-height: 1;
  473. padding: 10rpx;
  474. }
  475. .report-export-create-modal-body {
  476. padding: 40rpx 40rpx 32rpx;
  477. }
  478. .export-date-tip {
  479. font-size: 26rpx;
  480. color: #1488cc;
  481. margin-bottom: 32rpx;
  482. background: #ebf3fb;
  483. padding: 20rpx 24rpx;
  484. border-radius: 12rpx;
  485. border-left: 6rpx solid #1488cc;
  486. font-weight: 500;
  487. }
  488. .report-export-error-text {
  489. font-size: 24rpx;
  490. color: #ff4d4f;
  491. margin-top: 12rpx;
  492. display: block;
  493. }
  494. .report-export-create-modal-footer {
  495. padding: 0 40rpx 48rpx;
  496. display: flex;
  497. justify-content: space-between;
  498. gap: 24rpx;
  499. }
  500. .report-export-create-modal-btn {
  501. height: 88rpx;
  502. line-height: 88rpx;
  503. border-radius: 44rpx;
  504. text-align: center;
  505. font-size: 30rpx;
  506. font-weight: 600;
  507. flex: 1;
  508. margin: 0;
  509. }
  510. .cancel-btn {
  511. background: #f5f7fa;
  512. color: #666;
  513. border: 1rpx solid #e4e7ed;
  514. }
  515. .confirm-btn {
  516. background: linear-gradient(135deg, #1890ff 0%, #096dd9 100%);
  517. color: #fff;
  518. box-shadow: 0 6rpx 16rpx rgba(24, 144, 255, 0.3);
  519. }
  520. </style>