1.设置模态框
需求:点击离职单选框时下面角色栏的按钮被禁用。
点击角色栏管理员单选框时出现权限选择框。


2.需求:模态框弹出再次点击,填写过的内容清空
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.点击复制链接时,复制框内内容

实现代码如下:
/**
* 点击复制链接按钮时复制框内内容
*/
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('复制成功');//点击复制之后提示复制成功
}
document.execCommand("Copy");
if (document.selection) {
document.selection.empty();
} else if (window.getSelection) {
window.getSelection().removeAllRanges();
}
}

网友评论