checklist.vue 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229
  1. <template>
  2. <view class="">
  3. <!-- <u-navbar
  4. title="我的业绩"
  5. :placeholder="true"
  6. :autoBack="true"
  7. :safeAreaInsetTop="true"
  8. >
  9. </u-navbar> -->
  10. <view class="page-wrap">
  11. <view class="date u-flex"@click="pickerDateShow = true">
  12. <img class="img" src="../static/img/date-ico.png" alt="">
  13. {{checkDate}}
  14. </view>
  15. <u-datetime-picker
  16. :show="pickerDateShow"
  17. ref="datePicker"
  18. v-model="timestamp"
  19. mode="date"
  20. @cancel="pickerDateShow=false"
  21. :maxDate="new Date().getTime()"
  22. :formatter="formatter"
  23. @confirm="confirmDate"
  24. ></u-datetime-picker>
  25. </view>
  26. <mescroll-body class="" ref="mescrollRef" @init="mescrollInit" @down="downCallback" @up="upCallback" :down="downOption" :up="upOption">
  27. <view class="page-wrap" v-show="dataList.length>0" >
  28. <view class="list">
  29. <view class="item" @click="goDetail(item.id)" v-for="item in dataList" :key="item.id">
  30. <view class="userinfo">
  31. 姓名:{{item.createBy}}/{{item.dept}}
  32. </view>
  33. <view class="goods-name">核销商品:{{item.goodsName}}</view>
  34. <view class="quantity">数量:{{item.quantity}}</view>
  35. <view class="bottom u-flex u-row-between">
  36. <text>{{item.checkTime}}</text>
  37. <u-icon name="arrow-right" color="#333" size="18"></u-icon>
  38. </view>
  39. </view>
  40. </view>
  41. </view>
  42. </mescroll-body>
  43. </view>
  44. </template>
  45. <script>
  46. // 引入mescroll-mixins.js
  47. import MescrollMixin from "@/uni_modules/mescroll-uni/components/mescroll-uni/mescroll-mixins.js";
  48. export default {
  49. mixins: [MescrollMixin], // 使用mixin
  50. data() {
  51. return {
  52. timestamp:undefined,
  53. pickerDateShow:false,
  54. downOption: {},
  55. // 上拉加载的配置(可选, 绝大部分情况无需配置)
  56. upOption: {
  57. page: {
  58. size: 10 // 每页数据的数量,默认10
  59. },
  60. noMoreSize: 5, // 配置列表的总数量要大于等于5条才显示'-- END --'的提示
  61. empty: {
  62. tip: '暂无相关数据'
  63. }
  64. },
  65. // ,{name:'安全学习',recordType:3}
  66. tabsList:[{name:'全部',recordType:''},{name:'答题',recordType:1},{name:'兑换码失效',recordType:4}],
  67. recordType:'',
  68. params:{
  69. checkDate:''
  70. },
  71. activeIndex:0,
  72. dataList: []
  73. }
  74. },
  75. onShow() {
  76. },
  77. onLoad() {
  78. this.timestamp = Number(new Date());
  79. this.checkDate = uni.$u.timeFormat(this.timestamp, 'yyyy年mm月dd日');
  80. this.params.checkDate = uni.$u.timeFormat(this.timestamp, 'yyyy-mm-dd');
  81. },
  82. onReady() {
  83. // 微信小程序需要用此写法
  84. this.$refs.datePicker.setFormatter(this.formatter)
  85. },
  86. methods: {
  87. /*下拉刷新的回调, 重置列表为第一页 (此处可删,mixins已默认)
  88. downCallback(){
  89. this.mescroll.resetUpScroll();
  90. },
  91. /*上拉加载的回调*/
  92. upCallback(page) {
  93. // 此处可以继续请求其他接口
  94. // if(page.num == 1){
  95. // // 请求其他接口...
  96. // }
  97. // 如果希望先请求其他接口,再触发upCallback,可参考以下写法
  98. // if(!this.params.id){
  99. // this.mescroll.endErr()
  100. // return // 此处return,先获取xx
  101. // }
  102. let pageNum = page.num; // 页码, 默认从1开始
  103. let pageSize = page.size; // 页长, 默认每页10条isAsc:0//时间排序 0:降序 1:升序 (默认星级降序排序)
  104. this.params = Object.assign(this.params,{pageNum:pageNum,pageSize:pageSize});
  105. this.$u.api.checkList(this.params).then(data => {
  106. console.log('data',JSON.parse(JSON.stringify(data)));
  107. // 接口返回的当前页数据列表 (数组)
  108. let curPageData = data.data.rows;
  109. this.totalAmount = data.data.total;
  110. console.log('curPageData',JSON.parse(JSON.stringify(curPageData)));
  111. // 接口返回的当前页数据长度 (如列表有26个数据,当前页返回8个,则curPageLen=8)
  112. let curPageLen = curPageData.length;
  113. // 接口返回的总页数 (如列表有26个数据,每页10条,共3页; 则totalPage=3)
  114. // let totalPage = data.data.data.totalPage;
  115. // 接口返回的总数据量(如列表有26个数据,每页10条,共3页; 则totalSize=26)
  116. let totalSize = curPageData.total;
  117. // 接口返回的是否有下一页 (true/false)
  118. // let hasNext = data.xxx;
  119. // console.log('totalPage',totalPage,'curPageLen',curPageLen);
  120. //设置列表数据
  121. if(page.num == 1) this.dataList = []; //如果是第一页需手动置空列表
  122. this.dataList = this.dataList.concat(curPageData); //追加新数据
  123. // 请求成功,隐藏加载状态
  124. //方法一(推荐): 后台接口有返回列表的总页数 totalPage
  125. // this.mescroll.endByPage(curPageLen, totalPage);
  126. //方法二(推荐): 后台接口有返回列表的总数据量 totalSize
  127. this.mescroll.endBySize(curPageLen, totalSize);
  128. }).catch(err => {
  129. this.mescroll.endErr()
  130. console.log(err)
  131. });
  132. },
  133. /*若希望重新加载列表,只需调用此方法即可(内部会自动page.num=1,再主动触发up.callback)*/
  134. reloadList() {
  135. this.mescroll.resetUpScroll();
  136. },
  137. itemClick(item){
  138. console.log('item',item);
  139. },
  140. confirmDate(e){
  141. console.log('confirmDate',e);
  142. this.pickerDateShow = false;
  143. this.checkDate = uni.$u.timeFormat(e.value, 'yyyy年mm月dd日');
  144. this.params.checkDate = uni.$u.timeFormat(e.value, 'yyyy-mm-dd');
  145. this.reloadList()
  146. },
  147. formatter(type, value) {
  148. if (type === 'year') {
  149. return `${value}年`
  150. }
  151. if (type === 'month') {
  152. return `${value}月`
  153. }
  154. if (type === 'day') {
  155. return `${value}日`
  156. }
  157. return value
  158. },
  159. goDetail(id){
  160. console.log('goDetail',id);
  161. uni.$u.route('/center/checkdetails', {
  162. id: id
  163. });
  164. }
  165. }
  166. }
  167. </script>
  168. <style>
  169. page{
  170. background-color: #F5F9FC;
  171. }
  172. </style>
  173. <style lang="scss" scoped>
  174. .list{
  175. border-radius: 8rpx;
  176. padding: 0 20rpx;
  177. .item{
  178. background-color: #fff;
  179. padding: 30rpx;
  180. background-color: #fff;
  181. margin-bottom: 20rpx;
  182. border-radius: 24rpx;
  183. font-size: 28rpx;
  184. font-family: PingFangSC-Regular, PingFang SC;
  185. font-weight: 400;
  186. color: #666666;
  187. line-height: 40rpx;
  188. .userinfo{
  189. font-size: 32rpx;
  190. font-weight: 600;
  191. color: #333333;
  192. line-height: 44rpx;
  193. margin-bottom: 14rpx;
  194. }
  195. .goods-name{
  196. margin-bottom: 12rpx;
  197. }
  198. .quantity{
  199. margin-bottom: 12rpx;
  200. }
  201. .bottom{
  202. font-size: 28rpx;
  203. font-weight: 400;
  204. color: #999999;
  205. line-height: 40rpx;
  206. }
  207. }
  208. }
  209. .date{
  210. width: fit-content;
  211. padding: 12rpx 20rpx;
  212. background-color: #fff;
  213. border-radius: 16rpx;
  214. font-size: 28rpx;
  215. font-weight: 400;
  216. color: #009AEF;
  217. line-height: 40rpx;
  218. .img{
  219. margin-right: 10rpx;
  220. }
  221. }
  222. </style>