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的弹层显示和隐藏
	 }
   }
 }
相关推荐
沉到海底去吧Go14 小时前
【身份证识别表格】批量识别身份证扫描件或照片保存为Excel表格,怎么大批量将身份证图片转为excel表格?基于WPF和腾讯OCR的识别方案
ocr·wpf·excel·身份证识别表格·批量扫描件身份证转表格·图片识别表格·图片识别excel表格
a GISer doctor14 小时前
EXCEL中嵌入其他表格等文件
excel
yngsqq18 小时前
CAD属性图框值与Excel联动(CAD块属性导出Excel、excel更新CAD块属性)——CAD c#二次开发
excel
帆张芳显18 小时前
前端EXCEL插件,智表ZCELL产品V3.0 版本发布,底层采用canvas全部重构,功能大幅扩展,性能极致提升,满足千万级单元格加载
前端·重构·excel·jquery·插件·智表
課代表19 小时前
Excel VBA 词频统计宏
ui·excel··vba·模块·字典
LAM LAB1 天前
【WPS】怎么解决“word的复制表格”粘贴到“excel的单元格”变多行单元格的问题
word·excel·wps
Eiceblue1 天前
如何通过C# 获取Excel单元格的数据类型
开发语言·visualstudio·c#·excel
基多里的猫1 天前
Excel提取单元格特定符号左右两边内容
excel·excel提取单元格字符内容·excel使用小技巧
消失在人海中1 天前
把Excel数据文件导入到Oracle数据库
数据库·oracle·excel
winfredzhang1 天前
使用Python 打造多格式文件预览工具 — 图、PDF、Word、Excel 一站式查看
python·pdf·word·excel·照片·查看,zip,复制