王文博 5 年之前
父節點
當前提交
1a8c7b1a4d
共有 4 個文件被更改,包括 48 次插入17 次删除
  1. 5 0
      src/conf/config.js
  2. 25 5
      src/pages/dc/components/Edit/index.js
  3. 7 8
      src/pages/dc/index.js
  4. 11 4
      src/pages/dc/service.js

+ 5 - 0
src/conf/config.js

@@ -0,0 +1,5 @@
+let dc = 'http://localhost:8080'
+
+export {
+    dc
+}

+ 25 - 5
src/pages/dc/components/Edit/index.js

@@ -9,18 +9,38 @@ export default class Index extends Component {
       params: {}
     }
     this.formSetting = [{
-      label: '公司名称',
+      label: '规则名',
       type: 'input',
-      key: 'id',
+      key: 'rule',
       isRequired: true,
       placeholder: '请输入'
-    }, {
-      label: '联系手机',
+    },
+    {
+      label: '接口名',
       type: 'input',
       key: 'url',
       isRequired: true,
       placeholder: '请输入'
-    }, {
+    },
+    {
+      label: '状态',
+      type: 'select',
+      key: 'status',
+      options: [
+        { value: 1, label: '可运行' },
+        { value: 2, label: '停止' }
+      ],
+      style:{width:'100%'},
+      isRequired: true,
+      placeholder: '请输入'
+    },{
+      label: '描述',
+      type: 'input',
+      key: 'desc',
+      isRequired: true,
+      placeholder: '请输入'
+    },
+     {
       label: 'JSON',
       render: () => {
         const { fieldsJson } = this.state.params

+ 7 - 8
src/pages/dc/index.js

@@ -49,7 +49,6 @@ class Index extends React.PureComponent {
       { title: '序号', dataIndex: 'id' },
       { title: '规则名', dataIndex: 'rule' },
       { title: '接口', dataIndex: 'url' },
-      { title: '字段配置', dataIndex: 'fieldsJson' },
       { title: '是否可以运行', dataIndex: 'status' },
       { title: '描述', dataIndex: 'desc' },
       // { title: '创建时间', dataIndex: 'createTime' },
@@ -70,7 +69,7 @@ class Index extends React.PureComponent {
       this.refresh = refresh
     },
     // 筛选和列表的中间位置如果有批量操作按钮,可以放在这个位置
-    batchBtns: [{ label: '创建', type: 'primary', onClick: () => this.editItem({}) }]
+    batchBtns: [{ label: '创建', type: 'primary', onClick: () => this.editItem({fieldsJson:"{}"}) }]
   }
 
   // 点击编辑按钮时的事件处理函数
@@ -104,11 +103,11 @@ class Index extends React.PureComponent {
   // 点击新建、编辑对话框的确定按钮的事件处理函数
   onModalOk = (params) => {
     // 在触发action调用接口前,可以做一些前端校验工作,比如下面的:
-    if (!params.developerName) {
-      // 如果developerName不存在或者为空字符,那么给用户一个warning提示,同时return阻止后面的接口调用
-      message.warning('公司名称必填')
-      return
-    }
+    // if (!params.developerName) {
+    //   // 如果developerName不存在或者为空字符,那么给用户一个warning提示,同时return阻止后面的接口调用
+    //   message.warning('公司名称必填')
+    //   return
+    // }
 
     const fieldsJson = params.fieldsJson.reduce((t, { key, desc, column }) => {
       t[key] = {
@@ -116,7 +115,7 @@ class Index extends React.PureComponent {
       }
     }, {})
     params.fieldsJson = JSON.stringify(fieldsJson)
-    const type = params.id ? 'template/_addItem' : 'template/_editItem'
+    const type = !params.id ? 'template/_addItem' : 'template/_editItem'
     this.props.dispatch({
       type,
       payload: params,

+ 11 - 4
src/pages/dc/service.js

@@ -1,11 +1,18 @@
 import { fetchApi } from '@/apis/'
+import { dc } from '@/conf/config'
+
 
 export async function addItem (params) {
-  const url = 'tabledata'
+  const url = `${dc}/dc/web/edit-rule`;
   return fetchApi(url, params)
 }
 
-export async function testpost (body) {
-  const url = 'tabledata'
-  return fetchApi(url, { method: 'POST', body })
+export async function delItem (params) {
+  const url = `${dc}/dc/web/delete-rule`
+  return fetchApi(url, params)
+}
+
+export async function editItem (params) {
+  const url = `${dc}/dc/web/edit-rule`;
+  return fetchApi(url, params)
 }