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

zacard-cvx

v1.3.0

Published

convert tree xlsx import into vxe-grid metadata

Downloads

9

Readme

npm version npm downloads npm license

cvx

convert tree xlsx import into vxe-grid metadata

Install

yarn add zacard-cvx

How to use

参考examples/AppImp.vue
import { cvx } from 'zacard-cvx';

<vxe-button>
   <input type="file" @change="importDataEvent" accept=".xls,.xlsx,.csv">
</vxe-button>

<vxe-grid
      ref="xTable"
      highlight-current-row
      :mouse-config="{selected: true}"
      :keyboard-config="{isArrow: true, isDel: true, isEnter: true, isTab: true, isEdit: true}"
      :edit-config="{trigger: 'dblclick', mode: 'cell'}"
      :checkbox-config="{range: true}"
      :columns="tableColumnDef"
      :data="tableData"
      :tree-config="{children: 'children'}"
    >
</vxe-grid>

// data定义
tableColumnDef: [
        { field: 'seqId', title: '编号', treeNode: true },
        { field: '零件名称', title: '零件名称' },
        { field: '材料', title: '材料' },
        { field: '工艺', title: '工艺' },
        { field: '单件重量', title: '单件重量' },
        { field: '角色', title: '角色' },
        { field: '日期', title: '日期' }
]

const mockVueMehtods = {
  importDataEvent (evnt) {
      cvx(evnt, this, {
        colDef: this.tableColumnDef,
        tree: true
      })
        .then(res => {
          console.log(res)
          const {
            tableData
          } = res
          this.tableData = tableData
        })
        .catch(e => {
          console.error(e)
        })
  }
}

Reference

cvx inbound parameters

/**
 * @param {object} evnt dom原生事件
 * @param {object} vm 组件实例
 * @param {object} opt 选项
 * @param {string} opt.FS 使用什么分割符号切割每一行字段,默认使用\\$,防止内容内出现逗号
 * @param {number} opt.tmout 解析超时
 * @param {boolean} opt.tree 是否树形目录
 */
也可以参考 vxe_hello 项目

cvx promise return

res.headArr {array<string|any>} 列表头(数组形式)
res.headMap {object<string,string|any>} 列表头(字典形式)
res.tableData {array<object|any>} 格式化后的数组
res.hitResult {object[string,Array]} 匹配字段的结果
res.hitResult.hitCol {Array<string>} 匹配字段的结果,命中的
res.hitResult.unhitCol {Array<string>} 匹配字段的结果,未命中的

注意:当导入的是数组元素,会去tableData中第一列元素作为编号,同时每个元素都会有个seqId字段用来新编号,但同时保留了原编号供使用

// vxe-grid 树的column定义,注意使用treeNode: true
{ field: 'seqId', title: '编号', treeNode: true },
{ field: '零件名称', title: '零件名称' },
{ field: '材料', title: '材料' },
{ field: '工艺', title: '工艺' },
{ field: '单件重量', title: '单件重量' },
{ field: '角色', title: '角色' },
{ field: '日期', title: '日期' }