people.vue 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211
  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. }
  58. },
  59. onUnload() {
  60. uni.$off('residentInfoList')
  61. },
  62. onLoad: function(e) {
  63. uni.$on('residentInfoList',(res)=>{
  64. this.getrefreshData()
  65. })
  66. if(e.id){
  67. this.houseId=e.id;
  68. }
  69. this.init()
  70. this.getDataFn()
  71. },
  72. // 上拉触底加载更多触发事件
  73. onReachBottom() {
  74. if (this.reachflag) {
  75. this.pageNum++
  76. this.getDataFn()
  77. }
  78. },
  79. methods:{
  80. checkPermi, checkRole,
  81. init(){
  82. //人员面貌
  83. getDictionaryFn('affiliation_personnel').then(res=>{
  84. if(res.code==200){
  85. this.rymmList = res.data.map(v => {
  86. return {
  87. dictLabel: v.dictLabel,
  88. dictValue: v.dictValue
  89. }
  90. })
  91. }
  92. })
  93. },
  94. getAddFn(){
  95. this.$tab.navigateTo("/health/pages/health/add")
  96. },
  97. getDetail(id){
  98. this.$tab.navigateTo("/health/pages/health/add?id="+id)
  99. },
  100. getConfirm(){
  101. this.getrefreshData()
  102. },
  103. getReset(){
  104. this.rymm='';
  105. this.text='';
  106. this.getrefreshData()
  107. },
  108. getrefreshData(){
  109. this.pageNum=1;
  110. this.list=[];
  111. this.reachflag=true;
  112. this.getDataFn()
  113. },
  114. getTabFn(val){
  115. this.tabval=val
  116. },
  117. bindDateChangea(e){
  118. var val=e.detail.value;
  119. this.rymm=this.rymmList[val].dictLabel;
  120. this.rymmid=this.rymmList[val].dictValue;
  121. this.getrefreshData()
  122. },
  123. getDelFn(id){
  124. var that=this;
  125. residentInfoDel(id).then(res=>{
  126. if(res.code==200){
  127. that.$toast("删除成功")
  128. setTimeout(function(){
  129. that.getrefreshData()
  130. },1500)
  131. }
  132. })
  133. },
  134. getDataFn(){
  135. var params={
  136. pageSize:this.pageSize,
  137. pageNum: this.pageNum,
  138. }
  139. if(this.houseId){
  140. params.houseId=this.houseId
  141. }
  142. if(this.text){
  143. params.residentName=this.text
  144. }
  145. if(this.rymm){
  146. params.residentAppearance=this.rymmid
  147. }
  148. houseInfoList(params).then(res=>{
  149. if(res.code==200){
  150. if (res.rows.length < this.pageSize) {
  151. this.reachflag = false
  152. this.wtdt = '到底了~';
  153. } else {
  154. var num = parseInt(res.rows.length) + parseInt(this.pageSize) * parseInt(this.pageNum - 1)
  155. if (num < res.total) {
  156. this.reachflag = true
  157. this.wtdt = ''
  158. } else {
  159. this.reachflag = false
  160. this.wtdt = '到底了~';
  161. }
  162. }
  163. var newArr=JSON.parse(JSON.stringify(res.rows))
  164. newArr.forEach(ite=>{
  165. var newArr=ite.residentInfoList;
  166. if(ite.residentInfoList){
  167. newArr.forEach(itea=>{
  168. itea.right=0
  169. })
  170. }
  171. ite.zhanflag=false;
  172. })
  173. if (this.pageNum == 1) {
  174. this.list = newArr;
  175. } else {
  176. this.list = this.list.concat(newArr)
  177. }
  178. }else{
  179. this.$toast(res.msg)
  180. }
  181. })
  182. },
  183. }
  184. }
  185. </script>
  186. <style>
  187. page{background: #F3F3F0;}
  188. </style>
  189. <style lang="scss" scoped>
  190. .car{padding-top: 140rpx;}
  191. .cartop{position: fixed;left: 0;right: 0;top: 0;background-color: #ffffff;z-index: 2;
  192. .topa{padding: 20rpx 20rpx 32rpx;
  193. .resetimg{width: 36rpx;height: 36rpx;margin-right: 24rpx;flex: 0 0 auto;}
  194. .chekt{width: 150rpx;overflow: hidden;
  195. view{font-weight: 500;font-size: 26rpx;color: #272727;flex: 1;}
  196. image{width: 24rpx;height: 16rpx;margin-left: 18rpx;flex: 0 0 auto;}
  197. }
  198. .search{flex: 1;margin-left: 16rpx;height: 64rpx;background: #EEEEEE;border-radius: 32rpx;border: 2rpx solid #E6E6E6;padding-left: 24rpx;box-sizing: border-box;
  199. image{width: 32rpx;height: 34rpx;margin-right: 22rpx;flex: 0 0 auto;}
  200. input{flex: 1;font-size: 26rpx;color: #272727;}
  201. .btn{width: 100rpx;height: 64rpx;background: #3565ED;border-radius: 32rpx;flex: 0 0 auto;font-weight: bold;text-align: center;line-height: 64rpx;
  202. font-size: 26rpx;
  203. color: #FFFFFF;}
  204. }
  205. }
  206. }
  207. .carlists{padding: 0 18rpx;}
  208. </style>