Commit 25c0900a by zhaochengxiang

采集

parent d482e183
import React, { useState, useEffect, useContext, useMemo, useReducer } from 'react';
import { Space, Button, TreeSelect, Select, Pagination, Typography, Modal, Tooltip } from 'antd';
import { Space, Button, TreeSelect, Select, Pagination, Typography, Modal, Tooltip, Input } from 'antd';
import { AppContext } from '../../../../App';
import { dispatch } from '../../../../model';
......@@ -20,6 +20,7 @@ const FC = (props) => {
const [tasksProgress, setTasksProgress] = useState(undefined);
const [visibleCols, setVisibleCols] = useState(undefined);
const [checkedKeys, setCheckedKeys] = useState(undefined);
const [keyword, setKeyword] = useState(undefined);
const [updateTaskParam, setUpdateTaskParam] = useState({
visible: false,
......@@ -189,6 +190,7 @@ const FC = (props) => {
return (configState.scope===undefined || item.target?.scope === configState.scope?.toString())
&& (configState.datasourceId===undefined || item.target?.id === configState.datasourceId)
&& (configState.targetType===undefined || item.target?.type === configState.targetType)
&& (!keyword || (item.taskCode||'').indexOf(keyword)!==-1 || (item.schema||'').indexOf(keyword)!==-1)
});
newTasks?.forEach(item => {
const index = (supportedTargetTypes||[]).findIndex(_item => _item.targetType === item.type);
......@@ -207,13 +209,14 @@ const FC = (props) => {
})
}
console.log('newTasks', newTasks);
newTasks = paginate(newTasks, pagination.pageNum, pagination.pageSize);
return newTasks;
}
return []
}, [tasks, pagination, configState, supportedTargetTypes, sortedInfo])
}, [tasks, pagination, configState, supportedTargetTypes, sortedInfo, keyword])
const total = useMemo(() => {
if (tasks) {
......@@ -221,13 +224,14 @@ const FC = (props) => {
return (configState.scope===undefined || item.target?.scope === configState.scope?.toString())
&& (configState.datasourceId===undefined || item.target?.id === configState.datasourceId)
&& (configState.targetType===undefined || item.target?.type === configState.targetType)
&& (!keyword || item.taskCode?.indexOf(keyword)!==-1 || item.schema?.indexOf(keyword)!==-1)
});
return (newTasks||[]).length;
}
return 0;
}, [tasks, pagination, configState])
}, [tasks, pagination, configState, keyword])
const getAllTasks = () => {
setLoadingTasks(true);
......@@ -308,6 +312,10 @@ const FC = (props) => {
refresh && getTaskCols();
}
const onSearchInputChange = (e) => {
setKeyword(e.target.value||'');
}
const onCancelTask = (task) => {
modal.confirm({
title: '是否取消该任务?',
......@@ -411,11 +419,20 @@ const FC = (props) => {
<Button disabled={(checkedKeys||[]).length===0} onClick={onDeleteTasks}>删除</Button>
</Tooltip>
</Space>
<Space>
<Config setTargetTypes={setSupportedTargetTypes} onState={(state) => {
console.log('state', state);
setConfigState(state);
setPagination({...pagination, pageNum: 1});
}} />
<Input
placeholder='请输入任务编号/抽取Schema名称'
allowClear
value={keyword}
onChange={onSearchInputChange}
style={{ width: 260 }}
/>
</Space>
</div>
<Table
className='mt-3'
......
......@@ -7,7 +7,7 @@ import { AppContext } from '../../../../App';
import { dispatch } from '../../../../model';
import { paginate } from '../../../../util';
import Table from '../../ResizeableTable';
import env from '../../../../service/samples/env.json';
// import env from '../../../../service/samples/env.json';
const { RangePicker } = DatePicker;
const { Meta } = Card;
......@@ -25,7 +25,7 @@ const reportStates = [
]
const FC = (props) => {
// const { env } = useContext(AppContext);
const { env } = useContext(AppContext);
const [rangeValue, setRangeValue] = useState(undefined);
const [summaryData, setSummaryData] = useState(undefined);
const [reportData, setReportData] = useState(undefined);
......@@ -96,7 +96,7 @@ const FC = (props) => {
return (taskCode===undefined || item.taskCode === taskCode)
&& (datasourceName===undefined || item.databaseName === datasourceName)
&& (reportState===undefined || item.state === reportState)
&& (!keyword || item.taskCode?.indexOf(keyword)!==-1 || item.databaseName?.indexOf(keyword)!==-1)
&& (!keyword || (item.taskCode||'').indexOf(keyword)!==-1 || (item.databaseName||'').indexOf(keyword)!==-1)
});
setSummaryData([
......
......@@ -2,5 +2,5 @@
height: calc(100vh - 124px);
padding: 20px;
background: #fff;
overflow: auto;
overflow: hidden;
}
\ No newline at end of file
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