teamUser.vue 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279
  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.emailTM}}</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. eventChannel: null,
  75. }
  76. },
  77. onShow() {
  78. const eventChannel = this.getOpenerEventChannel();
  79. if (Object.keys(eventChannel).length) { // 简单判断eventChannel是否有效
  80. this.eventChannel = eventChannel;
  81. }
  82. let pages = getCurrentPages();
  83. let options = pages[pages.length-1].options;
  84. this.type = options.type||'';
  85. this.query.coachId = uni.getStorageSync('userInfo')&&JSON.parse(uni.getStorageSync('userInfo')).id||''
  86. this.query.page = 1;
  87. this.isOver = false;
  88. this.list = [];
  89. this.getList()
  90. },
  91. methods:{
  92. scrolltolower(){
  93. if(this.isOver) return
  94. this.getList()
  95. },
  96. getList(){
  97. this.$api.get('/core/member/page',this.query).then(({data:res})=>{
  98. if(res.code!==0) return this.$showToast(res.msg)
  99. this.list = [...this.list,...res.data.list]
  100. this.list.forEach((l,i)=>{
  101. l.emailTM = this.$reg.desensitizeContent(l.email);
  102. this.$set(this.list[i],'category','');
  103. this.$set(this.list[i],'categoryName','');
  104. this.$set(this.list[i],'select',false);
  105. })
  106. this.query.page++
  107. if(this.length>=res.data.total) this.isOver = true
  108. })
  109. },
  110. getCategoryData(){
  111. this.$api.get('/getListByType/UserCategory').then(({data:res})=>{
  112. if(res.code!==0) return this.$showToast(res.msg)
  113. this.categoryData = res.data.map(d=>({name:d.dictLabel,id:d.dictValue}))
  114. this.show = true;
  115. })
  116. },
  117. selectUser(item,index){
  118. this.$set(this.list[index],'select',!this.list[index].select);
  119. },
  120. selectUserCategory(item,index){
  121. this.currentUser = item;
  122. this.currentIndex = index;
  123. this.getCategoryData()
  124. },
  125. deleteUser(item,index){
  126. uni.showModal({
  127. title:'温馨提示',
  128. content:`是否确认删除团队成员【${item.realName}】?`,
  129. success: (res) => {
  130. if(res.confirm){
  131. this.$api.del('/core/member',[item.id]).then(({data:res})=>{
  132. if(res.code!==0) return this.$showToast(res.msg)
  133. this.query.page = 1;
  134. this.list = [];
  135. this.isOver = false;
  136. this.getList()
  137. })
  138. this.list.forEach((d, i) => {
  139. this.$refs['swipeAction' + i][0].closeHandler();
  140. })
  141. }
  142. }
  143. })
  144. },
  145. handleAdd(){
  146. uni.navigateTo({
  147. url:'/pagesMy/teamUserDetail?type='+this.type
  148. })
  149. },
  150. handleEdit(item){
  151. uni.navigateTo({
  152. url:'/pagesMy/teamUserDetail?id='+item.id+'&type='+this.type
  153. })
  154. },
  155. selectConfirm(e){
  156. this.$set(this.list[this.currentIndex],'category',e.id);
  157. this.$set(this.list[this.currentIndex],'categoryName',e.name);
  158. this.show = false;
  159. },
  160. handleConfirmAdd(){
  161. let selectList = this.list.filter(l=>l.select);
  162. if(selectList.length===0) return this.$showToast('请至少选择一位团队成员')
  163. let tempuser = selectList.find(s=>!s.category);
  164. if(tempuser) return this.$showToast(`请为团队人员【${tempuser.realName}】选择身份类型`)
  165. if (this.eventChannel) {
  166. this.eventChannel.emit('selectUserConfirm', selectList);
  167. uni.navigateBack();
  168. }else {
  169. uni.navigateBack();
  170. }
  171. }
  172. }
  173. }
  174. </script>
  175. <style scoped lang="scss">
  176. ::v-deep .u-swipe-action-item{
  177. margin-top: 20rpx;
  178. background: transparent !important;
  179. }
  180. ::v-deep .swipe-action{
  181. border: none !important;
  182. }
  183. .default_page{
  184. padding: 0 24rpx;
  185. box-sizing: border-box;
  186. .add{
  187. width: calc(100% - 52rpx);
  188. height: 88rpx;
  189. background: #FFFFFF;
  190. border-radius: 44rpx;
  191. border: 1rpx solid #33A7A7;
  192. margin: 30rpx 26rpx 0;
  193. font-family: PingFang-SC, PingFang-SC;
  194. font-weight: bold;
  195. font-size: 32rpx;
  196. color: #009191;
  197. line-height: 88rpx;
  198. text-align: center;
  199. }
  200. .list{
  201. flex: 1;
  202. overflow-y: auto;
  203. // margin-top: 20rpx;
  204. .lbox{
  205. background: #FFFFFF;
  206. box-shadow: inset 0rpx -1rpx 0rpx 0rpx rgba(229,231,235,0.5);
  207. border-radius: 24rpx;
  208. padding: 36rpx 24rpx 40rpx;
  209. // margin-top: 20rpx;
  210. &-select{
  211. width: 36rpx;
  212. height: 36rpx;
  213. margin-right: 24rpx;
  214. }
  215. &-info{
  216. flex: 1;
  217. &-top{
  218. text{
  219. font-family: PingFang-SC, PingFang-SC;
  220. font-weight: bold;
  221. font-size: 32rpx;
  222. color: #002846;
  223. line-height: 32rpx;
  224. }
  225. .type{
  226. background: #FFF7DC;
  227. border-radius: 21rpx;
  228. padding: 6rpx 16rpx;
  229. font-family: PingFangSC, PingFang SC;
  230. font-weight: 400;
  231. font-size: 22rpx;
  232. color: #BA9B31;
  233. line-height: 30rpx;
  234. margin-left: 20rpx;
  235. image{
  236. width: 24rpx;
  237. height: 24rpx;
  238. margin-left: 12rpx;
  239. }
  240. }
  241. }
  242. &-email{
  243. font-family: PingFangSC, PingFang SC;
  244. font-weight: 400;
  245. font-size: 28rpx;
  246. color: #667E90;
  247. line-height: 28rpx;
  248. margin-top: 30rpx;
  249. }
  250. }
  251. &-edit{
  252. width: 30rpx;
  253. height: 30rpx;
  254. }
  255. }
  256. }
  257. .btn{
  258. width: calc(100% - 52rpx);
  259. height: 88rpx;
  260. background: linear-gradient( 90deg, #33A7A7 0%, #64BBBB 100%);
  261. border-radius: 44rpx;
  262. font-family: PingFang-SC, PingFang-SC;
  263. font-weight: bold;
  264. font-size: 32rpx;
  265. color: #FFFFFF;
  266. line-height: 88rpx;
  267. text-align: center;
  268. letter-spacing: 2rpx;
  269. margin: 40rpx 26rpx 54rpx;
  270. }
  271. }
  272. </style>