8080 </template >
8181 </el-table-column >
8282 <el-table-column :label =" $t('table.actions')" align =" center" width =" 230" class-name =" small-padding fixed-width" >
83- <template slot-scope="{row}">
83+ <template slot-scope="{row,$index }">
8484 <el-button type =" primary" size =" mini" @click =" handleUpdate(row)" >
8585 {{ $t('table.edit') }}
8686 </el-button >
9090 <el-button v-if =" row.status!='draft'" size =" mini" @click =" handleModifyStatus(row,'draft')" >
9191 {{ $t('table.draft') }}
9292 </el-button >
93- <el-button v-if =" row.status!='deleted'" size =" mini" type =" danger" @click =" handleModifyStatus (row,'deleted' )" >
93+ <el-button v-if =" row.status!='deleted'" size =" mini" type =" danger" @click =" handleDelete (row,$index )" >
9494 {{ $t('table.delete') }}
9595 </el-button >
9696 </template >
@@ -319,13 +319,8 @@ export default {
319319 const tempData = Object .assign ({}, this .temp )
320320 tempData .timestamp = + new Date (tempData .timestamp ) // change Thu Nov 30 2017 16:41:05 GMT+0800 (CST) to 1512031311464
321321 updateArticle (tempData).then (() => {
322- for (const v of this .list ) {
323- if (v .id === this .temp .id ) {
324- const index = this .list .indexOf (v)
325- this .list .splice (index, 1 , this .temp )
326- break
327- }
328- }
322+ const index = this .list .findIndex (v => v .id === this .temp .id )
323+ this .list .splice (index, 1 , this .temp )
329324 this .dialogFormVisible = false
330325 this .$notify ({
331326 title: ' 成功' ,
@@ -337,14 +332,13 @@ export default {
337332 }
338333 })
339334 },
340- handleDelete (row ) {
335+ handleDelete (row , index ) {
341336 this .$notify ({
342337 title: ' 成功' ,
343338 message: ' 删除成功' ,
344339 type: ' success' ,
345340 duration: 2000
346341 })
347- const index = this .list .indexOf (row)
348342 this .list .splice (index, 1 )
349343 },
350344 handleFetchPv (pv ) {
@@ -358,7 +352,7 @@ export default {
358352 import (' @/vendor/Export2Excel' ).then (excel => {
359353 const tHeader = [' timestamp' , ' title' , ' type' , ' importance' , ' status' ]
360354 const filterVal = [' timestamp' , ' title' , ' type' , ' importance' , ' status' ]
361- const data = this .formatJson (filterVal, this . list )
355+ const data = this .formatJson (filterVal)
362356 excel .export_json_to_excel ({
363357 header: tHeader,
364358 data,
@@ -367,8 +361,8 @@ export default {
367361 this .downloadLoading = false
368362 })
369363 },
370- formatJson (filterVal , jsonData ) {
371- return jsonData .map (v => filterVal .map (j => {
364+ formatJson (filterVal ) {
365+ return this . list .map (v => filterVal .map (j => {
372366 if (j === ' timestamp' ) {
373367 return parseTime (v[j])
374368 } else {
@@ -378,11 +372,7 @@ export default {
378372 },
379373 getSortClass : function (key ) {
380374 const sort = this .listQuery .sort
381- return sort === ` +${ key} `
382- ? ' ascending'
383- : sort === ` -${ key} `
384- ? ' descending'
385- : ' '
375+ return sort === ` +${ key} ` ? ' ascending' : ' descending'
386376 }
387377 }
388378}
0 commit comments