index.vue 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. <template>
  2. <view class="car">
  3. <!-- 列表 -->
  4. <view class="carlists">
  5. <car-list :datainfo="list" :wtdt="wtdt" type='feeset' @getDetail="getDetail" @getDelFn="getDelFn"></car-list>
  6. </view>
  7. <block v-if="checkPermi(['wuYe:fee:settings:add'])">
  8. <view style="height: 100rpx;"></view>
  9. <view class="rfbtn" @click="getFeeSetFn">添加设置</view>
  10. </block>
  11. <loading></loading>
  12. </view>
  13. </template>
  14. <script>
  15. import config from '@/config'
  16. const baseUrl = config.baseUrl
  17. import carList from "@/work/components/car/list.vue"
  18. import {feesetList,feesetDel} from "@/api/work/manage.js"
  19. import { checkPermi, checkRole } from "@/utils/permission"; // 权限判断函数
  20. export default{
  21. components:{carList},
  22. data(){
  23. return{
  24. list:[],
  25. pageSize: 10,
  26. pageNum: 1,
  27. reachflag: true,
  28. wtdt:'',
  29. }
  30. },
  31. onUnload() {
  32. uni.$off('refsetList')
  33. },
  34. onLoad: function() {
  35. uni.$on('refsetList',(res)=>{
  36. this.getrefreshData()
  37. })
  38. this.getDataFn()
  39. },
  40. // 上拉触底加载更多触发事件
  41. onReachBottom() {
  42. if (this.reachflag) {
  43. this.pageNum++
  44. this.getDataFn()
  45. }
  46. },
  47. methods:{
  48. checkPermi, checkRole,
  49. getDetail(id){
  50. this.$tab.navigateTo("/work/pages/fee/set?id="+id)
  51. },
  52. getFeeSetFn(){
  53. this.$tab.navigateTo("/work/pages/fee/set")
  54. },
  55. getAddFn(){
  56. },
  57. getrefreshData(){
  58. this.pageNum=1;
  59. this.list=[];
  60. this.reachflag=true;
  61. this.getDataFn()
  62. },
  63. getDelFn(data){
  64. var that=this;
  65. feesetDel(data).then(res=>{
  66. if(res.code==200){
  67. this.$toast("删除成功");
  68. setTimeout(function(){
  69. that.getrefreshData()
  70. },1500)
  71. }
  72. })
  73. },
  74. getDataFn(){
  75. var params={
  76. pageSize:this.pageSize,
  77. pageNum: this.pageNum,
  78. }
  79. feesetList(params).then(res=>{
  80. if(res.code==200){
  81. if (res.rows.length < this.pageSize) {
  82. this.reachflag = false
  83. this.wtdt = '到底了~';
  84. } else {
  85. var num = parseInt(res.rows.length) + parseInt(this.pageSize) * parseInt(this.pageNum - 1)
  86. if (num < res.total) {
  87. this.reachflag = true
  88. this.wtdt = ''
  89. } else {
  90. this.reachflag = false
  91. this.wtdt = '到底了~';
  92. }
  93. }
  94. var newArr=JSON.parse(JSON.stringify(res.rows))
  95. newArr.forEach(ite=>{
  96. ite.right=0;
  97. })
  98. if (this.pageNum == 1) {
  99. this.list = newArr;
  100. } else {
  101. this.list = this.list.concat(newArr)
  102. }
  103. }else{
  104. this.$toast(res.msg)
  105. }
  106. })
  107. },
  108. }
  109. }
  110. </script>
  111. <style>
  112. page{background: #F3F3F0;}
  113. </style>
  114. <style lang="scss" scoped>
  115. .car{padding: 24rpx 0 10rpx;}
  116. .carlists{padding: 0 18rpx;}
  117. </style>