people.vue 6.7 KB

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