|
@@ -1,13 +1,13 @@
|
|
|
<template>
|
|
|
<div class="addSheet-wrap">
|
|
|
- <div :class="['main',{'full-height':$route.path!=='/addAnalysisSheet'}]" v-loading="isLoading">
|
|
|
+ <div :class="['main',{'full-height':$route.path!=='/addAnalysisSheet'}]">
|
|
|
<div class="left-section">
|
|
|
<el-tabs
|
|
|
v-model="selectIndex"
|
|
|
type="card"
|
|
|
closable
|
|
|
@tab-remove="handleRemoveSheet"
|
|
|
- @tab-click="switchSheetHandle"
|
|
|
+ @tab-click="handleSwitchSheet"
|
|
|
>
|
|
|
<el-tab-pane
|
|
|
:key="item.name"
|
|
@@ -16,16 +16,19 @@
|
|
|
:name="String(index)"
|
|
|
/>
|
|
|
</el-tabs>
|
|
|
- <div class="sheet-wrapper" v-if="sheetConfig.data">
|
|
|
- <Sheet ref="sheetRef" :option="sheetConfig"/>
|
|
|
+ <div class="sheet-wrapper" v-loading="isLoading">
|
|
|
+ <Sheet ref="sheetRef" :option="sheetConfig" v-if="sheetConfig.data"/>
|
|
|
</div>
|
|
|
+
|
|
|
+ <!-- <tableNoData text="暂无数据" v-else/> -->
|
|
|
</div>
|
|
|
|
|
|
<rightSection v-if="$route.path!=='/addAnalysisSheet'"/>
|
|
|
</div>
|
|
|
|
|
|
+
|
|
|
<!-- 上传文件 -->
|
|
|
- <bottomSection v-if="$route.path==='/addAnalysisSheet'"/>
|
|
|
+ <bottomSection v-if="$route.path==='/addAnalysisSheet'" :sheetList="sheetConfig.data||[]"/>
|
|
|
|
|
|
</div>
|
|
|
</template>
|
|
@@ -34,7 +37,7 @@
|
|
|
import * as sheetInterface from '@/api/modules/sheetApi.js';
|
|
|
import Sheet from '../components/SheetExcel.vue';
|
|
|
import { getSheetImage } from '../common/option';
|
|
|
-import bottomSection from './components/uploadBottomSection.vue'
|
|
|
+import bottomSection from './components/bottomSection.vue'
|
|
|
import rightSection from './components/rightSection.vue';
|
|
|
export default {
|
|
|
components: { Sheet,bottomSection,rightSection },
|
|
@@ -47,10 +50,15 @@ export default {
|
|
|
return {
|
|
|
isLoading: false,
|
|
|
uploadSheetsList: [],
|
|
|
+ pageSize: 2000,
|
|
|
+ currentPage: 0,
|
|
|
+ maxPage:0,
|
|
|
+
|
|
|
selectIndex: '0',
|
|
|
sheetConfig: {
|
|
|
showsheetbar: true,
|
|
|
- // data: []
|
|
|
+ // enablePage: true
|
|
|
+ data: null
|
|
|
}
|
|
|
}
|
|
|
},
|
|
@@ -60,14 +68,10 @@ export default {
|
|
|
this.$router.go(-1);
|
|
|
},
|
|
|
|
|
|
- loadDataSync(sheets) {
|
|
|
-
|
|
|
- // let data =
|
|
|
- },
|
|
|
-
|
|
|
/* 切换表格 */
|
|
|
- switchSheetHandle() {
|
|
|
-
|
|
|
+ handleSwitchSheet() {
|
|
|
+ this.sheetConfig.data = null;
|
|
|
+ this.handelTranslateData();
|
|
|
},
|
|
|
|
|
|
/* 获取分类 */
|
|
@@ -79,45 +83,81 @@ 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)
|
|
|
+ loadDataSync() {
|
|
|
+ let len = this.sheetConfig.data.length;
|
|
|
+ for(let i =0;i<len;i++) {
|
|
|
+ if(this.allSheetData[i].celldata[this.currentPage*this.pageSize]) {
|
|
|
+ this.sheetConfig.data[i].celldata = this.sheetConfig.data[i].celldata.concat(this.allSheetData[i].celldata.slice(this.currentPage*this.pageSize, (this.currentPage+1)*this.pageSize))
|
|
|
+ console.log(this.sheetConfig.data[i].celldata)
|
|
|
+ this.$refs.sheetRef.init()
|
|
|
+ }
|
|
|
+ continue
|
|
|
+
|
|
|
+ }
|
|
|
|
|
|
- window.luckysheet.destroy()
|
|
|
+ if (this.currentPage<this.maxPage) {
|
|
|
+ this.currentPage++
|
|
|
+ setTimeout(this.loadDataSync(), 1000); // 1秒后加载下一页数据
|
|
|
+ }else {
|
|
|
+ this.isLoadOver = true;
|
|
|
+ }
|
|
|
+ },
|
|
|
+
|
|
|
+ /* 分割数据 */
|
|
|
+ splitSheetData(sheets) {
|
|
|
+ this.allSheetData = sheets.map(_ => ({
|
|
|
+ index: _.index, //工作表索引
|
|
|
+ order: _.order, //工作表的下标
|
|
|
+ name: _.name,
|
|
|
+ calcChain: _.calcChain,
|
|
|
+ celldata: _.celldata,
|
|
|
+ config: _.config
|
|
|
+ }));
|
|
|
|
|
|
- // this.loadDataSync(exportJson.sheets);
|
|
|
+ this.maxPage = Math.max(...sheets.map(_ => Math.ceil(_.celldata.length / this.pageSize)))
|
|
|
|
|
|
- this.sheetConfig.data = exportJson.sheets.map(_ => ({
|
|
|
- index: _.index, //工作表索引
|
|
|
- order: _.order, //工作表的下标
|
|
|
- name: _.name,
|
|
|
- calcChain: _.calcChain,
|
|
|
- celldata: _.celldata,
|
|
|
- config: _.config,
|
|
|
- }));
|
|
|
+ this.sheetConfig.data = this.allSheetData.map(_ => ({
|
|
|
+ index: _.index, //工作表索引
|
|
|
+ order: _.order, //工作表的下标
|
|
|
+ name: _.name,
|
|
|
+ calcChain: _.calcChain,
|
|
|
+ config: _.config,
|
|
|
+ celldata: _.celldata
|
|
|
+ }));
|
|
|
+
|
|
|
+ // this.loadDataSync();
|
|
|
+ // console.log(this.sheetConfig.data)
|
|
|
+ this.isLoading = false;
|
|
|
+ },
|
|
|
|
|
|
- this.isLoading = false
|
|
|
- // this.$refs.sheetRef.init();
|
|
|
+ handelTranslateData() {
|
|
|
+ this.isLoading = true;
|
|
|
+ LuckyExcel.transformExcelToLucky(this.uploadSheetsList[Number(this.selectIndex)], (exportJson, luckysheetfile) =>{
|
|
|
+
|
|
|
+ if(exportJson.sheets==null || exportJson.sheets.length==0){
|
|
|
+ this.$message.warning('解析文件失败')
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ this.splitSheetData(exportJson.sheets);
|
|
|
|
|
|
- console.log(this.sheetConfig)
|
|
|
});
|
|
|
|
|
|
},
|
|
|
|
|
|
/* 移除表格 */
|
|
|
- handleRemoveSheet(name) {
|
|
|
- console.log(name)
|
|
|
- let index = this.uploadSheetsList.findIndex(_ => _.name === name)
|
|
|
- this.uploadSheetsList.splice(index,1)
|
|
|
-
|
|
|
+ handleRemoveSheet(index) {
|
|
|
if(this.uploadSheetsList.length === 1) {
|
|
|
this.backHandle()
|
|
|
+ return
|
|
|
}
|
|
|
+
|
|
|
+ this.uploadSheetsList.splice(Number(index),1)
|
|
|
+ if(this.selectIndex === index) {
|
|
|
+ this.selectIndex = '0';
|
|
|
+ this.handleSwitchSheet()
|
|
|
+ }
|
|
|
+
|
|
|
},
|
|
|
|
|
|
|
|
@@ -169,8 +209,7 @@ export default {
|
|
|
this.getClassify();
|
|
|
if(this.files) {
|
|
|
this.uploadSheetsList = Object.values(this.files);
|
|
|
- this.isLoading = true;
|
|
|
- this.handelTranslateData(this.uploadSheetsList[Number(this.selectIndex)])
|
|
|
+ this.handelTranslateData()
|
|
|
this.$store.commit('sheet/SET_UPLOADFIlES',null)
|
|
|
}
|
|
|
}
|
|
@@ -208,6 +247,7 @@ export default {
|
|
|
flex:1;
|
|
|
.sheet-wrapper {
|
|
|
position: relative;
|
|
|
+ background: #fff;
|
|
|
min-height: 700px;
|
|
|
}
|
|
|
|