user.vue 10 KB

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