MonitorTable1.vue 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. <template>
  2. <div class="monitor-table">
  3. <!-- <BasicTable @register="registerTable" :rowSelection="rowSelection">
  4. <template #action="{ record }">
  5. <TableAction :actions="getActions(record)" :dropDownActions="getDropDownAction(record)" />
  6. </template>
  7. </BasicTable> -->
  8. <a-table :row-selection="rowSelection" :columns="columns.value" :data-source="dataTableSource" row-key="dataIndex">
  9. <template #name="{ text }">
  10. <a>{{ text }}</a>
  11. </template>
  12. </a-table>
  13. </div>
  14. </template>
  15. <script lang="ts" name="system-user" setup>
  16. //ts语法
  17. import { computed } from '@vue/reactivity';
  18. import { debug } from 'console';
  19. import { defineExpose, toRaw, watch, ref } from 'vue';
  20. import { BasicColumn } from '/@/components/Table';
  21. import { getTableHeaderColumns, setWebColumnsKey } from '/@/hooks/web/useWebColumns';
  22. const props = defineProps({
  23. columnsType: {
  24. type: String,
  25. required: true,
  26. },
  27. dataSource: {
  28. type: Array,
  29. required: true,
  30. },
  31. searchFormSchema: {
  32. type: Array,
  33. default: () => [],
  34. },
  35. list: {
  36. type: Function,
  37. // required: true,
  38. },
  39. designScope: {
  40. type: String,
  41. },
  42. title: {
  43. type: String,
  44. },
  45. });
  46. const dataTableSource = ref([]);
  47. watch(
  48. () => props.dataSource,
  49. (newVal) => {
  50. const list = [];
  51. newVal.forEach((item) => {
  52. list.push(toRaw(item));
  53. });
  54. dataTableSource.value = list;
  55. }
  56. );
  57. setWebColumnsKey(props.columnsType);
  58. const columns = computed(() => getTableHeaderColumns);
  59. /**
  60. * 操作列定义
  61. * @param record
  62. */
  63. function getActions(record) {
  64. return [
  65. {
  66. label: '详情',
  67. onClick: openDetail.bind(null, record),
  68. },
  69. ];
  70. }
  71. const rowSelection = {
  72. onChange: (selectedRowKeys: [], selectedRows: BasicColumn[]) => {
  73. console.log(`selectedRowKeys: ${selectedRowKeys}`, 'selectedRows: ', selectedRows);
  74. },
  75. // getCheckboxProps: (record: BasicColumn) => ({
  76. // disabled: record.name === 'Disabled User', // Column configuration not to be checked
  77. // name: record.name,
  78. // }),
  79. };
  80. function openDetail(record) {
  81. record;
  82. }
  83. </script>
  84. <style scoped lang="less">
  85. :deep(.ant-table-body) {
  86. height: auto !important;
  87. }
  88. .monitor-table{
  89. width: 100%;
  90. }
  91. </style>