payee.vue 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  1. <template>
  2. <view>
  3. <u-navbar
  4. title="选择收费员"
  5. title-color="#fff"
  6. :border-bottom="false"
  7. :custom-back="customBack"
  8. back-icon-color="#CCE8FF"
  9. :background="{background: '#4D68DC' }">
  10. </u-navbar>
  11. <u-search placeholder="搜索收费员姓名" v-model="keyword" @search="search" @custom="search"></u-search>
  12. <mescroll-uni ref="mescrollRef" @init="mescrollInit" :top="config.platform=='h5'?220:300" @down="downCallback" :up="upOption" @up="upCallback" @emptyclick="emptyClick">
  13. <view class="">
  14. <u-radio-group v-model="selected" @change="radioGroupChange" width="50%">
  15. <u-radio
  16. @change="radioChange(item)"
  17. v-for="(item, index) in dataList" :key="item.id"
  18. :name="item.id"
  19. :disabled="item.disabled"
  20. >
  21. {{item.payeeName}}
  22. </u-radio>
  23. </u-radio-group>
  24. </view>
  25. </mescroll-uni>
  26. </view>
  27. </template>
  28. <script>
  29. import MescrollMixin from "@/uni_modules/mescroll-uni/components/mescroll-uni/mescroll-mixins.js";
  30. export default{
  31. mixins: [MescrollMixin], // 使用mixin (在main.js注册全局组件)
  32. data(){
  33. return{
  34. keyword:'',
  35. selected:'',
  36. upOption:{
  37. page: {
  38. size: 150 // 每页数据的数量
  39. },
  40. // auto:false,
  41. // use:false,
  42. noMoreSize: 4, //如果列表已无数据,可设置列表的总数量要大于半页才显示无更多数据;避免列表数据过少(比如只有一条数据),显示无更多数据会不好看; 默认5
  43. empty:{
  44. tip: '~ 暂无数据 ~', // 提示
  45. // btnText: '去看看'
  46. }
  47. },
  48. dataList:[],
  49. }
  50. },
  51. onLoad(){
  52. },
  53. onShow(){
  54. },
  55. watch:{
  56. // keyword:{
  57. // handler(val, oldVal){
  58. // this.dataList.map((item)=>{
  59. // if(item.payeeName.indexOf(val)!=-1){
  60. // this.dataList.push(item);
  61. // }
  62. // })
  63. // },
  64. // },
  65. },
  66. methods:{
  67. customBack(){
  68. uni.navigateBack();
  69. },
  70. /*上拉加载的回调: 其中page.num:当前页 从1开始, page.size:每页数据条数,默认10 */
  71. upCallback(page) {
  72. // console.log('vuex_user',this.vuex_user);
  73. // console.log('page',page)
  74. //联网加载数据
  75. // let keyword = this.tabs[this.tabIndex]?.text;
  76. let params ={
  77. pageNum:page.num,
  78. pageSize:page.size,
  79. payeeName:this.keyword,
  80. // roadNo:''
  81. }
  82. this.$u.api.payeeList(params).then(curPageData=>{
  83. console.log('curPageData',curPageData)
  84. //联网成功的回调,隐藏下拉刷新和上拉加载的状态;
  85. this.mescroll.endSuccess(curPageData.data.length);
  86. // this.mescroll.endBySize(curPageData.rows.length, curPageData.total);
  87. //设置列表数据
  88. if(page.num == 1) this.dataList = []; //如果是第一页需手动制空列表
  89. // curPageData.rows.map((item)=>{
  90. // if(item.userId==this.vuex_user.userId){
  91. // item.disabled = true
  92. // }else{
  93. // item.disabled = false
  94. // }
  95. // });
  96. this.dataList=this.dataList.concat(curPageData.data); //追加新数据
  97. }).catch((err)=>{
  98. uni.showToast({
  99. title:'链接失败'
  100. });
  101. console.log('err',err)
  102. //联网失败, 结束加载
  103. this.mescroll.endErr();
  104. })
  105. },
  106. //点击空布局按钮的回调
  107. emptyClick(){
  108. },
  109. radioChange(item){
  110. // console.log('radioChange',e);
  111. // console.log('item',item);
  112. this.$u.vuex('vuex_selected_payee.name',item.payeeName)
  113. },
  114. radioGroupChange(e){
  115. // console.log('radioGroupChange',e);
  116. this.selected = e;
  117. this.$u.vuex('vuex_selected_payee.id',e)
  118. console.log('radioGroupChange');
  119. uni.navigateBack();
  120. },
  121. search(){
  122. this.dataList = [];
  123. this.mescroll.resetUpScroll();
  124. }
  125. }
  126. }
  127. </script>
  128. <style lang="scss" scoped>
  129. .u-search{
  130. margin: 24rpx!important;
  131. }
  132. .u-radio-group{
  133. display: flex;
  134. margin: 24rpx;
  135. .u-radio{
  136. margin-bottom: 24rpx;
  137. }
  138. }
  139. </style>