王文博 5 年之前
父节点
当前提交
9affb3e167
共有 6 个文件被更改,包括 67 次插入33 次删除
  1. 25 25
      .umirc.js
  2. 1 1
      src/apis/base.js
  3. 1 2
      src/apis/index.js
  4. 28 4
      src/pages/dc/index.js
  5. 7 1
      src/pages/dc/model.js
  6. 5 0
      src/pages/dc/service.js

+ 25 - 25
.umirc.js

@@ -2,31 +2,31 @@
 // ref: https://umijs.org/config/
 export default {
   treeShaking: true,
-  chainWebpack(config) {
-    // config.plugin('moment-locales').use(momentLocalesWebpackPlugin, [{
-    //   localesToKeep: ['zh-cn'],
-    // }])
-    config.merge({
-      optimization: {
-        minimize: true,
-        splitChunks: {
-          chunks: 'all',
-          minSize: 30000,
-          minChunks: 3,
-          automaticNameDelimiter: '.',
-          cacheGroups: {
-            vendors: {
-              name: 'common',
-              test({ resource }) {
-                return /[\\/]node_modules[\\/]/.test(resource);
-              },
-              priority: 10,
-            },
-          },
-        },
-      }
-    })
-  },
+  // chainWebpack(config) {
+  //   // config.plugin('moment-locales').use(momentLocalesWebpackPlugin, [{
+  //   //   localesToKeep: ['zh-cn'],
+  //   // }])
+  //   config.merge({
+  //     optimization: {
+  //       minimize: true,
+  //       splitChunks: {
+  //         chunks: 'all',
+  //         minSize: 30000,
+  //         minChunks: 3,
+  //         automaticNameDelimiter: '.',
+  //         cacheGroups: {
+  //           vendors: {
+  //             name: 'common',
+  //             test({ resource }) {
+  //               return /[\\/]node_modules[\\/]/.test(resource);
+  //             },
+  //             priority: 10,
+  //           },
+  //         },
+  //       },
+  //     }
+  //   })
+  // },
   plugins: [
     // ref: https://umijs.org/plugin/umi-plugin-react.html
     [

+ 1 - 1
src/apis/base.js

@@ -13,7 +13,7 @@ const request = axios.create({
   baseURL: `${getPrefix()}/api`,
   timeout: 5000,
   withCredentials: true,
-  headers: { 'content-type': 'application/json' }
+  // headers: { 'content-type': 'application/json' }
 })
 
 request.interceptors.request.use(

+ 1 - 2
src/apis/index.js

@@ -21,8 +21,7 @@ export function fetchApi (url, params) {
     return request({
       method: 'POST',
       url,
-      params,
-
+      data: params.body,
     })
   } else {
     return request({

+ 28 - 4
src/pages/dc/index.js

@@ -4,8 +4,9 @@ import { message, Divider, Popconfirm } from 'antd'
 import { FilterTable } from 'wptpc-design'
 import s from './index.less'
 import Edit from './components/Edit'
+import { dc } from '@/conf/config'
 // const apiUrl = 'http://localhost:9090/dc/web/get-rule-list'
-const apiUrl = 'http://localhost:8080/dc/web/get-rule-list'
+const apiUrl = `${dc}/dc/web/get-rule-list`
 
 @connect(({ loading }) => ({
   // 添加或者编辑接口触发的loading属性,可以用于控制接口请求阶段让对话框的”确定“按钮不可点击
@@ -49,7 +50,9 @@ class Index extends React.PureComponent {
       { title: '序号', dataIndex: 'id' },
       { title: '规则名', dataIndex: 'rule' },
       { title: '接口', dataIndex: 'url' },
-      { title: '是否可以运行', dataIndex: 'status' },
+      { title: '是否可以运行', dataIndex: 'status', 
+      render: (text) => text === 1 ? '可以运行':'禁止运行'
+    },
       { title: '描述', dataIndex: 'desc' },
       // { title: '创建时间', dataIndex: 'createTime' },
       // { title: '更新时间', dataIndex: 'modifyTime' },
@@ -61,6 +64,10 @@ class Index extends React.PureComponent {
           title="确定删除"
           onConfirm={() => this.delItem(record)}>
           <a>删除</a>
+        </Popconfirm><Divider type="vertical" /><Popconfirm
+          title="确定执行"
+          onConfirm={() => this.execItem(record)}>
+          <a>执行</a>
         </Popconfirm></span>
       }
     ],
@@ -88,13 +95,27 @@ class Index extends React.PureComponent {
         const { code } = res || {}
         if (code === 0) {
           message.success('删除成功')
-          this.setState({ showModal: false })
           this.refresh()
         }
       }
     })
   }
 
+  execItem ({ id }) {
+    this.props.dispatch({
+      type: 'template/_execItem',
+      payload: { id },
+      callback: res => {
+        const { code } = res || {}
+        if (code === 0) {
+          message.success('执行成功')
+          this.refresh()
+        }
+      }
+    })
+  }
+
+
   // 点击新建、编辑对话框的取消按钮的事件处理函数
   onModalCancel = () => {
     this.setState({ showModal: false })
@@ -113,8 +134,11 @@ class Index extends React.PureComponent {
       t[key] = {
         desc, column
       }
+      return t;
     }, {})
+    console.log(fieldsJson,1)
     params.fieldsJson = JSON.stringify(fieldsJson)
+    console.log(params,2)
     const type = !params.id ? 'template/_addItem' : 'template/_editItem'
     this.props.dispatch({
       type,
@@ -122,7 +146,7 @@ class Index extends React.PureComponent {
       callback: res => {
         const { code } = res || {}
         if (code === 0) {
-          const msg = params.id ? '编辑用户成功' : '添加用户成功'
+          const msg = params.id ? '编辑成功' : '添加成功'
           message.success(msg)
           this.setState({ showModal: false })
           this.refresh()

+ 7 - 1
src/pages/dc/model.js

@@ -1,5 +1,5 @@
 import {
-  addItem, delItem
+  addItem, delItem, execItem
 } from './service'
 
 export default {
@@ -23,6 +23,12 @@ export default {
       if (res) {
         if (callback) callback(res)
       }
+    },
+    * _execItem ({ payload, callback }, { call }) {
+      const res = yield call(execItem, payload)
+      if (res) {
+        if (callback) callback(res)
+      }
     }
   },
   reducers: {}

+ 5 - 0
src/pages/dc/service.js

@@ -17,3 +17,8 @@ export async function editItem (params) {
   const url = `${dc}/dc/web/edit-rule`;
   return fetchApi(url, {method:'POST',body:params})
 }
+
+export async function execItem (params) {
+  const url = `${dc}/dc/data-center/command`;
+  return fetchApi(url, {method:'POST',body:params})
+}