big-data.js 2.73 KB
Newer Older
liang ce 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 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94
import _toConsumableArray from 'babel-runtime/helpers/toConsumableArray';
import _extends from 'babel-runtime/helpers/extends';
/* eslint react/no-multi-comp:0, no-console:0 */

import '../assets/index.less';
import './demo.less';
import TreeSelect, { SHOW_PARENT } from '../index';
import Gen from './big-data-generator';

export default {
  data: function data() {
    return {
      gData: [],
      gData1: [],
      value: '',
      value1: ''
    };
  },

  methods: {
    onChange: function onChange(value) {
      console.log('onChange', arguments);
      this.value = value;
    },
    onChangeStrictly: function onChangeStrictly(value1) {
      console.log('onChangeStrictly', arguments);
      var ind = parseInt(Math.random() * 3, 10);
      value1.push({ value: '0-0-0-' + ind + '-value', label: '0-0-0-' + ind + '-label', halfChecked: true });
      this.value1 = value1;
    },
    onGen: function onGen(data) {
      _extends(this.$data, {
        gData: data,
        gData1: [].concat(_toConsumableArray(data)),
        value: '0-0-0-value',
        value1: [{ value: '0-0-value', label: '0-0-label', halfChecked: true }, { value: '0-0-0-value', label: '0-0-0-label' }]
        // value: ['0-0-0-0-value', '0-0-0-1-value', '0-0-0-2-value'],
      });
    }
  },

  render: function render() {
    var h = arguments[0];

    return h(
      'div',
      { style: { padding: '0 20px' } },
      [h(Gen, {
        on: {
          'gen': this.onGen
        }
      }), h(
        'div',
        { style: { display: 'flex' } },
        [h(
          'div',
          { style: { marginRight: '20px' } },
          [h('h3', ['normal check']), h(TreeSelect, {
            style: { width: '300px' },
            attrs: { dropdownStyle: { maxHeight: '200px', overflow: 'auto' },
              treeData: this.gData,
              treeLine: true,
              value: this.value,
              placeholder: h('i', ['\u8BF7\u4E0B\u62C9\u9009\u62E9']),
              treeCheckable: true,
              showCheckedStrategy: SHOW_PARENT,

              __propsSymbol__: Symbol()
            },
            on: {
              'change': this.onChange
            }
          })]
        ), h('div', [h('h3', ['checkStrictly']), h(TreeSelect, {
          style: { width: '300px' },
          attrs: { dropdownStyle: { maxHeight: '200px', overflow: 'auto' },
            treeData: this.gData1,
            treeLine: true,
            value: this.value1,
            placeholder: h('i', ['\u8BF7\u4E0B\u62C9\u9009\u62E9']),
            treeCheckable: true,
            treeCheckStrictly: true,
            showCheckedStrategy: SHOW_PARENT,

            __propsSymbol__: Symbol()
          },
          on: {
            'change': this.onChangeStrictly
          }
        })])]
      )]
    );
  }
};