teamUser.vue 8.4 KB

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