Commit 1596c400 by zhaochengxiang

任务基本信息

parent c8fb61e0
......@@ -488,6 +488,14 @@ export function* getCompareJobDetail(payload) {
return yield call(datamodelerService.getCompareJobDetail, payload)
}
export function* addCompareJob(payload) {
return yield call(datamodelerService.addCompareJob, payload)
}
export function* updateCompareJob(payload) {
return yield call(datamodelerService.updateCompareJob, payload)
}
export function* deleteCompareJobs(payload) {
return yield call(datamodelerService.deleteCompareJobs, payload)
}
......
......@@ -441,6 +441,14 @@ export function getCompareJobDetail(payload) {
return GetJSON("/datamodeler/easyDataModelModelCompareJob/findById", payload)
}
export function addCompareJob(payload) {
return PostJSON("/datamodeler/easyDataModelModelCompareJob/addJob", payload)
}
export function updateCompareJob(payload) {
return PostJSON("/datamodeler/easyDataModelModelCompareJob/updateJob", payload)
}
export function deleteCompareJobs(payload) {
return Delete("/datamodeler/easyDataModelModelCompareJob/delModelCompareJobs", payload)
}
......
import React from 'react'
import { Button, Modal, Spin, Space, Divider } from 'antd'
import { Button, Modal, Spin, Space, Divider, Form, Row, Col, Input, Select, Checkbox, Radio } from 'antd'
import { dispatch } from '../../../model'
......@@ -53,6 +53,34 @@ const FC = (props) => {
try {
const basicRows = await basicFormRef.current?.validate()
setWaiting(true)
if (type === 'add') {
dispatch({
type: 'datamodel.addCompareJob',
payload: {
data: {...basicRows}
},
callback: () => {
close(true)
},
error: () => {
setWaiting(false)
}
})
} else {
dispatch({
type: 'datamodel.updateCompareJob',
payload: {
data: {...task, ...basicRows}
},
callback: () => {
close(true)
},
error: () => {
setWaiting(false)
}
})
}
} catch (e) {
}
......@@ -81,7 +109,7 @@ const FC = (props) => {
onCancel={() => { close() }}
>
<Spin spinning={loading || waiting}>
<Header title='任务基本设置' />
<Header title='基本信息' />
<BasicForm ref={basicFormRef} type={type} task={task} />
</Spin>
</Modal>
......@@ -97,10 +125,165 @@ export const Header = ({ title }) => (
</Space>
)
export const LabelItem = ({ title, ...restProps }) => {
return <span style={{ lineHeight: '32px' }} {...restProps}>{title}</span>
}
const BasicForm = React.forwardRef(function ({ type, task }, ref) {
const [loadingStates, setLoadingStates] = React.useState(false)
const [states, setStates] = React.useState()
const [loadingModelStates, setLoadingModelStates] = React.useState(false)
const [modelStates, setModelStates] = React.useState()
const [form] = Form.useForm()
React.useImperativeHandle(ref, () => ({
validate: async () => {
const rows = await form.validateFields()
if (rows.jobStatusId) {
const index = (states??[]).findIndex(item => item.id === rows.jobStatusId)
if (index !== -1) {
rows.jobStatusType = states[index]
}
}
rows.modelStatusTypes = (modelStates??[]).filter(item => (rows.modelStatusIds??[]).indexOf(item.id)!==-1)
return rows
},
}), [form, states, modelStates])
React.useEffect(() => {
if (task) {
form?.setFieldsValue({
...task,
jobStatusId: task?.jobStatusType?.id,
modelStatusIds: (task?.modelStatusTypes??[]).map(item => item.id)
})
}
}, [task])
React.useEffect(() => {
getStates()
getModelStates()
}, [])
const marginBottom = React.useMemo(() => {
return (type === 'detail') ? 5 : 15
}, [type])
const getStates = () => {
setLoadingStates(true)
dispatch({
type: 'datamodel.getCompareJobStates',
callback: data => {
setLoadingStates(false)
setStates(data)
},
error: () => {
setLoadingStates(false)
}
})
}
const getModelStates = () => {
setLoadingModelStates(true)
dispatch({
type: 'datamodel.getCompareJobModelStates',
callback: data => {
setLoadingModelStates(false)
setModelStates(data)
},
error: () => {
setLoadingModelStates(false)
}
})
}
const onValuesChange = (changedValues, allValues) => {
}
return (
<div>
basic form
</div>
<Form
form={form}
labelCol={{ span: 6 }}
wrapperCol={{ span: 18 }}
autoComplete="off"
onValuesChange={onValuesChange}
>
<Row gutter={15}>
{
(type==='edit'||type === 'detail') && <Col span={24}>
<Form.Item
label='任务编号'
labelCol={{ span: 3 }}
style={{ marginBottom }}
>
<LabelItem title={task?.jobShowNumber} />
</Form.Item>
</Col>
}
<Col span={12}>
<Form.Item
label="任务名称"
name="jobName"
style={{ marginBottom }}
rules={[{ required: true, message: '请输入任务名称!' }]}
>
{ (type==='detail') ? <LabelItem title={task?.jobName} /> : <Input placeholder="请输入任务名称" /> }
</Form.Item>
</Col>
<Col span={12}>
<Form.Item
label="任务描述"
name="jobDesc"
style={{ marginBottom }}
>
{ (type==='detail') ? <LabelItem title={task?.jobDesc} /> : <Input placeholder="请输入任务描述" /> }
</Form.Item>
</Col>
<Col span={12}>
<Form.Item
label="任务状态"
name="jobStatusId"
style={{ marginBottom }}
rules={[{ required: true, message: '请选择任务状态!' }]}
>
{ (type==='detail') ? <LabelItem title={task?.jobStatusType?.name} /> : <Select
placeholder='请选择状态'
loading={loadingStates}
allowClear
>
{states?.map(item => <Select.Option key={item.id} value={item.id}>{item.name}</Select.Option>)}
</Select> }
</Form.Item>
</Col>
<Col span={12}>
<Form.Item
label="模型状态"
name="modelStatusIds"
style={{ marginBottom }}
rules={[{ required: true, message: '请选择模型状态!' }]}
>
{ (type==='detail') ? <LabelItem title={(task?.modelStatusTypes??[]).map(item => item.name).toString()} /> : <Checkbox.Group loading={loadingModelStates}>
{modelStates?.map(item => <Checkbox key={item.id} value={item.id}>{item.name}</Checkbox>)}
</Checkbox.Group> }
</Form.Item>
</Col>
<Col span={12}>
<Form.Item
label="自动更新模型状态"
name="autoUpdateModel"
style={{ marginBottom }}
rules={[{ required: true, message: '请选择是否自动更新模型状态!' }]}
>
{ (type==='detail') ? <LabelItem title={task?.autoUpdateModel?'是':'否'} /> : <Radio.Group>
<Radio value={true}></Radio>
<Radio value={false}></Radio>
</Radio.Group> }
</Form.Item>
</Col>
</Row>
</Form>
)
})
\ 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