Browse Source

Merge branch 'luckysheet' of http://120.46.222.128:10021/elink-star/epmet-work-pc into luckysheet_xiaowang

luckysheet-xiaowang-Intelligen
是小王呀\24601 7 months ago
parent
commit
1a38acaa69
  1. 15
      src/views/modules/base/smartExcel/cpts/excel-template-confirmation.vue
  2. 26
      src/views/modules/base/smartExcel/cpts/excel-view.vue

15
src/views/modules/base/smartExcel/cpts/excel-template-confirmation.vue

@ -2,7 +2,7 @@
<!-- 确认模板 --> <!-- 确认模板 -->
<div class=''> <div class=''>
<el-dialog title="模板确认" :visible.sync="showTemplate" width="50%" :close-on-click-modal="false"> <el-dialog title="模板确认" :visible.sync="showTemplate" width="50%" :close-on-click-modal="false">
<div id="luckysheet"></div> <div id="luckysheet1" v-if="showTemplate"></div>
<span slot="footer" class="dialog-footer"> <span slot="footer" class="dialog-footer">
<el-button @click="handleCancel"> </el-button> <el-button @click="handleCancel"> </el-button>
<el-button type="primary" @click="handleConfirm"> </el-button> <el-button type="primary" @click="handleConfirm"> </el-button>
@ -53,6 +53,7 @@ export default {
that.exportJson = exportJson that.exportJson = exportJson
if (exportJson.sheets == null || exportJson.sheets.length == 0) return alert('读取excel文件内容失败, 目前不支持XLS文件!'); if (exportJson.sheets == null || exportJson.sheets.length == 0) return alert('读取excel文件内容失败, 目前不支持XLS文件!');
window.luckysheet.destroy(); window.luckysheet.destroy();
options.container = 'luckysheet1'
window.luckysheet.create({ window.luckysheet.create({
...options, ...options,
data: exportJson.sheets, data: exportJson.sheets,
@ -71,16 +72,6 @@ export default {
mounted() { mounted() {
console.log(this.fileUrl, 'fileUrl==='); console.log(this.fileUrl, 'fileUrl===');
this.urlToFile('http://localhost:9001/epmet-work-pc/test1.xlsx',this.fileName) this.urlToFile('http://localhost:9001/epmet-work-pc/test1.xlsx',this.fileName)
this.$nextTick(() => {
window.luckysheet.destroy();
options.title = '模板确认'
window.luckysheet.create({
...options,
hook: {
cellEditBefore: this.handleCellEditBefore,
},
});
})
}, },
props: { props: {
@ -104,7 +95,7 @@ export default {
</script> </script>
<style lang='scss' scoped> <style lang='scss' scoped>
#luckysheet { #luckysheet1 {
height: 500px; height: 500px;
} }
</style> </style>

26
src/views/modules/base/smartExcel/cpts/excel-view.vue

@ -59,6 +59,7 @@ export default {
], ],
menuActive: 0, menuActive: 0,
socket: null, socket: null,
currentTable:''
}; };
}, },
props: { props: {
@ -95,6 +96,7 @@ export default {
const { id } = this.$store.state.user; const { id } = this.$store.state.user;
options.gridKey = this.workbookId; options.gridKey = this.workbookId;
options.allowUpdate = true; options.allowUpdate = true;
options.container = 'luckysheet'
options.loadUrl = `http://219.146.91.110:30801/api/actual/base/luckySheet/workbook/load?workbookId=${this.workbookId}` options.loadUrl = `http://219.146.91.110:30801/api/actual/base/luckySheet/workbook/load?workbookId=${this.workbookId}`
options.updateUrl = `ws://219.146.91.110:30801/api/actual/base/ws/luckysheet/${this.workbookId}/${id}` options.updateUrl = `ws://219.146.91.110:30801/api/actual/base/ws/luckysheet/${this.workbookId}/${id}`
options.loadSheetUrl = `http://219.146.91.110:30801/api/actual/base/luckySheet/workbook/loadSheets?workbookId=${this.workbookId}` options.loadSheetUrl = `http://219.146.91.110:30801/api/actual/base/luckySheet/workbook/loadSheets?workbookId=${this.workbookId}`
@ -155,15 +157,23 @@ export default {
}, },
getAllTables() { getAllTables() {
let list = luckysheet.getAllSheets() let list = luckysheet.getAllSheets()
let currentTable = list.filter(item => item.status == '1') this.currentTable = list.filter(item => item.status == '1')
const findFirstAllNullIndex = (arr) => {
return arr.findIndex(subArray => Array.isArray(subArray) && subArray.every(item => item === null)); const findLastNonNullIndex = (arr) => {
for (let i = arr.length - 1; i >= 0; i--) {
const subArray = arr[i];
// null
if (Array.isArray(subArray) && subArray.some(item => item !== null && item.v && item.v !== null&& item.v !== '')) {
return i; //
}
}
return -1; // -1
}; };
this.sheetR = findFirstAllNullIndex(currentTable[0].data) this.sheetR = findLastNonNullIndex(this.currentTable[0].data)
console.log(this.sheetR);
if(this.sheetR != -1){ if(this.sheetR != -1){
luckysheet.insertRow(this.currentTable[0].data.length,5)
this.updataSheet() this.updataSheet()
}else{
luckysheet.insertRow(currentTable[0].data.length,5)
} }
}, },
updataSheet() { updataSheet() {
@ -208,9 +218,9 @@ export default {
} }
] ]
arr.forEach((item, index) => { arr.forEach((item, index) => {
luckysheet.insertRow(this.currentTable[0].data.length,1)
for (let k in item) { for (let k in item) {
// index +1 + this.sheetR() luckysheet.setCellValue(index+this.sheetR + 1, k - 1, item[k])
luckysheet.setCellValue(index+this.sheetR, k - 1, item[k])
} }
}) })
}, },

Loading…
Cancel
Save