<template>
  <div class="app-container">
    <page-header content="添加"></page-header>
    <el-form ref="dataForm" :model="dataForm" :rules="dataRules" label-width="140px">
      <el-form-item label="备注" prop="remark">
        <el-input v-model.trim="dataForm.remark" class="input-width" placeholder="请输入备注" clearable></el-input>
      </el-form-item>
    </el-form>
    <page-footer showConfirm width="800px" @cancel="onCancel" @confirm="onConfirm"></page-footer>
  </div>
</template>

<script>

import {validateNotEmpty} from "@/utils/validate";

export default {
  name: "SystemDatabaseBackupEdit",
  data() {
    return {
      dataForm: {
        remark: undefined, // 备注
      },


      dataRules: {
        'remark': [{validator: validateNotEmpty, errorMessage: "备注不能为空", required: true, trigger: 'blur'}],
      },
    }
  },

  watch: {},

  mounted() {
    this.initData();
  },

  methods: {
    // 初始化数据
    initData() {
    },

    // 取消
    onCancel() {
      this.$router.back();
    },

    // 确认
    onConfirm() {
      this.$refs['dataForm'].validate((valid) => {
        if (valid) {
          this.$axios.post("/v1/system/database/backup/add", this.dataForm).then(() => {
            this.$message.success("保存成功！");
            this.$eventBus.$emit("SystemDatabaseBackupAdd");
            this.onCancel();
          });
        }
      });
    },
  },

}
</script>
<style lang="scss" scoped>
.app-container {
  .input-width {
    width: 250px;
  }
}
</style>
