hexiao_record.vue 18 KB

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