<style>

</style>
<template>
  <q-dialog v-model="persistent" content-class="bg-grey-1" persistent transition-show="scale">
    <q-card style="width: 600px;max-width:900px;" class="CLM-Form">
      <q-card-section>
        <div class="text-h6">考核评价</div>
      </q-card-section>
      <q-card-section class="q-pt-none scroll" style="max-height: 70vh">
        <div class="row wrap">
          <div class="col-12">
            <q-select filled stack-label use-input option-value="Id" option-label="Name" v-model="objOption.Behavior"
              :options="behaviorList" label="该员工的综合工作表现" :dense="false" class="col-12 q-pr-lg q-pb-lg" emit-value
              map-options />
          </div>
        </div>
        <div class="row wrap">
          <div class="col-12">
            <q-input filled stack-label maxlength="20" :dense="false" v-model="objOption.Advantage"
              class="col-12 q-pr-lg q-pb-lg" label="主要优点" />
          </div>
        </div>
        <div class="row wrap">
          <div class="col-12">
            <q-input filled stack-label maxlength="20" :dense="false" v-model="objOption.ShortComing"
              class="col-12 q-pr-lg q-pb-lg" label="主要缺点" />
          </div>
        </div>
        <div class="row wrap">
          <div class="col-12">
            <q-select filled stack-label use-input option-value="Id" option-label="Name" v-model="objOption.Potential"
              :options="potentialList" label="该员工发展潜力" :dense="false" class="col-12 q-pr-lg q-pb-lg" emit-value
              map-options />
          </div>
        </div>
        <div class="row wrap" v-if="objOption.Potential=='其他'">
          <div class="col-12">
            <q-input filled stack-label maxlength="20" :dense="false" v-model="objOption.PotentialOther"
              class="col-12 q-pr-lg q-pb-lg" label="其他" />
          </div>
        </div>
      </q-card-section>
      <q-separator />
      <q-card-actions align="right" class="bg-white">
        <q-btn label="取消" flat color="grey-10" style="font-weight:400 !important" @click="closeBehaviorForm" />
        <q-btn label="提交" color="accent q-px-md" style="font-weight:400 !important" :loading="saveBehaviorLoading"
          @click="saveBehavior">
        </q-btn>
      </q-card-actions>
    </q-card>
  </q-dialog>
</template>
<script>
  import {
    saveTeacherAssessmentInfo,
  } from '../../api/teacher/index';
  export default {
    components: {},
    props: {
      saveObj: {
        type: Object,
        default: null
      }
    },
    data() {
      return {
        persistent: true,
        saveBehaviorLoading: false,
        behaviorList: [{
            Id: "表现最好的员工之一",
            Name: "表现最好的员工之一"
          },
          {
            Id: "表现优良",
            Name: "表现优良"
          },
          {
            Id: "表现基本满意",
            Name: "表现基本满意"
          },
          {
            Id: "尚需若干改进才能达到满意的地步",
            Name: "尚需若干改进才能达到满意的地步"
          },
          {
            Id: "需大幅改进才能达到满意的地步",
            Name: "需大幅改进才能达到满意的地步"
          },
        ],
        potentialList: [{
            Id: "潜力很大",
            Name: "潜力很大"
          },
          {
            Id: "需再学习改进",
            Name: "需再学习改进"
          },
          {
            Id: "尚可",
            Name: "尚可"
          },
          {
            Id: "其他",
            Name: "其他"
          }
        ],
        objOption: {
          Id: 0,
          Behavior: "",
          Advantage: "",
          ShortComing: "",
          Potential: "",
          PotentialOther: ""
        },
      }
    },
    created() {

    },
    mounted() {
      this.initData();
    },
    methods: {
      initData() {
        this.objOption.Id = this.saveObj.Id;
        this.objOption.Behavior = this.saveObj.Behavior;
        this.objOption.Advantage = this.saveObj.Advantage;
        this.objOption.ShortComing = this.saveObj.ShortComing;
        this.objOption.Potential = this.saveObj.Potential;
        this.objOption.PotentialOther = this.saveObj.PotentialOther;
      },
      //关闭弹窗
      closeBehaviorForm() {
        this.$emit('close')
        this.persistent = false
      },
      //保存信息
      saveBehavior() {
        this.saveBehaviorLoading = true;
        saveTeacherAssessmentInfo(this.objOption).then(res => {
          this.saveBehaviorLoading = false;
          if (res.Code == 1) {
            this.$q.notify({
              icon: 'iconfont icon-chenggong',
              color: 'accent',
              timeout: 2000,
              message: '数据保存成功！',
              position: 'top'
            })
            this.$emit('success');
            this.$emit('close');
          }
        });
      },
    },
  }
</script>