Commit f27a4992 by fukai

支持sequence检验

parent b761e01a
...@@ -15,7 +15,7 @@ import TagSet from "./Tags" ...@@ -15,7 +15,7 @@ import TagSet from "./Tags"
import {DeepCopy,getLogicAdress} from './Utils' import {DeepCopy,getLogicAdress} from './Utils'
import {TagV} from './TagValidater' import {TagV,isTagValueEmpty} from './TagValidater'
import YBIC from './Tags/YBIC' import YBIC from './Tags/YBIC'
...@@ -47,7 +47,7 @@ export class SWFPage extends Component ...@@ -47,7 +47,7 @@ export class SWFPage extends Component
console.log(msg) console.log(msg)
} }
validateAllMessage=(tags,rs)=> validateAllMessage=(tags,rs,seqlist=[])=>
{ {
const mty = this.props.params.mty||this.props.extra.msgtyp const mty = this.props.params.mty||this.props.extra.msgtyp
for(let item of tags) for(let item of tags)
...@@ -58,7 +58,7 @@ export class SWFPage extends Component ...@@ -58,7 +58,7 @@ export class SWFPage extends Component
{ {
item.tagValue = [{},'',{}] item.tagValue = [{},'',{}]
} }
if(!TagV("T"+item.tag,item.status,item.tagValue,item.tno,mty)) if(!TagV("T"+item.tag,item.status,item.tagValue,item.tno,mty,seqlist,this.props.extra.countMap))
{ {
rs.hasError = true rs.hasError = true
console.log(item.tag) console.log(item.tag)
...@@ -68,12 +68,12 @@ export class SWFPage extends Component ...@@ -68,12 +68,12 @@ export class SWFPage extends Component
}else if(item.cyclist) }else if(item.cyclist)
{ {
for(let cyc of item.cycs) for(let cyc of item.cycs)
this.validateAllMessage(cyc,rs) this.validateAllMessage(cyc,rs,seqlist)
} }
else if(item.seqlist) else if(item.seqlist)
{ {
for(let seq of item.seqs) for(let seq of item.seqs)
this.validateAllMessage(seq,rs) this.validateAllMessage(seq,rs,[...seqlist,{status:item.status,seqlist:item.seqlist}])
} }
} }
} }
...@@ -415,7 +415,7 @@ export class SWFPage extends Component ...@@ -415,7 +415,7 @@ export class SWFPage extends Component
</Col> </Col>
<Col span={1} style={{textAlign:'center'}}><span style={{fontWeight:'bolder'}}>{"NO."}</span></Col> <Col span={1} style={{textAlign:'center'}}><span style={{fontWeight:'bolder'}}>{"NO."}</span></Col>
</Row> </Row>
<SWFMessage action={this.props.params.action} enLock={this.props.params.action=='redit'} updateTreeValue={this.props.actions.updateTreeValue} pattern={tags} ref={ref=>this.swfmsg = ref} mty={mty}/> <SWFMessage action={this.props.params.action} extra={this.props.extra} enLock={this.props.params.action=='redit'} updateTreeValue={this.props.actions.updateTreeValue} pattern={tags} ref={ref=>this.swfmsg = ref} mty={mty}/>
</Col> </Col>
<Col span={3}></Col> <Col span={3}></Col>
...@@ -542,11 +542,11 @@ export class MessageArea extends Component{ ...@@ -542,11 +542,11 @@ export class MessageArea extends Component{
{ {
fields.map((item,index)=>{ fields.map((item,index)=>{
if(item.tag) if(item.tag)
return <Tag action={this.props.action} enLock={this.props.enLock} updateTreeValue={this.props.updateTreeValue} pattern={item} key={item.tno} mty={this.props.mty}/> return <Tag extra={this.props.extra} action={this.props.action} enLock={this.props.enLock} updateTreeValue={this.props.updateTreeValue} pattern={item} seqlist={this.props.seqlist} key={item.tno} mty={this.props.mty}/>
if(item.cyclist) if(item.cyclist)
return <CYCList action={this.props.action} enLock={this.props.enLock} updateTreeValue={this.props.updateTreeValue} pattern={item} key={item.cyclist+','+index} mty={this.props.mty}/> return <CYCList extra={this.props.extra} action={this.props.action} enLock={this.props.enLock} updateTreeValue={this.props.updateTreeValue} pattern={item} seqlist={this.props.seqlist} key={item.cyclist+','+index} mty={this.props.mty}/>
if(item.seqlist) if(item.seqlist)
return <SEQList action={this.props.action} enLock={this.props.enLock} updateTreeValue={this.props.updateTreeValue} pattern={item} key={item.seq+','+index} mty={this.props.mty}/> return <SEQList extra={this.props.extra} action={this.props.action} enLock={this.props.enLock} updateTreeValue={this.props.updateTreeValue} pattern={item} seqlist={this.props.seqlist} key={item.seqlist+','+index} mty={this.props.mty}/>
return null return null
}) })
} }
...@@ -655,7 +655,7 @@ export class CYCList extends MessageArea ...@@ -655,7 +655,7 @@ export class CYCList extends MessageArea
{index==0?null: {index==0?null:
<Button style={{position:'absolute',top:'0.35em',zIndex:99}} onClick={()=>this.removeItem(index)} size="small" shape="circle" icon="cross" title="Remove Cycle"/> <Button style={{position:'absolute',top:'0.35em',zIndex:99}} onClick={()=>this.removeItem(index)} size="small" shape="circle" icon="cross" title="Remove Cycle"/>
} }
<Cyc action={this.props.action} updateTreeValue={this.props.updateTreeValue} pattern={cyc} mty={this.props.mty} /> <Cyc extra={this.props.extra} action={this.props.action} seqlist={this.props.seqlist} updateTreeValue={this.props.updateTreeValue} pattern={cyc} mty={this.props.mty} />
</div>) </div>)
}) })
} }
...@@ -738,14 +738,14 @@ export class SEQList extends MessageArea ...@@ -738,14 +738,14 @@ export class SEQList extends MessageArea
addItem=()=>{ addItem=()=>{
let subtree = this.props.pattern let subtree = this.props.pattern
let obj = this.clonePO(subtree.pattern) let obj = this.clonePO(subtree.pattern)
subtree.cycs.push(obj) subtree.seqs.push(obj)
this.props.updateTreeValue() this.props.updateTreeValue()
} }
removeItem=(index)=>{ removeItem=(index)=>{
let subtree = this.props.pattern let subtree = this.props.pattern
subtree.cycs.splice(index,1) subtree.seqs.splice(index,1)
//通知刷新 //通知刷新
this.props.updateTreeValue() this.props.updateTreeValue()
...@@ -759,6 +759,7 @@ export class SEQList extends MessageArea ...@@ -759,6 +759,7 @@ export class SEQList extends MessageArea
output() output()
{ {
let subtree = this.props.pattern let subtree = this.props.pattern
let seqlist = this.props.seqlist?[...this.props.seqlist,{seqlist:subtree.seqlist,status:subtree.status}]:[{seqlist:subtree.seqlist,status:subtree.status}]
return ( return (
<div> <div>
<Row> <Row>
...@@ -782,14 +783,14 @@ export class SEQList extends MessageArea ...@@ -782,14 +783,14 @@ export class SEQList extends MessageArea
{index==0 || subtree.cyccnt==0?null: {index==0 || subtree.cyccnt==0?null:
<Button style={{position:'absolute',top:'0.35em',zIndex:99}} onClick={()=>this.removeItem(index)} size="small" shape="circle" icon="cross" title="Remove Cycle"/> <Button style={{position:'absolute',top:'0.35em',zIndex:99}} onClick={()=>this.removeItem(index)} size="small" shape="circle" icon="cross" title="Remove Cycle"/>
} }
<Seq action={this.props.action} updateTreeValue={this.props.updateTreeValue} pattern={seq} mty={this.props.mty} /> <Seq extra={this.props.extra} action={this.props.action} seqlist={seqlist} updateTreeValue={this.props.updateTreeValue} pattern={seq} mty={this.props.mty} />
</div>) </div>)
}) })
} }
<Row> <Row>
<Col span={1}></Col> <Col span={1}></Col>
<Col> <Col>
<p style={{paddingLeft:'2em',position:'relative',top:'-1.4em'}}><span style={{fontWeight:'bolder',fontSize:'1.5em'}}>{subtree.cyccnt==0?`End Of ${subtree.desp}`:subtree.desp.replace(/^[->]/,'------|')}</span></p> <p style={{paddingLeft:'2em',position:'relative',top:'-1.4em'}}><span style={{fontWeight:'bolder',fontSize:'1.5em'}}>{subtree.cyccnt==0?`End Of ${subtree.desp}`:subtree.desp.replace(/^[-]+>/,'------|')}</span></p>
</Col> </Col>
</Row> </Row>
</div> </div>
...@@ -802,6 +803,7 @@ export class SEQList extends MessageArea ...@@ -802,6 +803,7 @@ export class SEQList extends MessageArea
} }
export class Tag extends MessageArea export class Tag extends MessageArea
{ {
constructor(props) constructor(props)
...@@ -816,16 +818,92 @@ export class Tag extends MessageArea ...@@ -816,16 +818,92 @@ export class Tag extends MessageArea
// }else // }else
// this.name = this.pattern.tag // this.name = this.pattern.tag
// this.state = {name:this.name} // this.state = {name:this.name}
this.state={tagValue:this.props.pattern.tagValue} this.state={tagValue:this.props.pattern.tagValue,isEmpty:this.isEmpty(this.props.pattern.tagValue)}
} }
componentWillMount()
{
if((this.props.action == 'redit' || this.props.action == 'redit2')&& this.props.seqlist)
{
let {countMap={}} = this.props.extra
for(let seqlbl of this.props.seqlist )
{
let key = seqlbl.seqlist
if(!countMap[key])
countMap[key] = 1
else
countMap[key]++
}
this.props.extra.countMap = countMap
}
}
componentWillUnmount()
{
if(this.props.seqlist)
{
let val = this.state.tagValue
let mval = val && val.length? val[1] : ''
if(!mval)
return
let {countMap} = this.props.extra
if(!countMap)
return
for(let seqlbl of this.props.seqlist )
{
let key = seqlbl.seqlist
if(countMap[key])
countMap[key]--
}
}
}
isEmpty(tagValue)
{
if(!tagValue)
return true
return isTagValueEmpty("T"+this.props.pattern.tag,tagValue)
}
output() output()
{ {
let comp = TagSet("T"+this.props.pattern.tag,{action:this.props.action,enLock:this.props.enLock,mty:this.props.mty,status:this.props.pattern.status,value:this.props.pattern.tagValue,desp:this.props.pattern.label}, let comp = TagSet("T"+this.props.pattern.tag,{action:this.props.action,enLock:this.props.enLock,mty:this.props.mty,status:this.props.pattern.status,value:this.props.pattern.tagValue,desp:this.props.pattern.label},
val=>{ val=>{
this.props.pattern.tagValue = val this.props.pattern.tagValue = val
TagV("T"+this.props.pattern.tag,this.props.pattern.status,val,this.props.pattern.tno,this.props.mty) let {status} = this.props.pattern
this.setState({tagValue:this.props.pattern.tagValue}) let {countMap} = this.props.extra
if(this.props.seqlist)
{
if(!countMap)
{
countMap = {}
this.props.extra.countMap = countMap
}
// let mval = val && val.length? val[1] : ''
let val_old = this.state.tagValue
// let mval_old = val_old && val_old.length? val_old[1] : ''
if(!this.state.isEmpty && this.isEmpty(val))
{
for(let seqlbl of this.props.seqlist ) //计数减1
{
let key = seqlbl.seqlist
if(countMap[key])
countMap[key]--
}
}
else if(this.state.isEmpty && !this.isEmpty(val))
{
for(let seqlbl of this.props.seqlist ) //计算加1
{
let key = seqlbl.seqlist
if(!countMap[key])
countMap[key]=1
else
countMap[key]++
}
}
}
TagV("T"+this.props.pattern.tag,status,val,this.props.pattern.tno,this.props.mty,this.props.seqlist,this.props.extra.countMap)
this.setState({tagValue:this.props.pattern.tagValue,isEmpty:this.isEmpty(this.props.pattern.tagValue)})
//this.props.updateTreeValue() //this.props.updateTreeValue()
} }
) )
......
import {RegMap} from './TagRegMap' import {RegMap} from './TagRegMap'
export function TagV(tag,status,value,tno,mty) export function isTagValueEmpty(tag,tagValue)
{
let obj = tagValue[0]
let regobj = RegMap[tag]
for(let key in regobj)
{
if(obj[key])
return false
}
return true
}
export function TagV(tag,status,value,tno,mty,seqlist,countMap={})
{ {
let regobj = RegMap[tag] let regobj = RegMap[tag]
let obj = value[0] let obj = value[0]
let mval = value[1] let mval = value[1]
//计算状态 status,是否是必填的,要参考所在序列是否是必填,上一层序列计数,来决定当前序列是否必填
if(seqlist && seqlist.length && status == 'M' && isTagValueEmpty(tag,value))
{
let curseq = seqlist[seqlist.length - 1]
let curcnt = countMap[curseq.seqlist] || 0
if(curseq.status == 'O' && curcnt==0)
{
status = 'O'
}
else if(curseq.status == 'M' && curcnt==0)
{
//验证上层是否有计数为O,且上层计数
for(let i = seqlist.length - 2 ; i >=0;i--)
{
let itemseq = seqlist[i]
let itemcnt = countMap[itemseq.seqlist] || 0
if(itemcnt>0)
break
if(itemseq.status == 'O' && itemcnt == 0)
status = 'O'
}
}
}
let errmsg = null let errmsg = null
if(value.length == 3) if(value.length == 3)
errmsg = value[2] || {} errmsg = value[2] || {}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment