perf[complex-table]:refine code (#2825)
This commit is contained in:
parent
be18a69fa4
commit
93e01926e3
|
@ -18,7 +18,7 @@ for (let i = 0; i < count; i++) {
|
||||||
forecast: '@float(0, 100, 2, 2)',
|
forecast: '@float(0, 100, 2, 2)',
|
||||||
importance: '@integer(1, 3)',
|
importance: '@integer(1, 3)',
|
||||||
'type|1': ['CN', 'US', 'JP', 'EU'],
|
'type|1': ['CN', 'US', 'JP', 'EU'],
|
||||||
'status|1': ['published', 'draft', 'deleted'],
|
'status|1': ['published', 'draft'],
|
||||||
display_time: '@datetime',
|
display_time: '@datetime',
|
||||||
comment_disabled: true,
|
comment_disabled: true,
|
||||||
pageviews: '@integer(300, 5000)',
|
pageviews: '@integer(300, 5000)',
|
||||||
|
|
|
@ -80,7 +80,7 @@
|
||||||
</template>
|
</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
<el-table-column :label="$t('table.actions')" align="center" width="230" class-name="small-padding fixed-width">
|
<el-table-column :label="$t('table.actions')" align="center" width="230" class-name="small-padding fixed-width">
|
||||||
<template slot-scope="{row}">
|
<template slot-scope="{row,$index}">
|
||||||
<el-button type="primary" size="mini" @click="handleUpdate(row)">
|
<el-button type="primary" size="mini" @click="handleUpdate(row)">
|
||||||
{{ $t('table.edit') }}
|
{{ $t('table.edit') }}
|
||||||
</el-button>
|
</el-button>
|
||||||
|
@ -90,7 +90,7 @@
|
||||||
<el-button v-if="row.status!='draft'" size="mini" @click="handleModifyStatus(row,'draft')">
|
<el-button v-if="row.status!='draft'" size="mini" @click="handleModifyStatus(row,'draft')">
|
||||||
{{ $t('table.draft') }}
|
{{ $t('table.draft') }}
|
||||||
</el-button>
|
</el-button>
|
||||||
<el-button v-if="row.status!='deleted'" size="mini" type="danger" @click="handleModifyStatus(row,'deleted')">
|
<el-button v-if="row.status!='deleted'" size="mini" type="danger" @click="handleDelete(row,$index)">
|
||||||
{{ $t('table.delete') }}
|
{{ $t('table.delete') }}
|
||||||
</el-button>
|
</el-button>
|
||||||
</template>
|
</template>
|
||||||
|
@ -319,13 +319,8 @@ export default {
|
||||||
const tempData = Object.assign({}, this.temp)
|
const tempData = Object.assign({}, this.temp)
|
||||||
tempData.timestamp = +new Date(tempData.timestamp) // change Thu Nov 30 2017 16:41:05 GMT+0800 (CST) to 1512031311464
|
tempData.timestamp = +new Date(tempData.timestamp) // change Thu Nov 30 2017 16:41:05 GMT+0800 (CST) to 1512031311464
|
||||||
updateArticle(tempData).then(() => {
|
updateArticle(tempData).then(() => {
|
||||||
for (const v of this.list) {
|
const index = this.list.findIndex(v => v.id === this.temp.id)
|
||||||
if (v.id === this.temp.id) {
|
this.list.splice(index, 1, this.temp)
|
||||||
const index = this.list.indexOf(v)
|
|
||||||
this.list.splice(index, 1, this.temp)
|
|
||||||
break
|
|
||||||
}
|
|
||||||
}
|
|
||||||
this.dialogFormVisible = false
|
this.dialogFormVisible = false
|
||||||
this.$notify({
|
this.$notify({
|
||||||
title: '成功',
|
title: '成功',
|
||||||
|
@ -337,14 +332,13 @@ export default {
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
handleDelete(row) {
|
handleDelete(row, index) {
|
||||||
this.$notify({
|
this.$notify({
|
||||||
title: '成功',
|
title: '成功',
|
||||||
message: '删除成功',
|
message: '删除成功',
|
||||||
type: 'success',
|
type: 'success',
|
||||||
duration: 2000
|
duration: 2000
|
||||||
})
|
})
|
||||||
const index = this.list.indexOf(row)
|
|
||||||
this.list.splice(index, 1)
|
this.list.splice(index, 1)
|
||||||
},
|
},
|
||||||
handleFetchPv(pv) {
|
handleFetchPv(pv) {
|
||||||
|
@ -358,7 +352,7 @@ export default {
|
||||||
import('@/vendor/Export2Excel').then(excel => {
|
import('@/vendor/Export2Excel').then(excel => {
|
||||||
const tHeader = ['timestamp', 'title', 'type', 'importance', 'status']
|
const tHeader = ['timestamp', 'title', 'type', 'importance', 'status']
|
||||||
const filterVal = ['timestamp', 'title', 'type', 'importance', 'status']
|
const filterVal = ['timestamp', 'title', 'type', 'importance', 'status']
|
||||||
const data = this.formatJson(filterVal, this.list)
|
const data = this.formatJson(filterVal)
|
||||||
excel.export_json_to_excel({
|
excel.export_json_to_excel({
|
||||||
header: tHeader,
|
header: tHeader,
|
||||||
data,
|
data,
|
||||||
|
@ -367,8 +361,8 @@ export default {
|
||||||
this.downloadLoading = false
|
this.downloadLoading = false
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
formatJson(filterVal, jsonData) {
|
formatJson(filterVal) {
|
||||||
return jsonData.map(v => filterVal.map(j => {
|
return this.list.map(v => filterVal.map(j => {
|
||||||
if (j === 'timestamp') {
|
if (j === 'timestamp') {
|
||||||
return parseTime(v[j])
|
return parseTime(v[j])
|
||||||
} else {
|
} else {
|
||||||
|
@ -378,11 +372,7 @@ export default {
|
||||||
},
|
},
|
||||||
getSortClass: function(key) {
|
getSortClass: function(key) {
|
||||||
const sort = this.listQuery.sort
|
const sort = this.listQuery.sort
|
||||||
return sort === `+${key}`
|
return sort === `+${key}` ? 'ascending' : 'descending'
|
||||||
? 'ascending'
|
|
||||||
: sort === `-${key}`
|
|
||||||
? 'descending'
|
|
||||||
: ''
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue