residential.vue 8.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335
  1. <template>
  2. <view>
  3. <!-- 筛选标签条 -->
  4. <view class="cu-bar bg-white flex" style="z-index: 100;width: 100%;position: fixed;top: -2rpx;">
  5. <view class="u-line-1" @click="showDown(index)" v-for="(item,index) in filterMenu" :key="index" style="width: 20%;text-align: center;height: 100%;">
  6. <text v-text="data[index]==''?item:data[index]" :class="data[index]==''?'':'text-red'"></text>
  7. <u-icon v-if="index!=3" name="arrow-down-fill" size="20" style="padding-left: 10rpx;"></u-icon>
  8. <text class="cuIcon-filter padding-left-10" v-else></text>
  9. <u-badge :offset="[10, 8]" v-if="index==3" size="mini" type="error" :count="filterCount"></u-badge>
  10. </view>
  11. </view>
  12. <mescroll-body ref="mescrollRef" @init="mescrollInit" @down="downCallback" @up="upCallback" :down="downOption" :up="upOption">
  13. <view style="margin-top: 110rpx;">
  14. <card @delItem="delItem" :list="list"></card>
  15. </view>
  16. </mescroll-body>
  17. <!-- 所属机构 -->
  18. <u-popup border-radius="60" height="60%" mode="bottom" v-model="popupShow">
  19. <view class="fixed cu-bar search bg-white">
  20. <view class="search-form round">
  21. <text class="cuIcon-search"></text>
  22. <u-input style="width: 90%;" v-model="agencyKeyword" type="text" :adjust-position="false" placeholder="请输入关键字搜索" confirm-type="search"/>
  23. </view>
  24. </view>
  25. <scroll-view v-if="!$isEmpty(searchList)" style="padding-top: 110rpx;height: 100%;" :scroll-y="true" >
  26. <view @click="residentailConfirm(item)" hover-class="hoverClass" class="text-center padding-30 solid-bottom" v-for="(item,index) in searchList" :key="index">
  27. <text>{{item.label}}</text>
  28. </view>
  29. <u-divider v-if="searchList.length>=10" height="80">只显示十条数据</u-divider>
  30. </scroll-view>
  31. <u-empty v-else name="search"></u-empty>
  32. </u-popup>
  33. <!-- 楼栋 -->
  34. <u-popup border-radius="60" height="60%" mode="bottom" v-model="residentailShow">
  35. <view class="fixed cu-bar search bg-white">
  36. <view class="search-form round">
  37. <text class="cuIcon-search"></text>
  38. <u-input style="width: 90%;" v-model="residentialKeyWord" type="text" :adjust-position="false" placeholder="请输入关键字搜索" confirm-type="search"/>
  39. </view>
  40. </view>
  41. <scroll-view v-if="!$isEmpty(residentialList)" style="padding-top: 110rpx;height: 100%;" :scroll-y="true" >
  42. <view @click="buildingConfirm(item)" hover-class="hoverClass" class="text-center padding-30 solid-bottom" v-for="(item,index) in residentialList" :key="index">
  43. <text>{{item.name}}</text>
  44. </view>
  45. <u-divider v-if="residentialList.length>=10" height="80">只显示十条数据</u-divider>
  46. </scroll-view>
  47. <u-empty v-else name="search"></u-empty>
  48. </u-popup>
  49. <!-- 地区选择器 -->
  50. <u-picker @confirm="regionConfirm" mode="region" v-model="regionShow"></u-picker>
  51. <!-- 筛选 -->
  52. <u-modal :show-cancel-button="true" cancel-text="重置" @cancel="reset" @confirm="filterConfirm" title="筛选" :mask-close-able="true" v-model="filterShow" >
  53. <view class="slot-content" style="margin: 20rpx;">
  54. <u-form label-width="150" :model="params" ref="uForm">
  55. <u-form-item label="小区名"><u-input v-model="params.name" /></u-form-item>
  56. <!-- <u-form-item :border-bottom="false" label="门牌号"><u-input v-model="params.houseNumber" /></u-form-item> -->
  57. </u-form>
  58. </view>
  59. </u-modal>
  60. <!-- 添加按钮 -->
  61. <add-btn @click.native="add"></add-btn>
  62. <!-- 通知alert -->
  63. <u-toast ref="uToast" />
  64. </view>
  65. </template>
  66. <script>
  67. import card from "./card.vue"
  68. import MescrollMixin from "@/components/mescroll-body/mescroll-mixins.js";
  69. let that;
  70. export default {
  71. components:{
  72. card
  73. },
  74. mixins:[MescrollMixin],
  75. data() {
  76. return {
  77. //顶部菜单栏
  78. filterMenu: ["地区","所属机构","物业名称","筛选"],
  79. data:['','','',''],
  80. //地区
  81. regionShow:false,
  82. areaValue:'',
  83. //底部弹出框
  84. popupShow:false,
  85. searchList:[],
  86. //筛选框
  87. filterShow:false,
  88. filterCount:0,
  89. // 列表数据
  90. params:{},
  91. agencyKeyword:'',
  92. //小区
  93. residentailShow:false,
  94. residentialKeyWord:'',
  95. residentialList:[],
  96. list: [],
  97. downOption: {
  98. use: true,
  99. auto: false
  100. },
  101. upOption: {
  102. page: {
  103. page: 0,
  104. size: 10
  105. },
  106. noMoreSize: 5,
  107. empty: {
  108. tip: '暂无相关数据'
  109. }
  110. },
  111. }
  112. },
  113. onLoad(){
  114. that=this
  115. this.getListByLikeName({isSelect:true})
  116. },
  117. onShow() {
  118. if (this.canReset) {
  119. this.mescroll.resetUpScroll()
  120. }
  121. this.canReset=true
  122. },
  123. watch:{
  124. agencyKeyword(){
  125. let that=this
  126. //节流函数
  127. if (this.timer){
  128. clearTimeout(this.timer)//阻止setTimeout函数的执行
  129. }
  130. this.timer = setTimeout(() => {
  131. that.searchList=[]
  132. let params = {
  133. isSelect: true,
  134. regionArea: that.areaValue,
  135. agencyName: that.agencyKeyword
  136. }
  137. this.getListByLikeName(params)
  138. }, 500)
  139. },
  140. residentialKeyWord(){
  141. let that=this
  142. //节流函数
  143. if (this.timer){
  144. clearTimeout(this.timer)//阻止setTimeout函数的执行
  145. }
  146. this.timer = setTimeout(() => {
  147. that.residentialList=[]
  148. let params={
  149. agencyId:that.params.agencyId,
  150. name:that.residentialKeyWord
  151. }
  152. that.fetchresidentialList(params)
  153. }, 500)
  154. },
  155. },
  156. methods: {
  157. /**
  158. * 获取筛选的条件数
  159. */
  160. getFilterCount(){
  161. let n=0
  162. if (!this.$isEmpty(this.params.agencyId)) {
  163. //机构
  164. n++
  165. }
  166. if (!this.$isEmpty(this.params.estatePid)) {
  167. //物业
  168. n++
  169. }
  170. if (!this.$isEmpty(this.params.name)) {
  171. //小区名
  172. n++
  173. }
  174. this.filterCount=n
  175. },
  176. /**
  177. * 下拉回调
  178. */
  179. downCallback(){
  180. setTimeout(()=>{
  181. this.mescroll.resetUpScroll()
  182. },1500)
  183. },
  184. /**
  185. * 上拉回调
  186. * @param {Object} mescroll
  187. */
  188. upCallback(mescroll) {
  189. let params=this.params
  190. params.current=mescroll.num
  191. params.size=mescroll.size
  192. this.getFilterCount()
  193. console.log(111)
  194. try{
  195. this.$api.residential.pageBycondition(params).then(res=>{
  196. console.log(res)
  197. let data=res.data.records
  198. let length=data.length
  199. let total=res.data.total
  200. mescroll.endBySize(length, total);
  201. if(mescroll.num == 1) this.list = [];
  202. this.list=this.list.concat(data);
  203. })
  204. }catch(e){
  205. mescroll.endErr();
  206. }
  207. },
  208. /**
  209. * 重置
  210. */
  211. reset(){
  212. this.params={}
  213. this.data=['','','','','']
  214. this.areaValue=''
  215. this.searchList=[]
  216. this.agencyKeyword=''
  217. this.unitList=[]
  218. this.residentialKeyWord='',
  219. this.residentialList=[],
  220. this.list=[],
  221. this.mescroll.resetUpScroll()
  222. },
  223. /**
  224. * 点击选择机构
  225. */
  226. residentailConfirm(res){
  227. //筛选标题
  228. this.params.residentialId =res.value
  229. this.data[1] = res.label
  230. this.popupShow = false
  231. //获取机构
  232. let params={
  233. residentialId:this.params.residentialId
  234. }
  235. this.fetchresidentialList(params)
  236. this.mescroll.resetUpScroll()
  237. },
  238. /**
  239. * 顶部菜单选择
  240. * @param {Object} index 菜单下标
  241. */
  242. showDown(index){
  243. if (index==0) {
  244. //地区
  245. this.regionShow=true
  246. return
  247. }
  248. if(index==1){
  249. //机构
  250. this.popupShow = true;
  251. return;
  252. }else if(index==2){
  253. //物业名称
  254. this.residentailShow=true
  255. }else if (index==3) {
  256. //筛选
  257. this.filterShow=true
  258. }
  259. },
  260. /**
  261. * 确认筛选
  262. */
  263. filterConfirm(){
  264. this.mescroll.resetUpScroll()
  265. },
  266. /**
  267. * 地区确认回调
  268. * @param {Object} object
  269. */
  270. regionConfirm(object){
  271. this.data[0]= object.area.label;
  272. this.areaValue = object.area.value;
  273. let params = {
  274. isSelect: true,
  275. regionArea: this.areaValue
  276. };
  277. this.getListByLikeName(params);
  278. },
  279. /**
  280. * 获取机构列表
  281. * @param {Object} params
  282. */
  283. getListByLikeName(params){
  284. let list = [];
  285. this.$api.permissions.orgList(params).then(res=>{
  286. console.log(res)
  287. let list = [];
  288. for(let item of res.data.records){
  289. let element = {
  290. label: item.name,
  291. value: item.id
  292. }
  293. list.splice(list.length,0,element);
  294. // list.push(obj);
  295. }
  296. this.searchList = list;
  297. })
  298. },
  299. /**
  300. * 添加小区
  301. */
  302. add(){
  303. uni.navigateTo({
  304. url:"./add"
  305. })
  306. },
  307. delItem(item){
  308. this.$dialog.showModal('确定要删除此项吗?').then(res=>{
  309. this.$api,room.del({id:item.id}).then(res=>{
  310. if (res.data) {
  311. this.$showToast('删除成功')
  312. that.mescroll.resetUpScroll()
  313. }
  314. })
  315. })
  316. }
  317. }
  318. }
  319. </script>
  320. <style>
  321. </style>