patrol_record.vue 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255
  1. <template>
  2. <view class="page-container">
  3. <!-- <view class="search-wrapper">-->
  4. <!-- <view class="search-bar">-->
  5. <!-- <uni-icons type="search" size="20" color="#999"></uni-icons>-->
  6. <!-- <input-->
  7. <!-- class="search-input"-->
  8. <!-- v-model="searchQuery"-->
  9. <!-- placeholder="输入门店名称/上货日期搜索"-->
  10. <!-- placeholder-class="placeholder"-->
  11. <!-- confirm-type="search"-->
  12. <!-- @confirm="handleSearch"-->
  13. <!-- />-->
  14. <!-- </view>-->
  15. <!-- </view>-->
  16. <scroll-view class="list-container" scroll-y="true" @scrolltolower="loadMore">
  17. <view v-if="recordList.length === 0 && loadStatus !== 'loading'" class="empty-list">
  18. <text>暂无上货记录</text>
  19. </view>
  20. <view v-for="record in recordList" :key="record.id" class="record-card">
  21. <view class="card-decorator"></view>
  22. <view class="card-content">
  23. <view class="card-header">
  24. <uni-icons type="shop-filled" size="20" color="#3c82f8"></uni-icons>
  25. <text class="record-id">{{ record.recordNo }}</text>
  26. </view>
  27. <view class="details-section">
  28. <view class="detail-row">
  29. <text class="detail-label">上货商品总数</text>
  30. <text class="detail-value">{{ record.totalNum }}</text>
  31. </view>
  32. <view class="detail-row" v-for="item in record.queryActiveRecordDetailVos">
  33. <text class="detail-label">{{ item.productName }}</text>
  34. <text class="detail-value">{{ item.num }}</text>
  35. </view>
  36. <view class="detail-row product-item" v-for="(product, index) in record.products" :key="index">
  37. <text class="detail-label product-name">{{ product.name }}</text>
  38. <text class="detail-value">{{ product.quantity }}{{ product.unit }}</text>
  39. </view>
  40. <view class="detail-row">
  41. <text class="detail-label">上货门店</text>
  42. <text class="detail-value">{{ record.storeName }}</text>
  43. </view>
  44. <view class="detail-row">
  45. <text class="detail-label">上货时间</text>
  46. <text class="detail-value">{{ record.activeTime }}</text>
  47. </view>
  48. <view class="detail-row">
  49. <text class="detail-label">上货奖励</text>
  50. <text class="detail-value reward">{{ record.reward==null?"0":record.reward }}积分</text>
  51. </view>
  52. </view>
  53. </view>
  54. </view>
  55. <uni-load-more :status="loadStatus"></uni-load-more>
  56. </scroll-view>
  57. </view>
  58. </template>
  59. <script>
  60. import {queryActiveRecord} from "@/api/hexiao";
  61. import {xundianRecord} from "../../../../api/hexiao";
  62. export default {
  63. data() {
  64. return {
  65. searchQuery: '',
  66. recordList: [],
  67. pagination: {
  68. page: 1,
  69. limit: 10,
  70. },
  71. loadStatus: 'more', // 'more'-加载前, 'loading'-加载中, 'noMore'-没有更多了
  72. isLoading: false,
  73. };
  74. },
  75. onLoad() {
  76. // 页面加载时获取第一页数据
  77. this.fetchRecords(true);
  78. },
  79. // 监听下拉刷新
  80. onPullDownRefresh() {
  81. this.fetchRecords(true);
  82. },
  83. methods: {
  84. // 核心:获取记录列表数据
  85. async fetchRecords(isRefresh = false) {
  86. if (this.isLoading || (this.loadStatus === 'noMore' && !isRefresh)) {
  87. return;
  88. }
  89. if (isRefresh) {
  90. this.pagination.page = 1;
  91. this.recordList = [];
  92. this.loadStatus = 'more';
  93. }
  94. this.isLoading = true;
  95. this.loadStatus = 'loading';
  96. // 在这里替换成您真实的 uni.request API 调用
  97. console.log(`正在请求第 ${this.pagination.page} 页数据...`);
  98. xundianRecord(this.pagination.page,this.pagination.limit).then(res=>{
  99. let mockData = res.data.records;
  100. if (mockData.length > 0) {
  101. this.recordList = [...this.recordList, ...mockData];
  102. this.pagination.page++;
  103. this.loadStatus = 'more';
  104. } else {
  105. this.loadStatus = 'noMore';
  106. }
  107. this.isLoading = false;
  108. uni.stopPullDownRefresh(); // 停止下拉刷新动画
  109. });
  110. // --- [模拟API请求结束] ---
  111. },
  112. // 上拉加载更多
  113. loadMore() {
  114. this.fetchRecords();
  115. },
  116. // 搜索
  117. handleSearch() {
  118. // 在实际项目中,搜索应该调用API,这里为简单起见只做前端筛选
  119. // this.fetchRecords(true);
  120. uni.showToast({ title: '触发搜索', icon: 'none' });
  121. }
  122. }
  123. }
  124. </script>
  125. <style lang="scss" scoped>
  126. .page-container {
  127. display: flex;
  128. flex-direction: column;
  129. height: 100vh;
  130. background-color: #f5f6fa;
  131. }
  132. .search-wrapper {
  133. padding: 20rpx;
  134. background-color: #ffffff;
  135. border-bottom: 1rpx solid #f0f0f0;
  136. }
  137. .search-bar {
  138. display: flex;
  139. align-items: center;
  140. background-color: #f5f6fa;
  141. border-radius: 50rpx;
  142. padding: 0 25rpx;
  143. height: 70rpx;
  144. }
  145. .search-input {
  146. flex: 1;
  147. font-size: 28rpx;
  148. margin-left: 15rpx;
  149. }
  150. .placeholder {
  151. color: #b0b0b0;
  152. }
  153. .list-container {
  154. flex: 1;
  155. height: 100%; // 必须给scroll-view一个明确的高度
  156. }
  157. .empty-list {
  158. text-align: center;
  159. color: #999;
  160. padding-top: 150rpx;
  161. }
  162. .record-card {
  163. background-color: #ffffff;
  164. border-radius: 16rpx;
  165. margin: 20rpx;
  166. position: relative;
  167. overflow: hidden;
  168. box-shadow: 0 4rpx 20rpx rgba(0, 0, 0, 0.05);
  169. }
  170. .card-decorator {
  171. position: absolute;
  172. left: 0;
  173. top: 0;
  174. bottom: 0;
  175. width: 8rpx;
  176. background-color: #e3efff;
  177. }
  178. .card-content {
  179. padding: 30rpx;
  180. padding-left: 40rpx;
  181. }
  182. .card-header {
  183. display: flex;
  184. align-items: center;
  185. padding-bottom: 20rpx;
  186. border-bottom: 1rpx solid #f5f5f5;
  187. .record-id {
  188. font-size: 30rpx;
  189. font-weight: bold;
  190. color: #333;
  191. margin-left: 15rpx;
  192. }
  193. }
  194. .details-section {
  195. padding-top: 10rpx;
  196. }
  197. .detail-row {
  198. display: flex;
  199. justify-content: space-between;
  200. align-items: center;
  201. padding: 15rpx 0;
  202. font-size: 28rpx;
  203. .detail-label {
  204. color: #666;
  205. }
  206. .detail-value {
  207. color: #333;
  208. }
  209. &.product-item .detail-label {
  210. color: #333; // 商品名称颜色深一些
  211. font-weight: 400;
  212. }
  213. .reward {
  214. color: #ff9900;
  215. font-weight: 500;
  216. }
  217. }
  218. </style>