user.vue 9.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395
  1. <template>
  2. <view>
  3. <!-- 筛选标签条 -->
  4. <view class="cu-bar bg-white flex" style="padding: 0 10rpx;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: 25%;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!=4" 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==4" 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 @deleteItem="delItem" :list="list"></card>
  15. </view>
  16. </mescroll-body>
  17. <!-- 小区 -->
  18. <u-popup border-radius="60" height="60%" mode="bottom" v-model="residentailShow">
  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="residentailKeyWord" type="text" :adjust-position="false" placeholder="请输入关键字搜索" confirm-type="search"/>
  23. </view>
  24. </view>
  25. <scroll-view v-if="!$isEmpty(residentailList)" 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 residentailList" :key="index">
  27. <text>{{item.label}}</text>
  28. </view>
  29. <u-divider v-if="residentailList.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="buildingShow">
  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="buildingKeyWord" type="text" :adjust-position="false" placeholder="请输入关键字搜索" confirm-type="search"/>
  39. </view>
  40. </view>
  41. <scroll-view v-if="!$isEmpty(buildingList)" 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 buildingList" :key="index">
  43. <text>{{item.name}}</text>
  44. </view>
  45. <u-divider v-if="buildingList.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="unitConfirm" range-key="name" :range="unitList" v-model="unitShow" mode="selector"></u-picker>
  51. <!-- 人脸状态 -->
  52. <u-picker @confirm="faceStatusConfirm" range-key="name" :range="faceStatusList" v-model="faceShow" mode="selector"></u-picker>
  53. <!-- 筛选 -->
  54. <u-modal :show-cancel-button="true" cancel-text="重置" @cancel="reset" @confirm="mescroll.resetUpScroll()" title="筛选" :mask-close-able="true" v-model="filterShow" >
  55. <view class="slot-content" style="margin: 20rpx;">
  56. <u-form label-width="150" :model="params" ref="uForm">
  57. <u-form-item label="姓名"><u-input v-model="params.name" /></u-form-item>
  58. <u-form-item :border-bottom="false" label="手机号"><u-input type="number" v-model="params.tel" /></u-form-item>
  59. </u-form>
  60. </view>
  61. </u-modal>
  62. <!-- 添加按钮 -->
  63. <!-- <add-btn @click.native="add"></add-btn> -->
  64. <!-- 通知alert -->
  65. <u-toast ref="uToast" />
  66. </view>
  67. </template>
  68. <script>
  69. import card from "./comps/card.vue"
  70. import MescrollMixin from "@/components/mescroll-body/mescroll-mixins.js";
  71. let that;
  72. export default {
  73. components:{
  74. card
  75. },
  76. mixins:[MescrollMixin],
  77. data() {
  78. return {
  79. //顶部菜单栏
  80. filterMenu: ["小区","楼栋","单元","人脸状态","筛选"],
  81. data:['','','','',''],
  82. //小区
  83. residentailShow:false,
  84. residentailList:[],
  85. residentailKeyWord:'',
  86. //楼栋
  87. buildingShow:false,
  88. buildingList:[],
  89. buildingKeyWord:'',
  90. //单元
  91. unitShow:false,
  92. unitList:[],
  93. //人脸状态
  94. faceShow:false,
  95. faceStatusList:[
  96. {
  97. 'name':'待审核',
  98. 'value':'0'
  99. },
  100. {
  101. 'name':'审核通过',
  102. 'value':'1'
  103. },
  104. {
  105. 'name':'审核未通过',
  106. 'value':'2'
  107. },
  108. {
  109. 'name':'待上传',
  110. 'value':'-1'
  111. },
  112. ],
  113. //筛选框
  114. filterShow:false,
  115. filterCount:0,
  116. params:{},
  117. list: [],
  118. downOption: {
  119. use: true,
  120. auto: false
  121. },
  122. upOption: {
  123. page: {
  124. page: 0,
  125. size: 10
  126. },
  127. noMoreSize: 5,
  128. empty: {
  129. tip: '暂无相关数据'
  130. }
  131. },
  132. }
  133. },
  134. onLoad(){
  135. that=this
  136. this.getResidentailList()
  137. },
  138. onShow() {
  139. if (this.canReset) {
  140. this.mescroll.resetUpScroll()
  141. }
  142. this.canReset=true
  143. },
  144. watch:{
  145. residentailKeyWord(){
  146. let that=this
  147. //节流函数
  148. if (this.timer){
  149. clearTimeout(this.timer)//阻止setTimeout函数的执行
  150. }
  151. this.timer = setTimeout(() => {
  152. that.residentailList=[]
  153. this.getResidentailList()
  154. }, 500)
  155. },
  156. buildingKeyWord(){
  157. let that=this
  158. //节流函数
  159. if (this.timer){
  160. clearTimeout(this.timer)//阻止setTimeout函数的执行
  161. }
  162. this.timer = setTimeout(() => {
  163. that.buildingList=[]
  164. that.fetchBuildingList()
  165. }, 500)
  166. },
  167. },
  168. methods: {
  169. /* 小区 */
  170. //获取小区列表
  171. getResidentailList(){
  172. let params={
  173. isSelect:true,
  174. name: that.residentailKeyWord,
  175. }
  176. let list = [];
  177. this.$api.residential.page(params).then(res=>{
  178. let list=[]
  179. res.list.forEach(item=>{
  180. let obj={
  181. label:item.name,
  182. value:item.id
  183. }
  184. list.push(obj)
  185. })
  186. this.residentailList = list;
  187. })
  188. },
  189. //点击选择小区,获取楼栋列表
  190. residentailConfirm(res){
  191. this.params.residentialId =res.value
  192. this.data[0] = res.label
  193. this.residentailShow = false
  194. //获取楼栋列表
  195. this.fetchBuildingList()
  196. this.mescroll.resetUpScroll()
  197. },
  198. /* 楼栋 */
  199. //获取楼栋列表
  200. fetchBuildingList(){
  201. let params={
  202. residentialId:this.params.residentialId,
  203. name:that.buildingKeyWord
  204. }
  205. this.$api.building.page(params).then(res=>{
  206. this.buildingList=res.data.records
  207. })
  208. },
  209. //点击选择楼栋,获取单元列表
  210. buildingConfirm(res){
  211. console.log(res);
  212. this.params.buildingId=res.id
  213. this.data[1] = res.name
  214. this.buildingShow = false
  215. this.getUnitByResidentialId()
  216. this.mescroll.resetUpScroll()
  217. },
  218. /* 单元 */
  219. //获取单元列表
  220. getUnitByResidentialId(){
  221. let params={
  222. residentialId:this.params.residentialId,
  223. buildingId:this.params.buildingId
  224. }
  225. this.$api.unit.page(params).then(res=>{
  226. this.unitList=res.list
  227. })
  228. },
  229. //点击选择单元
  230. unitConfirm(index){
  231. this.data[2]=this.unitList[index].name
  232. this.params.unitId=this.unitList[index].id
  233. this.mescroll.resetUpScroll()
  234. },
  235. /* 人脸状态 */
  236. faceStatusConfirm(e){
  237. this.data[3]=this.faceStatusList[e].name
  238. this.params.checkState=this.faceStatusList[e].value
  239. this.mescroll.resetUpScroll()
  240. },
  241. /* 筛选 */
  242. //重置
  243. reset(){
  244. this.params={}
  245. this.data=['','','','','']
  246. this.residentailList=[]
  247. this.buildingList=[]
  248. this.unitList=[]
  249. this.residentailKeyWord=''
  250. this.buildingKeyWord='',
  251. this.list=[],
  252. this.getResidentailList()
  253. this.mescroll.resetUpScroll()
  254. },
  255. //获取筛选的条件数
  256. getFilterCount(){
  257. let n=0
  258. if (!this.$isEmpty(this.params.residentialId)) {
  259. //小区
  260. n++
  261. }
  262. if (!this.$isEmpty(this.params.buildingId)) {
  263. //楼栋
  264. n++
  265. }
  266. if (!this.$isEmpty(this.params.unitId)) {
  267. //单元
  268. n++
  269. }
  270. if (!this.$isEmpty(this.params.checkState)) {
  271. //人脸状态
  272. n++
  273. }
  274. if (!this.$isEmpty(this.params.name)) {
  275. //姓名
  276. n++
  277. }
  278. if (!this.$isEmpty(this.params.tel)) {
  279. //手机号
  280. n++
  281. }
  282. this.filterCount=n
  283. },
  284. /**
  285. * 下拉回调
  286. */
  287. downCallback(){
  288. setTimeout(()=>{
  289. this.mescroll.resetUpScroll()
  290. },1500)
  291. },
  292. /**
  293. * 上拉回调
  294. * @param {Object} mescroll
  295. */
  296. upCallback(mescroll) {
  297. let params=this.params
  298. params.current=mescroll.num
  299. params.size=mescroll.size
  300. this.getFilterCount()
  301. try{
  302. this.$api.user.page(params).then(res=>{
  303. let data=res.data.records
  304. let length=data.length
  305. let total=res.data.total
  306. mescroll.endBySize(length, total);
  307. if(mescroll.num == 1) this.list = [];
  308. this.list=this.list.concat(data);
  309. })
  310. }catch(e){
  311. mescroll.endErr();
  312. }
  313. },
  314. /**
  315. * 顶部菜单选择
  316. * @param {Object} index 菜单下标
  317. */
  318. showDown(index){
  319. if (index==0) {
  320. //小区
  321. this.residentailShow=true
  322. }else if (index==1) {
  323. //楼栋
  324. if (this.$isEmpty(this.params.residentialId)) {
  325. this.$u.toast('请选择小区')
  326. }else{
  327. this.buildingShow=true
  328. }
  329. return
  330. }else if (index==2) {
  331. //单元
  332. if (this.$isEmpty(this.params.buildingId)) {
  333. this.$u.toast('请选择楼栋')
  334. }else{
  335. this.unitShow=true
  336. }
  337. return
  338. }else if (index==3) {
  339. //人脸状态
  340. this.faceShow=true
  341. }else if (index==4) {
  342. //筛选
  343. this.filterShow=true
  344. }
  345. },
  346. //添加
  347. add(){
  348. uni.navigateTo({
  349. url:"./add"
  350. })
  351. },
  352. //删除
  353. delItem(item){
  354. this.$dialog.showModal('确定要删除此项吗?').then(res=>{
  355. this.$api.user.del({id:item.id}).then(res=>{
  356. if (res.data==true) {
  357. this.$u.toast('删除成功')
  358. that.mescroll.resetUpScroll()
  359. }
  360. })
  361. })
  362. }
  363. }
  364. }
  365. </script>
  366. <style>
  367. </style>