resultTable.vue 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  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. <a class="table-action-link" @click="upload(record)">导出</a>
  11. <!-- <TableAction :actions="createActions(record, column)" /> -->
  12. <!-- <a href="javascript:void(0)" ><Icon icon="ant-design:delete-outlined"></Icon></a> -->
  13. </template>
  14. </template>
  15. <template #expandedRowRender="{ record }">
  16. <a-empty v-if="record.testDetail && record.testDetail.length < 1" />
  17. <a-table v-else :columns="innerResultColumns" :data-source="record.testDetail" rowKey="id" size="small" :pagination="false">
  18. <template #bodyCell="{ record, column }">
  19. <template v-if="record[column.dataIndex] === null">
  20. <span>-</span>
  21. </template>
  22. </template>
  23. </a-table>
  24. </template>
  25. <!-- <template></template> -->
  26. </a-table>
  27. </template>
  28. <script lang="ts">
  29. import { resultList } from '/@/views/vent/monitorManager/windrectMonitor/windrect.api';
  30. import { ref, onMounted } from 'vue';
  31. import { resultColumns, innerResultColumns } from '../windrect.data';
  32. import { BasicTable, TableAction, BasicColumn, ActionItem, EditRecordRow } from '/@/components/Table';
  33. import { getExportUrl } from '../windrect.api';
  34. import { useMethods } from '/@/hooks/system/useMethods';
  35. export default {
  36. name: 'ResultTable',
  37. components: { TableAction },
  38. props: {
  39. deviceType: {
  40. type: String,
  41. required: true,
  42. },
  43. },
  44. setup() {
  45. const loading = ref(false);
  46. const dataSource = ref([]);
  47. const { handleExportXls } = useMethods();
  48. const getMonitor = () => {
  49. resultList({}).then((res) => {
  50. loading.value = false;
  51. dataSource.value = res.records;
  52. });
  53. };
  54. function createActions(record: EditRecordRow, column: BasicColumn): ActionItem[] {
  55. return [
  56. {
  57. label: '导出',
  58. onClick: handleExportXls.bind(null, '测风报表-' + new Date().toLocaleString(), getExportUrl, { testid: record.id }),
  59. },
  60. ];
  61. };
  62. function upload(record: EditRecordRow) {
  63. let d = new Date();
  64. let customFormattedDate = `${d.getFullYear()}-${String(d.getMonth() + 1).padStart(2, '0')}-${String(d.getDate()).padStart(2, '0')}`;
  65. handleExportXls('测风报表-' + customFormattedDate, getExportUrl, { testid: record.id });
  66. };
  67. onMounted(() => {
  68. loading.value = true;
  69. getMonitor();
  70. });
  71. return {
  72. dataSource,
  73. resultColumns,
  74. innerResultColumns,
  75. loading,
  76. createActions,
  77. upload
  78. };
  79. },
  80. };
  81. </script>