user.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399
  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.phone" /></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.data.records.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.data[1]=""
  196. this.data[2]=""
  197. this.residentailShow = false
  198. //获取楼栋列表
  199. this.fetchBuildingList()
  200. this.mescroll.resetUpScroll()
  201. },
  202. /* 楼栋 */
  203. //获取楼栋列表
  204. fetchBuildingList(){
  205. let params={
  206. residentialId:this.params.residentialId,
  207. name:that.buildingKeyWord
  208. }
  209. this.$api.building.page(params).then(res=>{
  210. this.buildingList=res.data.records
  211. })
  212. },
  213. //点击选择楼栋,获取单元列表
  214. buildingConfirm(res){
  215. console.log(res);
  216. this.params.buildingId=res.id
  217. this.data[1] = res.name
  218. this.buildingShow = false
  219. this.getUnitByResidentialId()
  220. this.mescroll.resetUpScroll()
  221. },
  222. /* 单元 */
  223. //获取单元列表
  224. getUnitByResidentialId(){
  225. let params={
  226. residentialId:this.params.residentialId,
  227. buildingId:this.params.buildingId
  228. }
  229. this.$api.unit.page(params).then(res=>{
  230. this.unitList=res.data.records
  231. })
  232. },
  233. //点击选择单元
  234. unitConfirm(index){
  235. this.data[2]=this.unitList[index].name
  236. this.params.unitId=this.unitList[index].id
  237. this.mescroll.resetUpScroll()
  238. },
  239. /* 人脸状态 */
  240. faceStatusConfirm(e){
  241. this.data[3]=this.faceStatusList[e].name
  242. this.params.checkState=this.faceStatusList[e].value
  243. this.mescroll.resetUpScroll()
  244. },
  245. /* 筛选 */
  246. //重置
  247. reset(){
  248. this.params={}
  249. this.data=['','','','','']
  250. this.residentailList=[]
  251. this.buildingList=[]
  252. this.unitList=[]
  253. this.residentailKeyWord=''
  254. this.buildingKeyWord='',
  255. this.list=[],
  256. this.getResidentailList()
  257. this.mescroll.resetUpScroll()
  258. },
  259. //获取筛选的条件数
  260. getFilterCount(){
  261. let n=0
  262. if (!this.$isEmpty(this.params.residentialId)) {
  263. //小区
  264. n++
  265. }
  266. if (!this.$isEmpty(this.params.buildingId)) {
  267. //楼栋
  268. n++
  269. }
  270. if (!this.$isEmpty(this.params.unitId)) {
  271. //单元
  272. n++
  273. }
  274. if (!this.$isEmpty(this.params.checkState)) {
  275. //人脸状态
  276. n++
  277. }
  278. if (!this.$isEmpty(this.params.name)) {
  279. //姓名
  280. n++
  281. }
  282. if (!this.$isEmpty(this.params.phone)) {
  283. //手机号
  284. n++
  285. }
  286. this.filterCount=n
  287. },
  288. /**
  289. * 下拉回调
  290. */
  291. downCallback(){
  292. setTimeout(()=>{
  293. this.mescroll.resetUpScroll()
  294. },1500)
  295. },
  296. /**
  297. * 上拉回调
  298. * @param {Object} mescroll
  299. */
  300. upCallback(mescroll) {
  301. let params=this.params
  302. params.current=mescroll.num
  303. params.size=mescroll.size
  304. this.getFilterCount()
  305. try{
  306. this.$api.user.page(params).then(res=>{
  307. let data=res.data.records
  308. let length=data.length
  309. let total=res.data.total
  310. mescroll.endBySize(length, total);
  311. if(mescroll.num == 1) this.list = [];
  312. this.list=this.list.concat(data);
  313. })
  314. }catch(e){
  315. mescroll.endErr();
  316. }
  317. },
  318. /**
  319. * 顶部菜单选择
  320. * @param {Object} index 菜单下标
  321. */
  322. showDown(index){
  323. if (index==0) {
  324. //小区
  325. this.residentailShow=true
  326. }else if (index==1) {
  327. //楼栋
  328. if (this.$isEmpty(this.params.residentialId)) {
  329. this.$u.toast('请选择小区')
  330. }else{
  331. this.buildingShow=true
  332. }
  333. return
  334. }else if (index==2) {
  335. //单元
  336. if (this.$isEmpty(this.params.buildingId)) {
  337. this.$u.toast('请选择楼栋')
  338. }else{
  339. this.unitShow=true
  340. }
  341. return
  342. }else if (index==3) {
  343. //人脸状态
  344. this.faceShow=true
  345. }else if (index==4) {
  346. //筛选
  347. this.filterShow=true
  348. }
  349. },
  350. //添加
  351. add(){
  352. uni.navigateTo({
  353. url:"./add"
  354. })
  355. },
  356. //删除
  357. delItem(item){
  358. this.$dialog.showModal('确定要删除此项吗?').then(res=>{
  359. this.$api.user.del({id:item.id}).then(res=>{
  360. if (res.data==true) {
  361. this.$u.toast('删除成功')
  362. that.mescroll.resetUpScroll()
  363. }
  364. })
  365. })
  366. }
  367. }
  368. }
  369. </script>
  370. <style>
  371. </style>