teamEdit.vue 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160
  1. <template>
  2. <view class="default_page" :style="{'min-height':h+'px', 'padding-top':mt+'px'}">
  3. <cus-header title='编辑团队' :interceptBack="true" @back="requestBack"></cus-header>
  4. <cus-team-info-fill ref="teamRef" :teamId="id" :submitting="saving" @handleConfirm="handleConfirm" :confirmText="confirmText"></cus-team-info-fill>
  5. <view class="dialog adffcacjc" v-if="show">
  6. <view class="dbox">
  7. <view class="dbox-title">温馨提示</view>
  8. <view class="dbox-content">本次团队配置修改将在本团队<span>所有激活状态下的PERILL团队发展动态评估问卷中</span>生效,确定提交吗?</view>
  9. <view class="dbox-btns adfacjb">
  10. <view class="zt_btn" @click="editConfirm">确定</view>
  11. <view class="qx_btn" @click="show=false">取消</view>
  12. </view>
  13. </view>
  14. </view>
  15. </view>
  16. </template>
  17. <script>
  18. import CusTeamInfoFill from '@/components/CusTeamInfoFill/index.vue'
  19. export default {
  20. components:{ CusTeamInfoFill },
  21. data(){
  22. return {
  23. id:'',
  24. teamInfo:null,
  25. confirmText:'确定',
  26. scaleName:'',
  27. hierarchyName:'',
  28. submitDto:null,
  29. show:false,
  30. saving:false
  31. }
  32. },
  33. onLoad(options) {
  34. this.id = options.id;
  35. this.scaleName = options.scaleName;
  36. this.hierarchyName = options.hierarchyName;
  37. this.getDetail()
  38. },
  39. onShow() {
  40. if (!this.id) return
  41. this.$nextTick(() => {
  42. const background = this.$refs.teamRef && this.$refs.teamRef.$refs.backgroundRef
  43. if (background) background.refreshFiles(this.id).catch(error => {
  44. this.$showToast(error && (error.message || error.msg) || '资料列表刷新失败')
  45. })
  46. })
  47. },
  48. methods:{
  49. hasPendingBackgroundFiles(){
  50. const team = this.$refs.teamRef
  51. return Boolean(team && (team.hasUnresolvedBackgroundFiles()
  52. || team.isBackgroundUploadActive()))
  53. },
  54. requestBack(){
  55. if(this.saving) return this.$showToast('团队正在保存,请稍候')
  56. if(!this.hasPendingBackgroundFiles()) return uni.navigateBack()
  57. uni.showModal({
  58. title:'背景资料尚未完成',
  59. content:'仍有背景资料正在上传或等待重试,返回将丢弃待处理队列;已发出的上传可能仍会完成。确定返回吗?',
  60. confirmText:'仍然返回',
  61. confirmColor:'#FD4F66',
  62. success: result => {
  63. if(result.confirm) uni.navigateBack()
  64. }
  65. })
  66. },
  67. getDetail(){
  68. this.$api.get(`/core/user/team/${this.id}`).then(({data:res})=>{
  69. if(res.code!==0) return this.$showToast(res.msg)
  70. this.teamInfo = res.data;
  71. this.$refs.teamRef.setTeamInfo(res.data)
  72. this.$refs.teamRef.teamInfo.functionIds = res.data.functions.map(f=>f.id);
  73. this.$refs.teamRef.teamInfo.orgIds = res.data.organizations.map(o=>o.id);
  74. this.$refs.teamRef.areaText = res.data.provinceName+res.data.cityName;
  75. this.$refs.teamRef.industryText = res.data.industryName;
  76. this.$refs.teamRef.functionTypeText = res.data.functions.map(f=>f.functionName).join('、');
  77. this.$refs.teamRef.architectureTypeText = res.data.organizations.map(f=>f.orgName).join('、');
  78. this.$refs.teamRef.teamScaleText = this.scaleName;
  79. this.$refs.teamRef.teamLevelText = this.hierarchyName;
  80. })
  81. },
  82. handleConfirm(data){
  83. this.submitDto = data;
  84. this.show = true;
  85. },
  86. async editConfirm(){
  87. if(this.saving) return
  88. this.saving = true
  89. try {
  90. const { data:res } = await this.$api.put('/core/user/team',this.submitDto)
  91. if(res.code!==0){
  92. this.$showToast(res.msg)
  93. return
  94. }
  95. this.show = false
  96. this.$showToast('编辑成功')
  97. setTimeout(()=>{
  98. uni.redirectTo({
  99. url:'/pagesMy/team'
  100. })
  101. },1500)
  102. } catch(error) {
  103. this.$showToast(error && (error.message || error.msg) || '团队编辑失败,请重试')
  104. } finally {
  105. this.saving = false
  106. }
  107. }
  108. }
  109. }
  110. </script>
  111. <style scoped lang="scss">
  112. .default_page{
  113. box-sizing: border-box;
  114. }
  115. .dialog{
  116. position: fixed;
  117. left: 0;
  118. right: 0;
  119. top: 0;
  120. bottom: 0;
  121. background: rgba(0, 0, 0, .4);
  122. z-index: 1000;
  123. .dbox{
  124. width: calc(100% - 150rpx);
  125. background: #FFFFFF;
  126. border-radius: 32rpx;
  127. padding: 48rpx 30rpx;
  128. box-sizing: border-box;
  129. &-title{
  130. font-family: PingFang-SC, PingFang-SC;
  131. font-weight: bold;
  132. font-size: 34rpx;
  133. color: #002846;
  134. line-height: 48rpx;
  135. text-align: center;
  136. }
  137. &-content{
  138. padding: 0 14rpx;
  139. font-family: PingFangSC, PingFang SC;
  140. font-weight: 400;
  141. font-size: 32rpx;
  142. color: #002846;
  143. line-height: 54rpx;
  144. text-align: center;
  145. margin-top: 30rpx;
  146. span{
  147. font-weight: bold;
  148. }
  149. }
  150. &-btns{
  151. margin-top: 56rpx;
  152. &>view{
  153. width: calc(50% - 20rpx);
  154. }
  155. }
  156. }
  157. }
  158. </style>