ant-design-vue/components/vc-tree/demo/basic.jsx

121 lines
3.4 KiB
Vue
Raw Normal View History

2018-03-24 09:12:22 +00:00
/* eslint no-console:0 */
/* eslint no-alert:0 */
import PropTypes from '../../_util/vue-types'
2018-12-14 01:56:40 +00:00
import Tree from '../index'
2018-03-24 09:12:22 +00:00
import '../assets/index.less'
import './basic.less'
2018-09-26 14:57:01 +00:00
const treeData = [
{ key: '0-0', title: 'parent 1', children:
[
{ key: '0-0-0', title: 'parent 1-1', children:
[
{ key: '0-0-0-0', title: 'parent 1-1-0' },
],
},
{ key: '0-0-1', title: 'parent 1-2', children:
[
{ key: '0-0-1-0', title: 'parent 1-2-0', disableCheckbox: true },
{ key: '0-0-1-1', title: 'parent 1-2-1' },
],
},
],
},
]
2018-03-24 09:12:22 +00:00
export default {
props: {
keys: PropTypes.array.def(['0-0-0-0']),
},
data () {
const keys = this.keys
return {
defaultExpandedKeys: keys,
defaultSelectedKeys: keys,
defaultCheckedKeys: keys,
}
},
methods: {
onExpand (expandedKeys) {
console.log('onExpand', expandedKeys, arguments)
},
onSelect (selectedKeys, info) {
console.log('selected', selectedKeys, info)
this.selKey = info.node.$options.propsData.eventKey
},
onCheck (checkedKeys, info) {
console.log('onCheck', checkedKeys, info)
},
onEdit () {
setTimeout(() => {
console.log('current key: ', this.selKey)
}, 0)
},
onDel (e) {
if (!window.confirm('sure to delete?')) {
return
}
e.stopPropagation()
},
toggleChildren () {
this.showMore = !this.showMore
},
},
render () {
2018-12-14 01:56:40 +00:00
const customLabel = ( // eslint-disable-line
2018-09-26 14:57:01 +00:00
<span class='cus-label'>
<span>operations: </span>
<span style={{ color: 'blue' }} onClick={this.onEdit}>Edit</span>&nbsp;
<label onClick={(e) => e.stopPropagation()}>
<input type='checkbox' /> checked
</label>
&nbsp;
<span style={{ color: '#EB0000' }} onClick={this.onDel}>Delete</span>
</span>
)
2018-03-24 09:12:22 +00:00
return (<div style={{ margin: '0 20px' }}>
<h2>simple</h2>
2018-09-26 14:57:01 +00:00
{/* <Tree
2018-03-24 09:12:22 +00:00
class='myCls' showLine checkable defaultExpandAll
defaultExpandedKeys={this.defaultExpandedKeys}
onExpand={this.onExpand}
defaultSelectedKeys={this.defaultSelectedKeys}
defaultCheckedKeys={this.defaultCheckedKeys}
onSelect={this.onSelect} onCheck={this.onCheck}
>
<TreeNode title='parent 1' key='0-0'>
<TreeNode title={customLabel} key='0-0-0'>
update to antd3.8.3 (#159) * refactor: align * feat: update align to 2.4.3 * feat: update trigger 2.5.4 * feat: update tooltip 3.7.2 * fix: align * feat: update vc-calendar to 9.6.2 * feat: update vc-checkbox to 2.1.5 * feat: update vc-dialog to 7.1.8 * feat: update vc-from to 2.2.1 * feat: update vc-notification to 3.1.1 * test: update snapshots * feat: update vc-tree to 1.12.6 * feat: update vc-table to 6.2.8 * feat: update vc-upload to 2.5.1 * feat: update vc-input-number to 4.0.12 * feat: update vc-tabs to 9.2.6 * refactor: vc-menu * refactor: update vc-menu to 7.0.5 * style: remove unused * feat: update pagination to 1.16.5 * feat: add vc-progress 2.2.5 tag * feat: add vc-rate 2.4.0 tag * feat: update vc-slider to 8.6.1 * fix: tooltip error * style: delete conosle * feat: update vc-steps to 3.1.1 * add vc-switch tag 1.6.0 * feat: update upload to 2.5.1 * fix: update vc-menu * fix: update store * fix: add ref dir * fix: trigger mock shouldComponentUpdate * fix: update vc-select * revert: trigger lazyrenderbox * fix: update vc-select * fix: update vc-select * fix: update vc-select * fix: update vc-menu * fix: update vc-slick ref * update style to 3.8.2 * test: update snapshots * update vc-select * update util & affix * feat: add drawer * fix: support title add slot mode * test: update affix test * update alert * update anchor * update snapshots * fix: doc and vc-drawer * update select & auto-complete * update back-top & grid * feractor: avatar * test: add drawer test * update badge * update button * update card * update divider * feat: update vc-tabs to 9.3.6 and tabs * add afterEnter callback * update form * fix: update drawer * test: update snapshots * update modal & notification * test: update snapshots * update message * update locale-provider * update dropdown * update layout popconfirm popover * update time-picker * update menu * update date-picker * docs: update input docs * update input * update snapshots * update table * update test snapshots * feat: update progress * update checkbox * feat: update spin * update radio * docs: slider steps timeline * update list * update transfer * update collapse * update cascader * update upload
2018-09-05 13:28:54 +00:00
<TreeNode title='leaf' key='0-0-0-0' style={{ background: 'rgba(255, 0, 0, 0.1)' }} />
2018-03-24 09:12:22 +00:00
<TreeNode title='leaf' key='0-0-0-1' />
</TreeNode>
<TreeNode title='parent 1-1' key='0-0-1'>
<TreeNode title='parent 1-1-0' key='0-0-1-0' disableCheckbox />
<TreeNode title='parent 1-1-1' key='0-0-1-1' />
</TreeNode>
<TreeNode title='parent 1-2' key='0-0-2' disabled>
<TreeNode title='parent 1-2-0' key='0-0-2-0' disabled />
<TreeNode title='parent 1-2-1' key='0-0-2-1' />
</TreeNode>
</TreeNode>
2018-09-26 14:57:01 +00:00
</Tree> */}
2018-03-24 09:12:22 +00:00
<h2>Check on Click TreeNode</h2>
<Tree
class='myCls'
showLine
checkable
selectable={ false }
defaultExpandAll
onExpand={this.onExpand}
defaultSelectedKeys={this.defaultSelectedKeys}
defaultCheckedKeys={this.defaultCheckedKeys}
onSelect={this.onSelect}
onCheck={this.onCheck}
2018-09-26 14:57:01 +00:00
treeData={treeData}
/>
2018-03-24 09:12:22 +00:00
</div>)
},
}