Excel导入组件的封装以及使用页面点击弹出该弹框

封装的组件

html 复制代码
<template>
  <el-dialog
    width="500px"
    title="员工导入"
    :visible="showExcelDialog"
    @close="$emit('update:showExcelDialog', false)"
  >
    <el-row type="flex" justify="center">
      <div class="upload-excel">
        <input
          ref="excel-upload-input"
          class="excel-upload-input"
          type="file"
          accept=".xlsx, .xls"
        >
        <div class="drop">
          <i class="el-icon-upload" />
          <el-button type="text">下载导入模板</el-button>
          <span>将文件拖到此处或
            <el-button type="text">点击上传</el-button>
          </span>
        </div>
      </div>
    </el-row>
    <el-row type="flex" justify="end">
      <!-- update:props属性名,值 直接修改 .sync修饰符的属性值 -->
      <el-button size="mini" type="primary" @click="$emit('update:showExcelDialog', false)">取消</el-button>
    </el-row>
  </el-dialog>
</template>
<script>

export default {
  props: {
    showExcelDialog: {
      type: Boolean,
      default: false
    }
  },
  methods: {

  }
}
</script>

<style scoped lang="scss">
    .upload-excel {
      display: flex;
      justify-content: center;
      margin: 20px;
      width: 360px;
      height: 180px;
      align-items: center;
      color: #697086;
      .excel-upload-input {
        display: none;
        z-index: -9999;
      }
      .btn-upload,
      .drop {
        border: 1px dashed #dcdfe6;
        width: 100%;
        height: 100%;
        text-align: center;
        line-height: 160px;
        border-radius: 8px;
        display: flex;
        flex-direction: column;
        justify-content: center;
      }
      .drop {
        line-height: 40px;
        color: #bbb;
        i {
          font-size: 60px;
          display: block;
          color: #c0c4cc;
        }
      }
    }
</style>


在需要使用弹框页面

html

html 复制代码
 <el-button size="mini" @click="showExcelDialog = true">excel导入</el-button>
 <import-excel :show-excel-dialog.sync="showExcelDialog" />

css

javascript 复制代码
import ImportExcel from './components/import-excel.vue'
export default {
  components: {
    ImportExcel
  },
	data () {
	 return  {
	     showExcelDialog: false // 控制excel的弹层显示和隐藏
	 }
   }
 }
相关推荐
米芝鱼8 小时前
Unity读取Excel转换为二进制数据文件与自定义数据读写
游戏·unity·游戏引擎·excel·urp
用户298698530148 小时前
如何在 C# 中创建、读取和更新 Excel 文档
后端·c#·excel
艾上编程8 小时前
第一章——办公自动化之Excel批量合并工具:Python助力高效办公
开发语言·python·excel
MYX_30910 小时前
使用EXCEL进行数据清洗
excel
傻啦嘿哟11 小时前
Python高效实现Excel与TXT文本文件数据转换指南
开发语言·python·excel
綝~11 小时前
Excel导入MongoDB操作手册
数据库·excel
暗武逢天12 小时前
Java导出复杂Excel升级版(解决占位符遗留问题,通用工具类)
java·excel·easyexcel·模板导出·通用工具类
ohoy1 天前
EasyPoi 自定义数据处理
excel
ohoy1 天前
easypoi 自定义样式 学生-分数红绿颜色设置
excel
ranchor6661 天前
excel+pandas使用str.contains() 的典型例子
excel·pandas