teamUser.vue 7.7 KB

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