re commit
This commit is contained in:
@@ -0,0 +1,138 @@
|
||||
import React from 'react';
|
||||
import {
|
||||
Container,
|
||||
Segment,
|
||||
Form,
|
||||
Input,
|
||||
Button,
|
||||
Checkbox,
|
||||
Grid
|
||||
} from 'semantic-ui-react';
|
||||
import {getRequest} from '../../../actions';
|
||||
import UnitItem from './UnitItem';
|
||||
|
||||
const defState = {
|
||||
groups: {},
|
||||
edit: {
|
||||
active: false,
|
||||
name: '',
|
||||
type: 'ln',
|
||||
op: '',
|
||||
id1: {
|
||||
st: '',
|
||||
list: [],
|
||||
data: {}
|
||||
},
|
||||
id2: {
|
||||
st: '',
|
||||
list: [],
|
||||
data: {}
|
||||
}
|
||||
}
|
||||
}
|
||||
const gtype = {
|
||||
lc: {
|
||||
type: 'lc',
|
||||
id: '',
|
||||
op: '',
|
||||
value: ''
|
||||
},
|
||||
ln: {
|
||||
type: 'ln'
|
||||
}
|
||||
}
|
||||
|
||||
class ActionLinkAdd extends React.Component {
|
||||
state = {
|
||||
...defState
|
||||
}
|
||||
|
||||
getSelectList = (unit, type = '') => {
|
||||
if (!unit) {
|
||||
return;
|
||||
}
|
||||
let edit = {
|
||||
...this.state.edit
|
||||
};
|
||||
if (!(unit in edit)) {
|
||||
return;
|
||||
}
|
||||
edit[unit].st = type;
|
||||
edit[unit].data = {
|
||||
...gtype.lc
|
||||
}
|
||||
if (type != 'di' && type != 'leone') {
|
||||
return this.setState({edit});
|
||||
}
|
||||
|
||||
if (type == 'di' || type == 'leone') {
|
||||
this.props.toggleLoading(1);
|
||||
let json = {
|
||||
type
|
||||
};
|
||||
fetch('/api/system/getselectlist', getRequest(json))
|
||||
.then(response => response.json())
|
||||
.then(json => {
|
||||
if (json.status != 1)
|
||||
return this.props.showDialog(json.message);
|
||||
edit[unit].list = json.data.record || [];
|
||||
this.setState({edit}, () => {
|
||||
this.props.toggleLoading(0);
|
||||
});
|
||||
});
|
||||
}
|
||||
if(type == 'unit') {
|
||||
let list = [];
|
||||
for(let i in this.state.groups){
|
||||
list.push({id: i, name: this.state.groups[i].name});
|
||||
}
|
||||
edit[unit].list = list;
|
||||
edit[unit].data = {
|
||||
...gtype.ln
|
||||
}
|
||||
this.setState({edit})
|
||||
}
|
||||
}
|
||||
|
||||
render() {
|
||||
|
||||
return (
|
||||
<Container>
|
||||
<Form as={Segment}>
|
||||
<Form.Field>
|
||||
<Checkbox label="啟用連動"/>
|
||||
</Form.Field>
|
||||
<Form.Field>
|
||||
<label>建立條件群組</label>
|
||||
<Segment color="red">
|
||||
<Form.Field>
|
||||
<Input label="節點名稱"/>
|
||||
</Form.Field>
|
||||
<Form.Field>
|
||||
<label>觸發條件</label>
|
||||
<select>
|
||||
<option value="">請選擇觸發條件</option>
|
||||
<option value="8">AND</option>
|
||||
<option value="9">OR</option>
|
||||
</select>
|
||||
</Form.Field>
|
||||
<Grid columns={2} padded>
|
||||
<UnitItem unit="id1" data={this.state.edit.id1} getList={this.getSelectList}/>
|
||||
<UnitItem unit="id2" data={this.state.edit.id2} getList={this.getSelectList}/>
|
||||
</Grid>
|
||||
<div
|
||||
style={{
|
||||
textAlign: 'right'
|
||||
}}>
|
||||
<Button type="button" basic size="tiny" color="blue" content="加入"/>
|
||||
<Button type="button" basic size="tiny" color="green" content="清除"/>
|
||||
</div>
|
||||
</Segment>
|
||||
</Form.Field>
|
||||
</Form>
|
||||
</Container>
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
export default ActionLinkAdd;
|
||||
Reference in New Issue
Block a user