<template>
    <!-- 弹出框表单 -->
    <el-drawer
            :title="title"
            :visible.sync="open"
            :direction="direction"
            :destroy-on-close="true"
            size="60%">
        <el-form ref="form" :model="form" :rules="rules" label-width="120px">
            <el-row>
                                <Field :span="20" label="标题" prop="title" v-model="form.title" type="textarea" placeholder="请输入标题"/>
                <Field :span="20" label="内容"><editor v-model="form.content" :min-height="256"/></Field>
                <Field :span="20" label="图片"><imageUpload v-model="form.imagePath" prePath="/file/preview"/></Field>
                <Field :span="20" label="备注" prop="remark" v-model="form.remark" type="textarea" placeholder="请输入备注"/>

            </el-row>

            <form-buttons @submit='submitForm' v-if="pageInfo.type!='view'" noCancelBtn />
        </el-form>

    </el-drawer>
</template>

<script>
    import form from "@/assets/mixins/formdialog";
    export default {
        name: "AdvantageDetail",
        mixins: [form],
        components: {

        },
        created() {
            this.changePath("advantage")
        },
        data() {
            return {
                // 遮罩层
                loading: true,
                // 弹出层标题
                title: "公司优势特点",
                // 是否显示弹出层
                open: false,
                direction:"rtl",
                toString:[
                ],
                toDate:[
                ],
                // 表单校验
                rules: {
                }
            };
        },

        methods: {
            /** 编辑 */
            edit(row) {
                this.reset()
                this.query = { id: row.id };
                this.urls.currUrl ="advantage/edit";
                this.getData();
                this.pageInfo.type="edit"
                this.title = "修改公司优势特点";
            },
            /** 新增 */
            add(row) {
                this.reset()
                this.urls.currUrl = "advantage/add";
                this.getData();
                this.pageInfo.type="add"
                this.title = "新增公司优势特点";
            },
            /** 查看*/
            view(row) {
                this.reset()
                this.query = { id: row.id };
                this.urls.currUrl ="advantage/view";
                this.getData();
                this.pageInfo.type="view"
                this.title = "公司优势特点详细";
            },
            /**取消按钮 */
            cancel() {
                this.open = false;
            },
            /**获取数据后弹框 */
            afterRender(data) {
                this.open = true;
            },

            afterSubmit(data) {
                this.open = false;
                this.$emit("ok");
            },

            // 表单重置
            reset() {
                this.form = {
                    title : null,
                    content : null,
                    imagePath : null,
                    remark : null,
                };
                this.resetForm("form");
            },
            resetForm(refName) {
                if (this.$refs[refName]) {
                    this.$refs[refName].resetFields();
                }
            },
        },
    };
</script>
