<template>
  <app-container>
    <case-list
      v-loading="listLoading"
      :case-list="caseList"
      :total="total"
      :list-query="listQuery"
      :table-columns="tableColumns"
      @changeQuery="changeQuery"
      @addDetail="showDetail"/>
  </app-container>
</template>

<script>
import CaseList from '@/components/CaseCommon/caseList'
import CaseDetailRead from '@/components/CaseCommon/caseDetailRead'
import { getHistoryList } from '@/api/callCase/callCase'

export default {
  name: 'HistoryCaseList',
  components: { CaseList, CaseDetailRead },
  data() {
    return {
      caseList: [], // 案卷列表// ，传递给子组件
      tableColumns: [
        {
          text: '案卷编号',
          value: 'caseid'
        },
        {
          text: '节点名称',
          value: 'caseStateName'
        },
        {
          text: '案卷类别',
          value: 'eorcName'
        },
        {
          text: '案卷大类',
          value: 'casetypeName'
        },
        {
          text: '案卷小类',
          value: 'casetypeDetailName'
        },
        {
          text: '案卷描述',
          value: 'description'
        },
        {
          text: '案卷位置',
          value: 'fieldintro'
        }
      ],
      listQuery: {
        reporterPhone: '',
        offset: 1,
        limit: 20,
        sort: '',
        order: ''
      }, // 筛选条件
      total: 0,
      listLoading: true // 加载动画
    }
  },
  mounted() {
    this.listQuery.reporterPhone = this.$route.query.reporterPhone
    this.fetchData()
  },
  activated() {
    this.listQuery.reporterPhone = this.$route.query.reporterPhone
    this.fetchData()
  },
  methods: {
    // 获取数据
    fetchData() {
      this.listLoading = true
      // 根据不同类型，调用不同的接口
      console.log(this.listQuery.reporterPhone)
      getHistoryList(this.listQuery).then(res => {
        this.caseList = res.data.rows
        this.total = parseInt(res.data.total)
        this.listLoading = false
      })
    },
    // 来自caselist组件的查询条件(分页)更改后的查询
    changeQuery(listQuery) {
      this.listQuery = listQuery
      this.fetchData()
    },
    // 查看详情
    showDetail(tabPane, row) {
      console.log('detail', row.id)
      // this.$router.push({ path: '/caseDetailRead/' + row.id })
      this.$router.push({
        name: 'CaseDetailRead',
        params: {
          id: row.id
        }
      })
    }
  }
}
</script>

<style scoped>
  .table-container {
    border: 0 !important;
  }
</style>

