index.vue 14 KB

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