personnel.vue 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165
  1. <template>
  2. <view class="page-body flex flex_column">
  3. <swiper class="scroll-list" :current="swiperCurrent">
  4. <swiper-item class="swiper-item" style="height: 100%;width: 100%;overflow: hidden;">
  5. <scroll-view scroll-y style="height: 100%;width: 100%;overflow: auto;" @scrolltolower="onreachBottom">
  6. <view style="height: 20rpx;" ></view>
  7. <view
  8. class="check-order-list"
  9. v-for="(item,index) in list"
  10. :key="item.id"
  11. >
  12. <view class="flex align_center justify_between" @click="editPerson(item)">
  13. <view class="flex_1">
  14. <view class="u-name">
  15. <text style="margin-right: 0.5rem;">{{item.name}}</text>
  16. <u-icon :name="item.sex==1?'man':'woman'" size="28" :color="item.sex==1?'#00aaff':'#ffaaaa'"></u-icon>
  17. </view>
  18. <view class="u-mobile">
  19. <text v-if="item.isManager == 1">门店负责人 / </text>
  20. <text v-if="item.isManager == 0 && item.roleNames">{{item.roleNames}} / </text>
  21. {{item.mobile}}
  22. </view>
  23. </view>
  24. <view>
  25. <u-icon size="34" name="edit-pen"></u-icon>
  26. </view>
  27. </view>
  28. </view>
  29. <view style="padding:0 30upx 30upx;">
  30. <u-empty :src="`/static/nodata.png`" icon-size="180" :text="noDataText" img-width="120" v-if="list.length==0 && status!='loading'" mode="list"></u-empty>
  31. <u-loadmore v-if="(total>=list.length&&list.length)||status=='loading'" :status="status" />
  32. </view>
  33. </scroll-view>
  34. </swiper-item>
  35. </swiper>
  36. <view class="footer flex align_center justify_center">
  37. <u-button @click="editIsManage()" v-if="userInfo&&userInfo.superAdmin==1&&!hasOnlyAdmin" :throttle-time="100" shape="circle" type="error" plain>
  38. 更换负责人
  39. </u-button>
  40. <u-button @click="editPerson(null)" :throttle-time="100" :custom-style="{ background: '#066cff', color: '#fff' }" shape="circle" type="info">
  41. 新增员工
  42. </u-button>
  43. </view>
  44. </view>
  45. </template>
  46. <script>
  47. import {searchEmployee, delEmployee } from '@/api/employee'
  48. import moment from 'moment'
  49. export default{
  50. name:'personnel',
  51. data(){
  52. return{
  53. status: 'loading',
  54. noDataText: '暂无数据',
  55. current: 0,
  56. swiperCurrent: 0,
  57. // 查询条件
  58. pageNo: 1,
  59. pageSize: 20,
  60. list: [],
  61. total: 0,
  62. }
  63. },
  64. onShow() {
  65. this.getRow(1)
  66. },
  67. computed:{
  68. userInfo(){
  69. return this.$store.state.vuex_userInfo
  70. },
  71. hasOnlyAdmin(){
  72. return this.list.length ==1 && this.list[0].isManager == 1 || this.list.length == 0
  73. }
  74. },
  75. methods:{
  76. // 查询列表
  77. getRow (pageNo) {
  78. let _this = this
  79. if (pageNo) {
  80. this.pageNo = pageNo
  81. }
  82. let params = {
  83. pageNo:this.pageNo,
  84. pageSize:this.pageSize
  85. }
  86. this.status = "loading"
  87. searchEmployee(params).then(res => {
  88. if (res.code == 200 || res.status == 204 || res.status == 200) {
  89. if(_this.pageNo>1){
  90. _this.list = _this.list.concat(res.data.list || [])
  91. }else{
  92. _this.list = res.data.list || []
  93. }
  94. _this.total = res.data.count || 0
  95. } else {
  96. _this.list = []
  97. _this.total = 0
  98. _this.noDataText = res.message
  99. }
  100. _this.status = _this.total>=_this.list.length ? "nomore" : 'loadmore'
  101. })
  102. },
  103. // scroll-view到底部加载更多
  104. onreachBottom() {
  105. if(this.list.length < this.total){
  106. this.pageNo += 1
  107. this.getRow()
  108. }else{
  109. this.status = "nomore"
  110. }
  111. },
  112. // 编辑员工
  113. editPerson(row){
  114. this.$store.state.vuex_nowStaffData = row;
  115. uni.navigateTo({
  116. url: "/pages/storeManage/addPerson"
  117. })
  118. },
  119. // 更换负责人
  120. editIsManage(){
  121. const row = this.list.find(item=>item.isManager == 1)
  122. uni.navigateTo({
  123. url: "/pages/storeManage/editIsManage?adminId="+row.id
  124. })
  125. }
  126. }
  127. }
  128. </script>
  129. <style lang="less">
  130. .page-body{
  131. height: 100vh;
  132. padding:0;
  133. .scroll-list{
  134. flex-grow: 1;
  135. .check-order-list{
  136. background: #ffffff;
  137. padding: 10upx 20upx;
  138. margin: 0 25rpx 25rpx 25rpx;
  139. border-radius: 20upx;
  140. box-shadow: 1px 1px 3px #EEEEEE;
  141. > view{
  142. padding: 0.8rem 0.5rem;
  143. .u-name{
  144. font-size: 32rpx;
  145. margin-bottom: 0.5rem;
  146. }
  147. .u-mobile{
  148. color: #666;
  149. }
  150. }
  151. }
  152. }
  153. .footer{
  154. padding: 0.6rem;
  155. background: #ffffff;
  156. u-button{
  157. width: 45%;
  158. margin: 0 2%;
  159. }
  160. }
  161. }
  162. </style>