<style>
  .remindOne {
    border: 1px solid rgba(187, 191, 196, .3);
    border-radius: 4px;
    margin-bottom: 12px;
    padding: 20px 24px 8px;
  }

  .Notifititle {
    position: relative;
    font-size: 16px;
    line-height: 24px;
    font-weight: 500;
    color: #1f2329;
    padding-left: 10px;
    margin-bottom: 4px;
  }

  .Notifititle::before {
    position: absolute;
    left: 0;
    top: 4px;
    height: 16px;
    width: 0;
    content: "";
    border-left: 2px solid #3370ff;
  }

  .Notificat-item {
    padding: 16px 0;
    border-bottom: 1px solid rgba(187, 191, 196, .2);
    display: -ms-flexbox;
    display: flex;
    -ms-flex-align: center;
    align-items: center;
  }

  .Notificat_Inner {
    font-size: 14px;
    line-height: 22px;
    color: #1f2329;
    margin-bottom: 2px;
  }

  .Notify_innerTwo {
    font-size: 12px;
    line-height: 18px;
    color: #8f959e;
  }

  .Notify_Edit {
    cursor: pointer;
    color: #3370ff;
  }

</style>
<template>
  <div>
    <div class="page-content">
      <div class="remindOne">
        <div class="Notifititle">提醒全体成员</div>
        <div>
          <div class="Notificat-item">
            <div style="flex:1">
              <div class="Notificat_Inner">填写 OKR（仅未填写的）</div>
              <div class="Notify_innerTwo" v-if="dataList&&dataList.length>0">
                提醒时间：周期开始后第 {{dataList[0].Days}} 个工作日 {{dataList[0].Time}}
                <span class="Notify_Edit" @click="updateTime(dataList[0])">修改</span>
              </div>
            </div>
            <div>
              <template v-if="dataList&&dataList.length>0">
                <q-toggle size="md" color="primary" @input="getEnable(1)" v-model="dataList[0].Enable" :false-value="2" :true-value="1" />
              </template>
            </div>
          </div>
          <div class="Notificat-item" style="border:0;">
            <div style="flex:1">
              <div class="Notificat_Inner">给 OKR 打分（仅未打分的）</div>
              <div class="Notify_innerTwo" v-if="dataList&&dataList.length>0">
                提醒时间：周期结束前第 {{dataList[1].Days}} 个工作日 {{dataList[1].Time}}
                <span class="Notify_Edit" @click="updateTime(dataList[1])">修改</span>
              </div>
            </div>
            <div>
              <template v-if="dataList&&dataList.length>0">
                <q-toggle size="md" color="primary" @input="getEnable(2)" v-model="dataList[1].Enable" :false-value="2" :true-value="1" />
              </template>
            </div>
          </div>
        </div>
      </div>
      <div class="remindOne">
        <div class="Notifititle">提醒管理者</div>
        <div>
          <div class="Notificat-item">
            <div style="flex:1">
              <div class="Notificat_Inner">查看下级 OKR 填写情况（仅有下级未填写的）</div>
              <div class="Notify_innerTwo" v-if="dataList&&dataList.length>0">
                提醒时间：周期开始后第 {{dataList[2].Days}} 个工作日 {{dataList[2].Time}}
                <span class="Notify_Edit" @click="updateTime(dataList[2])">修改</span>
              </div>
            </div>
            <div>
              <template v-if="dataList&&dataList.length>0">
                <q-toggle size="md" color="primary" @input="getEnable(3)" v-model="dataList[2].Enable" :false-value="2" :true-value="1" />
              </template>
            </div>
          </div>
          <div class="Notificat-item" style="border:0;">
            <div style="flex:1">
              <div class="Notificat_Inner">查看下级 OKR 打分情况（仅有下级未打分的）</div>
              <div class="Notify_innerTwo" v-if="dataList&&dataList.length>0">
                提醒时间：周期结束前第 {{dataList[3].Days}} 个工作日 {{dataList[3].Time}}
                <span class="Notify_Edit" @click="updateTime(dataList[3])">修改</span>
              </div>
            </div>
            <div>
              <template v-if="dataList&&dataList.length>0">
                <q-toggle size="md" color="primary" @input="getEnable(4)" v-model="dataList[3].Enable" :false-value="2" :true-value="1" />
              </template>
            </div>
          </div>
        </div>
      </div>
      <remindtime-form v-if="isShowsetForm" @close="closeruleset" :save-obj="setObj" @success="refreshRule">
      </remindtime-form>
    </div>
  </div>
</template>
<script>
  import {
    GetOKRRemindList,
    SetOKRRemindEnable
  } from '../../api/okr/index';
  import remindtimeForm from '../../components/okr/remindtime-form';
  export default {
    meta: {
      title: "提醒设置"
    },
    components: {
      remindtimeForm
    },
    data() {
      return {
        dataList: [],
        isShowsetForm:false,
        setObj:{}
      }
    },
    created() {},
    mounted() {
      this.getList();
    },
    methods: {
      //获取数据
      getList() {
        GetOKRRemindList({}).then(res => {
          if (res.Code == 1) {
            this.dataList = res.Data;
          }
        })
      },
      //点击切换
      getEnable(type){
        let msg = {
          Type:type
        }
        SetOKRRemindEnable(msg).then(res => {
          if (res.Code == 1) {
            this.getList();
            this.$q.notify({
              icon: 'iconfont icon-chenggong',
              color: 'accent',
              timeout: 2000,
              message: '修改成功！',
              position: 'top'
            })
          }
        })
      },
      //关闭弹窗
      closeruleset(){
        this.isShowsetForm=false;
      },
      //修改成功回调
      refreshRule(){
        this.getList();
      },
      //修改
      updateTime(obj){
        this.setObj=obj;
        this.isShowsetForm=true;
      }
    }
  }

</script>
