<template>
    <!-- 弹出框表单 -->
    <el-drawer
            :title="title"
            :visible.sync="open"
            :direction="direction"
            :destroy-on-close="true"
            size="50%">
        <el-form ref="form" :model="form" :rules="rules" label-width="120px">
            <el-row>
                <Field :span="20" label="案例名称" prop="name" v-model="form.name" type="textarea" placeholder="请输入案例名称"/>
                <Field :span="20" label="案例种类" prop="exampleType" v-model="form.exampleType" type="radio" :enumData="dict.exampleType" />
                <Field :span="20" label="案例图片"><imageUpload v-model="form.image1" prePath="/file/preview"/></Field>
                <Field :span="20" label=""><imageUpload v-model="form.image2" prePath="/file/preview"/></Field>
                <Field :span="20" label=""><imageUpload v-model="form.image3" prePath="/file/preview"/></Field>
                <Field :span="20" label=""><imageUpload v-model="form.image4" prePath="/file/preview"/></Field>
                <Field :span="20" label=""><imageUpload v-model="form.image5" prePath="/file/preview"/></Field>
                <Field :span="20" label=""><imageUpload v-model="form.image6" prePath="/file/preview"/></Field>
                <Field :span="20" label=""><imageUpload v-model="form.image7" prePath="/file/preview"/></Field>
                <Field :span="20" label=""><imageUpload v-model="form.image8" prePath="/file/preview"/></Field>
                <Field :span="20" label=""><imageUpload v-model="form.image9" prePath="/file/preview"/></Field>
                <Field :span="20" label=""><imageUpload v-model="form.image10" prePath="/file/preview"/></Field>
                <Field :span="20" label=""><imageUpload v-model="form.image11" prePath="/file/preview"/></Field>
                <Field :span="20" label=""><imageUpload v-model="form.image12" prePath="/file/preview"/></Field>
                <Field :span="20" label=""><imageUpload v-model="form.image13" prePath="/file/preview"/></Field>
                <Field :span="20" label=""><imageUpload v-model="form.image14" prePath="/file/preview"/></Field>
                <Field :span="20" label=""><imageUpload v-model="form.image15" prePath="/file/preview"/></Field>
                <Field :span="20" label=""><imageUpload v-model="form.image16" prePath="/file/preview"/></Field>

              <Field :span="20" label="内容" prop="content" v-model="form.content" type="textarea" placeholder="请输入内容"/>
                <Field :span="20" label="内容html"><editor v-model="form.contentHtml" :min-height="256"/></Field>

            </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: "ExampleDetail",
        mixins: [form],
        components: {

        },
        created() {
            this.changePath("example")
        },
        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 ="example/edit";
                this.getData();
                this.pageInfo.type="edit"
                this.title = "修改案例图片";
            },
            /** 新增 */
            add(row) {
                this.reset()
                this.urls.currUrl = "example/add";
                this.getData();
                this.pageInfo.type="add"
                this.title = "新增案例图片";
            },
            /** 查看*/
            view(row) {
                this.reset()
                this.query = { id: row.id };
                this.urls.currUrl ="example/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 = {
                    name : null,
                    exampleType : null,
                    image1 : null,
                    image2 : null,
                    image3 : null,
                    image4 : null,
                    image5 : null,
                    image6 : null,
                    image7 : null,
                    image8 : null,
                    image9 : null,
                    image10 : null,
                    image11 : null,
                    image12 : null,
                    image13 : null,
                    image14 : null,
                    image15 : null,
                    image16 : null,
                    content : null,
                    contentHtml : null,
                };
                this.resetForm("form");
            },
            resetForm(refName) {
                if (this.$refs[refName]) {
                    this.$refs[refName].resetFields();
                }
            },
        },
    };
</script>
