add_goods_record.vue 9.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379
  1. <template>
  2. <view class="page-container">
  3. <view class="search-wrapper">
  4. <view class="query">
  5. <u-row customStyle="margin-bottom: 10px" gutter="20">
  6. <u-col span="9">
  7. <u--input
  8. @focus="timeShow = true"
  9. v-model="startTimeXd"
  10. placeholder="开始日期 ~ 结束日期"
  11. prefixIcon="calendar"
  12. prefixIconStyle="font-size: 22px;color: #909399"
  13. @input="handleSearch"
  14. @change="change"
  15. ></u--input>
  16. </u-col>
  17. <u-col span="3">
  18. <view class="query-btn" @click="show = !show">
  19. <view class="query-btn-icon">
  20. </view>
  21. <view class="query-btn-text">筛选</view>
  22. </view>
  23. </u-col>
  24. </u-row>
  25. </view>
  26. </view>
  27. <scroll-view class="list-container" scroll-y="true" @scrolltolower="loadMore">
  28. <view v-if="recordList.length === 0 && loadStatus !== 'loading'" class="empty-list">
  29. <text>暂无上货记录</text>
  30. </view>
  31. <view v-for="record in recordList" :key="record.id" class="record-card">
  32. <view class="card-decorator"></view>
  33. <view class="card-content">
  34. <view class="card-header">
  35. <uni-icons type="calendar-filled" size="20" color="#3c82f8"></uni-icons>
  36. <text class="record-id">{{ record.recordNo }}</text>
  37. </view>
  38. <view class="details-section">
  39. <view class="detail-row">
  40. <text class="detail-label">上货商品总数</text>
  41. <text class="detail-value">{{ record.totalNum }}</text>
  42. </view>
  43. <view class="detail-row" v-for="item in record.queryActiveRecordDetailVos">
  44. <text class="detail-label">{{ item.productName }}</text>
  45. <text class="detail-value">{{ item.num }}</text>
  46. </view>
  47. <view class="detail-row product-item" v-for="(product, index) in record.products" :key="index">
  48. <text class="detail-label product-name">{{ product.name }}</text>
  49. <text class="detail-value">{{ product.quantity }}{{ product.unit }}</text>
  50. </view>
  51. <view class="detail-row">
  52. <text class="detail-label">上货门店</text>
  53. <text class="detail-value">{{ record.storeName }}</text>
  54. </view>
  55. <view class="detail-row">
  56. <text class="detail-label">上货时间</text>
  57. <text class="detail-value">{{ record.activeTime }}</text>
  58. </view>
  59. <view class="detail-row">
  60. <text class="detail-label">上货奖励</text>
  61. <text class="detail-value reward">{{ record.reward==null?"0":record.reward }}积分</text>
  62. </view>
  63. </view>
  64. </view>
  65. </view>
  66. <uni-load-more :status="loadStatus"></uni-load-more>
  67. </scroll-view>
  68. <u-popup :show="show" mode="bottom" @close="show = false" >
  69. <view class="popup-content">
  70. <view class="popup-text">筛选</view>
  71. <u-row customStyle="margin-bottom: 10px">
  72. <u-col span="3">
  73. <view class="explain">选择日期</view>
  74. </u-col>
  75. <u-col span="9">
  76. <u--input
  77. v-model="startTimeXd"
  78. placeholder="开始日期 ~ 结束日期"
  79. prefixIcon="calendar"
  80. prefixIconStyle="font-size: 22px;color: #909399"
  81. @focus="timeShow = true"
  82. ></u--input>
  83. </u-col>
  84. </u-row>
  85. <u-row customStyle="margin-bottom: 10px">
  86. <u-col span="3">
  87. <view class="explain">门店名称</view>
  88. </u-col>
  89. <u-col span="9">
  90. <u--input v-model="searchQuery"
  91. placeholder="请输入内容"
  92. border="surround"
  93. ></u--input>
  94. </u-col>
  95. </u-row>
  96. <view class="popup-btn">
  97. <u-button @click="handleSearch" class="popup-btn-one">搜索</u-button>
  98. <u-button @click="resetForm" class="popup-btn-one" type="primary">重置</u-button>
  99. </view>
  100. </view>
  101. </u-popup>
  102. <u-calendar @close="timeShow = false" :show="timeShow" :mode="mode" @confirm="confirm"></u-calendar>
  103. </view>
  104. </template>
  105. <script>
  106. import {queryActiveRecord} from "@/api/hexiao";
  107. export default {
  108. data() {
  109. return {
  110. startTime: '',
  111. endTime: '',
  112. timeShow: false,
  113. startTimeXd:"",
  114. mode: 'range',
  115. show:false,
  116. searchQuery: '',
  117. recordList: [],
  118. pagination: {
  119. page: 1,
  120. limit: 10,
  121. },
  122. loadStatus: 'more', // 'more'-加载前, 'loading'-加载中, 'noMore'-没有更多了
  123. isLoading: false,
  124. };
  125. },
  126. onLoad() {
  127. // 页面加载时获取第一页数据
  128. this.fetchRecords(true);
  129. },
  130. // 监听下拉刷新
  131. onPullDownRefresh() {
  132. this.fetchRecords(true);
  133. },
  134. methods: {
  135. confirm(e) {
  136. this.startTime = e[0];
  137. this.endTime = e[e.length-1];
  138. this.startTimeXd = e[0]+' ~ '+e[e.length-1];
  139. if(!this.show){
  140. this.handleSearch()
  141. }
  142. this.timeShow = false;
  143. },
  144. // 核心:获取记录列表数据
  145. async fetchRecords(isRefresh = false) {
  146. if (this.isLoading || (this.loadStatus === 'noMore' && !isRefresh)) {
  147. return;
  148. }
  149. if (isRefresh) {
  150. this.pagination.page = 1;
  151. this.recordList = [];
  152. this.loadStatus = 'more';
  153. }
  154. this.isLoading = true;
  155. this.loadStatus = 'loading';
  156. // 在这里替换成您真实的 uni.request API 调用
  157. console.log(`正在请求第 ${this.pagination.page} 页数据...`);
  158. queryActiveRecord(this.pagination.page,this.pagination.limit,this.searchQuery,this.startTime,this.endTime).then(res=>{
  159. let mockData = res.data.records;
  160. if(mockData == null){
  161. mockData = [];
  162. }
  163. if (mockData.length > 0) {
  164. this.recordList = [...this.recordList, ...mockData];
  165. this.pagination.page++;
  166. this.loadStatus = 'more';
  167. } else {
  168. this.loadStatus = 'noMore';
  169. }
  170. this.isLoading = false;
  171. uni.stopPullDownRefresh(); // 停止下拉刷新动画
  172. });
  173. // --- [模拟API请求结束] ---
  174. },
  175. // 上拉加载更多
  176. loadMore() {
  177. this.fetchRecords();
  178. },
  179. // 搜索
  180. change(){
  181. debugger;
  182. },
  183. handleSearch() {
  184. this.show = false;
  185. // 在实际项目中,搜索应该调用API,这里为简单起见只做前端筛选
  186. this.fetchRecords(true);
  187. },
  188. resetForm(){
  189. this.searchQuery = "";
  190. this.startTime = "";
  191. this.endTime = "";
  192. this.startTimeXd = "";
  193. }
  194. }
  195. }
  196. </script>
  197. <style lang="scss" scoped>
  198. .page-container {
  199. display: flex;
  200. flex-direction: column;
  201. height: 100vh;
  202. background-color: #f5f6fa;
  203. }
  204. .search-wrapper {
  205. padding: 20rpx;
  206. background-color: #ffffff;
  207. border-bottom: 1rpx solid #f0f0f0;
  208. }
  209. .search-bar {
  210. display: flex;
  211. align-items: center;
  212. background-color: #f5f6fa;
  213. border-radius: 50rpx;
  214. padding: 0 25rpx;
  215. height: 70rpx;
  216. }
  217. .search-input {
  218. flex: 1;
  219. font-size: 28rpx;
  220. margin-left: 15rpx;
  221. }
  222. .placeholder {
  223. color: #b0b0b0;
  224. }
  225. .list-container {
  226. flex: 1;
  227. height: 100%; // 必须给scroll-view一个明确的高度
  228. }
  229. .empty-list {
  230. text-align: center;
  231. color: #999;
  232. padding-top: 150rpx;
  233. }
  234. .record-card {
  235. background-color: #ffffff;
  236. border-radius: 16rpx;
  237. margin: 20rpx;
  238. position: relative;
  239. overflow: hidden;
  240. box-shadow: 0 4rpx 20rpx rgba(0, 0, 0, 0.05);
  241. }
  242. .card-decorator {
  243. position: absolute;
  244. left: 0;
  245. top: 0;
  246. bottom: 0;
  247. width: 8rpx;
  248. background-color: #e3efff;
  249. }
  250. .card-content {
  251. padding: 30rpx;
  252. padding-left: 40rpx;
  253. }
  254. .card-header {
  255. display: flex;
  256. align-items: center;
  257. padding-bottom: 20rpx;
  258. border-bottom: 1rpx solid #f5f5f5;
  259. .record-id {
  260. font-size: 30rpx;
  261. font-weight: bold;
  262. color: #333;
  263. margin-left: 15rpx;
  264. }
  265. }
  266. .details-section {
  267. padding-top: 10rpx;
  268. }
  269. .detail-row {
  270. display: flex;
  271. justify-content: space-between;
  272. align-items: center;
  273. padding: 15rpx 0;
  274. font-size: 28rpx;
  275. .detail-label {
  276. color: #666;
  277. }
  278. .detail-value {
  279. color: #333;
  280. }
  281. &.product-item .detail-label {
  282. color: #333; // 商品名称颜色深一些
  283. font-weight: 400;
  284. }
  285. .reward {
  286. color: #ff9900;
  287. font-weight: 500;
  288. }
  289. }
  290. .query-btn {
  291. background-color: #409eff;
  292. color: #fff;
  293. padding: 20rpx;
  294. border-radius: 10rpx;
  295. height: 34rpx;
  296. display: flex;
  297. justify-content: center;
  298. align-items: center;
  299. }
  300. .query-btn-icon {
  301. height: 32rpx;
  302. width: 32rpx;
  303. background-image:
  304. url("https://hyscancode.oss-cn-hangzhou.aliyuncs.com/xiaochengxu/cjx/queryIoc.png");
  305. background-size: cover;
  306. background-position: center;
  307. background-repeat: no-repeat;
  308. }
  309. .query-btn-text {
  310. font-weight: 400;
  311. font-size: 30rpx;
  312. color: #F5F5F5;
  313. }
  314. .popup-content{
  315. height: 25vh;
  316. padding: 10px;
  317. }
  318. .popup-text{
  319. font-family: PingFang SC;
  320. font-weight: bold;
  321. font-size: 36rpx;
  322. color: #1C1E1D;
  323. text-align: center;
  324. margin-bottom: 10px;
  325. }
  326. .popup-btn{
  327. display: flex;
  328. justify-content: space-around;
  329. }
  330. .popup-btn-one{
  331. width: 275rpx;
  332. height: 70rpx;
  333. background: linear-gradient(0deg, #6FA4FE, #488CFF);
  334. box-shadow: 0rpx 9rpx 16rpx 0rpx rgba(153,153,153,0.35);
  335. border-radius: 35rpx;
  336. }
  337. </style>