car.vue 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  1. <template>
  2. <view class="carbox">
  3. <view class="flex1 cartop">
  4. <box-list :datainfo="list" type="mycar" :clcxList="clcxList" @getDetail="getDetail" @getDelFn="getDelFn"></box-list>
  5. </view>
  6. <view class="plr12 flex0">
  7. <view class="rhbtn" @click="getAddFn">添加车辆</view>
  8. </view>
  9. <loading></loading>
  10. </view>
  11. </template>
  12. <script>
  13. import config from '@/config'
  14. const baseUrl = config.baseUrl
  15. import boxList from "@/work/components/car/list.vue"
  16. import { checkPermi, checkRole } from "@/utils/permission"; // 权限判断函数
  17. import {carList,carDel} from "@/api/work/car.js"
  18. import {getDictionaryFn} from "@/api/system/user.js"
  19. export default{
  20. components:{boxList},
  21. data(){
  22. return{
  23. rimg: require('@/people/static/people/rimg.png'),
  24. list:[],
  25. pageSize: 10,
  26. pageNum: 1,
  27. reachflag: true,
  28. wtdt:'',
  29. clcxList:[],
  30. houseId:'',
  31. }
  32. },
  33. onUnload() {
  34. uni.$off('carlist')
  35. },
  36. onLoad: function(e) {
  37. uni.$on('carlist',(res)=>{
  38. this.getDataFn()
  39. })
  40. this.houseId=e.id
  41. this.init()
  42. this.getDataFn()
  43. },
  44. // 上拉触底加载更多触发事件
  45. onReachBottom() {
  46. if (this.reachflag) {
  47. this.pageNum++
  48. this.getDataFn()
  49. }
  50. },
  51. methods:{
  52. checkPermi, checkRole,
  53. init(){
  54. // 车型
  55. getDictionaryFn('cartype').then(res=>{
  56. if(res.code==200){
  57. this.clcxList = res.data.map(v => {
  58. return {
  59. dictLabel: v.dictLabel,
  60. dictValue: v.dictValue
  61. }
  62. })
  63. }
  64. })
  65. },
  66. getDelFn(data){
  67. var that=this;
  68. carDel(data).then(res=>{
  69. if(res.code==200){
  70. this.$toast("删除成功");
  71. setTimeout(function(){
  72. that.getDataFn()
  73. },1500)
  74. }
  75. })
  76. },
  77. getAddFn(){
  78. this.$tab.navigateTo("/work/pages/manage/addcar")
  79. },
  80. getDetail(id){
  81. this.$tab.navigateTo("/work/pages/manage/addcar?id="+id)
  82. },
  83. getChargeFn(){
  84. this.$tab.navigateTo("/mine/pages/car/charge")
  85. },
  86. getDataFn(){
  87. var params={
  88. pageSize:this.pageSize,
  89. pageNum: this.pageNum,
  90. houseId:this.houseId,
  91. }
  92. carList(params).then(res=>{
  93. if(res.code==200){
  94. if (res.rows.length < this.pageSize) {
  95. this.reachflag = false
  96. this.wtdt = '到底了~';
  97. } else {
  98. var num = parseInt(res.rows.length) + parseInt(this.pageSize) * parseInt(this.pageNum - 1)
  99. if (num < res.total) {
  100. this.reachflag = true
  101. this.wtdt = ''
  102. } else {
  103. this.reachflag = false
  104. this.wtdt = '到底了~';
  105. }
  106. }
  107. var newArr=JSON.parse(JSON.stringify(res.rows))
  108. newArr.forEach(ite=>{
  109. ite.right=0;
  110. })
  111. if (this.pageNum == 1) {
  112. this.list = newArr;
  113. } else {
  114. this.list = this.list.concat(newArr)
  115. }
  116. }else{
  117. this.$toast(res.msg)
  118. }
  119. })
  120. },
  121. }
  122. }
  123. </script>
  124. <style>
  125. page{background: #F3F3F0;}
  126. </style>
  127. <style lang="scss" scoped>
  128. .carbox{display: flex;flex-direction: column;min-height: 100vh;padding: 22rpx 18rpx 100rpx;
  129. .cartop{overflow: auto;}
  130. .cartips{background: #FFFFFF;border-radius: 20rpx;height: 98rpx;padding: 0 24rpx;
  131. image{width: 16rpx;height: 28rpx;flex: 0 0 auto;margin-left: 20rpx;}
  132. .tit{font-weight: bold;font-size: 26rpx;color: #272727;}
  133. }
  134. }
  135. </style>