Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
S
szse
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
zhaochengxiang
szse
Commits
f947c507
Commit
f947c507
authored
Jul 14, 2021
by
zhaochengxiang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
采集调度
parent
a1b9c621
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
118 additions
and
55 deletions
+118
-55
ScheduleAction.jsx
...view/Manage/DatasourceManage/Component/ScheduleAction.jsx
+75
-23
ScheduleCURDModal.jsx
...w/Manage/DatasourceManage/Component/ScheduleCURDModal.jsx
+36
-32
ScheduleCURDModal.less
.../Manage/DatasourceManage/Component/ScheduleCURDModal.less
+7
-0
No files found.
src/view/Manage/DatasourceManage/Component/ScheduleAction.jsx
View file @
f947c507
import
React
,
{
useEffect
,
useState
}
from
'react'
;
import
{
Modal
,
Select
,
Form
,
Input
,
Divider
,
Space
,
Button
,
Switch
,
TimePicker
}
from
'antd'
;
import
{
Select
,
Form
,
Input
,
Switch
,
TimePicker
,
Cascader
,
Row
,
Col
}
from
'antd'
;
import
moment
from
'moment'
;
import
{
dispatch
}
from
'../../../../model'
;
import
{
showMessage
}
from
'../../../../util'
;
const
{
Option
}
=
Select
;
const
ScheduleAction
=
(
props
)
=>
{
const
{
action
,
id
,
form
,
tid
}
=
props
;
const
{
action
,
id
,
form
,
tid
,
onChange
}
=
props
;
const
[
schedule
,
setSchedule
]
=
useState
({});
const
[
currentExeCycleType
,
setCurrentExeCycleType
]
=
useState
(
null
);
useEffect
(()
=>
{
reset
();
...
...
@@ -31,6 +27,7 @@ const ScheduleAction = (props) => {
},
callback
:
data
=>
{
setSchedule
(
data
||
{});
onChange
&&
onChange
(
data
||
{});
}
});
}
...
...
@@ -53,18 +50,11 @@ const ScheduleAction = (props) => {
setSchedule
(
data
||
{});
setFormFiledsValue
(
data
||
{});
onChange
&&
onChange
(
data
||
{});
}
})
}
const
getCurrentExeCycleType
=
(
data
)
=>
{
(
data
?.
scheduleParameters
||
[]).
forEach
(
item
=>
{
if
(
item
.
name
===
'exeCycleType'
)
{
setCurrentExeCycleType
(
item
.
value
);
}
});
}
const
setFormFiledsValue
=
(
data
)
=>
{
let
_fieldsValue
=
{};
...
...
@@ -75,6 +65,8 @@ const ScheduleAction = (props) => {
_fieldsValue
[
item
.
name
||
''
]
=
(
item
.
value
===
"1"
)
?
true
:
false
;
}
else
if
(
item
.
selectMode
===
'timePicker'
)
{
_fieldsValue
[
item
.
name
||
''
]
=
moment
(
item
.
value
,
'HH:mm:ss'
);
}
else
if
(
item
.
selectMode
===
'cascader'
)
{
_fieldsValue
[
item
.
name
||
''
]
=
(
item
.
value
||
''
).
split
(
','
);
}
});
...
...
@@ -84,6 +76,8 @@ const ScheduleAction = (props) => {
_fieldsValue
[
item
.
name
||
''
]
=
(
item
.
value
===
"1"
)
?
true
:
false
;
}
else
if
(
item
.
selectMode
===
'timePicker'
)
{
_fieldsValue
[
item
.
name
||
''
]
=
moment
(
item
.
value
,
'HH:mm:ss'
);
}
else
if
(
item
.
selectMode
===
'cascader'
)
{
_fieldsValue
[
item
.
name
||
''
]
=
(
item
.
value
||
''
).
split
(
','
);
}
});
...
...
@@ -94,6 +88,36 @@ const ScheduleAction = (props) => {
form
.
resetFields
();
}
const
onValuesChange
=
(
changedValues
,
allValues
)
=>
{
let
newSchedule
=
JSON
.
parse
(
JSON
.
stringify
(
schedule
));
(
newSchedule
?.
targetParameters
||
[]).
forEach
(
item
=>
{
item
.
value
=
allValues
[
item
.
name
];
if
(
item
.
selectMode
===
'switch'
)
{
item
.
value
=
(
allValues
[
item
.
name
||
''
]
===
true
)?
'1'
:
'0'
;
}
else
if
(
item
.
selectMode
===
'timePicker'
)
{
item
.
value
=
allValues
[
item
.
name
||
''
].
format
(
'HH:mm:ss'
);
}
else
if
(
item
.
selectMode
===
'cascader'
)
{
item
.
value
=
allValues
[
item
.
name
||
''
].
join
(
','
);
}
});
(
newSchedule
?.
scheduleParameters
||
[]).
forEach
(
item
=>
{
item
.
value
=
allValues
[
item
.
name
];
if
(
item
.
selectMode
===
'switch'
)
{
item
.
value
=
(
allValues
[
item
.
name
||
''
]
===
true
)?
'1'
:
'0'
;
}
else
if
(
item
.
selectMode
===
'timePicker'
)
{
item
.
value
=
allValues
[
item
.
name
||
''
].
format
(
'HH:mm:ss'
);
}
else
if
(
item
.
selectMode
===
'cascader'
)
{
item
.
value
=
allValues
[
item
.
name
||
''
].
join
(
','
);
}
});
onChange
&&
onChange
(
newSchedule
);
}
const
formItemLayout
=
{
labelCol
:
{
xs
:
{
span
:
24
},
...
...
@@ -113,14 +137,9 @@ const ScheduleAction = (props) => {
if
(
item
.
selectMode
===
'singleSelect'
)
{
const
_datas
=
[];
if
(
item
.
name
===
'exeDay'
)
{
}
else
{
for
(
var
key
in
item
.
selectItemMap
)
{
_datas
.
push
({
key
,
value
:
item
.
selectItemMap
[
key
]});
}
}
return
(
<
Select
>
...
...
@@ -135,6 +154,13 @@ const ScheduleAction = (props) => {
);
}
if
(
item
.
selectMode
===
'cascader'
)
{
return
<
Cascader
options=
{
item
.
selectItemList
}
expandTrigger=
"hover"
/>
}
if
(
item
.
selectMode
===
'timePicker'
)
{
return
<
TimePicker
/>;
}
...
...
@@ -146,36 +172,62 @@ const ScheduleAction = (props) => {
}
return
(
<
Form
{
...
formItemLayout
}
form=
{
form
}
>
<
Form
{
...
formItemLayout
}
form=
{
form
}
onValuesChange=
{
onValuesChange
}
>
<
Row
gutter=
{
10
}
>
{
schedule
&&
(
schedule
.
targetParameters
||
[]).
map
((
item
,
index
)
=>
{
let
_type
=
'string'
;
if
(
item
.
selectMode
===
'switch'
)
{
_type
=
'boolean'
;
}
else
if
(
item
.
selectMode
===
'timePicker'
)
{
_type
=
'object'
;
}
else
if
(
item
.
selectMode
===
'cascader'
)
{
_type
=
'array'
;
}
return
(
<
Col
span=
{
12
}
key=
{
index
}
>
<
Form
.
Item
label=
{
item
.
cnName
||
''
}
name=
{
item
.
name
||
''
}
key=
{
index
}
rules=
{
[{
required
:
item
.
required
,
message
:
'必填项'
,
type
:
(
item
.
selectMode
===
'timePicker'
)?
'object'
:
'string'
}]
}
rules=
{
[{
required
:
item
.
required
,
message
:
'必填项'
,
type
:
_type
}]
}
valuePropName=
{
(
item
.
selectMode
===
'switch'
)?
'checked'
:
'value'
}
>
{
formItemBody
(
item
)
}
</
Form
.
Item
>
</
Col
>
)
})
}
{
schedule
&&
(
schedule
.
scheduleParameters
||
[]).
map
((
item
,
index
)
=>
{
let
_type
=
'string'
;
if
(
item
.
selectMode
===
'switch'
)
{
_type
=
'boolean'
;
}
else
if
(
item
.
selectMode
===
'timePicker'
)
{
_type
=
'object'
;
}
else
if
(
item
.
selectMode
===
'cascader'
)
{
_type
=
'array'
;
}
return
(
<
Col
span=
{
12
}
key=
{
index
}
>
<
Form
.
Item
label=
{
item
.
cnName
||
''
}
name=
{
item
.
name
||
''
}
key=
{
index
}
rules=
{
[{
required
:
item
.
required
,
message
:
'必填项'
}]
}
rules=
{
[{
required
:
item
.
required
,
message
:
'必填项'
,
type
:
_type
}]
}
valuePropName=
{
(
item
.
selectMode
===
'switch'
)?
'checked'
:
'value'
}
>
{
formItemBody
(
item
)
}
</
Form
.
Item
>
</
Col
>
)
})
}
</
Row
>
</
Form
>
);
}
...
...
src/view/Manage/DatasourceManage/Component/ScheduleCURDModal.jsx
View file @
f947c507
import
React
,
{
useEffect
,
useState
}
from
'react'
;
import
{
Table
,
Space
,
Button
,
Tooltip
,
Modal
,
Form
}
from
'antd'
;
import
{
EditOutlined
,
ReconciliationOutlined
,
DeleteOutlined
}
from
'@ant-design/icons'
;
import
{
EditOutlined
,
DeleteOutlined
}
from
'@ant-design/icons'
;
import
ScheduleAction
from
'./ScheduleAction'
;
import
{
dispatch
}
from
'../../../../model'
;
import
{
showMessage
}
from
'../../../../util'
;
import
'./ScheduleCURDModal.less'
;
const
ScheduleCURDModal
=
(
props
)
=>
{
const
{
visible
,
onCancel
,
id
}
=
props
;
...
...
@@ -15,6 +17,7 @@ const ScheduleCURDModal = (props) => {
const
[
currentSchedule
,
setCurrentSchedule
]
=
useState
(
''
);
const
[
step
,
setStep
]
=
useState
(
0
);
const
[
confirmLoading
,
setConfirmLoading
]
=
useState
(
false
);
const
[
editSchedule
,
setEditSchedule
]
=
useState
({});
const
[
modal
,
contextHolder
]
=
Modal
.
useModal
();
const
[
form
]
=
Form
.
useForm
();
...
...
@@ -25,6 +28,7 @@ const ScheduleCURDModal = (props) => {
getSchedules
();
}
//eslint-disable-next-line react-hooks/exhaustive-deps
},
[
visible
])
const
columns
=
[
...
...
@@ -53,7 +57,7 @@ const ScheduleCURDModal = (props) => {
{
title
:
'调度时间'
,
dataIndex
:
'cronDesc'
,
width
:
18
0
,
width
:
20
0
,
ellipsis
:
true
,
},
{
...
...
@@ -72,9 +76,9 @@ const ScheduleCURDModal = (props) => {
<
Tooltip
placement=
'bottom'
title=
{
'修改'
}
>
<
Button
icon=
{
<
EditOutlined
/>
}
size=
'small'
onClick=
{
()
=>
{
editItem
(
record
);
}
}
/>
</
Tooltip
>
<
Tooltip
placement=
'bottom'
title=
{
'详情'
}
>
{
/*
<Tooltip placement='bottom' title={'详情'}>
<Button icon={<ReconciliationOutlined />} size='small' onClick={() => { detailItem(record); }} />
</
Tooltip
>
</Tooltip>
*/
}
<
Tooltip
placement=
'bottom'
title=
{
'删除'
}
>
<
Button
icon=
{
<
DeleteOutlined
/>
}
size=
'small'
onClick=
{
()
=>
{
deleteItem
(
record
);
}
}
/>
</
Tooltip
>
...
...
@@ -109,11 +113,11 @@ const ScheduleCURDModal = (props) => {
setCurrentSchedule
(
record
);
}
const
detailItem
=
(
record
)
=>
{
setStep
(
1
);
setAction
(
'detail'
);
setCurrentSchedule
(
record
);
}
//
const detailItem = (record) => {
//
setStep(1);
//
setAction('detail');
//
setCurrentSchedule(record);
//
}
const
deleteItem
=
(
record
)
=>
{
modal
.
confirm
({
...
...
@@ -148,12 +152,13 @@ const ScheduleCURDModal = (props) => {
const
reset
=
()
=>
{
setStep
(
0
);
setSchedules
([]);
setCurrentSchedule
({});
setConfirmLoading
(
false
);
}
const
onActionChange
=
(
data
)
=>
{
getSchedules
(
);
setEditSchedule
(
data
);
}
const
prev
=
()
=>
{
...
...
@@ -161,30 +166,28 @@ const ScheduleCURDModal = (props) => {
}
const
save
=
async
()
=>
{
// try {
// const row = await form.validateFields();
// const newTemplateData = {...currentTemplate, ...row};
try
{
await
form
.
validateFields
();
//
setConfirmLoading(true);
// dispatchLatest
({
// type: 'datamodel.saveTemplat
e',
//
payload: {
// data: newTemplateData
//
},
//
callback: () => {
//
setConfirmLoading(false);
//
reset();
// onCancel && onCancel(true
);
//
},
//
error: () => {
//
setConfirmLoading(false);
//
}
//
})
setConfirmLoading
(
true
);
dispatch
({
type
:
'datasource.saveAndStartSchedul
e'
,
payload
:
{
data
:
editSchedule
},
callback
:
()
=>
{
setConfirmLoading
(
false
);
reset
();
getSchedules
(
);
},
error
:
()
=>
{
setConfirmLoading
(
false
);
}
})
//
} catch (errInfo) {
//
console.log('Validate Failed:', errInfo);
//
}
}
catch
(
errInfo
)
{
console
.
log
(
'Validate Failed:'
,
errInfo
);
}
}
...
...
@@ -275,6 +278,7 @@ const ScheduleCURDModal = (props) => {
id=
{
currentSchedule
.
id
}
form=
{
form
}
tid=
{
id
}
onChange=
{
onActionChange
}
/>
}
{
contextHolder
}
...
...
src/view/Manage/DatasourceManage/Component/ScheduleCURDModal.less
0 → 100644
View file @
f947c507
.schedule-curd-modal {
.yy-table {
max-height: 600px !important;
overflow: auto !important;
}
}
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment