<!--检查配置-->
<template>
  <div class="app-container checkConfig">
    <el-form :model="form" ref="form" label-position="top" :inline="true" :rules="rules" class="checkConfigPage"
             v-show="showSearch" label-width="68px">
      <div class="top-box scrollbar-box">
        <p class="form-title">一般整改</p>
        <el-form-item label="短信通知模板" prop="checkSmsMsg">
          <el-input
            style="width:260px;margin-right:60px;"
            maxLength="50"
            v-model="form.checkSmsMsg"
            placeholder="请输入短信通知模板"
            clearable
            size="small"
          />
        </el-form-item>
        <el-form-item label="一体机通知模板" prop="checkAioMsg">
          <el-input
            style="width:260px;margin-right:60px;"
            maxLength="50"
            v-model="form.checkAioMsg"
            placeholder="请输入一体机通知模板"
            clearable
            size="small"
          />
        </el-form-item>
        <el-form-item label="站内信通知模板" prop="checkAppMsg">
          <el-input
            style="width:260px;margin-right:60px;"
            maxLength="50"
            v-model="form.checkAppMsg"
            placeholder="请输入站内信通知模板"
            clearable
            size="small"
          />
        </el-form-item>
        <p class="form-title">重大整改</p>
        <el-form-item label="短信通知模板" prop="rectifySmsMsg">
          <el-input
            style="width:260px;margin-right:60px;"
            maxLength="50"
            v-model="form.rectifySmsMsg"
            placeholder="请输入短信通知模板"
            clearable
            size="small"
          />
        </el-form-item>
        <el-form-item label="一体机通知模板" prop="rectifyAioMsg">
          <el-input
            style="width:260px;margin-right:60px;"
            maxLength="50"
            v-model="form.rectifyAioMsg"
            placeholder="请输入一体机通知模板"
            clearable
            size="small"
          />
        </el-form-item>
        <el-form-item label="站内信通知模板" prop="rectifyAppMsg">
          <el-input
            style="width:260px;margin-right:60px;"
            maxLength="50"
            v-model="form.rectifyAppMsg"
            placeholder="请输入站内信通知模板"
            clearable
            size="small"
          />
        </el-form-item>
      </div>
      <p class="bottom-button-box add-button-one-90" @click="submitForm" v-hasPermiRouter="['laboratory:checkConfig:edit']">保存</p>
    </el-form>
  </div>
</template>

<script>
import { listCheckConfig,
  updateCheckConfig } from "@/api/securityCheck/index";

export default {
  name: "CheckConfig",
  data() {
    return {
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 表单参数
      form: {},
      // 表单校验
      rules: {
        checkSmsMsg: [
          { required: true, message: "请输入短信通知模板", trigger: "blur" },
          { required: true, message: "请输入短信通知模板", validator: this.spaceJudgment, trigger: "blur" }
        ],
        checkAioMsg: [
          { required: true, message: "请输入一体机通知模板", trigger: "blur" },
          { required: true, message: "请输入一体机通知模板", validator: this.spaceJudgment, trigger: "blur" }
        ],
        checkAppMsg: [
          { required: true, message: "请输入站内信通知模板", trigger: "blur" },
          { required: true, message: "请输入站内信通知模板", validator: this.spaceJudgment, trigger: "blur" }
        ],
        rectifySmsMsg: [
          { required: true, message: "请输入短信通知模板", trigger: "blur" },
          { required: true, message: "请输入短信通知模板", validator: this.spaceJudgment, trigger: "blur" }
        ],
        rectifyAioMsg: [
          { required: true, message: "请输入一体机通知模板", trigger: "blur" },
          { required: true, message: "请输入一体机通知模板", validator: this.spaceJudgment, trigger: "blur" }
        ],
        rectifyAppMsg: [
          { required: true, message: "请输入站内信通知模板", trigger: "blur" },
          { required: true, message: "请输入站内信通知模板", validator: this.spaceJudgment, trigger: "blur" }
        ],
      }
    };
  },
  created() {
    this.getList();
  },
  methods: {
    /** 查询检查推送信息配置列表 */
    getList() {
      this.loading = true;
      listCheckConfig().then( response => {
        this.$set(this,'form',response.data);
        this.loading = false;
      });
    },
    /** 提交按钮 */
    submitForm() {
      this.$refs["form"].validate(valid => {
        if (valid) {
          this.loading = true;
          updateCheckConfig(this.form).then( response => {
            this.msgSuccess("保存成功")
            this.loading = false;
          });
        }
      });
    },
  }
};
</script>

<style scoped lang="scss">
  .checkConfig{
    flex:1;
    display: flex;
    flex-direction: column;
    overflow: hidden !important;
    box-shadow: 0 0 8px 2px rgba(0, 0, 0, 0.1);
    padding: 0 20px !important;
    .checkConfigPage{
      flex:1;
      display: flex;
      flex-direction: column;
      overflow: hidden !important;
      .top-box{
        flex:1;
        overflow-y: scroll;
      }
    }
    .bottom-button-box{
      width:100px;
      margin:20px auto;
    }
    .form-title{
      border-bottom:1px solid #dedede;
      padding:10px 0 20px;
    }
  }
</style>
