Compare commits

1 Commits
master ... dev

Author SHA1 Message Date
f4cf0ab701 temp: table-preview 2022-05-10 14:03:52 +08:00
2 changed files with 20 additions and 6 deletions

View File

@@ -1,7 +1,7 @@
<template> <template>
<div id="app"> <div id="app">
<el-row> <el-row>
<el-col :span="12"><full-table /></el-col> <el-col :span="12"><full-table/></el-col>
<el-col :span="12"></el-col> <el-col :span="12"></el-col>
</el-row> </el-row>
</div> </div>

View File

@@ -34,6 +34,9 @@
></el-option> ></el-option>
</el-select> </el-select>
<el-button @click="showPreview">选择解析区域</el-button> <el-button @click="showPreview">选择解析区域</el-button>
<el-dialog title="预览表格" width="80%" :visible.sync="previewVisible">
</el-dialog>
</el-main> </el-main>
</el-container> </el-container>
</template> </template>
@@ -48,10 +51,11 @@ export default {
loadFileName: "", loadFileName: "",
table: null, table: null,
currentSheet: "", currentSheet: "",
previewVisible: false,
}; };
}, },
computed: { computed: {
isImportable: function(){ isImportable: function () {
return this.loadFileName === null; return this.loadFileName === null;
}, },
isNotEditable: function () { isNotEditable: function () {
@@ -66,6 +70,7 @@ export default {
}, },
}, },
methods: { methods: {
// Load the excel file into temporary buffer in explorer
loadFile: function (file) { loadFile: function (file) {
this.loadFileName = file.name; this.loadFileName = file.name;
let fRead = new FileReader(); let fRead = new FileReader();
@@ -75,6 +80,7 @@ export default {
}; };
fRead.readAsBinaryString(file.raw); fRead.readAsBinaryString(file.raw);
}, },
// Load the table from buffer to this.table
importTable: function () { importTable: function () {
localforage.getItem("LoadedTable").then((res) => { localforage.getItem("LoadedTable").then((res) => {
if (res !== null) { if (res !== null) {
@@ -83,13 +89,21 @@ export default {
}); });
console.log("importing table"); console.log("importing table");
}, },
showPreview: function() { //
let toShow = this.table.sheets[this.currentSheet]; showPreview: function () {
XLSX.utils.sheet_to_formulae() var tabName = this.table.SheetNames[this.currentSheet]
} var sheetByRow = XLSX.utils.sheet_to_json(this.table.Sheets[tabName]);
this.previewVisible = true;
},
}, },
}; };
</script> </script>
<style scoped> <style scoped>
td {
min-width: 10px;
border: 1px;
border-block-color: #cccccc;
}
</style> </style>