item.vue 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. <template>
  2. <MeScroll :up="up" :down="down" @up="upFn" :fixed="false" @down="downFn" @init="initMeScroll">
  3. <card @handelRepair="handelRepair" :list="list" @></card>
  4. </MeScroll>
  5. </template>
  6. <script>
  7. import MeScroll from '@/components/mescroll-body/mescroll-uni.vue'
  8. import card from '@/components/repair/repair'
  9. var app=getApp()
  10. export default {
  11. components:{
  12. MeScroll,card
  13. },
  14. props: {
  15. refresh:Boolean,
  16. type: Number,
  17. i: Number,
  18. item:Object
  19. },
  20. data() {
  21. return {
  22. isInit: false, // 是否初始化
  23. list: [], // 列表数据
  24. mescroll: null, // mescroll 对象
  25. // 上拉配置参数
  26. up: {
  27. noMoreSize: 5,
  28. auto: true,
  29. page: {
  30. page: 0,
  31. size: 10
  32. }
  33. },
  34. // 下拉配置参数
  35. down: {
  36. use: true,
  37. auto: false
  38. }
  39. }
  40. },
  41. watch:{
  42. refresh() {
  43. console.log("我要刷新了");
  44. this.mescroll.resetUpScroll()
  45. },
  46. type(val) {
  47. if(!this.isInit && val === this.i) {
  48. this.mescroll.resetUpScroll()
  49. }
  50. }
  51. },
  52. mounted() {
  53. if(!this.isInit && this.i === 0) {
  54. this.mescroll.resetUpScroll()
  55. }
  56. },
  57. methods: {
  58. handelRepair(item){
  59. item.handleStatus=1
  60. item.estimateStatus=0
  61. this.$showModel('确定把该工单置为已处理状态?').then(res=>{
  62. this.$api.residential.addOrEditEstateRepair(item).then(res=>{
  63. this.$u.toast('操作成功')
  64. this.mescroll.resetUpScroll()
  65. })
  66. })
  67. },
  68. /**
  69. * @param {Object} mescroll 初始化组件
  70. */
  71. initMeScroll(mescroll) {
  72. this.mescroll = mescroll
  73. },
  74. /**
  75. * @param {Object} mescroll 上拉回调
  76. */
  77. upFn(mescroll) {
  78. let that=this
  79. let data={
  80. current:mescroll.num,
  81. size:mescroll.size,
  82. handleStatus:this.item.value
  83. }
  84. // if (this.item.value==2) {
  85. // data.handleStatus=1
  86. // data.estimateStatus=0
  87. // }
  88. try{
  89. this.$api.residential.showRepairList(data).then(res=>{
  90. let data=res.data.records
  91. console.log(data);
  92. let length=data.length
  93. mescroll.endBySize(length, res.data.total);
  94. if(mescroll.num == 1) that.list = [];
  95. that.list=that.list.concat(data);
  96. })
  97. }catch(e){
  98. mescroll.endErr();
  99. }
  100. },
  101. /**
  102. * 下拉回调
  103. * */
  104. downFn(mescroll) {
  105. setTimeout(()=>{
  106. this.list=[]
  107. this.mescroll.resetUpScroll()
  108. },1500)
  109. },
  110. }
  111. }
  112. </script>
  113. <style lang="scss" scoped>
  114. view{
  115. box-sizing: border-box;
  116. }
  117. </style>