Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
let orderPrpo = order
if (params) {
let filterProps = XEUtils.keys(params).filter(key => !['sort', 'order'].includes(key) && params[key])
if (filterProps) {
rest = rest.filter(data => filterProps.every(key => '' + data[key] === '' + params[key]))
}
if (params.order) {
orderPrpo = params.order
}
if (params.sort) {
sortProp = params.sort.split(',')
}
}
rest = XEUtils.toArrayTree(list, { key, parentKey, sortKey: sortProp })
if (params && params[key]) {
let matchObj = XEUtils.findTree(rest, item => '' + item[key] === '' + params[key], { key, parentKey })
rest = matchObj ? matchObj.item.children : []
}
rest = rest.map(item => {
if (item.children && item.children.length) {
item.hasChildren = true
}
delete item.children
return item
})
if (orderPrpo === 'desc') {
rest = rest.reverse()
}
return max ? rest.slice(0, max) : rest
}
}
let matchObj = XEUtils.findTree(tableSourceData, row => rowId === XEUtils.get(row, rowKey), treeConfig)
row = Object.assign({}, row, { [children]: null })
insertAt (newRecord, record) {
let rowItem = this._toDatas([newRecord], 'insert')[0]
let rest = { row: rowItem.data, _row: rowItem }
if (record) {
if (record === -1) {
this._fullData.push(rowItem)
} else {
let matchObj = XEUtils.findTree(this._fullData, row => row.data === record, this.elTreeOpts)
if (matchObj) {
if (matchObj.parent) {
rest.parent = matchObj.parent.data
}
matchObj.items.splice(matchObj.index, 0, rowItem)
} else {
this._fullData.push(rowItem)
}
}
} else {
this._fullData.unshift(rowItem)
}
this.currentRow = rowItem.data
this._saveOperStatus()
this._updateData()
if (this.scrollLoad) {
this.$nextTick(() => {
if (this.highlightCurrentRow) {
let matchObj = this.currentRow ? XEUtils.findTree(this.datas, row => row.data === this.currentRow, this.elTreeOpts) : null
this.$refs.refElTable.setCurrentRow(matchObj ? matchObj.item : null)
}
})
},
errList.forEach(params => {
let { row, column, rules } = params
let matchObj = XEUtils.findTree(this.tableData, item => item === row, this.treeConfig)
let seq = matchObj.path.filter(item => item !== this.treeConfig.children).map(item => Number(item) + 1).join('.')
rules.forEach(rule => {
msgList.push(`第 ${seq} 行 ${column.title} 校验错误:${rule.message}`)
})
})
})
hasRowChange (record, property) {
let matchObj = XEUtils.findTree(this._fullData, row => row.data === record, this.elTreeOpts)
return property ? this._isRowDataChange(matchObj.item, { property }) : this._isRowDataChange(matchObj.item)
},
/**
getRowIndex (row) {
let { tableFullData, treeConfig } = this
return treeConfig ? XEUtils.findTree(tableFullData, item => item === row, treeConfig) : this.getRowMapIndex(row)
},
getColumnMapIndex (column) {
expandRowKeys.forEach(rowKey => {
let matchObj = XEUtils.findTree(tableFullData, item => rowKey === item[property], treeConfig)
let rowChildren = matchObj ? matchObj.item[children] : 0
if (rowChildren && rowChildren.length) {
treeExpandeds.push(matchObj.item)
}
})
this.treeExpandeds = treeExpandeds
records.forEach(record => {
let matchObj = XEUtils.findTree(this._fullData, row => row.data === record, this.elTreeOpts)
if (matchObj) {
let { index, items } = matchObj
let removeRow = items.splice(index, 1)[0]
if (removeRow.editStatus === 'initial') {
this.deleteRecords.push(removeRow)
}
rest.push(removeRow.data)
}
})
this._clearActiveData()
hasRowInsert (record) {
let matchObj = XEUtils.findTree(this._fullData, row => row.data === record, this.elTreeOpts)
return matchObj && matchObj.item.editStatus === 'insert'
},
/**