teamUser.vue 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262
  1. <template>
  2. <view class="default_page adffc" :style="{'min-height':h+'px', 'padding-top':mt+'px'}">
  3. <cus-header title='团队成员'></cus-header>
  4. <view class="add" @click="handleAdd">+ 添加</view>
  5. <view class="list" v-if="list.length">
  6. <u-swipe-action>
  7. <u-swipe-action-item v-for="(item, index) in list" :key="index"
  8. :options="options" @click="e=>deleteUser(item,e)" :ref="'swipeAction' + index" :threshold="5"
  9. >
  10. <view class="swipe-action u-border-top u-border-bottom">
  11. <view class="swipe-action__content">
  12. <view class="lbox adfac" @click.prevent="selectUser(item,index)">
  13. <template v-if="type">
  14. <image class="lbox-select" v-if="item.select" :src="imgBase+'selected.png'"></image>
  15. <image class="lbox-select" v-else :src="imgBase+'not_select.png'"></image>
  16. </template>
  17. <view class="lbox-info">
  18. <view class="lbox-info-top adfac">
  19. <text>{{item.realName}}</text>
  20. <template v-if="type">
  21. <view class="type adfac" @click.stop="selectUserCategory(item,index)">
  22. {{item.categoryName||'选择身份类型'}}
  23. <image :src="imgBase+'icon_user_down.png'"></image>
  24. </view>
  25. </template>
  26. </view>
  27. <view class="lbox-info-email">{{item.email}}</view>
  28. </view>
  29. <view class="lbox-edit" @click.stop="handleEdit(item)">
  30. <u-icon name="edit-pen" size="42rpx" color="#B9B9B9"></u-icon>
  31. </view>
  32. </view>
  33. </view>
  34. </view>
  35. </u-swipe-action-item>
  36. </u-swipe-action>
  37. </view>
  38. <view v-else class="adffcacjc" style="flex: 1;">
  39. <empty text='暂无团队人员,请添加'></empty>
  40. </view>
  41. <view class="btn" v-if="type" @click="handleConfirmAdd">确定</view>
  42. <cus-select :show="show" title="选择身份类型" :list="categoryData" @close="show=false" @confirmTeam="selectConfirm"></cus-select>
  43. </view>
  44. </template>
  45. <script>
  46. import empty from '@/components/pageEmpty/index.vue'
  47. import CusSelect from '@/components/CusSelect/index.vue'
  48. export default {
  49. components:{ empty, CusSelect },
  50. data(){
  51. return {
  52. type:'',
  53. query:{
  54. page:1,
  55. limit:10,
  56. coachId:''
  57. },
  58. isOver:false,
  59. list:[],
  60. options: [
  61. {
  62. text: '删除',
  63. icon: 'trash',
  64. iconSize:'32rpx',
  65. style: {
  66. backgroundColor: '#f56c6c'
  67. }
  68. }
  69. ],
  70. show:false,
  71. categoryData:[],
  72. currentUser:null,
  73. currentIndex:'',
  74. }
  75. },
  76. onLoad(options) {
  77. this.type = options.type||'';
  78. this.query.coachId = uni.getStorageSync('userInfo')&&JSON.parse(uni.getStorageSync('userInfo')).id||''
  79. this.getList()
  80. },
  81. methods:{
  82. scrolltolower(){
  83. if(this.isOver) return
  84. this.getList()
  85. },
  86. getList(){
  87. this.$api.get('/core/member/page',this.query).then(({data:res})=>{
  88. if(res.code!==0) return this.$showToast(res.msg)
  89. this.list = [...this.list,...res.data.list]
  90. this.list.forEach((l,i)=>{
  91. this.$set(this.list[i],'category','');
  92. this.$set(this.list[i],'categoryName','');
  93. this.$set(this.list[i],'select',false);
  94. })
  95. this.query.page++
  96. if(this.length>=res.data.total) this.isOver = true
  97. })
  98. },
  99. getCategoryData(){
  100. this.$api.get('/getListByType/UserCategory').then(({data:res})=>{
  101. if(res.code!==0) return this.$showToast(res.msg)
  102. this.categoryData = res.data.map(d=>({name:d.dictLabel,id:d.dictValue}))
  103. this.show = true;
  104. })
  105. },
  106. selectUser(item,index){
  107. this.$set(this.list[index],'select',!this.list[index].select);
  108. },
  109. selectUserCategory(item,index){
  110. this.currentUser = item;
  111. this.currentIndex = index;
  112. this.getCategoryData()
  113. },
  114. deleteUser(item,index){
  115. uni.showModal({
  116. title:'温馨提示',
  117. content:`是否确认删除团队成员【${item.realName}】?`,
  118. success: (res) => {
  119. if(res.confirm){
  120. this.$api.del('/core/member',[item.id]).then(({data:res})=>{
  121. if(res.code!==0) return this.$showToast(res.msg)
  122. this.query.page = 1;
  123. this.list = [];
  124. this.isOver = false;
  125. this.getList()
  126. })
  127. this.list.forEach((d, i) => {
  128. this.$refs['swipeAction' + i][0].closeHandler();
  129. })
  130. }
  131. }
  132. })
  133. },
  134. handleAdd(){
  135. uni.navigateTo({
  136. url:'/pagesMy/teamUserDetail?type='+this.type
  137. })
  138. },
  139. handleEdit(item){
  140. uni.navigateTo({
  141. url:'/pagesMy/teamUserDetail?id='+item.id+'&type='+this.type
  142. })
  143. },
  144. selectConfirm(e){
  145. this.$set(this.list[this.currentIndex],'category',e.id);
  146. this.$set(this.list[this.currentIndex],'categoryName',e.name);
  147. this.show = false;
  148. },
  149. handleConfirmAdd(){
  150. let selectList = this.list.filter(l=>l.select);
  151. if(selectList.length===0) return this.$showToast('请至少选择一位团队成员')
  152. let tempuser = selectList.find(s=>!s.category);
  153. if(tempuser) return this.$showToast(`请为团队人员【${tempuser.realName}】选择身份类型`)
  154. this.getOpenerEventChannel().emit('selectUserConfirm',selectList)
  155. uni.navigateBack()
  156. }
  157. }
  158. }
  159. </script>
  160. <style scoped lang="scss">
  161. ::v-deep .u-swipe-action-item{
  162. margin-top: 20rpx;
  163. }
  164. ::v-deep .swipe-action{
  165. border: none !important;
  166. }
  167. .default_page{
  168. padding: 0 24rpx;
  169. box-sizing: border-box;
  170. .add{
  171. width: calc(100% - 52rpx);
  172. height: 88rpx;
  173. background: #FFFFFF;
  174. border-radius: 44rpx;
  175. border: 1rpx solid #33A7A7;
  176. margin: 30rpx 26rpx 0;
  177. font-family: PingFang-SC, PingFang-SC;
  178. font-weight: bold;
  179. font-size: 32rpx;
  180. color: #009191;
  181. line-height: 88rpx;
  182. text-align: center;
  183. }
  184. .list{
  185. flex: 1;
  186. overflow-y: auto;
  187. margin-top: 20rpx;
  188. .lbox{
  189. background: #FFFFFF;
  190. box-shadow: inset 0rpx -1rpx 0rpx 0rpx rgba(229,231,235,0.5);
  191. border-radius: 24rpx;
  192. padding: 36rpx 24rpx 40rpx;
  193. margin-top: 20rpx;
  194. &-select{
  195. width: 36rpx;
  196. height: 36rpx;
  197. margin-right: 24rpx;
  198. }
  199. &-info{
  200. flex: 1;
  201. &-top{
  202. text{
  203. font-family: PingFang-SC, PingFang-SC;
  204. font-weight: bold;
  205. font-size: 32rpx;
  206. color: #002846;
  207. line-height: 32rpx;
  208. }
  209. .type{
  210. background: #FFF7DC;
  211. border-radius: 21rpx;
  212. padding: 6rpx 16rpx;
  213. font-family: PingFangSC, PingFang SC;
  214. font-weight: 400;
  215. font-size: 22rpx;
  216. color: #BA9B31;
  217. line-height: 30rpx;
  218. margin-left: 20rpx;
  219. image{
  220. width: 24rpx;
  221. height: 24rpx;
  222. margin-left: 12rpx;
  223. }
  224. }
  225. }
  226. &-email{
  227. font-family: PingFangSC, PingFang SC;
  228. font-weight: 400;
  229. font-size: 28rpx;
  230. color: #666666;
  231. line-height: 28rpx;
  232. margin-top: 30rpx;
  233. }
  234. }
  235. &-edit{
  236. width: 30rpx;
  237. height: 30rpx;
  238. }
  239. }
  240. }
  241. .btn{
  242. width: calc(100% - 52rpx);
  243. height: 88rpx;
  244. background: linear-gradient( 90deg, #33A7A7 0%, #64BBBB 100%);
  245. border-radius: 44rpx;
  246. font-family: PingFang-SC, PingFang-SC;
  247. font-weight: bold;
  248. font-size: 32rpx;
  249. color: #FFFFFF;
  250. line-height: 88rpx;
  251. text-align: center;
  252. letter-spacing: 2rpx;
  253. margin: 40rpx 26rpx 54rpx;
  254. }
  255. }
  256. </style>