update modbus db and view
This commit is contained in:
@@ -5,13 +5,16 @@ const DeviceListItem = ({i18n, idx, data, delModbus, editModbus, showDev, select
|
||||
|
||||
return (
|
||||
<List.Item active={data.uid == showDev}>
|
||||
<span style={{cursor: 'pointer'}} onClick={() => {
|
||||
selectDevToShow(data.uid);
|
||||
}}>
|
||||
{data.name} / Node:{data.node}
|
||||
</span>
|
||||
<Icon style={{cursor: 'pointer'}} name="trash" onClick={()=>{delModbus(data.uid || '')}}/>
|
||||
<Icon style={{cursor: 'pointer'}} name="write" onClick={()=>{editModbus(1, data)}}/>
|
||||
<Icon style={{cursor: 'pointer'}} name="trash" title="Delete" onClick={()=>{delModbus(data.uid || '')}}/>
|
||||
<Icon style={{cursor: 'pointer'}} name="write" title="Edit" onClick={()=>{editModbus(1, data)}}/>
|
||||
<List.Content style={{cursor: 'pointer'}} onClick={() => {
|
||||
selectDevToShow(data.uid);
|
||||
}}>
|
||||
<List.Header>
|
||||
{data.name}
|
||||
</List.Header>
|
||||
Node: {data.node} / Type: {data.type}
|
||||
</List.Content>
|
||||
</List.Item>
|
||||
)
|
||||
}
|
||||
|
||||
@@ -17,6 +17,7 @@ const IOModal = ({i18n, open, type, data, onSubmit, onClose}) => {
|
||||
id: data.uid || '',
|
||||
addr: '',
|
||||
num: '',
|
||||
datalen: '',
|
||||
type: ''
|
||||
};
|
||||
|
||||
@@ -26,6 +27,8 @@ const IOModal = ({i18n, open, type, data, onSubmit, onClose}) => {
|
||||
if(num && 'value' in num) json.num = num.value;
|
||||
let type = e.querySelector('select[name="io_type"]');
|
||||
if(type && 'value' in type) json.type = type.value;
|
||||
let len = e.querySelector('input[name="datalen"]');
|
||||
if(len && 'value' in len) json.datalen = len.value;
|
||||
|
||||
return json;
|
||||
}}>
|
||||
@@ -41,10 +44,13 @@ const IOModal = ({i18n, open, type, data, onSubmit, onClose}) => {
|
||||
</select>
|
||||
</Form.Field>
|
||||
<Form.Field>
|
||||
<Input name="addr" label="起始位址" defaultValue={data.addr || ''} />
|
||||
<Input name="addr" label="起始位址" defaultValue={data.addr} />
|
||||
</Form.Field>
|
||||
<Form.Field>
|
||||
<Input name="num" label="數量" defaultValue={data.num || ''} />
|
||||
<Input name="num" label="數量" defaultValue={data.num} />
|
||||
</Form.Field>
|
||||
<Form.Field>
|
||||
<Input name="datalen" label="資料長度" defaultValue={data.datalen} placeholder="長度不填則預設2"/>
|
||||
</Form.Field>
|
||||
<Grid columns={2}>
|
||||
<Grid.Column>
|
||||
|
||||
@@ -54,7 +54,8 @@ class IOPanel extends React.Component {
|
||||
<Table.Header>
|
||||
<Table.Row>
|
||||
<Table.HeaderCell>起始位置</Table.HeaderCell>
|
||||
<Table.HeaderCell>接口數量</Table.HeaderCell>
|
||||
<Table.HeaderCell>讀取數量</Table.HeaderCell>
|
||||
<Table.HeaderCell>資料長度</Table.HeaderCell>
|
||||
<Table.HeaderCell>操作</Table.HeaderCell>
|
||||
</Table.Row>
|
||||
</Table.Header>
|
||||
|
||||
@@ -7,6 +7,7 @@ const IOPanelListItem = ({i18n, data, ioModal, delIOList, showAIOSet}) => {
|
||||
<Table.Row>
|
||||
<Table.Cell>{data.addr}</Table.Cell>
|
||||
<Table.Cell>{data.num}</Table.Cell>
|
||||
<Table.Cell>{data.datalen}</Table.Cell>
|
||||
<Table.Cell>
|
||||
<Button type="button" basic content="修改" onClick={()=>{ioModal(1, data)}}/>
|
||||
<Button type="button" basic content="刪除" onClick={()=>{delIOList(data.uid || '')}}/>
|
||||
|
||||
@@ -15,6 +15,7 @@ const ModbusModal = ({i18n, open, type, data, onSubmit, onClose}) => {
|
||||
let json = {
|
||||
name: '',
|
||||
node: '',
|
||||
type: '',
|
||||
id: data.uid || '',
|
||||
original_node: data.node || ''
|
||||
};
|
||||
@@ -23,6 +24,8 @@ const ModbusModal = ({i18n, open, type, data, onSubmit, onClose}) => {
|
||||
if(n && 'value' in n) json.name = n.value;
|
||||
let nn = e.querySelector('input[name="node"]');
|
||||
if(nn && 'value' in nn) json.node = nn.value;
|
||||
let type = e.querySelector('input[name="type"]');
|
||||
if(type && 'value' in type) json.type = type.value;
|
||||
|
||||
return json ;
|
||||
}}>
|
||||
@@ -30,7 +33,10 @@ const ModbusModal = ({i18n, open, type, data, onSubmit, onClose}) => {
|
||||
<Input name="name" defaultValue={data.name || ''} label="Name"/>
|
||||
</Form.Field>
|
||||
<Form.Field>
|
||||
<Input name="node" defaultValue={data.node || ''} label="Node"/>
|
||||
<Input name="node" defaultValue={data.node} label="Node"/>
|
||||
</Form.Field>
|
||||
<Form.Field>
|
||||
<Input name="type" defaultValue={data.type} label="Type" placeholder="預設請留空"/>
|
||||
</Form.Field>
|
||||
<Grid columns={2}>
|
||||
<Grid.Column>
|
||||
|
||||
@@ -101,6 +101,7 @@ class ModbusPage extends React.Component {
|
||||
submitIOModal = (type, data) => {
|
||||
let {i18n} = this.props;
|
||||
if((type == 1 && !data.id) || !('addr' in data) || !('num' in data) || !('type' in data)) return this.props.showDialog(i18n.t('tip.input_empty'));
|
||||
if(data.datalen == 0) return this.props.showDialog('資料長度不能為0');
|
||||
|
||||
data.devuid = this.state.showDev;
|
||||
if(type == 1){
|
||||
|
||||
Reference in New Issue
Block a user