<template>
  <div>
    <el-card>
      <el-page-header @back="goback" content="创建公告"></el-page-header>
    </el-card>
    <div class="body">
      <div class="s-body">

        <el-form :model="ruleForm" :rules="rules" ref="ruleForm" label-width="100px" class="demo-ruleForm">
          <el-form-item label="公告名称:  " prop="name">
            <el-input v-model="ruleForm.name"></el-input>
          </el-form-item>


          <el-form-item label="发布时间:  " required>
            <el-col>
              <el-form-item prop="date2">
                <el-time-picker placeholder="选择时间" v-model="ruleForm.date2" style="width: 100%;"></el-time-picker>
              </el-form-item>
            </el-col>
          </el-form-item>
          <el-form-item label="公告内容:  " prop="name">
            <mavon-editor ref="md" v-model="notice.noticeContent" style="height:calc(100vh - 260px)" />

            <el-button type="danger" @click="dialogVisible = true " style='float:right'>发布公告</el-button>

            <el-dialog title="提示" :visible.sync="dialogVisible" width="30%" :before-close="handleClose">
              <span>确认发布公告吗？</span>
              <span slot="footer" class="dialog-footer">
                <el-button @click="dialogVisible = false">取 消</el-button>
                <el-button type="primary" @click="dialogVisible = false">确 定</el-button>
              </span>
            </el-dialog>
          </el-form-item>
        </el-form>
      </div>
    </div>
  </div>
</template>


<script>
export default {
  name: 'Addnotice',

  data() {
    return {
      ruleForm: {
        name: '',
        date2: '',
      },
      notice: {
        noticeContent: ""
      },
      rules: {
        name: [
          { required: true, message: '请输入公告名称', trigger: 'blur' },

        ],
        date2: [
          { type: 'date', required: true, message: '请选择时间', trigger: 'change' }
        ],
      },
      dialogVisible:false
    }
  },

  methods: {
    goback() {
      window.history.go(-1)
    },
    submitForm(formName) {
      this.$refs[formName].validate((valid) => {
        if (valid) {
          alert('submit!');
        } else {
          console.log('error submit!!');
          return false;
        }
      });
    },
    resetForm(formName) {
      this.$refs[formName].resetFields();
    },
    handleClose(done) {
        this.$confirm('确认关闭？')
          .then(_ => {
            done();
          })
          .catch(_ => {});
      }
    


  }


}
</script>

<style scoped>
.body {
  margin: auto;
  width: 80%;
  border: solid 2px rgb(239, 231, 231);
  margin-top: 50px;
  border-radius: 10px;
}

.s-body {
  margin: 0 auto;
  width: 70%;
  /* background-color: pink; */
  padding-top: 80px;
}
</style>