item.vue 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  1. <template>
  2. <MeScroll :up="up" :down="down" @up="upFn" :fixed="false" @down="downFn" @init="initMeScroll">
  3. <card @deleteItem="deleteItem" :list="list" @cancel="cancel"></card>
  4. </MeScroll>
  5. </template>
  6. <script>
  7. import MeScroll from '@/comps/mescroll-body/mescroll-uni.vue'
  8. import card from './card.vue'
  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: false,
  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. /**
  59. * @param {Object} item 删除订单
  60. */
  61. deleteItem(item){
  62. let that=this
  63. app.globalData.twoFailHint("确定要删除该工单?",function(){
  64. //删除状态
  65. item.isDeleted=1
  66. // let operation='estateRepair/addEstateRepair'
  67. that.$http.addEstateRepair(item).then(res =>{
  68. if (res.data.add_result==true) {
  69. app.globalData.oneFailHint("删除成功成功");
  70. that.mescroll.resetUpScroll()
  71. }else{
  72. app.globalData.oneFailHint(res.data.add_result);
  73. }
  74. });
  75. })
  76. },
  77. /**
  78. * 取消订单
  79. * @param {Object} item 订单实体
  80. */
  81. cancel(item){
  82. let that=this
  83. app.globalData.twoFailHint("确定要取消该工单?",function(){
  84. item.handleStatus=3
  85. // let operation='estateRepair/addEstateRepair'
  86. that.$http.addEstateRepair(item).then (res =>{
  87. console.log(res,"ress");
  88. if (res.data.success) {
  89. app.globalData.oneFailHint("取消成功");
  90. that.mescroll.resetUpScroll()
  91. }else{
  92. app.globalData.oneFailHint(res.data.add_result);
  93. }
  94. });
  95. })
  96. },
  97. /**
  98. * @param {Object} mescroll 初始化组件
  99. */
  100. initMeScroll(mescroll) {
  101. this.mescroll = mescroll
  102. },
  103. /**
  104. * @param {Object} mescroll 上拉回调
  105. */
  106. upFn(mescroll) {
  107. let that=this
  108. let data={
  109. "page":{
  110. current:mescroll.num,
  111. size:mescroll.size,
  112. },
  113. memberId:this.vuex_member.id,
  114. handleStatus:this.item.value
  115. }
  116. try{
  117. that.$http.estateRepairList(data).then (res=>{
  118. let data=res.data.data
  119. let records=data.records
  120. let length=records.length
  121. mescroll.endBySize(length, data.total);
  122. if(mescroll.num == 1) that.list = []; //如果是第一页需手动制空列表
  123. that.list=that.list.concat(records); //追加新数据
  124. });
  125. }catch(e){
  126. mescroll.endErr();
  127. }
  128. },
  129. /**
  130. * 下拉回调
  131. * */
  132. downFn(mescroll) {
  133. setTimeout(()=>{
  134. this.list=[]
  135. this.mescroll.resetUpScroll()
  136. },1500)
  137. },
  138. }
  139. }
  140. </script>
  141. <style lang="scss" scoped>
  142. view{
  143. box-sizing: border-box;
  144. }
  145. </style>