Browse Source

先顺序找到第一条数据为空的做数据填充

luckysheet-xiaowang-Intelligen
mk 7 months ago
parent
commit
fdeb135f7f
  1. 171
      src/views/modules/base/smartExcel/cpts/excel-view.vue

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

@ -1,26 +1,26 @@
<template> <template>
<!-- :style="{ height: tableHeight }" --> <!-- :style="{ height: tableHeight }" -->
<div class='flex el-card'> <div class='flex el-card'>
<div class="left_menu flex flex-y"> <div class="left_menu flex flex-y">
<el-button type="text" round @click="handelClickBack" icon="el-icon-back">返回</el-button> <el-button type="text" round @click="handelClickBack" icon="el-icon-back">返回</el-button>
<div :class="{ 'menu_item': true, 'active': menuActive === index }" v-for="(item, index) in menuList" <div :class="{ 'menu_item': true, 'active': menuActive === index }" v-for="(item, index) in menuList" :key="index"
:key="index" @click="handleClickMenu(index)"> @click="handleClickMenu(index)">
<span>{{ item.name }}</span> <span>{{ item.name }}</span>
<i class="el-icon-arrow-right"></i> <i class="el-icon-arrow-right"></i>
</div>
</div> </div>
<div class="flex flex-y flex1 luckysheet-wrap"> </div>
<div class="top_btn flex flex-end"> <div class="flex flex-y flex1 luckysheet-wrap">
<div> <div class="top_btn flex flex-end">
<el-button type="warning" @click="getAllTables"> 自动检测</el-button> <div>
</div> <el-button type="warning" @click="getAllTables"> 自动检测</el-button>
<div> </div>
<el-button type="danger"> 驳回重提</el-button> <div>
<el-button type="primary"> 审核存档</el-button> <el-button type="danger"> 驳回重提</el-button>
</div> <el-button type="primary"> 审核存档</el-button>
</div> </div>
<div id="luckysheet"></div>
</div> </div>
<div id="luckysheet"></div>
</div>
</div> </div>
</template> </template>
@ -73,26 +73,26 @@ export default {
}, },
watch: {}, watch: {},
mounted() { mounted() {
this.$nextTick(()=>{ this.$nextTick(() => {
this.loadWorkBook() this.loadWorkBook()
}) })
}, },
methods: { methods: {
loadWorkBook() { loadWorkBook() {
window.luckysheet.destroy(); window.luckysheet.destroy();
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.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}`
window.luckysheet.create({ window.luckysheet.create({
...options, ...options,
hook: { hook: {
cellEditBefore: this.handleCellEditBefore, cellEditBefore: this.handleCellEditBefore,
sheetCreateAfter: this.handleSheetCreateAfter, sheetCreateAfter: this.handleSheetCreateAfter,
}, },
}); });
}, },
handleSheetCreateAfter(e) { handleSheetCreateAfter(e) {
console.log('setsheet', e); console.log('setsheet', e);
@ -141,60 +141,66 @@ export default {
handelClickBack() { handelClickBack() {
this.$emit('close') this.$emit('close')
}, },
getAllTables(){ getAllTables() {
console.log(luckysheet.getAllSheets()); let list = luckysheet.getAllSheets()
let currentTable = luckysheet.getAllSheets().filter(item=>item.status === '1') let currentTable = list.filter(item => item.status == '1')
const findFirstAllNullIndex = (arr) => {
return arr.findIndex(subArray => Array.isArray(subArray) && subArray.every(item => item === null));
};
this.sheetR = findFirstAllNullIndex(currentTable[0].data)
if(this.sheetR != -1){
this.updataSheet()
}else{
luckysheet.insertRow(currentTable[0].data.length,5)
}
},
updataSheet() {
let arr = [ let arr = [
{ {
1:'张三1', 1: '张三1',
2:'证件类型1', 2: '证件类型1',
3:'1234', 3: '1234',
4:'456', 4: '456',
5:'国籍', 5: '国籍',
6:'性别', 6: '性别',
7:'出生日期', 7: '出生日期',
8:'所属社区', 8: '所属社区',
9:'所属网格', 9: '所属网格',
10:'所属小区', 10: '所属小区',
11:'楼栋名称', 11: '楼栋名称',
12:'单元号', 12: '单元号',
13:'门牌号', 13: '门牌号',
14:'人房关系', 14: '人房关系',
15:'人户状况', 15: '人户状况',
16:'与户主关系', 16: '与户主关系',
17:'民族' 17: '民族'
}, },
{ {
1:'张三12', 1: '张三12',
2:'证件类型12', 2: '证件类型12',
3:'12342', 3: '12342',
4:'4562', 4: '4562',
5:'国籍2', 5: '国籍2',
6:'性别2', 6: '性别2',
7:'出生日期2', 7: '出生日期2',
8:'所属社区2', 8: '所属社区2',
9:'所属网格2', 9: '所属网格2',
10:'所属小区2', 10: '所属小区2',
11:'楼栋名称2', 11: '楼栋名称2',
12:'单元号2', 12: '单元号2',
13:'门牌号2', 13: '门牌号2',
14:'人房关系2', 14: '人房关系2',
15:'人户状况2', 15: '人户状况2',
16:'与户主关系2', 16: '与户主关系2',
17:'民族' 17: '民族'
} }
] ]
arr.forEach((item,index)=>{ arr.forEach((item, index) => {
for(let k in item){ for (let k in item) {
// index +1 + this.sheetR() // index +1 + this.sheetR()
luckysheet.setCellValue(index+1, k - 1, item[k]) luckysheet.setCellValue(index+this.sheetR, k - 1, item[k])
} }
}) })
// 17
},
updataSheet(){
}, },
}, },
beforeDestroy() { beforeDestroy() {
@ -208,11 +214,12 @@ export default {
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
.el-card { .el-card {
margin: 10px auto; margin: 10px auto;
padding: 0 16px; padding: 0 16px;
box-sizing: border-box; box-sizing: border-box;
width: calc(100% - 40px); width: calc(100% - 40px);
} }
.luckysheet-wrap { .luckysheet-wrap {
margin: 10px; margin: 10px;
padding: 0px; padding: 0px;

Loading…
Cancel
Save