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

89 lines
1.7 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 BaseMixin from '../../_util/BaseMixin';
import '../assets/index.less';
import TreeSelect from '../src/index';
2018-07-11 09:51:20 +00:00
2019-01-12 03:33:27 +00:00
const SHOW_PARENT = TreeSelect.SHOW_PARENT;
2018-07-11 09:51:20 +00:00
2019-01-12 03:33:27 +00:00
const treeData = [
{
label: 'Node1',
value: '0-0',
key: '0-0',
children: [
{
label: 'Child Node1',
value: '0-0-0',
key: '0-0-0',
},
],
},
{
label: 'Node2',
value: '0-1',
key: '0-1',
children: [
{
label: 'Child Node3',
value: '0-1-0',
key: '0-1-0',
},
{
label: 'Child Node4',
value: '0-1-1',
key: '0-1-1',
},
{
label: 'Child Node5',
value: '0-1-2',
key: '0-1-2',
},
],
},
];
2018-07-11 09:51:20 +00:00
export default {
mixins: [BaseMixin],
data: () => ({
value: ['0-0-0'],
disabled: false,
}),
2018-07-11 09:51:20 +00:00
methods: {
2019-01-12 03:33:27 +00:00
onChange(value) {
console.log('onChange ', value, arguments);
this.setState({ value });
2018-07-11 09:51:20 +00:00
},
2019-01-12 03:33:27 +00:00
switch(checked) {
this.setState({ disabled: checked });
2018-07-11 09:51:20 +00:00
},
},
2019-01-12 03:33:27 +00:00
render() {
2018-07-11 09:51:20 +00:00
const tProps = {
props: {
treeData,
disabled: this.disabled,
value: this.value,
multiple: true,
allowClear: true,
treeCheckable: true,
showCheckedStrategy: SHOW_PARENT,
searchPlaceholder: 'Please select',
__propsSymbol__: Symbol(),
2018-07-11 09:51:20 +00:00
},
on: {
change: this.onChange,
},
style: {
width: '300px',
},
2019-01-12 03:33:27 +00:00
};
2018-07-11 09:51:20 +00:00
return (
<div>
<TreeSelect {...tProps} />
2019-01-12 03:33:27 +00:00
<input type="checkbox" onChange={e => this.switch(e.target.checked)} /> 禁用
2018-07-11 09:51:20 +00:00
</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
};