<template>
    <el-card class="tjm_card_style_custom">
        <div class="tjm_card_table">
            <el-table v-loading="loading" row-key="id" header-cell-class-name="tjm_card_table_header" height="400" :data="tableData" border @row-click="table_detail">
                <el-table-column type="index" label="序号" width="55"></el-table-column>
                <el-table-column label="回复人" prop="createName" min-width="120" show-overflow-tooltip></el-table-column>
                <el-table-column label="回复内容" prop="messageContent" min-width="180" show-overflow-tooltip></el-table-column>
                <el-table-column label="回复日期" min-width="120" show-overflow-tooltip>
                    <template #default="scope">{{ scope.row.createTime.split(" ")[0] }}</template>
                </el-table-column>
            </el-table>
        </div>
        <div class="tjm_card_pagination">
            <yh-pagination v-model:pageNo="params.page" v-model:pageSize="params.size" :total="total" @paginationChange="reloadTable"></yh-pagination>
        </div>
    </el-card>
</template>

<script>
import API from "@/api/policy/toDo";
import yhPagination from "@/components/Pagination/index.vue";

export default {
    components: {
        yhPagination
    },

    data() {
        return {
            loading: false,
            params: {
                page: 1,
                size: 10
            },

            total: 0,
            tableData: []
        }
    },

    mounted() {
        this.reloadTable();
    },

    methods: {
        reloadTable() {
            this.loading = true;
            API.msg(this.params).then(res => {
                this.loading = false;
                if (res.code === 200) {
                    this.tableData = res.data.records;
                    this.total = res.data.total;
                } else ElMessage.error(res.msg);
            }).catch(() => this.loading = false);
        },

        table_detail({ refId, policyName, policyDocNo }) {
            this.$emit("replyAll", { id: refId, name: policyName, docNo: policyDocNo });
        }
    }
}
</script>

<style lang="scss" scoped>
.tjm_card_table {
  margin-top: 0;
}
</style>