# d3j-commonop

> d3j commonop for private

Latest version **2.0.28** (published 2017-11-15) · ISC license · 0 weekly downloads

## Install

```sh
npm install d3j-commonop
pnpm add d3j-commonop
yarn add d3j-commonop
bun add d3j-commonop
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 2.0.28 |
| Published | 2017-11-15 |
| First published | 2017-08-31 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 10 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Maintainers | ykforerlang |

## Links

- npm: https://www.npmjs.com/package/d3j-commonop
- npm.io page: https://npm.io/package/d3j-commonop

## Dependencies (10)

- [antd](https://npm.io/package/antd.md) ^2.12.8
- [react](https://npm.io/package/react.md) ^15.6.1
- [redux](https://npm.io/package/redux.md) ^3.7.2
- [history](https://npm.io/package/history.md) ^4.6.3
- [react-dom](https://npm.io/package/react-dom.md) ^15.6.1
- [prop-types](https://npm.io/package/prop-types.md) ^15.5.10
- [react-redux](https://npm.io/package/react-redux.md) ^5.0.6
- [redux-thunk](https://npm.io/package/redux-thunk.md) ^2.2.0
- [redux-logger](https://npm.io/package/redux-logger.md) ^3.0.6
- [react-scripts](https://npm.io/package/react-scripts.md) 1.0.12

## Recent versions

- 2.0.28 (latest) — 2017-11-15
- 2.0.27 — 2017-11-14
- 2.0.26 — 2017-11-13
- 2.0.25 — 2017-11-03
- 2.0.24 — 2017-11-03
- 2.0.23 — 2017-11-02
- 2.0.22 — 2017-11-02
- 2.0.21 — 2017-11-01
- 2.0.20 — 2017-11-01
- 2.0.18 — 2017-10-30
- 2.0.17 — 2017-10-30
- 2.0.16 — 2017-10-30
- 2.0.15 — 2017-10-30
- 2.0.14 — 2017-10-26
- 2.0.13 — 2017-10-24
- … 35 more at https://npm.io/package/d3j-commonop/versions

## README

# d3j-commonop
d3j-commonop 是一个多tab的通用后台。 使用前请先阅读：[通用多tab后台](./blog/通用多tab后台.md)

### how to use
1. first install [create-react-app](https://github.com/facebookincubator/create-react-app), create a project
```
npm install -g create-react-app
create-react-app my-app
cd my-app/
```

2. install [d3j-commmonop](https://www.npmjs.com/package/d3j-commonop) 
```
npm install d3j-commonop --save
```

3. 执行: "fibjs ./node_modules/d3j-commonop/generateCode.js"


4. give a appConfig.json at src 
```
npm run codeInit
npm start
```


### appConfig
like this:
```json
{
  "name": "Hello World",
  "logo":"http://lorempixel.com/200/80/",
  "defaultRoot": true,
  "menu":[
    {
      "icon": "mail",
      "label": "基本信息",
      "children": [
        {
          "icon": "setting",
          "label": "用户管理",
          "url": "/userlist",
          "data": {
            "title": "用户",
            "dataSource": "userlist",
            "pagination": {
              "size": 2,
              "pages": 7
            },
            "columns": [{
              "title": "用户名",
              "dataIndex": "username",
              "key": "username",
              "search": true
            }, {
              "title": "年龄",
              "dataIndex": "age",
              "key": "age",
              "search": true
            }, {
              "title": "密码",
              "dataIndex": "password",
              "key": "password"
            }, {
              "title": "操作",
              "key": "__op",
              "opList": " edit"
            }]
          }
        }
      ]
    },
    {
      "icon": "setting",
      "label": "学生管理",
      "url": "/student",
      "data": {
        "title": "学生",
        "dataSource": "student",
        "columns": [{
          "title": "用户名",
          "dataIndex": "username",
          "key": "username"
        }, {
          "title": "年龄",
          "dataIndex": "age",
          "key": "age"
        }, {
          "title": "操作",
          "key": "__op",
          "opList": "edit"
        }]
      }
    },
    {
      "icon": "mail",
      "label": "关于",
      "url": "/about"
    }
  ]
}
```
logo can also be :

```
"logo":{
  "url":"http://lorempixel.com/200/80/",
  "width":"200",
  "height":"80"
}
```



### rooter
参考 [history](https://github.com/ReactTraining/history) 的使用方法
```javascript 1.7
import { history } from 'd3j-commonop'
history.push('/hello')
```
额外的支持 
```javascript 1.7
history.push({
    pathname: '/hello',
    search: {
        a: '1',
        b: '2'
    }
})
```
获取参数的时候： 
```javascript 1.7
const { urlSearch } = this.props
```

另外 提供一个Link组件
```javascript 1.7
import { RouterLib } from 'd3j-commonop'
const Link = RouterLib.Link
```

### diy
#### override reducer
```javascript 1.7
// you can handle before default by case first
// ./component/userlist/module/reducer.js
export default function reducer(state = {}, action) {
    switch (action.type) {
        case 'USERLIST_inputChange': {
            // 你自己的逻辑
            return {
                ...
            }
        }
       
        default: {
            // 否则默认处理
            return baseReducer(prefix, state, action)
        }
    }
}
```

### auth
权限组件 SimpleAuth
```jsx harmony
<SimpleAuth power="编辑"><ComponentA/></SimpleAuth>
```

### 加强版BaseForm
新增下拉选择框，日期框（分为单个日期框以及包含开始日期和结束日期的日期框），级联选择框
参数格式(和配置文件的columns类似，多了一个type属性)
[{
	title: '用户',
	dateIndex; 'userlist',
	key: 'userlist',
	type: 'select', //select表示类型是下拉选择框
	oplist: ['Jone', 'Effy', 'Dongyang']
}, {
	title: '起始时间',
	dateIndex; 'startDate',
	key: 'startDate',
	type: 'date' //date表示类型是单个日期的选择框
}, {
	title: '活动期限',
	dateIndex; 'period',
	key: 'period',
	type: 'rangeDate' //rangeDate表示类型是包含起止日期的选择框
}, {
	title: '省市',
	dateIndex; 'address',
	key: 'address',
	type: 'cascader', //cascader表示类型是级联选择器
	oplist: [{ //oplist表示级联的内容，如果没有则默认是省市级联
            value: 'LPL',
            label: 'LPL',
            children: [{
                value: 'EDG',
                label: 'EDG'
            }, {
                value: 'WE',
                label: 'WE'
            }]
        }, {
            value: 'LCK',
            label: 'LCK',
            children: [{
                value: 'SKT',
                label: 'SKT',
                children: [{
                    value: 'KT',
                    label: 'KT'
                }]
            }]
        }]
}]

---
_Source: https://npm.io/package/d3j-commonop · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
