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

usetable1.0

v1.0.0

Published

vue2 elementui 框架对table表格的二次封装

Downloads

3

Readme

useTable

vue2-elementui-table表格组件二次封装

使用需要搭配elementui框架

属性说明

|属性名|类型|默认值|说明| | -- | -- | --|--| | httprequest | function | ()=>{} | 表格数据 | | headerList | Array | [] | 头部数据 | | onEvents | function | ()=>{} | 表格事件 | | showEmptyTable | Boolean | true | 表格数据为空时展示 | | propsObj | Object | {} | 表格 Attributes | | tableRef | String | '' | 表格ref |

使用示例

	<useTable
      :httprequest="httprequest"
      ref="useTable"
      :headerList="headerData"
       :onEvents="onEvents"
        :propsObj="{ stripe: true }"
    ></useTable>
import useTable from "@/components/useTable/useTable.vue";
export default {
  components: {
    useTable
  },
  data() {
    return {
     headerData:[
        {
          props: {
            label: "",
            type: "selection", //多选
            width: 80,
          },
        },
        props: {
            type: "index",
            width: 100,
        },
        {
          props: {
            prop: "id", //数据参数
            label: "ID", //表头数据
            width: 50 //表格列所占宽度
          },
        },
        {
          props: {
            prop: "name", //数据参数
            label: "名称", //表头数据
            width: 50, //表格列所占宽度
            "show-overflow-tooltip": true, //单行显示文字超出...省略,鼠标滑过弹窗形式展示全部内容
          },
        },
        { //展示的数据过多时可以使用render展示
          props: {
            prop: "",
            label: "已使用/已领取/总数",
            width: 150,
          },
          render: (h, scope) => {
            return (
              <div style="display:flex;">
                <span>{scope.row.use_count}/</span>
                <span>{scope.row.receive_count}/</span>
                <span>{scope.row.total_count}</span>
              </div>
            );
          },
        },
        {//render中也可以写组件
          props: {
            prop: "type_fomat",
            label: "课程",
            width: 300,
          },
          render: (h, scope) => {
            return (
              <div>
                <courseInfo
                  content={{
                    cover: scope.row.head_imgs[0],
                    title: scope.row.title,
                    price: scope.row.sale_price,
                    time: scope.row.created_time,
                  }}
                ></courseInfo>
              </div>
            );
          },
        },
        {
          props: {
            prop: "",
            label: "操作",
            width: 100,
          },
          render: (h, scope) => {
            return (
              <div class="button_warp">
                <div
                  class="line_button"
                  onClick={this.handleEdits.bind(
                    this,
                    scope.row.id,
                  )}
                >
                  编辑
                </div>
                <div
                  class="line_button"
                  onClick={this.handleDeletes.bind(
                    this,
                    scope.row
                  )}
                >
                  删除
                </div>
              </div>
            );
          },
        },
     ],
      searchParams: {
        limit: 10,
        page: 1,
      },
    }
  },
  methods:{
     async httprequest(params) {
        let _this = this;
      this.searchParams = params;
      let res = await this.xxxx(params);
      _this.select_ids.forEach((item) => {
        data.forEach((val) => {
          if (val.id == item) {
            console.log(_this.tableRef, val, "useTableRun.value.");
            _this.$nextTick(() => {
              _this.$refs.useTable.$children[0].toggleRowSelection(val, true);
            });
          }
        });
      });
      let keys = {
        data: res.list,
        total: res.count,
      };
      return keys;
    },
    onEvents() {
      return {
        "selection-change": (e) => {
          e.forEach((item) => {
            let index = this.select_ids.findIndex((ite) => {
              return ite == item.id;
            });
            if (index == -1) {
              this.select_ids.push(item.id);
              this.selectInfos.push(item)
            }
          });
        },
      };
    },
  }
}

效果图

暂无