Commit dbe0e74f by zhaochengxiang

新增任务

parent 98991488
......@@ -5,9 +5,9 @@ import moment from 'moment'
import produce from 'immer'
import { dispatch } from '../../../model'
import Table from '../../../util/Component/Table'
import Table, { generateId } from '../../../util/Component/Table'
import { saveColumns } from '../../../service/msd'
import { showMessage } from '../../../util'
import { generateUUID, showMessage } from '../../../util'
const FC = (props) => {
const { visible, type, item, onCancel} = props
......@@ -61,12 +61,25 @@ const FC = (props) => {
const save = async () => {
try {
const basicRows = await basicFormRef.current?.validate()
const rangeRows = await rangeRef.current?.validate()
const strategyRows = await strategyRef.current?.validate()
const scheduleRows = await scheduleFormRef.current?.validate()
console.log('basicRows', basicRows)
console.log('rangeRows', rangeRows)
console.log('strategyRows', strategyRows)
console.log('scheduleRows', scheduleRows)
if ((rangeRows??[]).length === 0) {
showMessage('warn', '请先填写对比范围')
return
}
if ((strategyRows??[]).length === 0) {
showMessage('warn', '请先填写对比策略')
return
}
setWaiting(true)
if (type === 'add') {
dispatch({
......@@ -74,6 +87,7 @@ const FC = (props) => {
payload: {
data: {
...basicRows,
jobCatalogItems: rangeRows,
strategyItemPropertyTypes: strategyRows,
jobSchedule: scheduleRows,
}
......@@ -92,6 +106,7 @@ const FC = (props) => {
data: {
...task,
...basicRows,
jobCatalogItems: rangeRows,
strategyItemPropertyTypes: strategyRows,
jobSchedule: scheduleRows,
}
......@@ -135,7 +150,7 @@ const FC = (props) => {
<Header title='基本信息' />
<BasicForm ref={basicFormRef} type={type} task={task} />
<Header title='对比范围' />
<Range ref={rangeRef} />
<Range ref={rangeRef} type={type} task={task} />
<Header title='对比策略' />
<Strategy ref={strategyRef} type={type} task={task} />
<Header title='调度配置' />
......@@ -707,11 +722,54 @@ const Range = React.forwardRef(function ({ type, task }, ref) {
const [isAdding, setAdding] = React.useState(false)
const [form] = Form.useForm()
const rangesRef = React.useRef()
React.useImperativeHandle(ref, () => ({
validate: async () => {
await onOkClick()
return rangesRef.current
},
}), [ranges, isAdding])
const onAddClick = () => {
if (isAdding) return
setAdding(true)
}
const onOkClick = async () => {
rangesRef.current = ranges??[]
if (!isAdding) return
try {
const rows = await form.validateFields()
let newRanges = [...ranges??[]]
newRanges = [...newRanges, {
...rows.modelRange,
...rows.metadataRange,
}]
console.log('newRanges', newRanges)
setRanges(newRanges)
rangesRef.current = newRanges
setAdding(false)
} catch(e) {
throw new Error()
}
}
const onCancelClick = () => {
setAdding(false)
}
const onRangeDeleteClick = (index) => {
const newRanges = [...ranges??[]]
newRanges.splice(index, 1)
setRanges(newRanges)
}
return (
<div>
{
......@@ -727,27 +785,47 @@ const Range = React.forwardRef(function ({ type, task }, ref) {
autoComplete="off"
>
<Row gutter={15}>
<Col span={12}>
<Col span={10}>
<Form.Item
label="数据模型范围"
name="modelCatalogId"
name="modelRange"
rules={[{ required: true, message: '请选择模型范围!' }]}
>
<ModelRangeItem />
</Form.Item>
</Col>
<Col span={12}>
<Col span={10}>
<Form.Item
label="数据元数据范围"
name="modelCatalogId"
name="metadataRange"
rules={[{ required: true, message: '请选择元数据范围!' }]}
>
<MetadataRangeItem />
</Form.Item>
</Col>
<Col span={4}>
<Space>
<Button onClick={onOkClick}>确定</Button>
<Button onClick={onCancelClick}>取消</Button>
</Space>
</Col>
</Row>
</Form>
}
{
(ranges??[]).map((item, index) => {
return (
<Row className='mb-1' key={generateUUID()} align='middle' gutter={15}>
<Col span={12}>
{`【模型】${(item.modelCatalogNameList??[]).join('/')} -【元数据】${(item.metadataCatalogNameList??[]).join('/')}`}
</Col>
{
type !== 'detail' && <Button type='link' onClick={() => onRangeDeleteClick(index)}>删除</Button>
}
</Row>
)
})
}
</div>
)
})
......
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