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

@devops-web/cs-tree-table

v2.1.4

Published

[更新日志](./CHANGELOG.md)

Downloads

144

Readme

组件

更新日志

更新流程

  1. 切换源到npm官方源https://registry.npmjs.org/
  2. npm login
  3. 使用npm version patch修改package.json中的版本号
  4. npm publish

组件开发流程

  1. 将已经开发完成的组件放入全局组件工程src\package
  2. 将组件注册到src\package\index.js文件中

使用方法

npm i @devops-web/cs-tree-table

全局引入

import Vue from "vue";
import CsTreeTable from "@devops-web/cs-tree-table";
Vue.use(CsTreeTable);

树形表格

  • selection, Boolean,默认 true,控制是否可选中
  • 需要设置 lazy=true 和 load 函数
  • hasChildren=true 标识行数据可以展开
  • slot:footer 可以设置底部的删除等操作配置,不设置的时候底部的全选按钮也不展示
<template>
  <div>
    <cs-tree-table
      :columns="columns"
      :data="tableData"
      :pagination="pagination"
      :operations="operations"
      @getTableData="getTableData"
      :expand-row-keys="expandRowKeys"
      :checked-row-keys="checkedRowKeys"
      rowKey="id"
      :load="load"
      :lazy="true"
    >
      <template v-slot:name="scope">
        <el-tag>{{scope.row.name}}</el-tag>
        <span>{{scope.row.date}}</span>
      </template>
      <template v-slot:footer>
        <el-button size="mini" :disabled="checkedRowKeys.length === 0"
          >删除</el-button
        >
      </template>
    </cs-tree-table>
  </div>
</template>

<script>
let count = 100;
export default {
  name: "CsTable2",
  data() {
    return {
      /**
       * 表格操作列:参数类型可以是Function,Array,false
       */
      operations(row, column, $index) {
        let data = [
          {
            name: "detail",
            label: "详情",
            action: () => {
              console.log("详情");
            },
          },
          {
            name: "edit",
            label: "编辑",
            action: () => {
              console.log("编辑");
            },
          },
          {
            name: "remove",
            label: "删除",
            disabled: true,
            confirmMsg: "确认要删除xxx吗",
            action: () => {
              console.log("删除");
            },
          },
          {
            name: "xxx1",
            label: "启动",
            disabled: true,
            action: () => {
              console.log("启动");
            },
          },
          {
            name: "xxx2",
            label: "停止",
            action: () => {
              console.log("停止");
            },
          },
        ];
        if ($index === 0) {
          data = data.slice(0, 2);
        }
        return data;
      },
      /**
       * 表格列:formatter:目前可以date|datetime
       * 表格列:slot为自定义单元格内容,slotHader为自定义表头内容
       */
      columns: [
        {
          label: "Name",
          dataIndex: "name",
          slot:'name' // 这里的name和template中的v-slot:name保持一致即可
        },
        {
          type: "expand",
          label: "Date",
          dataIndex: "date",
        },
        {
          label: "Address",
          dataIndex: "address",
          showOverflowTooltip: true,
        },
      ],
      expandRowKeys: [],
      checkedRowKeys: [],
      tableData: [
        {
          id: 1,
          date: "2016-05-02",
          name: "王小虎",
          address: "上海市普陀区金沙江路上海市普陀区金沙江路上海市普陀区金沙江路上海市普陀区金沙江路上海市普陀区金沙江路上海市普陀区金沙江路上海市普陀区金沙江路上海市普陀区金沙江路上海市普陀区金沙江路 1518 弄",
        },
        {
          id: 2,
          date: "2016-05-04",
          name: "王小虎",
          address: "上海市普陀区金沙江路 1517 弄",
        },
        {
          id: 3,
          date: "2016-05-01",
          name: "王小虎",
          address: "上海市普陀区金沙江路 1519 弄",
          hasChildren: true,
        },
        {
          id: 4,
          date: "2016-05-03",
          name: "王小虎",
          address: "上海市普陀区金沙江路 1516 弄",
        },
      ],
      /**
       * 分页:total,pageNum,pageSize必传,简单环境下只用维护total字段
       */
      pagination: {
        total: 100,
        pageNum: 1,
        pageSize: 20,
        pageSizes: [10, 20, 1000], // 非必填
      },
    };
  },
  methods: {
    load(row, resolve) {
      setTimeout(() => {
        resolve([
          {
            id: count++,
            date: "2016-05-01",
            name: "王小虎" + count++,
            address: "上海市普陀区金沙江路 1519 弄",
            hasChildren: true,
          },
          {
            id: count++,
            date: "2016-05-01",
            name: "王小虎" + count++,
            address: "上海市普陀区金沙江路 1519 弄",
          },
        ]);
      }, 1000);
    },
    getTableData() {
      // 这里需要清空,也可以设置默认的展开项和选中项
      this.expandRowKeys = [];
      this.checkedRowKeys = [];
      console.log(
        "分页参数",
        this.pagination.pageNum,
        this.pagination.pageSize
      );
      setTimeout(() => {
        this.tableData = [
          {
            id: 1,
            date: "2016-05-02",
            name: "王小虎3222",
            address: "上海市普陀区金沙江路 1518 弄",
          },
        ];
        this.pagination.total = 100;
      }, 1000);
    },
  },
};
</script>