teamUser.vue 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263
  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'
  137. })
  138. },
  139. handleEdit(item){
  140. uni.navigateTo({
  141. url:'/pagesMy/teamUserDetail?id='+item.id
  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 sendList = selectList.map(l=>({realName:l.realName,id:l.id,category:l.category,categoryName:l.categoryName,email:l.email}))
  153. let tempuser = selectList.find(s=>!s.category);
  154. if(tempuser) return this.$showToast(`请为团队人员【${tempuser.realName}】选择身份类型`)
  155. this.getOpenerEventChannel().emit('selectUserConfirm',sendList)
  156. uni.navigateBack()
  157. }
  158. }
  159. }
  160. </script>
  161. <style scoped lang="scss">
  162. ::v-deep .u-swipe-action-item{
  163. margin-top: 20rpx;
  164. }
  165. ::v-deep .swipe-action{
  166. border: none !important;
  167. }
  168. .default_page{
  169. padding: 0 24rpx;
  170. box-sizing: border-box;
  171. .add{
  172. width: calc(100% - 52rpx);
  173. height: 88rpx;
  174. background: #FFFFFF;
  175. border-radius: 44rpx;
  176. border: 1rpx solid #33A7A7;
  177. margin: 30rpx 26rpx 0;
  178. font-family: PingFang-SC, PingFang-SC;
  179. font-weight: bold;
  180. font-size: 32rpx;
  181. color: #009191;
  182. line-height: 88rpx;
  183. text-align: center;
  184. }
  185. .list{
  186. flex: 1;
  187. overflow-y: auto;
  188. margin-top: 20rpx;
  189. .lbox{
  190. background: #FFFFFF;
  191. box-shadow: inset 0rpx -1rpx 0rpx 0rpx rgba(229,231,235,0.5);
  192. border-radius: 24rpx;
  193. padding: 36rpx 24rpx 40rpx;
  194. margin-top: 20rpx;
  195. &-select{
  196. width: 36rpx;
  197. height: 36rpx;
  198. margin-right: 24rpx;
  199. }
  200. &-info{
  201. flex: 1;
  202. &-top{
  203. text{
  204. font-family: PingFang-SC, PingFang-SC;
  205. font-weight: bold;
  206. font-size: 32rpx;
  207. color: #002846;
  208. line-height: 32rpx;
  209. }
  210. .type{
  211. background: #FFF7DC;
  212. border-radius: 21rpx;
  213. padding: 6rpx 16rpx;
  214. font-family: PingFangSC, PingFang SC;
  215. font-weight: 400;
  216. font-size: 22rpx;
  217. color: #BA9B31;
  218. line-height: 30rpx;
  219. margin-left: 20rpx;
  220. image{
  221. width: 24rpx;
  222. height: 24rpx;
  223. margin-left: 12rpx;
  224. }
  225. }
  226. }
  227. &-email{
  228. font-family: PingFangSC, PingFang SC;
  229. font-weight: 400;
  230. font-size: 28rpx;
  231. color: #666666;
  232. line-height: 28rpx;
  233. margin-top: 30rpx;
  234. }
  235. }
  236. &-edit{
  237. width: 30rpx;
  238. height: 30rpx;
  239. }
  240. }
  241. }
  242. .btn{
  243. width: calc(100% - 52rpx);
  244. height: 88rpx;
  245. background: linear-gradient( 90deg, #33A7A7 0%, #64BBBB 100%);
  246. border-radius: 44rpx;
  247. font-family: PingFang-SC, PingFang-SC;
  248. font-weight: bold;
  249. font-size: 32rpx;
  250. color: #FFFFFF;
  251. line-height: 88rpx;
  252. text-align: center;
  253. letter-spacing: 2rpx;
  254. margin: 40rpx 26rpx 54rpx;
  255. }
  256. }
  257. </style>