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

v2-base-ui

v1.0.5

Published

element-ui for vue2

Downloads

71

Readme

v2-base-ui

基于 vue2 , element-ui 封装的一些通用的组件(表格,表单和弹窗),使用场景表格查询,表单编辑提交等。重复的表格页面和表单功能,只用写配置文件就行了。(组件具体使用的 deme,目录 src/main/demo,下载项目直接运行就可看到效果)

install

yarn add v2-base-ui

// 或者

npm install v2-base-ui

introduce

完整引入

import baseui from 'v2-base-ui';

Vue.use(baseui);

全局默认配置

// 全局配置可以减少很多重复的代码,统一规范

// 组件内置的全局基础配置
export const BASECONFIG = {
  // 查询默认length
  searchMaxlength: 50,
  // 表单默认length
  formMaxlength: 50,
  // 表单文本框默认length
  textareaMaxlength: 200,
  // 数据为空时默认占位符号
  emptyStr: "-",
  // table props 配置 ,默认了表单头部背景色
  tableProps: {},
  // 查询form的props
  searchProps: { inline: true, labelPosition: "right", labelWidth: "120px" },
  // 查询组件默认样式
  searchStyle: { width: "100%" },
  // 表单组件默认样式
  formStyle: { width: "400px", labelWidth: "120px" },
  // 分页默认样式
  pageStyle: { justifyContent: "flex-end" },
  // 默认字体大小
  defaultFontSize: "",
};

// 上面是组件内默认的配置如果需要重新定义可以使用配置项重新定义

Vue.use(baseui,opt);  // opt就是一个对象 {searchMaxlength: 100} 你可以重新自定义上面默认的配置项

局部引入

import { BaseTable,BaseForm,BaseDialog,BaseSearch,reset,copyField } from "v2-base-ui";

如何使用

先定义列表的配置文件 tableConfig

export const tableConfig = {
  propList: [
    { type: "selection", width: "60" },
    { prop: "name", prop2:"userNo", label: "姓名/工号" },
    { prop: "age", label: "年龄" },
    { prop: "phone", label: "手机" },
    {
      prop: "sex",
      label: "性别",
      options: [
        { value: 1, label: "男" },
        { value: 2, label: "女" },
      ],
      // 数组或者对象,然后会根据value值自动去匹配
      // options: {
      //   1: "男",
      //   2: "女",
      // },
    },
    { prop: "address", label: "地址", slotName: "address" },
    { label: "操作", width: "220", slotName: "handler", fixed: "right" },
  ],
};

定义查询条件的配置文件 searchConfig

export const searchConfig = {
  formItems: [
    {
      field: "name",
      type: "input",
      label: "姓名",
    },
    {
      field: "age",
      type: "input",
      label: "年龄",
    },
    {
      field: "phone",
      type: "input",
      label: "手机号",
    },
    {
      startField:'startDate',
      endField:'endDate',
      type: "datePicker",
      label: "时间范围",
      itemProps: {
        startPlaceholder: "开始时间",
        endPlaceholder: "结束时间",
        type: "daterange",
        format: "yyyy-MM-dd",
        valueFormat: "yyyy-MM-dd",
      },
    },
  ],
};

页面

<template>
  <div>
    <!-- 查询 -->
    <BaseSearch
      ref="BaseSearch"
      v-bind.sync="searchConfig"
      :query-form.sync="queryForm"
      @getList="getList"
    >
    </BaseSearch>
    <!-- 表格 -->
    <BaseTable
      v-bind="tableConfig"
      :table-data="tableData"
      :total="total"
      :page.sync="page"
      @getList="getList"
    >
    </BaseTable>
  </div>
</template>

<script>
import { tableConfig } from "./config/table.config";
import { searchConfig } from "./config/search.config";

// 接口返回的表格数据
const tableData = {
  code: 200,
  data: {
    total: 2,
    records: [
      {
        name: "张三",
        userNo: "U123456",
        age: "16",
        phone: "13822002211",
        sex: 1,
        address: "四川成都",
      },
      {
        name: "李四",
        userNo: "U123456",
        age: "18",
        phone: "18200000000",
        sex: 2,
        address: "",
      },
    ],
  },
};

// 模拟真实接口,返回数据
const getUser = (args) => {
    return new Promise((resolve, reject) => {
      if (args.currentPage === 1) {
        resolve(tableData);
      } else {
        reject("第二页没有数据");
      }
    });
};

export default {
  name: "demo",
  data() {
    const tb = {
      tableData: [],
      page: { currentPage: 1, pageSize: 10 },
      total: 0,
      loading: false,
      queryForm: {},
      searchConfig,
      tableConfig,
    };
    return {
      // 表格
      ...tb,
    };
  },
  mounted() {
    this.getList();
  },
  methods: {
    // 数据查询
    getList() {
      getUser(this.page).then((res) => {
        this.tableData = res.data.records || [];
        this.total = Number(res.data.total || 0);
     })
    },
  },
};
</script>
  • 就这么简单,一个标准的查询表单就出来了,后面有表格就只用增删配置项,解放双手。
  • 然后还有一些表单组件和弹窗具体使用方法可以看我写的 demo , 所在文件目录 src/main/demo ,直接下载项目运行就能看到效果
  • ps 组件持续迭代中

gitee

https://gitee.com/my-project---components/v2-base-ui