delay render

This commit is contained in:
shaohaojiecoder 2020-12-13 16:42:17 +08:00
parent fb9186aa1e
commit 0cac7fa3f4
2 changed files with 19 additions and 0 deletions

View File

@ -20,6 +20,10 @@ export default {
type: [String, Function],
default: 'key'
},
loaded: {
type: Boolean,
default: true
},
data: {
type: Function,
required: true
@ -265,6 +269,14 @@ export default {
},
render () {
if (!this.loaded) {
return (
<div style="width: 100%; height:160px; text-align: center; line-height:160px">
<a-spin tip="Loading...">
</a-spin>
</div>
)
}
const props = {}
const localKeys = Object.keys(this.$data)
const showAlert = (typeof this.alert === 'object' && this.alert !== null && this.alert.show) && typeof this.rowSelection.selectedRowKeys !== 'undefined' || this.alert

View File

@ -51,6 +51,7 @@
ref="table"
size="middle"
rowKey="ci_id"
:loaded="tableLoaded"
:columns="columns"
:data="loadInstances"
:alert="options.alert"
@ -172,6 +173,7 @@ export default {
data () {
return {
loading: false,
tableLoaded: false,
loadTip: '',
pageSizeOptions: ['10', '25', '50', '100'],
form: this.$form.createForm(this),
@ -191,6 +193,7 @@ export default {
instanceList: [],
columns: [],
loadInstances: parameter => {
this.tableLoaded = false
const params = Object.assign(parameter, this.$refs.search.queryParam)
let q = `q=_type:${this.$router.currentRoute.meta.typeId}`
Object.keys(params).forEach(key => {
@ -219,6 +222,10 @@ export default {
result.totalPage = Math.ceil(res.numfound / params.pageSize)
result.data = Object.assign([], res.result)
result.data.forEach((item, index) => (item.key = item.ci_id))
this.$nextTick(() => {
this.tableLoaded = true
})
if (res.numfound) {
setTimeout(() => {
this.setColumnWidth()