<template>
  <div>
    <el-form :model="quitForm" ref="quitForm" :rules="quitRules">
      <el-form-item prop="disposeContent">
        <el-input
          type="textarea"
          v-model="quitForm.disposeContent"
            maxlength="99"
            show-word-limit
          placeholder="请填写处理意见"
        ></el-input>
      </el-form-item>
    </el-form>
    <div slot="footer" class="dialog-footer" style="text-align: right">
      <el-button @click="$emit('close')">取 消</el-button>
      <el-button type="primary" @click="submit">确 定</el-button>
    </div>
  </div>
</template>
<script>
import { teacherAttendanceUpdate } from "../api";
export default {
  props: ["detail"],
  data() {
    return {
      quitForm: {
        disposeContent: '',
      },
      quitRules: {
        disposeContent: [{ required: true, message: "请填写退团退费原因" }],
      },
    };
  },
  mounted() {
      //  console.log(this.detail.teacherAttendance.disposeContent);
    if (this.detail?.teacherAttendance?.disposeContent) {
      this.$set(
        this.quitForm,
        "disposeContent",
        this.detail.teacherAttendance.disposeContent
      );
      // this.quitForm.reason = this.detail?.teacherAttendance?.disposeContent
    }
    if(this.detail?.disposeContent){
          this.$set(
        this.quitForm,
        "disposeContent",
        this.detail.disposeContent
      );
    }
  },
  methods: {
    submit() {
      this.$refs.quitForm.validate(async (valid) => {
        if (valid) {
          try {
            await teacherAttendanceUpdate({
              id: this.detail.teacherAttendanceId,
              ...this.quitForm,
            });
            this.$emit("close");
            this.$emit("submited");
            this.$message.success("提交成功");
          } catch (error) {}
        }
      });
    },
  },
};
</script>
