Ben Lin
2024-06-18 ebbd788fbb2c0b45d4473798efc57eec8ba74a25
src/views/demo/table/AuthColumn.vue
@@ -56,11 +56,11 @@
    </BasicTable>
  </div>
</template>
<script lang="ts">
  import { defineComponent } from 'vue';
  import { BasicTable, useTable, BasicColumn, TableAction } from '/@/components/Table';
<script lang="ts" setup>
  import { BasicTable, useTable, BasicColumn, TableAction } from '@/components/Table';
  import { demoListApi } from '/@/api/demo/table';
  import { demoListApi } from '@/api/demo/table';
  const columns: BasicColumn[] = [
    {
      title: '编号',
@@ -70,32 +70,38 @@
    {
      title: '姓名',
      dataIndex: 'name',
      width: 200,
      minWidth: 200,
      auth: 'test', // 根据权限控制是否显示: 无权限,不显示
    },
    {
      title: '状态',
      dataIndex: 'status',
      width: 100,
    },
    {
      title: '状态1',
      dataIndex: 'status1',
      width: 100,
    },
    {
      title: '状态2',
      dataIndex: 'status2',
      width: 100,
    },
    {
      title: '状态3',
      dataIndex: 'status3',
      width: 100,
    },
    {
      title: '状态4',
      dataIndex: 'status4',
      width: 100,
    },
    {
      title: '状态5',
      dataIndex: 'status5',
      width: 100,
    },
    {
      title: '地址',
@@ -115,40 +121,30 @@
      width: 200,
    },
  ];
  export default defineComponent({
    components: { BasicTable, TableAction },
    setup() {
      const [registerTable] = useTable({
        title: 'TableAction组件及固定列示例',
        api: demoListApi,
        columns: columns,
        bordered: true,
        rowKey: 'id',
        rowSelection: {
          type: 'checkbox',
        },
        actionColumn: {
          width: 250,
          title: 'Action',
          dataIndex: 'action',
          // slots: { customRender: 'action' },
        },
      });
      function handleEdit(record: Recordable) {
        console.log('点击了编辑', record);
      }
      function handleDelete(record: Recordable) {
        console.log('点击了删除', record);
      }
      function handleOpen(record: Recordable) {
        console.log('点击了启用', record);
      }
      return {
        registerTable,
        handleEdit,
        handleDelete,
        handleOpen,
      };
  const [registerTable] = useTable({
    title: 'TableAction组件及固定列示例',
    api: demoListApi,
    columns: columns,
    bordered: true,
    rowKey: 'id',
    rowSelection: {
      type: 'checkbox',
    },
    actionColumn: {
      width: 250,
      title: 'Action',
      dataIndex: 'action',
    },
    showSelectionBar: true, // 显示多选状态栏
  });
  function handleEdit(record: Recordable) {
    console.log('点击了编辑', record);
  }
  function handleDelete(record: Recordable) {
    console.log('点击了删除', record);
  }
  function handleOpen(record: Recordable) {
    console.log('点击了启用', record);
  }
</script>