1.設(shè)置模態(tài)框
需求:點(diǎn)擊離職單選框時下面角色欄的按鈕被禁用。
點(diǎn)擊角色欄管理員單選框時出現(xiàn)權(quán)限選擇框护戳。
2.需求:模態(tài)框彈出再次點(diǎn)擊菱农,填寫過的內(nèi)容清空
class AddPosition extends Component {
constructor(props){
super(props);
this.state = {
position: '',
}
}
onClean = () => {
this.setState({
position: '',
});
}
handleCancel = () => {
this.onClean();
this.props.handleCancel();
}
handleOk = () => {
this.onClean();
this.props.handleOk();
}
render(){
const { position } = this.state;
return(
<Modal
title="添加職位"
visible={this.props.visible}
onOk={this.handleOk}
onCancel={this.handleCancel}
className="addModal"
>
<div className="input">
<span className="editspan">職位名稱:</span>
<Input placeholder="請輸入職位名稱" value={position}
onChange = {(e) => this.setState({position: e.target.value})}
/>
</div>
</Modal>
)
}
}
export default connect(({ }) => ({
}))(AddPosition);
3.點(diǎn)擊復(fù)制鏈接時炕淮,復(fù)制框內(nèi)內(nèi)容
實(shí)現(xiàn)代碼如下:
/**
* 點(diǎn)擊復(fù)制鏈接按鈕時復(fù)制框內(nèi)內(nèi)容
*/
copyLink = () => {
//console.log(this.refs.fetchSignUpLink)
if (document.body.createTextRange) {
var range = document.body.createTextRange();
range.moveToElementText(this.refs.fetchSignUpLink);
range.select();
} else if (window.getSelection) {
var selection = window.getSelection();
var range = document.createRange();
range.selectNodeContents(this.refs.fetchSignUpLink);
selection.removeAllRanges();
selection.addRange(range);
message.success('復(fù)制成功');//點(diǎn)擊復(fù)制之后提示復(fù)制成功
}
document.execCommand("Copy");
if (document.selection) {
document.selection.empty();
} else if (window.getSelection) {
window.getSelection().removeAllRanges();
}
}