<!-- 
  TODO 成本管理 / 应收账单
 -->
<template>
  <div class="p-4 receivable-bill-list">
    <!-- 搜索栏 -->
    <el-form
      class="el-search-form"
      :model="listParm"
      label-width="80px"
      :inline="true"
    >
      <el-form-item class="item-search">
        <!-- <el-date-picker
          v-model="listParm.month"
          type="date"
          format="YYYY/MM/DD"
          placeholder="请选择月份"
        /> -->
        <el-select
          v-model="listParm.month"
          placeholder="请选择月份"
        >
          <el-option
            v-for="item in state.monthList"
            :key="item.value"
            :label="item.label"
            :value="item.value"
          />
        </el-select>
      </el-form-item>
      <el-form-item class="item-search">
        <el-select
          v-model="listParm.customerId"
          clearable
          :filterable="true"
          placeholder="请选择客户"
          :filter-method="definFilter"
        >
          <el-option
            v-for="item in customerList_"
            :key="item.value"
            :label="item.label"
            :value="item.value"
          />
        </el-select>
      </el-form-item>
      <el-form-item>
        <el-button
          :icon="Search"
          @click="searchBtn"
        >
          搜索
        </el-button>
        <el-button
          :icon="RefreshRight"
          style="color: #FF7670;"
          @click="resetBtn"
        >
          重置
        </el-button>
        <el-button
          :icon="Download"
          :loading="state.exportDisabled"
          type="primary"
          @click="exportBtn"
        >
          导出
        </el-button>
      </el-form-item>
    </el-form>
    <!-- 表格列表 -->
    <BaseTable
      :height="tableHeight"
      @register="registerTable"
    />
    <!-- 分页 -->
    <el-pagination
      v-model:current-page="listParm.pageNum"
      :page-sizes="[10, 20, 40, 80, 100]"
      :page-size="listParm.pageSize"
      layout="total, sizes, prev, pager, next, jumper"
      :total="listParm.total"
      background
      @size-change="sizeChange"
      @current-change="currentChange"
    />
  </div>
</template>
  
<script lang="ts" setup name="receivableBill">
// import { ref, nextTick, onMounted } from 'vue';
import {
    Search,
    Download,
    RefreshRight
} from "@element-plus/icons-vue";
import { BaseTable, useTable } from '@/components/Table';
import useReceivableBill from '@/composables/business/receivablebill/useReceivableBill';
import { useReceivableBillTable } from '@/composables/business/receivablebill/useReceivableBillTable';
import useResizeHeight from '@/hooks/useResizeHeight';
import useDefinFilter from '@/hooks/useDefinFilter';

// 基础数据 
const { receivableBillTableList } = useReceivableBillTable()
const [registerTable] = useTable(receivableBillTableList)

const { searchBtn, resetBtn, exportBtn, sizeChange, currentChange, listParm, state } = useReceivableBill(receivableBillTableList)

// 自定义select搜索
const { definFilter, typeList: customerList_ } = useDefinFilter(state, 'customerList')

// 表格自适应屏幕高度
const { tableHeight } = useResizeHeight()
</script>