index.vuebak 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. <template>
  2. <div class="h-full overflow-hidden">
  3. <n-card title="用户管理" :bordered="false" class="rounded-16px shadow-sm">
  4. <n-space class="pb-12px" justify="space-between">
  5. <!-- <n-space>
  6. <n-button type="primary" @click="handleAddTable">
  7. <icon-ic-round-plus class="mr-4px text-20px" />
  8. 新增
  9. </n-button>
  10. <n-button type="error">
  11. <icon-ic-round-delete class="mr-4px text-20px" />
  12. 删除
  13. </n-button>
  14. <n-button type="success">
  15. <icon-uil:export class="mr-4px text-20px" />
  16. 导出Excel
  17. </n-button>
  18. </n-space> -->
  19. <!-- <n-space align="center" :size="18">
  20. <n-button size="small" type="primary" @click="getTableData">
  21. <icon-mdi-refresh class="mr-4px text-16px" :class="{ 'animate-spin': loading }" />
  22. 刷新表格
  23. </n-button>
  24. <column-setting v-model:columns="columns" />
  25. </n-space> -->
  26. </n-space>
  27. <n-data-table :columns="columns" :data="tableData" :pagination="pagination" />
  28. <!-- <table-action-modal v-model:visible="visible" :type="modalType" :edit-data="editData" /> -->
  29. </n-card>
  30. </div>
  31. </template>
  32. <script setup lang="ts">
  33. import { ref } from 'vue';
  34. import type { Ref } from 'vue';
  35. // import type { SelectAll_1Res } from './api';
  36. import type { DataTableColumns, PaginationProps } from 'naive-ui';
  37. // import { query } from '~/src/service/api/user';
  38. // import type { QueryParams } from '~/src/service/api/user';
  39. import { selectAll_1 } from '~/src/service/api/user';
  40. const tableData = ref<any[]>([]);
  41. const pagination: PaginationProps = ref({
  42. page: 1,
  43. pageSize: 10,
  44. showSizePicker: true,
  45. pageSizes: [10, 20, 50]
  46. // onChange: (page: number) => {
  47. // // 处理页码变化
  48. // },
  49. // onUpdatePageSize: (pageSize: number) => {
  50. // // 处理每页显示数量变化
  51. // }
  52. }).value;
  53. async function getTableData() {
  54. // const pageNum = pagination.page as number;
  55. // const pageSize = pagination.pageSize as number;
  56. // const params: any = {};
  57. selectAll_1().then(res => {
  58. // console.log(res);
  59. tableData.value = res.data as [];
  60. });
  61. }
  62. type RowData = {
  63. key: number
  64. id: number
  65. name: string
  66. description: string
  67. createTime: string
  68. modifyTime: string
  69. createUid: number
  70. disabled: string
  71. }
  72. const columns: Ref<DataTableColumns<RowData>> = ref([
  73. {
  74. type: 'selection',
  75. align: 'center',
  76. },
  77. {
  78. key: 'id',
  79. title: "ID",
  80. align: 'center'
  81. },
  82. {
  83. key: 'name',
  84. title: '部门名称',
  85. align: 'center'
  86. },
  87. {
  88. key: 'description',
  89. title: '部门地址',
  90. align: 'center'
  91. },
  92. {
  93. key: 'createTime',
  94. title: '创建时间',
  95. align: 'center'
  96. },
  97. {
  98. key: 'modifyTime',
  99. title: '修改时间',
  100. align: 'center'
  101. },
  102. {
  103. key: 'createUid',
  104. title: '创建用户ID',
  105. align: 'center'
  106. },
  107. {
  108. key: 'disabled',
  109. title: '状态',
  110. align: 'center'
  111. }
  112. ]) as Ref<DataTableColumns<any>>;
  113. function init() {
  114. getTableData();
  115. }
  116. // 初始化
  117. init();
  118. </script>