vue 纯前端导入Excel
1.vue-cli脚手架搭好框架
2.npm install xlsx --save
3.代码
<template>
<div>
<el-row class="handle-box" :gutter="24">
<el-col :span="17" class="head">
<el-button @click="handleCreate">新建</el-button>
<el-button @click="deleteMulti">删除</el-button>
<el-button @click="exportExcel">导出</el-button>
<el-button @click="releaseMulti" disabled>发布</el-button>
<input type="file" @change="importFile(this)" id="imFile" style="display: none"
accept="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet, application/vnd.ms-excel" />
<el-button @click="uploadFile">从Excle中导入</el-button>
<el-button @click="standardImport">从标准模板中导入</el-button>
</el-col>
<el-col :span="7">
<el-input v-model="searchValue.keyword" placeholder="请输入提资编号或名称" class="handle-input" clearable
disabled>
<el-button slot="append" icon="el-icon-search" @click="search" disabled></el-button>
</el-input>
</el-col>
</el-row>
<el-row>
<el-col :span="24">
<VmBaseTable ref="material_plan_table" :setTableHigh="true" :data="dataTable" :columns="dataColumns"
@page-change="pageChange" showCheck :tableHigh="tableHigh" :page_sizes="[5,10,15,20,25]">
</VmBaseTable>
<batchAddMaterial ref="batch-add-material" @search="search" @postData="getPostData" :isDisable="true">
</batchAddMaterial>
<StandardImport ref="standard-template-material" @importStandardMethod="importStandardMethod">
</StandardImport>
<batchLookMaterial ref="batch-look-material"></batchLookMaterial>
<batchEditMaterial ref="batch-edit-material" @search="search" @editorData="getEditorData">
</batchEditMaterial>
</el-col>
</el-row>
<div style="text-align:right;margin-top:10px" v-if="isModelHeight">
<el-button @click="deleteTemplate">取 消</el-button>
<el-button type="primary" @click="submit">保 存</el-button>
</div>
</div>
</template>
<script>
/*eslint-disable */
//引入xlsx
var XLSX = require('xlsx')
import VmBaseTable from "../../../../components/common/base/base-table"
import batchAddMaterial from "./batch-add-put-material"
import StandardImport from "./standard-template-material-import"
import batchLookMaterial from "./batch-look-put-material"
import batchEditMaterial from "./edit-put-material"
export default {
name: "Tizicehua",
components: {
VmBaseTable,
batchAddMaterial,
StandardImport,
batchLookMaterial,
batchEditMaterial
},
props: {
project_id: {
type: String,
default: ""
},
project_phase: {
type: String,
default: ""
},
isModelHeight: {
type: Boolean,
default: false
}
},
created() {
if (!this.isModelHeight) {
let _this =