UP scTable 若干个数据操作方法

This commit is contained in:
sakuya 2022-05-21 18:59:08 +08:00
parent 923465274e
commit 780f713856
1 changed files with 40 additions and 2 deletions

View File

@ -1,10 +1,10 @@
<!--
* @Descripttion: 数据表格组件
* @version: 1.7
* @version: 1.8
* @Author: sakuya
* @Date: 2021年11月29日21:51:15
* @LastEditors: sakuya
* @LastEditTime: 2022年5月15日00:24:09
* @LastEditTime: 2022年5月21日18:08:46
-->
<template>
@ -322,6 +322,44 @@
configSizeChange(){
this.$refs.scTable.doLayout()
},
// unshiftRow
unshiftRow(row){
this.tableData.unshift(row)
},
// pushRow
pushRow(row){
this.tableData.push(row)
},
//key
updateKey(row, rowKey=this.rowKey){
this.tableData.filter(item => item[rowKey]===row[rowKey] ).forEach(item => {
Object.assign(item, row)
})
},
//index
updateIndex(row, index){
Object.assign(this.tableData[index], row)
},
//index
removeIndex(index){
this.tableData.splice(index, 1)
},
//index
removeIndexes(indexes=[]){
indexes.forEach(index => {
this.tableData.splice(index, 1)
})
},
//key
removeKey(key, rowKey=this.rowKey){
this.tableData.splice(this.tableData.findIndex(item => item[rowKey]===key), 1)
},
//keys
removeKeys(keys=[], rowKey=this.rowKey){
keys.forEach(key => {
this.tableData.splice(this.tableData.findIndex(item => item[rowKey]===key), 1)
})
},
//
clearSelection(){
this.$refs.scTable.clearSelection()