comegl.vue 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245
  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 mode="date" @change='bindDateChangea'>
  7. <view class="chekt flexc">
  8. <view>{{xzrq|| "来访日期"}}</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. <car-list :datainfo="list" :tabval="tabval" :visitorType="visitorType" :wtdt="wtdt" type='comepeo' @getDelFn="getDelFn" @getDetail="getDetail"></car-list>
  26. </view>
  27. <block v-if="checkPermi(['wuYe:visitorManage: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 carList from "@/people/components/car/list.vue"
  38. import { checkPermi, checkRole } from "@/utils/permission"; // 权限判断函数
  39. import {getDictionaryFn} from "@/api/system/user.js"
  40. import {visitorList,reservList,reservDel,visitorDel} from "@/api/work/people.js"
  41. export default{
  42. components:{carList},
  43. data(){
  44. return{
  45. reset:require('@/car/static/car/reset.png'),
  46. search:require('@/car/static/car/search.png'),
  47. up:require('@/car/static/car/up.png'),
  48. xzrq:"",
  49. text:'',
  50. list:[],
  51. pageSize: 10,
  52. pageNum: 1,
  53. reachflag: true,
  54. wtdt:'',
  55. tabval:'1',
  56. tablist:[{tit:'预约来访',val:1},{tit:'临时来访',val:2},],
  57. visitorType:[],//访客状态
  58. }
  59. },
  60. onUnload() {
  61. uni.$off('refComelist')
  62. },
  63. onLoad: function() {
  64. uni.$on('refComelist',(res)=>{
  65. this.getrefreshData()
  66. })
  67. this.init()
  68. this.getDataFn()
  69. },
  70. // 上拉触底加载更多触发事件
  71. onReachBottom() {
  72. if (this.reachflag) {
  73. this.pageNum++
  74. this.getDataFn()
  75. }
  76. },
  77. methods:{
  78. checkPermi, checkRole,
  79. init(){
  80. },
  81. getAddFn(){
  82. this.$tab.navigateTo("/people/pages/people/comeadd?type="+this.tabval)
  83. },
  84. getDetail(ite){
  85. var id='';
  86. if(this.tabval==1){
  87. id=ite.reservRecordId
  88. }else{
  89. id=ite.visitorManageId
  90. }
  91. this.$tab.navigateTo("/people/pages/people/comeadd?type="+this.tabval+'&id='+id)
  92. },
  93. getConfirm(){
  94. this.getrefreshData()
  95. },
  96. getReset(){
  97. this.xzrq='';
  98. this.text='';
  99. this.getrefreshData()
  100. },
  101. getrefreshData(){
  102. this.pageNum=1;
  103. this.list=[];
  104. this.reachflag=true;
  105. this.getDataFn()
  106. },
  107. getTabFn(val){
  108. this.tabval=val;
  109. this.getrefreshData()
  110. },
  111. bindDateChangea(e){
  112. var val=e.detail.value;
  113. this.xzrq=val;
  114. this.getrefreshData()
  115. },
  116. getDelFn(ite){
  117. var that=this;
  118. var id='';
  119. if(this.tabval==1){
  120. id=ite.reservRecordId
  121. }else{
  122. id=ite.visitorManageId
  123. }
  124. if(this.tabval==1){
  125. reservDel(id).then(res=>{
  126. if(res.code==200){
  127. that.$toast("删除成功")
  128. setTimeout(function(){
  129. that.getrefreshData()
  130. },1500)
  131. }
  132. })
  133. }else{
  134. visitorDel(id).then(res=>{
  135. if(res.code==200){
  136. that.$toast("删除成功")
  137. setTimeout(function(){
  138. that.getrefreshData()
  139. },1500)
  140. }
  141. })
  142. }
  143. },
  144. getDataFn(){
  145. var params={
  146. pageSize:this.pageSize,
  147. pageNum: this.pageNum,
  148. }
  149. if(this.text){
  150. params.houseAddress=this.tabval
  151. }
  152. if(this.xzrq){
  153. params.visitorTime=this.xzrq
  154. }
  155. if(this.tabval==1){
  156. reservList(params).then(res=>{
  157. if(res.code==200){
  158. if (res.rows.length < this.pageSize) {
  159. this.reachflag = false
  160. this.wtdt = '到底了~';
  161. } else {
  162. var num = parseInt(res.rows.length) + parseInt(this.pageSize) * parseInt(this.pageNum - 1)
  163. if (num < res.total) {
  164. this.reachflag = true
  165. this.wtdt = ''
  166. } else {
  167. this.reachflag = false
  168. this.wtdt = '到底了~';
  169. }
  170. }
  171. var newArr=JSON.parse(JSON.stringify(res.rows))
  172. newArr.forEach(ite=>{
  173. ite.right=0;
  174. })
  175. if (this.pageNum == 1) {
  176. this.list = newArr;
  177. } else {
  178. this.list = this.list.concat(newArr)
  179. }
  180. }else{
  181. this.$toast(res.msg)
  182. }
  183. })
  184. }else{
  185. visitorList(params).then(res=>{
  186. if(res.code==200){
  187. if (res.rows.length < this.pageSize) {
  188. this.reachflag = false
  189. this.wtdt = '到底了~';
  190. } else {
  191. var num = parseInt(res.rows.length) + parseInt(this.pageSize) * parseInt(this.pageNum - 1)
  192. if (num < res.total) {
  193. this.reachflag = true
  194. this.wtdt = ''
  195. } else {
  196. this.reachflag = false
  197. this.wtdt = '到底了~';
  198. }
  199. }
  200. if (this.pageNum == 1) {
  201. this.list = res.rows;
  202. } else {
  203. this.list = this.list.concat(res.rows)
  204. }
  205. }else{
  206. this.$toast(res.msg)
  207. }
  208. })
  209. }
  210. },
  211. }
  212. }
  213. </script>
  214. <style>
  215. page{background: #F3F3F0;}
  216. </style>
  217. <style lang="scss" scoped>
  218. .car{padding: 224rpx 0 10rpx;}
  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{min-width: 180rpx;
  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. .tabtop{padding-bottom: 40rpx;
  235. .tabt{font-weight: 500;font-size: 32rpx;color: #666666;position: relative;line-height: 56rpx;padding: 0 40rpx;margin-right: 6rpx;
  236. &.act{font-weight: bold;font-size: 32rpx;color: #272727;
  237. &::after{content: '';width: 40rpx;height: 10rpx;background: #0156FE;border-radius: 6rpx;position: absolute;left: 50%;margin-left: -20rpx;bottom: -10rpx;}
  238. }
  239. }
  240. }
  241. }
  242. .carlists{padding: 0 18rpx;}
  243. </style>