fillTeamInfo.vue 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. <template>
  2. <view class="default_page" :style="{'min-height':h+'px', 'padding-top':mt+'px'}">
  3. <cus-header title='填写所在团队信息'></cus-header>
  4. <cus-team-info-fill ref="teamRef" @handleConfirm="handleConfirm" :confirmText="confirmText" :qtype="qtype"></cus-team-info-fill>
  5. </view>
  6. </template>
  7. <script>
  8. import CusTeamInfoFill from '@/components/CusTeamInfoFill/index.vue'
  9. export default {
  10. components:{ CusTeamInfoFill },
  11. data(){
  12. return {
  13. title:'',
  14. type:'',
  15. next:'',
  16. questionnaireId:'',
  17. confirmText:'下一步',
  18. qtype:''
  19. }
  20. },
  21. onLoad(options) {
  22. this.title = options.title||'';
  23. this.type = options.type;
  24. this.qtype = options.qtype||'';
  25. this.questionnaireId = options.questionnaireId||'';
  26. this.confirmText = options.type?'确定':'下一步';
  27. this.next = options.next;
  28. if(this.next) this.confirmText = '下一步';
  29. },
  30. methods:{
  31. async handleConfirm(team){
  32. team.questionnaireId = this.questionnaireId;
  33. try {
  34. const { data:res } = await this.$api.post('/core/user/team',team)
  35. if(res.code!==0) return this.$showToast(res.msg)
  36. const teamId = res.data && res.data.teamId
  37. if(!teamId) return this.$showToast('团队保存失败,请重试')
  38. const uploadResult = await this.$refs.teamRef.flushBackgroundFiles(teamId)
  39. if(uploadResult.failed > 0){
  40. await this.$showModal(`${uploadResult.failed}个背景资料上传失败,可重试后继续`)
  41. }
  42. if(this.$refs.teamRef.hasDeferredPcUpload()){
  43. await this.$refs.teamRef.waitForDeferredPcUpload(teamId)
  44. }
  45. await this.continueAfterTeamCreated(teamId)
  46. } catch(error) {
  47. this.$showToast(error && (error.message || error.msg) || '团队保存失败,请重试')
  48. }
  49. },
  50. async continueAfterTeamCreated(teamId) {
  51. if(this.next){
  52. const response = await this.$api.post('/core/team/questionnaire/publish',{
  53. answerSetting:1,
  54. coachId:JSON.parse(uni.getStorageSync('userInfo')).id,
  55. startTime:new Date().Format('yyyy-MM-dd hh:mm:ss'),
  56. endTime:new Date(new Date().setDate(new Date().getDate()+30)).Format('yyyy-MM-dd hh:mm:ss'),
  57. questionnaireId:this.questionnaireId,
  58. teamId,
  59. type:1
  60. })
  61. const result = response.data
  62. if(result.code!==0) return this.$showToast(result.msg)
  63. this.$showToast('保存成功,即将填写问卷')
  64. setTimeout(()=>{
  65. uni.removeStorageSync('newUser')
  66. uni.navigateTo({
  67. url:`/pagesPublish/questionnaireFill?teamQuestionnaireId=${result.data}&teamId=${teamId}&type=${this.type}&title=${this.title}`
  68. })
  69. },1500)
  70. return
  71. }
  72. this.$showToast('团队新增成功')
  73. setTimeout(()=>{
  74. this.getOpenerEventChannel().emit('saveTeamInfo')
  75. uni.navigateBack()
  76. },1500)
  77. }
  78. }
  79. }
  80. </script>
  81. <style scoped lang="scss">
  82. .default_page{
  83. box-sizing: border-box;
  84. }
  85. </style>