Socket
Book a DemoInstallSign in
Socket

bph

Package Overview
Dependencies
Maintainers
5
Versions
193
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

bph

本工具基于react, dva, antd 为方便开发列表的增删改查功能。

1.0.0-beta107
latest
npmnpm
Version published
Weekly downloads
78
-63.55%
Maintainers
5
Weekly downloads
 
Created
Source

bph

本工具基于react, dva, antd 为方便开发列表的增删改查功能。

功能点

1. 条件

用户可以通过下面代码添加条件

  renderCondition = () => {
    const {
      tableCardState: { condition },
    } = this.props;
    const conditionItems: IConditionItem[] = [
      ConditionItem({ title: '编号', field: 'id', initialValue: '' }),
      ConditionItem({ title: '部门名称', field: 'name', initialValue: '' }),
      undefined,
    ];
    return conditionItems;
  };

2. 操作按钮

默认情况下,操作按钮有 新增,删除2个按钮。 用户可以通过下面代码添加新的按钮

renderActionBar() {
  return [
    <Button key="check" onClick={() => console.log('审核')}>
      审核
    </Button>,
  ];
}

3. 列表

列表是用antd 的 Table封装。

render() {
  const tableCardConfig: ITableCardBaseConfig = {
    namespace: NAMESPACE, // 对应 model 的 NAMESPACE
    rowKey: 'id', // 数据主键,必须唯一。
    addButtonState: { visible: true, disabled: false }, // 操作按钮栏上,新增按钮是否可见/可用
    downloadButtonState: { visible: true, disabled: false }, // 条件栏上,下载按钮是否可见/可用
    deleteButtonState: { visible: true, disabled: false }, // 操作按钮栏上,删除按钮是否可见/可用
    scroll: { y: 500 }, // 设置横向或纵向滚动,也可用于指定滚动区域的宽和高,可以设置为像素值,百分比,true 和 'max-content'
    selectType: 'crossPageSelect', // 'radio' | 'checkbox' | 'crossPageSelect'
    pagination: {
      position: 'flex-start', // 分页条位置
    },
    filledParentNode: true, // 是否将表格充满整个容器
    autoSearch: true, // 页面加载完时,是否自动调用查询
    checkBox: true, // 数据行前是否显示复选框
    onRow: (record: IHash, index: number) => {
      return {
        style: {
          color: index % 2 ? '#ff0000' : '#00ff00',
        },
      };
    },
    columns: [
      {
        title: '编号',
        dataIndex: 'id',
        width: 340,
        // fixed: 'left',
        sorter: true,
      },
      {
        title: '名称',
        dataIndex: 'name',
        width: 200,
        // fixed: 'left',
        sorter: true,
      },
      {
        title: '创建时间',
        dataIndex: 'createDate',
        sorter: true,
      },
      {
        title: '操作',
        width: 180,
        render: (text, record, index) => {
          if (!this.tableCardBaseRef.current) {
            return null;
          }
          const { onEdit, onDelete, onCopy } = this.tableCardBaseRef.current;
          return (
            <OptionContainer splitLine={false}>
              <TextButton data={record} onClick={onEdit}>
                编辑
              </TextButton>
              <TextButton data={record} onClick={this.onOpenUser}>
                员工
              </TextButton>
              <TextButton data={record} onClick={onDelete}>
                删除
              </TextButton>
            </OptionContainer>
          );
        },
      },
    ],
  };

  return (
    <TableCardBase
      ref={this.tableCardBaseRef}
      tableCardConfig={tableCardConfig}
      renderCondition={this.renderCondition}
      renderActionBar={this.renderActionBar}
      renderEditor={this.renderEditor}
      {...this.props}
    />
  );
}

4. 添加/编辑

用户可以通过下面代码添加弹框进行数据的添加编辑

renderEditor() {
  return <Editor />;
}

demo

本例中有2个页面,部门管理,员工管理

  • 部门管理 -- 源代码:src/pages/page.department
  • 用户管理 -- 源代码:src/pages/page.user

FAQs

Package last updated on 08 Apr 2022

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.