index.vue 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. <template>
  2. <PageWrapper dense contentFullHeight fixedHeight contentClass="flex">
  3. <DeptTree class="w-1/4 xl:w-1/5" @select="handleSelect" />
  4. <BasicTable @register="registerTable" class="w-3/4 xl:w-4/5">
  5. <template #toolbar>
  6. <a-button type="primary" @click="handleCreate">新增账号</a-button>
  7. </template>
  8. <template #action="{ record }">
  9. <TableAction
  10. :actions="[
  11. {
  12. icon: 'clarity:note-edit-line',
  13. onClick: handleEdit.bind(null, record),
  14. },
  15. {
  16. icon: 'ant-design:delete-outlined',
  17. color: 'error',
  18. popConfirm: {
  19. title: '是否确认删除',
  20. confirm: handleDelete.bind(null, record),
  21. },
  22. },
  23. ]"
  24. />
  25. </template>
  26. </BasicTable>
  27. <AccountModal @register="registerModal" @success="handleSuccess" />
  28. </PageWrapper>
  29. </template>
  30. <script lang="ts">
  31. import { defineComponent } from 'vue';
  32. import { BasicTable, useTable, TableAction } from '/@/components/Table';
  33. import { getAccountList } from '/@/api/demo/system';
  34. import { PageWrapper } from '/@/components/Page';
  35. import DeptTree from './DeptTree.vue';
  36. import { useModal } from '/@/components/Modal';
  37. import AccountModal from './AccountModal.vue';
  38. import { columns, searchFormSchema } from './account.data';
  39. export default defineComponent({
  40. name: 'AccountManagement',
  41. components: { BasicTable, PageWrapper, DeptTree, AccountModal, TableAction },
  42. setup() {
  43. const [registerModal, { openModal }] = useModal();
  44. const [registerTable, { reload }] = useTable({
  45. title: '账号列表',
  46. api: getAccountList,
  47. columns,
  48. formConfig: {
  49. labelWidth: 120,
  50. schemas: searchFormSchema,
  51. },
  52. useSearchForm: true,
  53. showTableSetting: true,
  54. bordered: true,
  55. actionColumn: {
  56. width: 80,
  57. title: '操作',
  58. dataIndex: 'action',
  59. slots: { customRender: 'action' },
  60. },
  61. });
  62. function handleCreate() {
  63. openModal(true, {
  64. isUpdate: false,
  65. });
  66. }
  67. function handleEdit(record: Recordable) {
  68. console.log(record);
  69. openModal(true, {
  70. record,
  71. isUpdate: true,
  72. });
  73. }
  74. function handleDelete(record: Recordable) {
  75. console.log(record);
  76. }
  77. function handleSuccess() {
  78. reload();
  79. }
  80. function handleSelect(deptId: string = '') {
  81. reload({ searchInfo: { deptId } });
  82. }
  83. return {
  84. registerTable,
  85. registerModal,
  86. handleCreate,
  87. handleEdit,
  88. handleDelete,
  89. handleSuccess,
  90. handleSelect,
  91. };
  92. },
  93. });
  94. </script>