<template>
  <div>
    <n-card>
      <!-- <headSearch :info="search" @search="handleSearch" @reset="handleSearch" /> -->
      <data-table
        ref="tableRef"
        :columns="columns"
        :row-key="(row) => row.id"
        :request="loadDataTable"
        size="large"
        @update:checked-row-keys="handleCheck"
      >
        <template #tableTitle>
          <n-button type="primary" @click="handleModal"> 新建 </n-button>
        </template>
      </data-table>
    </n-card>
  </div>

  <!-- 新增、编辑弹窗 -->
  <BannerModal v-if="modalShow" v-model:visible="modalShow" :type="modalType" :data="rowData" @reload="handleSearch" />
</template>

<script>
import { unref, toRefs, reactive } from 'vue'
// import headSearch from '@/components/Search/index.vue'
import table from './tool/table.js'
import dataTable from '@/components/DataTable/index.vue'
import BannerModal from './BannerModal.vue'
import { bannerPage } from '@/api/system/banner.js'
export default {
  name: 'BannerManage',
  components: { dataTable, BannerModal },
  setup() {
    const data = reactive({
      ...toRefs(table)
    })
    const loadDataTable = async(res) => {
      const _params = {
        ...unref(data.searchParams),
        ...res
      }
      return await bannerPage(_params)
    }

    // 新增
    function handleModal() {
      data.rowData = null
      data.modalType = 'create'
      data.modalShow = true
    }

    const handleCheck = (e) => {
      console.log('eee', e)
    }

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

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