<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 label="标题" prop="title" v-model="form.title" type="textarea" placeholder="请输入标题"/>
                            <Field label="图片"><imageUpload v-model="form.imageUrl1" prePath="/file/preview"/></Field>
                            <Field label=""><imageUpload v-model="form.imageUrl2" prePath="/file/preview"/></Field>
                            <Field label=""><imageUpload v-model="form.imageUrl3" prePath="/file/preview"/></Field>
                            <Field label=""><imageUpload v-model="form.imageUrl4" prePath="/file/preview"/></Field>
                            <Field label=""><imageUpload v-model="form.imageUrl5" prePath="/file/preview"/></Field>
                            <Field label="产品类型id" prop="typeId" v-model="form.typeId" placeholder="请输入产品类型id"/>
                            <Field label="描述内容" prop="introduction" v-model="form.introduction" 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: "TypeDetailsDetail",
        mixins: [form],
        components: {

        },
        created() {
            this.changePath("type/details")
        },
        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 ="type/details/edit";
                this.getData();
                this.pageInfo.type="edit"
                this.title = "修改类型详细";
            },
            /** 新增 */
            add(row) {
                this.reset()
                this.urls.currUrl = "type/details/add";
                this.getData();
                this.pageInfo.type="add"
                this.title = "新增类型详细";
            },
            /** 查看*/
            view(row) {
                this.reset()
                this.query = { id: row.id };
                this.urls.currUrl ="type/details/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,
                    imageUrl1 : null,
                    imageUrl2 : null,
                    imageUrl3 : null,
                    imageUrl4 : null,
                    imageUrl5 : null,
                    typeId : null,
                    introduction : null,
                };
                this.resetForm("form");
            },
            resetForm(refName) {
                if (this.$refs[refName]) {
                    this.$refs[refName].resetFields();
                }
            },
        },
    };
</script>
