teamUser.vue 8.5 KB

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