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