car.vue 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  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.getrefreshData()
  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.getrefreshData()
  73. },1500)
  74. }
  75. })
  76. },
  77. getrefreshData(){
  78. this.pageNum=1;
  79. this.list=[];
  80. this.reachflag=true;
  81. this.getDataFn()
  82. },
  83. getAddFn(){
  84. this.$tab.navigateTo("/work/pages/manage/addcar?houseId="+this.houseId)
  85. },
  86. getDetail(id){
  87. this.$tab.navigateTo("/work/pages/manage/addcar?id="+id)
  88. },
  89. getChargeFn(){
  90. this.$tab.navigateTo("/mine/pages/car/charge")
  91. },
  92. getDataFn(){
  93. var params={
  94. pageSize:this.pageSize,
  95. pageNum: this.pageNum,
  96. houseId:this.houseId,
  97. }
  98. carList(params).then(res=>{
  99. if(res.code==200){
  100. if (res.rows.length < this.pageSize) {
  101. this.reachflag = false
  102. this.wtdt = '到底了~';
  103. } else {
  104. var num = parseInt(res.rows.length) + parseInt(this.pageSize) * parseInt(this.pageNum - 1)
  105. if (num < res.total) {
  106. this.reachflag = true
  107. this.wtdt = ''
  108. } else {
  109. this.reachflag = false
  110. this.wtdt = '到底了~';
  111. }
  112. }
  113. var newArr=JSON.parse(JSON.stringify(res.rows))
  114. newArr.forEach(ite=>{
  115. ite.right=0;
  116. })
  117. if (this.pageNum == 1) {
  118. this.list = newArr;
  119. } else {
  120. this.list = this.list.concat(newArr)
  121. }
  122. }else{
  123. this.$toast(res.msg)
  124. }
  125. })
  126. },
  127. }
  128. }
  129. </script>
  130. <style>
  131. page{background: #F3F3F0;}
  132. </style>
  133. <style lang="scss" scoped>
  134. .carbox{display: flex;flex-direction: column;min-height: 100vh;padding: 22rpx 18rpx 100rpx;
  135. .cartop{overflow: auto;}
  136. .cartips{background: #FFFFFF;border-radius: 20rpx;height: 98rpx;padding: 0 24rpx;
  137. image{width: 16rpx;height: 28rpx;flex: 0 0 auto;margin-left: 20rpx;}
  138. .tit{font-weight: bold;font-size: 26rpx;color: #272727;}
  139. }
  140. }
  141. </style>