<!-- 
    TODO 字典 / 费项类别
 -->
<template>
  <el-main>
    <!-- 搜索栏 -->
    <el-form
      class="el-search-form"
      :model="listParm"
      label-width="80px"
      :inline="true"
    >
      <el-form-item class="item-search">
        <el-input
          v-model="listParm.categoryName"
          placeholder="请输入名称"
        />
      </el-form-item>
      <el-form-item>
        <el-button
          :loading="feeItemCategoryList.loading"
          :icon="Search"
          @click="searchBtn"
        >
          搜索
        </el-button>
        <el-button
          :loading="feeItemCategoryList.loading"
          class="reset-btn"
          :icon="RefreshRight"
          @click="resetBtn"
        >
          重置
        </el-button>
        <el-button
          v-permission="['sys:feeItemCategory:add']"
          type="primary"
          :icon="Plus"
          @click="addBtn"
        >
          新增
        </el-button>
      </el-form-item>
    </el-form>
    <!-- 表格 -->
    <el-table
      :height="tableHeight"
      :data="feeItemCategoryList.list"
      border
      stripe
    >
      <el-table-column
        prop="categoryName"
        label="名称"
      />
      <el-table-column
        prop="createUserName"
        label="操作人员"
      />
      <el-table-column
        prop="createTime"
        label="操作时间"
      />
      <el-table-column
        label="操作"
        width="200"
      >
        <template #default="scope">
          <el-button
            v-permission="['sys:feeItemCategory:edit']"
            type="primary"
            :icon="Edit"
            @click="editBtn(scope.row)"
          >
            编辑
          </el-button>
          <el-button
            v-permission="['sys:feeItemCategory:delete']"
            type="danger"
            :icon="Delete"
            @click="deleteBtn(scope.row.id)"
          >
            删除
          </el-button>
        </template>
      </el-table-column>
    </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>
  <!-- 新增、编辑弹框 -->
  <AddandEditFeeItemCategory
    ref="adFeeItemCategoryRef"
    @save="save"
  />
</template>
<script setup lang="ts" name="feeItemCategory">
import { ref, onMounted, nextTick } from 'vue';
import { Search, Edit, Plus, Setting, RefreshRight, Delete } from '@element-plus/icons-vue';
import userFeeItemCategoryTable from '@/composables/FeeItemCategory/userFeeItemCategoryTable';
import useFeeItemCategory from '@/composables/FeeItemCategory/userFeeItemCategory';
import AddandEditFeeItemCategory from './AddandEditFeeItemCategory.vue';
import useResizeHeight from '@/hooks/useResizeHeight';

//表格列表
const { listParm, feeItemCategoryList, getFeeItemCategoryList, sizeChange, currentChange, searchBtn, resetBtn } = userFeeItemCategoryTable()
//新增、编辑
const { addBtn, editBtn, deleteBtn, adFeeItemCategoryRef, save } = useFeeItemCategory(getFeeItemCategoryList)
// 表格自适应屏幕高度
const { tableHeight } = useResizeHeight()
</script>
   
<style lang="scss">
.el-search-form {
  width: 100%;

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