car.vue 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  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. }
  31. },
  32. onUnload() {
  33. uni.$off('carlist')
  34. },
  35. onLoad: function() {
  36. uni.$on('carlist',(res)=>{
  37. this.getDataFn()
  38. })
  39. this.init()
  40. this.getDataFn()
  41. },
  42. // 上拉触底加载更多触发事件
  43. onReachBottom() {
  44. if (this.reachflag) {
  45. this.pageNum++
  46. this.getDataFn()
  47. }
  48. },
  49. methods:{
  50. checkPermi, checkRole,
  51. init(){
  52. // 车型
  53. getDictionaryFn('cartype').then(res=>{
  54. if(res.code==200){
  55. this.clcxList = res.data.map(v => {
  56. return {
  57. dictLabel: v.dictLabel,
  58. dictValue: v.dictValue
  59. }
  60. })
  61. }
  62. })
  63. },
  64. getDelFn(data){
  65. var that=this;
  66. carDel(data).then(res=>{
  67. if(res.code==200){
  68. this.$toast("删除成功");
  69. setTimeout(function(){
  70. that.getDataFn()
  71. },1500)
  72. }
  73. })
  74. },
  75. getAddFn(){
  76. this.$tab.navigateTo("/work/pages/manage/addcar")
  77. },
  78. getDetail(id){
  79. this.$tab.navigateTo("/work/pages/manage/addcar?id="+id)
  80. },
  81. getChargeFn(){
  82. this.$tab.navigateTo("/mine/pages/car/charge")
  83. },
  84. getDataFn(){
  85. var params={
  86. pageSize:this.pageSize,
  87. pageNum: this.pageNum,
  88. }
  89. carList(params).then(res=>{
  90. if(res.code==200){
  91. if (res.rows.length < this.pageSize) {
  92. this.reachflag = false
  93. this.wtdt = '到底了~';
  94. } else {
  95. var num = parseInt(res.rows.length) + parseInt(this.pageSize) * parseInt(this.pageNum - 1)
  96. if (num < res.total) {
  97. this.reachflag = true
  98. this.wtdt = ''
  99. } else {
  100. this.reachflag = false
  101. this.wtdt = '到底了~';
  102. }
  103. }
  104. var newArr=JSON.parse(JSON.stringify(res.rows))
  105. newArr.forEach(ite=>{
  106. ite.right=0;
  107. })
  108. if (this.pageNum == 1) {
  109. this.list = newArr;
  110. } else {
  111. this.list = this.list.concat(newArr)
  112. }
  113. }else{
  114. this.$toast(res.msg)
  115. }
  116. })
  117. },
  118. }
  119. }
  120. </script>
  121. <style>
  122. page{background: #F3F3F0;}
  123. </style>
  124. <style lang="scss" scoped>
  125. .carbox{display: flex;flex-direction: column;min-height: 100vh;padding: 22rpx 18rpx 100rpx;
  126. .cartop{overflow: auto;}
  127. .cartips{background: #FFFFFF;border-radius: 20rpx;height: 98rpx;padding: 0 24rpx;
  128. image{width: 16rpx;height: 28rpx;flex: 0 0 auto;margin-left: 20rpx;}
  129. .tit{font-weight: bold;font-size: 26rpx;color: #272727;}
  130. }
  131. }
  132. </style>