# zg-business

## 安装
```
yarn add zg-business -D
```

## 引入
### store
* 引入业务actions，以便action调用
在actions定义文件中

```
import {bizComponents, bizStore, bizModules} from 'zg-business'
const actions = {
  ...bizStore.actions
}
```

* 引入业务store

``` js
import Vue from 'vue'
import Vuex from 'vuex'

import {bizComponents, bizStore, bizModules} from 'zg-business'
import {ajax} from '../utils'
let bizStore = bizStore.getStore(ajax) // ajax工具需要引用时传入

Vue.use(Vuex)

export default new Vuex.Store({
  modules: {
    ...bizStore
  }
})
```

### components
在项目入口文件中

``` js
// 业务组件库
import {bizComponents, bizStore, bizModules} from 'zg-business'
import 'zg-business/dist/zg-business.css'

Vue.use(bizComponents)
```

### 功能模块

环境要求
1. 全局混入中，包含appId与platform
2. 数据采集sdk的全局对象zhuge，需挂载在window上，支持window.track调用
3. 获取当前用户信息
``` js 
this.$store.dispatch(bizStore.actions.biz.sys.getCurrentUser)
```
4. 设置当前应用
``` js
this.$store.dispatch(bizStore.actions.biz.sys.setCurrentApp, app)
```

``` js
import {bizComponents, bizStore, bizModules} from 'zg-business'

Vue.use(bizModules)
```
#### 实时概览
使用实时概览功能，需要页面中引入百度地图sdk
``` html
<script src="//api.map.baidu.com/api?v=3.0&ak=6Vi0r310u4EvjbznTi12W9ym7iP7OTg9"></script>
```