index.vue 13 KB

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