node-swallowjs
Version:
epp portal
113 lines (112 loc) • 3.65 kB
JSX
var Check = React.createClass({
mixins: [FormMixin],
getInitialState() {
return {
name: '',
phase: 'open',
type: 'avail',
value: ''
}
},
getName() {
return this.props.obj==='launch'
? {
name: SPLIT(this.state.name),
phase: this.state.phase,
type: this.state.type
}
: SPLIT(this.state.name);
},
handleSubmit(e) {
api.check(this.props.obj==='launch' ? 'domain' : this.props.obj, this.getName(), function(code, data) {
switch(code) {
case '2501':
logout();
break;
default:
this.setState({value: data});
}
}.bind(this));
},
render() {
switch(this.props.obj) {
case 'domain':
case 'host':
case 'contact':
return (
<div>
<table align="center" border="0">
<tbody>
<tr>
<td align="center">{this.props.children}</td>
</tr>
<tr>
<td align="center">
<textarea {...this.linkState({
name: 'name',
rows: '4',
cols: '40',
onFocus: this.onSetState({name:'', value:''})
})}/>
</td>
</tr>
<tr>
<td height="16"></td>
</tr>
<tr>
<td align="center">
<input type="button" value="提交" onClick={this.handleSubmit}/>
</td>
</tr>
</tbody>
</table>
<OpResult content={this.state.value} />
</div>
);
case 'launch':
return (
<div>
<table align="center" border="0">
<tbody>
<tr>
<td colSpan="2" align="center">{this.props.children}</td>
</tr>
<tr>
<td>
<textarea {...this.linkState({
name: 'name',
rows: '4',
cols: '40',
onFocus: this.onSetState({name:'', value:''})
})}/>
</td>
<td>
<LaunchPhase {...this.linkState({name: 'phase'})}/><br/>
<input {...this.linkState({
name: 'type',
type: 'radio',
value: 'claims'
})}/>claims<br/>
<input {...this.linkState({
name: 'type',
type: 'radio',
value: 'avail'
})}/>avail<br/>
</td>
</tr>
<tr>
<td colSpan="2" height="16"></td>
</tr>
<tr>
<td colSpan="2" align="center">
<input type="button" value="提交" onClick={this.handleSubmit}/>
</td>
</tr>
</tbody>
</table>
<OpResult content={this.state.value} />
</div>
);
}
}
});