<!-- 
   TODO 央行汇率分页查询
 -->
<template>
  <el-main>
    <!-- 搜索栏 -->
    <el-form
      class="el-search-form"
      :model="listParm"
      label-width="80px"
      :inline="true"
      size="mini"
    >
      <el-form-item class="query-search">
        <el-select
          v-model="listParm.currencyCode"
          placeholder="币种编号"
        >
          <el-option
            v-for="item in currencyList"
            :key="item.value"
            :label="`${item.value}(${item.label})`"
            :value="item.value"
          />
        </el-select>
      </el-form-item>
      <el-form-item class="query-search">
        <el-date-picker
          v-model="listParm.releaseTime"
          style="width: 100%;"
          value-format="YYYY-MM-DD"
          placeholder="发布时间"
          type="date"
        />
      </el-form-item>
      <el-form-item>
        <el-button
          :loading="customerRateList.loading"
          :icon="Search"
          @click="searchBtn"
        >
          搜索
        </el-button>
        <el-button
          :loading="customerRateList.loading"
          class="reset-btn"
          :icon="RefreshRight"
          @click="resetBtn"
        >
          重置
        </el-button>
      </el-form-item>
    </el-form>
    <!-- 表格 -->
    <el-table
      :height="tableHeight"
      :data="customerRateList.list"
      stripe
    >
      <el-table-column
        prop="currencyCode"
        label="币种"
      />
      <el-table-column
        prop="currencyRate"
        label="汇率"
      />
      <el-table-column
        prop="releaseTime"
        label="发布时间"
      />
      <el-table-column
        prop="createTime"
        label="创建时间"
      />
    </el-table>
    <!-- 分页 -->
    <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"
    />
  </el-main>
</template>
<script setup lang="ts" name="centralBankRate">
import { Search, RefreshRight } from "@element-plus/icons-vue";
import useResizeHeight from "@/hooks/useResizeHeight";
import useQueryCustomerrateList from "@/composables/customerrate/useQueryCustomerrateList";

//表格列表
const {
  currencyList,
  listParm,
  customerRateList,
  sizeChange,
  currentChange,
  searchBtn,
  resetBtn
} = useQueryCustomerrateList();
// 表格自适应屏幕高度
const { tableHeight } = useResizeHeight();
</script>

<style lang="scss">
.el-search-form {
  width: 100%;

  // 将每一行的设置为相对定位 方便后面before after 使用绝对定位来固定位置
  .query-search {
    width: 184px;
    margin-right: 11px;
  }
}
</style>
