|
@@ -63,33 +63,41 @@ export default {
|
|
this.ishead = false
|
|
this.ishead = false
|
|
this.head.init(this)
|
|
this.head.init(this)
|
|
}
|
|
}
|
|
- this.border = this.root.border
|
|
|
|
- this.selection = this.root.type
|
|
|
|
- this.root.trChildren.push(this)
|
|
|
|
- const rowData = this.root.data.find(v => v[this.root.rowKey] === this.keyValue)
|
|
|
|
- if(rowData){
|
|
|
|
- this.rowData = rowData
|
|
|
|
|
|
+ if(this.root){
|
|
|
|
+ this.border = this.root.border
|
|
|
|
+ this.selection = this.root.type
|
|
|
|
+ this.root.trChildren.push(this)
|
|
|
|
+ const rowData = this.root.data.find(v => v[this.root.rowKey] === this.keyValue)
|
|
|
|
+ if(rowData){
|
|
|
|
+ this.rowData = rowData
|
|
|
|
+ }
|
|
|
|
+ this.root.isNodata()
|
|
}
|
|
}
|
|
- this.root.isNodata()
|
|
|
|
},
|
|
},
|
|
mounted() {
|
|
mounted() {
|
|
if (this.widthThArr.length > 0) {
|
|
if (this.widthThArr.length > 0) {
|
|
const selectionWidth = this.selection === 'selection' ? 50 : 0
|
|
const selectionWidth = this.selection === 'selection' ? 50 : 0
|
|
- this.root.minWidth = this.widthThArr.reduce((a, b) => Number(a) + Number(b)) + selectionWidth
|
|
|
|
|
|
+ if(this.root){
|
|
|
|
+ this.root.minWidth = this.widthThArr.reduce((a, b) => Number(a) + Number(b)) + selectionWidth
|
|
|
|
+ }
|
|
}
|
|
}
|
|
},
|
|
},
|
|
// #ifndef VUE3
|
|
// #ifndef VUE3
|
|
destroyed() {
|
|
destroyed() {
|
|
- const index = this.root.trChildren.findIndex(i => i === this)
|
|
|
|
- this.root.trChildren.splice(index, 1)
|
|
|
|
- this.root.isNodata()
|
|
|
|
|
|
+ if(this.root){
|
|
|
|
+ const index = this.root.trChildren.findIndex(i => i === this)
|
|
|
|
+ this.root.trChildren.splice(index, 1)
|
|
|
|
+ this.root.isNodata()
|
|
|
|
+ }
|
|
},
|
|
},
|
|
// #endif
|
|
// #endif
|
|
// #ifdef VUE3
|
|
// #ifdef VUE3
|
|
unmounted() {
|
|
unmounted() {
|
|
- const index = this.root.trChildren.findIndex(i => i === this)
|
|
|
|
- this.root.trChildren.splice(index, 1)
|
|
|
|
- this.root.isNodata()
|
|
|
|
|
|
+ if(this.root){
|
|
|
|
+ const index = this.root.trChildren.findIndex(i => i === this)
|
|
|
|
+ this.root.trChildren.splice(index, 1)
|
|
|
|
+ this.root.isNodata()
|
|
|
|
+ }
|
|
},
|
|
},
|
|
// #endif
|
|
// #endif
|
|
methods: {
|
|
methods: {
|
|
@@ -98,16 +106,20 @@ export default {
|
|
},
|
|
},
|
|
// 选中
|
|
// 选中
|
|
checkboxSelected(e) {
|
|
checkboxSelected(e) {
|
|
- let rootData = this.root.data.find(v => v[this.root.rowKey] === this.keyValue)
|
|
|
|
- this.checked = e.checked
|
|
|
|
- this.root.check(rootData||this, e.checked,rootData? this.keyValue:null)
|
|
|
|
|
|
+ if(this.root){
|
|
|
|
+ let rootData = this.root.data.find(v => v[this.root.rowKey] === this.keyValue)
|
|
|
|
+ this.checked = e.checked
|
|
|
|
+ this.root.check(rootData||this, e.checked,rootData? this.keyValue:null)
|
|
|
|
+ }
|
|
},
|
|
},
|
|
change(e) {
|
|
change(e) {
|
|
- this.root.trChildren.forEach(item => {
|
|
|
|
- if (item === this) {
|
|
|
|
- this.root.check(this, e.detail.value.length > 0 ? true : false)
|
|
|
|
- }
|
|
|
|
- })
|
|
|
|
|
|
+ if(this.root){
|
|
|
|
+ this.root.trChildren.forEach(item => {
|
|
|
|
+ if (item === this) {
|
|
|
|
+ this.root.check(this, e.detail.value.length > 0 ? true : false)
|
|
|
|
+ }
|
|
|
|
+ })
|
|
|
|
+ }
|
|
},
|
|
},
|
|
/**
|
|
/**
|
|
* 获取父元素实例
|
|
* 获取父元素实例
|