npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

bph

v1.0.0-beta107

Published

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

Downloads

511

Readme

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个页面,部门管理,员工管理

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