list.vue 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. <template>
  2. <view class="">
  3. <mescroll-body ref="mescrollRef" @init="mescrollInit" @down="downCallback" @up="upCallback" :down="downOption"
  4. :up="upOption">
  5. <card @deleteItem="deleteItem" :list="list" @cancel="cancel"></card>
  6. </mescroll-body>
  7. </view>
  8. </template>
  9. <script>
  10. import MescrollMixin from "@/comps/mescroll-body/mescroll-mixins.js";
  11. import card from "./card.vue"
  12. export default {
  13. mixins: [MescrollMixin], // 使用mixin
  14. name: '',
  15. components: {
  16. card
  17. },
  18. data() {
  19. return {
  20. list: [],
  21. page: {
  22. current: 1,
  23. size: 30,
  24. },
  25. };
  26. },
  27. methods: {
  28. /**
  29. * @param {Object} item 删除订单
  30. */
  31. deleteItem(item) {
  32. this.$dialog.showModal('确定要删除该工单').then(_=>{
  33. //删除状态
  34. item.isDeleted = 1
  35. this.$http.addEstateRepair(item).then(res => {
  36. if (res.data.add_result == true) {
  37. this.$u.toast('删除成功')
  38. this.mescroll.resetUpScroll()
  39. } else {
  40. app.globalData.oneFailHint(res.data.add_result);
  41. }
  42. });
  43. })
  44. },
  45. /**
  46. * 取消订单
  47. * @param {Object} item 订单实体
  48. */
  49. cancel(item) {
  50. this.$dialog.showModal('确定要取消该工单').then(_ => {
  51. item.handleStatus = 3
  52. this.$http.addEstateRepair(item).then(res => {
  53. if (res.data.success) {
  54. this.$u.toast('取消成功')
  55. this.mescroll.resetUpScroll()
  56. } else {
  57. getApp().globalData.oneFailHint(res.data.add_result);
  58. }
  59. });
  60. })
  61. },
  62. downCallback(mescroll) {
  63. setTimeout(() => {
  64. this.mescroll.resetUpScroll()
  65. }, 200)
  66. },
  67. upCallback(mescroll) {
  68. let data = {
  69. "page": {
  70. current: mescroll.num,
  71. size: mescroll.size,
  72. },
  73. memberId: this.vuex_member.id,
  74. }
  75. try {
  76. this.$http.estateRepairList(data).then(res => {
  77. let data = res.data.data
  78. let records = data.records
  79. let length = records.length
  80. mescroll.endBySize(length, data.total);
  81. if (mescroll.num == 1) this.list = []; //如果是第一页需手动制空列表
  82. this.list = this.list.concat(records); //追加新数据
  83. });
  84. } catch (e) {
  85. mescroll.endErr();
  86. }
  87. }
  88. }
  89. };
  90. </script>
  91. <style lang="scss" scoped>
  92. </style>