优化table数据过多造成卡顿问题

This commit is contained in:
shenyanpei
2021-09-26 11:30:29 +08:00
parent acaf5437b7
commit 138557770b
@@ -49,11 +49,12 @@
</div> </div>
</div> </div>
<el-table <el-table
:data="dataList" :data="dataList.slice((currentPage - 1) * pageSize, currentPage * pageSize ) "
style="width: 100%; border: 1px solid #cccccc" style="width: 100%; border: 1px solid #cccccc;height: 400px"
row-key="standId" row-key="standId"
height="70%" height="70%"
border border
highlight-current-row
@selection-change="selectStandChange" @selection-change="selectStandChange"
:header-cell-style="{background: '#e8e8e8', color: '#333333', fontSize: '16px', :header-cell-style="{background: '#e8e8e8', color: '#333333', fontSize: '16px',
fontWeight: 'bold'}" fontWeight: 'bold'}"
@@ -72,7 +73,8 @@
> >
<template slot-scope="scope"> <template slot-scope="scope">
<a v-if="scope.row.standYear" class="table-jump" <a v-if="scope.row.standYear" class="table-jump"
@click="handlePreview(scope.row)">{{ scope.row.standSort }} {{ scope.row.standNumber @click="handlePreview(scope.row)">{{ scope.row.standSort }} {{
scope.row.standNumber
}}-{{ scope.row.standYear }}</a> }}-{{ scope.row.standYear }}</a>
<a v-else @click="handlePreview(scope.row)" class="table-jump">{{ scope.row.standSort }} <a v-else @click="handlePreview(scope.row)" class="table-jump">{{ scope.row.standSort }}
{{ scope.row.standNumber }}</a> {{ scope.row.standNumber }}</a>
@@ -255,6 +257,14 @@
<!-- </template>--> <!-- </template>-->
<!-- </el-table-column>--> <!-- </el-table-column>-->
</el-table> </el-table>
<el-pagination
layout="total,sizes, prev, pager, next"
background
:page-sizes="[20, 40, 60]"
:total="total"
@current-change="handleCurrentChange"
>
</el-pagination>
</div> </div>
<div> <div>
<el-collapse accordion> <el-collapse accordion>
@@ -422,8 +432,11 @@
</el-form> </el-form>
</div> </div>
<div class="demo-drawer-footer"> <div class="demo-drawer-footer">
<el-button class="common-button-primary" size="mini" icon="el-icon-check" type="primary" @click="saveBatchEditForm">确定</el-button> <el-button class="common-button-primary" size="mini" icon="el-icon-check" type="primary" @click="saveBatchEditForm">
<el-button class="common-button-default" size="mini" icon="el-icon-close" @click="cancelBatchEditForm">取消</el-button> 确定
</el-button>
<el-button class="common-button-default" size="mini" icon="el-icon-close" @click="cancelBatchEditForm">取消
</el-button>
</div> </div>
</el-drawer> </el-drawer>
</div> </div>
@@ -444,6 +457,9 @@ export default {
}, },
data() { data() {
return { return {
total: 0,
currentPage: 1,
pageSize: 20,
nodeList: [], nodeList: [],
isTransfer: false, isTransfer: false,
// 调整处理人抽屉状态 // 调整处理人抽屉状态
@@ -696,7 +712,6 @@ export default {
pId: this.pId pId: this.pId
}).then(res => { }).then(res => {
if (res) { if (res) {
console.log(res.mesg);
const processForm = JSON.parse(res.mesg); const processForm = JSON.parse(res.mesg);
this.getFormFieldList(processForm); this.getFormFieldList(processForm);
} }
@@ -713,15 +728,27 @@ export default {
this.listForm.prcName = this.prcName; this.listForm.prcName = this.prcName;
this.listForm["id"] = item.id; this.listForm["id"] = item.id;
// this.listForm.dataList = item.dataList; // this.listForm.dataList = item.dataList;
this.dataList = this.listForm.dataList; this.dataList = this.listForm.dataList[0].children
console.log(this.dataList); this.dataList.map(item => {
this.$set(item, 'standName', this.listForm.dataList[0].standName)
this.$set(item, 'standEnName', this.listForm.dataList[0].standEnName)
this.$set(item, 'standYear', this.listForm.dataList[0].standYear)
this.$set(item, 'standSort', this.listForm.dataList[0].standSort)
this.$set(item, 'standNumber', this.listForm.dataList[0].standNumber)
})
this.total = this.listForm.dataList[0].children.length;
} else { } else {
this.listForm = item.form; this.listForm = item.form;
this.dataList = item.form.dataList; this.dataList = item.form.dataList[0].children
this.total = item.form.dataList[0].children.length;
} }
}); });
}, },
// 分页
handleCurrentChange(currentPage) {
this.currentPage = currentPage;
},
//保存事件 //保存事件
handleSave() { handleSave() {
this.saveLoading = true; this.saveLoading = true;
@@ -874,9 +901,11 @@ export default {
.demo-drawer-content { .demo-drawer-content {
margin-top: 10px; margin-top: 10px;
} }
/deep/ .el-table th > .cell { /deep/ .el-table th > .cell {
font-size: 12px; font-size: 12px;
} }
/deep/ .el-table thead.is-group th { /deep/ .el-table thead.is-group th {
padding: 0px; padding: 0px;
} }