people.vue 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215
  1. <template>
  2. <view class="car">
  3. <view class="cartop">
  4. <view class="topa flexc">
  5. <image :src="reset" class="resetimg" @click="getReset"></image>
  6. <picker range-key='dictLabel' :range="rymmList" @change='bindDateChangea'>
  7. <view class="chekt flexc">
  8. <view class="over">{{rymm|| "选择身份"}}</view>
  9. <image :src="up"></image>
  10. </view>
  11. </picker>
  12. <view class="search flexc">
  13. <image :src="search"></image>
  14. <!-- confirm-type="search" @confirm="getConfirm" -->
  15. <input placeholder="请输入人员姓名进行搜索" v-model="text"/>
  16. <view class="btn" @click="getConfirm">搜索</view>
  17. </view>
  18. </view>
  19. </view>
  20. <!-- 列表 -->
  21. <view class="carlists">
  22. <box-list :datainfo="list" :rymmList="rymmList" :wtdt="wtdt" type='people' @getDelFn="getDelFn" @getDetail="getDetail"></box-list>
  23. </view>
  24. <block v-if="checkPermi(['wuYe:residentInfo:add'])">
  25. <view style="height: 100rpx;"></view>
  26. <view class="rfbtn" @click="getAddFn">添加人员</view>
  27. </block>
  28. <loading></loading>
  29. </view>
  30. </template>
  31. <script>
  32. import config from '@/config'
  33. const baseUrl = config.baseUrl
  34. import boxList from "@/mine/components/box/list.vue"
  35. import {getDictionaryFn} from "@/api/system/user.js"
  36. import { checkPermi, checkRole } from "@/utils/permission"; // 权限判断函数
  37. import {houseInfoList} from "@/api/work/work.js"
  38. import {residentInfoList,residentInfoDel} from "@/api/work/people.js"
  39. export default{
  40. components:{boxList},
  41. data(){
  42. return{
  43. reset:require('@/mine/static/reset.png'),
  44. search:require('@/mine/static/search.png'),
  45. up:require('@/mine/static/up.png'),
  46. sfxx:"",
  47. text:'',
  48. rymm:'',
  49. rymmid:"",
  50. rymmList:[],
  51. list:[],
  52. pageSize: 10,
  53. pageNum: 1,
  54. reachflag: true,
  55. wtdt:'',
  56. houseId:'',
  57. userId:this.$store.state.user.userId,
  58. phonenumber:this.$store.state.user.phonenumber,
  59. }
  60. },
  61. onUnload() {
  62. uni.$off('residentInfoList')
  63. },
  64. onLoad: function(e) {
  65. uni.$on('residentInfoList',(res)=>{
  66. this.getrefreshData()
  67. })
  68. if(e.id){
  69. this.houseId=e.id;
  70. }
  71. this.init()
  72. this.getDataFn()
  73. },
  74. // 上拉触底加载更多触发事件
  75. onReachBottom() {
  76. if (this.reachflag) {
  77. this.pageNum++
  78. this.getDataFn()
  79. }
  80. },
  81. methods:{
  82. checkPermi, checkRole,
  83. init(){
  84. //人员面貌
  85. getDictionaryFn('affiliation_personnel').then(res=>{
  86. if(res.code==200){
  87. this.rymmList = res.data.map(v => {
  88. return {
  89. dictLabel: v.dictLabel,
  90. dictValue: v.dictValue
  91. }
  92. })
  93. }
  94. })
  95. },
  96. getAddFn(){
  97. this.$tab.navigateTo("/health/pages/health/add")
  98. },
  99. getDetail(id){
  100. this.$tab.navigateTo("/health/pages/health/add?id="+id)
  101. },
  102. getConfirm(){
  103. this.getrefreshData()
  104. },
  105. getReset(){
  106. this.rymm='';
  107. this.text='';
  108. this.getrefreshData()
  109. },
  110. getrefreshData(){
  111. this.pageNum=1;
  112. this.list=[];
  113. this.reachflag=true;
  114. this.getDataFn()
  115. },
  116. getTabFn(val){
  117. this.tabval=val
  118. },
  119. bindDateChangea(e){
  120. var val=e.detail.value;
  121. this.rymm=this.rymmList[val].dictLabel;
  122. this.rymmid=this.rymmList[val].dictValue;
  123. this.getrefreshData()
  124. },
  125. getDelFn(id){
  126. var that=this;
  127. residentInfoDel(id).then(res=>{
  128. if(res.code==200){
  129. that.$toast("删除成功")
  130. setTimeout(function(){
  131. that.getrefreshData()
  132. },1500)
  133. }
  134. })
  135. },
  136. getDataFn(){
  137. var params={
  138. pageSize:this.pageSize,
  139. pageNum: this.pageNum,
  140. residentPhone:this.phonenumber,
  141. userId:this.userId
  142. }
  143. if(this.houseId){
  144. params.houseId=this.houseId
  145. }
  146. if(this.text){
  147. params.residentName=this.text
  148. }
  149. if(this.rymm){
  150. params.residentAppearance=this.rymmid
  151. }
  152. houseInfoList(params).then(res=>{
  153. if(res.code==200){
  154. if (res.rows.length < this.pageSize) {
  155. this.reachflag = false
  156. this.wtdt = '到底了~';
  157. } else {
  158. var num = parseInt(res.rows.length) + parseInt(this.pageSize) * parseInt(this.pageNum - 1)
  159. if (num < res.total) {
  160. this.reachflag = true
  161. this.wtdt = ''
  162. } else {
  163. this.reachflag = false
  164. this.wtdt = '到底了~';
  165. }
  166. }
  167. var newArr=JSON.parse(JSON.stringify(res.rows))
  168. newArr.forEach(ite=>{
  169. var newArr=ite.residentInfoList;
  170. if(ite.residentInfoList){
  171. newArr.forEach(itea=>{
  172. itea.right=0
  173. })
  174. }
  175. ite.zhanflag=false;
  176. })
  177. if (this.pageNum == 1) {
  178. this.list = newArr;
  179. } else {
  180. this.list = this.list.concat(newArr)
  181. }
  182. }else{
  183. this.$toast(res.msg)
  184. }
  185. })
  186. },
  187. }
  188. }
  189. </script>
  190. <style>
  191. page{background: #F3F3F0;}
  192. </style>
  193. <style lang="scss" scoped>
  194. .car{padding-top: 140rpx;}
  195. .cartop{position: fixed;left: 0;right: 0;top: 0;background-color: #ffffff;z-index: 2;
  196. .topa{padding: 20rpx 20rpx 32rpx;
  197. .resetimg{width: 36rpx;height: 36rpx;margin-right: 24rpx;flex: 0 0 auto;}
  198. .chekt{width: 150rpx;overflow: hidden;
  199. view{font-weight: 500;font-size: 26rpx;color: #272727;flex: 1;}
  200. image{width: 24rpx;height: 16rpx;margin-left: 18rpx;flex: 0 0 auto;}
  201. }
  202. .search{flex: 1;margin-left: 16rpx;height: 64rpx;background: #EEEEEE;border-radius: 32rpx;border: 2rpx solid #E6E6E6;padding-left: 24rpx;box-sizing: border-box;
  203. image{width: 32rpx;height: 34rpx;margin-right: 22rpx;flex: 0 0 auto;}
  204. input{flex: 1;font-size: 26rpx;color: #272727;}
  205. .btn{width: 100rpx;height: 64rpx;background: #3565ED;border-radius: 32rpx;flex: 0 0 auto;font-weight: bold;text-align: center;line-height: 64rpx;
  206. font-size: 26rpx;
  207. color: #FFFFFF;}
  208. }
  209. }
  210. }
  211. .carlists{padding: 0 18rpx;}
  212. </style>