更新key样式选择问题

This commit is contained in:
姜棚 2022-01-24 15:43:08 +08:00
parent 0cbe05e1b9
commit 589f57f288
2 changed files with 131 additions and 74 deletions

View File

@ -204,22 +204,54 @@ export default class add extends React.Component{
this.state.keys.push(step) this.state.keys.push(step)
this.setState({keys:this.state.keys}) this.setState({keys:this.state.keys})
this.setState({isload:true}) this.setState({isload:true})
if(this.refs[this.state.keys[0]].state.model.style == 5) if(this.refs[this.state.keys[0]].state.model.style == 6)
{ {
console.log("白名单")
this.setState({whiteStyle:true})
this.setState({keyStyle:6})
}
else{
this.setState({keyStyle:1})
this.setState({whiteStyle:true}) this.setState({whiteStyle:true})
this.setState({keyStyle:5})
} }
console.log(this.state.keys) console.log(this.state.keys)
} }
onStyleChange(e){ onStyleChange(e){
console.log("状态",e.target.value) console.log("状态",e.target.value)
if(e.target.value == 5) if(e.target.value == 6)
{ {
console.log(77777)
this.setState({whiteStyle:true}) this.setState({whiteStyle:true})
this.setState({keyStyle:5}) this.setState({keyStyle:6})
sessionStorage.setItem("white",1)
for(let i = 0;i < this.state.keys.length;i++)
{
if(this.refs[this.state.keys[i]])
{
if(i > 0)
{
this.refs[this.state.keys[i]].setkeyStyle(6)
}
}
}
} }
else{ else{
this.setState({keyStyle:e.target.value}) console.log(88888,this.refs)
sessionStorage.setItem("white",3)
for(let i = 0;i < this.state.keys.length;i++)
{
if(this.refs[this.state.keys[i]])
{
if(i > 0)
{
this.refs[this.state.keys[i]].setkeyStyle(1)
}
}
}
this.setState({whiteStyle:false}) this.setState({whiteStyle:false})
} }
} }
@ -350,8 +382,11 @@ export default class add extends React.Component{
}> }>
<Step2 ref={item} addNewkey ={()=>{this.addNewkey()}} onStyleChange={(e)=>{this.onStyleChange(e)}} keyStyle={this.state.keyStyle} isload={this.state.isload} name={index} whiteStyle={this.state.whiteStyle} /> <Step2 ref={item} addNewkey ={()=>{this.addNewkey()}} onStyleChange={(e)=>{this.onStyleChange(e)}} keyStyle={this.state.keyStyle} isload={this.state.isload} name={index} whiteStyle={this.state.whiteStyle} />
</Card> </Card>
) : null ) : null
}) })

View File

@ -88,22 +88,17 @@ export default class acclist extends React.Component{
let items = dom.getElementsByClassName("form-Item"); let items = dom.getElementsByClassName("form-Item");
let input = items[1].getElementsByTagName("input")[0]; let input = items[1].getElementsByTagName("input")[0];
input.focus(); input.focus();
//除了主key批次窗口其他都禁用 if(this.props.name > 0)
if(this.props.name > 0) {
{ console.log("key样式", this.props.keyStyle)
this.setState({whiteStyle:this.props.whiteStyle}) this.setState({whiteStyle:this.props.whiteStyle})
if(this.props.keyStyle == 6) this.setState({white_visible:this.props.whiteStyle})
{ let model = this.state.model;
this.setState({white_visible:this.props.whiteStyle}) model.style = this.props.keyStyle;
let model = this.state.model; this.setState({model:model})
model.style = this.props.keyStyle }
this.setState({model:model})
}
}
} }
submit(){ submit(){
@ -123,13 +118,7 @@ export default class acclist extends React.Component{
data.mobile_repeat = this.state.mobile_repeat data.mobile_repeat = this.state.mobile_repeat
console.log("key样式",data.style) console.log("key样式",data.style)
if(data.style == 6)
{
sessionStorage.setItem("white",1)
}
else{
sessionStorage.setItem("white",3)
}
return data; return data;
} }
@ -145,12 +134,20 @@ export default class acclist extends React.Component{
onStyleChange(e){ onStyleChange(e){
if(this.props.name == 0)
{
this.props.onStyleChange(e)
}
this.props.onStyleChange(e)
let model2 = this.state.model; let model2 = this.state.model;
model2.style = e.target.value; model2.style = e.target.value;
model2.quantity = 0 model2.quantity = 0
this.setState({model:model2}) this.setState({model:model2})
// console.log("生成key",this.state.model)
console.log("")
if(e.target.value == 6) if(e.target.value == 6)
{ {
sessionStorage.setItem("white",1) sessionStorage.setItem("white",1)
@ -243,40 +240,76 @@ export default class acclist extends React.Component{
},500) },500)
} }
} }
// initKeyStyle(){
componentWillReceiveProps(nextProps) { // console.log("初始化")
if(this.state.whiteStyle != nextProps.whiteStyle) // console.log("当前的值")
// }
setkeyStyle(style){
if(style == 6)
{ {
if(this.props.name > 0) this.setState({whiteStyle:true})
{ this.setState({white_visible:true})
this.setState({whiteStyle:nextProps.whiteStyle}) }
} else{
this.setState({whiteStyle:false})
this.setState({white_visible:false})
} }
if(this.state.model.style != nextProps.keyStyle)
{ let model = this.state.model;
model.style = style
this.setState({model:model})
}
componentWillReceiveProps(nextProps) {
// if(this.state.whiteStyle != nextProps.whiteStyle)
// {
// if(this.props.name > 0)
// {
// this.setState({whiteStyle:nextProps.whiteStyle})
// this.setState({white_visible:nextProps.whiteStyle})
// }
// }
// if(this.state.model.style != nextProps.keyStyle)
// {
// if(this.props.name > 0)
// {
// if(nextProps.keyStyle == 6)
// {
// let model = this.state.model;
// model.style = nextProps.keyStyle
// this.setState({model:model})
// console.log(777878)
// }
// }
if(this.props.name > 0) // }
{ // if(this.props.name > 0)
console.log("更改状态") // {
// console.log("更改状态")
let model = this.state.model; // let model = this.state.model;
model.style = nextProps.keyStyle // // model.style = nextProps.keyStyle
this.setState({model:model}) // // this.setState({model:model})
if(model.style == 6) // if(model.style == 6)
{ // {
sessionStorage.setItem("white",1)
this.setState({white_visible:true}) // sessionStorage.setItem("white",1)
} // this.setState({white_visible:true})
else{ // }
sessionStorage.setItem("white",3) // else{
this.setState({white_visible:false}) // console.log(1111)
} // sessionStorage.setItem("white",3)
// this.setState({white_visible:false})
// }
} // }
} // }
} }
onChangeCombinedDate(e){ onChangeCombinedDate(e){
@ -334,7 +367,6 @@ export default class acclist extends React.Component{
quantity:this.state.codeInfo.issued, quantity:this.state.codeInfo.issued,
restrict:this.state.codeInfo.restrict, restrict:this.state.codeInfo.restrict,
range : rank.toString(), range : rank.toString(),
} }
let arr = _.map(productlist,(item)=>{ let arr = _.map(productlist,(item)=>{
@ -358,13 +390,10 @@ export default class acclist extends React.Component{
if(this.state.rowIndex > -1) if(this.state.rowIndex > -1)
{ {
console.log("编辑")
this.state.distdata[this.state.rowIndex] = temp; this.state.distdata[this.state.rowIndex] = temp;
this.setState({distdata:this.state.distdata}) this.setState({distdata:this.state.distdata})
console.log(this.state.distdata)
} }
else{ else{
console.log("新增")
let tempdata = this.state.distdata; let tempdata = this.state.distdata;
tempdata.push(temp) tempdata.push(temp)
this.setState({distdata:tempdata}) this.setState({distdata:tempdata})
@ -390,7 +419,7 @@ export default class acclist extends React.Component{
let step1 = JSON.parse (sessionStorage.getItem("step1")); let step1 = JSON.parse (sessionStorage.getItem("step1"));
let str = moment(val).format("YYYY-MM-DD HH:mm:ss") let str = moment(val).format("YYYY-MM-DD HH:mm:ss")
let isBetween = moment(str).isBetween(step1.begin_time,step1.end_time,null,'(]'); let isBetween = moment(str).isBetween(step1.begin_time,step1.end_time,null,'(]');
return !isBetween return !isBetween
} }
@ -626,21 +655,14 @@ export default class acclist extends React.Component{
let temp = this.state.exceldata.filter(o=>o.type == "success"); let temp = this.state.exceldata.filter(o=>o.type == "success");
console.log("excel数据",this.state.exceldata)
console.log(temp)
let mobile_repeat= _.map(temp,(o)=>{ let mobile_repeat= _.map(temp,(o)=>{
return o.mobile; return o.mobile;
}) })
console.log("手机重复",mobile_repeat)
this.setState({mobile_repeat:mobile_repeat}) this.setState({mobile_repeat:mobile_repeat})
let model = this.state.model; let model = this.state.model;
console.log("重复号码数量",this.state.mobile_repeat.length)
model.quantity = this.state.excel_count - this.state.error_count + mobile_repeat.length; model.quantity = this.state.excel_count - this.state.error_count + mobile_repeat.length;
console.log("数量", model.quantity)
this.setState({model:model}) this.setState({model:model})
this.setState({accessVerify:false}) this.setState({accessVerify:false})
@ -726,7 +748,7 @@ export default class acclist extends React.Component{
resetUpload(){ resetUpload(){
this.setState({excel_visible:false}) this.setState({excel_visible:false})
this.setState({import_visible:true}) this.setState({import_visible:true})
this.setState({accessVerify:true}) this.setState({accessVerify:true})
} }
switchChange(e,rowData){ switchChange(e,rowData){
@ -943,10 +965,10 @@ export default class acclist extends React.Component{
<Form model={this.state.model} rules={rules} ref="form1"> <Form model={this.state.model} rules={rules} ref="form1">
<FormItem labelname=" key样式" prop="style" id="style"> <FormItem labelname=" key样式" prop="style" id="style">
<RadioGroup onChange={(e)=>{ this.onStyleChange(e)} } value={this.state.model.style}> <RadioGroup onChange={(e)=>{ this.onStyleChange(e)} } value={this.state.model.style}>
<RadioButton value={1} disabled={this.props.name > 0 && this.state.model.style ==6} >串码</RadioButton> <RadioButton value={1} disabled={this.props.name > 0 && this.state.model.style == 6 } >串码</RadioButton>
<RadioButton value={2} disabled={this.props.name > 0 && this.state.model.style ==6} >链接</RadioButton> <RadioButton value={2} disabled={this.props.name > 0 && this.state.model.style == 6 } >链接</RadioButton>
<RadioButton value={4} disabled={this.props.name > 0 && this.state.model.style ==6} >二维码</RadioButton> <RadioButton value={4} disabled={this.props.name > 0 && this.state.model.style == 6 } >二维码</RadioButton>
<RadioButton value={6} disabled={this.props.name > 0 && this.state.model.style !=6} >白名单</RadioButton> <RadioButton value={6} disabled={this.props.name > 0 && this.state.model.style != 6 } >白名单</RadioButton>
</RadioGroup> </RadioGroup>
</FormItem> </FormItem>