forked from opentiny/tiny-vue
doc: 修改文档示例 (#224)
This commit is contained in:
parent
6ca421b964
commit
adc9c1bf86
|
@ -10,11 +10,21 @@
|
||||||
<template #toolbar>
|
<template #toolbar>
|
||||||
<tiny-grid-toolbar class="customizedBox">
|
<tiny-grid-toolbar class="customizedBox">
|
||||||
<template #buttons>
|
<template #buttons>
|
||||||
<tiny-button @click="insertEvent">新增</tiny-button>
|
<tiny-button @click="insertEvent">
|
||||||
<tiny-button @click="removeEvent">移除选中</tiny-button>
|
新增
|
||||||
<tiny-button @click="getRemoveEvent">获取删除</tiny-button>
|
</tiny-button>
|
||||||
<tiny-button @click="getUpdateEvent">获取修改</tiny-button>
|
<tiny-button @click="removeEvent">
|
||||||
<tiny-button @click="clearTreeExpand">清空展开状态</tiny-button>
|
移除选中
|
||||||
|
</tiny-button>
|
||||||
|
<tiny-button @click="getRemoveEvent">
|
||||||
|
获取删除
|
||||||
|
</tiny-button>
|
||||||
|
<tiny-button @click="getUpdateEvent">
|
||||||
|
获取修改
|
||||||
|
</tiny-button>
|
||||||
|
<tiny-button @click="clearTreeExpand">
|
||||||
|
清空展开状态
|
||||||
|
</tiny-button>
|
||||||
</template>
|
</template>
|
||||||
</tiny-grid-toolbar>
|
</tiny-grid-toolbar>
|
||||||
</template>
|
</template>
|
||||||
|
@ -202,12 +212,15 @@ export default {
|
||||||
methods: {
|
methods: {
|
||||||
insertEvent() {
|
insertEvent() {
|
||||||
let tree = this.$refs.tree
|
let tree = this.$refs.tree
|
||||||
|
const row = {
|
||||||
|
name: '新数据',
|
||||||
|
isNew: true,
|
||||||
|
children: [{
|
||||||
|
name: '新数据-child',
|
||||||
|
}]
|
||||||
|
}
|
||||||
tree
|
tree
|
||||||
.createRow({
|
.createRow(row)
|
||||||
name: '新数据',
|
|
||||||
isNew: true
|
|
||||||
})
|
|
||||||
.then((newRow) => {
|
.then((newRow) => {
|
||||||
// 插入到第一行
|
// 插入到第一行
|
||||||
this.tableData = [newRow, ...this.tableData]
|
this.tableData = [newRow, ...this.tableData]
|
||||||
|
@ -216,6 +229,7 @@ export default {
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
removeEvent() {
|
removeEvent() {
|
||||||
|
const isSameObject = (obj1, obj2) => JSON.stringify(obj1) === JSON.stringify(obj2)
|
||||||
let tree = this.$refs.tree
|
let tree = this.$refs.tree
|
||||||
|
|
||||||
let removeRecords = tree.getSelectRecords()
|
let removeRecords = tree.getSelectRecords()
|
||||||
|
@ -223,7 +237,13 @@ export default {
|
||||||
let tableData = this.tableData
|
let tableData = this.tableData
|
||||||
|
|
||||||
this.tableData = copy(tableData, removeRecords)
|
this.tableData = copy(tableData, removeRecords)
|
||||||
|
for (let i = 0; i < this.tableData.length; i++) {
|
||||||
|
for (let j = 0; j < removeRecords.length; j++) {
|
||||||
|
if (isSameObject(this.tableData[i], removeRecords[j])) {
|
||||||
|
this.tableData.splice(i, 1)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
this.removeList = removeRecords.map((item) => ({ ...item }))
|
this.removeList = removeRecords.map((item) => ({ ...item }))
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue