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

v3-base-ui

v0.0.51

Published

element-plus for vue3

Downloads

22

Readme

v3-base-ui

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

install

npm install v3-base-ui

or

yarn add v3-base-ui

introduce

完整引入

import baseui from 'v3-base-ui';

Vue.use(baseui);

局部引入

如何使用

写了的简单的demo , 所在文件目录 src/main/demo ,直接下载项目运行就能看到效果

1663841501795

页面直接引入组件,然后相同的页面只需要写配置文件就可以了 (完整的demo在项目的src/main/demo目录)

列表的配置文件 tableConfig

export const tableConfig = {
  propList: [
    { type: "selection", width: "60"},
    { prop: "name", label: "姓名" },
    { prop: "age", label: "年龄" },
    { prop: "phone", label: "手机" },
    { 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",
      },
    },
  ],
};

index.html

<template>
  <el-card v-loading="loading" class="base-page">
    <BaseSearch
      v-bind="searchConfig"
      v-model="queryForm"
      @getList="getList"
      @reset="reset"
    >
      <el-button type="primary" @click="doAction('xz')">新增</el-button>
    </BaseSearch>
    <BaseTable
      v-bind="tableConfig"
      :table-data="tableData"
      :total="total"
      v-model:page="pageInfo"
      @getList="getList"
    >
      <template #handler="{ row }">
        <div>
          <el-button type="text" @click="doAction('bj', row)">编辑</el-button>
          <el-button type="text" @click="doAction('ck', row)">查看</el-button>
          <el-button type="text" @click="doAction('sc', row, index)"
            >删除</el-button
          >
        </div>
      </template>
    </BaseTable>

    <!-- 弹窗 -->
    <BaseDialog
      width="600px"
      :title="title"
      v-model="dialogVisible"
      :loading="dialogLoading"
      @click="doAction('qd')"
    >
      <BaseForm ref="baseForm" v-bind="formConfig" v-model="form"> </BaseForm>
    </BaseDialog>
  </el-card>
</template>

<script lang="ts" setup>
import { ref, toRefs } from "vue";
import { tableConfig } from "./config/table.config";
import { searchConfig } from "./config/search.config";
import { formConfig } from "./config/form.config";
import { usePageSearch } from "@/main/hooks/use-page-search";
import { copyField } from "@/main/utils";
import router from "../../../router";

// 模拟数据
const tableData = ref([
  {
    name: "张三",
    age: "16",
    sex: "男",
    phone: "1382200221\n 11111111111111111111",
    address: "成都",
  },
  {
    name: "李四",
    age: "18",
    sex: "女",
    phone: "182000000000",
    address: "宇宙的尽头哈哈哈哈哈哈哈哈哈啊哈哈哈哈哈哈哈哈哈",
  },
]);
// 初始化查询条件
const [state, queryForm, reset] = usePageSearch();
const { pageInfo, total, loading } = toRefs(state);
total.value = 2;
// queryForm.value = copyField(searchConfig);
const dialogVisible = ref(false);
const dialogLoading = ref(false);
const form = ref({});
// const tempRow = ref("");
const title = ref("");
const isAdd = ref(false);

//  数据查询
const getList = () => {
  console.log(queryForm.value);
};

/**
 * @description: 页面操作
 * @param {*} type 操作类型
 * @param {*} row 数据
 */
const doAction = (type: string, row?: any, index?: number) => {
  switch (type) {
    case "xz":
      form.value = copyField(formConfig);
      dialogVisible.value = true;
      isAdd.value = true;
      title.value = "新增";
      break;
    case "bj":
      // form.value = cloneDeep(row);
      dialogVisible.value = true;
      isAdd.value = false;
      form.value = row;
      title.value = "编辑";
      break;
    case "ck":
      router.push("/demo/detail");
      break;
    case "sc":
      console.log("删除");
      tableData.value.splice(index, 1);
      break;
    case "qd":
      if (isAdd.value) {
        // 新增
        tableData.value.push(form.value);
      }
      dialogVisible.value = false;
      break;
    default:
      console.log("其他操作");
  }
};
</script>

gitee

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