index.vue
2.67 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
<script lang="ts" setup>
import { BasicTable, useTable } from '/@/components/Table';
import { columns, formSchemas } from './config';
import { BasicModal, useModal } from '/@/components/Modal';
import { Input } from 'ant-design-vue';
import { ref } from 'vue';
import { EdgeDeviceItemType } from '/@/api/edgeManage/model/edgeInstance';
import { EventManageRequest } from '/@/api/device/model/eventManageModel';
import { getEventManageListRecord } from '/@/api/device/eventManage';
import { EyeOutlined } from '@ant-design/icons-vue';
import { useI18n } from '/@/hooks/web/useI18n';
const { t } = useI18n();
const props = defineProps({
recordData: {
type: Object as PropType<EdgeDeviceItemType>,
default: () => {},
},
});
const outputData = ref<string>();
const [registerTable] = useTable({
columns,
api: getEventManageListRecord,
fetchSetting: {
totalField: 'totalElements',
listField: 'data',
},
beforeFetch: (params: EventManageRequest) => {
const page = params.page - 1 < 0 ? 0 : params.page - 1;
const _params = Object.keys(params)
.filter((key) => params[key])
.reduce((prev, next) => ({ ...prev, [next]: params[next] }), {});
return {
..._params,
page,
startTime: params.startTime ? new Date(params.startTime).getTime() : params.startTime,
endTime: params.endTime ? new Date(params.endTime).getTime() : params.endTime,
tbDeviceId: props?.recordData?.id?.id,
};
},
formConfig: {
labelWidth: 80,
schemas: formSchemas,
fieldMapToTime: [['dateRange', ['startTime', 'endTime'], 'YYYY-MM-DD HH:mm:ss']],
},
useSearchForm: true,
showIndexColumn: false,
clickToRowSelect: false,
showTableSetting: true,
bordered: true,
rowKey: 'id',
});
const [registerModal, { openModal, closeModal }] = useModal();
const handleViewDetail = (record: Record<'eventValue', Recordable>) => {
outputData.value = JSON.stringify(record.eventValue, null, 2);
openModal(true);
};
</script>
<template>
<div>
<BasicTable :clickToRowSelect="false" @register="registerTable">
<template #outputParams="{ record }">
<span class="cursor-pointer text-blue-500" @click="handleViewDetail(record)">
<EyeOutlined class="svg:text-blue-500" />
<span class="ml-2">{{ t('common.detailText') }}</span>
</span>
</template>
</BasicTable>
<BasicModal
:title="t('deviceManagement.product.outputDataText')"
@register="registerModal"
@ok="closeModal"
>
<Input.TextArea v-model:value="outputData" :autosize="true" />
</BasicModal>
</div>
</template>