|
@@ -1,6 +1,16 @@
|
|
|
-import { service } from '@/pages/device/Instance';
|
|
|
|
|
|
|
+import { InstanceModel, service } from '@/pages/device/Instance';
|
|
|
import { useParams } from 'umi';
|
|
import { useParams } from 'umi';
|
|
|
-import { DatePicker, Modal, Radio, Select, Space, Table, Tabs } from 'antd';
|
|
|
|
|
|
|
+import {
|
|
|
|
|
+ DatePicker,
|
|
|
|
|
+ Modal,
|
|
|
|
|
+ Popconfirm,
|
|
|
|
|
+ Radio,
|
|
|
|
|
+ Select,
|
|
|
|
|
+ Space,
|
|
|
|
|
+ Table,
|
|
|
|
|
+ Tabs,
|
|
|
|
|
+ Tooltip as ATooltip,
|
|
|
|
|
+} from 'antd';
|
|
|
import type { PropertyMetadata } from '@/pages/device/Product/typings';
|
|
import type { PropertyMetadata } from '@/pages/device/Product/typings';
|
|
|
import encodeQuery from '@/utils/encodeQuery';
|
|
import encodeQuery from '@/utils/encodeQuery';
|
|
|
import { useEffect, useState } from 'react';
|
|
import { useEffect, useState } from 'react';
|
|
@@ -9,6 +19,7 @@ import { Axis, Chart, Geom, Legend, Tooltip, Slider } from 'bizcharts';
|
|
|
import FileComponent from '../../Running/Property/FileComponent';
|
|
import FileComponent from '../../Running/Property/FileComponent';
|
|
|
import { DownloadOutlined, SearchOutlined } from '@ant-design/icons';
|
|
import { DownloadOutlined, SearchOutlined } from '@ant-design/icons';
|
|
|
import Detail from './Detail';
|
|
import Detail from './Detail';
|
|
|
|
|
+import AMap from './AMap';
|
|
|
interface Props {
|
|
interface Props {
|
|
|
visible: boolean;
|
|
visible: boolean;
|
|
|
close: () => void;
|
|
close: () => void;
|
|
@@ -33,6 +44,8 @@ const PropertyLog = (props: Props) => {
|
|
|
const [detailVisible, setDetailVisible] = useState<boolean>(false);
|
|
const [detailVisible, setDetailVisible] = useState<boolean>(false);
|
|
|
const [current, setCurrent] = useState<any>('');
|
|
const [current, setCurrent] = useState<any>('');
|
|
|
|
|
|
|
|
|
|
+ const [geoList, setGeoList] = useState<any[]>([]);
|
|
|
|
|
+
|
|
|
const columns = [
|
|
const columns = [
|
|
|
{
|
|
{
|
|
|
title: '时间',
|
|
title: '时间',
|
|
@@ -62,13 +75,49 @@ const PropertyLog = (props: Props) => {
|
|
|
}}
|
|
}}
|
|
|
/>
|
|
/>
|
|
|
) : (
|
|
) : (
|
|
|
- <DownloadOutlined />
|
|
|
|
|
|
|
+ <ATooltip title="下载">
|
|
|
|
|
+ <Popconfirm
|
|
|
|
|
+ title="确认修改"
|
|
|
|
|
+ onConfirm={() => {
|
|
|
|
|
+ const type = (record?.value || '').split('.').pop();
|
|
|
|
|
+ const downloadUrl = record.value;
|
|
|
|
|
+ const downNode = document.createElement('a');
|
|
|
|
|
+ downNode.href = downloadUrl;
|
|
|
|
|
+ downNode.download = `${InstanceModel.detail.name}-${data.name}${moment(
|
|
|
|
|
+ new Date().getTime(),
|
|
|
|
|
+ ).format('YYYY-MM-DD-HH-mm-ss')}.${type}`;
|
|
|
|
|
+ downNode.style.display = 'none';
|
|
|
|
|
+ document.body.appendChild(downNode);
|
|
|
|
|
+ downNode.click();
|
|
|
|
|
+ document.body.removeChild(downNode);
|
|
|
|
|
+ }}
|
|
|
|
|
+ >
|
|
|
|
|
+ <DownloadOutlined />
|
|
|
|
|
+ </Popconfirm>
|
|
|
|
|
+ </ATooltip>
|
|
|
)}
|
|
)}
|
|
|
</a>
|
|
</a>
|
|
|
),
|
|
),
|
|
|
},
|
|
},
|
|
|
];
|
|
];
|
|
|
|
|
|
|
|
|
|
+ const geoColumns = [
|
|
|
|
|
+ {
|
|
|
|
|
+ title: '时间',
|
|
|
|
|
+ dataIndex: 'timestamp',
|
|
|
|
|
+ key: 'timestamp',
|
|
|
|
|
+ render: (text: any) => <span>{text ? moment(text).format('YYYY-MM-DD HH:mm:ss') : ''}</span>,
|
|
|
|
|
+ },
|
|
|
|
|
+ {
|
|
|
|
|
+ title: '位置',
|
|
|
|
|
+ dataIndex: 'value',
|
|
|
|
|
+ key: 'value',
|
|
|
|
|
+ render: (text: any, record: any) => (
|
|
|
|
|
+ <FileComponent type="table" value={{ formatValue: record.value }} data={data} />
|
|
|
|
|
+ ),
|
|
|
|
|
+ },
|
|
|
|
|
+ ];
|
|
|
|
|
+
|
|
|
const tabList = [
|
|
const tabList = [
|
|
|
{
|
|
{
|
|
|
tab: '列表',
|
|
tab: '列表',
|
|
@@ -140,7 +189,6 @@ const PropertyLog = (props: Props) => {
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
useEffect(() => {
|
|
useEffect(() => {
|
|
|
- console.log(data);
|
|
|
|
|
if (visible) {
|
|
if (visible) {
|
|
|
handleSearch(
|
|
handleSearch(
|
|
|
{
|
|
{
|
|
@@ -179,7 +227,7 @@ const PropertyLog = (props: Props) => {
|
|
|
);
|
|
);
|
|
|
}}
|
|
}}
|
|
|
dataSource={dataSource?.data || []}
|
|
dataSource={dataSource?.data || []}
|
|
|
- columns={columns}
|
|
|
|
|
|
|
+ columns={data?.valueType?.type === 'geoPoint' ? geoColumns : columns}
|
|
|
pagination={{
|
|
pagination={{
|
|
|
pageSize: dataSource?.pageSize || 10,
|
|
pageSize: dataSource?.pageSize || 10,
|
|
|
showSizeChanger: true,
|
|
showSizeChanger: true,
|
|
@@ -317,7 +365,8 @@ const PropertyLog = (props: Props) => {
|
|
|
visible={visible}
|
|
visible={visible}
|
|
|
onCancel={() => close()}
|
|
onCancel={() => close()}
|
|
|
onOk={() => close()}
|
|
onOk={() => close()}
|
|
|
- width="45vw"
|
|
|
|
|
|
|
+ destroyOnClose={true}
|
|
|
|
|
+ width="50vw"
|
|
|
>
|
|
>
|
|
|
<div style={{ marginBottom: '20px' }}>
|
|
<div style={{ marginBottom: '20px' }}>
|
|
|
<Space>
|
|
<Space>
|
|
@@ -430,6 +479,22 @@ const PropertyLog = (props: Props) => {
|
|
|
});
|
|
});
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
+ if (key === 'geo') {
|
|
|
|
|
+ service
|
|
|
|
|
+ .getPropertyData(
|
|
|
|
|
+ params.id,
|
|
|
|
|
+ encodeQuery({
|
|
|
|
|
+ paging: false,
|
|
|
|
|
+ terms: { property: data.id, timestamp$BTW: start && end ? [start, end] : [] },
|
|
|
|
|
+ sorts: { timestamp: 'desc' },
|
|
|
|
|
+ }),
|
|
|
|
|
+ )
|
|
|
|
|
+ .then((resp) => {
|
|
|
|
|
+ if (resp.status === 200) {
|
|
|
|
|
+ setGeoList(resp.result);
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
|
|
+ }
|
|
|
}}
|
|
}}
|
|
|
>
|
|
>
|
|
|
{tabList.map((item) => (
|
|
{tabList.map((item) => (
|
|
@@ -437,6 +502,11 @@ const PropertyLog = (props: Props) => {
|
|
|
{renderComponent(item.key)}
|
|
{renderComponent(item.key)}
|
|
|
</Tabs.TabPane>
|
|
</Tabs.TabPane>
|
|
|
))}
|
|
))}
|
|
|
|
|
+ {data?.valueType?.type === 'geoPoint' && (
|
|
|
|
|
+ <Tabs.TabPane tab="轨迹" key="geo">
|
|
|
|
|
+ <AMap value={geoList} name={data.name} />
|
|
|
|
|
+ </Tabs.TabPane>
|
|
|
|
|
+ )}
|
|
|
</Tabs>
|
|
</Tabs>
|
|
|
{detailVisible && (
|
|
{detailVisible && (
|
|
|
<Detail
|
|
<Detail
|