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

meta_components

v1.8.5

Published

Downloads

142

Readme

元数据组件库

元数据控件类型定义

| 控件 | 常量 | 值(string) | | --- | --- | --- | | 单行文本 | FIELD_TYPE__SINGLE_LINE | 1 | | 下拉框单选 | FIELD_TYPE__DROPDOWN_RADIO | 2 | | 复选框 | FIELD_TYPE__CHECKBOX | 3 | | 下拉复选 | FIELD_TYPE__DROPDOWN_MULTIPLE | 4 | | 日期 | FIELD_TYPE__DATE | 5 | | 开关/布尔值 | FIELD_TYPE__SWITCH | 6 | | 多行文本 | FIELD_TYPE__MULTILINE | 7 | | 层叠选择/树形选择 | FIELD_TYPE__CASCADE | 8 | | 图片 | FIELD_TYPE__IMAGE | 9 | | 文件 | FIELD_TYPE__FILE | 10 | | 精确到秒的时间选择器 | FIELD_TYPE__DATETIME | 11 |

安裝

# 安装组件库
npm i meta_components -S

引入组件库

// 方式1 
import Vue from 'vue';
import mc from 'meta_components';
import 'meta_components/lib/index.css'

Vue.use(mc, http => {
  // 挂载 baseUrl
  http.defaults.baseURL = process.env.NODE_ENV === 'development' ? '/oa_api' : ''
  // Add a request interceptor
  http.interceptors.request.use(function (config) {
    // config.headers['token'] = Vue.$cookies.get('token')
    return config
  }, function (error) {
    // Do something with request error
    return Promise.reject(error)
  })
  
  http.interceptors.response.use(function (response) {
    return response
  }, function (error) {
    // Do something with response error
    return Promise.reject(error)
  })
})

1、元数据 表格套装  mc-data-grid-base

Attributes

| 参数 | 默认值 | 类型 | 说明 | | --- | --- | --- | --- | | metaid | (无) | string | (必须值) | | formTitle | 表单 | string | 表单标题 |

Events

| 事件名称 | 说明 | 回调参数 | | --- | --- | --- | | row-command | 特殊行级操作处理 | {type: string, row: object, metaid: string } | | table-command | 特殊表级操作处理 | {type: string, metaid: string } |

示例

<!--
 * User: CHT
 * Date: 2020/3/7
 * Time: 15:48
-->
<template>
  <div>
    <mc-data-grid-base
      @row-command="rowCommand"
      @table-command="tableCommand"
      metaid="oa_employee_next_birthday">
    </mc-data-grid-base>

    <!--    <mc-data-grid-base-->
    <!--      metaid="oa_employee_entry_record">-->
    <!--    </mc-data-grid-base>-->

    <!--    <mc-data-grid-base-->
    <!--      metaid="oa_employee_schedule_sign">-->
    <!--    </mc-data-grid-base>-->

    <!--    <mc-data-grid-base-->
    <!--      metaid="oa_sys_post_type">-->
    <!--    </mc-data-grid-base>-->

    <!--    <mc-data-grid-base-->
    <!--      metaid="oa_resume_invite_record">-->
    <!--    </mc-data-grid-base>-->

    <!--    <mc-data-grid-base-->
    <!--      @row-command="rowCommand"-->
    <!--      @table-command="tableCommand"-->
    <!--      metaid="oa_resume_invite">-->
    <!--    </mc-data-grid-base>-->

    <!--    <mc-data-grid-base-->
    <!--      @row-command="rowCommand"-->
    <!--      @table-command="tableCommand"-->
    <!--      metaid="oa_talent_bank">-->
    <!--    </mc-data-grid-base>-->

    <!--    <mc-data-grid-base-->
    <!--      @row-command="rowCommand"-->
    <!--      @table-command="tableCommand"-->
    <!--      metaid="oa_resume_ready">-->
    <!--    </mc-data-grid-base>-->

    <!--    <mc-data-grid-base-->
    <!--      metaid="oa_resume_pre">-->
    <!--    </mc-data-grid-base>-->

    <!--    <mc-data-grid-base-->
    <!--      metaid="oa_employee_contract">-->
    <!--    </mc-data-grid-base>-->

    <!--    <mc-data-grid-base-->
    <!--      metaid="oa_employee_birthday">-->
    <!--    </mc-data-grid-base>-->

    <!--    <mc-data-grid-base-->
    <!--      metaid="oa_user_info">-->
    <!--    </mc-data-grid-base>-->

  </div>
</template>

<script>
  export default {
    data() {
      return {}
    },
    methods: {
      // 内部无法处理的特殊类别的 [行级操作] 处理函数
      rowCommand(options) {
        console.log(options)
      },
      // 内部无法处理的特殊类别的 [表级操作] 处理函数
      tableCommand(options) {
        console.log(options)
      }
    }
  }
</script>

2. mc-file/mc-image

  • mc-file 上传文件
  • mc-image 上传图片

Attributes

| 参数 | 类型 | 默认值 | 说明 | | --- | --- | --- | --- | | inject-value.sync | array | [] | (必须参数) 使用时带上 .sync  | | accept | array | 上传文件: ['.pdf', '.doc', '.docx', '.xls', '.xlsx', '.ppt', '.pptx', '.zip', '.rar', '.jpg', '.png', '.jpeg', '.gif', '.txt'] 上传图片:['image/png',  'image/jpg',  'image/jpeg'] | 文件类型限制(参考input type=file 时 accept) | | max-size | number | 1024 * 1024 * 5 | 文件大小限制 | | number | number | 9 | 文件数量限制 | | readonly | boolean | false | 是否只读 |

Events

| 事件名称 | 说明 | 回调参数 | | --- | --- | --- | | change | 文件上传成功/删除成功 后回调 | (无) |

示例

<!--
 * User: CHT
 * Date: 2020/3/5
 * Time: 13:59
-->
<template>
  <div>
    <br>
    <mc-file
      :readonly="false"
      :number="9"
      :maxSize="1024 * 1024 * 3"
      :inject-value.sync="files1"
      :acceptList="['.zip']">
    </mc-file>
    <br>
    <mc-file
      @change="files2Change"
      :inject-value.sync="files2">
    </mc-file>
    <br>
    <mc-image
      :readonly="false"
      :number="9"
      :maxSize="1024 * 1024 * 3"
      :acceptList="['image/png']"
      :inject-value.sync="images1">
    </mc-image>
    <mc-image
      @change="image2Change"
      :inject-value.sync="images2">
    </mc-image>
  </div>
</template>

<script>
  export default {
    data() {
      return {
        files1: [],
        files2: [
          'https://trainpics.weiye360.cn/5c276da756824a64e47b7925bccec00c.jpg'
        ],
        images1: [
          'https://trainpics.weiye360.cn/5c276da756824a64e47b7925bccec00c.jpg'
        ],
        images2: []

      }
    },
    methods: {
      files2Change() {
        console.log(this.files2)
      },
      image2Change() {
        console.log(this.images2)
      }
    }
  }
</script>

3. mc-data-grid

  • 元数据表格
  • 包含搜索
  • 包含表级操作按钮

Attributes

| 参数 | 默认值 | 类型 | 说明 | | --- | --- | --- | --- | | metaid | (无) | string | (必须值) |

Events

| 事件名称 | 说明 | 回调参数 | | --- | --- | --- | | row-command | 特殊行级操作处理 | {type: string, row: object, metaid: string } | | table-command | 特殊表级操作处理 | {type: string, metaid: string } | | handler | 表级操作:"add"行级操作:"modify"、"view"这三种操作会触发该方法 | {metaid: string, operation: string, rowId?: string}// "modify"、"view"  时存在 rowId |

示例:

 

  • mc-data-grid-base 实现源码
  • 包含 mc-data-grid 、 mc-meta-form
<!--
 * User: CHT
 * Date: 2020/4/13
 * Time: 16:55
-->
<template>
  <div class="mc-date-grid-base__container">
    <mc-data-grid
      ref="dataGrid"
      :metaid="metaid"
      @row-command="rowCommand"
      @table-command="tableCommand"
      @handler="handler">
    </mc-data-grid>
    <el-drawer
      :visible.sync="drawerConf.visible"
      size="800px"
      :wrapper-closable="false"
      :title="formTitle">
      <mc-meta-form
        v-if="drawerConf.visible"
        ref="metaForm"
        size="medium"
        :label-width="120"
        :span="12"
        :metaid="metaid"
        :rowId="drawerConf.rowId"
        :operation="drawerConf.operation">
        <template v-slot="{form}">
          <el-col
            class="mc-date-grid-base__container-handler"
            :span="24">
            <el-button
              v-if="form.operation !== OPERATION_TYPE__VIEW"
              @click="metaFormSubmit"
              type="primary">
              提交
            </el-button>
            <el-button
              v-if="form.operation === OPERATION_TYPE__ADD"
              @click="metaFormReset">
              重置
            </el-button>
          </el-col>
        </template>
      </mc-meta-form>
    </el-drawer>
  </div>
</template>

<script>
  import mcDataGrid from './table'
  import {
    OPERATION_TYPE__ADD,
    OPERATION_TYPE__MODIFY,
    OPERATION_TYPE__VIEW,
    RESPONSE_CODE__SUCCESS
  } from '../types'
  import {apiMetaFormSubmit} from '../api'

  export default {
    props: {
      metaid: {
        type: String,
        default: '',
        required: true
      },
      formTitle: {
        type: String,
        default: '表单'
      }
    },
    data() {
      return {
        drawerConf: {
          visible: false,
          rowId: '',
          operation: '',
          metaid: '',
          reset() {
            this.visible = false
            this.rowId = ''
            this.operation = ''
            this.metaid = ''
          }
        },
        OPERATION_TYPE__ADD,
        OPERATION_TYPE__MODIFY,
        OPERATION_TYPE__VIEW
      }
    },
    components: {
      mcDataGrid
    },
    methods: {
      handler({metaid, operation, rowId = ''}) {
        Object.assign(this.drawerConf, {
          metaid,
          operation,
          rowId,
          visible: true
        })
      },
      metaFormSubmit() {
        this.$refs.metaForm.loading = true
        this.$refs.metaForm.validate()
          .then(data => {
            return apiMetaFormSubmit({
              metaid: this.metaid,
              operation: this.drawerConf.operation,
              data
            })
          })
          .then(result=> {
            if(result.state === RESPONSE_CODE__SUCCESS) {
              this.$message.success('添加成功!')
              this.drawerConf.reset()
              this.$refs.dataGrid.resetSearch()
            }
          })
          .catch(err => {
            console.error(err)
          })
          .finally(()=> {
            this.$refs.metaForm.loading = false
          })
      },
      metaFormReset() {
        this.$refs.metaForm.reset()
      },
      rowCommand(options) {
        this.$emit('row-command', options)
      },
      tableCommand(options) {
        this.$emit('table-command', options)
      }
    }
  }
</script>