<!--分级要求配置-->
<template>
  <div class="page-container basicConfiguration-gradingConfiguration">
    <div class="content-box scrollbar-box">
      <el-form class="add-form-box" :model="newData" ref="form"
               :rules="rules">
        <el-form-item label="学时计算" prop="gradeStudyHour" label-width="112px">
          <div class="form-min-box">
            <el-input-number  class="form-input-number"
                              style="width:100px"
                              :min="0"
                              :max="9999"
                              :step="1" :precision="0" step-strictly
                              v-model="newData.gradeStudyHour"
                              :controls="false">
            </el-input-number>
            <p class="form-min-p">分钟</p>
            <span class="form-min-span">注：9月 1日至次年的8月31日为一学年</span>
          </div>
        </el-form-item>
        <p class="title-1-p">Ⅰ级分级</p>
        <div class="form-flex-box">
          <el-form-item label="第一学年完成不少于" prop="levelOneInitMinHour" label-width="182px">
            <div class="form-min-box-2">
              <el-input-number  class="form-input-number"
                                style="width:260px"
                                :min="0"
                                :max="9999"
                                :step="0.1" :precision="1" step-strictly
                                v-model="newData.levelOneInitMinHour">
              </el-input-number>
              <p class="form-min-p">学时,</p>
            </div>
          </el-form-item>
          <el-form-item label="后续每学年完成不少于" prop="levelOneFollowMinHour" label-width="170px">
            <div class="form-min-box-2">
              <el-input-number  class="form-input-number"
                                style="width:260px"
                                :min="0"
                                :max="9999"
                                :step="0.1" :precision="1" step-strictly
                                v-model="newData.levelOneFollowMinHour">
              </el-input-number>
              <p class="form-min-p">学时学习</p>
            </div>
          </el-form-item>
        </div>
        <p class="title-2-p">Ⅱ级分级</p>
        <div class="form-flex-box">
          <el-form-item label="第一学年完成不少于" prop="leveltwoInitMinHour" label-width="182px">
            <div class="form-min-box-2">
              <el-input-number  class="form-input-number"
                                style="width:260px"
                                :min="0"
                                :max="9999"
                                :step="0.1" :precision="1" step-strictly
                                v-model="newData.leveltwoInitMinHour">
              </el-input-number>
              <p class="form-min-p">学时,</p>
            </div>
          </el-form-item>
          <el-form-item label="后续每学年完成不少于" prop="levelTwoFollowMinHour" label-width="170px">
            <div class="form-min-box-2">
              <el-input-number  class="form-input-number"
                                style="width:260px"
                                :min="0"
                                :max="9999"
                                :step="0.1" :precision="1" step-strictly
                                v-model="newData.levelTwoFollowMinHour">
              </el-input-number>
              <p class="form-min-p">学时学习</p>
            </div>
          </el-form-item>
        </div>
        <p class="title-3-p">Ⅲ级分级</p>
        <div class="form-flex-box">
          <el-form-item label="第一学年完成不少于" prop="levelThreeInitMinHour" label-width="182px">
            <div class="form-min-box-2">
              <el-input-number  class="form-input-number"
                                style="width:260px"
                                :min="0"
                                :max="9999"
                                :step="0.1" :precision="1" step-strictly
                                v-model="newData.levelThreeInitMinHour">
              </el-input-number>
              <p class="form-min-p">学时,</p>
            </div>
          </el-form-item>
          <el-form-item label="后续每学年完成不少于" prop="levelThreeFollowMinHour" label-width="170px">
            <div class="form-min-box-2">
              <el-input-number  class="form-input-number"
                                style="width:260px"
                                :min="0"
                                :max="9999"
                                :step="0.1" :precision="1" step-strictly
                                v-model="newData.levelThreeFollowMinHour">
              </el-input-number>
              <p class="form-min-p">学时学习</p>
            </div>
          </el-form-item>
        </div>
        <p class="title-4-p">Ⅳ级分级</p>
        <div class="form-flex-box">
          <el-form-item label="第一学年完成不少于" prop="levelFourInitMinHour" label-width="182px">
            <div class="form-min-box-2">
              <el-input-number  class="form-input-number"
                                style="width:260px"
                                :min="0"
                                :max="9999"
                                :step="0.1" :precision="1" step-strictly
                                v-model="newData.levelFourInitMinHour">
              </el-input-number>
              <p class="form-min-p">学时,</p>
            </div>
          </el-form-item>
          <el-form-item label="后续每学年完成不少于" prop="levelFourFollowMinHour" label-width="170px">
            <div class="form-min-box-2">
              <el-input-number  class="form-input-number"
                                style="width:260px"
                                :min="0"
                                :max="9999"
                                :step="0.1" :precision="1" step-strictly
                                v-model="newData.levelFourFollowMinHour">
              </el-input-number>
              <p class="form-min-p">学时学习</p>
            </div>
          </el-form-item>
        </div>
      </el-form>
    </div>
  </div>
</template>

<script>
  //import { getDicts } from "@/api/commonality/noPermission";
  //import { systemUserSelect } from "@/api/commonality/permission";
  //import { getInfo } from "@/api/basicsModules/index";
  import { examElConfigValueMap,examElConfigSave } from "@/api/safetyEducationExaminationNew/index";
  export default {
    name: 'gradingConfiguration',
    props:{
      propsData:{},
    },
    data(){
      return{
        newData:{
          gradeStudyHour:0,
          levelOneInitMinHour:0,
          levelOneFollowMinHour:0,
          leveltwoInitMinHour:0,
          levelTwoFollowMinHour:0,
          levelThreeInitMinHour:0,
          levelThreeFollowMinHour:0,
          levelFourInitMinHour:0,
          levelFourFollowMinHour:0,
        },
        rules:{
          // gradeStudyHour: [
          //   { required: true, message: "请输入学时计算", trigger: "blur" },
          //   { required: true, message: "请输入学时计算", validator: this.spaceJudgment, trigger: "blur" }
          // ],
          // levelOneInitMinHour: [
          //   { required: true, message: "请输入第一学年完成所需学时", trigger: "blur" },
          //   { required: true, message: "请输入第一学年完成所需学时", validator: this.spaceJudgment, trigger: "blur" }
          // ],
          // levelOneFollowMinHour: [
          //   { required: true, message: "请输入后续每学年完成所需学时", trigger: "blur" },
          //   { required: true, message: "请输入后续每学年完成所需学时", validator: this.spaceJudgment, trigger: "blur" }
          // ],
          // leveltwoInitMinHour: [
          //   { required: true, message: "请输入第二学年完成所需学时", trigger: "blur" },
          //   { required: true, message: "请输入第二学年完成所需学时", validator: this.spaceJudgment, trigger: "blur" }
          // ],
          // levelTwoFollowMinHour: [
          //   { required: true, message: "请输入后续每学年完成所需学时", trigger: "blur" },
          //   { required: true, message: "请输入后续每学年完成所需学时", validator: this.spaceJudgment, trigger: "blur" }
          // ],
          // levelThreeInitMinHour: [
          //   { required: true, message: "请输入第三学年完成所需学时", trigger: "blur" },
          //   { required: true, message: "请输入第三学年完成所需学时", validator: this.spaceJudgment, trigger: "blur" }
          // ],
          // levelThreeFollowMinHour: [
          //   { required: true, message: "请输入后续每学年完成所需学时", trigger: "blur" },
          //   { required: true, message: "请输入后续每学年完成所需学时", validator: this.spaceJudgment, trigger: "blur" }
          // ],
          // levelFourInitMinHour: [
          //   { required: true, message: "请输入第四学年完成所需学时", trigger: "blur" },
          //   { required: true, message: "请输入第四学年完成所需学时", validator: this.spaceJudgment, trigger: "blur" }
          // ],
          // levelFourFollowMinHour: [
          //   { required: true, message: "请输入后续每学年完成所需学时", trigger: "blur" },
          //   { required: true, message: "请输入后续每学年完成所需学时", validator: this.spaceJudgment, trigger: "blur" }
          // ],
        },
      }
    },
    created(){
      this.initialize();
    },
    mounted(){

    },
    methods:{
      initialize(){
        examElConfigValueMap({configType:1}).then(response => {
          this.$set(this,'newData',response.data);
        });
      },
      //重置
      resetButton(){
        let self = this;
        this.$confirm('确认重置?', "警告", {
          confirmButtonText: "确认",
          cancelButtonText: "取消",
          type: "warning"
        }).then(function() {
        }).then(() => {
          this.initialize();
        }).catch(() => {});
      },
      //提交
      submitButton(){
        let self = this;
        this.$refs["form"].validate(valid => {
          if (valid) {
            this.$confirm('确认提交?', "警告", {
              confirmButtonText: "确认",
              cancelButtonText: "取消",
              type: "warning"
            }).then(function() {
            }).then(() => {
              const list = Object.entries(self.newData).map(([key, value]) => ({
                configType: 1,
                configCode: key,
                configValue: value // 确保 configValue 是字符串类型
              }));
              examElConfigSave(list).then(response => {
                self.msgSuccess(response.message);
                self.initialize();
              });
            }).catch(() => {});
          }
        })
      },
    },
  }
</script>

<style scoped lang="scss">
  .basicConfiguration-gradingConfiguration{
    .content-box{
      flex:1;
      display: flex;
      padding:20px;
      .form-min-box{
        display: flex;
        .form-input-number ::v-deep .el-input__inner {
          border-top-right-radius: 0;
          border-bottom-right-radius:0;
        }
        .form-min-p{
          background-color: #DCDFE6;
          padding:0 20px;
          border-top-right-radius: 4px;
          border-bottom-right-radius: 4px;
          line-height: 40px;
        }
        .form-min-span{
          margin-left:20px;
          color: #999;
          line-height: 40px;
        }
      }
      .form-min-box-2{
        display: flex;
        .form-min-p{
          line-height: 40px;
          margin-left:15px;
        }
      }
      .form-flex-box{
        display: flex;
      }
      .title-1-p{
        font-size:18px;
        line-height:40px;
        margin-left:40px;
        color:#FE0000;
        margin-bottom:20px;
      }
      .title-2-p{
        font-size:18px;
        line-height:40px;
        margin-left:40px;
        color:#FCA401;
        margin-bottom:20px;
      }
      .title-3-p{
        font-size:18px;
        line-height:40px;
        margin-left:40px;
        color:#FBDE01;
        margin-bottom:20px;
      }
      .title-4-p{
        font-size:18px;
        line-height:40px;
        margin-left:40px;
        color:#0141FF;
        margin-bottom:20px;
      }
    }
  }
</style>
