queryUser.vue 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  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. async function getTableData() {
  16. const pageNum = pagination.page as number;
  17. const pageSize = pagination.pageSize as number;
  18. const params: QueryParams = {
  19. name: '',
  20. description: '',
  21. isActive: '',
  22. createTime: '',
  23. modifyTime: "" ,
  24. createUid: 0,
  25. disabled: '',
  26. };
  27. query(pageNum, pageSize, params).then((res) => {
  28. console.log(res);
  29. tableData.value = res.data as[]
  30. })
  31. }
  32. const columns: Ref<DataTableColumns<QueryParams>> = ref([
  33. {
  34. type: 'selection',
  35. align: 'center'
  36. },
  37. {
  38. key: 'depname',
  39. title: '部门名称',
  40. align: 'center'
  41. },
  42. {
  43. key: 'address',
  44. title: '部门地址',
  45. align: 'center'
  46. },
  47. {
  48. key: 'phone',
  49. title: '部门电话',
  50. align: 'center'
  51. },
  52. {
  53. key: 'email',
  54. title: '部门电子邮箱',
  55. align: 'center',
  56. },
  57. {
  58. key: 'manager',
  59. title: '部门负责人',
  60. align: 'center'
  61. },
  62. {
  63. key: 'createTime',
  64. title: '创建时间',
  65. align: 'center'
  66. },
  67. {
  68. key: 'modifyTime',
  69. title: '修改时间',
  70. align: 'center'
  71. },
  72. {
  73. key: 'createUid',
  74. title: '创建用户ID',
  75. align: 'center'
  76. },
  77. {
  78. key: 'disabled',
  79. title: '状态',
  80. align: 'center'
  81. },
  82. ]) as Ref<DataTableColumns<QueryParams>>;
  83. const pagination: PaginationProps = ref({
  84. page: 1,
  85. pageSize: 10,
  86. showSizePicker: true,
  87. pageSizes: [10, 20, 50],
  88. onChange: (page: number) => {
  89. // 处理页码变化
  90. },
  91. onUpdatePageSize: (pageSize: number) => {
  92. // 处理每页显示数量变化
  93. }
  94. }).value;
  95. function init() {
  96. getTableData();
  97. }
  98. // 初始化
  99. init();
  100. </script>