queryUser.vue 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. <template>
  2. <div class="h-full overflow-hidden">
  3. <n-card title="权限管理" :bordered="false" class="rounded-16px shadow-sm">
  4. <n-data-table :columns="columns" :data="tableData" :pagination="pagination" />
  5. </n-card>
  6. </div>
  7. </template>
  8. <script setup lang="ts">
  9. import { ref } from 'vue';
  10. import type { Ref } from 'vue';
  11. import type { DataTableColumns, PaginationProps } from 'naive-ui';
  12. import { query } from '~/src/service/api/user';
  13. import type { QueryParams } from '~/src/service/api/user';
  14. const tableData = ref<QueryParams[]>([]);
  15. const pagination: PaginationProps = ref({
  16. page: 1,
  17. pageSize: 10,
  18. showSizePicker: true,
  19. pageSizes: [10, 20, 50],
  20. onChange: () => {
  21. // 处理页码变化
  22. },
  23. onUpdatePageSize: () => {
  24. // 处理每页显示数量变化
  25. }
  26. }).value;
  27. async function getTableData() {
  28. const pageNum = pagination.page as number;
  29. const pageSize = pagination.pageSize as number;
  30. const params: QueryParams = {
  31. name: '',
  32. description: '',
  33. isActive: '',
  34. createTime: '',
  35. modifyTime: '',
  36. createUid: 0,
  37. disabled: ''
  38. };
  39. query(pageNum, pageSize, params).then(res => {
  40. tableData.value = res.data as [];
  41. });
  42. }
  43. const columns: Ref<DataTableColumns<QueryParams>> = ref([
  44. {
  45. type: 'selection',
  46. align: 'center'
  47. },
  48. {
  49. key: 'depname',
  50. title: '部门名称',
  51. align: 'center'
  52. },
  53. {
  54. key: 'address',
  55. title: '部门地址',
  56. align: 'center'
  57. },
  58. {
  59. key: 'phone',
  60. title: '部门电话',
  61. align: 'center'
  62. },
  63. {
  64. key: 'email',
  65. title: '部门电子邮箱',
  66. align: 'center'
  67. },
  68. {
  69. key: 'manager',
  70. title: '部门负责人',
  71. align: 'center'
  72. },
  73. {
  74. key: 'createTime',
  75. title: '创建时间',
  76. align: 'center'
  77. },
  78. {
  79. key: 'modifyTime',
  80. title: '修改时间',
  81. align: 'center'
  82. },
  83. {
  84. key: 'createUid',
  85. title: '创建用户ID',
  86. align: 'center'
  87. },
  88. {
  89. key: 'disabled',
  90. title: '状态',
  91. align: 'center'
  92. }
  93. ]) as Ref<DataTableColumns<QueryParams>>;
  94. function init() {
  95. getTableData();
  96. }
  97. // 初始化
  98. init();
  99. </script>