|
@@ -1,5 +1,5 @@
|
|
|
import React from 'react'
|
|
|
-import { Form, Input, Row, Col, Switch, Button, Modal, message } from 'antd'
|
|
|
+import { Form, Input, Row, Col, Switch, Button, Modal, message, Select } from 'antd'
|
|
|
import { connect } from 'dva'
|
|
|
import AceEditor from 'react-ace'
|
|
|
import { detail, test, update } from '../service'
|
|
@@ -47,7 +47,7 @@ class Add extends React.PureComponent {
|
|
|
this.setState({ ...values })
|
|
|
Modal.success({
|
|
|
title: '提交成功',
|
|
|
- content: '策略代码编译正常,点击“测试按钮”可以继续测试策略逻辑'
|
|
|
+ content: '决策代码编译正常,点击“测试按钮”可以继续测试决策逻辑'
|
|
|
})
|
|
|
}
|
|
|
})
|
|
@@ -57,7 +57,11 @@ class Add extends React.PureComponent {
|
|
|
|
|
|
test =(id) => {
|
|
|
if (!this.state.name) {
|
|
|
- message.warn('请先提交策略内容!')
|
|
|
+ message.warn('请先提交决策内容!')
|
|
|
+ return false
|
|
|
+ }
|
|
|
+ if (this.state.timeTaskEnabled) {
|
|
|
+ message.warn('定时启用不能测试,请先关闭!')
|
|
|
return false
|
|
|
}
|
|
|
if (!isJSON(this.state.testContent)) {
|
|
@@ -66,6 +70,7 @@ class Add extends React.PureComponent {
|
|
|
}
|
|
|
test({
|
|
|
name: this.state.name,
|
|
|
+ type: this.state.type,
|
|
|
input: JSON.parse(this.state.testContent)
|
|
|
}).then(res => {
|
|
|
if (res.code === 0) {
|
|
@@ -80,26 +85,46 @@ class Add extends React.PureComponent {
|
|
|
const { name, description, enabled, content } = this.state
|
|
|
return (
|
|
|
<div>
|
|
|
- <h1>编辑策略</h1>
|
|
|
+ <h1>编辑决策</h1>
|
|
|
<Row>
|
|
|
<Col span={12}>
|
|
|
<Form {...formItemLayout}>
|
|
|
- <Form.Item label="策略名称">
|
|
|
+ <Form.Item label="决策名称">
|
|
|
{getFieldDecorator('name', {
|
|
|
initialValue: name
|
|
|
})(<Input placeholder="全英文或英文带下划线" />)}
|
|
|
</Form.Item>
|
|
|
- <Form.Item label="策略描述">
|
|
|
+ <Form.Item label="决策描述">
|
|
|
{getFieldDecorator('description', {
|
|
|
initialValue: description
|
|
|
})(<Input.TextArea placeholder="多行输入" />)}
|
|
|
</Form.Item>
|
|
|
+ <Form.Item label="决策类型">
|
|
|
+ {getFieldDecorator('type', { initialValue: this.state.type })(
|
|
|
+ <Select placeholder={'请选择类型'} onChange={value => this.setState({ type: value })}>
|
|
|
+ <Select.Option value= {0}>策略</Select.Option>
|
|
|
+ <Select.Option value= {1}>流程</Select.Option>
|
|
|
+ <Select.Option value= {2}>模型</Select.Option>
|
|
|
+ <Select.Option value= {3}>调度</Select.Option>
|
|
|
+ </Select>)
|
|
|
+ }
|
|
|
+ </Form.Item>
|
|
|
<Form.Item label="是否启用">
|
|
|
{getFieldDecorator('enabled', {
|
|
|
initialValue: enabled
|
|
|
})(<Switch checked={enabled} onChange={checked => this.setState({ enabled: checked })} />)}
|
|
|
</Form.Item>
|
|
|
- <Form.Item label="策略逻辑开发">
|
|
|
+ {
|
|
|
+ (this.state.type !== 3 && this.setState({ timeTaskEnabled: false })) ||
|
|
|
+ (this.state.type === 3 && (
|
|
|
+ <Form.Item label="定时是否启用">
|
|
|
+ {getFieldDecorator('timeTaskEnabled', {
|
|
|
+ initialValue: this.state.timeTaskEnabled
|
|
|
+ })(<Switch checked={this.state.timeTaskEnabled} onChange={checked => this.setState({ timeTaskEnabled: checked })} />)}
|
|
|
+ </Form.Item>
|
|
|
+ ))
|
|
|
+ }
|
|
|
+ <Form.Item label="决策逻辑开发">
|
|
|
|
|
|
<AceEditor
|
|
|
style={{ width: this.state.showTest ? '100%' : '200%' }}
|