item.vue 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. <template>
  2. <MeScroll :up="up" :down="down" @up="upFn" :fixed="false" @down="downFn" @init="initMeScroll">
  3. <card :list="list" ></card>
  4. </MeScroll>
  5. </template>
  6. <script>
  7. import MeScroll from '@/components/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. fireType: Number,
  19. item:Object
  20. },
  21. data() {
  22. return {
  23. isInit: false, // 是否初始化
  24. list: [], // 列表数据
  25. mescroll: null, // mescroll 对象
  26. // 上拉配置参数
  27. up: {
  28. noMoreSize: 5,
  29. auto: true,
  30. page: {
  31. page: 0,
  32. size: 10
  33. }
  34. },
  35. // 下拉配置参数
  36. down: {
  37. use: true,
  38. auto: false
  39. }
  40. }
  41. },
  42. watch:{
  43. refresh() {
  44. console.log("我要刷新了");
  45. this.mescroll.resetUpScroll()
  46. },
  47. type(val) {
  48. if(!this.isInit && val === this.i) {
  49. this.mescroll.resetUpScroll()
  50. }
  51. }
  52. },
  53. mounted() {
  54. if(!this.isInit && this.i === 0) {
  55. this.mescroll.resetUpScroll()
  56. }
  57. },
  58. methods: {
  59. /**
  60. * @param {Object} mescroll 初始化组件
  61. */
  62. initMeScroll(mescroll) {
  63. this.mescroll = mescroll
  64. },
  65. /**
  66. * @param {Object} mescroll 上拉回调
  67. */
  68. upFn(mescroll) {
  69. let that=this
  70. let params={
  71. creditCode:this.$cache.get('creditCode'), //公司统一信用代码
  72. current:mescroll.num,
  73. size:mescroll.size,
  74. }
  75. if (this.fireType==0) {
  76. //烟感报警
  77. params.prefix=this.$device_prefix.SMOKE
  78. }else if (this.fireType==1) {
  79. //燃气告警
  80. params.prefix=this.$device_prefix.GAS
  81. }else if (this.fireType==2) {
  82. //消防水压
  83. params.deviceType=this.$device_type.FIRE_HYDRANT
  84. }
  85. if (!this.$isEmpty(this.item.value)) {
  86. params.deviceStatus=this.item.value //设备状态
  87. }
  88. try{
  89. this.$api.fireDevice.page(params).then(res=>{
  90. let data=res.data.records
  91. let length=data.length
  92. let total=res.data.total
  93. mescroll.endBySize(length, 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.mescroll.resetUpScroll()
  107. },1500)
  108. },
  109. }
  110. }
  111. </script>
  112. <style lang="scss" scoped>
  113. view{
  114. box-sizing: border-box;
  115. }
  116. </style>