<template>
    <div class="app-container calendar-list-container" style="padding-bottom: 80px;">
        <el-form :rules="rules" ref="dataForm" :model="dataForm" status-icon label-position="left" label-width="100px" style='width: 85%; margin-left:50px;'>
         <el-form-item  label="标题" prop="title">
              <el-input v-model="dataForm.title"></el-input>
            </el-form-item>
            <el-form-item
              style="width: 100%"
              label="内容"
              prop="content"
            >
              <tinymce v-model="dataForm.content" ref="tinymce"></tinymce>
            </el-form-item>
  
        </el-form>
        <el-button style="float: right;margin-right: 120px;" type="primary" @click="updateData">修改</el-button>
    
        
    </div>
   
  </template>
  
  <style>
    
  </style>
  
  
  <script>
   import {likeRulesDetail, updateLikeRules} from "@/api/yeZhanManage/likeRules";
    import waves from "@/directive/waves"; // 水波纹指令
    import Tinymce from '@/components/Tinymce'
    export default {
    components: { Tinymce },
    directives: { waves },
    data() {
      return {
        dataForm: {
          type:'interactiveRule',
          title: '',
          content: "",
        },
        dialogFormVisible: false,
        rules: {
            title: [{ required: true, message: "标题不能为空", trigger: "blur" }],
            content: [{ required: true, message: "规则不能为空", trigger: "blur" }],
        },
      }
    },
    created() {
        this.getDetail();
    },
    methods: {
    
      getDetail() {
          this.loading = true
          likeRulesDetail({noticeType:'interactiveRule'}).then(response => {
            this.dataForm.title = response.data.data.title;
            this.dataForm.content = response.data.data.content;
            this.dataForm.id = response.data.data.id;
            this.loading = false;
          }).catch(() => {})
      },
      updateData() {
        this.$refs['dataForm'].validate((valid) => {
          if (valid) {
            this.loading = true;
            updateLikeRules(this.dataForm).then(() => {
              this.loading = false;
                this.$notify({
                  title: '成功',
                  message: '更新成功',
                  type: 'success',
                  duration: 2000
                })
                this.getDetail()
              }) 
          }
        })
      },
  
      
    }
  }
  </script>
  