# formatTreeSelectProps(obj) ⇒ array

格式化tree属性为TreeSelect所需

Returns: array -

格式化后符合TreeSelect的tree


Author: liukun 919590347@qq.com

Param Type Default Description
obj object

入参对象

obj.tree object

原始tree

[obj.fieldNames] object {id: 'key', label: 'label', children: 'children'}

格式化tree所需的属性

[obj.parentSelectable] boolean false

父级是否可选择,默认不可选

Example

import { formatTreeSelectProps } from '@wont/utils'

const beforeTree = [
  {
    id: 1,
    label: '1-1',
    children: [
      {
        id: 11,
        label: '1-1-1',
        children: [
          {
            id: 111,
            label: '1-1-1-1',
          },
        ],
      },
    ],
  },
  {
    id: 2,
    label: '2-1',
  },
]
const afterTree = [
  {
    id: 1,
    value: 1,
    label: '1-1',
    selectable: false,
    children: [
      {
        id: 11,
        value: 11,
        label: '1-1-1',
        selectable: false,
        children: [
          {
            id: 111,
            value: 111,
            label: '1-1-1-1',
          },
        ],
      },
    ],
  },
  {
    id: 2,
    value: 2,
    label: '2-1',
  },
]
formatTreeSelectProps({
  tree: beforeTree,
})
// return afterTree