1.1.12 • Published 5 years ago

@ixinwu-ngp/materials-component v1.1.12

Weekly downloads
2
License
MIT
Repository
-
Last release
5 years ago

NGP 组件库

风格

当前基础组件库使用的是ant.design 组件库,风格基于 ant.design 的设计语言封装实现

开发说明

样式方案参考@ixinwu-ngp/web-styles

antd 的组件使用按照以下方式,手动引用组件和对应样式

import Form from 'antd/lib/form';
import 'antd/lib/form/style';
import Icon from 'antd/lib/icon';
import 'antd/lib/icon/style';
import Input from 'antd/lib/input';
import 'antd/lib/input/style';
import Button from 'antd/lib/button';
import 'antd/lib/button/style';
import Checkbox from 'antd/lib/checkbox';
import 'antd/lib/checkbox/style';
import Row from 'antd/lib/row';
import 'antd/lib/row/style';
import Col from 'antd/lib/col';
import 'antd/lib/col/style';

API

CssBaseline

屏蔽浏览器的样式差异,修改 css 盒模型为 border-box

import CssBaseLine from '@ixinwu-ngp/materials-component/css_base_line';

Error

import Error from '@ixinwu-ngp/materials-component/error';

Props

NameTypeDefaultDescription
messagestring错误信息

Loading

import Loading from '@ixinwu-ngp/materials-component/loading';

Props

NameTypeDefaultDescription
messagestring提示信息
sizestringsmall/default/large组件大小

DateFormat

日期时间格式化组件,使用 moment 对日期/日期字符串进行转换和格式化

import DateFormat from '@ixinwu-ngp/materials-component/date_format';

Props

NameTypeDefaultDescription
valuestring|date|moment|number输入时间
formatstring'YYYY-MM-DD HH:mm:ss'时间格式
inValidstring'--'无效时展示内容

NumberFormat

数字格式化组件,使用 numeral 对数字进行转换和格式化

import NumberFormat from '@ixinwu-ngp/materials-component/number_format';

Props

NameTypeDefaultDescription
valuenumber输入数字
formatstring'0,0'数字格式
inValidstring'--'无效时展示内容

TextFormat

文本格式化,处理空文本显示

import TextFormat from '@ixinwu-ngp/materials-component/text_format';

Props

NameTypeDefaultDescription
valuestring输入文本
inValidstring'--'无效时展示内容

TypeFormat

类别格式化,通过 key 显示对应的文本名称

import DateFormat from '@ixinwu-ngp/materials-component/date_format';

Props

NameTypeDefaultDescription
valuestring类别 key
types[][]类别定义,每项格式为:{key: 'key1', text: '文本 1'}
inValidstring'--'无效时展示内容

NumberRangePicker

数值区间选择

import NumberRangePicker from '@ixinwu-ngp/materials-component/number_range_format';

Props

NameTypeDefaultDescription
valuenumber, number[]输入值
onChangefunction(number, number)[]数值变化时的回调
formatterfunction(value: number | string): string-指定输入框展示值的格式
parserfunction(string): number-指定从 formatter 里转换回数字的方式,和 formatter 搭配使用
minnumber-Infinity最小值
maxnumberInfinity最大值

FieldDisplay

根据字段配置(fields)解析对应数据(data)生成展示,可以用于业务对象详细属性的展示等

import FieldDisplay from '@ixinwu-ngp/materials-component/field_display';

Props

NameTypeDefaultDescription
fields[][]fields 配置
data{}{}业务对象数据,属性 key 需要与 fields 配置每项的 key 对应
onFieldClickfunction(field, value)可点击字段的回调,value 是 datafield.key

fields 每项配置说明

PropTypeDefaultDescription
keystring标识
textstring标签
displayTypestring展示方式,默认使用 TextFormat 组件展示,可配置为:'number' | 'datetime' | 'groupType'
groupKeystring关联的类别 Key, displayType 设置为 groupType 时有效
visiblebooleanfalse是否显示
clickablebooleanfalse是否可点击交互,触发 FieldDisplay 组件的 onFieldClick 属性配置的方法
colspannumber1占据单位宽度数量
formatstring展示格式,如果 displayType 为 datetime,格式定义参考 moment,如果 displayType 为 number,格式定义参考 numeral
inValidstring无效数据展示
componentReactComponet自定义展示组件,有三个属性:value 是 datafield.key ,field,data

FieldForm

根据字段配置(fields)解析对应数据(data)生成编辑表单,可用于实现业务对象创建和编辑功能

import FieldForm from '@ixinwu-ngp/materials-component/field_form';

Props

NameTypeDefaultDescription
fields[][]fields 配置
data{}{}业务对象数据,属性 key 需要与 fields 配置每项的 key 对应
fieldRelations[][]字段关联配置
groupCascades[][]类别级联配置

fields 每项配置说明

PropTypeDefaultDescription
keystring标识
textstring标签
displayTypestring展示方式,默认使用 Input 组件编辑,可配置为:'number' | 'datetime' | 'groupType'
groupKeystring关联的类别 Key, displayType 设置为 groupType 时有效
visiblebooleanfalse是否显示
colspannumber1占据单位宽度数量
formatstring展示格式,如果 displayType 为 datetime,格式定义参考 moment,如果 displayType 为 number,格式定义参考 numeral
componentReactComponet自定义表单组件,有两个属性:field,data

fieldRelations 配置

[
  {
    // 主字段Key
    masterFieldKey: 'aaa__type',
    // 从字段Key的范围(被控制的字段Key数组)
    slaveRangeFieldKeys: [
      'aaa__type1Field1',
      'aaa__type1Field2',
      'aaa__type2Field1',
      'aaa__type2Field2',
      // ...
    ],
    // 具体的关联配置
    relationConfig: [
      {
        // 当字段的数据值为type_1时,显示slaveFieldKeys对应的字段,其他被控制的字段Key数组中对应的字段不显示
        masterTypeKey: 'type_1',
        slaveFieldKeys: [
          'aaa__type1Field1',
          'aaa__type1Field2',
          //...
        ],
      },
      // ...
    ],
  },
  // ...
];

groupCascades 配置

[
  {
    // 主类型key
    masterGroupKey: 'typeGroup',
    // 从类型Key
    slaveGroupKey: 'stageGroup',
    // 具体的级联配置
    cascadeConfig: [
      {
        // 当关联主类型的字段值为type_1时,关联从类型的字段的类型可选key集合为['stage_1', 'stage_2', 'stage_3']
        masterTypeKey: 'type_1',
        slaveTypeKeys: ['stage_1', 'stage_2', 'stage_3'],
      },
      // ...
    ],
  },
  // ...
];

FieldGrid

FieldDisplayFieldForm默认布局组件,组件会根据容器 DOM 的实际宽度计算每项(field)的单位宽度

import FieldGrid from '@ixinwu-ngp/materials-component/field_grid';

Props

NameTypeDefaultDescription
fields[][]fields 配置

fields 每项配置说明

PropTypeDefaultDescription
keystringfield 的标识
displaystring | ReactNodefield 的对应的展示方式
colspannumber1field 占据单位宽度数量

ListSearch

根据字段配置(fields)生成搜索表单,可用于实现业务列表的查询功能

import FieldForm from '@ixinwu-ngp/materials-component/field_form';

Props

NameTypeDefaultDescription
fields[][]fields 配置
data{}{}业务对象数据,属性 key 需要与 fields 配置每项的 key 对应

fields 每项配置说明

PropTypeDefaultDescription
keystring标识
textstring标签
displayTypestring展示方式,默认使用 Input 组件编辑,可配置为:'number' | 'datetime' | 'groupType'
groupKeystringdisplayType 为 groupType 时有效,关联的类别 Key
showTotalbooleanfalsedisplayType 为 groupType 时有效,下拉列表是否显示“全部”选项
searchablebooleanfalse是否可作为查询条件,在 ListSearch 组件中只展示 searchable 为 true 的字段
colspannumber1占据单位宽度数量
componentReactComponet自定义表单组件,有两个属性:field,data

ListTable

根据字段配置(fields)生成数据表格,可用于实现业务列表的数据列表展示

import ListTable from '@ixinwu-ngp/materials-component/list_table';

Props

NameTypeDefaultDescription
fields[][]fields 配置
onCellClickfunction(field, value, record)字段点击回调

其他属性与 antd 的 Table 组件相同

fields 每项配置说明

PropTypeDefaultDescription
keystring标识
textstring标签
displayTypestring展示方式,默认使用 TextFormat 组件展示,可配置为:'number' | 'datetime' | 'groupType'
groupKeystring关联的类别 Key, displayType 设置为 groupType 时有效
visiblebooleanfalse是否显示
clickablebooleanfalse是否可点击交互,触发 ListTable 组件的 onCellClick 属性配置的方法
formatstring展示格式,如果 displayType 为 datetime,格式定义参考 moment,如果 displayType 为 number,格式定义参考 numeral
inValidstring无效数据展示
renderfunction(value,record)自定义列展示,与 antd 的 Table 组件中 Column 的 render 定义相同
componentReactComponet自定义展示组件,有三个属性:value,field,record
1.1.12

5 years ago

1.1.11

5 years ago

1.1.10

5 years ago

1.1.9

5 years ago

1.1.8

5 years ago

1.1.7

5 years ago

1.1.6

5 years ago

1.1.5

5 years ago

1.1.4

5 years ago

1.1.3

5 years ago

1.1.2

5 years ago

1.1.1

5 years ago

1.1.0

5 years ago

1.0.0

5 years ago