<template>
  <div class="add_page">
    <el-form
      ref="form" :model="form" :rules="rules"
      required
      label-width="100px"
    >
      <el-form-item prop="sensitiveKeyword" label="敏感词">
        <el-input v-model="form.sensitiveKeyword" />
      </el-form-item>
    </el-form>
    <div class="btn_list">
      <el-button type="primary" @click="confirm">确定</el-button>
      <el-button class="delete" @click="cancel">取消</el-button>
    </div>
  </div>
</template>

<script>
export default {
  props: {
    dialog: {
      type: Object,
      default: () => {}
    }
  },
  data() {
    return {
      form: {
        sensitiveKeyword: this.dialog.info.sensitiveKeyword || ''
      },
      rules: {
        sensitiveKeyword: [
          { required: true, message: '请输入敏感词', trigger: 'blur' }
        ]
      }
    }
  },
  methods: {
    confirm() {
      const vm = this
      vm.$refs.form.validate((valid) => {
        if (valid) {
          vm.$emit('add', vm.form)
        }
      })
    },
    cancel() {
      this.$emit('close')
    }
  }
}
</script>

<style lang='less' scoped>
.add_page {
    padding: 0 50px;
    .btn_list {
        padding-top: 20px;
        text-align: center;
    }
}
/deep/.el-button {
    // margin-right: 30px;
}
</style>
