resultTable.vue 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  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" :pagination="false">
  17. <template #bodyCell="{ record, column }">
  18. <template v-if="record[column.dataIndex] === null">
  19. <span>-</span>
  20. </template>
  21. </template>
  22. </a-table>
  23. </template>
  24. <!-- <template></template> -->
  25. </a-table>
  26. </template>
  27. <script lang="ts">
  28. import { resultList } from '/@/views/vent/monitorManager/windrectMonitor/windrect.api';
  29. import { ref, onMounted } from "vue";
  30. import { resultColumns, innerResultColumns } from '../windrect.data';
  31. import { BasicTable, TableAction, BasicColumn, ActionItem, EditRecordRow } from '/@/components/Table';
  32. import { getExportUrl } from '../windrect.api'
  33. import { useMethods } from '/@/hooks/system/useMethods';
  34. export default {
  35. name: 'ResultTable',
  36. props: {
  37. deviceType: {
  38. type: String,
  39. required: true,
  40. },
  41. },
  42. components: { TableAction },
  43. setup() {
  44. const loading = ref(false)
  45. const dataSource = ref([]);
  46. const { handleExportXls } = useMethods();
  47. const getMonitor = () => {
  48. resultList({}).then((res) => {
  49. loading.value = false
  50. dataSource.value = res.records
  51. });
  52. };
  53. function createActions(record: EditRecordRow, column: BasicColumn): ActionItem[] {
  54. return [
  55. {
  56. label: '导出',
  57. onClick: handleExportXls.bind(null, '测风报表导出', getExportUrl, { testid : record.id}),
  58. },
  59. ];
  60. }
  61. onMounted(() => {
  62. loading.value = true
  63. getMonitor();
  64. });
  65. return {
  66. dataSource,
  67. resultColumns,
  68. innerResultColumns,
  69. loading,
  70. createActions
  71. };
  72. },
  73. };
  74. </script>