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

patpet-crud

v0.0.6

Published

基于elementUI进行二次封装的crud组件

Downloads

10

Readme

对 elementUI 进行二次封装的 crud 组件

安装

yarn add patpet-crud
或
npm i patpet-crud

使用

import patpetCrud from 'patpet-crud'
import 'patpet-crud/lib/patpet-crud.css'
Vue.use(patpetCrud)

示例

https://wenruo-l.github.io/CRUDWithElementUI/dist/index.html#/testCrud

代码

<template>
  <basic-container>
    <crud
      ref="crud"
      :option="option"
      v-model="form"
      :query.sync="query"
      :tableData="data"
      :before-open="beforeOpen"
      @row-save="rowSave"
      @row-update="rowUpdate"
      @row-delete="rowDelete"
      @handle-delete="handleDelete"
      @search-change="searchChange"
      @search-reset="searchReset"
      @selection-change="selectionChange"
      @current-change="currentChange"
      @size-change="sizeChange"
      @refresh-change="refreshChange"
      @on-load="onLoad"
    ></crud>
  </basic-container>
</template>

<script>
export default {
  name: "test-crud",
  data() {
    return {
      loading: true,
      form: {},
      query: {
        test4: "通过query设置的默认值",
      },
      page: {
        pageSize: 10,
        currentPage: 1,
        total: 0,
      },
      selectionList: [],
      option: {
        height: "auto",
        // calcHeight: 30,
        border: true,
        selection: true,
        column: [
          {
            label: "测试1",
            prop: "test1",
            rules: [
              {
                required: true,
                message: "搞快点",
                trigger: "blur",
              },
            ],
          },
          {
            label: "测试2",
            prop: "test2",
            type: "select",
            search: true,
            searchValue: 1,
            dicData: [
              {
                label: "选项1",
                value: 1,
              },
              {
                label: "选项2",
                value: 2,
              },
            ],
          },
          {
            label: "测试3",
            prop: "test3",
            searchValue: "通过option设置的默认值",
            search: true,
          },
          {
            label: "测试4",
            prop: "test4",
            search: true,
          },
          {
            label: "测试5",
            prop: "test5",
            search: true,
          },
          {
            label: "测试6",
            prop: "test6",
            search: true,
          },
          {
            label: "测试7",
            prop: "test8",
            span: 24,
            labelWidth: 200,
            search: true,
          },
        ],
      },
      data: [],
    };
  },
  created() {
    console.log("test-crud  this", this);
  },
  methods: {
    rowSave(form, done) {
      this.data.push(form);
      this.$message.success("操作成功");
      done();
    },
    rowUpdate(form, done, index) {
      this.$message.success(
        `第${index + 1}行 更新数据  ${JSON.stringify(form)}`
      );
      this.$set(this.data, index, form);
      setTimeout(() => {
        this.$message.success("操作成功");
      }, 500);
      done();
    },
    rowDelete(row, index) {
      this.data.splice(index, 1);
      this.$message.success("操作成功");
    },
    handleDelete(rows) {
      this.$message.warning(`选中删除数据 ${JSON.stringify(rows)}`);
    },
    beforeOpen(done, type) {
      if (type === "view") {
        this.form = {
          test1: "我不是哈哈嗨",
          test2: 2,
        };
      }
      done();
    },
    searchReset() {
      this.query = {};
      this.onLoad(this.page);
    },
    searchChange(params, done) {
      this.query = params;
      this.page.currentPage = 1;
      this.onLoad(this.page, params);
      done();
    },
    selectionChange(rows) {
      this.selectionList = rows;
    },
    selectionClear() {
      this.selectionList = [];
      this.$refs.crud && this.$refs.crud.toggleSelection();
    },
    currentChange(currentPage) {
      this.page.currentPage = currentPage;
    },
    sizeChange(pageSize) {
      this.page.pageSize = pageSize;
    },
    refreshChange() {
      console.log("refreshChange");
      this.onLoad(this.page, this.query);
    },
    onLoad() {
      this.loading = true;
      this.data.push({ test1: "哈哈嗨", test2: 1 });
      console.log("this.$refs.crud", this.$refs);
      this.selectionClear();
      this.loading = false;
    },
  },
};
</script>

文档地址

文档

包含组件

  • crud (增删查改)
  • p-table(封装好的表格)
  • p-form(封装好的表单)