<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="内容"><editor v-model="form.content" :min-height="256"/></Field>
                            <Field label="是否公开 " prop="isShow" v-model="form.isShow" type="select" :enumData="dict.isShow" placeholder="请选择是否公开 "/>
                            <Field label="反馈人姓名" prop="feedbackName" v-model="form.feedbackName" placeholder="请输入反馈人姓名"/>
                            <Field label="联系方式" prop="contactInfo" v-model="form.contactInfo" placeholder="请输入联系方式"/>
                            <Field label="身份证号" prop="idCard" v-model="form.idCard" placeholder="请输入身份证号"/>
                            <Field label="地址" prop="Address" v-model="form.Address" placeholder="请输入地址"/>
                            <Field label="是否回复 " prop="reply" v-model="form.reply" type="select" :enumData="dict.reply" placeholder="请选择是否回复 "/>
                            <Field label="回复"><editor v-model="form.replyContent" :min-height="256"/></Field>
                            <Field label="反馈类型 " prop="feedbackType" v-model="form.feedbackType" type="select" :enumData="dict.feedbackType" placeholder="请选择反馈类型 "/>
                            <Field label="附件名称，多个逗号分割" prop="fileName" v-model="form.fileName" placeholder="请输入附件名称，多个逗号分割"/>
                            <Field label="附件地址，多个逗号分割"><fileUpload v-model="form.filePath"  prePath="/file/fileupload"/></Field>
                            <Field label="处理人id" prop="processId" v-model="form.processId" placeholder="请输入处理人id"/>
                            <Field label="处理人名称" prop="processName" v-model="form.processName" placeholder="请输入处理人名称"/>
                            <Field label="处理状态" prop="processStatus" v-model="form.processStatus" type="select" :enumData="dict.processStatus" placeholder="请选择处理状态"/>
                            <Field label="处理意见" prop="processComments" v-model="form.processComments" placeholder="请输入处理意见"/>
                            <Field label="处理时间" prop="processTime" v-model="form.processTime" type="date" />
                            <Field 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: "FeedbackDetail",
        mixins: [form],
        components: {

        },
        created() {
            this.changePath("feedback")
        },
        data() {
            return {
                // 遮罩层
                loading: true,
                // 弹出层标题
                title: "反馈信息",
                // 是否显示弹出层
                open: false,
                direction:"rtl",
                toString:[
                    "isShow",
                    "reply",
                    "feedbackType",
                    "processStatus",
                ],
                toDate:[
                    "processTime",
                ],
                // 表单校验
                rules: {
                    title: [
                        {required: true,message: "请输入标题", trigger: "blur" },
                        {max: 512,message: "最多只能录入512个字符",trigger: "blur",},
                    ],
                    isShow: [
                        {required: true,message: "请输入是否公开 ", trigger: "blur" },
                    ],
                    feedbackName: [
                        {required: true,message: "请输入反馈人姓名", trigger: "blur" },
                        {max: 64,message: "最多只能录入64个字符",trigger: "blur",},
                    ],
                    contactInfo: [
                        {required: true,message: "请输入联系方式", trigger: "blur" },
                        {max: 64,message: "最多只能录入64个字符",trigger: "blur",},
                    ],
                    idCard: [
                        {required: true,message: "请输入身份证号", trigger: "blur" },
                        {max: 64,message: "最多只能录入64个字符",trigger: "blur",},
                    ],
                    Address: [
                        {required: true,message: "请输入地址", trigger: "blur" },
                        {max: 64,message: "最多只能录入64个字符",trigger: "blur",},
                    ],
                    reply: [
                        {required: true,message: "请输入是否回复 ", trigger: "blur" },
                    ],
                    replyContent: [
                        {required: true,message: "请输入回复", trigger: "blur" },
                        {max: 64,message: "最多只能录入64个字符",trigger: "blur",},
                    ],
                    feedbackType: [
                        {required: true,message: "请输入反馈类型 ", trigger: "blur" },
                    ],
                    fileName: [
                        {required: true,message: "请输入附件名称，多个逗号分割", trigger: "blur" },
                        {max: 64,message: "最多只能录入64个字符",trigger: "blur",},
                    ],
                    createTime: [
                        {required: true,message: "请选择创建时间" },
                    ],
                }
            };
        },

        methods: {
            /** 编辑 */
            edit(row) {
                this.reset()
                this.query = { id: row.id };
                this.urls.currUrl ="feedback/edit";
                this.getData();
                this.pageInfo.type="edit"
                this.title = "修改反馈信息";
            },
            /** 新增 */
            add(row) {
                this.reset()
                this.urls.currUrl = "feedback/add";
                this.getData();
                this.pageInfo.type="add"
                this.title = "新增反馈信息";
            },
            /** 查看*/
            view(row) {
                this.reset()
                this.query = { id: row.id };
                this.urls.currUrl ="feedback/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 : "",
                    content : "",
                    isShow : 0,
                    feedbackName : "",
                    contactInfo : "",
                    idCard : "",
                    Address : "",
                    reply : 0,
                    replyContent : "",
                    feedbackType : 1,
                    fileName : "",
                    filePath : "",
                    processId : null,
                    processName : "",
                    processStatus : 1,
                    processComments : "",
                    processTime : null,
                    remark : "",
                };
                this.resetForm("form");
            },
            resetForm(refName) {
                if (this.$refs[refName]) {
                    this.$refs[refName].resetFields();
                }
            },
        },
    };
</script>
