王文博 пре 5 година
родитељ
комит
d13670cf56

+ 1 - 9
package.json

@@ -4,8 +4,7 @@
     "start": "umi dev",
     "build": "umi build",
     "lint": "eslint --ext .js src",
-    "format": "eslint --ext .js src --fix",
-    "precommit": "lint-staged"
+    "format": "eslint --ext .js src --fix"
   },
   "dependencies": {
     "antd": "^3.23.4",
@@ -27,19 +26,12 @@
     "eslint-plugin-promise": "^4.2.1",
     "eslint-plugin-react": "^7.14.3",
     "eslint-plugin-standard": "^4.0.1",
-    "husky": "^3.0.5",
     "less-vars-to-js": "^1.3.0",
     "lint-staged": "^9.3.0",
     "react-test-renderer": "^16.9.0",
     "umi": "^2.9.6",
     "umi-plugin-react": "1.9.5"
   },
-  "lint-staged": {
-    "*.{js,jsx}": [
-      "eslint --fix",
-      "git add"
-    ]
-  },
   "engines": {
     "node": ">=8.12.0"
   }

+ 1 - 1
src/layouts/mainLayout/index.js

@@ -89,7 +89,7 @@ export default class MainLayout extends React.PureComponent {
                 <Menu.Item key="/dc/data" onClick={() => { router.push('/dc/data') }}>UA数据管理</Menu.Item>
                 <Menu.Item key="/dc/list" onClick={() => { router.push('/dc/list') }}>UA数据报表</Menu.Item>
                 <Menu.Item key="/dc/subscribe/data"  onClick={() => { router.push('/dc/subscribe/data') }}>订阅数据管理</Menu.Item>
-                <Menu.Item key="/dc/subscribe"  onClick={() => { router.push('/dc/subscribe/job')}}>订阅数据报表</Menu.Item>
+                <Menu.Item key="/dc/subscribe/list"  onClick={() => { router.push('/dc/subscribe/list')}}>订阅数据报表</Menu.Item>
               </SubMenu>
             </Menu>
           </Sider>

+ 1 - 2
src/pages/dc/data.js

@@ -170,9 +170,8 @@ class Index extends React.PureComponent {
       }
       return t
     }, {})
-    console.log(fieldsJson, 1)
     params.fieldsJson = JSON.stringify(fieldsJson)
-    console.log(params, 2)
+    console.log(params, 3)
     const type = !params.id ? 'template/_addItem' : 'template/_editItem'
     this.props.dispatch({
       type,

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

@@ -2,10 +2,9 @@ import { fetchApi } from '@/apis/'
 import { dc } from '@/conf/config'
 
 export async function addItem (params) {
+  console.log("addRule")
   const url = `${dc}/dc/web/edit-rule`
-  console.log(params)
   return fetchApi(url, params)
-  // return fetchApi(url, {method:'POST',body:params})
 }
 
 export async function delItem (params) {
@@ -14,13 +13,12 @@ export async function delItem (params) {
 }
 
 export async function editItem (params) {
+  console.log("editRule")
   const url = `${dc}/dc/web/edit-rule`
   return fetchApi(url, params)
-  // return fetchApi(url, {method:'POST',body:params})
 }
 
 export async function execItem (params) {
   const url = `${dc}/dc/data-center/command`
   return fetchApi(url, params)
-  // return fetchApi(url, {method:'POST',body:params})
 }

+ 4 - 4
src/pages/dc/subscribe/components/Job/index.js

@@ -78,10 +78,12 @@ class JobModal extends React.PureComponent {
                   <Select.Option value={2}>变量增加</Select.Option>
                 </Select>
                 <Checkbox checked={fieldsJson[index].cacheDay === 1} onChange={(e) => {
+                  console.log("==day")
                   fieldsJson[index].cacheDay = e.target.checked
                   this.onParamsChange('fieldsJson', fieldsJson)
                 }} style={{ width: 120, marginRight: 10 }}>按天缓存</Checkbox>
                 <Checkbox checked={fieldsJson[index].cacheHour === 1} onChange={(e) => {
+                  console.log("==hour")
                   fieldsJson[index].cacheHour = e.target.checked
                   this.onParamsChange('fieldsJson', fieldsJson)
                 }} style={{ width: 120, marginRight: 10 }}>按小时缓存</Checkbox>
@@ -98,7 +100,7 @@ class JobModal extends React.PureComponent {
   clickSaveJob = (index) => () => {
     const { params } = this.state
     const { fieldsJson } = params
-    const type = 'template/_editSubJobItem'
+    const type = 'subscribetpl/_editSubJobItem'
     console.log(params)
     fieldsJson[index].sid = params.id
     this.props.dispatch({
@@ -119,7 +121,6 @@ class JobModal extends React.PureComponent {
               fieldsJson
             }
           })
-          this.refresh()
         }
       }
     })
@@ -128,7 +129,7 @@ class JobModal extends React.PureComponent {
   clickDeleteJob = (index) => () => {
     const { params } = this.state
     const { fieldsJson } = params
-    const type = 'template/_deleteSubJobItem'
+    const type = 'subscribetpl/_deleteSubJobItem'
     console.log(index)
     this.props.dispatch({
       type,
@@ -145,7 +146,6 @@ class JobModal extends React.PureComponent {
               fieldsJson
             }
           })
-          this.refresh()
         }
       }
     })

+ 3 - 8
src/pages/dc/subscribe/data.js

@@ -11,7 +11,7 @@ const apiUrl = `${dc}/dc/web/get-sub-rule-list`
 
 @connect(({ loading }) => ({
   // 添加或者编辑接口触发的loading属性,可以用于控制接口请求阶段让对话框的”确定“按钮不可点击
-  actionLoading: loading.effects['template/_addItem'] || loading.effects['ugc/_editItem']
+  // actionLoading: loading.effects['subscribetpl/_addItem'] || loading.effects['ugc/_editItem']
 }))
 class Index extends React.PureComponent {
   state = {
@@ -100,12 +100,7 @@ class Index extends React.PureComponent {
         dataIndex: 'actions',
         // 所有需要弹窗操作的都可以用编辑的逻辑;所有不需要弹窗的操作,比如上架、发布等,都可以用”删除“的逻辑
         render: (text, record) => <span><a onClick={() => this.editItem(record)}>编辑</a>
-          <Divider type="vertical"/><a onClick={() => this.editJob(record)}>任务</a><Divider
-            type="vertical"/><Popconfirm
-            title="确定删除"
-            onConfirm={() => this.delItem(record)}>
-            <a>删除</a>
-          </Popconfirm></span>
+          <Divider type="vertical"/><a onClick={() => this.editJob(record)}>任务</a></span>
       }
     ],
     // 通过这个函数可以获取列表的刷新的函数,编辑、删除后可以用它来刷新列表
@@ -209,7 +204,7 @@ class Index extends React.PureComponent {
     }, {})
     params.fieldsJson = JSON.stringify(fieldsJson)
     console.log(params, 235)
-    const type = !params.id ? 'template/_addItem' : 'template/_editItem'
+    const type =  'subscribetpl/_editSubRuleItem'
     this.props.dispatch({
       type,
       payload: params,

+ 95 - 0
src/pages/dc/subscribe/list.js

@@ -0,0 +1,95 @@
+import React from 'react'
+import { FilterTable } from 'wptpc-design'
+import s from './data.less'
+import { dc } from '@/conf/config'
+
+const apiUrl = `${dc}/dc/web/search-sub-job`
+
+class SubJobList extends React.PureComponent {
+  state = {
+    showModal: false,
+    params: {}
+  }
+
+  filterSetting = {
+    isClearSearch: true,
+    formFields: [
+      {
+        label: '描述:',
+        type: 'input',
+        key: 'desc',
+        placeholder: '请输入订阅任务的描述'
+      }
+    ]
+    // 在接口请求前,可以修改给接口的入参
+    // beforeSearchFunc: params => {
+    //   params.pageNum = params.pageNum
+    // }
+  }
+
+  // filtertable的列表配置
+  tableSetting = {
+    rowKey: 'alias',
+    isFrontPagination: true,
+    pagination: {
+      pageSize: 10
+    },
+    columnConfig: [
+      {
+        title: '序号',
+        dataIndex: 'id'
+      },
+      {
+        title: '订阅任务描述',
+        dataIndex: 'description'
+      },
+      {
+        title: '查询名',
+        dataIndex: 'name'
+      },
+      {
+        title: '唯一标识',
+        dataIndex: 'uniquId'
+      },
+      {
+          title: '订阅的数据库',
+          dataIndex: "subDb"
+      },
+      {
+          title: '订阅的数据表',
+          dataIndex: "subTable"
+      },
+      {
+          title: '订阅字段',
+          dataIndex: "subFields"
+      },
+      {
+          title: '订阅过滤条件',
+          dataIndex: "subFilter"
+      },
+      {
+           title: '订阅回调地址',
+           dataIndex: "url"
+      },
+      {
+        title: '订阅计算类型',
+        dataIndex: 'type',
+        render: (text) => text === 1 ? '自增' : '变量增加'
+      }
+    ],
+    getRefresh: refresh => {
+      this.refresh = refresh
+    }
+  }
+
+  render () {
+    return (
+      <div className={s.templatePage}>
+        <FilterTable filterSetting={this.filterSetting} tableSetting={this.tableSetting} apiUrl={apiUrl}
+          isPage={false}/>
+      </div>
+    )
+  }
+}
+
+export default SubJobList

+ 8 - 2
src/pages/dc/subscribe/model.js

@@ -1,11 +1,17 @@
 import {
-  editSubJobItem, deleteSubJobItem
+  editSubJobItem, deleteSubJobItem,editSubRuleItem
 } from './service'
 
 export default {
-  namespace: 'template',
+  namespace: 'subscribetpl',
   state: {},
   effects: {
+    * _editSubRuleItem ({ payload, callback }, { call }) {
+      const res = yield call(editSubRuleItem, payload)
+      if (res) {
+        if (callback) callback(res)
+      }
+    },
     * _editSubJobItem ({ payload, callback }, { call }) {
       const res = yield call(editSubJobItem, payload)
       if (res) {

+ 6 - 0
src/pages/dc/subscribe/service.js

@@ -10,3 +10,9 @@ export async function deleteSubJobItem (params) {
   const url = `${dc}/dc/web/delete-sub-job`
   return fetchApi(url, params)
 }
+
+
+export async function editSubRuleItem(params) {
+  const url = `${dc}/dc/web/edit-sub-rule`
+  return fetchApi(url, params)
+}