Commit 39dd87a9 authored by 李纪文's avatar 李纪文

feat: 组态、mqtt组件增加订阅mqtt传参

parent 85880263
...@@ -20,6 +20,7 @@ group: ...@@ -20,6 +20,7 @@ group:
| mqttSsl | 是否加密 | bool | false | | mqttSsl | 是否加密 | bool | false |
| siteCode | 站点编码 | string | - | | siteCode | 站点编码 | string | - |
| devices | 设备编码集合 | array | [] | | devices | 设备编码集合 | array | [] |
| params | Mqtt 订阅参数传递 | object | {} |
| callback | 订阅的回调 | function(value,code,topic){ } | function(){} | | callback | 订阅的回调 | function(value,code,topic){ } | function(){} |
| controlback | 控制的回调 | function(value,code,topic){ } | function(){} | | controlback | 控制的回调 | function(value,code,topic){ } | function(){} |
......
...@@ -10,6 +10,7 @@ class MqttView { ...@@ -10,6 +10,7 @@ class MqttView {
this.devices = props.devices; this.devices = props.devices;
this.callback = props.callback; this.callback = props.callback;
this.controlback = props.controlback; this.controlback = props.controlback;
this.params = props.params || {};
this.flag = false; this.flag = false;
} }
...@@ -25,11 +26,12 @@ class MqttView { ...@@ -25,11 +26,12 @@ class MqttView {
path = this.mqttPath, path = this.mqttPath,
userName = 'admin', userName = 'admin',
password = 'public'; password = 'public';
const queryStr = this.toQueryString(this.params);
this.saveWaCount = 0; this.saveWaCount = 0;
this.saveWaClient = new MqttClient.Client( this.saveWaClient = new MqttClient.Client(
hostname, hostname,
port, port,
`${path}?_site=${this.siteCode}`, `${path}?_site=${this.siteCode}${queryStr ? '&' + queryStr : ''}`,
clientId, clientId,
); );
this.saveWaOptions = { this.saveWaOptions = {
...@@ -155,6 +157,13 @@ class MqttView { ...@@ -155,6 +157,13 @@ class MqttView {
}) })
.toUpperCase(); .toUpperCase();
} }
// 转为url参数
toQueryString(obj) {
return Object.keys(obj)
.map((key) => encodeURIComponent(key) + '=' + encodeURIComponent(obj[key]))
.join('&');
}
} }
MqttView.propTypes = { MqttView.propTypes = {
...@@ -163,6 +172,7 @@ MqttView.propTypes = { ...@@ -163,6 +172,7 @@ MqttView.propTypes = {
mqttSsl: PropTypes.bool, mqttSsl: PropTypes.bool,
siteCode: PropTypes.string, siteCode: PropTypes.string,
devices: PropTypes.array, devices: PropTypes.array,
params: PropTypes.object,
callback: PropTypes.func, callback: PropTypes.func,
controlback: PropTypes.func, controlback: PropTypes.func,
}; };
...@@ -173,6 +183,7 @@ MqttView.defaultProps = { ...@@ -173,6 +183,7 @@ MqttView.defaultProps = {
mqttSsl: false, mqttSsl: false,
siteCode: '', siteCode: '',
devices: [], devices: [],
params: {},
callback: () => {}, callback: () => {},
controlback: () => {}, controlback: () => {},
}; };
......
...@@ -36,6 +36,7 @@ group: ...@@ -36,6 +36,7 @@ group:
| isZoom | 是否可缩放(手持上建议设置 true) | boolean | false | | isZoom | 是否可缩放(手持上建议设置 true) | boolean | false |
| flowShow | 是否水流效果(无数据表现) | boolean | true | | flowShow | 是否水流效果(无数据表现) | boolean | true |
| messaged | 传递信息给组态 | object | {} | | messaged | 传递信息给组态 | object | {} |
| params | Mqtt 订阅参数传递 | object | {} |
| customBack | 自定义交互的回调,返回点击的模型 | function(node){} | - | | customBack | 自定义交互的回调,返回点击的模型 | function(node){} | - |
### 工艺回放 ### 工艺回放
......
...@@ -999,6 +999,7 @@ const ConfigurationView = (props) => { ...@@ -999,6 +999,7 @@ const ConfigurationView = (props) => {
mqttSsl: globalConfig.mqtt_IsSSL, mqttSsl: globalConfig.mqtt_IsSSL,
siteCode: globalConfig?.mqtt_mess?.site_code || '', siteCode: globalConfig?.mqtt_mess?.site_code || '',
devices: devicesCode, devices: devicesCode,
params: props.params || {},
callback: refreshData, callback: refreshData,
controlback: controlData, controlback: controlData,
}) })
...@@ -3328,6 +3329,7 @@ ConfigurationView.defaultProps = { ...@@ -3328,6 +3329,7 @@ ConfigurationView.defaultProps = {
isZoom: false, isZoom: false,
flowShow: true, flowShow: true,
messaged: {}, messaged: {},
params: {},
customBack: () => {}, customBack: () => {},
}; };
...@@ -3339,6 +3341,7 @@ ConfigurationView.propTypes = { ...@@ -3339,6 +3341,7 @@ ConfigurationView.propTypes = {
isZoom: PropTypes.bool, isZoom: PropTypes.bool,
flowShow: PropTypes.bool, flowShow: PropTypes.bool,
messaged: PropTypes.object, messaged: PropTypes.object,
params: PropTypes.object,
customBack: PropTypes.func, customBack: PropTypes.func,
}; };
......
...@@ -12,17 +12,21 @@ const Demo = () => { ...@@ -12,17 +12,21 @@ const Demo = () => {
<> <>
<div style={{ width: '100%', height: '600px', background: '#242835' }}> <div style={{ width: '100%', height: '600px', background: '#242835' }}>
<PandaConfiguration <PandaConfiguration
name={name} // name={name}
devices={devices.split(',')} // devices={devices.split(',')}
// name={'崇左丽江水厂原水泵房'} name={'崇左丽江水厂原水泵房'}
// devices={'EQZT00000007,CPBA00000001,CPAA00000001,EQZT00000008,CPDA00000001,CPAD00000001,LJSC00000002,EQZT00000005,EQZT00000004,EQZT00000002,EQZT00000003'.split( devices={'EQZT00000007,CPBA00000001,CPAA00000001,EQZT00000008,CPDA00000001,CPAD00000001,LJSC00000002,EQZT00000005,EQZT00000004,EQZT00000002,EQZT00000003'.split(
// ',', ',',
// )} )}
// name={'丽江水厂原水提升泵D单元'} // name={'丽江水厂原水提升泵D单元'}
// devices={'CPAA00000001, CPAD00000001, LJSC00000002'.split(',')} // devices={'CPAA00000001, CPAD00000001, LJSC00000002'.split(',')}
config={globalConfig} config={globalConfig}
deviceName={['工艺流程1', '工艺流程2', '工艺流程3']} deviceName={['工艺流程1', '工艺流程2', '工艺流程3']}
messaged={messaged} messaged={messaged}
params={{
name: '1213',
title: 'mqtt参数',
}}
// isZoom={true} // isZoom={true}
// flowShow={false} // flowShow={false}
/> />
......
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