Socket
Book a DemoInstallSign in
Socket

@tongdun/react-ui-table

Package Overview
Dependencies
Maintainers
6
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install
Package was removed
Sorry, it seems this package was removed from the registry

@tongdun/react-ui-table

中后台通用表格展示页面

unpublished
latest
Source
npmnpm
Version
1.0.11
Version published
Maintainers
6
Created
Source

描述

基于react,antd和react-ui-form的企业级中后台表格组件

Install

npm install @tongdun/react-ui-table

引用方式

import TdTable from '@tongdun/react-ui-table'

API

基础参数

参数说明类型默认值
formConfig查询头配置,参见react-ui-formArray-
formProps其他react-ui-form参数Object-
handler查询/翻页的回调函数(params, pagination)=>{}-
header表格和查询体之间的内容String|ReactNode-
pagination分页器,参考配置项paginationObject{current: 1,pageSize: 10}
tableProps其他antd table配置Object-
rowKey表格行 key 的取值,可以是字符串或一个函数String|Function(record):string'key'
columnsantd table columns,若有width属性,会自动做超长tooltip处理Array-
dataSource数据数组Array-

实例

class CommonTable extends Component {
  constructor (props) {
    super(props)
    this.state = {
      pagination: {pageSize: 10, current: 2}, //分页对象
      dataSource: dataSource, //表格数据源
      genderSelect: genderSelect //性别下拉框
    }
  }

  detail (record) {
    console.log('查看事件',record)
  }

  handlerSubmit (params, pagination) {
    console.log(params, pagination, 'handleSubmit')
    //此处pagination需要手动更新!
    this.setState({
      pagination: pagination
    })
  }

  add () {
    console.log('新增',this.state.dataSource)
  }

  render () {
    const {genderSelect, dataSource, pagination} = this.state
    const columns = [
      {
        title: '姓名',
        dataIndex: 'name',
        key: 'name'
      }, {
        title: '年龄',
        dataIndex: 'age',
        key: 'age'
      }, {
        title: '地址',
        dataIndex: 'address',
        key: 'address',
        // 若有width属性,会自动做超长tooltip处理
        width: 100
      }, {
        title: '性别',
        dataIndex: 'gender',
        key: 'gender',
        render: (text, record) => {
          return <span>
            {record.gender === 'F' ? '女' : '男'}
          </span>
        }
      }, {
        title: '操作',
        key: 'opt',
        render: (text, record) => (
          <span>
                <a href='javascript:void(0)' style={{marginRight: 5}}
                   onClick={this.detail.bind(this, record)}>查看事件</a>
          </span>
        )
      }
    ]

    const formConfig = [{
      type: 'rangePicker',
      label: '出生日期',
      name: 'time',
      format: 'YYYY-MM-DD HH:mm:ss',
      keys: ['startTime', 'endTime'],
      initialValue: [moment().subtract(3, 'month'), moment()],
      item: <RangePicker showTime
                         format='YYYY-MM-DD HH:mm:ss'
                         ranges={{
                           ['30天']: [moment().subtract(30, 'days'), moment()]
                         }}/>
    }, {
      label: '性别',
      name: 'gender',
      item: <Select style={{width: 100}}>
        {
          Object.keys(genderSelect).map((item, index) => {
            return <Option key={index} value={item}>{genderSelect[item]}</Option>
          })
        }
      </Select>
    }, {
      label: '地址',
      name: 'address',
      item: <Input type='text'/>
    }, {
      type: 'button',
      items: [
        {
          active: 'Submit',
          value: '查询'
        },
        {
          active: 'Reset',
          value: '重置',
          props: {
            type: 'default'
          }
        }
      ]
    }
    ]
    const rowSelection = {
      onChange: (selectedRowKeys, selectedRows) => {
        console.log(`selectedRowKeys: ${selectedRowKeys}`, 'selectedRows: ', selectedRows)
      }
    }
    const header = <div style={{marginBottom: 20}}>
      <Button type={'primary'} icon={'plus'} onClick={this.add.bind(this)}>新增</Button>
    </div>
    return (
      <ReactUiTable
        columns={columns}
        dataSource={dataSource}
        formConfig={formConfig}
        pagination={pagination}
        rowKey={'id'}
        header={header}
        handler={this.handlerSubmit.bind(this)}
        tableProps={
          {rowSelection: rowSelection}
        }
        formProps={
          {style: {boxShadow: '0 4px 2px #ccc',margin:10}}
        }
      />
    )
  }
}

react-ui-table

Keywords

react

FAQs

Package last updated on 15 Nov 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.