UNPKG

nbugs-pc-select-user

Version:

https://nbugs.yuque.com/front-end/components/project-readme

75 lines (62 loc) 1.88 kB
/* eslint-disable no-console */ import React from 'react'; import ReactDOM from 'react-dom'; import SelectUser from './component'; const APIEnv = 'dev'; // production/dev/test class Test extends React.Component { constructor(props) { super(props); this.state = { showSelectUser: false, _selectSignature: '', }; this.handleCancel = this.handleCancel.bind(this); } componentDidMount() { // setTimeout(() => { // this.setState({ // showSelectUser: true, // _selectSignature: '', // }); // }, 3000); } handleConfirm = ({ selectSignature = '', deptList = [], userList = [] } = {}) => { this.setState({ showSelectUser: false, _selectSignature: selectSignature, }); console.log('TCL: Test -> handleConfirm -> userList', userList); console.log('TCL: Test -> handleConfirm -> deptList', deptList); console.log('TCL: Test -> handleConfirm -> selectSignature', selectSignature); }; getCheckedNodes = ({ deptList, userList }) => { console.log('TCL: getCheckedNodes -> userList', userList); console.log('TCL: getCheckedNodes -> deptList', deptList); }; handleCancel() { this.setState({ showSelectUser: false, }); } render() { const { showSelectUser, _selectSignature } = this.state; return ( <div> <div onClick={() => this.setState({ showSelectUser: true })}>点击</div> { showSelectUser && ( <SelectUser selectType="user" showComp={showSelectUser} APIEnv={APIEnv} selectSignature={_selectSignature} getCheckedNodes={this.getCheckedNodes} onCancel={this.handleCancel} onOk={this.handleConfirm} /> )} </div> ); } } ReactDOM.render(<Test />, document.getElementById('root'));