SysTenantListView.vue 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. <template>
  2. <div class="full-height page-container">
  3. <SmartTable @register="registerTable" :size="getTableSize">
  4. <template #table-operation="{ row }">
  5. <SmartVxeTableAction :actions="getActions(row)" />
  6. </template>
  7. </SmartTable>
  8. </div>
  9. </template>
  10. <script lang="ts" setup>
  11. import { useI18n } from '@/hooks/web/useI18n';
  12. import { useSizeSetting } from '@/hooks/setting/UseSizeSetting';
  13. import {
  14. ActionItem,
  15. SmartTable,
  16. SmartVxeTableAction,
  17. useSmartTable,
  18. } from '@/components/SmartTable';
  19. import {
  20. getFormSchemas,
  21. getSearchFormSchemas,
  22. getTableColumns,
  23. Permission,
  24. } from './SysTenantListView.config';
  25. import { batchSaveUpdateApi, deleteApi, getByIdApi, listApi } from './SysTenantListView.api';
  26. const { t } = useI18n();
  27. const { getTableSize } = useSizeSetting();
  28. const getActions = (row: Recordable): ActionItem[] => {
  29. return [
  30. {
  31. label: t('common.button.edit'),
  32. auth: Permission.update,
  33. onClick: () => editByRowModal(row),
  34. },
  35. {
  36. label: t('common.button.delete'),
  37. auth: Permission.delete,
  38. danger: true,
  39. onClick: () => deleteByRow(row),
  40. },
  41. ];
  42. };
  43. const [registerTable, { editByRowModal, deleteByRow }] = useSmartTable({
  44. id: 'system-tenant-list',
  45. customConfig: { storage: true },
  46. columns: getTableColumns(),
  47. height: 'auto',
  48. pagerConfig: true,
  49. useSearchForm: true,
  50. border: true,
  51. stripe: true,
  52. rowConfig: {
  53. keyField: 'id',
  54. isHover: true,
  55. },
  56. columnConfig: {
  57. resizable: true,
  58. },
  59. searchFormConfig: {
  60. schemas: getSearchFormSchemas(t),
  61. searchWithSymbol: true,
  62. colon: true,
  63. layout: 'inline',
  64. actionColOptions: {
  65. span: undefined,
  66. },
  67. compact: true,
  68. },
  69. addEditConfig: {
  70. modalConfig: {
  71. width: 800,
  72. },
  73. formConfig: {
  74. colon: true,
  75. schemas: getFormSchemas(t),
  76. baseColProps: { span: 12 },
  77. labelCol: { span: 6 },
  78. wrapperCol: { span: 17 },
  79. },
  80. },
  81. sortConfig: {
  82. remote: true,
  83. },
  84. proxyConfig: {
  85. ajax: {
  86. query: (params) => listApi(params.ajaxParameter),
  87. save: ({ body: { insertRecords, updateRecords } }) =>
  88. batchSaveUpdateApi([...insertRecords, ...updateRecords]),
  89. delete: ({ body: { removeRecords } }) => deleteApi(removeRecords),
  90. getById: (params) => getByIdApi(params.id),
  91. },
  92. },
  93. toolbarConfig: {
  94. zoom: true,
  95. refresh: true,
  96. column: { columnOrder: true },
  97. buttons: [
  98. {
  99. code: 'ModalAdd',
  100. },
  101. {
  102. code: 'delete',
  103. },
  104. ],
  105. },
  106. });
  107. </script>