<template>
    <div class="container" style="padding: 30px">
        <el-form
            :model="queryParams"
            ref="queryForm"
            :inline="true"
            label-width="68px"
            style="display: flex; justify-content: space-between"
        >
            <div style="display: flex">
                <el-form-item label="用户名称" prop="userName">
                    <el-input v-model="queryParams.userName" placeholder="请输入用户名称" clearable size="small" />
                </el-form-item>
                <el-form-item>
                    <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
                    <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
                </el-form-item>
            </div>
        </el-form>
        <el-table v-loading="loading" :data="schoolList" :default-sort="{ prop: 'title1' }">
            <el-table-column label="序号" align="center" type="index" />
            <el-table-column label="评价用户" align="center" prop="user_name" />
            <el-table-column label="被评价用户" align="center" prop="appraisee_name" />
            <el-table-column label="评价星级" align="center" sortable prop="star" />
            <el-table-column label="评价文案" align="center" prop="content" />
            <el-table-column label="关联任务" align="center" prop="project_name" />
            <el-table-column label="评价时间" align="center" prop="create_time">
                 <template slot-scope="scope">
                    {{ parseTime(new Date(scope.row.create_time)) }}
                </template>
            </el-table-column>
            <el-table-column label="操作" align="center">
                <template slot-scope="scope">
                    <el-button size="mini" type="text" @click="delRow(scope.row)">删除</el-button>
                </template>
            </el-table-column>
        </el-table>
        <pagination
            v-show="total > 0"
            :total="total"
            :page.sync="queryParams.pageNum"
            :limit.sync="queryParams.pageSize"
            @pagination="getList"
        />
    </div>
</template>
<script>
import { getReviewList, delReview } from '@/api/system/myreview.js'
export default {
    name: 'peixunbaoming',
    data() {
        return {
            loading: false,
            schoolList: [{ title1: 3 }, { title1: 100 }],
            // 总条数
            total: 0,
            // 查询参数
            queryParams: {
                pageNum: 1,
                pageSize: 10,
                userName: null
            },
            visibleopen: false,
        }
    },
    created() {
        this.getList()
    },
    methods: {
        async getList() {
            this.loading = true
            try {
                const res = await getReviewList({...this.queryParams})
                this.loading = false
                this.total = res.total
                this.schoolList = res.rows
            } catch (error) {
                this.loading = false
                this.$message.error('数据获取失败')
            }
        },
        // 提交
        handleQuery() {
            this.getList()
        },
        resetQuery() {
            this.resetForm('queryForm')
            this.getList()
        },
        // 删除行
        delRow(row) {
            this.$confirm('此操作将永久删除该, 是否继续?', '提示', {
                confirmButtonText: '确定',
                cancelButtonText: '取消',
                type: 'warning',
            }).then(async () => {
                await delReview(row.comment_id)
                this.$message({
                    type: 'success',
                    message: '删除成功!',
                })
                this.getList()
            })
        },
    },
}
</script>

<style lang="scss" scoped>
</style>
