ant-design-vue/components/vc-tree-select/demo/big-data.js

85 lines
2.3 KiB
JavaScript
Raw Normal View History

2018-07-11 09:51:20 +00:00
/* eslint react/no-multi-comp:0, no-console:0 */
2019-01-12 03:33:27 +00:00
import '../assets/index.less';
import './demo.less';
import TreeSelect, { SHOW_PARENT } from '../index';
import Gen from './big-data-generator';
2018-07-11 09:51:20 +00:00
export default {
2019-01-12 03:33:27 +00:00
data() {
2018-07-11 09:51:20 +00:00
return {
gData: [],
gData1: [],
value: '',
value1: '',
2019-01-12 03:33:27 +00:00
};
2018-07-11 09:51:20 +00:00
},
methods: {
2019-01-12 03:33:27 +00:00
onChange(value) {
console.log('onChange', arguments);
this.value = value;
2018-07-11 09:51:20 +00:00
},
2019-01-12 03:33:27 +00:00
onChangeStrictly(value1) {
console.log('onChangeStrictly', arguments);
const 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;
2018-07-11 09:51:20 +00:00
},
2019-01-12 03:33:27 +00:00
onGen(data) {
2018-07-11 09:51:20 +00:00
Object.assign(this.$data, {
gData: data,
gData1: [...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'],
2019-01-12 03:33:27 +00:00
});
2018-07-11 09:51:20 +00:00
},
},
2019-01-12 03:33:27 +00:00
render() {
return (
<div style={{ padding: '0 20px' }}>
<Gen onGen={this.onGen} />
<div style={{ display: 'flex' }}>
<div style={{ marginRight: '20px' }}>
<h3>normal check</h3>
<TreeSelect
style={{ width: '300px' }}
dropdownStyle={{ maxHeight: '200px', overflow: 'auto' }}
treeData={this.gData}
treeLine
value={this.value}
placeholder={<i>请下拉选择</i>}
treeCheckable
showCheckedStrategy={SHOW_PARENT}
onChange={this.onChange}
__propsSymbol__={Symbol()}
/>
</div>
<div>
<h3>checkStrictly</h3>
<TreeSelect
style={{ width: '300px' }}
dropdownStyle={{ maxHeight: '200px', overflow: 'auto' }}
treeData={this.gData1}
treeLine
value={this.value1}
placeholder={<i>请下拉选择</i>}
treeCheckable
treeCheckStrictly
showCheckedStrategy={SHOW_PARENT}
onChange={this.onChangeStrictly}
__propsSymbol__={Symbol()}
/>
</div>
2018-07-11 09:51:20 +00:00
</div>
</div>
2019-01-12 03:33:27 +00:00
);
2018-07-11 09:51:20 +00:00
},
2019-01-12 03:33:27 +00:00
};