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

el-admin-table

v0.8.0

Published

vue element-ui table form pagination

Downloads

23

Readme

基本说明

  • 可以使用el-table/el-pagination/el-form的所有@事件
  • 增加了@reset, @goSearch
  • customQuery 不用渲染form的时候用的筛选条件
  • selectUnique 在使用选择框的时候,独一份的选择结果的obj,sync属性

api 调用需要传入 apiFn

formData使用 .sync 方式传入,可以互动成功

pagerAttrs .sync 方式传入,可以互动成功

属性说明 about Props

  /**
    * 开启选择框单选时,emit 最后一个选择 selectUnique.sync 接收
    * when el-table selection prop is enabled, selectUnique.sync will receive the last choice
    */
  selectUnique: {
    type: Object
  },
  /**
    * 用于显示总条数
    * sometimes we need to get the total amount after a success request, totalCount.sync prop will receive the number
    */
  totalCount: {
    type: Number,
    default: 0
  },
  /**
    * API函数 给个参数位置 apiFn(param)
    * 在父组件中调用可以用 apiFn(params) => otherFn(params, args)
    API function (param)
    complicated use e.g.
    */
  apiFn: {
    type: Function
  },
  /**
    * 是否使用分页器
    * use pagination or not
    */
  hasPager: {
    type: Boolean,
    default: true
  },
  /**
    * 分页插件配置
    * el-pagination config
    */
  pagerAttrs: {
    type: Object,
    default: () => {
      return {};
    }
  },
  /**
    * 不用渲染form的时候用的参数条件,任意参数为空,将不发请求,需要手动
    * some static params without rendering a form
    * [ Warning: an empty key-value will stop the request ]
    */
  customQuery: {
    type: Object,
    default: () => {
      return {};
    }
  },
  /**
    * 表格配置项
    * el-table props accepted
    */
  tableAttrs: {
    type: Object,
    default: () => {
      return {};
    }
  },
  /**
    * 表单
    * alias el-form model
    */
  formData: {
    type: Object,
    default: () => {
      return {};
    }
  },
  /**
    * 表格列表需要自己组装的数据结构
    * when http-response brings you a complicated Object, you can use this functional prop format the response
    */
  filterOut: {
    type: Function
  },
  /**
    * 是否需要查询按钮
    * whether you need search buttons
    */
  hasSearchBtn: {
    type: Boolean,
    default: true
  }

tableAttrs

  tableAttrs {
    ...{ /* el-table props */ },
    columns:[
      {
        col: {
          // all el-table-column props besides the below props
          // 包含除了以下4个的所有el-table-column属性
        },
        label, // 
        prop,  // 
        render, // vue.$createElement. (first class) 是一个h函数,来自vue.$createElement,优先显示html标签
        formatter // a simple function. (enable without render) 普通函数,用于改变字符串
      },
      {
        type: selection
      },
      {
        type: "index" // (just index) 序号
      },
      {
        type: operation,
        btns: [
          prop: row => { props },
          text: 'btn text',
          atClick: click event
        ]
      },
    ]
  }

render-button

  prop: (row: any) => {
    return {
      disabled: row.status === '1',
      type: 'text'
    };
  },
  show: (row: any) => row.name !== 1,
  text: 'comments',
  atClick: (row: RowType) => console.log(row)

tableAttrs

 tableAttrs: {
  border: true,
  size: 'small',
  'row-class-name': ({ rowIndex }) => {
    if (rowIndex % 2 === 1) {
      return 'dark';
    }
  },
  columns: [
    {
      type: 'selection'
    },
    {
      type: 'index'
    },
    {
      col: {
        sortable: true
      },
      prop: 'date',
      label: 'Date',
      formatter: row => new Date().toLocaleString()
    },
    {
      col: {
        width: '180px'
      },
      prop: 'name',
      label: 'Name'
    },
    {
      prop: 'address',
      label: 'Addr',
      render: (h, row) => h('div', {
        attrs: {
          class: 'box'
        }
      }, 'msg')
    },
    {
      type: 'operation',
      btns: [
        {
          prop: row => {
            return {
              disabled: row.status === 1
            };
          },
          text: 'Delete',
          atClick: row => console.log(row)
        }
      ]
    }
  ]
}