residential.vue 11 KB

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