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

antd-table-custom

v0.0.8

Published

antdtable自定义组件

Downloads

18

Readme

antd-table-custom

使用说明: 是一款基于antd table开发的扩展组件

安装: yarn add antd-table-custom || npm i antd-table-custom

列支持格式

   // renderCom对应的字段:
    RENDERTREE, //下拉树
    RENDERINPUTNUM, //数字输入框
    RENDERRADIO,  //单选组
    RENDERSELECT, // 下拉框
    RENDERSTAEX,  //文本框
    RENDERICON   //图标 目前不支持扩展
    //默认为input输入框

columns

  • columns中{}列的每一项
  • isRequire:表示添加、编辑时是否为必填项
  • isSearch:搜索中是展示 在配置toolbar时
  • hidden: 初始化时是否展示当前列
  • customRender:自定义操作咧渲染函数
  • renderCom:列会以什么形式渲染
  • disabled:当前是否为禁用状态
  • dict:字典、当返回函数与所需的字段不匹配时、如果为数组时则直接成为组件所需数组
  • api:请求函数
  • 操作列title必须为‘操作’ 或 dataIndex=“options”
  • MyIcon组件已经集成到源码 、目前不支持扩展
  • isCol:这个属性是唯一的,在你所需展示得名称上加入即可

示例代码如下

let columns: ColumnsType<MenuDataType> = [
        {
            title: '菜单名称',
            dataIndex: 'name',
            width: 200,
            ellipsis: true,
            key: 'name',
            isCol: true,
            isSearch: true,
            isRequire: true
        },
        {
            title: '路由地址',
            dataIndex: 'path',
            key: 'path',
            isSearch: true,
            isRequire: true
        },
        {
            title: '上级菜单',
            dataIndex: 'parentId',
            key: 'parentId',
            hidden: true,
            renderCom: RENDERTREE,
            dict: {
                label: 'title',
                value: 'id'
            },
            api: getMenuTree()
        },
        {
            title: '菜单图标',
            dataIndex: 'source',
            key: 'source',
            isRequire: true,
            renderCom: RENDERICON,
            render: (_: any, record: MenuDataType) => {
                return (<MyIcon type={getStringByLastkey(' ', record.source as string)} ></MyIcon>)
            }
        },
        {
            title: '菜单编号',
            dataIndex: 'code',
            key: 'code',
            isSearch: true,
            isRequire: true,
        },
        {
            title: '菜单类型',
            dataIndex: 'alias',
            key: 'alias',
            isRequire: true,
            dict: [
                {
                    label: '菜单',
                    value: 1
                }, {
                    label: '按钮',
                    value: 2
                }
            ],
            renderCom: RENDERRADIO,
        },
        {
            title: '菜单排序',
            dataIndex: 'sort',
            key: 'sort',
            isRequire: true,
            renderCom: RENDERINPUTNUM,
        },
        {
            title: "类型",
            dataIndex: "type",
            key: 'type',
            renderCom: RENDERSELECT,
            dict: [
                {
                    label: 'web',
                    value: 'web'
                }, {
                    label: 'pda',
                    value: 'pda'
                }, {
                    label: 'pad',
                    value: 'pad'
                }
            ],
        },
        {
            title: '备注',
            dataIndex: 'remark',
            key: 'remark',
            hidden: true,
            renderCom: RENDERSTAEX
        },
        {
            title: '操作',
            dataIndex: 'options',
            key: 'options',
            fixed: 'right',
            width: 400,
            edit: true,
            look: true,
            del: true,
            customRender: customRender,
        }
    ] 

toolsbar

  • toolsbar:是否展示顶部导航栏
  • addBtn:增加
  • delBtn:删除
  • reload:刷新
  • seach:搜索
  • columnsEdit:列编辑
  • addApi:添加请求函数
  • editApi:编辑请求函数
  • delApi:删除请求函数

使用方法

将动态生成表单方法暴露出来啦

import { byTableCloumsCreateFrom } from 'antd-table-custom';

使用方法:

//addClo:columns数据、
{addClo && byTableCloumsCreateFrom(addClo, fromProps)}

fromProps:

 //动态生成表单所需数据
    const [iconValue, setIconvalue] = useState('')
    const [treeData, setTreeData] = useState([])
    const [open, setopen] = useState(false)
    const [form] = Form.useForm();
    let formRef = useRef()
    //传递参数
    const fromProps = { anyProps: { iconValue, setIconvalue, treeData,open, setopen }, form, formRef }

新增列宽拖拽功能 但是需要设置列宽项才可以

源码目前还未开放、QQ:1015454418