resultTable.vue 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. <template>
  2. <!-- <BasicTable @register="registerTable" @edit-change="handleEditChange">
  3. <template #action="{ record, column }">
  4. <TableAction :actions="createActions(record, column)" />
  5. </template>
  6. </BasicTable> -->
  7. <a-table :columns="resultColumns" :data-source="dataSource" rowKey="id" class="components-table-demo-nested" :loading="loading" size="small" >
  8. <template #bodyCell="{ record, column }">
  9. <template v-if="column.dataIndex === 'action'">
  10. <TableAction :actions="createActions(record, column)" />
  11. <!-- <a href="javascript:void(0)" ><Icon icon="ant-design:delete-outlined"></Icon></a> -->
  12. </template>
  13. </template>
  14. <template #expandedRowRender="{record}">
  15. <a-empty v-if="record.testDetail && record.testDetail.length < 1"/>
  16. <a-table v-else :columns="innerResultColumns" :data-source="record.testDetail" rowKey="id" size="small">
  17. </a-table>
  18. </template>
  19. <!-- <template></template> -->
  20. </a-table>
  21. </template>
  22. <script lang="ts">
  23. import { resultList } from '/@/views/vent/monitorManager/windrectMonitor/windrect.api';
  24. import { ref, onMounted } from "vue";
  25. import { resultColumns, innerResultColumns } from '../windrect.data';
  26. import { BasicTable, TableAction, BasicColumn, ActionItem, EditRecordRow } from '/@/components/Table';
  27. import { getExportUrl } from '../windrect.api'
  28. import { useMethods } from '/@/hooks/system/useMethods';
  29. export default {
  30. name: 'ResultTable',
  31. props: {
  32. deviceType: {
  33. type: String,
  34. required: true,
  35. },
  36. },
  37. components: { TableAction },
  38. setup() {
  39. const loading = ref(false)
  40. const dataSource = ref([]);
  41. const { handleExportXls } = useMethods();
  42. const getMonitor = () => {
  43. resultList({}).then((res) => {
  44. loading.value = false
  45. dataSource.value = res.records
  46. });
  47. };
  48. function createActions(record: EditRecordRow, column: BasicColumn): ActionItem[] {
  49. return [
  50. {
  51. label: '导出',
  52. onClick: handleExportXls.bind(null, '测风报表导出', getExportUrl, { testid : record.id}),
  53. },
  54. {
  55. label: '删除',
  56. },
  57. ];
  58. }
  59. onMounted(() => {
  60. loading.value = true
  61. getMonitor();
  62. });
  63. return {
  64. dataSource,
  65. resultColumns,
  66. innerResultColumns,
  67. loading,
  68. createActions
  69. };
  70. },
  71. };
  72. </script>