<style lang="less">
    @import '../../styles/common.less';
    .ivu-card-head {
        p {
            height: 32px;
            line-height: 32px;
        }
        button {
            float: right;
        }
    }
</style>

<template>
    <div>
        <Row class="margin-top-10">
            <Col>
            <Card>
                <p slot="title">企业介绍内容编辑</p>
                <div class="edittable-table-height-con">
                    <Form>
                        <FormItem label="内容">
                            <editor :editor-content="introduce"></editor>
                        </FormItem>
                    </Form>
                    <div class="submit">
                        <Button @click="handlePublish" :loading="publishLoading" icon="ios-checkmark" size="large" type="primary">提交</Button>
                    </div>
                </div>
            </Card>
            </Col>
        </Row>
    </div>
</template>

<script>
    import tinymce from 'tinymce';
    import editor from '../main-components/editor'
    export default {
        name: 'introduce',
        components: {
            editor
        },
        data() {
            return {
                introduce: '',
                publishLoading: false
            };
        },
        methods: {
            handlePublish() {
                let introduce = tinymce.activeEditor.getContent();
                if (introduce) {
                    this.publishLoading = true;
                    this.axios.post("/introduce/store", {
                        introduce
                    }).then((res) => {
                        if (res.data.status == 0) {
                            this.$Message.success('操作成功！');
                            this.publishLoading = false;
                        }
                    });
                } else {
                    this.$Message.warning('内容不能为空！');
                }
            },
            getData() {
                this.axios.get("/introduce", {})
                .then((res) => {
                    if (res.data.status == 0) {
                        this.introduce = res.data.data.introduce;
                    }
                });
            }
        },
        mounted() {
            this.getData();
        }
    };
</script>
