|
@@ -1,14 +1,31 @@
|
|
<template>
|
|
<template>
|
|
<div>
|
|
<div>
|
|
- <el-upload
|
|
|
|
- class="upload-demo"
|
|
|
|
- action="https://jsonplaceholder.typicode.com/posts/"
|
|
|
|
- :on-change="handleChange"
|
|
|
|
- >
|
|
|
|
- <el-button size="small" type="primary">点击上传</el-button>
|
|
|
|
- </el-upload>
|
|
|
|
|
|
+ <div class="top">
|
|
|
|
+ <el-upload
|
|
|
|
+ class="upload-demo"
|
|
|
|
+ action="https://jsonplaceholder.typicode.com/posts/"
|
|
|
|
+ :on-change="handleChange"
|
|
|
|
+ >
|
|
|
|
+ <el-button size="small" type="primary">点击上传</el-button>
|
|
|
|
+ </el-upload>
|
|
|
|
|
|
- <el-table :data="tableData" style="width:100%">
|
|
|
|
|
|
+ <el-select v-model="value" placeholder="请选择">
|
|
|
|
+ <el-option
|
|
|
|
+ v-for="item in tableList"
|
|
|
|
+ :key="item.value"
|
|
|
|
+ :label="item.label"
|
|
|
|
+ :value="item.value"
|
|
|
|
+ >
|
|
|
|
+ </el-option>
|
|
|
|
+ </el-select>
|
|
|
|
+ <el-cascader
|
|
|
|
+ placeholder="试试搜索:指南"
|
|
|
|
+ :options="options"
|
|
|
|
+ :props="{ multiple: true }"
|
|
|
|
+ filterable
|
|
|
|
+ ></el-cascader>
|
|
|
|
+ </div>
|
|
|
|
+ <el-table :data="tableData" style="width: 100%">
|
|
<el-table-column
|
|
<el-table-column
|
|
v-for="i in arr"
|
|
v-for="i in arr"
|
|
:key="i"
|
|
:key="i"
|
|
@@ -27,6 +44,31 @@ export default {
|
|
return {
|
|
return {
|
|
tableData: [{}],
|
|
tableData: [{}],
|
|
arr: [],
|
|
arr: [],
|
|
|
|
+ value:'',
|
|
|
|
+ tableList:[
|
|
|
|
+ {
|
|
|
|
+ value: "table",
|
|
|
|
+ label: "table1",
|
|
|
|
+ },
|
|
|
|
+ {
|
|
|
|
+ value: "table2",
|
|
|
|
+ label: "table2",
|
|
|
|
+ },
|
|
|
|
+ ],
|
|
|
|
+ options: [
|
|
|
|
+ {
|
|
|
|
+ value: "table",
|
|
|
|
+ label: "ID",
|
|
|
|
+ },
|
|
|
|
+ {
|
|
|
|
+ value: "table1",
|
|
|
|
+ label: "Name",
|
|
|
|
+ },
|
|
|
|
+ {
|
|
|
|
+ value: "table2",
|
|
|
|
+ label: "table2",
|
|
|
|
+ },
|
|
|
|
+ ],
|
|
};
|
|
};
|
|
},
|
|
},
|
|
mounted() {
|
|
mounted() {
|
|
@@ -45,16 +87,18 @@ export default {
|
|
let sheet = Object.keys(workbook.Sheets)[0];
|
|
let sheet = Object.keys(workbook.Sheets)[0];
|
|
const json = XLSX.utils.sheet_to_json(workbook.Sheets[sheet]); //获得以第一列为键名的sheet数组对象
|
|
const json = XLSX.utils.sheet_to_json(workbook.Sheets[sheet]); //获得以第一列为键名的sheet数组对象
|
|
console.log(json);
|
|
console.log(json);
|
|
- var arr=[];
|
|
|
|
|
|
+ var arr = [];
|
|
for (let v in json) {
|
|
for (let v in json) {
|
|
- if(v>100){break;}
|
|
|
|
|
|
+ if (v > 100) {
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
for (let k in Object.keys(json[v])) {
|
|
for (let k in Object.keys(json[v])) {
|
|
if (arr.indexOf(Object.keys(json[v])[k]) == -1) {
|
|
if (arr.indexOf(Object.keys(json[v])[k]) == -1) {
|
|
arr.push(Object.keys(json[v])[k]);
|
|
arr.push(Object.keys(json[v])[k]);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- this.arr = arr
|
|
|
|
|
|
+ this.arr = arr;
|
|
this.$nextTick(() => {
|
|
this.$nextTick(() => {
|
|
this.tableData = json;
|
|
this.tableData = json;
|
|
});
|
|
});
|
|
@@ -66,4 +110,13 @@ export default {
|
|
},
|
|
},
|
|
},
|
|
},
|
|
};
|
|
};
|
|
-</script>
|
|
|
|
|
|
+</script>
|
|
|
|
+<style lang="scss" scoped>
|
|
|
|
+.top {
|
|
|
|
+ width: 80%;
|
|
|
|
+ margin-top: 10px;
|
|
|
|
+ display: flex;
|
|
|
|
+ justify-content: space-around;
|
|
|
|
+ overflow: hidden;
|
|
|
|
+}
|
|
|
|
+</style>
|