<!-- 园区介绍 -->
<template>
    <div class="content">
        <div style="font-size:18px;font-weight: bold;margin-bottom:20px;">{{ info.title }}</div>
        <div>
            <tinymce v-model="info.content" :height="300" width="80%" menubar="" />
            <div style="margin:20px 0;">
                <!-- <el-button @click="item.isEdit = !item.isEdit" type="primary">编辑</el-button> -->
                <el-button @click="save()" type="primary">保存</el-button>
            </div>
        </div>
    </div>
</template>
<script>
import Tinymce from '@/components/Tinymce'
import { introductionModule, editModule } from '@/api/module'
export default {
    data() {
        return {
            info: ''
        }
    },
    components: { Tinymce },
    mounted() {
        this.getModule()
    },
    methods: {
        getModule() {
            introductionModule().then(res => {
                const { code, data, msg } = res
                if (code === 200) {
                    this.info = data
                } else {
                    this.$message.error(msg)
                }
            })
        },
        save() {
            const { content, title, id } = this.info
            if (!content) {
                this.$message.error('内容不能为空')
                return
            }
            editModule({ id, title, content }).then(res => {
                const { code, msg } = res
                if (code === 200) {
                    this.$message.success('已保存')
                } else {
                    this.$message.error(msg)
                }
            })
        },
    }

}
</script>
<style lang="scss" scoped>
.content {
    .title {
        font-size: 18px;
        font-weight: bold;
        margin-bottom: 12px;
    }
}
</style>