How to use the xe-utils.findTree function in xe-utils

To help you get started, we’ve selected a few xe-utils examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github xuliangzhan / vxe-table / examples / mock / api / helper.js View on Github external
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
    }
  }
github xuliangzhan / vxe-table / packages / table / src / table.js View on Github external
          let matchObj = XEUtils.findTree(tableSourceData, row => rowId === XEUtils.get(row, rowKey), treeConfig)
          row = Object.assign({}, row, { [children]: null })
github xuliangzhan / vue-element-extends / packages / editable / src / editable.vue View on Github external
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) {
github xuliangzhan / vue-element-extends / packages / editable / src / editable.vue View on Github external
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)
        }
      })
    },
github xuliangzhan / vxe-table / examples / views / table / tree / CellValid.vue View on Github external
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}`)
              })
            })
          })
github xuliangzhan / vue-element-extends / packages / editable / src / editable.vue View on Github external
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)
    },
    /**
github xuliangzhan / vxe-table / packages / table / src / table.js View on Github external
getRowIndex (row) {
      let { tableFullData, treeConfig } = this
      return treeConfig ? XEUtils.findTree(tableFullData, item => item === row, treeConfig) : this.getRowMapIndex(row)
    },
    getColumnMapIndex (column) {
github xuliangzhan / vxe-table / packages / table / src / table.js View on Github external
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
github xuliangzhan / vue-element-extends / packages / editable / src / editable.vue View on Github external
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()
github xuliangzhan / vue-element-extends / packages / editable / src / editable.vue View on Github external
hasRowInsert (record) {
      let matchObj = XEUtils.findTree(this._fullData, row => row.data === record, this.elTreeOpts)
      return matchObj && matchObj.item.editStatus === 'insert'
    },
    /**