|
@@ -1,8 +1,24 @@
|
|
|
<template>
|
|
|
<div class="addSheet-wrap">
|
|
|
- <div :class="['main',{'full-height':$route.path!=='/addAnalysisSheet'}]">
|
|
|
+ <div :class="['main',{'full-height':$route.path!=='/addAnalysisSheet'}]" v-loading="isLoading">
|
|
|
<div class="left-section">
|
|
|
- <Sheet ref="sheetRef" :option="sheetConfig"/>
|
|
|
+ <el-tabs
|
|
|
+ v-model="selectIndex"
|
|
|
+ type="card"
|
|
|
+ closable
|
|
|
+ @tab-remove="handleRemoveSheet"
|
|
|
+ @tab-click="switchSheetHandle"
|
|
|
+ >
|
|
|
+ <el-tab-pane
|
|
|
+ :key="item.name"
|
|
|
+ v-for="(item,index) in uploadSheetsList"
|
|
|
+ :label="item.name"
|
|
|
+ :name="String(index)"
|
|
|
+ />
|
|
|
+ </el-tabs>
|
|
|
+ <div class="sheet-wrapper" v-if="sheetConfig.data">
|
|
|
+ <Sheet ref="sheetRef" :option="sheetConfig"/>
|
|
|
+ </div>
|
|
|
</div>
|
|
|
|
|
|
<rightSection v-if="$route.path!=='/addAnalysisSheet'"/>
|
|
@@ -22,8 +38,16 @@ import bottomSection from './components/uploadBottomSection.vue'
|
|
|
import rightSection from './components/rightSection.vue';
|
|
|
export default {
|
|
|
components: { Sheet,bottomSection,rightSection },
|
|
|
+ computed: {
|
|
|
+ files() {
|
|
|
+ return this.$store.state.sheet.files;
|
|
|
+ }
|
|
|
+ },
|
|
|
data() {
|
|
|
return {
|
|
|
+ isLoading: false,
|
|
|
+ uploadSheetsList: [],
|
|
|
+ selectIndex: '0',
|
|
|
sheetConfig: {
|
|
|
showsheetbar: true,
|
|
|
// data: []
|
|
@@ -33,7 +57,17 @@ export default {
|
|
|
methods: {
|
|
|
|
|
|
backHandle() {
|
|
|
- window.close();
|
|
|
+ this.$router.go(-1);
|
|
|
+ },
|
|
|
+
|
|
|
+ loadDataSync(sheets) {
|
|
|
+
|
|
|
+ // let data =
|
|
|
+ },
|
|
|
+
|
|
|
+ /* 切换表格 */
|
|
|
+ switchSheetHandle() {
|
|
|
+
|
|
|
},
|
|
|
|
|
|
/* 获取分类 */
|
|
@@ -45,6 +79,47 @@ export default {
|
|
|
})
|
|
|
},
|
|
|
|
|
|
+ handelTranslateData(e) {
|
|
|
+ LuckyExcel.transformExcelToLucky(e, (exportJson, luckysheetfile) =>{
|
|
|
+
|
|
|
+ if(exportJson.sheets==null || exportJson.sheets.length==0){
|
|
|
+ this.$message.warning('解析文件失败')
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ console.log(exportJson,luckysheetfile)
|
|
|
+
|
|
|
+ window.luckysheet.destroy()
|
|
|
+
|
|
|
+ // this.loadDataSync(exportJson.sheets);
|
|
|
+
|
|
|
+ this.sheetConfig.data = exportJson.sheets.map(_ => ({
|
|
|
+ index: _.index, //工作表索引
|
|
|
+ order: _.order, //工作表的下标
|
|
|
+ name: _.name,
|
|
|
+ calcChain: _.calcChain,
|
|
|
+ celldata: _.celldata,
|
|
|
+ config: _.config,
|
|
|
+ }));
|
|
|
+
|
|
|
+ this.isLoading = false
|
|
|
+ // this.$refs.sheetRef.init();
|
|
|
+
|
|
|
+ console.log(this.sheetConfig)
|
|
|
+ });
|
|
|
+
|
|
|
+ },
|
|
|
+
|
|
|
+ /* 移除表格 */
|
|
|
+ handleRemoveSheet(name) {
|
|
|
+ console.log(name)
|
|
|
+ let index = this.uploadSheetsList.findIndex(_ => _.name === name)
|
|
|
+ this.uploadSheetsList.splice(index,1)
|
|
|
+
|
|
|
+ if(this.uploadSheetsList.length === 1) {
|
|
|
+ this.backHandle()
|
|
|
+ }
|
|
|
+ },
|
|
|
+
|
|
|
|
|
|
/* 保存表格 */
|
|
|
saveSheetHandle: _.debounce(async function() {
|
|
@@ -92,6 +167,12 @@ export default {
|
|
|
},
|
|
|
mounted() {
|
|
|
this.getClassify();
|
|
|
+ if(this.files) {
|
|
|
+ this.uploadSheetsList = Object.values(this.files);
|
|
|
+ this.isLoading = true;
|
|
|
+ this.handelTranslateData(this.uploadSheetsList[Number(this.selectIndex)])
|
|
|
+ this.$store.commit('sheet/SET_UPLOADFIlES',null)
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
</script>
|
|
@@ -124,13 +205,27 @@ export default {
|
|
|
position: relative;
|
|
|
min-height: 700px;
|
|
|
.left-section {
|
|
|
- position:relative;
|
|
|
flex:1;
|
|
|
- margin-right: 20px;
|
|
|
+ .sheet-wrapper {
|
|
|
+ position: relative;
|
|
|
+ min-height: 700px;
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
&.full-height {
|
|
|
min-height: calc(100vh - 120px);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+</style>
|
|
|
+<style lang="scss">
|
|
|
+.addSheet-wrap {
|
|
|
+ .el-tabs__nav {
|
|
|
+ background: #fff;
|
|
|
+ }
|
|
|
+ .el-tabs__header {
|
|
|
+ margin-bottom: 0;
|
|
|
+ // border-bottom: none;
|
|
|
+ }
|
|
|
+}
|
|
|
</style>
|