Basic6.tsx 1.6 KB
Newer Older
李纪文's avatar
李纪文 committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73
// @ts-ignore
import React, { useEffect, useState } from 'react';
import { SelectCustom, TreeSelectCustom, Option, OptGroup, SHOW_PARENT } from '../index';
import { HomeOutlined } from '@ant-design/icons';
import './index.less';

const Demo = (props) => {
  const onChange = (newValue) => {
    console.log(`selected ${newValue}`);
  };
  const treeData = [
    {
      title: '平台研发部',
      value: '平台研发部',
      key: '0-0',
      children: [
        {
          title: '研发一部',
          value: '研发一部',
          key: '0-0-0',
        },
        {
          title: '研发二部',
          value: '研发二部',
          key: '0-0-1',
        },
        {
          title: '研发三部',
          value: '研发三部',
          key: '0-0-2',
        },
        {
          title: '研发四部',
          value: '研发四部',
          key: '0-0-3',
        },
      ],
    },
    {
      title: '平台实施部',
      value: '平台实施部',
      key: '0-1',
      children: [
        {
          title: '项目管理组',
          value: '项目管理组',
          key: '0-1-0',
        },
        {
          title: '项目支持组',
          value: '项目支持组',
          key: '0-1-1',
        },
      ],
    },
  ];
  return (
    <TreeSelectCustom
      treeData={treeData}
      onChange={onChange}
      treeCheckable={true}
      defaultValue={['研发一部', '研发三部']}
      // showCheckedStrategy SHOW_PARENT
      placeholder="Please select"
      treeDefaultExpandAll
      style={{
        width: '100%',
      }}
    />
  );
};

export default Demo;