<template> <el-dialog :title="titleText" :visible.sync="dialogFormVisible" style="width: 1800px" append-to-body> <search-area :need-clear="false" :need-search-more="false" type="seperate" search-more-type="default" @search="search"> <!--一般查询条件--> <search-item> <el-date-picker v-model="dateRange" type="daterange" range-separator="至" start-placeholder="开始日期" end-placeholder="结束日期" value-format="yyyy-MM-dd" /> </search-item> </search-area> <normal-table :data="list" :total="total" :columns="columns" :head="tableOption.head" :query="listQuery" :list-loading="listLoading" :options="tableOption.options" :tools-option="tableOption.toolsOption" @change="changePage" > <template slot="columns"> <el-table-column label="评分" align="center" width="200"> <template slot-scope="scope"> <el-rate style="text-align: center;" v-model="scope.row.score" disabled show-score text-color="#ff9900" score-template="{value}" /> </template> </el-table-column> </template> </normal-table> </el-dialog> </template> <script> import { toiletEvaluationRecords } from '@/api/statistics' export default { name: 'EvaluationRecords', data() { return { dialogFormVisible: false, // 对话框是否显示 titleText: '评价记录', listQuery: { toiletId: '', beginDate: '', endDate: '', offset: 1, limit: 10 }, // 筛选条件 dateRange: [], columns: [ { text: '评价时间', value: 'commentTime', align: 'center', width: 160 }, { text: '评价内容', value: 'comment', align: 'center' } ], // 显示列 list: [], // 列表数据 total: 0, // 数据总数 listLoading: true, // 加载动画 tableOption: { head: { show: true, // 是否需要标题栏, text: '数据列表' // 标题名称 }, options: { needIndex: true // 是否需要序号列 }, toolsOption: { selectColumns: false, // 是否需要筛选列 refresh: false // 是否需要刷新按钮 } }, // 表格属性 } }, watch: { dateRange: { handler(newVal, oldVal) { if (newVal !== null && newVal !== undefined) { this.listQuery.beginDate = newVal[0] this.listQuery.endDate = newVal[1] } else { this.listQuery.beginDate = '' this.listQuery.endDate = '' } }, immediate: true } }, methods: { // 初始化对话框 initDialog: function(dialogFormVisible, row = null) { this.dialogFormVisible = dialogFormVisible this.titleText = row.toiletName + "评价记录" this.search() }, search: function() { toiletEvaluationRecords(this.listQuery).then(res => { if (res.code === 200) { this.list = res.data.rows this.total = res.data.total } this.listLoading = false }) }, // 页数发生变化后的操作,可能是页码变化,可能是每页容量变化,此函数必写 changePage(val) { if (val && val.size) { this.listQuery.limit = val.size } if (val && val.page) { this.listQuery.offset = val.page } this.search() }, cancel: function() { this.dialogFormVisible = false } } } </script> <style rel="stylesheet/scss" lang="scss" scoped> .el-dialog{ width:700px } .el-select{ width: 100%; } .form-div{ width:100%; height:100%; display:flex; justify-content: space-between; } .form-left{ flex:1; height:100%; } .form-right{ width: 180px; height:100%; .avatar{ margin-bottom: 10px; } text-align: center; } </style>