<script setup lang="ts">
import ahTable from "@/components/hTable/index.vue";
import {
  ConditionalType,
  intTableData,
  TableColumnSearch,
  TableConfig,
} from "@/components/hTable/hTable";
import { onMounted, ref, defineOptions } from "vue";
import { fa } from "element-plus/es/locales.mjs";
import { hTableAPI } from "@/api/hTable";
const ControllerName = "AdminRole";

defineOptions({
  name: ControllerName,
});

function searchCallback(data) {}
const table = ref<{ initTable: (config: TableConfig) => void }>(null);
const tableData: TableConfig = intTableData({
  apiUrl: ControllerName,
  selectColumn: false, // 列表选择
  border: false, // 是否显示表格边框
  searchCallback: searchCallback,
  search: {
    // 查询条件
    show: true,
    PageIndex: 0,
    PageSize: 20,
    OrderBy: "CreateTime", // 排序
    defaultConditions: [], // 默认查询条件
    Conditions: [],
  },
  operationColumn: true, // 显示操作按钮
  operationColumnData: [
    {
      topBtn: false, // 头部按钮
      show: true,
      label: "角色授权",
      perms: "角色授权", //按钮显示需要的权限码
      btnType: "custom", // 按钮类型 add edit del 不设置则 自定义按钮
      btnStyle: "success", // topBtn: true才生效 success danger
      custom: {
        // 按钮类型 custom 专用
        title: "分配权限", // 弹出框title
        src: "menu/index", // 组件路径
        width: "1200px", // 弹框宽度
        height: "800px", // 弹框高度
      },
    },
    {
      // 操作按钮
      topBtn: false, // 是头部按钮
      label: "修改",
      btnType: "edit", // 按钮类型 add edit del custom
    },
    {
      // 操作按钮
      topBtn: true, // 是头部按钮
      label: "添加",
      btnStyle: "success",
      btnType: "add", // 按钮类型 add edit del custom
    },
    {
      topBtn: false, // 头部按钮
      show: true,
      label: "删除",
      btnType: "del", // 按钮类型 add edit del 不设置则 自定义按钮
      btnStyle: "danger", // topBtn: true才生效 success danger
    },
  ],
  column: {
    // 行数据
    id: {
      label: "编号",
      search: new TableColumnSearch(true),
      width: "150px",
    },
    name: {
      label: "角色名称",
      width: "180px",
      search: new TableColumnSearch(true, ConditionalType.Like),
      edit: {
        add: true,
      },
    },
    enable: {
      label: "启用",
      type: "switch",
      search: new TableColumnSearch(true),
      edit: {
        add: true,
        edit: true,
        valueE: true,
      },
    },
    createTime: {
      label: "创建时间",
      type: "datetime",
      search: new TableColumnSearch(true),
    },
    remark: {
      label: "备注",
      type: "textarea",
      search: new TableColumnSearch(true),
      edit: {
        add: true,
        edit: true,
        editRows: 3,
        valueE: true,
      },
    },
  },
  data: [],
  pageData: {
    total: 0,
  },
  selectRows: [],
});

const showTable = ref(false);
onMounted(async () => {
  //初始化数据原

  showTable.value = true;
});
</script>

<template>
  <div><ahTable v-if="showTable" ref="table" :tableConfig="tableData" /></div>
</template>
