hexiao_record.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664
  1. <template>
  2. <view class="page-container">
  3. <view class="sticky-header">
  4. <view class="search-wrapper">
  5. <view class="query">
  6. <u-row customStyle="margin-bottom: 10px" gutter="20">
  7. <u-col span="9">
  8. <u--input
  9. @focus="timeShow = true"
  10. v-model="startTimeXd"
  11. placeholder="开始日期 ~ 结束日期"
  12. prefixIcon="calendar"
  13. prefixIconStyle="font-size: 22px;color: #909399"
  14. @clear="handleSearch"
  15. ></u--input>
  16. </u-col>
  17. <u-col span="3">
  18. <view class="query-btn" @click="clearSearch">
  19. <view class="query-btn-text">清空</view>
  20. </view>
  21. </u-col>
  22. </u-row>
  23. </view>
  24. </view>
  25. <view class="tabs-wrapper">
  26. <view
  27. v-for="tab in tabs"
  28. :key="tab.key"
  29. class="tab-item"
  30. :class="{ 'active': currentTab === tab.id }"
  31. @click="changeTab(tab.id)"
  32. >
  33. {{ tab.name }}
  34. </view>
  35. </view>
  36. </view>
  37. <!-- 门店汇总显示区域 - 表格形式 -->
  38. <view v-if="currentTab === 3" class="store-summary-container">
  39. <scroll-view class="summary-list" scroll-y="true">
  40. <view v-if="summaryList.length === 0" class="empty-list">
  41. <text>暂无汇总数据</text>
  42. </view>
  43. <view v-else class="summary-table-wrapper">
  44. <!-- 表头 -->
  45. <view class="table-header">
  46. <view class="header-cell store-col">门店</view>
  47. <view class="header-cell product-col">品相</view>
  48. <view class="header-cell number-col">数量</view>
  49. </view>
  50. <!-- 表格内容 -->
  51. <view class="table-body">
  52. <!-- 每个门店的第一行 -->
  53. <view class="table-row" v-for="(store, storeIndex) in summaryList" :key="storeIndex">
  54. <view class="table-cell store-col">
  55. <view class="store-name-cell">
  56. <uni-icons type="shop" size="16" color="#3c82f8"></uni-icons>
  57. <text class="store-name-text">{{ store.storeName }}</text>
  58. </view>
  59. </view>
  60. <view>
  61. <view class="table-row-cl2" v-for="(item, itemIndex) in store.writeOffRecordDetailVos" :key="itemIndex">
  62. <view class="table-cell product-col">
  63. <text>{{ item.item }}</text>
  64. </view>
  65. <view class="table-cell number-col">
  66. <text>{{ item.writeOffAmount }}</text>
  67. </view>
  68. </view>
  69. <view class="table-row-cl2 ">
  70. <view class="table-cell product-col">
  71. <text>汇总</text>
  72. </view>
  73. <view class="table-cell number-col">
  74. <text style="color: orange;">{{ store.summaryCount }}</text>
  75. </view>
  76. </view>
  77. </view>
  78. </view>
  79. </view>
  80. </view>
  81. </scroll-view>
  82. </view>
  83. <!-- 原有记录列表(tab 0-2时显示) -->
  84. <scroll-view
  85. v-else
  86. class="list-container"
  87. scroll-y="true"
  88. @scrolltolower="loadMore"
  89. >
  90. <view v-if="recordList.length === 0 && loadStatus !== 'loading'" class="empty-list">
  91. <text>暂无相关记录</text>
  92. </view>
  93. <view v-for="record in recordList" :key="record.orderNo" class="record-card">
  94. <view class="card-header">
  95. <uni-icons type="paperclip" size="20" color="#3c82f8"></uni-icons>
  96. <text class="record-id" @click="detail(record.orderNo)" style="text-decoration: underline">{{ record.orderNo }}</text>
  97. <view class="status-badge pending" v-if="record.status === 0">
  98. {{ getStatusText(record.status) }}
  99. </view>
  100. <view class="status-badge verifying" v-if="record.status === 1">
  101. {{ getStatusText(record.status) }}
  102. </view>
  103. <view class="status-badge verified" v-if="record.status === 2">
  104. {{ getStatusText(record.status) }}
  105. </view>
  106. </view>
  107. <view class="card-body">
  108. <view class="detail-row">
  109. <text class="detail-label">门店名称</text>
  110. <text class="detail-value">{{ record.storeName }}</text>
  111. </view>
  112. <view class="detail-row">
  113. <text class="detail-label">上传时间</text>
  114. <text class="detail-value">{{ record.uploadTime }}</text>
  115. </view>
  116. <view class="detail-row">
  117. <text class="detail-label">商品总数</text>
  118. <text class="detail-value">{{ record.writeOffNum }}</text>
  119. </view>
  120. <view class="detail-row product-item" v-for="(item, index) in record.writeOffRecordDetailVos" :key="index">
  121. <text class="detail-label">{{ item.categoryName }}</text>
  122. <text class="detail-value">{{ item.num }}</text>
  123. </view>
  124. <view class="detail-row" v-if="record.status === 1 ||record.status === 2">
  125. <text class="detail-label">提交时间</text>
  126. <text class="detail-value">{{ record.applyTime }}</text>
  127. </view>
  128. <view class="detail-row" v-if="record.status === 2">
  129. <text class="detail-label">审核时间</text>
  130. <text class="detail-value">{{ record.writeOffTime }}</text>
  131. </view>
  132. </view>
  133. <view class="card-footer" v-if="record.status === 0">
  134. <button class="verify-btn" @click="verify(record.id,record.orderNo)">一键核销</button>
  135. </view>
  136. </view>
  137. <uni-load-more :status="loadStatus"></uni-load-more>
  138. </scroll-view>
  139. <u-calendar min-date="2025-07-01" max-date="2030-07-01" @close="timeShow = false" :show="timeShow" :mode="mode" @confirm="confirm"></u-calendar>
  140. </view>
  141. </template>
  142. <script>
  143. import {queryAddRecord, doCommitToJxs, queryStoreSummary} from "@/api/hexiao"; // 假设新的接口
  144. export default {
  145. data() {
  146. return {
  147. startTime: '',
  148. endTime: '',
  149. timeShow: false,
  150. startTimeXd: "",
  151. mode: 'range',
  152. searchQuery: '',
  153. tabs: [
  154. { name: '待核销', key: 'pending', id: 0 },
  155. { name: '核销中', key: 'verifying', id: 1},
  156. { name: '已核销', key: 'verified', id: 2},
  157. { name: '门店汇总', key: 'all', id: 3},
  158. ],
  159. currentTab: 0,
  160. recordList: [],
  161. summaryList: [
  162. {
  163. writeOffRecordDetailVos:[]
  164. }
  165. ], // 门店汇总数据
  166. grandTotal: 0, // 总计数量
  167. pagination: { page: 1, limit: 10 },
  168. loadStatus: 'more', // 'more', 'loading', 'noMore'
  169. isLoading: false,
  170. };
  171. },
  172. onLoad() {
  173. this.fetchRecords(true);
  174. },
  175. onPullDownRefresh() {
  176. if (this.currentTab === 3) {
  177. this.fetchStoreSummary(true);
  178. } else {
  179. this.fetchRecords(true);
  180. }
  181. },
  182. methods: {
  183. confirm(e) {
  184. this.startTime = e[0];
  185. this.endTime = e[e.length-1];
  186. this.startTimeXd = e[0]+' ~ '+e[e.length-1];
  187. if(!this.show){
  188. this.handleSearch()
  189. }
  190. this.timeShow = false;
  191. },
  192. getStatusClass(status){
  193. const statusMap = {
  194. 0: 'pending',
  195. 1: 'verifying',
  196. 2: 'verified'
  197. };
  198. return statusMap[status] || '';
  199. },
  200. getStatusText(status) {
  201. const statusMap = {
  202. 0: '待核销',
  203. 1: '核销中',
  204. 2: '已核销'
  205. };
  206. return statusMap[status] || '未知';
  207. },
  208. changeTab(tabKey) {
  209. if (this.currentTab === tabKey) return;
  210. this.currentTab = tabKey;
  211. if (this.currentTab === 3) {
  212. // 切换到门店汇总tab
  213. this.fetchStoreSummary(true);
  214. } else {
  215. // 切换到其他tab(0-2)
  216. this.fetchRecords(true);
  217. }
  218. },
  219. async fetchStoreSummary(isRefresh = false) {
  220. if (this.isLoading) return;
  221. this.isLoading = true;
  222. try {
  223. const params = {
  224. startTime: this.startTime,
  225. endTime: this.endTime
  226. };
  227. const res = await queryStoreSummary(params);
  228. if (res.code === 0) {
  229. this.summaryList = res.data || [];
  230. this.grandTotal = res.data.grandTotal || 0;
  231. } else {
  232. this.summaryList = [];
  233. this.grandTotal = 0;
  234. uni.showToast({ title: '获取汇总数据失败', icon: 'none' });
  235. }
  236. console.log('this.summaryList',this.summaryList)
  237. console.log('this.summaryList',this.summaryList.length)
  238. } catch (error) {
  239. console.error('获取门店汇总失败:', error);
  240. this.summaryList = [];
  241. this.grandTotal = 0;
  242. } finally {
  243. this.isLoading = false;
  244. uni.stopPullDownRefresh();
  245. }
  246. },
  247. async fetchRecords(isRefresh = false) {
  248. if (this.isLoading || (this.loadStatus === 'noMore' && !isRefresh)) {
  249. return;
  250. }
  251. if (isRefresh) {
  252. this.pagination.page = 1;
  253. this.recordList = [];
  254. this.loadStatus = 'more';
  255. }
  256. this.isLoading = true;
  257. this.loadStatus = 'loading';
  258. let data = {};
  259. if(this.currentTab !== -1){
  260. data.status = this.currentTab;
  261. }
  262. data.startTime = this.startTime;
  263. data.endTime = this.endTime;
  264. data.pageIndex = this.pagination.page
  265. data.pageSize = this.pagination.limit
  266. queryAddRecord(data).then(res=>{
  267. let finalData = res.data.records;
  268. if(!finalData){
  269. finalData = [];
  270. }
  271. if (finalData.length > 0) {
  272. this.recordList = [...this.recordList, ...finalData];
  273. this.pagination.page++;
  274. this.loadStatus = 'more';
  275. } else {
  276. this.loadStatus = 'noMore';
  277. }
  278. this.isLoading = false;
  279. uni.stopPullDownRefresh();
  280. });
  281. },
  282. detail(id){
  283. uni.navigateTo({ url: `/pages/hexiao/ywy/hexiao_detail?id=`+id });
  284. },
  285. loadMore() {
  286. if (this.currentTab === 3) {
  287. // 门店汇总不需要分页加载
  288. return;
  289. }
  290. this.fetchRecords();
  291. },
  292. clearSearch(){
  293. this.startTime = "";
  294. this.endTime = "";
  295. this.startTimeXd = "";
  296. this.handleSearch()
  297. },
  298. handleSearch() {
  299. if (this.currentTab === 3) {
  300. this.fetchStoreSummary(true);
  301. } else {
  302. this.fetchRecords(true);
  303. }
  304. },
  305. verify(id,orderNo) {
  306. uni.showModal({
  307. title: '提示',
  308. content: `确认核销订单 ${orderNo} 吗?`,
  309. success: (res) => {
  310. if (res.confirm) {
  311. doCommitToJxs(id).then(res=>{
  312. if(res.code === 0){
  313. this.fetchRecords(true);
  314. uni.showToast({ title: '核销成功' });
  315. }else{
  316. uni.showToast({ title: '核销失败' });
  317. }
  318. });
  319. }
  320. }
  321. });
  322. }
  323. }
  324. }
  325. </script>
  326. <style lang="scss" scoped>
  327. .page-container {
  328. display: flex;
  329. flex-direction: column;
  330. height: 100vh;
  331. background-color: #f5f6fa;
  332. }
  333. .sticky-header {
  334. position: sticky;
  335. top: 0;
  336. z-index: 100;
  337. background-color: #f5f6fa;
  338. }
  339. .search-wrapper {
  340. padding: 20rpx;
  341. background-color: #ffffff;
  342. }
  343. .tabs-wrapper {
  344. display: flex;
  345. background-color: #ffffff;
  346. border-bottom: 1rpx solid #f0f0f0;
  347. .tab-item {
  348. flex: 1;
  349. text-align: center;
  350. padding: 25rpx 0;
  351. font-size: 28rpx;
  352. color: #666;
  353. position: relative;
  354. &.active {
  355. color: #3c82f8;
  356. font-weight: 500;
  357. &::after {
  358. content: '';
  359. position: absolute;
  360. bottom: 0;
  361. left: 50%;
  362. transform: translateX(-50%);
  363. width: 60rpx;
  364. height: 6rpx;
  365. background-color: #3c82f8;
  366. border-radius: 3rpx;
  367. }
  368. }
  369. }
  370. }
  371. /* 门店汇总样式 - 表格形式 */
  372. .store-summary-container {
  373. //flex: 1;
  374. background-color: #f5f6fa;
  375. overflow: auto;
  376. height: 100%;
  377. }
  378. .summary-list {
  379. height: 100%;
  380. }
  381. .summary-table-wrapper {
  382. background-color: #ffffff;
  383. border-radius: 16rpx;
  384. margin: 20rpx;
  385. overflow: hidden;
  386. box-shadow: 0 4rpx 20rpx rgba(0, 0, 0, 0.05);
  387. }
  388. .table-header {
  389. display: flex;
  390. background-color: #f8f9fa;
  391. padding: 24rpx 20rpx;
  392. border-bottom: 1rpx solid #e8e8e8;
  393. .header-cell {
  394. font-size: 28rpx;
  395. font-weight: 600;
  396. color: #333;
  397. text-align: center;
  398. &.store-col {
  399. width: 220rpx;
  400. flex-shrink: 0;
  401. }
  402. &.product-col {
  403. flex: 1;
  404. }
  405. &.number-col {
  406. width: 150rpx;
  407. flex-shrink: 0;
  408. text-align: center;
  409. }
  410. }
  411. }
  412. .table-body {
  413. .table-row {
  414. display: flex;
  415. align-items: center;
  416. padding: 0 20rpx;
  417. min-height: 100rpx;
  418. border-bottom: 1rpx solid #a5a5a5;
  419. .table-cell {
  420. font-size: 28rpx;
  421. color: #333;
  422. display: flex;
  423. align-items: center;
  424. padding: 20rpx 0;
  425. min-height: 100rpx;
  426. box-sizing: border-box;
  427. &.store-col {
  428. width: 220rpx;
  429. flex-shrink: 0;
  430. .store-name-cell {
  431. display: flex;
  432. align-items: center;
  433. uni-icons {
  434. margin-right: 10rpx;
  435. }
  436. .store-name-text {
  437. font-weight: 500;
  438. }
  439. }
  440. }
  441. &.product-col {
  442. flex: 1;
  443. }
  444. &.number-col {
  445. width: 150rpx;
  446. flex-shrink: 0;
  447. text-align: right;
  448. justify-content: flex-end;
  449. }
  450. }
  451. }
  452. .store-divider {
  453. height: 1rpx;
  454. background-color: #f0f0f0;
  455. margin: 0 20rpx;
  456. }
  457. }
  458. .table-footer {
  459. display: flex;
  460. align-items: center;
  461. padding: 0 20rpx;
  462. min-height: 100rpx;
  463. background-color: #f0f7ff;
  464. border-top: 2rpx solid #3c82f8;
  465. .footer-cell {
  466. font-size: 30rpx;
  467. font-weight: bold;
  468. display: flex;
  469. align-items: center;
  470. padding: 20rpx 0;
  471. min-height: 100rpx;
  472. box-sizing: border-box;
  473. &.store-col {
  474. width: 220rpx;
  475. flex-shrink: 0;
  476. }
  477. &.product-col {
  478. flex: 1;
  479. justify-content: flex-end;
  480. padding-right: 10rpx;
  481. .total-label {
  482. color: #333;
  483. }
  484. }
  485. &.number-col {
  486. width: 150rpx;
  487. flex-shrink: 0;
  488. text-align: right;
  489. .total-number {
  490. color: #3c82f8;
  491. font-size: 32rpx;
  492. }
  493. }
  494. }
  495. }
  496. .empty-list {
  497. text-align: center;
  498. color: #999;
  499. padding-top: 150rpx;
  500. }
  501. /* 原有样式保持不变 */
  502. .list-container {
  503. flex: 1;
  504. height: 100%;
  505. }
  506. .record-card {
  507. background-color: #ffffff;
  508. border-radius: 16rpx;
  509. margin: 20rpx;
  510. padding: 30rpx;
  511. box-shadow: 0 4rpx 20rpx rgba(0, 0, 0, 0.05);
  512. position: relative;
  513. }
  514. .card-header {
  515. display: flex;
  516. align-items: center;
  517. padding-bottom: 20rpx;
  518. border-bottom: 1rpx solid #f5f5f5;
  519. .record-id {
  520. font-size: 30rpx;
  521. font-weight: bold;
  522. color: #333;
  523. margin-left: 15rpx;
  524. }
  525. }
  526. .status-badge {
  527. position: absolute;
  528. top: 0;
  529. right: 0;
  530. padding: 8rpx 20rpx;
  531. font-size: 24rpx;
  532. color: #fff;
  533. border-top-right-radius: 16rpx;
  534. border-bottom-left-radius: 16rpx;
  535. &.pending { background-color: #3c82f8; }
  536. &.verifying { background-color: #ff9900; }
  537. &.verified { background-color: #54CFAB; }
  538. }
  539. .card-body {
  540. padding-top: 10rpx;
  541. }
  542. .detail-row {
  543. display: flex;
  544. justify-content: space-between;
  545. align-items: center;
  546. padding: 12rpx 0;
  547. font-size: 28rpx;
  548. .detail-label { color: #666; }
  549. .detail-value { color: #333; }
  550. &.product-item {
  551. .detail-label { color: #333; }
  552. .detail-value { color: #999; }
  553. }
  554. }
  555. .card-footer {
  556. display: flex;
  557. justify-content: flex-end;
  558. margin-top: 20rpx;
  559. }
  560. .verify-btn {
  561. background-color: #3c82f8;
  562. color: #fff;
  563. font-size: 26rpx;
  564. padding: 0 30rpx;
  565. height: 60rpx;
  566. line-height: 60rpx;
  567. border-radius: 30rpx;
  568. margin: 0;
  569. &::after { border: none; }
  570. }
  571. .query-btn {
  572. background-color: #409eff;
  573. color: #fff;
  574. padding: 20rpx;
  575. border-radius: 10rpx;
  576. height: 34rpx;
  577. display: flex;
  578. justify-content: center;
  579. align-items: center;
  580. }
  581. .query-btn-text {
  582. font-weight: 400;
  583. font-size: 30rpx;
  584. color: #F5F5F5;
  585. }
  586. .table-row-cl2{
  587. display: flex;
  588. }
  589. </style>