Browse Source

Merge branch 'feature/fengkong_thanos_v0.2' into 'master'

Feature/fengkong thanos v0.2

See merge request admin-manager/dc!29
王文博 5 năm trước cách đây
mục cha
commit
5d0cd2ecee

+ 2 - 1
src/conf/config.js

@@ -11,7 +11,8 @@ if (document.domain === 'localhost') {
   // dc = 'http://localhost:8000/api'
   // dc = 'http://backend.wpt.local:8087'
   dc = 'http://back-apit.weipaitang.com'
-  thanos = 'http://thanos-admint.wpt.la'
+  // thanos = 'http://thanos-admint.wpt.la'
+  thanos = 'http://localhost:7070'
 } else if (document.domain === 'back-admint.wpt.la') {
   dc = 'http://back-apit.weipaitang.com'
   us = 'http://back-apit.weipaitang.com'

+ 35 - 8
src/pages/fengkong/strategies/add/index.js

@@ -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 AceEditor from 'react-ace'
 import { create, test } from '../service'
 
@@ -18,8 +18,10 @@ const formItemLayout = {
 @Form.create()
 class Add extends React.PureComponent {
   state = {
+    type: 0,
     content: '',
     enabled: false,
+    timeTaskEnabled: false,
     showTest: false, // 是否展示测试内容
     testContent: '', // 测试数据
     testResult: '' // 测试结果
@@ -33,11 +35,12 @@ class Add extends React.PureComponent {
           createUser: this.props.currentUser.name, // 创建人
           updateUser: this.props.currentUser.name // 最后修改人
         }).then(res => {
+          console.log(res)
           if (res.code === 0) {
             this.setState({ ...values })
             Modal.success({
               title: '提交成功',
-              content: '策代码编译正常,点击“测试按钮”可以继续测试策逻辑'
+              content: '策代码编译正常,点击“测试按钮”可以继续测试策逻辑'
             })
           }
         })
@@ -47,11 +50,16 @@ class Add extends React.PureComponent {
 
   test =() => {
     if (!this.state.name) {
-      message.warn('请先提交策略内容!')
+      message.warn('请先提交决策内容!')
+      return false
+    }
+    if (this.state.timeTaskEnabled) {
+      message.warn('定时启用不能测试,请先关闭!')
       return false
     }
     test({
       name: this.state.name,
+      type: this.state.type,
       input: JSON.parse(this.state.testContent)
     }).then(res => {
       if (res.code === 0) {
@@ -62,25 +70,44 @@ class Add extends React.PureComponent {
 
   render () {
     const { getFieldDecorator } = this.props.form
-
     return (
       <div>
-        <h1>新增策</h1>
+        <h1>新增策</h1>
         <Row>
           <Col span={12}>
             <Form {...formItemLayout}>
-              <Form.Item label="策名称">
+              <Form.Item label="策名称">
                 {getFieldDecorator('name')(<Input placeholder="全英文或英文带下划线" />)}
               </Form.Item>
-              <Form.Item label="策描述">
+              <Form.Item label="策描述">
                 {getFieldDecorator('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: this.state.enabled
                 })(<Switch checked={this.state.enabled} onChange={checked => this.setState({ enabled: checked })} />)}
               </Form.Item>
-              <Form.Item label="策略逻辑开发">
+              {
+                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="决策逻辑开发">
                 {getFieldDecorator('content')(
                   <AceEditor
                     style={{ width: this.state.showTest ? '100%' : '200%' }}

+ 32 - 7
src/pages/fengkong/strategies/edit/$name.js

@@ -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%' }}

+ 21 - 3
src/pages/fengkong/strategies/strategies.js

@@ -18,7 +18,7 @@ class GroupList extends React.PureComponent {
       to={{
         pathname: './add'
       }}
-    ><Button>新增策</Button></Link>,
+    ><Button>新增策</Button></Link>,
     isClearSearch: true,
     formFields: [
       {
@@ -30,7 +30,7 @@ class GroupList extends React.PureComponent {
     ]
     // 在接口请求前,可以修改给接口的入参
     // beforeSearchFunc: params => {
-    //   params.pageNum = params.pageNum
+    //   params.type = 3
     // }
   }
 
@@ -55,7 +55,25 @@ class GroupList extends React.PureComponent {
         dataIndex: 'description'
       },
       {
-        title: '策略是否启用',
+        title: '类型',
+        dataIndex: 'type',
+        render: (text) => {
+          if (text === 0) {
+            return '策略'
+          }
+          if (text === 1) {
+            return '流程'
+          }
+          if (text === 2) {
+            return '模型'
+          }
+          if (text === 3) {
+            return '调度'
+          }
+        }
+      },
+      {
+        title: '决策是否启用',
         dataIndex: 'enabled',
         render: (text) => text === true ? '是' : '否'
       },