<template>
  <div>
    <div v-if="Object.keys(detailData).length" class="growth">
      <div class="growth_heads">
        <div class="growth_left">
          <div class="left_text">我的成长路径</div>
            <el-popover
              placement="right"
              width="437"
              trigger="click"
              :visible-arrow="false"
              v-model="explainBody"
              popper-class="growth_explain"
             >
              <div slot="reference" class="growth_i">
                <div class="growth_mark">?</div>
              </div>
              <div class="growth_explain1">
                <div class="growth_explain_text">
                  <div class="text">根据您的归属组织、您所在岗位、职级，已为您自动匹配“{{detailData.growName || ''}}”，抓紧时间学习吧～</div>
                  <div class="explain_close"  @click="explainBody = false"></div>
                </div>
              </div>
            </el-popover>
        </div>
        <div class="growth_right">
          <div class="right_text">什么是成长路径</div>
          <div class="growth_img" @click="checkedTrue">
            <img class="img" src="../../assets/images/growth/mark.png" alt="">
          </div>
        </div>
      </div>
      <div class="growth_body">
        <div class="body_head">
          <div class="head_left">{{detailData.growName || ''}}</div>
          <div class="head_right">
            <div class="head_right_one">{{detailData.organizationName || ''}}</div>
            <div class="head_right_two">
              <span class="head_right_sta">学习状态:</span>
              <span class="head_right_status" :style="{color: ['#FF8336','#31AF0D','#409EFF '][detailData.studyStatus]}"> {{detailData.studyStatus==0?'未开始':detailData.studyStatus==1?'已完成':'进行中'}}</span>
            </div>
          </div>
        </div>
        <el-popover
          placement="bottom-end"
          width="300"
          trigger="click"
          :visible-arrow="false"
          v-model="downBody"
          offset="0"
          popper-class="growth_body_down"
          >
          <div slot="reference" class="growth_body_shared">
            <img class="shared_img" src="../../assets/images/growth/growthRight.png" alt="">
            <span class="shared_text">共享文档</span>
          </div>
          <div class="growth_body_down">
            <div class="down_head">
              <span class="down_head_text">共享文档</span>
              <div class="down_close" @click="downBody = false">
                <img class="down_close_img" src="../../assets/images/growth/close.png" alt="">
              </div>
            </div>
            <div class="down_over">
              <div class="down_body" v-for="itme in 10">
                <div class="down_body_left">
                  <img class="left_img" src="../../assets/images/growth/ppt.png" alt="">
                  <span title="人工智能启蒙讲解讲义.pptx" class="left_text">人工智能启蒙讲解讲义.pptx</span>
                </div>
                <div class="down_btn">
                  <span class="down_btn_text">下载</span>
                </div>
              </div>
            </div>
          </div>
        </el-popover>
        
        <div v-if="detailData.remark" class="body_explain">
          <div class="body_explain_icon">
            <img class="body_explain_img" src="../../assets/images/growth/growthLeft.png" alt="">
            <div class="body_explain_text">说明</div>
          </div>
          <div class="body_explain_item">
            <div class="body_explain_text">
              {{detailData.remark || ''}}
            </div>
          </div>
        </div>
        <div class="body_schedule">
          <div class="body_schedule_icon">
            <img class="body_schedule_img" src="../../assets/images/growth/growthTime.png" alt="">
            <div class="body_schedule_text">学习进度</div>
          </div>
          <div class="body_schedule_item">
            <div class="body_schedule_one">
              <div class="body_schedule_left">
                <div>总任务</div>
                <div>当前任务</div>
              </div>
              <div class="body_schedule_right">
                <div>{{detailData.taskNum}}门</div>
                <div>{{detailData.currentTaskName}}</div>
              </div>
            </div>
            <div class="body_schedule_two">
              <div class="body_schedule_pro">
                <span class="pro_text">总进度</span>
                <el-progress :stroke-width="12" :percentage="detailData.overallCompletionRate"></el-progress>
              </div>
              <div class="body_schedule_btn" @click="startLearn">
                <span class="body_schedule_text">{{detailData.overallCompletionRate==0?'开始学习':detailData.overallCompletionRate==100?'回顾':'继续学习'}}</span>
              </div>
            </div>
          </div>
        </div>
      </div>
      <div>
        <el-dialog
          title="成长路径说明"
          :visible.sync="centerDialogVisible"
          width="476px"
          style="margin-top: 30vh;"
          center>
          <div class="dialog_body">
            <div class="dialog_body_text">
              本功能针对学员所在组织、岗位、职级自动匹配成长路径，完成本路径方可晋升
            </div>
            <div class="dialog_body_btn" @click="checkedVisible">
              <span>我已阅读</span>
            </div>
            <div class="dialog_body_foot">
              <el-checkbox v-model="checked">下次进入不再弹窗</el-checkbox>
            </div>
          </div>
        </el-dialog>
      </div>
    </div>
    <el-empty v-else :image-size="200"></el-empty>
  </div>
</template>

<script>
import {getList} from '@/api/growth'
import {mapGetters} from 'vuex'
export default {
  name: 'Growth',
  data() {
    return {
      downBody: false,
      explainBody: false,
      centerDialogVisible: false,
      checked: false,
      detailData: {},
    }
  },
  mounted() {
    getList(this.userInfo.aid).then(res=>{
      if(res.code == 200 ){
        this.detailData = res.data
      }
      if(res.code == 4){
        // this.$message({
        //   type: 'error',
        //   message: res.msg
        // })
      }
    })
    if(localStorage.getItem("checkedGrowth") != null){
      this.centerDialogVisible = localStorage.getItem("checkedGrowth") === "true"
    }else{
      this.centerDialogVisible = true
    }
  },
  watch:{
    
  },
  methods: {
    startLearn(){
      this.$router.push({
        path: '/growthpath',
        query: {growId:this.detailData.growId,name: this.detailData.growName}
      })
    },
    checkedTrue(){
      this.centerDialogVisible = true
      this.checked = localStorage.getItem("checkedGrowth") === "false"
    },
    checkedVisible(){
      this.centerDialogVisible = false
      localStorage.setItem("checkedGrowth",!this.checked)
    },
  },
  computed: {
    ...mapGetters(['userInfo'])
  },
};
</script>

<style scoped lang="scss">
::v-deep .el-dialog__header{
  height: 68px;
  background: linear-gradient( 180deg, #E1DAFF 0%, #FFFFFF 100%);
  padding-top: 23px;
  margin-bottom: 36px;
}
::v-deep .el-dialog__body{
  padding: 0;
}

.growth_body_down{
      background-image: url(../../assets/images/growth/fileBack.png);
      background-repeat: no-repeat;
      background-size:100%;
      width: 487px;
      max-height: 452px;
      position: absolute;
      right: -120px;
      top: -22px;
      padding-right: 32px;
      .down_head{
        margin-top: 57px;
        margin-bottom: 34px;
        text-align: center;
        position: relative;
        .down_head_text{
          width: 96px;
          height: 28px;
          font-weight: 600;
          font-size: 24px;
          color: #387DF7;
          line-height: 28px;
          text-align: left;
        }
        .down_close{
          position: absolute;
          cursor: pointer;
          right: 37px;
          top: -18px;
          .down_close_img{
            width: 26px;
            height: 26px;
          }
        }
      }
      .down_over{
        padding: 0px 40px 0px 63px;
        overflow-y: auto;
        max-height: 309px;
        .down_body{
          display: flex;
          justify-content: space-between;
          margin-bottom: 22px;
          .down_body_left{
            display: flex;
            .left_img{
              width: 20px;
              height: 20px;
            }
            .left_text{
              display: inline-block;
              overflow: hidden;
              text-align: left;
              white-space: nowrap;
              text-overflow: ellipsis;
              margin-left: 18px;
              width: 210px;
              height: 20px;
              font-weight: 500;
              font-size: 14px;
              color: #677D86;
              line-height: 20px;
            }
          }
          .down_btn{
            cursor: pointer;
            width: 70px;
            height: 28px;
            line-height: 28px;
            border-radius: 4px;
            border: 1px solid #387DF7;
            text-align: center;
            .down_btn_text{
              width: 28px;
              height: 20px;
              font-weight: 400;
              font-size: 14px;
              color: #387DF7;
              line-height: 20px;
            }
          }
        }
      }
    }
.growth_explain{
  top: 347xp !important;
  .growth_explain1{
    display: flex;
    justify-content: center;
    align-items: center;
    width: 487px;
    height: 170px;
    margin: -37px;
    background: url("../../assets/images/growth/explain.png") no-repeat;
    background-size: 100%;
    .growth_explain_text{
      width: 376px;
      height: 56px;
      font-weight: 400;
      font-size: 14px;
      color: #333333;
      line-height: 28px;
      text-align: left;
      position: relative;
      .text{
        display: -webkit-box;
        word-wrap: break-word;
        word-break:break-all;
        overflow: hidden;
        text-overflow:ellipsis;
        -webkit-box-orient: vertical;
        -webkit-line-clamp:2;
      }
      .explain_close{
        cursor: pointer;
        background-image: url(../../assets/images/growth/close.png);
        z-index: 99999;
        width: 26px;
        height: 26px;
        position: absolute;
        right: -21px;
        top: -26px;
      }
    }

  }
    }
.growth{
  .dialog_body{
    height: 238px;
    margin-bottom: 32px;
    .dialog_body_text{
      width: 372px;
      height: 52px;
      font-weight: 400;
      font-size: 14px;
      color: #333333;
      line-height: 26px;
      text-align: left;
      margin: 0 auto;
      margin-bottom: 56px;
    }
    .dialog_body_btn{
      cursor: pointer;
      width: 152px;
      margin: 0 auto;
      margin-bottom: 31px;
      height: 40px;
      background: #387DF7;
      box-shadow: 1px 2px 8px 1px rgba(56,125,247,0.38);
      border-radius: 4px;
      text-align: center;
      line-height: 40px;
      color: #ffffff;
      font-size: 14px;
    }
    .dialog_body_foot{
      margin: 0 0 40px 61px;
    }
  }
  .growth_heads{
    display: flex;
    justify-content: space-between;
    margin: 22px 43px 19px 40px;
    position: relative;
    .growth_left{
      display: flex;
      justify-content: center;
      line-height: 40px;
      .left_text{
        width: 108px;
        height: 25px;
        font-weight: 600;
        font-size: 18px;
        color: #333333;
        text-align: left;
      }
      .growth_i{
        cursor: pointer;
        width: 20px;
        height: 20px;
        margin-left: 7px;
        border: 1px solid #999999;
        border-radius: 100%;
        margin-top: 10px;
        .growth_mark{
          color: #999999;
          line-height: 20px;
          margin-left: 5px;
        }
      }
    }
    .growth_right{
      width: 198px;
      height: 40px;
      line-height: 40px;
      background: #387DF7;
      box-shadow: 1px 2px 15px 1px rgba(56,125,247,0.34);
      border-radius: 20px;
      display: flex;
      justify-content: center;
      .right_text{
        width: 112px;
        height: 22px;
        font-weight: 400;
        font-size: 16px;
        color: #FFFFFF;
        text-align: left;
      }
      .growth_img{
        cursor: pointer;
        width: 20px;
        height: 20px;
        margin-left: 13px;
        .img{
          vertical-align: middle;
        }
      }
    }
  }
  .growth_body{
    max-width: 1340px;
    height: 574px;
    background: #FFFFFF;
    border-radius: 10px;
    border: 1px solid #E4EDFE;
    margin: 0 41px 0px 38px;
    position: relative;
    .growth_body_shared{
      cursor: pointer;
      position: absolute;
      right: 46px;
      top: 107px;
      .shared_img{
        width: 21px;
        height: 18px;
      }
      .shared_text{
        width: 64px;
        height: 22px;
        font-weight: 600;
        font-size: 16px;
        color: #409EFF;
        line-height: 22px;
        text-align: left;
        margin-left: 9px;
      }
    }
    .body_head{
      max-width: 1340px;
      height: 88px;
      background: linear-gradient( 180deg, #DEEBFF 0%, #FFFFFF 100%);
      border-radius: 10px 10px 0px 0px;
      border: 1px solid #E4EDFE;
      display: flex;
      justify-content: space-between;
      margin-bottom: 25px;
      .head_left{
        // width: 272px;
        height: 28px;
        font-weight: 600;
        font-size: 20px;
        color: #387DF7;
        line-height: 28px;
        text-align: left;
        margin: 29px 0 0 33px;
      }
      .head_right{
        // width: 326px;
        height: 22px;
        font-weight: 400;
        font-size: 16px;
        color: #666660;
        line-height: 22px;
        margin: 32px 45px 0 0;
        display: flex;
        justify-content: space-between;
        line-height: 22px;
        .head_right_one{
          overflow: hidden;
          white-space: nowrap;
          text-overflow: ellipsis;
        }
        .head_right_two{
          margin-left: 14px;
          .head_right_sta{

          }
          .head_right_status{
            color: #409EFF;
          }
        }
      }
    }
    .body_explain{
      margin-bottom: 25px;
      .body_explain_icon{
        display: flex;
        margin-left: 35px;
        margin-bottom: 23px;
        .body_explain_img{
          width: 16px;
          height: 16px;
          margin-top: 4px;
        }
        .body_explain_text{
          width: 32px;
          height: 22px;
          font-weight: 600;
          font-size: 16px;
          color: #333333;
          line-height: 22px;
          text-align: left;
          margin-left: 10px;
        }
      }
      .body_explain_item{
        margin-left: 35px;
        margin-right: 45px;
        max-width: 1260px;
        height: 100px;
        background: #F5F6F7;
        border-radius: 10px;
        padding: 22px 25px 22px 16px;
        .body_explain_text{
          max-width: 1219px;
          height: 56px;
          font-weight: 400;
          font-size: 14px;
          color: #333333;
          line-height: 28px;
          text-align: left;
          display: -webkit-box;
          word-wrap: break-word;
          word-break:break-all;
          overflow: hidden;
          text-overflow:ellipsis;
          -webkit-box-orient: vertical;
          -webkit-line-clamp:2;
        }
      }
    }
    .body_schedule{
      .body_schedule_icon{
        display: flex;
        margin-bottom: 33px;
        .body_schedule_img{
          width: 16px;
          height: 16px;
          margin-left: 35px;
          margin-top: 4px;
        }
        .body_schedule_text{
          width: 64px;
          height: 22px;
          font-weight: 600;
          font-size: 16px;
          color: #333333;
          line-height: 22px;
          text-align: left;
          margin-left: 10px;
        }
      }
      .body_schedule_item{
        margin-left: 58px;
        .body_schedule_one{
          display: flex;
          margin-bottom: 52px;
          .body_schedule_left{
            min-width: 65px;
            font-weight: 500;
            font-size: 16px;
            color: #3B3C4A;
            line-height: 22px;
            text-align: left;
          }
          .body_schedule_right{
            margin-left: 16px;
            min-width: 65px;
            font-weight: 500;
            font-size: 16px;
            color: #2E72F2;
            line-height: 22px;
            text-align: left;
          }
        }
        .body_schedule_two{
          display: flex;
          .body_schedule_pro{
            width: 314px;
            height: 37px;
            .pro_text{
              width: 42px;
              height: 22px;
              font-weight: 400;
              font-size: 14px;
              color: #666660;
              line-height: 22px;
              text-align: left;
              margin-bottom: 2px;
            }
          }
          .body_schedule_btn{
            width: 140px;
            cursor: pointer;
            height: 40px;
            margin-left: 44px;
            background: #409EFF;
            box-shadow: 1px 2px 15px 1px rgba(56,125,247,0.34);
            border-radius: 4px;
            text-align: center;
            line-height: 40px;
            .body_schedule_text{
              width: 64px;
              height: 22px;
              font-weight: 400;
              font-size: 16px;
              color: #FFFFFF;
              line-height: 22px;
              text-align: left;
            }
          }
        }
      }
    }
  }
}
</style>
