<template>
  <div>
    <n-card>
      <HeadSearch :info="search" @search="handleSearch" @reset="handleSearch" />
      <DataTable
        ref="tableRef"
        :columns="columns"
        :row-key="(row) => row.id"
        :request="loadDataTable"
        size="large"
      />
    </n-card>
  </div>

  <ReportDrawer v-model:visible="detailDrawer" :type="detailType" :data="rowData" />

</template>

<script>
import table from './tools/table.js'
import { search, getAirOptions } from './tools/search.js'
import HeadSearch from '@/components/Search/index.vue'
import DataTable from '@/components/DataTable/index.vue'
import ReportDrawer from './components/ReportDrawer.vue'
import { reactive, unref, toRefs, onUnmounted } from 'vue'
import { getReportList } from '@/api/report/index.js'

export default {
  name: 'TaskAll',
  components: { HeadSearch, DataTable, ReportDrawer },
  setup() {
    getAirOptions()
    const data = reactive({
      search,
      ...toRefs(table)
    })

    /**
     * @description: 加载表格数据
     * @param {*} res
     * @return {*}
     */
    const loadDataTable = async(res) => {
      const _params = {
        ...unref(data.searchParams),
        ...res
      }
      return await getReportList(_params)
    }

    onUnmounted(() => {
      data.searchParams = null
      data.detailDrawer = false
    })

    return {
      ...toRefs(data),
      loadDataTable
    }
  }
}

</script>
<style scoped lang='scss'>
</style>
