indexCopy.vue 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  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="tsx">
  9. import { ref } from 'vue';
  10. import type { Ref } from 'vue';
  11. import type { DataTableColumns, PaginationProps } from 'naive-ui';
  12. import { query_1 } from '~/src/service/api/user';
  13. import type { Query_1Params } from '~/src/service/api/user';
  14. const tableData = ref<Query_1Params[]>([]);
  15. function setTableData(data: Query_1Params[]) {
  16. tableData.value = data;
  17. }
  18. async function getTableData() {
  19. const pageNum = pagination.page as number;
  20. const pageSize = pagination.pageSize as number;
  21. const params: Query_1Params = {
  22. depname: '',
  23. address: '',
  24. phone: '',
  25. email: '',
  26. manager: '',
  27. createTime: "",
  28. modifyTime: "" ,
  29. createUid: 0,
  30. disabled: '',
  31. };
  32. query_1(pageNum, pageSize, params)
  33. .then(response => {
  34. console.log(response);
  35. const data: Query_1Params[] = response.data as Query_1Params[]; // 使用类型断言
  36. setTimeout(() => {
  37. setTableData(data);
  38. }, 1000);
  39. })
  40. .catch(error => {
  41. // 处理错误情况
  42. });
  43. }
  44. const columns: Ref<DataTableColumns<Query_1Params>> = ref([
  45. {
  46. type: 'selection',
  47. align: 'center'
  48. },
  49. {
  50. key: 'depname',
  51. title: '部门名称',
  52. align: 'center'
  53. },
  54. {
  55. key: 'address',
  56. title: '部门地址',
  57. align: 'center'
  58. },
  59. {
  60. key: 'phone',
  61. title: '部门电话',
  62. align: 'center'
  63. },
  64. {
  65. key: 'email',
  66. title: '部门电子邮箱',
  67. align: 'center',
  68. },
  69. {
  70. key: 'manager',
  71. title: '部门负责人',
  72. align: 'center'
  73. },
  74. {
  75. key: 'createTime',
  76. title: '创建时间',
  77. align: 'center'
  78. },
  79. {
  80. key: 'modifyTime',
  81. title: '修改时间',
  82. align: 'center'
  83. },
  84. {
  85. key: 'createUid',
  86. title: '创建用户ID',
  87. align: 'center'
  88. },
  89. {
  90. key: 'disabled',
  91. title: '状态',
  92. align: 'center'
  93. },
  94. ]) as Ref<DataTableColumns<Query_1Params>>;
  95. const pagination: PaginationProps = ref({
  96. page: 1,
  97. pageSize: 10,
  98. showSizePicker: true,
  99. pageSizes: [10, 20, 50],
  100. onChange: (page: number) => {
  101. // 处理页码变化
  102. },
  103. onUpdatePageSize: (pageSize: number) => {
  104. // 处理每页显示数量变化
  105. }
  106. }).value;
  107. function init() {
  108. getTableData();
  109. }
  110. // 初始化
  111. init();
  112. </script>