index.vue 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. <template>
  2. <PageWrapper dense contentFullHeight fixedHeight contentClass="flex">
  3. <DeptTree class="w-1/4 xl:w-1/5" @select="handleSelect" />
  4. <div class="m-4 vxebasic-form-container">
  5. <VxeBasicTable ref="tableRef" v-bind="gridOptions">
  6. <template #action="{ row }">
  7. <TableAction outside :actions="createActions(row)" />
  8. </template>
  9. </VxeBasicTable>
  10. </div>
  11. </PageWrapper>
  12. </template>
  13. <script lang="ts" setup>
  14. import { reactive, ref } from 'vue';
  15. import { ActionItem, TableAction } from '/@/components/Table';
  16. import { getAccountList } from '/@/api/demo/system';
  17. import { PageWrapper } from '/@/components/Page';
  18. import DeptTree from '../account/DeptTree.vue';
  19. import { columns, searchFormSchema } from './vxeAccount.data';
  20. import { BasicTableProps, VxeBasicTable, VxeGridInstance } from '/@/components/VxeTable';
  21. const tableRef = ref<VxeGridInstance>();
  22. const searchInfo = ref();
  23. const gridOptions = reactive<BasicTableProps>({
  24. id: 'VxeTable',
  25. keepSource: true,
  26. columns: columns,
  27. formConfig: {
  28. enabled: true,
  29. items: searchFormSchema,
  30. },
  31. height: 'auto',
  32. proxyConfig: {
  33. ajax: {
  34. query: async ({ page, form }) => {
  35. return getAccountList({
  36. page: page.currentPage,
  37. pageSize: page.pageSize,
  38. ...form,
  39. searchInfo: searchInfo.value,
  40. });
  41. },
  42. },
  43. },
  44. });
  45. const handleSelect = (deptId = '') => {
  46. searchInfo.value = deptId;
  47. if (tableRef.value) {
  48. tableRef.value.commitProxy('query');
  49. }
  50. };
  51. // 操作按钮(权限控制)
  52. const createActions = (record) => {
  53. const actions: ActionItem[] = [
  54. {
  55. label: '详情',
  56. onClick: () => {
  57. console.log(record);
  58. },
  59. },
  60. {
  61. label: '编辑',
  62. onClick: () => {},
  63. },
  64. {
  65. label: '删除',
  66. color: 'error',
  67. popConfirm: {
  68. title: '是否确认删除',
  69. confirm: () => {
  70. tableRef.value?.remove(record);
  71. },
  72. },
  73. },
  74. ];
  75. return actions;
  76. };
  77. </script>
  78. <style lang="less" scope>
  79. .vxebasic-form-container {
  80. flex: auto;
  81. }
  82. </style>