<style>
  .stuCloseBtn {
    position: absolute;
    right: -8px;
    top: -9px;
    width: 20px;
    height: 20px;
    border: 1px solid red;
    background-color: red;
    color: #fff;
    line-height: 18px;
    text-align: center;
    border-radius: 50%;
    cursor: pointer;
  }
</style>
<template>
  <div>
    <q-card flat class="q-pa-lg q-my-lg"  >
      <div class="text-h6 text-weight-bold">学员预约截止日期</div>
      <div style="display:flex;margin-bottom:10px;position:relative;width:620px;">
        <q-select class="col-6 q-pb" v-model="dictObjEmp.Code" style="width:300px;margin-right:10px;" clearable filled
          stack-label use-input option-value="Id" option-label="Name" ref="ManagerId" :options="WeekList" label="截止日期"
          :dense="false" emit-value map-options>
        </q-select>
      </div>
      <q-btn class="q-mt-xl q-px-lg" unelevated color="primary" :loading="saving" @click="saveHandler">立即保存</q-btn>
    </q-card>
  </div>
</template>

<script>
  import {
    PlanAppointmentConfig,SetPlanAppointmentConfig
  } from "../../api/stuMan/index";


  export default {
    components: {
       
    },
    data() {
      return {
        
        outerVisible: false,
        saving: false,
        loading: false,
        dictObjEmp: {
          ID: 0,
          Code: null,
        },
        Name: "学员预约分配规则",
        WeekList: [{
            Id: 1,
            Name: "星期一"
          },
          {
            Id: 2,
            Name: "星期二"
          },
          {
            Id: 3,
            Name: "星期三"
          },
          {
            Id: 4,
            Name: "星期四"
          },
          {
            Id: 5,
            Name: "星期五"
          },
          {
            Id: 6,
            Name: "星期六"
          },
          {
            Id: 7,
            Name: "星期天"
          },
        ]
      };
    },
    created() {
      this.init();
    },
    methods: {
      init() {
        this.loading = true;
        PlanAppointmentConfig({}).then(res => {
          this.loading = false;
          if (res.Code == 1) {
            var tempObj = res.Data;
            if (tempObj) {
              this.dictObjEmp = {
                ID: tempObj.ID,
                Code: Number(tempObj.Code),
              };
            }
          }
        });
      },
      saveHandler() {
        if (this.dictObjEmp.Code == null) {
          this.$q.notify({
            type: 'negative',
            position: "top",
            message: `请选择预约截止日期`
          });
          return
        }
        this.saving = true;
        SetPlanAppointmentConfig(this.dictObjEmp).then(r => {
          this.saving = false;
          if (r.Code == 1) {
            this.$q.notify({
              icon: "iconfont icon-chenggong",
              color: "accent",
              timeout: 2000,
              message: "数据保存成功！",
              position: "top"
            });
            this.init();
          } else {
            this.saving = false;
          }
        });
      }
    }
  };
</script>
<style>
</style>