0.6.1 • Published 7 months ago

zb-comp v0.6.1

Weekly downloads
-
License
-
Repository
-
Last release
7 months ago

指标网组件库

基于ElementUI进行的二次封装组件库

Project setup

npm install

Compiles and hot-reloads for development

npm run serve

Compiles and minifies for production

npm run lib

安装

使用npm安装插件

npm i zb-comp

在入口文件导入zb-comp

import ZbComp from 'zb-comp';
import 'zb-comp/lib/index/index.css';
Vue.use(ZbComp);

按需加载

增加bable-plugin-import插件

npm i babel-plugin-import -D

修改babel.config.js

module.exports = {
  plugins: [
    [
      'import',
      {
        libraryName: 'zb-comp',
        style: name => `${name}/index.css`,
        camel2DashComponentName: false,
        camel2UnderlineComponentName: false,
      },
    ],
  ],
};

修改导入方式

import { Dialog,Space,NoData } from 'zb-comp';

Vue.use(Dialog);
Vue.use(Space);
Vue.use(NoData);

组件

Space

避免组件紧贴在一起,拉开统一的空间。

<zb-space>
  <div>Div1</div>
  <div>Div2</div>
</zb-space>
属性类型可选值默认值描述
sizestring'small','middle','large', '10px', '10rem', '10%''small'间距大小

ColumnFilter

表格列设置,可以选择需要展示的列和不需展示的列 1. 设置表头最后一列的render方式

<el-table-column prop="action" label="操作" align="left" :render-header="renderOperationHeader">
  1. 在render函数中加入zb-column-filter
renderOperationHeader(h: any, { column }: any) {
  return (
    <div style={{ display: 'flex', justifyContent: 'space-between' }}>
      <span>{column.label}</span>
      <zb-column-filter columns={indexTableColumn} onChange={this.columnChange} />
    </div>
  );
}
属性类型可选值默认值描述
columnstring'small','middle','large', '10px', '10rem', '10%''small'间距大小
事件回调值描述
change表头数据点击确定后返回的表头数据

column

属性类型可选值默认值描述
idstring唯一表示
visiblebooleantrue, falsetrue列是否可见
editablebooleantrue, falsetrue列设置是否可以更改

Dialog

基于ElementUI的Dialog,可接受ElementUI的参数

<zb-dialog></zb-dialog>
属性类型可选值默认值描述
typestring'danger','warn', 'info'弹窗类型
showCancelButtonbooleantrue, falsetrue是否显示取消按钮
showFooterbooleantrue, falsetrue是否显示底部按钮
事件回调值描述
confirm点击确定的回调
close点击取消的回调

插槽

属性描述
footer弹窗底部插槽

函数式调用Dialog

导入插件后,可直接用下面的命令弹出Dialog

this.$dialog.alert({
  type: 'danger',
  message: '弹出框',
  confirm: () => {
    console.log('点击确定回调')
  },
  close: () => {
    console.log('点击取消回调')
  }
})

总共有this.$dialog.alert和this.$dialog.confirm两种调用方式,效果同window.alert和window.confirm

注意

  1. 函数式调用,适用于只需要给用户进行一句话提示时使用,复杂场景请使用组件式调用
  2. 组件式调用,请不要同时传入confirm事件和confirm属性,否则点击确定会触发两次
  3. 组件式调用,请不要同时传入close事件和close属性,否则点击确定会触发两次

NoData

无数据时的展示

<zb-nodata />
属性类型可选值默认值描述
descriptionstring'暂无数据'无数据描述

TableSearch

表格条件筛选组件,基于ElementUI的Form、FormItem、Input、Select、Cascader、DatePicker、Button等组件封装

<zb-table-search />

参数

属性类型可选值默认值描述
confarray所有筛选条件的集合
labelWidthstring'auto'表单域标签的宽度
contentWidthstring'140px'表单域输入框选择框等的宽度

conf 参数配置举例

get searchConf(): Record<string, any>[] {
  return [
    {
      type: 'input',
      id: 'queryName',
      name: '名称',
      placeholder: '请输入清单名称',
      length: 30,
    },
    {
      type: 'select',
      id: 'reviewStatus',
      name: '审核状态',
      placeholder: '请选择审核状态',
      options: this.reviewStatusList.map((_item: { status: string; name: string }) => ({
        value: _item.status,
        name: _item.name,
      })),
    },
    {
      type: 'date-range',
      id: 'dateRange',
      name: '审核时间',
      dbWidth: true,
      'picker-options': {
        disabledDate(time: any): boolean {
          const endTime = new Date(new Date().toLocaleDateString()).getTime() + 24 * 60 * 60* 1000 - 1;
          return time.getTime() > endTime;
        },
      },
    },
    {
      type: 'select',
      id: 'rational',
      name: '是否合理',
      placeholder: '请选择审核人',
      options: [
        {
          name: '是',
          value: true,
        },
        {
          name: '否',
          value: false,
        },
      ],
    },
    {
      type: 'select',
      id: 'areaId',
      name: '地区',
      placeholder: '请选择地区',
      event: {
        change: (value: string) => this.getBqItem(value),
      },
      options: this.areaList.map((_item: { areaId: string; name: string }) => ({
        value: _item.areaId,
        name: _item.name,
      })),
    },
    {
      type: 'select',
      id: 'tradeTemplateId',
      name: '清单',
      placeholder: '请选择清单',
      event: {
        change: (value: string) => this.getBqItemTrade(value),
      },
      hidden: !this.selectedAreaId,
      options: this.tradeTemplateList.map((_item: { id: string; description: string }) => ({
        value: _item.id,
        name: _item.description,
      })),
    }
  ]

事件

事件回调值描述
onSearch所有筛选条件对应值构成的对象点击搜索按钮的回调

插槽

属性描述
btn除默认搜索重置按钮外,自定义的其他操作按钮

QuarterPicker

季度选择器,基于ElementUI的DatePicker, Card等组件封装,实现季度选择

<zb-quarter-picker />

参数

属性类型可选值默认值描述
valuearray'', '2002-01-01'''默认日期

事件

事件回调值描述
onChange选中季度对象点击季度回调

QuarterRangePicker

季度范围选择器,基于ElementUI的DatePicker, Card等组件封装,实现季度范围选择

<zb-quarter-range-picker />

参数

属性类型可选值默认值描述
valuearraynull, [], '2002-01-01', '2020-12-31'null默认日期范围

事件

事件回调值描述
onChange两个选中季度对象的数组点击季度范围回调

Table

表格组件,基于ElementUI的Table, TableColumn, Pagination等组件和TableSearch组件实现的包含顶部条件筛选,表格及分页功能的 列表组件。

<zb-table />

参数

属性类型可选值默认值描述
searchConfarray所有筛选条件的集合
labelWidthstring'80px'顶部过滤条件表单域标签的宽度
columnsarray表格列头数据
tableDataarray表格数据
showIndexbooleantrue是否显示序号列
showPaginationbooleantrue是否显示分页
selectedIdsstring''所有选中数据id
pageNonumber1当前页码
pageSizenumber15每页显示数量
pageSizesnumber[]15, 30, 45, 60每页显示个数选择器的选项设置
totalnumber0数据总数量
selectableFunction(row, index)仅对有复选框列的表格有效,类型为 Function,Function 的返回值用来决定这一行的 CheckBox 是否可以勾选

注意

  1. 除上表中参数外,还支持el-table组件支持的所有参数

事件

事件回调值描述
onSearch过滤条件点击搜索或重置按钮回调
onRefresh点击分页查询表格数据回调
onCellClickrow, column, cell, event点击分页查询表格数据回调

注意

  1. 除上表中事件外,还支持el-table组件支持的所有事件

插槽

属性描述
default顶部筛选条件区,除默认搜索重置按钮外,自定义的其他操作按钮
tableColumnBefore表格开始自定义列
tableColumnAfter表格最后自定义列

Excel

基于 luckysheet 和 luckyexcel 的 Excel文件预览组件。

<zb-excel />

参数

属性类型可选值默认值描述
fileBlob要预览的blob文件
configobject组件内置的默认配置参数Excel展示的配置参数

注意

  1. 目前只支持.xlsx格式的Excel文件预览;
  2. config如果使用默认配置参数,该组件只支持预览,如果需要其他功能,可通过config进行配置,具体可参考luckysheet官方文档: https://mengshukeji.gitee.io/LuckysheetDocs/zh/;
  3. 使用该组件需在项目public下的index.html文件中引入如下文件:
<link rel='stylesheet' href='https://cdn.jsdelivr.net/npm/luckysheet/dist/plugins/css/pluginsCss.css' />
<link rel='stylesheet' href='https://cdn.jsdelivr.net/npm/luckysheet/dist/plugins/plugins.css' />
<link rel='stylesheet' href='https://cdn.jsdelivr.net/npm/luckysheet/dist/css/luckysheet.css' />
<link rel='stylesheet' href='https://cdn.jsdelivr.net/npm/luckysheet/dist/assets/iconfont/iconfont.css' />
<script src="https://cdn.jsdelivr.net/npm/luckysheet/dist/plugins/js/plugin.js"></script>
<script src="https://cdn.jsdelivr.net/npm/luckysheet/dist/luckysheet.umd.js"></script>

Docx

基于 docx-preview 封装的 Word 文档预览组件

<zb-docx />

参数

属性类型可选值默认值描述
srcBlob要预览的blob文件

注意

  1. 目前只支持.docx格式的Word文档预览;
0.5.10

8 months ago

0.5.8

8 months ago

0.5.7

9 months ago

0.5.9

8 months ago

0.5.4

9 months ago

0.5.3

9 months ago

0.5.6

9 months ago

0.5.5

9 months ago

0.5.0

11 months ago

0.6.1

7 months ago

0.5.2

10 months ago

0.6.0

7 months ago

0.5.1

10 months ago

0.3.9

1 year ago

0.3.0

1 year ago

0.2.1

1 year ago

0.2.0

1 year ago

0.3.6

1 year ago

0.2.7

1 year ago

0.3.5

1 year ago

0.2.6

1 year ago

0.3.8

1 year ago

0.2.9

1 year ago

0.3.7

1 year ago

0.2.8

1 year ago

0.1.9

1 year ago

0.3.2

1 year ago

0.2.3

1 year ago

0.4.0

12 months ago

0.3.1

1 year ago

0.2.2

1 year ago

0.3.4

1 year ago

0.2.5

1 year ago

0.3.3

1 year ago

0.2.4

1 year ago

0.1.8

1 year ago

0.1.7

1 year ago

0.1.6

1 year ago

0.1.5

1 year ago

0.1.4

1 year ago

0.1.3

1 year ago

0.1.2

2 years ago

0.1.1

2 years ago

0.1.0

2 years ago