<style>
  .baseSetForm .Period-rules {
    display: flex;
    margin-bottom: 24px;
    padding-left: 20px;
  }

  .baseSetForm .Period_Spreate {
    flex: 1;
    min-width: 200px;
    margin-right: 32px;
  }

  .baseSetForm .Period-rule-title {
    color: #646a73;
    margin-bottom: 4px;
    display: flex;
    align-items: center;
  }

  .baseSetForm .Period-info-icon {
    margin-left: 8px;
    color: #8f959e;
    line-height: 1;
    vertical-align: top;
  }

  .process_Btn_List {
    display: flex;
    justify-content: flex-end;
    padding: 20px;
  }

  .processBtn_Cancel {
    width: 90px;
    height: 35px;
    border: 1px solid #A1AAB2;
    color: #000000;
    background-color: #fff;
    text-align: center;
    line-height: 35px;
    border-radius: 5px;
    cursor: pointer;
    margin-right: 20px;
  }

  .processBtn_Save {
    width: 90px;
    height: 35px;
    background-color: #2961FE;
    color: #FFF;
    text-align: center;
    line-height: 35px;
    border-radius: 5px;
    cursor: pointer;
  }

  .baseSetForm_Dialog {
    margin: 20px;
  }

  .cycle_Title {
    font-size: 20px;
    font-weight: 500;
    color: #1f2329;
  }

  .Period-alert {
    padding: 9px 16px;
    border-radius: 4px;
    background-color: #f0f4ff;
    line-height: 22px;
    color: #1f2329;
    display: flex;
    align-items: center;
    margin-top: 20px;
    margin-bottom: 12px;
    font-size: 13px;
  }

  .Okr_Length {
    font-weight: 500;
    color: #1f2329;
  }

  .FormItem-asterisk {
    position: relative;
    top: 3px;
    margin-left: 3px;
    color: #f54a45;
    line-height: 1;
  }

  .baseSetForm_Dialog .el-radio {
    display: block;
    margin-bottom: 15px;
  }

</style>
<template>
  <div class="baseSetForm">
    <div style="text-align:right;">
      <q-btn color="accent" size="sm" class="q-mr-md" @click="isShowBaseSet=true" label="修改基础配置" />
    </div>
    <div class="Period-rules">
      <div class="Period_Spreate">
        <div class="Period-rule-title">周期长度</div>
        <div>{{getPerodMonth(baseObj.PeriodMonth)}}</div>
      </div>
      <div class="Period_Spreate">
        <div class="Period-rule-title">
          新生效周期
          <span class="Period-info-icon">
            <el-tooltip content="当前周期设置后的首个生效周期" placement="top" effect="light">
              <i class="iconfont icon-tishi"></i>
            </el-tooltip>
          </span>
        </div>
        <div>{{baseObj.StartDate}} - {{baseObj.EndDate}}</div>
      </div>
    </div>
    <div class="Period-rules">
      <div class="Period_Spreate">
        <div class="Period-rule-title">新周期出现时间</div>
        <div>上个周期结束前 {{baseObj.BeforeNum}} {{baseObj.BeforeType==1?'天':'月'}}</div>
      </div>
      <div class="Period_Spreate">
        <div class="Period-rule-title">
          年度 OKR
        </div>
        <div>
          {{baseObj.YearOKR==1?'已开启':'未开启'}}
        </div>
      </div>
    </div>
    <div class="Period-rules">
      <div class="Period_Spreate">
        <div class="Period-rule-title">
          主管审核
        </div>
        <div>
          {{baseObj.DirectorAudit==1?'已开启':'未开启'}}
        </div>
      </div>
    </div>
    <basecycle-form v-if="isShowBaseSet" :save-obj="baseObj" @close="closeProcessForm" @success="refreshPage">
    </basecycle-form>
  </div>
</template>
<script>
  import {
    GetOKRPeriodConfigInfo
  } from '../../api/okr/index';
  import basecycleForm from '../../components/okr/basecycle-form';
  export default {
    meta: {
      title: ""
    },
    components: {
      basecycleForm
    },
    data() {
      return {
        isShowBaseSet: false,
        baseObj: {}
      }
    },
    mounted() {
      this.getList();
    },
    methods: {
      //获取okr配置信息
      getList() {
        GetOKRPeriodConfigInfo({}).then(res => {
          if (res.Code == 1) {
            this.baseObj = res.Data;
          }
        })
      },
      //返回组装数据
      getPerodMonth(num) {
        let str = ''
        switch (num) {
          case 1:
            str = 1 + ' ' + '个月'
            break;
          case 2:
            str = 2 + ' ' + '个月'
            break;
          case 3:
            str = 3 + ' ' + '个月'+' '+'（季度）'
            break;
          case 4:
            str = 4 + ' ' + '个月'
            break;
          case 6:
            str = '半年'
            break;
          default:
        }
        return str;
      },
      //关闭流程设置
      closeProcessForm() {
        this.isShowBaseSet = false;
      },
      refreshPage() {
        this.getList();
      },
    }
  }

</script>
