list.vue 1.91 KB
<template>
  <div>
    <BasicTable @register="registerTable">
      <template #toolbar>
        <a-button type="primary" @click="handleCreateOrEdit(null)"> 新增公共接口 </a-button>
      </template>
      <template #action="{ record }">
        <TableAction
          :actions="[
            {
              label: '修改',
              icon: 'clarity:note-edit-line',
              onClick: handleCreateOrEdit.bind(null, record),
            },
            {
              label: '删除',
              icon: 'ant-design:delete-outlined',
              color: 'error',
              popConfirm: {
                title: '是否确认删除',
                confirm: handleDeleteOrBatchDelete.bind(null, record),
              },
            },
          ]"
        />
      </template>
    </BasicTable>
  </div>
  <PublicApiForm @register="registerDrawer" />
</template>
<script lang="ts" setup name="list">
  import { BasicTable, useTable, TableAction } from '/@/components/Table';
  import { useDrawer } from '/@/components/Drawer';
  import { columns, list } from './config';
  import { PublicApiForm } from './index';

  const [registerTable] = useTable({
    // api: exportPage,
    dataSource: list,
    columns,
    showIndexColumn: false,
    clickToRowSelect: false,
    showTableSetting: true,
    bordered: true,
    actionColumn: {
      width: 200,
      title: '操作',
      dataIndex: 'action',
      slots: { customRender: 'action' },
      fixed: 'right',
    },
  });

  const [registerDrawer, { openDrawer }] = useDrawer();

  const handleDeleteOrBatchDelete = (record) => {
    console.log(record);
  };

  const handleCreateOrEdit = (record) => {
    const isUpdate = record === null ? false : true;
    const recordContent = record === null ? null : record;
    openDrawer(true, {
      isUpdate,
      record: recordContent,
    });
  };
</script>