# zl-vue-frame

> 为了各个开发人员开发的后台管理系统风统一，所以抽离了一个上线的项目架子去做开发，包括后期依赖版本的升级以及出现框架级别问题，也会比较好解决。

Latest version **1.0.2** (published 2019-06-05) · MIT license · 0 weekly downloads

## Install

```sh
npm install zl-vue-frame
pnpm add zl-vue-frame
yarn add zl-vue-frame
bun add zl-vue-frame
```

## 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 | 1.0.2 |
| Published | 2019-06-05 |
| First published | 2019-06-05 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >= 6.0.0 |
| Dependencies | 28 |
| Unpacked size | 1.4 MB |
| Known vulnerabilities | 0 (+39 in 8 direct dependencies) |
| Install scripts | no |
| Author | 于十月 |
| Maintainers | yushiyue |
| Keywords | vue, element-ui, admin, management-system, admin-template |

## Links

- npm: https://www.npmjs.com/package/zl-vue-frame
- npm.io page: https://npm.io/package/zl-vue-frame

## Dependencies (28)

- [vue](https://npm.io/package/vue.md) 2.6.6
- [vuex](https://npm.io/package/vuex.md) 3.1.0
- [xlsx](https://npm.io/package/xlsx.md) ^0.14.1
- [axios](https://npm.io/package/axios.md) 0.18.0
- [mockjs](https://npm.io/package/mockjs.md) 1.0.1-beta3
- [connect](https://npm.io/package/connect.md) 3.6.6
- [echarts](https://npm.io/package/echarts.md) 4.1.0
- [dropzone](https://npm.io/package/dropzone.md) 5.5.1
- [jsonlint](https://npm.io/package/jsonlint.md) 1.6.3
- [showdown](https://npm.io/package/showdown.md) 1.9.0
- [vue-i18n](https://npm.io/package/vue-i18n.md) 8.8.1
- [clipboard](https://npm.io/package/clipboard.md) 2.0.4
- [driver.js](https://npm.io/package/driver.js.md) 0.9.2
- [js-cookie](https://npm.io/package/js-cookie.md) 2.2.0
- [nprogress](https://npm.io/package/nprogress.md) 0.2.0
- [codemirror](https://npm.io/package/codemirror.md) 5.43.0
- [element-ui](https://npm.io/package/element-ui.md) 2.5.4
- [file-saver](https://npm.io/package/file-saver.md) 2.0.0
- [screenfull](https://npm.io/package/screenfull.md) 4.0.0
- [sortablejs](https://npm.io/package/sortablejs.md) 1.8.3
- [tui-editor](https://npm.io/package/tui-editor.md) 1.3.0
- [vue-router](https://npm.io/package/vue-router.md) 3.0.2
- [vue-count-to](https://npm.io/package/vue-count-to.md) 1.0.13
- [vuedraggable](https://npm.io/package/vuedraggable.md) ^2.16.0
- [normalize.css](https://npm.io/package/normalize.css.md) 8.0.1
- [vue-splitpane](https://npm.io/package/vue-splitpane.md) 1.0.2
- [vue-tree-chart](https://npm.io/package/vue-tree-chart.md) ^1.2.4
- [vue-table-with-tree-grid](https://npm.io/package/vue-table-with-tree-grid.md) ^0.2.4

## Recent versions

- 1.0.2 (latest) — 2019-06-05
- 1.0.1 — 2019-06-05
- 1.0.0 — 2019-06-05
- 3.9.3 — 2019-06-05

## README

### 项目运行

```bash
  # 开发
  npm run start:dev
  # 测试
  npm run start:test
  # 预发布
  npm run start:pre
  # 正式
  npm run start:prod
```

### 项目打包

```bash
  # 开发
  npm run build:dev
  # 测试
  npm run build:test
  # 预发布
  npm run build:pre
  # 正式
  npm run build:prod
```

### 项目基于vue-element-admin进行改造

[vue-element-admin文档地址](https://panjiachen.github.io/vue-element-admin-site/zh/guide/)

### 文件结构

```html

| -- zl-vue-frame
  | -- build  // webpack等一些配置文件
  | -- config // 全局变量以及运行打包配置文件
  | -- src 
    | -- api  //模块接口存放文件
    | -- assets  // 图片
    | -- components  // 公共组件
    | -- directive // 指令
    | -- filters // 过滤器
    | -- icons // svg图标使用
    | -- lang // i18n
    | -- router // 不需要权限中心控制的路由配置
    | -- store // 状态控制
    | -- styles // 样式
    | -- utils // 工具
    | -- views // 业务页面
```



### 组件使用

##### 1.美化版滚动条

- 需要给一个高度才会出现滚动条，属于element-ui没有暴露出来的一个组件

```html
  <el-scrollbar wrapClass="scrollbar-wrapper"></el-scrollbar>
```

##### 2.分页

| 属性 | 类型 | 介绍 |
|--|--|--|
| class | string | 使用`zl-pagination`会实现分页组件的居中 |
| 其他属性 | xxx | 其他属性参考`element-ui`文档 |

```html
  <el-pagination
    class="zl-pagination"
    @size-change="handleSizeChange"
    @current-change="handleCurrentChange"
    :current-page="currentPage"
    :page-sizes="[10, 20, 30, 40]"
    :page-size="100"
    layout="total, sizes, prev, pager, next, jumper"
    :total="total">
  </el-pagination>
```

##### 3.确定取消按钮
> 按钮使用原则第一个按钮默认主题色，其他按钮都是用白色也就是el-button的默认颜色

```html
  <el-button class="btn-theme" @click="save" >
    <svg-icon icon-class="pre-save"></svg-icon>
    我是主题色
  </el-button>

  <el-button class="btn-default" @click="$router.go(-1)">
    <svg-icon icon-class="pre-back"></svg-icon>
    我是默认色
  </el-button>
```



##### 4.删除，停用提示框

```js
const str = `
  <p style="text-align:center;">
    <i class="el-icon-warning" style="color:#299ee4;font-size:22px;vertical-align:middle;"></i>
    <span style="padding-left:10px;font-size:16px;vertical-align:middle;">此操作将永久删除, 是否继续?</span>
  </p>
`
dangerouslyUseHTMLString: true
```

##### 6.列表操作

- :show-overflow-tooltip="true"

```html
  <span class="icon-theme" @click="editInfo(scope.row)">编辑</span>
  <i class="zl-icon-line"></i>
  <span class="icon-theme" @click="stopFunc(scope.row)">{{ scope.row.status === 1 ? '停用' : '启用'}}</span>
```

```js
  // 表格固定表头

  // computed

  tableHeight() {
    return this.$store.state.app.$th
  }

  // watch

  tableData(data) {
    this.$store.dispatch('action_set_table_height', data.length)
  }

```

### 上传

- `:action="$store.state.vendor.photoUpload"`

- `:headers="{ token: $store.state.user.token }"`

``` html
<el-upload
  class="avatar-uploader"
  :action="$store.state.vendor.photoUpload"
  :show-file-list="false"
  :headers="{ token: $store.state.user.token }""
  :on-success="handleAvatarSuccess"
  :before-upload="beforeAvatarUpload">
  <img v-if="imageUrl" :src="imageUrl" class="avatar">
  <i v-else class="el-icon-plus avatar-uploader-icon"></i>
</el-upload>
```

```js
  // 上传之前
  beforeAvatarUpload(file) {
    const typeArr = ["image/png", "image/jpeg", "image/jpeg", "image/gif"]
    const isJPG = typeArr.indexOf(file.type) !== -1 ? true : false
    const isLt2M = file.size / 1024 <= 2048;
    if (!isJPG) {
      this.$message.warning("只能上传PNG,JPG,GIF格式的图片!")
    }
    if (!isLt2M) {
      this.$message.warning("图片大小不能超过2M!")
    }
    
    return isJPG && isLt2M
  },

  // 上传成功
  handleAvatarSuccess(response, file, fileList) {
    if (response.success) {
      this.$message.success('头像上传成功')
      this.imageUrl = response.data
    }
  }
```


### 限制规则

```js
import { validateInterAndZero } from '@/utils/validate'

const validateSeq = (rule, value, callback) => {
  if (value === '' || value === null || value === undefined) {
    callback()
  } else {
    if (!validateInterAndZero(value)) {
      callback(new Error('只能输入0以及正整数'))
    } else {
      if (value < 0 || value > 100000) {
        callback(new Error('只能输入0-100000'))
      } else {
        callback()
      }
    }
  }
}

const validateSeq2 = (rule, value, callback) => {
  if (value === '' || value === null || value === undefined) {
    callback()
  } else {
    if (!validateInterAndZero(value)) {
      callback(new Error('只能输入0以及正整数'))
    } else {
      if (value < 0 || value > 999) {
        callback(new Error('只能输入0-999'))
      } else {
        callback()
      }
    }
  }
}


staffLimit: [
  { validator: validateSeq, trigger: 'blur' }
],
seq: [
  { validator: validateSeq2, trigger: 'blur' }
]

```

### 关于表单验证
- utils/validate.js 里面有一部分验证规则
- 所有的验证需要用到正则的不要在文件里面写死，一律放到utils/validate.js里面

### 说明
框架里面还有一堆store以及utils里面的js并没有进行删除，到时候可以在不影响项目使用的情况下自行删除

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