Commit cb770c0bd6da425ce0fe3d2f5a6688f283d515f5
Merge branch 'fix/DEFECT-1435' into 'main_dev'
Fix/defect 1435 See merge request yunteng/thingskit-scada!94
Showing
1 changed file
with
15 additions
and
7 deletions
| ... | ... | @@ -7750,7 +7750,7 @@ DataFormatPanel.prototype.addDataFont = function (container) { | 
| 7750 | 7750 | } | 
| 7751 | 7751 | } | 
| 7752 | 7752 | } else if (commandType === COMMAND_TYPE_ENUM.MODBUS) { | 
| 7753 | - const dataSource = currentNodeData?.dataSources?.[0] | |
| 7753 | + const dataSource = currentNodeData?.dataSources?.[0] || getDataSourceBindValue() | |
| 7754 | 7754 | if (dataSource) { | 
| 7755 | 7755 | const additional = dataSource?.additional || {} | 
| 7756 | 7756 | if (dataSource?.deviceType !== 'SENDOR' && !additional?.deviceCode) { | 
| ... | ... | @@ -8004,7 +8004,6 @@ DataFormatPanel.prototype.addDataFont = function (container) { | 
| 8004 | 8004 | const stringValue = JSON.stringify(defaultValue, null, 2) | 
| 8005 | 8005 | editor.insert(stringValue) | 
| 8006 | 8006 | $(`#${enumActionEl.EDITOR_CONTAINER}`).parent().find(`textarea[name="${enumConst.JSON_COMMAND}"]`).val(stringValue) | 
| 8007 | - console.log($(`#${enumActionEl.EDITOR_CONTAINER}`).parent().find(`textarea[name="${enumConst.JSON_COMMAND}"]`).val()) | |
| 8008 | 8007 | editor.session.setMode("ace/mode/json"); | 
| 8009 | 8008 | editor.getSession().on('change', (event, editor) => { | 
| 8010 | 8009 | $(`#${enumActionEl.EDITOR_CONTAINER}`).parent().find(`textarea[name="${enumConst.JSON_COMMAND}"]`).val(editor.getValue()) | 
| ... | ... | @@ -14702,6 +14701,7 @@ class DispatchCenter { | 
| 14702 | 14701 | const { devicesInfo, autoPlay, interval, startTime, endTime } = sourceOption || {} | 
| 14703 | 14702 | const node = allCell.find(item => item.id === nodeId) | 
| 14704 | 14703 | const deviceIds = UseLayUi.parseStringToJSON(devicesInfo, []).map(item => item.deviceId) | 
| 14704 | + if (!node) continue | |
| 14705 | 14705 | const id = node.getAttribute(UUID) | 
| 14706 | 14706 | const element = document.getElementById(id) | 
| 14707 | 14707 | if (element) { | 
| ... | ... | @@ -16132,14 +16132,15 @@ class HandleDataInteraction { | 
| 16132 | 16132 | |
| 16133 | 16133 | const validateSwitchCommand = () => { | 
| 16134 | 16134 | const { commandType, transportType } = content | 
| 16135 | - const isCustom = commandType === '0' | |
| 16136 | 16135 | const isTCP = transportType === 'TCP' | 
| 16137 | - let { attr } = contentData.dataSources.find(item => item.nodeId === nodeId) || {} | |
| 16136 | + let dataSource = contentData.dataSources.find(item => item.nodeId === nodeId) || {} | |
| 16137 | + const { attr } = dataSource | |
| 16138 | 16138 | |
| 16139 | 16139 | let flag = false | 
| 16140 | 16140 | let value | 
| 16141 | 16141 | |
| 16142 | - if (isCustom) { | |
| 16142 | + // 自定义 | |
| 16143 | + if (commandType == '0') { | |
| 16143 | 16144 | if (isTCP) { | 
| 16144 | 16145 | value = content.tcpCommand | 
| 16145 | 16146 | if (value) flag = true | 
| ... | ... | @@ -16149,7 +16150,7 @@ class HandleDataInteraction { | 
| 16149 | 16150 | value = replaceAttrPlaceholder(value, attr, isNaN(replaceValue) ? 0 : Number(replaceValue)) | 
| 16150 | 16151 | if (value) flag = true | 
| 16151 | 16152 | } | 
| 16152 | - } else { | |
| 16153 | + } else if (commandType == '1') { | |
| 16153 | 16154 | if (isTCP) { | 
| 16154 | 16155 | value = content.serviceCommand | 
| 16155 | 16156 | if (value) flag = true | 
| ... | ... | @@ -16162,7 +16163,13 @@ class HandleDataInteraction { | 
| 16162 | 16163 | flag = true | 
| 16163 | 16164 | } | 
| 16164 | 16165 | } | 
| 16166 | + } else { | |
| 16167 | + const { additional = {} } = dataSource | |
| 16168 | + const { deviceCode, registerAddress } = additional || {} | |
| 16169 | + if (!deviceCode) UseLayUi.topErrorMsg('未找到设备地址码') | |
| 16170 | + if (!registerAddress) UseLayUi.topErrorMsg('未找到寄存器地址') | |
| 16165 | 16171 | } | 
| 16172 | + | |
| 16166 | 16173 | return { flag, value } | 
| 16167 | 16174 | } | 
| 16168 | 16175 | |
| ... | ... | @@ -16172,6 +16179,7 @@ class HandleDataInteraction { | 
| 16172 | 16179 | return | 
| 16173 | 16180 | } | 
| 16174 | 16181 | const { flag, value } = validateSwitchCommand() | 
| 16182 | + | |
| 16175 | 16183 | if (!flag) return | 
| 16176 | 16184 | |
| 16177 | 16185 | layer.confirm('是否确认下发命令?', async function (index) { | 
| ... | ... | @@ -16215,7 +16223,7 @@ class HandleDataInteraction { | 
| 16215 | 16223 | |
| 16216 | 16224 | if (commandType == enumCommandType.MODBUS) { | 
| 16217 | 16225 | value = data[enumActionEl.CUSTOM_TCP_COMMAND] | 
| 16218 | - const { method, deviceCode } = additional || {} | |
| 16226 | + const { method, deviceCode } = additional || {} | |
| 16219 | 16227 | |
| 16220 | 16228 | const validate = new Validate([ | 
| 16221 | 16229 | { value: deviceCode, required: true, message: '未找到设备地址码' }, | ... | ... |