<style scoped>
  .Student_Date .el-input__inner {
    background: transparent !important;
    border: 0 !important;
    padding-right: 0 !important;
  }

</style>
<template>
  <div>
    <div class="row wrap">
      <q-btn label="新增留学需求" color="accent q-mb-lg" size="sm" @click="isShowReserve = true" />
    </div>
    <template v-if="isShowReserve">
      <div class="row studentDate">
        <UeEditor v-model="addMsg.Remark" class="q-pb-sm" :config="config"></UeEditor>
      </div>
      <div class="row wrap justify-end q-pr-lg" style="margin-bottom:10px;">
        <q-btn label="关闭" flat color="accent q-mb-lg" size="md" style="margin-right:10px;" @click="closeClassForm" />
        <q-btn label="保存" color="accent q-mb-lg" size="md" @click="saveAppointForm()" />
      </div>
    </template>
  </div>
</template>
<script>
  import UeEditor from "../../editor/UeEditor";
  import {
    SetStudyAbroad
  } from "../../../api/scheduling/schedu";
  export default {
    components: {
      UeEditor
    },
    props: {
      saveObj: {
        type: Object,
        default: null
      }
    },
    data() {
      return {
        config: {
          initialFrameWidth: null,
          initialFrameHeight: 90
        },
        isShowReserve: false,
        addMsg: {
          Id: 0, //编号
          Visitor_Id: 0, //访客编号
          ReserveClassId: 0, //选中的班级编号
          ClassDate: "", //预约日期
          ClassTime: "", //预约开始时间
          EndTime: "", //预约结束时间
          TeacherId: 0, //教师编号
          ClassRoomId: 0, //教室编号
          ClassContent: "", //主讲内容
          TrialLessonId: "",
          ReserveType: 0,
          ClassPlanId: 0,
          Demand: "",
        },
        isShowTeacher: false, //是否显示试听课弹窗
        showObj: {
          className: "",
          courseName: "",
        }
      };
    },
    created() {

    },
    mounted() {
      if (this.saveObj) {
        this.addMsg.Visitor_Id = this.saveObj.StuId;
      }
    },
    methods: {
      //关闭窗口
      closeClassForm() {
        this.clearMsg()
        this.isShowReserve = false;
        this.$emit("success");
      },
      //清除
      clearMsg() {
        this.addMsg.Id = 0;
        this.addMsg.ReserveClassId = 0;
        this.addMsg.ClassDate = "";
        this.addMsg.ClassTime = "";
        this.addMsg.EndTime = "";
        this.addMsg.TeacherId = 0;
        this.addMsg.ClassRoomId = 0;
        this.addMsg.ClassContent = "";
        this.addMsg.TrialLessonId = "";
        this.addMsg.ReserveType = 0;
        this.addMsg.ClassPlanId = 0;
        this.addMsg.Demand = "";
      },
      //保存
      saveAppointForm() {
        if (this.addMsg.Remark == "") {
          this.$q.notify({
            type: "negative",
            position: "top",
            timeout: 2000,
            message: "请输入留学需求！"
          });
          return;
        }
        SetStudyAbroad(this.addMsg).then(res => {
          if (res.Code == 1) {
            this.$q.notify({
              icon: "iconfont icon-chenggong",
              color: "accent",
              timeout: 2000,
              message: res.Message,
              position: "top"
            });
            this.$emit("success");
          } else {
            this.$q.notify({
              type: "negative",
              position: "top",
              timeout: 2000,
              message: res.Message
            });
          }
          this.clearMsg();
          this.isShowReserve = false;
        });
      },
      closeAuditForm() {
        this.isShowTeacher = false;
      },
      //子组件选中传值
      getchildInfo(obj) {
        if (obj) {
          this.addMsg.ReserveType = obj.ReserveType;
          this.addMsg.ClassPlanId = obj.ClassPlanId;
          this.addMsg.TeacherId = obj.TeacherId;
          this.addMsg.ClassRoomId = obj.ClassRoomId;
          this.addMsg.ReserveClassId = obj.ReserveClassId;
          this.addMsg.ClassDate = obj.ClassDateStr;
          this.addMsg.ClassTime = obj.ClassTime;
          this.addMsg.EndTime = obj.EndTime;
          this.addMsg.ClassContent = obj.ClassContent;
          this.addMsg.TrialLessonId = obj.TrialLessonId;
          this.isShowReserve = true;
        }
      }
    }
  };

</script>
