update action link add page

This commit is contained in:
Jay
2017-04-18 09:24:41 +08:00
parent eb6b8d9ad5
commit 26f669fb96
14 changed files with 3400 additions and 1608 deletions
@@ -38,7 +38,9 @@ const stateDefault = () => ({
id2: {
unit: '',
data: {}
}
},
name: '',
op: ''
})
const lcDef = () => ({
@@ -92,7 +94,79 @@ class ConditionField extends React.Component {
}
joinGroup = () => {
console.log(this.state);
let id1 = {...this.state.id1};
let id2 = {...this.state.id2};
let {showDialog, addNewGroup} = this.props;
if(!('type' in id1.data)){
showDialog('請選擇元件');
}else{
if(id1.data.type == 'lc') {
let chk = this.checkLC(id1.data);
if(chk.status != 1) return showDialog(chk.message);
}else{
let chk = this.checkLN(id1.data);
if(chk.status != 1) return showDialog(chk.message);
}
}
if(!('type' in id2.data)){
showDialog('請選擇元件');
}else{
if(id2.data.type == 'lc') {
let chk = this.checkLC(id2.data);
if(chk.status != 1) return showDialog(chk.message);
}else{
let chk = this.checkLN(id2.data);
if(chk.status != 1) return showDialog(chk.message);
}
}
if(!this.state.op) return showDialog('請選擇條件');
if(!this.state.name) return showDialog('請輸入名稱');
addNewGroup({
name: this.state.name,
op: this.state.op,
type: 'lc',
id1: id1.data,
id2: id2.data
}, this.clearField);
}
changeState = (tag, value) => {
if(!tag) return ;
if(tag == 'name'){
this.setState({
name: value
})
}
if(tag == 'op'){
this.setState({
op: value
})
}
}
checkLC = (data) => {
let json = {
status: 0,
message: ''
};
if(typeof data != 'object' || Object.keys(data).length == 0) return {...json, message: '請選擇元件'};
if(!data.id) return {...json, message: '請選擇裝置'};
if(!('op' in data) || data.op == '') return {...json, message: '請選擇條件'};
if(!('value' in data) || data.value == '') return {...json, message: '請輸入數值'};
return {...json, status: 1}
}
checkLN = (data) => {
let json = {
status: 0,
message: ''
};
if(typeof data != 'object' || Object.keys(data).length == 0) return {...json, message: '請選擇元件'};
if(!data.dev) return {...json, message: '請選擇群組'};
return {...json, status: 1};
}
render() {
@@ -100,11 +174,11 @@ class ConditionField extends React.Component {
return (
<Segment color="red">
<Form.Field>
<Input label="節點名稱" />
<Input label="節點名稱" value={this.state.name} onChange={(e,d)=>{ this.changeState('name', d.value) }} />
</Form.Field>
<Form.Field>
<label>觸發條件</label>
<select>
<select value={this.state.op} onChange={e=>{this.changeState('op', e.target.value)}}>
<option value="">請選擇觸發條件</option>
{
ops.map((t,idx) => {