<template>
  <div>
    <div class="con-title">休学申请</div>
    <div class="con-box">
      <el-button type="text" @click="goBack">返回列表</el-button>
      <div class="main-form">
        <el-form label-width="120px" :disabled="isView" ref="ruleForm" :model="ruleForm" :rules="rules">
          <el-form-item label="姓名" prop="personal_name">
            <el-input v-model="ruleForm.personal_name" readonly />
          </el-form-item>
          <el-form-item label="班级" prop="class_name">
            <el-input v-model="ruleForm.class_name" readonly />
          </el-form-item>
          <el-form-item label="Sofia ID" prop="sofia_id">
            <el-input v-model="ruleForm.sofia_id" readonly />
          </el-form-item>
          <el-form-item label="休学时间" prop="semester_name">
            <el-radio-group v-model="ruleForm.semester_name">
              <div v-for="item in semesterList" :key="item.value" style="margin: 10px 0">
                <el-radio :label="item.value">{{ item.value }}</el-radio>
              </div>
            </el-radio-group>
          </el-form-item>
          <el-form-item label="休学原因" prop="reason">
            <el-input type="textarea" v-model="ruleForm.reason" :autosize="{ minRows: 5 }" />
          </el-form-item>
          <template v-if="isView">
            <el-form-item label="审批状态" style="margin: 0">
              {{ statusText }}
            </el-form-item>
            <el-form-item label="审批时间" style="margin: 0" v-if="detail.approve_time1">
              {{ detail.approve_time1 }}
            </el-form-item>
            <el-form-item label="审批备注" style="margin: 0" v-if="detail.remark1 || detail.remark2">
              {{ detail.remark1 || detail.remark2 }}
            </el-form-item>
          </template>
          <el-form-item v-if="!this.isView">
            <el-button type="primary" :loading="submitLoading" @click="handleSubmit">
              {{ $t('pages.affairsHall.shareAdd.savesubmit') }}
            </el-button>
            <el-button type="info" @click="onRemove" v-if="hasAbort">撤回申请</el-button>
          </el-form-item>
        </el-form>
      </div>
    </div>
  </div>
</template>

<script>
import editMixins from '../../mixins/edit'
export default {
  mixins: [editMixins],
  data() {
    return {
      ruleForm: {
        affair_id: '',
        personal_name: '',
        class_name: '',
        sofia_id: '',
        semester_name: '',
        reason: ''
      },
      rules: {
        personal_name: [{ required: true, message: '请输入您的姓名', trigger: 'blur' }],
        class_name: [{ required: true, message: '请输入您的班级', trigger: 'blur' }],
        sofia_id: [{ required: true, message: '请输入Sofia ID', trigger: 'blur' }],
        semester_name: [{ required: true, message: '请选择休学时间', trigger: 'blur' }],
        reason: [{ required: true, message: '请输入休学原因', trigger: 'blur' }]
      },
      // 学期列表
      semesterList: [
        { value: '春季学期（4月11日---7月10日）' },
        { value: '夏季学期（7月11日---10月10日）' },
        { value: '秋季学期（10月11日---1月10日）' },
        { value: '冬季学期（1月11日---4月10日）' }
      ]
    }
  },
  beforeMount() {
    if (this.isEdit || this.isView) {
      this.getDetail()
    } else {
      // 获取学生信息
      this.getStudent()
    }
  }
}
</script>

<style lang="scss" scoped>
.main-form {
  max-width: 600px;
  margin: 0 auto;
}
.el-date-editor.el-input {
  width: 100%;
}
</style>
