BasicTableBorder.vue 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. <template>
  2. <!--引用表格-->
  3. <div class="p-4">
  4. <BasicTable @register="registerTable">
  5. <template #bodyCell="{ column, text }">
  6. <template v-if="column.dataIndex === 'name'">
  7. <a>{{ text }}</a>
  8. </template>
  9. </template>
  10. <template #footer>页脚</template>
  11. </BasicTable>
  12. </div>
  13. </template>
  14. <script lang="ts" name="basic-table-demo" setup>
  15. import { ActionItem, BasicColumn, BasicTable, TableAction } from '/@/components/Table';
  16. import { useListPage } from '/@/hooks/system/useListPage';
  17. //定义表格列
  18. const columns: BasicColumn[] = [
  19. {
  20. title: '姓名',
  21. dataIndex: 'name',
  22. key: 'name',
  23. width: 300,
  24. },
  25. {
  26. title: '年龄',
  27. dataIndex: 'age',
  28. key: 'age',
  29. width: 300,
  30. },
  31. {
  32. title: '住址',
  33. dataIndex: 'address',
  34. key: 'address',
  35. ellipsis: true,
  36. },
  37. {
  38. title: '长内容列',
  39. dataIndex: 'address',
  40. key: 'address 2',
  41. ellipsis: true,
  42. },
  43. {
  44. title: '长内容列',
  45. dataIndex: 'address',
  46. key: 'address 3',
  47. ellipsis: true,
  48. },
  49. ];
  50. // 列表页面公共参数、方法
  51. const { tableContext } = useListPage({
  52. designScope: 'basic-table-demo',
  53. tableProps: {
  54. title: '边框表格',
  55. dataSource: [
  56. {
  57. key: '1',
  58. name: '张三',
  59. age: 32,
  60. address: '中国北京北京市朝阳区大屯路科学院南里1号楼3单元401',
  61. },
  62. {
  63. key: '2',
  64. name: '刘思',
  65. age: 32,
  66. address: '中国北京北京市昌平区顺沙路尚湖世家2号楼7单元503',
  67. },
  68. ],
  69. columns: columns,
  70. showActionColumn: false,
  71. useSearchForm: false,
  72. },
  73. });
  74. //注册table数据
  75. const [registerTable] = tableContext;
  76. /**
  77. * 操作栏
  78. */
  79. function getTableAction(record): ActionItem[] {
  80. return [
  81. {
  82. label: '编辑',
  83. onClick: handleEdit.bind(null, record),
  84. },
  85. ];
  86. }
  87. function handleEdit(record) {
  88. console.log(record);
  89. }
  90. </script>
  91. <style scoped></style>