<template>
  <div>
    <search-form :list-query="listQuery" @searchForm="searchForm"/>
    <case-list
      v-loading="listLoading"
      :case-list="caseList"
      :total="total"
      :list-query="listQuery"
      @changeQuery="changeQuery"
      @addDetail="addDetail"/>
  </div>
</template>

<script>
import CaseList from '@/components/CaseCommon/caseList'
import SearchForm from '@/components/CaseCommon/searchForm'
import { handleAuditListPage } from '@/api/coorBusiness/case'

export default {
  name: 'Index',
  components: { CaseList, SearchForm },
  data() {
    return {
      props: [], // 存储列表页传递的row
      editableTabsValue: 'listTab',
      editableTabs: [], // tab
      caseList: [], // 案卷列表，传递给子组件
      listQuery: {
        offset: 1,
        limit: 10,
        sort: '',
        order: ''
      }, // 筛选条件
      total: 0,
      listLoading: true // 加载动画
    }
  },
  activated() {
    this.fetchData()
  },
  methods: {
    async fetchData() {
      console.log(this.listQuery)
      this.listLoading = true
      const res = await handleAuditListPage(this.listQuery)
      this.caseList = res.data.rows
      this.total = parseInt(res.data.total)
      this.listLoading = false
      console.log(this.caseList)
    },
    changeQuery(listQuery) {
      this.listQuery = listQuery
      this.fetchData()
    },
    searchForm(listQuery) {
      this.listQuery = listQuery
      console.log('searchForm', this.listQuery)
      this.fetchData()
    },
    addDetail(tabPane, row) {
      this.$router.push({
        path: '/caseDetaliProcess',
        query: {
          id: row.id
        }
      })
    }
  }

}
</script>
