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的弹层显示和隐藏
	 }
   }
 }
相关推荐
我是苏苏4 小时前
Excel基础:电子表格Excel的使用技巧合集
excel
bin91531 天前
【EXCEL数据处理】000017 案例 Match和Index函数。
excel
shandianchengzi1 天前
【记录】Excel|Excel 打印成 PDF 页数太多怎么办
pdf·excel
bin91531 天前
【EXCEL数据处理】000010 案列 EXCEL文本型和常规型转换。使用的软件是微软的Excel操作的。处理数据的目的是让数据更直观的显示出来,方便查看。
大数据·数据库·信息可视化·数据挖掘·数据分析·excel·数据可视化
一个散步者的梦2 天前
Excel常用函数
excel
bin91532 天前
【EXCEL数据处理】000009 案列 EXCEL单元格数字格式。文本型数字格式和常规型数字格式的区别
大数据·前端·数据库·信息可视化·数据分析·excel·数据可视化
Eiceblue3 天前
Python保留数据删除Excel单元格的函数和公式
开发语言·python·excel
bin91533 天前
【EXCEL数据处理】000014 案例 EXCEL分类汇总、定位和创建组。附多个操作案例。
信息可视化·数据挖掘·数据分析·excel·数据可视化·数据图表·excel 数据分析
育种数据分析之放飞自我3 天前
GWAS分析中显著位点如何注释基因:excel???
linux·算法·excel
PowerBI学谦3 天前
Python in Excel 正式发布!
开发语言·python·excel