teamUser.vue 8.5 KB

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