Commit fc499916 by zhaochengxiang

采集

parent 3c230def
import React, { useState, useEffect, useContext, useMemo } from 'react';
import { Space, DatePicker, Row, Col, Card, Spin, Empty, Typography, Pagination, Input } from 'antd';
import { Space, DatePicker, Row, Col, Card, Spin, Empty, Typography, Pagination, Input, Select } from 'antd';
import 'moment/locale/zh-cn';
import locale from 'antd/es/date-picker/locale/zh_CN';
......@@ -18,16 +18,27 @@ function compare(val1, val2) {
return (a - b);
}
const reportStates = [
{ title: '完成', key: '' },
{ title: '失败', key: '' },
{ title: '执行中', key: '' },
{ title: '已取消', key: '' },
]
const FC = (props) => {
// const { env } = useContext(AppContext);
const [rangeValue, setRangeValue] = useState(undefined);
const [datasources, setDatasources] = useState(undefined);
const [summaryData, setSummaryData] = useState(undefined);
const [reportData, setReportData] = useState(undefined);
const [tracerData, setTracerData] = useState(undefined);
const [loadingReport, setLoadingReport] = useState(false);
const [pagination, setPagination] = useState({pageNum: 1, pageSize: 20});
const [keyword, setKeyword] = useState(undefined);
const [datasourceId, setDatasourceId] = useState(undefined);
const [reportState, setReportState] = useState('');
const [loadingDatasources, setLoadingDatasources] = useState(false);
const [datasources, setDatasources] = useState([]);
const {pageNum, pageSize} = pagination;
......@@ -76,8 +87,26 @@ const FC = (props) => {
useEffect(() => {
getTaskReportSummary();
getTaskReportDetail();
getDatasources();
}, [env])
const getDatasources = () => {
setLoadingDatasources(true);
dispatch({
type: 'datasource.getAllDatasources',
payload: {
namespace: env?.domainId,
},
callback: data => {
setLoadingDatasources(false);
setDatasources(data);
},
error: () => {
setLoadingDatasources(false);
}
})
}
const getTaskReportSummary = () => {
dispatch({
type: 'datasource.getTaskReportSummary',
......@@ -142,6 +171,10 @@ const FC = (props) => {
setRangeValue(value?.map(item => item.valueOf()));
}
const onDatasourceChange = (value) => {
setDatasourceId(value);
}
const onSearchInputChange = (e) => {
setKeyword(e.target.value||'');
}
......@@ -152,7 +185,7 @@ const FC = (props) => {
return (
<div>
<div>
<div className='flex' style={{ justifyContent: 'end' }}>
<Space>
<RangePicker
locale={locale}
......@@ -161,6 +194,28 @@ const FC = (props) => {
onChange={onTimeChange}
onOk={onTimeOk}
/>
<Select
allowClear
loading={loadingDatasources}
value={datasourceId}
placeholder='请选择数据库'
style={{ width: 170 }}
onChange={onDatasourceChange}
>
{
datasources?.map((item, index) => {
const nameIndex = item.targetParameters?.findIndex(_item => _item.name === 'name');
let name = '';
if (nameIndex !== -1) {
name = item.targetParameters[nameIndex].value;
}
return (
<Select.Option key={index} value={item.id}>{name}</Select.Option>
);
})
}
</Select>
<Input
placeholder='请输入任务编号/数据库'
allowClear
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment