<!-- 
    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.itemName"
          placeholder="请输入名称"
        />
      </el-form-item>
      <el-form-item class="item-search">
        <el-select
          v-model="listParm.itemType"
          clearable
          placeholder="请选择费用类型"
        >
          <el-option
            v-for="item in feeItemTypeSelectList.list"
            :key="item.value"
            :label="item.label"
            :value="item.value"
          />
        </el-select>
      </el-form-item>
      <el-form-item>
        <el-button
          :loading="feeItemList.loading"
          :icon="Search"
          @click="searchBtn"
        >
          搜索
        </el-button>
        <el-button
          :loading="feeItemList.loading"
          class="reset-btn"
          :icon="RefreshRight"
          @click="resetBtn"
        >
          重置
        </el-button>
        <el-button
          v-permission="['sys:feeitem:add']"
          type="primary"
          :icon="Plus"
          @click="addBtn"
        >
          新增
        </el-button>
      </el-form-item>
    </el-form>
    <!-- 表格 -->
    <el-table
      :height="tableHeight"
      :data="feeItemList.list"
      border
      stripe
    >
      <el-table-column
        prop="itemName"
        label="名称"
      />
      <el-table-column
        prop="englishName"
        label="英文名称"
      />
      <el-table-column
        prop="generalizedItemName"
        label="广义费用名称"
      />
      <el-table-column
        prop="paramterFlag"
        label="参数"
      >
        <template #default="scope">
          {{ scope.row.paramterFlag === 1 ? '是' : '否' }}
        </template>
      </el-table-column>
      <el-table-column
        prop="itemTypeName"
        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:feeitem:edit']"
            type="primary"
            :icon="Edit"
            @click="editBtn(scope.row)"
          >
            编辑
          </el-button>
          <el-button
            v-permission="['sys:feeitem: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>
  <!-- 新增、编辑弹框 -->
  <AddandEditFeeItem
    ref="adFeeItemRef"
    :fee-item-special-flag-select-list="feeItemSpecialFlagSelectList.list"
    :fee-item-type-select-list="feeItemTypeSelectList.list"
    @save="save"
  />
</template>
<script setup lang="ts" name="feeitem">
import { Search, Edit, Plus, Setting, RefreshRight, Delete } from '@element-plus/icons-vue';
import userFeeItemTable from '@/composables/feeitem/userFeeItemTable';
import useFeeItem from '@/composables/FeeItem/userFeeItem';
import AddandEditFeeItem from './AddandEditFeeitem.vue';
import useResizeHeight from '@/hooks/useResizeHeight';
//表格列表
const { listParm, feeItemList, getFeeItemList, sizeChange, currentChange, searchBtn, resetBtn, feeItemSpecialFlagSelectList,feeItemTypeSelectList } = userFeeItemTable()
//新增、编辑
const { addBtn, editBtn, deleteBtn, adFeeItemRef, save } = useFeeItem(getFeeItemList)
// 表格自适应屏幕高度
const { tableHeight } = useResizeHeight()
</script>
   
<style lang="scss">
.el-search-form {
  width: 100%;

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