<template>
    <div>
      <BasicTable
        :rowSelection="{ type: 'checkbox' }"
        @register="registerTable"
        :clickToRowSelect="false"
      >
        <template #toolbar>
          <Authority :value="authList.addAuth">
            <!-- <a-button type="primary" @click="handleCreate">新增</a-button> -->
            <tempButton :buttonInfo='bottonList.add'> </tempButton>
          </Authority>
          <Authority :value="authList.deleteAuth">
            <tempButton :buttonInfo='bottonList.delete'> </tempButton>
            <!-- <Popconfirm
              title="您确定要批量删除数据"
              ok-text="确定"
              cancel-text="取消"
              @confirm="handleDeleteOrBatchDelete(null)"
            >
              <a-button type="danger" color="error" :disabled="hasBatchDelete"> 删除 </a-button>
            </Popconfirm> -->
          </Authority>
          <Authority :value="authList.auditAuth">
            <tempButton :buttonInfo='bottonList.audit'> </tempButton>
            <!-- <a-button type="primary" @click="handleCreate">审核</a-button> -->
          </Authority>
        </template>
        <template #action="{ record }">
          <TableAction
            :actions="[
              {
  
                auth: authList.editAuth,
                icon: iconList.update.icon,
                onClick: handleEdit.bind(null, record),
                tooltip:iconList.update.label,
                color: iconList.delete.color,
              },
              {
                auth: authList.deleteAuth,
                icon: iconList.delete.icon,
                color: iconList.delete.color,
                popConfirm: {
                  title: '是否确认删除',
                  confirm: handleDeleteOrBatchDelete.bind(null, record),
                },
                tooltip:iconList.delete.label,
              },
            ]"
          />
        </template>
      </BasicTable>
      <!-- <RoleDrawer @register="registerDrawer" @success="handleSuccess" /> -->
    </div>
  </template>
  <script lang="ts">
    import { defineComponent, nextTick } from 'vue';
    import { BasicTable, useTable, TableAction } from '/@/components/Table';
    // import { delRole, getRoleListByPage, setRoleStatus } from '/@/api/system/system';
    // import { useDrawer } from '/@/components/Drawer';
    // import RoleDrawer from './RoleDrawer.vue';
    // import { RoleEnum } from '/@/enums/roleEnum';
    import { Authority } from '/@/components/Authority';
    // import { useBatchDelete } from '/@/hooks/web/useBatchDelete';
    // import { useMessage } from '/@/hooks/web/useMessage';
    import { Switch, Popconfirm } from 'ant-design-vue';
    import commom from '/@/views/dataSupport/method/commom.ts';
    import cssClass from '/@/views/dataSupport/config/cssClass.ts';
    import tempButton from '/@/views/dataSupport/components/button.vue';
    import editPage from './editPage.vue';
    import detailsPage from './detailsPage.vue';
    export default defineComponent({
      name: 'RoleManagement',
      // components: { BasicTable, RoleDrawer, TableAction, Authority, Switch, Popconfirm },
      components: { BasicTable, TableAction, Authority, Switch, Popconfirm ,tempButton,editPage,detailsPage},
      setup() {
        //table操作符号列表
        const {iconList,bottonType}=cssClass;
        //按钮配置
        const bottonList={
          add:{
            type:bottonType.add.value,
            click:addMethod,
          },
          delete:{
            type:bottonType.delete.value,
            click:deleteMethod,
          },
          audit:{
            type:bottonType.audit.value,
            click:auditMethod,
          },
        }
  
        /**
         * 新增信息
        */
        function addMethod(){
  
        };
  
        /**
         * 删除信息
        */
        function deleteMethod(){
  
        };
  
        /**
         * 审核信息
        */
        function auditMethod(){
  
        };
        //权限控制标识
        const bottomAuthority="api:basinHydropower:basinInformation:";
        const authList={
          addAuth:bottomAuthority+"basinInformationAdd",//新增权限控制
          deleteAuth:bottomAuthority+"basinInformationDelete",//删除权限控制
          auditAuth:bottomAuthority+"basinInformationAudit",//审核权限控制
          editAuth:bottomAuthority+"basinInformationUpdate",//审核权限控制
        }
        //查询条件
        const searchFormSchema=[{
            label:"关键字",
            field:"key"
          },{
            label:"流域状态",
            field:"state"
          },
          {
            label:"所属库区",
            field:"kq"
          },
        ]
        //列表信息 
        const columns=['xh','lybh','lymc','sskq','fw','createUser','createTime','editUser','editTime','lystate']
        // const [registerDrawer, { openDrawer }] = useDrawer();
        // function handleSuccess() {
        //   reload();
        // }
        const [registerTable, { setProps, reload, setSelectedRowKeys }] = useTable({
          title: '流域信息',
          api: getRoleListByPage,
          columns:commom.getInitColumns(columns),
          formConfig: {
            labelWidth: 120,
            schemas: commom.getInitInputList(searchFormSchema),
          },
          useSearchForm: true,
          showTableSetting: true,
          bordered: true,
          showIndexColumn: false,
          actionColumn: {
            width: 200,
            title: '操作',
            dataIndex: 'action',
            slots: { customRender: 'action' },
            fixed: 'right',
          },
        });
        // const { hasBatchDelete, handleDeleteOrBatchDelete, selectionOptions, resetSelectedRowKeys } =
        //   useBatchDelete(delRole, handleSuccess, setProps);
        // selectionOptions.rowSelection.getCheckboxProps = (record: Recordable) => {
        //   // Demo:status为1的选择框禁用
        //   if (record.status === 1) {
        //     return { disabled: true };
        //   } else {
        //     return { disabled: false };
        //   }
        // };
        // nextTick(() => {
        //   setProps(selectionOptions);
        // });
  
        // function handleCreate() {
        //   openDrawer(true, {
        //     isUpdate: false,
        //   });
        // }
  
        // function handleEdit(record: Recordable) {
        //   openDrawer(true, {
        //     record,
        //     isUpdate: true,
        //   });
        // }
  
  
        return {
          iconList,
          authList,
          bottonList,
          registerTable,
          // registerDrawer,
          // handleCreate,
          // handleEdit,
          // handleSuccess,
          // RoleEnum,
          // hasBatchDelete,
          // handleDeleteOrBatchDelete,
        };
      },
    });
  </script>
  