<template>
  <BasicModal v-bind="$attrs" @register="registerModal" title="查看账号">
    <BasicTable @register="registerTable" :searchInfo="searchInfo" />
  </BasicModal>
</template>
<script lang="ts" setup>
  import { ref, reactive, onMounted } from 'vue';
  import { BasicModal, useModalInner } from '@/components/Modal';
  import { loadByRole } from '@/api/demo/system';
  import { BasicTable, useTable } from '@/components/Table';

  defineOptions({ name: 'DeptModal' });

  const emit = defineEmits(['success', 'register']);

  const rowId = ref('');
  const searchInfo = reactive<Recordable>({});

  const [registerModal, { setModalProps }] = useModalInner(async (data) => {
    setModalProps({ confirmLoading: false });
    rowId.value = data.record.id;
    searchInfo.roleId = rowId.value;
    reload()
  });
  const [registerTable,{reload}] = useTable({
    api: loadByRole,
    columns: [
      {
        title: '用户名',
        dataIndex: 'account',
        width: 120,
      },
      {
        title: '昵称',
        dataIndex: 'name',
        width: 120,
      },
    ],
    useSearchForm: false,
    showTableSetting: false,
    tableSetting: { fullScreen: true },
    showIndexColumn: false,
    isCanResizeParent: true,
    rowKey: 'id',
    handleSearchInfoFn(info) {
      return info;
    },
  });

  onMounted(() => {});
</script>
