This commit is contained in:
red-deng-deng 2021-11-11 19:18:52 +08:00
commit 40c6a909e6
3 changed files with 35 additions and 47 deletions

View File

@ -9,26 +9,18 @@ import Menu from "../menu/main.js"
constructor(props) {
super(props);
this.state = {
children :props.children
}
}
componentDidUpdate(prevProps,prevState){
if(prevState.children!=this.state.children)
{
console.log("更新")
}
}
render() {
const {labelname,prop,labelwidth,myClassName} = this.props
console.log(222,this.state.children)
return (
<div className ={ myClassName ? myClassName + " form-Item" :"form-Item"} >
<div className="form-label" style={{width: labelwidth ? labelwidth : "180px" }}>
{labelname}
</div>
<div className="form-compontent">
{this.state.children}
{this.props.children}
</div>
</div>
)

View File

@ -17,6 +17,10 @@ export default class form extends React.Component {
rules: props.rules
}
}
componentWillReceiveProps(nextProps) {
this.setState({children: nextProps.children});
this.setState({model: nextProps.model});
}
componentDidMount() {
const dom = ReactDom.findDOMNode(this);
let doms = dom.getElementsByClassName("form-Item");
@ -200,33 +204,6 @@ export default class form extends React.Component {
}
// if (formItem_com.value == "") {
// if (rules_item[j].type == "required") {
// this.removeClasss(item);
// this.isRequired(formItem_com.value, o.className, item, rules_item[j].message);
// }
// } else {
// console.log("规则验证")
// if (rules_item[j].type == "regExp") {
// var regu = rules_item[j].reg;
// var re = new RegExp(regu);
// let s = formItem_com.value;
// if (re.test(s)) {
// console.log("满足")
// this.removeClasss(item)
// } else {
// console.log("不满足")
// this.isRequired(formItem_com.value, o.className, item, rules_item[j].message);
// }
// } else {
// this.removeClasss(item)
// }
// }
}
}
@ -236,7 +213,7 @@ export default class form extends React.Component {
render() {
return ( <
div className = "form" > {
this.state.children
this.props.children
} <
/div>
)

View File

@ -11,12 +11,13 @@ export default class adduserinfo extends React.Component{
super(props)
this.state={
model:{ //数据模型不可少
account:"",
phone:"",
pwd:"",
name:"",
type:"",
reseller:"",
return_id:"",
date_time:""
}
post:"",
station:"",
},
}
}
@ -29,8 +30,26 @@ export default class adduserinfo extends React.Component{
onUploadChange(files){
console.log(files);
};
submit(){
this.refs.form1.validator()
onChange (e) {
let model2 = {...this.model}
model2.station = e;
this.setState({
model:model2
});
};
cancel(){
console.log("取消")
let model2 = { //数据模型不可少
account:"",
phone:"",
pwd:"",
name:"",
post:"",
station:"",
}
this.setState({model:model2});
}
render(){
const options = [
@ -124,13 +143,13 @@ export default class adduserinfo extends React.Component{
<Select options={options} clearable placeholder="请选择岗位" popupWidth="360px" />
</FormItem>
<FormItem prop="station" labelname="角色">
<Select options={options} clearable placeholder="请选择角色" popupWidth="360px" width="520px"/>
<Select options={options} clearable placeholder="请选择角色" value={this.state.model.station} onChange={(e)=>{this.onChange(e)}} popupWidth="360px" width="520px"/>
</FormItem>
<div className="zent-form-actions">
<Button type="primary" onClick={this.submit.bind(this)}>
提交
</Button>
<Button type="normal" htmlType="reset">
<Button type="normal" htmlType="reset" onClick={this.cancel.bind(this)}>
取消
</Button>
</div>