<template>
    <div>
        <div>
            <el-row>
                <div class="content_title">
                    <span>互动提问</span>
                    <button @click="open()">
                        <img src="../../assets/icon_edit.png" alt="" />
                        <span>我要提问</span>
                    </button>
                </div>
            </el-row>
            <el-row>
                <div class="content_list">
                    <ul>
                        <li
                            v-for="item in tableData"
                            :key="item.id"
                            @click="$router.push({ name: 'interactDetail2', query: { id: item.id } })"
                        >
                            <div style="width:500px">
                                <span class="list_con">
                                    {{ item.title }}
                                </span>
                            </div>
                            <span class="author">{{ item.nickname }}</span>
                            <span class="num">回复&nbsp;{{ item.commentNum }}</span>
                            <span class="time">{{ item.createdAt }}</span>
                        </li>
                    </ul>
                </div>
            </el-row>
            <el-row class="pagination">
                <el-pagination
                    @size-change="onSizeChange"
                    @current-change="onCurrentChange"
                    :current-page="page"
                    :page-sizes="[10, 20, 30, 40, 50]"
                    :page-size="pageSize"
                    layout="total, sizes, prev, pager, next, jumper"
                    :total="totalElements"
                >
                </el-pagination>
            </el-row>
        </div>
        <!-- 弹窗 -->
        <insert :dataType="dataType" :outerVisible="outerVisible" @toColse="toColse()" :title="title" :key="0"></insert>
    </div>
</template>

<script>
import pageableTable from '@/mixins/pageableTable';
import insert from './insert';
export default {
    mixins: [pageableTable],
    name: 'problem',
    components: {
        insert
    },
    data() {
        return {
            // url: '/topic/all',
            url: '/post/allDTO',
            outerVisible: false,
            query: { type: 'QA' },
            title: '',
            dataType: 'FORUM'
        };
    },
    computed: {
        userInfo() {
            return this.$store.state.userInfo;
        }
    },
    methods: {
        beforeGetData() {
            return { search: this.search, query: this.query, sort: 'createdAt,desc' };
        },
        open() {
            if (this.$store.state.userInfo) {
                this.title = '发布问题';
                this.dataType = 3;
                this.outerVisible = true;
            } else {
                this.$alert('用户未登录，请先进行登录?', '提示', {
                    confirmButtonText: '确定',
                    type: 'warning'
                });
            }
        },
        toColse(show) {
            this.getData();
            this.outerVisible = show;
        }
    }
};
</script>
<style lang="less" scoped>
.content_title {
    height: 60px;
    line-height: 60px;
    box-sizing: border-box;
    padding-bottom: 20px;
    border-bottom: #f2f3f5 1px solid;
    > span {
        font-size: 16px;
        color: #000000;
        line-height: 30px;
        font-weight: 700;
    }
    button {
        width: 130px;
        height: 36px;
        background: #bf1616;
        border-radius: 4px;
        float: right;
        cursor: pointer;
        margin-top: 12px;
        display: flex;
        padding-left: 22px;
        align-items: center;
        img {
            width: 18px;
            height: 18px;
            margin-right: 6px;
        }
        span {
            color: #ffffff;
            font-size: 13px;
        }
    }
}

.content_list > ul {
    li {
        display: flex;
        align-items: center;
        justify-content: space-between;
        margin-top: 20px;
        cursor: pointer;

        // img {
        //     width: 18px;
        //     height: 18px;
        //     margin-right: 6px;
        // }
        i {
            font-style: normal;
            font-size: 11px;
            // width: 18px;
            height: 18px;
            line-height: 18px;
            background: #bf1616;
            border-radius: 2px;
            color: #fff;
            text-align: center;
            margin-right: 6px;
            padding: 0 3px;
            display: none;
            // overflow: hidden;
        }
        div {
            display: flex;
            align-items: center;
        }
        .show {
            display: block;
        }
        .list_con {
            width: 496px;
            font-size: 14px;
            color: #000000;
            overflow: hidden;
            white-space: nowrap;
            text-overflow: ellipsis;
        }
        .time {
            width: 25%;
            font-size: 14px;
            color: #939599;
        }
        .author {
            width: 20%;
            color: #939599;
            font-size: 14px;
        }
        .num {
            width: 15%;
            font-size: 14px;
            color: #c8c9cc;
        }
        &:hover .list_con {
            color: #bf1616;
        }
    }
}
.pagination {
    margin-top: 40px;
    text-align: center;
}
</style>
<style lang="less">
.el-dialog {
    overflow: hidden;
    .el-button {
        width: 100px;
        height: 36px;
        border-radius: 4px;
        font-size: 13px;
        color: #ffffff;
    }
    .back {
        background: #c4c7cc;
    }
    .sub {
        background: #bf1616;
    }
    .dialog-footer {
        float: right;
        padding: 0 40px 40px 0;
    }

    .el-input {
        width: 200px;
    }
    .el-form {
        display: flex;
        flex-wrap: wrap;
        .el-form-item {
            margin-right: 46px;
        }
    }
}
.el-dialog--center .el-dialog__body {
    padding: 30px 40px;
}
</style>
