<template>
  <a-spin :spinning="confirmLoading">
    <a-form ref="formRef" class="antd-modal-form" :labelCol="labelCol" :wrapperCol="wrapperCol">
      <a-row>
        <a-col :span="6">
          <a-form-item label="主键" v-bind="validateInfos.col00">
            <a-input v-model:value="formData.col00" placeholder="请输入主键" :disabled="disabled"></a-input>
          </a-form-item>
        </a-col>
        <a-col :span="6">
          <a-form-item label="学期" v-bind="validateInfos.col01">
            <a-input v-model:value="formData.col01" placeholder="请输入学期" :disabled="disabled"></a-input>
          </a-form-item>
        </a-col>
        <a-col :span="6">
          <a-form-item label="课程名称" v-bind="validateInfos.col02">
            <a-input v-model:value="formData.col02" placeholder="请输入课程名称" :disabled="disabled"></a-input>
          </a-form-item>
        </a-col>
        <a-col :span="6">
          <a-form-item label="开课单位" v-bind="validateInfos.col03">
            <a-input v-model:value="formData.col03" placeholder="请输入开课单位" :disabled="disabled"></a-input>
          </a-form-item>
        </a-col>
        <a-col :span="6">
          <a-form-item label="授课教师" v-bind="validateInfos.col04">
            <a-input v-model:value="formData.col04" placeholder="请输入授课教师" :disabled="disabled"></a-input>
          </a-form-item>
        </a-col>
        <a-col :span="6">
          <a-form-item label="授课教师工号" v-bind="validateInfos.col05">
            <a-input v-model:value="formData.col05" placeholder="请输入授课教师工号" :disabled="disabled"></a-input>
          </a-form-item>
        </a-col>
        <a-col :span="6">
          <a-form-item label="授课日期" v-bind="validateInfos.col06">
            <a-input v-model:value="formData.col06" placeholder="请输入授课日期" :disabled="disabled"></a-input>
          </a-form-item>
        </a-col>
        <a-col :span="6">
          <a-form-item label="授课时间" v-bind="validateInfos.col07">
            <a-input v-model:value="formData.col07" placeholder="请输入授课时间" :disabled="disabled"></a-input>
          </a-form-item>
        </a-col>
        <a-col :span="6">
          <a-form-item label="授课节次" v-bind="validateInfos.col08">
            <a-input v-model:value="formData.col08" placeholder="请输入授课节次" :disabled="disabled"></a-input>
          </a-form-item>
        </a-col>
        <a-col :span="6">
          <a-form-item label="授课地点" v-bind="validateInfos.col09">
            <a-input v-model:value="formData.col09" placeholder="请输入授课地点" :disabled="disabled"></a-input>
          </a-form-item>
        </a-col>
        <a-col :span="6">
          <a-form-item label="听课教师单位" v-bind="validateInfos.col10">
            <a-input v-model:value="formData.col10" placeholder="请输入听课教师单位" :disabled="disabled"></a-input>
          </a-form-item>
        </a-col>
        <a-col :span="6">
          <a-form-item label="听课教师工号" v-bind="validateInfos.col11">
            <a-input v-model:value="formData.col11" placeholder="请输入听课教师工号" :disabled="disabled"></a-input>
          </a-form-item>
        </a-col>
        <a-col :span="6">
          <a-form-item label="听课教师姓名" v-bind="validateInfos.col12">
            <a-input v-model:value="formData.col12" placeholder="请输入听课教师姓名" :disabled="disabled"></a-input>
          </a-form-item>
        </a-col>
        <a-col :span="6">
          <a-form-item label="听课身份" v-bind="validateInfos.col13">
            <a-input v-model:value="formData.col13" placeholder="请输入听课身份" :disabled="disabled"></a-input>
          </a-form-item>
        </a-col>
        <a-col :span="6">
          <a-form-item label="听课评价结果（5分制）" v-bind="validateInfos.col14">
            <a-input v-model:value="formData.col14" placeholder="请输入听课评价结果（5分制）" :disabled="disabled"></a-input>
          </a-form-item>
        </a-col>
        <a-col :span="6">
          <a-form-item label="评价量表类型" v-bind="validateInfos.col15">
            <a-input v-model:value="formData.col15" placeholder="请输入评价量表类型" :disabled="disabled"></a-input>
          </a-form-item>
        </a-col>
        <a-col :span="6">
          <a-form-item label="数据来源" v-bind="validateInfos.col16">
            <a-input v-model:value="formData.col16" placeholder="请输入数据来源" :disabled="disabled"></a-input>
          </a-form-item>
        </a-col>
        <a-col :span="6">
          <a-form-item label="讲课有热情，精神饱满，能调动学生情绪，课堂气氛活跃" v-bind="validateInfos.col1726">
            <a-input v-model:value="formData.col1726" placeholder="请输入讲课有热情，精神饱满，能调动学生情绪，课堂气氛活跃" :disabled="disabled"></a-input>
          </a-form-item>
        </a-col>
        <a-col :span="6">
          <a-form-item label="教学目标明确，内容丰富，重点突出，言语表达清楚。" v-bind="validateInfos.col18">
            <a-input v-model:value="formData.col18" placeholder="请输入教学目标明确，内容丰富，重点突出，言语表达清楚。" :disabled="disabled"></a-input>
          </a-form-item>
        </a-col>
        <a-col :span="6">
          <a-form-item label="授课有启发性，能给予学生思考、联想、创造的启迪" v-bind="validateInfos.col19">
            <a-input v-model:value="formData.col19" placeholder="请输入授课有启发性，能给予学生思考、联想、创造的启迪" :disabled="disabled"></a-input>
          </a-form-item>
        </a-col>
        <a-col :span="6">
          <a-form-item label="能有效利用各种教学媒体，课件或板书使用效果好" v-bind="validateInfos.col20">
            <a-input v-model:value="formData.col20" placeholder="请输入能有效利用各种教学媒体，课件或板书使用效果好" :disabled="disabled"></a-input>
          </a-form-item>
        </a-col>
        <a-col :span="6">
          <a-form-item label="仪表得体，按时上下课，严格要求学生" v-bind="validateInfos.col21">
            <a-input v-model:value="formData.col21" placeholder="请输入仪表得体，按时上下课，严格要求学生" :disabled="disabled"></a-input>
          </a-form-item>
        </a-col>
        <a-col :span="6">
          <a-form-item label="无迟到、早退、旷课现象" v-bind="validateInfos.col22">
            <a-input v-model:value="formData.col22" placeholder="请输入无迟到、早退、旷课现象" :disabled="disabled"></a-input>
          </a-form-item>
        </a-col>
        <a-col :span="6">
          <a-form-item label="课堂教学秩序好，无喧闹、打瞌睡、发短信、玩手机等现象" v-bind="validateInfos.col23">
            <a-input v-model:value="formData.col23" placeholder="请输入课堂教学秩序好，无喧闹、打瞌睡、发短信、玩手机等现象" :disabled="disabled"></a-input>
          </a-form-item>
        </a-col>
        <a-col :span="6">
          <a-form-item label="上课认真听讲、积极思考、主动与老师交流互动" v-bind="validateInfos.col24">
            <a-input v-model:value="formData.col24" placeholder="请输入上课认真听讲、积极思考、主动与老师交流互动" :disabled="disabled"></a-input>
          </a-form-item>
        </a-col>
        <a-col :span="6">
          <a-form-item label="课堂教学总体印象评价" v-bind="validateInfos.col25">
            <a-input v-model:value="formData.col25" placeholder="请输入课堂教学总体印象评价" :disabled="disabled"></a-input>
          </a-form-item>
        </a-col>
        <a-col :span="6">
          <a-form-item label="请填写对课堂内容以及其他方面的具体意见或建议" v-bind="validateInfos.col26">
            <a-input v-model:value="formData.col26" placeholder="请输入请填写对课堂内容以及其他方面的具体意见或建议" :disabled="disabled"></a-input>
          </a-form-item>
        </a-col>
        <a-col :span="6">
          <a-form-item label="1.具有教育理想、敬业精神和教学追求，热爱学生、学科和教学工作。" v-bind="validateInfos.col2745">
            <a-input v-model:value="formData.col2745" placeholder="请输入1.具有教育理想、敬业精神和教学追求，热爱学生、学科和教学工作。" :disabled="disabled"></a-input>
          </a-form-item>
        </a-col>
        <a-col :span="6">
          <a-form-item label="2.掌握所教学科必需的专业与教学知识。具备所教学科的教学设计、实施、评价、反思和研究能力。" v-bind="validateInfos.col28">
            <a-input v-model:value="formData.col28" placeholder="请输入2.掌握所教学科必需的专业与教学知识。具备所教学科的教学设计、实施、评价、反思和研究能力。" :disabled="disabled"></a-input>
          </a-form-item>
        </a-col>
        <a-col :span="6">
          <a-form-item label="3.把握学生身心发展规律与特点，尊重学生主体性与差异性。" v-bind="validateInfos.col29">
            <a-input v-model:value="formData.col29" placeholder="请输入3.把握学生身心发展规律与特点，尊重学生主体性与差异性。" :disabled="disabled"></a-input>
          </a-form-item>
        </a-col>
        <a-col :span="6">
          <a-form-item label="4.立德树人，为人师表，语言规范，情绪饱满，思想积极向上" v-bind="validateInfos.col30">
            <a-input v-model:value="formData.col30" placeholder="请输入4.立德树人，为人师表，语言规范，情绪饱满，思想积极向上" :disabled="disabled"></a-input>
          </a-form-item>
        </a-col>
        <a-col :span="6">
          <a-form-item label="5.执行教学计划，遵守教学纪律，严谨从教" v-bind="validateInfos.col31">
            <a-input v-model:value="formData.col31" placeholder="请输入5.执行教学计划，遵守教学纪律，严谨从教" :disabled="disabled"></a-input>
          </a-form-item>
        </a-col>
        <a-col :span="6">
          <a-form-item label="6.系统规划和设计教学活动，合理确定教学目标和教学内容的重难点，选择合适的教学方法、教学媒体和教学形式" v-bind="validateInfos.col32">
            <a-input v-model:value="formData.col32" placeholder="请输入6.系统规划和设计教学活动，合理确定教学目标和教学内容的重难点，选择合适的教学方法、教学媒体和教学形式" :disabled="disabled"></a-input>
          </a-form-item>
        </a-col>
        <a-col :span="6">
          <a-form-item label="7.清晰讲解课程内容，恰当解释知识中蕴含的本源性思想和学科方法，适时引导学生关注课程领域发展新动态。" v-bind="validateInfos.col33">
            <a-input v-model:value="formData.col33" placeholder="请输入7.清晰讲解课程内容，恰当解释知识中蕴含的本源性思想和学科方法，适时引导学生关注课程领域发展新动态。" :disabled="disabled"></a-input>
          </a-form-item>
        </a-col>
        <a-col :span="6">
          <a-form-item label="8.启发学生思考，鼓励学生发现、提出问题，恰当给予回应和引导。" v-bind="validateInfos.col34">
            <a-input v-model:value="formData.col34" placeholder="请输入8.启发学生思考，鼓励学生发现、提出问题，恰当给予回应和引导。" :disabled="disabled"></a-input>
          </a-form-item>
        </a-col>
        <a-col :span="6">
          <a-form-item label="9.监控教学过程，富有教学机智，教学体现生成性。" v-bind="validateInfos.col35">
            <a-input v-model:value="formData.col35" placeholder="请输入9.监控教学过程，富有教学机智，教学体现生成性。" :disabled="disabled"></a-input>
          </a-form-item>
        </a-col>
        <a-col :span="6">
          <a-form-item label="10.运用多元评价方式，了解学习状况，诊断学习问题，及时反馈" v-bind="validateInfos.col36">
            <a-input v-model:value="formData.col36" placeholder="请输入10.运用多元评价方式，了解学习状况，诊断学习问题，及时反馈" :disabled="disabled"></a-input>
          </a-form-item>
        </a-col>
        <a-col :span="6">
          <a-form-item label="11.学习认真积极，踊跃参与课堂活动，体会课程学习的挑战与乐趣，感悟课程的意义与价值。" v-bind="validateInfos.col37">
            <a-input v-model:value="formData.col37" placeholder="请输入11.学习认真积极，踊跃参与课堂活动，体会课程学习的挑战与乐趣，感悟课程的意义与价值。" :disabled="disabled"></a-input>
          </a-form-item>
        </a-col>
        <a-col :span="6">
          <a-form-item label="12.掌握所学课程的基本概念与原理，理解课程的知识结构与思想体系，了解所学知识的运用情境、策略和方法。" v-bind="validateInfos.col38">
            <a-input v-model:value="formData.col38" placeholder="请输入12.掌握所学课程的基本概念与原理，理解课程的知识结构与思想体系，了解所学知识的运用情境、策略和方法。" :disabled="disabled"></a-input>
          </a-form-item>
        </a-col>
        <a-col :span="6">
          <a-form-item label="13.遵循教学一般规律，具有鲜明的创新意识和个性风貌。" v-bind="validateInfos.col39">
            <a-input v-model:value="formData.col39" placeholder="请输入13.遵循教学一般规律，具有鲜明的创新意识和个性风貌。" :disabled="disabled"></a-input>
          </a-form-item>
        </a-col>
        <a-col :span="6">
          <a-form-item label="14.尊重学科本质属性，凸显学科育人价值，注重培养学科核心素养。" v-bind="validateInfos.col40">
            <a-input v-model:value="formData.col40" placeholder="请输入14.尊重学科本质属性，凸显学科育人价值，注重培养学科核心素养。" :disabled="disabled"></a-input>
          </a-form-item>
        </a-col>
        <a-col :span="6">
          <a-form-item label="15.课堂教学蕴含理性美，具有教学魅力，体现教学艺术性。" v-bind="validateInfos.col41">
            <a-input v-model:value="formData.col41" placeholder="请输入15.课堂教学蕴含理性美，具有教学魅力，体现教学艺术性。" :disabled="disabled"></a-input>
          </a-form-item>
        </a-col>
        <a-col :span="6">
          <a-form-item label="16.你对该课程的总体评价情况，5分是满分，您给打几分？" v-bind="validateInfos.col42">
            <a-input v-model:value="formData.col42" placeholder="请输入16.你对该课程的总体评价情况，5分是满分，您给打几分？" :disabled="disabled"></a-input>
          </a-form-item>
        </a-col>
        <a-col :span="6">
          <a-form-item label="17.您认为该课堂值得肯定的方面" v-bind="validateInfos.col43">
            <a-input v-model:value="formData.col43" placeholder="请输入17.您认为该课堂值得肯定的方面" :disabled="disabled"></a-input>
          </a-form-item>
        </a-col>
        <a-col :span="6">
          <a-form-item label="18.您认为该课堂需要改进的方面" v-bind="validateInfos.col44">
            <a-input v-model:value="formData.col44" placeholder="请输入18.您认为该课堂需要改进的方面" :disabled="disabled"></a-input>
          </a-form-item>
        </a-col>
        <a-col :span="6">
          <a-form-item label="19.其它建议" v-bind="validateInfos.col45">
            <a-input v-model:value="formData.col45" placeholder="请输入19.其它建议" :disabled="disabled"></a-input>
          </a-form-item>
        </a-col>
        <a-col :span="6">
          <a-form-item label="1.声音和画面情况" v-bind="validateInfos.col4655">
            <a-input v-model:value="formData.col4655" placeholder="请输入1.声音和画面情况" :disabled="disabled"></a-input>
          </a-form-item>
        </a-col>
        <a-col :span="6">
          <a-form-item label="2.ppt等课件情况" v-bind="validateInfos.col47">
            <a-input v-model:value="formData.col47" placeholder="请输入2.ppt等课件情况" :disabled="disabled"></a-input>
          </a-form-item>
        </a-col>
        <a-col :span="6">
          <a-form-item label="3.教师出镜情况" v-bind="validateInfos.col48">
            <a-input v-model:value="formData.col48" placeholder="请输入3.教师出镜情况" :disabled="disabled"></a-input>
          </a-form-item>
        </a-col>
        <a-col :span="6">
          <a-form-item label="4.以下那些描述符合本节课的教学实际情况（多选）" v-bind="validateInfos.col49">
            <a-input v-model:value="formData.col49" placeholder="请输入4.以下那些描述符合本节课的教学实际情况（多选）" :disabled="disabled"></a-input>
          </a-form-item>
        </a-col>
        <a-col :span="6">
          <a-form-item label="5.学生出席情况" v-bind="validateInfos.col50">
            <a-input v-model:value="formData.col50" placeholder="请输入5.学生出席情况" :disabled="disabled"></a-input>
          </a-form-item>
        </a-col>
        <a-col :span="6">
          <a-form-item label="6.学生参与课堂活动情况" v-bind="validateInfos.col51">
            <a-input v-model:value="formData.col51" placeholder="请输入6.学生参与课堂活动情况" :disabled="disabled"></a-input>
          </a-form-item>
        </a-col>
        <a-col :span="6">
          <a-form-item label="7.如果让您给本节课打分，5分是满分，您给打几分？" v-bind="validateInfos.col52">
            <a-input v-model:value="formData.col52" placeholder="请输入7.如果让您给本节课打分，5分是满分，您给打几分？" :disabled="disabled"></a-input>
          </a-form-item>
        </a-col>
        <a-col :span="6">
          <a-form-item label="8.您认为该课堂值得肯定的方面" v-bind="validateInfos.col53">
            <a-input v-model:value="formData.col53" placeholder="请输入8.您认为该课堂值得肯定的方面" :disabled="disabled"></a-input>
          </a-form-item>
        </a-col>
        <a-col :span="6">
          <a-form-item label="9.您认为该课堂需要改进的方面" v-bind="validateInfos.col54">
            <a-input v-model:value="formData.col54" placeholder="请输入9.您认为该课堂需要改进的方面" :disabled="disabled"></a-input>
          </a-form-item>
        </a-col>
        <a-col :span="6">
          <a-form-item label="10.其它建议" v-bind="validateInfos.col55">
            <a-input v-model:value="formData.col55" placeholder="请输入10.其它建议" :disabled="disabled"></a-input>
          </a-form-item>
        </a-col>
      </a-row>
    </a-form>
  </a-spin>
</template>

<script lang="ts" setup>
  import { ref, reactive, defineExpose, nextTick, defineProps, computed, onMounted } from 'vue';
  import { defHttp } from '/@/utils/http/axios';
  import { useMessage } from '/@/hooks/web/useMessage';
  import { getValueType } from '/@/utils';
  import { saveOrUpdate } from '../KcEvaluationsStat.api';
  import { Form } from 'ant-design-vue';
  
  const props = defineProps({
    formDisabled: { type: Boolean, default: false },
    formData: { type: Object, default: ()=>{} },
    formBpm: { type: Boolean, default: true }
  });
  const formRef = ref();
  const useForm = Form.useForm;
  const emit = defineEmits(['register', 'ok']);
  const formData = reactive<Record<string, any>>({
    id: '',
    col00: '',
    col01: '',
    col02: '',
    col03: '',
    col04: '',
    col05: '',
    col06: '',
    col07: '',
    col08: '',
    col09: '',
    col10: '',
    col11: '',
    col12: '',
    col13: '',
    col14: '',
    col15: '',
    col16: '',
    col1726: '',
    col18: '',
    col19: '',
    col20: '',
    col21: '',
    col22: '',
    col23: '',
    col24: '',
    col25: '',
    col26: '',
    col2745: '',
    col28: '',
    col29: '',
    col30: '',
    col31: '',
    col32: '',
    col33: '',
    col34: '',
    col35: '',
    col36: '',
    col37: '',
    col38: '',
    col39: '',
    col40: '',
    col41: '',
    col42: '',
    col43: '',
    col44: '',
    col45: '',
    col4655: '',
    col47: '',
    col48: '',
    col49: '',
    col50: '',
    col51: '',
    col52: '',
    col53: '',
    col54: '',
    col55: '',
  });
  const { createMessage } = useMessage();
  const labelCol = ref<any>({ xs: { span: 24 }, sm: { span: 5 } });
  const wrapperCol = ref<any>({ xs: { span: 24 }, sm: { span: 16 } });
  const confirmLoading = ref<boolean>(false);
  //表单验证
  const validatorRules = {
  };
  const { resetFields, validate, validateInfos } = useForm(formData, validatorRules, { immediate: true });

  // 表单禁用
  const disabled = computed(()=>{
    if(props.formBpm === true){
      if(props.formData.disabled === false){
        return false;
      }else{
        return true;
      }
    }
    return props.formDisabled;
  });

  
  /**
   * 新增
   */
  function add() {
    edit({});
  }

  /**
   * 编辑
   */
  function edit(record) {
    nextTick(() => {
      resetFields();
      //赋值
      Object.assign(formData, record);
    });
  }

  /**
   * 提交数据
   */
  async function submitForm() {
    // 触发表单验证
    await validate();
    confirmLoading.value = true;
    const isUpdate = ref<boolean>(false);
    //时间格式化
    let model = formData;
    if (model.id) {
      isUpdate.value = true;
    }
    //循环数据
    for (let data in model) {
      //如果该数据是数组并且是字符串类型
      if (model[data] instanceof Array) {
        let valueType = getValueType(formRef.value.getProps, data);
        //如果是字符串类型的需要变成以逗号分割的字符串
        if (valueType === 'string') {
          model[data] = model[data].join(',');
        }
      }
    }
    await saveOrUpdate(model, isUpdate.value)
      .then((res) => {
        if (res.success) {
          createMessage.success(res.message);
          emit('ok');
        } else {
          createMessage.warning(res.message);
        }
      })
      .finally(() => {
        confirmLoading.value = false;
      });
  }


  defineExpose({
    add,
    edit,
    submitForm,
  });
</script>

<style lang="less" scoped>
  .antd-modal-form {
    min-height: 500px !important;
    overflow-y: auto;
    padding: 24px 24px 24px 24px;
  }
</style>
