Newer
Older
toilet / src / views / statistics / evaluationStatistics.vue
<template>
  <app-container>
    <search-area :need-clear="false" :need-search-more="false" type="seperate" search-more-type="default" @search="fetchData">
      <!--一般查询条件-->
      <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" :columns="columns" :pagination="false"
      :head="tableOption.head" :query="listQuery" :list-loading="listLoading" :options="tableOption.options" :tools-option="tableOption.toolsOption"
    >
      <template slot="columns">
        <el-table-column label="平均评分" align="center">
          <template slot-scope="scope">
            <el-rate style="text-align: center;" v-model="scope.row.avgScore" disabled show-score text-color="#ff9900" score-template="{value}" />
          </template>
        </el-table-column>

        <el-table-column label="详细记录" align="center" width="200">
          <template slot-scope="scope">
            <el-button type="text" size="small" @click="detail(scope.row)">详细记录</el-button>
          </template>
        </el-table-column>
      </template>
    </normal-table>

    <evaluation-records v-show="showRecords" ref="evaRecords" />
  </app-container>
</template>

<script>
import { toiletEvaluation } from '@/api/statistics'
import EvaluationRecords from './evaluationRecords.vue'

export default {
  name: 'EvaluationStatistics',
  components: { EvaluationRecords },
  data() {
    return {
      listQuery: {
        beginDate: '',
        endDate: ''
      },
      columns: [
        { text: '公厕编号', value: 'toiletCode', align: 'center' },
        { text: '公厕名称', value: 'toiletName', align: 'center' },
        { text: '评价记录数', value: 'recordsCount', align: 'center' }
      ], // 显示列
      list: [], // 列表数据
      showRecords: false,
      listLoading: true, // 加载动画
      tableOption: {
        head: {
          show: true, // 是否需要标题栏,
          text: '统计结果' // 标题名称
        },
        options: {
          needIndex: false // 是否需要序号列
        },
        toolsOption: {
          selectColumns: false, // 是否需要筛选列
          refresh: false // 是否需要刷新按钮
        }
      }, // 表格属性
      dateRange: []
    }
  },
  watch: {
    dateRange: {
        handler(newVal, oldVal) {
          if (newVal !== null && newVal !== undefined) {
            this.listQuery.startDate = newVal[0]
            this.listQuery.endDate = newVal[1]
          } else {
            this.listQuery.startDate = ''
            this.listQuery.endDate = ''
          }
        }, immediate: true
      }
  },
  mounted() {
    this.fetchData()
  },
  methods: {
    // 获取统计数据
    fetchData() {
      this.listLoading = true
      toiletEvaluation(this.listQuery).then(res => {
        if (res.code === 200) {
          this.list = res.data
        }
        this.listLoading = false
      })
    },
    detail(row) {
      // this.showRecords = true
      this.$refs.evaRecords.initDialog(true, row)
    }
  }
}
</script>

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

</style>