All Projects → dream2023 → vue-ele-import

dream2023 / vue-ele-import

Licence: other
超简单、好用的 element-ui Excel 导入组件

Programming Languages

Vue
7211 projects
javascript
184084 projects - #8 most used programming language
HTML
75241 projects

Projects that are alternatives of or similar to vue-ele-import

abap2xlsx
Generate your professional Excel spreadsheet from ABAP
Stars: ✭ 493 (+886%)
Mutual labels:  excel, excel-import
xlsx-reader
xlsx-reader is a PHP library for fast and efficient reading of XLSX spreadsheet files. Its focus is on reading the data contained within XLSX files, disregarding all document styling beyond that which is strictly necessary for data type recognition. It is built to be usable for very big XLSX files in the magnitude of multiple GBs.
Stars: ✭ 40 (-20%)
Mutual labels:  excel, excel-import
vue-odometer
Vue.js(v2.x+) component wrap for Odometer.js
Stars: ✭ 63 (+26%)
Mutual labels:  vue-component
SchemaMapper
A .NET class library that allows you to import data from different sources into a unified destination
Stars: ✭ 41 (-18%)
Mutual labels:  excel
ingest-file
Ingestors extract the contents of mixed unstructured documents into structured (followthemoney) data.
Stars: ✭ 40 (-20%)
Mutual labels:  excel
hadoopoffice
HadoopOffice - Analyze Office documents using the Hadoop ecosystem (Spark/Flink/Hive)
Stars: ✭ 56 (+12%)
Mutual labels:  excel
vue-loading
Loading bar for Vue.js apps using axios
Stars: ✭ 19 (-62%)
Mutual labels:  vue-component
Reports.JS
Stimulsoft Reports.JS is a reporting tool for Node.js and JavaScript applications.
Stars: ✭ 33 (-34%)
Mutual labels:  excel
bingexcel
处理excel与java之间转换的ORM框架
Stars: ✭ 23 (-54%)
Mutual labels:  excel
cap-table-tool
Cap Table and Exit Waterfall Tool, https://foresight.is/cap-table
Stars: ✭ 22 (-56%)
Mutual labels:  excel
vue-circle-choice
A circle color choice and navigation with Vue.js
Stars: ✭ 20 (-60%)
Mutual labels:  vue-component
cypress-upload-file-post-form
Solution for two Cypress testing use-cases I came across with: perform a direct http FORM request to the server containing a file and other parameters and upload a file into a form before submission
Stars: ✭ 59 (+18%)
Mutual labels:  excel
nodejs-nedb-excel
基于nodejs+webpack,以nosql轻量级嵌入式数据库nedb作为存储,页面渲染采用react+redux,样式框架为ant design,实现了excel表格上传导出以及可视化
Stars: ✭ 28 (-44%)
Mutual labels:  excel
OpenSpreadsheet
OpenSpreadsheet provides an easy-to-use wrapper around the OpenXML spreadsheet SAX API. It specializes in efficiently reading and writing between strongly typed collections and worksheets.
Stars: ✭ 24 (-52%)
Mutual labels:  excel
vue-admin-better
🚀🚀🚀vue admin,vue3 admin,vue3.0 admin,vue后台管理,vue-admin,vue3.0-admin,admin,vue-admin,vue-element-admin,ant-design,vue-admin-beautiful-pro,vab admin pro,vab admin plus,vue admin plus,vue admin pro
Stars: ✭ 12,962 (+25824%)
Mutual labels:  element
fastapi-csv
🏗️ Create APIs from CSV files within seconds, using fastapi
Stars: ✭ 46 (-8%)
Mutual labels:  excel
financial-forecast
Personal Financial Forecasting Model
Stars: ✭ 24 (-52%)
Mutual labels:  excel
ExcelExport
Classes to generate Excel/CSV Report in ASP.NET Core
Stars: ✭ 39 (-22%)
Mutual labels:  excel
clipboard-parser
剪贴板解析器,支持解析@RequestParam/@ApiModelProperty接口定义代码、Word、Excel以及其他表格类数据
Stars: ✭ 15 (-70%)
Mutual labels:  excel
VisualTAF
ExlJS - Super easy to use, Excel and JS driven tool, encapsulating best practices in test automation development.
Stars: ✭ 21 (-58%)
Mutual labels:  excel

vue-ele-import | 超简单、好用的 element-ui Excel 导入组件

MIT Licence npm download

介绍

vue-ele-import 利用 element ui 组件库完成的 Excel 导入数据组件, 主要特点如下:

  • 简单:仅需一行 html 代码
  • 直观:分步骤进行、错误表格显示
  • 强大:数据校检、数据转化一步完成

演示图

安装

npm install vue-ele-import --save

使用

// 全局引入
import EleImport from 'vue-ele-import'
Vue.component(EleImport.name, EleImport)
// 局部引入
import EleImport from 'vue-ele-import'
export default {
  components: {
    EleImport
  }
}

示例

点我看在线示例

<template>
  <div>
    <ele-import
      :fields="fields"
      :filepath="filepath"
      :append="append"
      :formatter="formatter"
      :requestFn="requestFn"
      :rules="rules"
      :tips="tips"
      :title="title"
      :visible.sync="visible"
      @close="handleCloseImport"
      @finish="handleFinishImport"
    />
    <el-button @click="handleOpen" type="primary">点我打开</el-button>
  </div>
</template>

<script>
  export default {
    name: 'App',
    data() {
      return {
        // 弹窗的标题
        title: '导入人员',
        // 提示信息
        tips: ['名字必填', '年龄必填', '年龄请填写数字'],
        // 假如数据库中是`name`字段, 而Excel模板列是`名字`, 就需要写成 name: '名字'
        // ele-import 内部会抛弃非定义在fields里的列
        fields: {
          name: '名字',
          age: '年龄',
          city: '所在城市'
        },
        // formatter起到替换数据的作用
        formatter: {
          // 可以是对象, 在发送请求时, '深圳' 将被替换成 1, '广州' 被替换成 2
          city: {
            1: '深圳',
            2: '广州'
          },
          // 可以是函数, 在发送请求时, `age` 将加1, 例如 原数据是 19 -> 20
          age: function(value, row) {
            return value + 1
          }
        },
        // 附加数据, 在每条记录上都会加这两个字段和值
        append: {
          company: '腾讯',
          leader: '小马哥'
        },
        // 参数校检, 和 element-ui 中 form表单中传递的rules一样, 都是使用的 async-validator 库
        // https://element.eleme.cn/#/zh-CN/component/form#biao-dan-yan-zheng
        rules: {
          name: { type: 'string', required: true, message: '名字必填' },
          age: [
            { type: 'number', message: '年龄必须为数字' },
            { required: true, message: '年龄必须填写' }
          ]
        },
        // Excel模板下载地址
        // 注意, 只能是.xlsx的文件, .xls或者.cvs都会报错
        filepath:
          'https://raw.githubusercontent.com/dream2023/vue-ele-import/master/public/user.xlsx',
        // 控制弹窗, 和dialog的visible一样
        // https://element.eleme.cn/#/zh-CN/component/dialog
        visible: false
      }
    },
    methods: {
      // requestFn函数会被注入请求的数据
      // 需要返回一个Promise对象
      async requestFn(data) {
        // 演示代码
        // 1、如果没有针对ele-import做过接口约定, 可以采用如下形式:
        // try {
        //   const res = await axios.post('/user', data)
        //   return Promise.resolve()
        // } catch (error) {
        //   // error经过一系列转化, 转为
        //   const errorData = this.getErrorMessage(error)
        //   {0:{ age: '年龄为数字', city: '城市必填'}, 2:{ age: '年龄为数字'} } // 0 和 2 分别是行号
        //   return Promise.reject(errorData)
        // }
        // 2、如果针对ele-import做过接口约定, 当校检错误时, 后端返回的 error 就是上述错误形式, 则可直接
        // return axios.post('/user', data)
        // 总结: 无论如何总要返回一个Promise对象
      },
      handleCloseImport() {
        console.log('弹窗关闭了~')
      },
      handleFinishImport() {
        console.log('导入完毕了~')
      },
      handleOpen() {
        this.visible = true
      }
    },
    mounted() {}
  }
</script>

Props 参数

props: {
  // 文件路径
  filepath: {
    type: String,
    required: true
  },
  // 请求方法
  requestFn: {
    type: Function,
    required: true
  },
  // 字段
  fields: {
    type: Object,
    required: true
  },
  // 是否显示弹窗
  visible: {
    type: Boolean,
    required: true
  },
  // 弹窗标题
  title: {
    type: String,
    default: '批量导入'
  },
  // 提示信息,数组
  tips: Array,
  // 增加附加数据
  append: Object,
  // 验证规则
  rules: Object,
  // 格式化数据
  formatter: {
    type: Object
  },
  // 弹窗宽度
  dialogWidth: {
    type: String,
    default: '80%'
  }
}

参考链接

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].