<!--其他配置-->
<template>
  <div class="page-container basicConfiguration-otherConfiguration">
    <div class="content-box scrollbar-box">
      <el-form class="add-form-box" :model="newData" ref="form" :rules="rules" label-width="120px">
        <p class="title-p">其他设置</p>
        <div class="form-big-box">
          <p class="form-text-p" style="margin:0 20px 0 0;">课件文件限制默认最大上传</p>
          <el-form-item label="" prop="uploadMaxSize" label-width="0">
            <div class="form-min-box">
              <el-input-number  class="form-input-number"
                                style="width:160px"
                                :min="0"
                                :max="10"
                                :step="1" :precision="0" step-strictly
                                v-model="newData.uploadMaxSize">
              </el-input-number>
              <p class="form-min-p">G</p>
            </div>
          </el-form-item>
        </div>
        <div class="form-big-box">
          <p class="form-text-p" style="margin:0 36px 0 0;">实验室绑定自动审批设置</p>
          <el-form-item label="" prop="autoApprovalDays" label-width="0">
            <div class="form-min-box">
              <el-input-number  class="form-input-number"
                                style="width:160px"
                                :min="0"
                                :max="10"
                                :step="1" :precision="0" step-strictly
                                v-model="newData.autoApprovalDays">
              </el-input-number>
            </div>
          </el-form-item>
          <p class="form-text-p" style="margin:0 0 0 20px;">天，未处理则自动审批通过</p>
        </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: 'otherConfiguration',
    props:{
      propsData:{},
    },
    data(){
      return{
        newData:{
          uploadMaxSize:0,
          autoApprovalDays:0,
        },
        rules:{
          uploadMaxSize: [
            { required: true, message: "请输入课件文件限制默认最大上传", trigger: "blur" },
            { required: true, message: "请输入课件文件限制默认最大上传", validator: this.spaceJudgment, trigger: "blur" }
          ],
          autoApprovalDays: [
            { required: true, message: "请输入实验室绑定自动审批设置", trigger: "blur" },
            { required: true, message: "请输入实验室绑定自动审批设置", validator: this.spaceJudgment, trigger: "blur" }
          ],
        },
      }
    },
    created(){
      this.initialize();
    },
    mounted(){

    },
    methods:{
      initialize(){
        examElConfigValueMap({configType:6}).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: 6,
                configCode: key,
                configValue: value // 确保 configValue 是字符串类型
              }));
              examElConfigSave(list).then(response => {
                self.msgSuccess(response.message);
                self.initialize();
              });
            }).catch(() => {});
          }
        })
      },
    },
  }
</script>

<style scoped lang="scss">
  .basicConfiguration-otherConfiguration{
    flex:1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    .content-box{
      flex:1;
      display: flex;
      flex-direction: column;
      .border-top{
        margin-top:30px;
        border-top:1px solid #dedede;
      }
      .title-p{
        margin-left:30px;
        line-height:40px;
        margin-top:30px;
      }
      .form-big-box{
        display: flex;
        padding-left:60px;
        margin-top:30px;
        .form-text-p{
          line-height:40px;
          font-size:16px;
          font-weight:700;
        }
        .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{
            width:72px;
            background-color: #DCDFE6;
            text-align: center;
            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-help-box{
          display: flex;
          p{
            line-height:40px;
          }
          p:nth-child(1){
            color:#0183fa;
            margin:0 10px 0 20px;
          }
          p:nth-child(2){
            font-size:16px;
          }
        }
      }
    }
  }
</style>
