<!--
 * @Author: your name
 * @Date: 2022-01-03 14:38:06
 * @LastEditTime: 2022-08-25 15:47:30
 * @LastEditors: chenkangxu
 * @Description: 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 * @FilePath: \background-front-end\src\components\comment\comment.vue
-->
<template>
    <div>
        <modal :modalConfig="modalConfig">
            <cesTable
            style="padding:0 30px;"
            :loading="loading"
            :tableCols="pageData.tableCols"
            :tableData="pageData.tableData"
            :tablePage="pageData.tablePage"
            slot="dialog__content"
            @handleCurrentChange="findAll"
            @handleSizeChange="findAll"
            />
        </modal>
    </div>
</template>
<script>
import cesTable from '../common/table/custable.vue'
import modal from '../common/modal/modal.vue'
export default {
    components:{
        modal,
        cesTable
    },
    watch:{
        "modalConfig.show":{
            handler:function(val){
                if(val){
                    this.findAll()
                }
            }
        }
    },
    data(){
        return{
            //加载动画
            loading:false,
            modalConfig:{
                title:'评论',
                show:false,
                width:'900px'
            },
            pageData:{
                tableCols:[
                    {label:'头像',prop:'createHeadUrl',type:'elImage',width:'100px'},
                     {label:'姓名',prop:'createUsername'},
                    {label:'评论内容',prop:'commentContent',width:'300px'},
                     {label:'评论时间',prop:'createTime'},
                ],
                tableData:[],
                tablePage:{
                        currentPage: 1,
                        pageSize: 5,
                        pageTotal: 0,
                        pageSizeRange: [5, 10, 20, 50],
                        }
            },
        }
    },
    methods:{
        findAll(){
            this.loading=true;
             let data={};
                    data.page=this.pageData.tablePage.currentPage;
                    data.limit=this.pageData.tablePage.pageSize;
                    data.parentId=this.parentId
                    data.type=this.type
                    this.$api.getCommentList(data).then(res=>{
                        this.pageData.tableData=res.data.page.list;
                        this.pageData.tablePage.pageTotal=res.data.page.totalCount
                        this.loading=false;
                    })
        }
    },
    props:{
        type:{type:String,default:''},
        parentId:{type:String,default:''}
    }
}
</script>
<style lang="scss" scoped>
    
</style>