<template>
    <div class="page">
        <LayoutTable  ref="layouttable" :data="tableData" :config="tableConfig" notDel notAdd>
            <!-- 热门0为非热门1为热门 -->
            <div slot="table-search-left" class="onlyhot">
                <el-checkbox
                :key="0"
                v-model="isreply"
                :checked="isreply"
                @change="changeIsReply"
                >
                </el-checkbox>
                只看未回复
            </div>
        </LayoutTable>


        <drawer-show ref="drawerform" @ok="getData" />
    </div>
</template>

<script>
    /** 表单弹出框模式需引入 */
    import drawerShow from "./drawershow";
    import table from "@/assets/mixins/table";
    export default {
        name: "FeedbackList",
        components: {
            drawerShow
        },
        mixins: [table],
        created() {
        },
        mounted() {
            // 重写查询
            this.$refs.layouttable.$refs.searchform.onSubmit = this.onSearch
            // 重写搜索清除
            this.$refs.layouttable.$refs.searchform.cleanForm = this.cleanForm
        },
        methods: {
            /** 重写新增方法 */
            toAdd(row) {
                this.$refs.drawerform.add(row);
            },
            /** 重写编辑方法 */
            toEdit(row) {
                this.$refs.drawerform.edit(row);
            },
            /** 重写查看方法 */
            toView(row) {
                this.$refs.drawerform.view(row);
            },
            // 重写查询
            onSearch(){
                if(this.isreply){
                    this.$refs.layouttable.$refs.searchform.form = Object.assign({}, this.$refs.layouttable.$refs.searchform.form, {reply:1})
                }
                let { path, query } = this.$refs.layouttable.$refs.searchform.$route;
                let data = this.$refs.layouttable.$refs.searchform.decode(this.$refs.layouttable.$refs.searchform.form);
                this.$refs.layouttable.$refs.searchform.$router.push({
                    path: path,
                    query: Object.assign({}, query, data),
                });
            },
            // 重写搜索清除
            cleanForm(){
                this.isreply = false
                this.$refs.layouttable.$refs.searchform.form.reply = undefined
                this.$forceUpdate()
                this.$refs.layouttable.$refs.searchform.clean();
                this.$refs.layouttable.$refs.searchform.onSubmit();
            },
            changeIsReply(val){
                this.isreply = val
            },

        },
        data() {
            return {
                isreply:false,
                config: {
                    search: [
                        // {
                        //     name: "createTime",
                        //     type: "date",
                        //     label: "提交时间",
                        //     fuzzy: true,
                        //     valueFormat:"yyyy-MM-dd"
                        // },
                        {
                            name: "content",
                            type: "text",
                            label: "内容",
                            fuzzy: true,
                        },
                        {
                            name: "feedbackName",
                            type: "text",
                            label: "真实姓名",
                            fuzzy: true,
                        },
                    ],
                    columns: [
                        // {type: "selection", width: 60},
                        {type: "index",label: "序号",width: 50},


                        {label: "内容", prop: "content",formatter: this.formatter},

                      {label: "真实姓名", prop: "feedbackName",formatter: this.formatter},
                      {label: "联系电话", prop: "contactInfo",formatter: this.formatter},

                      {label: "单位名称", prop: "companyName",formatter: this.formatter},


                      {label: "邮箱地址", prop: "email",formatter: this.formatter},

                      {label: "提交时间", prop: "createTime", formatter: this.formatterDate},


                        {label: "是否回复 ", prop: "reply",formatter: this.formatter},

                        {label: "回复人", prop: "replyPerson",formatter: this.formatter},

                        // {label: "反馈类型 ", prop: "feedbackType",formatter: this.formatter},

                        // {label: "附件名称，多个逗号分割", prop: "fileName"},

                        // {label: "附件地址，多个逗号分割", prop: "filePath"},

                        // {label: "处理人名称", prop: "processName"},

                        // {label: "处理状态", prop: "processStatus",formatter: this.formatter},

                        // {label: "处理意见", prop: "processComments"},

                        {label: "回复时间", prop: "processTime", formatter: this.formatterDate},

                        // {label: "创建用户", prop: "createUserId", formatter: this.formatter},
                        {
                            label: "操作",
                            width: 240,
                            formatter: row => {
                                return (
                                    <el-button type="text" icon="el-icon-edit"  size='mini' onClick={()=>{this.toEdit(row)}}  title="详情">详情</el-button>
                            );
                            }
                        }
                    ]
                }
            };
        }
    };
</script>
