live.vue 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199
  1. <template>
  2. <view>
  3. <u-toast ref="uToast" />
  4. <view class="bg-white" style="position: sticky;top: 0;z-index: 999;">
  5. <view class="flex justify-around padding-20 bg-white">
  6. <view class="" @click="filter(1)">
  7. <text :class="residentialValue?'text-red':''">所属区域</text>
  8. <text class="cuIcon-unfold padding-left-10"></text>
  9. </view>
  10. <view class="" @click="filter(2)">
  11. <text :class="buildingValue?'text-red':''">所属楼栋</text>
  12. <text class="cuIcon-unfold padding-left-10"></text>
  13. </view>
  14. <view class="" :class="confirmFilter?'text-red':''" @click="filter(3)">
  15. <text>其他筛选</text>
  16. <text class="cuIcon-unfold padding-left-10"></text>
  17. </view>
  18. </view>
  19. </view>
  20. <!-- <view class="" :style="{height:dropdownHeight}"></view> -->
  21. <mescroll-body ref="mescrollRef" @init="mescrollInit" @down="downCallback" @up="upCallback" :down="downOption" :up="upOption">
  22. <live-card :list="list"></live-card>
  23. </mescroll-body>
  24. <!-- 所属区域筛选 -->
  25. <u-select v-model="residentialShow" @confirm="residentialConfirm" :list="residentialList"></u-select>
  26. <u-select v-model="buildingShow" @confirm="buildingConfirm" :list="buildingList"></u-select>
  27. <u-modal cancel-text="重置" cancel-color="#000000" @cancel="filterReset" confirm-color="#5064eb" :show-cancel-button="true" @confirm="filterConfirm" title="筛选" :mask-close-able="true" v-model="filterShow" >
  28. <view class="slot-content" style="margin: 20rpx;">
  29. <u-form label-width="150" ref="uForm">
  30. <u-form-item :border-bottom="false" label="设备名称"><u-input v-model="deviceName" /></u-form-item>
  31. </u-form>
  32. </view>
  33. </u-modal>
  34. </view>
  35. </template>
  36. <script>
  37. import MescrollMixin from "@/components/mescroll-body/mescroll-mixins.js";
  38. import liveCard from "./comps/live-card.vue"
  39. var that;
  40. export default {
  41. mixins: [MescrollMixin], // 使用mixin
  42. components:{
  43. liveCard
  44. },
  45. data() {
  46. return {
  47. dropdownHeight:'',
  48. //筛选设备名称
  49. confirmFilter:false,//是否点击了筛选按钮,点击了筛选后就让文字显红
  50. filterShow:false,
  51. deviceName:'',
  52. //区域
  53. residentialValue: '',
  54. residentialShow: false,
  55. residentialList: [],
  56. //楼栋
  57. buildingValue:'',
  58. buildingShow: false,
  59. buildingList:[],
  60. }
  61. },
  62. onLoad() {
  63. that=this
  64. this.fetchResidentialList()
  65. },
  66. onReady() {
  67. this.$u.getRect('.dropdown').then(res=>{
  68. this.dropdownHeight=res.height+'px'
  69. })
  70. },
  71. methods: {
  72. fetchResidentialList(){
  73. this.$api.residential.selectPage({size:100}).then(res=>{
  74. this.residentialList=[{label:'全部',value:''}]
  75. res.data.forEach(item=>{
  76. let obj={
  77. label:item.name,
  78. value:item.id
  79. }
  80. this.residentialList.push(obj)
  81. })
  82. })
  83. },
  84. fetchBuilding(){
  85. let params={residentialId:this.residentialValue,size:100}
  86. this.$api.building.page(params).then(res=>{
  87. this.buildingList=[{label:'全部',value:''}]
  88. res.data.records.forEach(item=>{
  89. let obj={
  90. label:item.name,
  91. value:item.id
  92. }
  93. this.buildingList.push(obj)
  94. })
  95. })
  96. },
  97. upCallback(mescroll){
  98. let params={
  99. current:mescroll.num,
  100. size:mescroll.size,
  101. residentialId:this.residentialValue,
  102. buildingId:this.buildingValue,
  103. deviceName:this.deviceName
  104. }
  105. try{
  106. this.$api.live.page(params).then(res=>{
  107. let data=res.data
  108. mescroll.endSuccess(data.length);
  109. if(mescroll.num == 1) that.list = []; //如果是第一页需手动制空列表
  110. that.list=data; //追加新数据
  111. })
  112. }catch(e){
  113. this.mescroll.endErr()
  114. }
  115. },
  116. //筛选
  117. open(index) {
  118. this.$refs.uDropdown.highlight();
  119. },
  120. close(index) {
  121. this.$refs.uDropdown.highlight(index);
  122. },
  123. closeDropdown() {
  124. this.$refs.uDropdown.close();
  125. },
  126. reset(){
  127. this.deviceName=''
  128. this.residentialValue=''
  129. this.buildingValue=''
  130. this.mescroll.resetUpScroll();
  131. this.closeDropdown()
  132. },
  133. filter(type){
  134. if (type==1) {
  135. //筛选区域
  136. this.residentialShow=true
  137. return
  138. }
  139. if (type==2) {
  140. if (this.$isEmpty(this.residentialValue)) {
  141. this.$refs.uToast.show({
  142. title: '请选择区域',
  143. type: 'error',
  144. position:'top'
  145. })
  146. return
  147. }
  148. //筛选楼栋
  149. this.buildingShow=true
  150. return
  151. }
  152. if (type==3) {
  153. this.filterShow=true
  154. return
  155. }
  156. },
  157. residentialConfirm(e){
  158. this.residentialValue=e[0].value
  159. //获取楼栋列表
  160. this.fetchBuilding()
  161. this.reload()
  162. },
  163. buildingConfirm(e){
  164. this.buildingValue=e[0].value
  165. this.reload()
  166. },
  167. filterConfirm(){
  168. this.confirmFilter=true
  169. this.reload()
  170. },
  171. /**
  172. * 重置筛选项
  173. */
  174. filterReset(){
  175. this.residentialValue=''
  176. this.buildingValue=''
  177. this.deviceName=''
  178. this.confirmFilter=false
  179. this.reload()
  180. },
  181. }
  182. }
  183. </script>
  184. <style lang="scss">
  185. page{
  186. background-color: #dadada;
  187. }
  188. </style>