hexiao_record_history.vue 9.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453
  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 class="data-display-container" v-if="recordList.length>0">
  32. <view class="header-row">
  33. <view class="header-item">项目</view>
  34. <view class="header-item">数量</view>
  35. <view class="header-item">时间</view>
  36. </view>
  37. <view class="data-body">
  38. <view class="data-row" v-for="(item, index) in recordList" :key="index">
  39. <view class="data-cell item-column">{{ item.itemName }}</view>
  40. <view class="data-cell">{{ item.quantity }}</view>
  41. <view class="data-cell">{{ item.verifyTime }}</view>
  42. </view>
  43. </view>
  44. </view>
  45. </scroll-view>
  46. <u-popup :show="show" mode="bottom" @close="show = false" >
  47. <view class="popup-content">
  48. <view class="popup-text">筛选</view>
  49. <u-row customStyle="margin-bottom: 10px">
  50. <u-col span="3">
  51. <view class="explain">选择日期</view>
  52. </u-col>
  53. <u-col span="9">
  54. <u--input
  55. v-model="startTimeXd"
  56. placeholder="开始日期 ~ 结束日期"
  57. prefixIcon="calendar"
  58. prefixIconStyle="font-size: 22px;color: #909399"
  59. @focus="timeShow = true"
  60. ></u--input>
  61. </u-col>
  62. </u-row>
  63. <view class="popup-btn">
  64. <u-button @click="handleSearch" class="popup-btn-one">搜索</u-button>
  65. <u-button @click="resetForm" class="popup-btn-one" type="primary">重置</u-button>
  66. </view>
  67. </view>
  68. </u-popup>
  69. <u-calendar min-date="2025-07-01" max-date="2030-07-01" @close="timeShow = false" :show="timeShow" :mode="mode" @confirm="confirm"></u-calendar>
  70. </view>
  71. </template>
  72. <script>
  73. import {queryWriteOffRecordByItem} from "@/api/hexiao";
  74. export default {
  75. data() {
  76. return {
  77. startTime: '',
  78. endTime: '',
  79. timeShow: false,
  80. startTimeXd:"",
  81. mode: 'range',
  82. show:false,
  83. searchQuery: '',
  84. recordList: [],
  85. totalInfo:{saleTotal:0,activateTotal:0},
  86. retailId:0,
  87. pagination: {
  88. page: 1,
  89. limit: 10,
  90. },
  91. loadStatus: 'more', // 'more'-加载前, 'loading'-加载中, 'noMore'-没有更多了
  92. isLoading: false,
  93. };
  94. },
  95. onLoad(opt) {
  96. // 页面加载时获取第一页数据
  97. if(opt.id){
  98. this.retailId = opt.id
  99. }
  100. this.fetchRecords(true);
  101. },
  102. // 监听下拉刷新
  103. onPullDownRefresh() {
  104. // this.fetchRecords(true);
  105. },
  106. methods: {
  107. detail(id){
  108. uni.navigateTo({ url: `/pages/hexiao/ywy/patrol_detail?id=`+id });
  109. },
  110. // 核心:获取记录列表数据
  111. async fetchRecords(isRefresh = false) {
  112. if (this.isLoading || (this.loadStatus === 'noMore' && !isRefresh)) {
  113. return;
  114. }
  115. this.isLoading = true;
  116. this.loadStatus = 'loading';
  117. if (isRefresh) {
  118. this.pagination.page = 1;
  119. this.recordList = [];
  120. this.loadStatus = 'more';
  121. }
  122. let data = {
  123. pageIndex: this.pagination.page,
  124. pageSize: this.pagination.limit,
  125. startTime: this.startTime,
  126. endTime: this.endTime,
  127. };
  128. queryWriteOffRecordByItem(data).then(res=>{
  129. let data =res.data;
  130. let records = data.records;
  131. if(!records){
  132. records = [];
  133. }
  134. if (records.length > 0) {
  135. this.recordList = [...this.recordList, ...records];
  136. this.pagination.page++;
  137. this.loadStatus = 'more';
  138. } else {
  139. this.loadStatus = 'noMore';
  140. }
  141. this.isLoading = false;
  142. uni.stopPullDownRefresh(); // 停止下拉刷新动画
  143. })
  144. },
  145. resetForm(){
  146. this.searchQuery = "";
  147. this.startTime = "";
  148. this.endTime = "";
  149. this.startTimeXd = "";
  150. },
  151. confirm(e) {
  152. this.startTime = e[0];
  153. this.endTime = e[e.length-1];
  154. this.startTimeXd = e[0]+' ~ '+e[e.length-1];
  155. if(!this.show){
  156. this.handleSearch()
  157. }
  158. this.timeShow = false;
  159. },
  160. // 上拉加载更多
  161. loadMore() {
  162. this.fetchRecords();
  163. },
  164. // 搜索
  165. handleSearch() {
  166. // 在实际项目中,搜索应该调用API,这里为简单起见只做前端筛选
  167. this.fetchRecords(true);
  168. }
  169. }
  170. }
  171. </script>
  172. <style lang="scss" scoped>
  173. .page-container {
  174. display: flex;
  175. flex-direction: column;
  176. height: 100vh;
  177. background-color: #f5f6fa;
  178. }
  179. .search-wrapper {
  180. padding: 20rpx;
  181. background-color: #ffffff;
  182. border-bottom: 1rpx solid #f0f0f0;
  183. }
  184. .search-bar {
  185. display: flex;
  186. align-items: center;
  187. background-color: #f5f6fa;
  188. border-radius: 50rpx;
  189. padding: 0 25rpx;
  190. height: 70rpx;
  191. }
  192. .search-input {
  193. flex: 1;
  194. font-size: 28rpx;
  195. margin-left: 15rpx;
  196. }
  197. .placeholder {
  198. color: #b0b0b0;
  199. }
  200. .list-container {
  201. flex: 1;
  202. height: 100%; // 必须给scroll-view一个明确的高度
  203. }
  204. .empty-list {
  205. text-align: center;
  206. color: #999;
  207. padding-top: 150rpx;
  208. }
  209. .record-card {
  210. background-color: #ffffff;
  211. border-radius: 16rpx;
  212. margin: 20rpx;
  213. position: relative;
  214. overflow: hidden;
  215. box-shadow: 0 4rpx 20rpx rgba(0, 0, 0, 0.05);
  216. }
  217. .card-decorator {
  218. position: absolute;
  219. left: 0;
  220. top: 0;
  221. bottom: 0;
  222. width: 8rpx;
  223. background-color: #e3efff;
  224. }
  225. .card-content {
  226. padding: 30rpx;
  227. padding-left: 40rpx;
  228. }
  229. .card-header {
  230. display: flex;
  231. align-items: center;
  232. padding-bottom: 20rpx;
  233. border-bottom: 1rpx solid #f5f5f5;
  234. .record-id {
  235. font-size: 30rpx;
  236. font-weight: bold;
  237. color: #333;
  238. margin-left: 15rpx;
  239. }
  240. }
  241. .details-section {
  242. padding-top: 10rpx;
  243. }
  244. .detail-row {
  245. display: flex;
  246. justify-content: space-between;
  247. align-items: center;
  248. padding: 15rpx 0;
  249. font-size: 28rpx;
  250. .detail-label {
  251. color: #666;
  252. }
  253. .detail-value {
  254. color: #333;
  255. }
  256. &.product-item .detail-label {
  257. color: #333; // 商品名称颜色深一些
  258. font-weight: 400;
  259. }
  260. .reward {
  261. color: #ff9900;
  262. font-weight: 500;
  263. }
  264. }
  265. .query-btn {
  266. background-color: #409eff;
  267. color: #fff;
  268. padding: 20rpx;
  269. border-radius: 10rpx;
  270. height: 34rpx;
  271. display: flex;
  272. justify-content: center;
  273. align-items: center;
  274. }
  275. .query-btn-icon {
  276. height: 32rpx;
  277. width: 32rpx;
  278. background-image:
  279. url("https://hyscancode.oss-cn-hangzhou.aliyuncs.com/xiaochengxu/cjx/queryIoc.png");
  280. background-size: cover;
  281. background-position: center;
  282. background-repeat: no-repeat;
  283. }
  284. .query-btn-text {
  285. font-weight: 400;
  286. font-size: 30rpx;
  287. color: #F5F5F5;
  288. }
  289. .popup-content{
  290. height: 25vh;
  291. padding: 10px;
  292. }
  293. .popup-text{
  294. font-family: PingFang SC;
  295. font-weight: bold;
  296. font-size: 36rpx;
  297. color: #1C1E1D;
  298. text-align: center;
  299. margin-bottom: 10px;
  300. }
  301. .popup-btn{
  302. display: flex;
  303. justify-content: space-around;
  304. }
  305. .popup-btn-one{
  306. width: 275rpx;
  307. height: 70rpx;
  308. background: linear-gradient(0deg, #6FA4FE, #488CFF);
  309. box-shadow: 0rpx 9rpx 16rpx 0rpx rgba(153,153,153,0.35);
  310. border-radius: 35rpx;
  311. }
  312. .data-display-container {
  313. padding: 30rpx;
  314. font-size: 28rpx;
  315. color: #333;
  316. min-height: 100vh; /* 确保内容撑满整个视口高度 */
  317. box-sizing: border-box; /* 边框和内边距包含在元素的总宽度和高度内 */
  318. }
  319. .card {
  320. background-color: #ffffff;
  321. border-radius: 16rpx;
  322. box-shadow: 0 4rpx 20rpx rgba(0, 0, 0, 0.08); /* 更柔和的阴影 */
  323. overflow: hidden; /* 确保圆角显示 */
  324. display: flex;
  325. flex-direction: column;
  326. max-height: calc(100vh - 60rpx); /* 卡片最大高度,留出上下padding */
  327. }
  328. .header-row {
  329. display: flex;
  330. flex-direction: row;
  331. background-color: #4A90E2; /* 品牌蓝色 */
  332. color: #ffffff;
  333. font-weight: bold;
  334. padding: 24rpx 0; /* 上下内边距增加 */
  335. border-bottom: 1rpx solid rgba(255, 255, 255, 0.2); /* 浅色边框 */
  336. position: sticky; /* 头部固定 */
  337. top: 0;
  338. z-index: 10;
  339. }
  340. .header-item {
  341. flex: 1;
  342. text-align: center;
  343. padding: 0 10rpx; /* 左右内边距 */
  344. font-size: 28rpx;
  345. }
  346. .data-body-scroll {
  347. flex: 1; /* 占据剩余空间 */
  348. overflow-y: auto; /* 允许滚动 */
  349. -webkit-overflow-scrolling: touch; /* iOS 平滑滚动 */
  350. }
  351. .data-row {
  352. display: flex;
  353. flex-direction: row;
  354. align-items: center; /* 垂直居中对齐 */
  355. padding: 20rpx 0; /* 上下内边距 */
  356. border-bottom: 1rpx solid #f0f0f0; /* 更细的分割线 */
  357. transition: background-color 0.2s ease; /* 鼠标悬停或点击的平滑过渡 */
  358. }
  359. .data-row:last-child {
  360. border-bottom: none; /* 最后一行没有底部边框 */
  361. }
  362. .data-row.even-row {
  363. background-color: #f9f9f9; /* 隔行变色 */
  364. }
  365. .data-row:hover {
  366. background-color: #eef7ff; /* 悬停效果 */
  367. }
  368. .data-cell {
  369. flex: 1;
  370. padding: 0 10rpx; /* 左右内边距 */
  371. text-align: center;
  372. font-size: 26rpx; /* 数据字体略小 */
  373. color: #555;
  374. word-break: break-word; /* 允许长文本在任何地方换行 */
  375. line-height: 1.4; /* 增加行高 */
  376. }
  377. .item-column {
  378. text-align: left;
  379. padding-left: 20rpx; /* 品项左边距 */
  380. color: #333;
  381. font-weight: 500;
  382. }
  383. .no-data {
  384. text-align: center;
  385. padding: 40rpx;
  386. color: #999;
  387. font-size: 30rpx;
  388. }
  389. </style>