Commit 553f3388bcedbb9cbccc3d93ee6bc7ab2a4b2721
1 parent
26150ef1
fix: 修复下发modbus命令功能码为06时下发命令需大于等于0
Showing
1 changed file
with
11 additions
and
10 deletions
@@ -7140,7 +7140,7 @@ DataFormatPanel.prototype.addDataFont = function (container) { | @@ -7140,7 +7140,7 @@ DataFormatPanel.prototype.addDataFont = function (container) { | ||
7140 | */ | 7140 | */ |
7141 | async function getAllGatewayDeviceAndConnectionDevice() { | 7141 | async function getAllGatewayDeviceAndConnectionDevice() { |
7142 | if (!recordData.orgId) return | 7142 | if (!recordData.orgId) return |
7143 | - const [err, res] = await to(ConfigurationNodeApi.getAllGatewayDeviceAndConnectionDevice(recordData.orgId)) | 7143 | + const [err, res] = await to(ConfigurationNodeApi.getMeetConditionsDevice({ organizationId: recordData.orgId })) |
7144 | allDeviceOptions = res | 7144 | allDeviceOptions = res |
7145 | mountAllDeviceToSelect() | 7145 | mountAllDeviceToSelect() |
7146 | } | 7146 | } |
@@ -7149,7 +7149,8 @@ DataFormatPanel.prototype.addDataFont = function (container) { | @@ -7149,7 +7149,8 @@ DataFormatPanel.prototype.addDataFont = function (container) { | ||
7149 | * @description 将设备选项挂载到节点中 | 7149 | * @description 将设备选项挂载到节点中 |
7150 | */ | 7150 | */ |
7151 | function mountAllDeviceToSelect() { | 7151 | function mountAllDeviceToSelect() { |
7152 | - const generateOption = UseLayUi.generateOptionTemplate({ dataSource: allDeviceOptions, alias: 'alias' }) | 7152 | + const generateOption = UseLayUi.generateOptionTemplate({ dataSource: allDeviceOptions, labelField: 'name', valueField: 'tbDeviceId', alias: 'alias' }) |
7153 | + | ||
7153 | $(`#${enumActionEl.DEVICE_DATA_BODY_EL}`).find(`select[name="${enumConst.DEVICE}"]`).html(generateOption) | 7154 | $(`#${enumActionEl.DEVICE_DATA_BODY_EL}`).find(`select[name="${enumConst.DEVICE}"]`).html(generateOption) |
7154 | UseLayUi.nextTick(() => form.render('select')) | 7155 | UseLayUi.nextTick(() => form.render('select')) |
7155 | } | 7156 | } |
@@ -7257,7 +7258,7 @@ DataFormatPanel.prototype.addDataFont = function (container) { | @@ -7257,7 +7258,7 @@ DataFormatPanel.prototype.addDataFont = function (container) { | ||
7257 | function createAddRowListenEvent() { | 7258 | function createAddRowListenEvent() { |
7258 | $(`#${enumActionEl.ADD_ROW_EL}`).on('click', () => { | 7259 | $(`#${enumActionEl.ADD_ROW_EL}`).on('click', () => { |
7259 | addRecord() | 7260 | addRecord() |
7260 | - const generateOption = UseLayUi.generateOptionTemplate({ dataSource: allDeviceOptions, alias: 'alias' }) | 7261 | + const generateOption = UseLayUi.generateOptionTemplate({ dataSource: allDeviceOptions, labelField: 'name', valueField: 'tbDeviceId', alias: 'alias' }) |
7261 | $(`#${enumActionEl.DEVICE_DATA_BODY_EL} tr`).last().find(`select[name="${enumConst.DEVICE}"]`).html(generateOption) | 7262 | $(`#${enumActionEl.DEVICE_DATA_BODY_EL} tr`).last().find(`select[name="${enumConst.DEVICE}"]`).html(generateOption) |
7262 | form.render('select') | 7263 | form.render('select') |
7263 | }) | 7264 | }) |
@@ -7267,7 +7268,7 @@ DataFormatPanel.prototype.addDataFont = function (container) { | @@ -7267,7 +7268,7 @@ DataFormatPanel.prototype.addDataFont = function (container) { | ||
7267 | * @description 设置设备选项 | 7268 | * @description 设置设备选项 |
7268 | */ | 7269 | */ |
7269 | function setDeviceOptions(row) { | 7270 | function setDeviceOptions(row) { |
7270 | - const generateOption = UseLayUi.generateOptionTemplate({ dataSource: allDeviceOptions, alias: 'alias' }) | 7271 | + const generateOption = UseLayUi.generateOptionTemplate({ dataSource: allDeviceOptions, labelField: 'name', valueField: 'tbDeviceId', alias: 'alias' }) |
7271 | $(`#${enumActionEl.DEVICE_DATA_BODY_EL} tr[lay-filter="${getRowFilter(row)}"]`).find(`select[name="${enumConst.DEVICE}"]`).html(generateOption) | 7272 | $(`#${enumActionEl.DEVICE_DATA_BODY_EL} tr[lay-filter="${getRowFilter(row)}"]`).find(`select[name="${enumConst.DEVICE}"]`).html(generateOption) |
7272 | } | 7273 | } |
7273 | 7274 | ||
@@ -7348,7 +7349,6 @@ DataFormatPanel.prototype.addDataFont = function (container) { | @@ -7348,7 +7349,6 @@ DataFormatPanel.prototype.addDataFont = function (container) { | ||
7348 | 7349 | ||
7349 | const formModel = form.val(enumActionEl.FORM_FILTER) | 7350 | const formModel = form.val(enumActionEl.FORM_FILTER) |
7350 | if (!formModel[enumConst.ORG_ID]) return false | 7351 | if (!formModel[enumConst.ORG_ID]) return false |
7351 | - | ||
7352 | for (let i = 0; i < tableData.length; i++) { | 7352 | for (let i = 0; i < tableData.length; i++) { |
7353 | const { value } = tableData[i] | 7353 | const { value } = tableData[i] |
7354 | if (!isJson(value)) { | 7354 | if (!isJson(value)) { |
@@ -7824,7 +7824,7 @@ DataFormatPanel.prototype.addDataFont = function (container) { | @@ -7824,7 +7824,7 @@ DataFormatPanel.prototype.addDataFont = function (container) { | ||
7824 | 7824 | ||
7825 | return fields.reduce((prev, next) => ({ ...prev, [next]: formVal[next] }), {}) | 7825 | return fields.reduce((prev, next) => ({ ...prev, [next]: formVal[next] }), {}) |
7826 | } | 7826 | } |
7827 | - | 7827 | + |
7828 | const data = { | 7828 | const data = { |
7829 | type: event.data.type, | 7829 | type: event.data.type, |
7830 | configurationId, | 7830 | configurationId, |
@@ -15961,8 +15961,9 @@ class HandleDataInteraction { | @@ -15961,8 +15961,9 @@ class HandleDataInteraction { | ||
15961 | const [err, res = []] = way === 'twoway' ? await to(ConfigurationNodeApi.deviceIsOnLine(deviceId)) : [null, [{ value: true }]] | 15961 | const [err, res = []] = way === 'twoway' ? await to(ConfigurationNodeApi.deviceIsOnLine(deviceId)) : [null, [{ value: true }]] |
15962 | const { value } = res[0] || {} | 15962 | const { value } = res[0] || {} |
15963 | if (value) { | 15963 | if (value) { |
15964 | - await to(ConfigurationNodeApi.sendInstruction(way, deviceId, data)) | ||
15965 | - UseLayUi.topSuccessMsg('下发成功~') | 15964 | + const [err, response] = await to(ConfigurationNodeApi.sendInstruction(way, deviceId, data)) |
15965 | + if (response?.rpcId) UseLayUi.topSuccessMsg('下发成功~') | ||
15966 | + else UseLayUi.topErrorMsg('下发失败~') | ||
15966 | } else { | 15967 | } else { |
15967 | UseLayUi.errorMsg('设备不在线!') | 15968 | UseLayUi.errorMsg('设备不在线!') |
15968 | } | 15969 | } |
@@ -16305,7 +16306,7 @@ class HandleDataInteraction { | @@ -16305,7 +16306,7 @@ class HandleDataInteraction { | ||
16305 | { value: method, required: true, message: '未找到Modbus命令操作类型' }, | 16306 | { value: method, required: true, message: '未找到Modbus命令操作类型' }, |
16306 | { value, message: '下发值不是一个数字', validator(value) { return value.toString().trim() && !isNaN(value) } }, | 16307 | { value, message: '下发值不是一个数字', validator(value) { return value.toString().trim() && !isNaN(value) } }, |
16307 | ...(method == '05' ? [{ value, message: '下发类型必须为0或1', validator(value) { return value == 0 || value == 1 } }] : []), | 16308 | ...(method == '05' ? [{ value, message: '下发类型必须为0或1', validator(value) { return value == 0 || value == 1 } }] : []), |
16308 | - ...(method == '06' ? [{ value, message: `下发类型必须为整型,缩放因子为${zoomFactor}`, validator(value) { return !isNaN(value) && getNumberFloatPart(Number(value)) * zoomFactor % 1 === 0 } }, { value: Number(value) * zoomFactor, message: `最大值不能超过65535,缩放因子为${zoomFactor}`, validator(value) { return Number(value) <= parseInt('ffff', 16) } }] : []), | 16309 | + ...(method == '06' ? [{ value, message: `下发类型必须为正整型,缩放因子为${zoomFactor}`, validator(value) { return !isNaN(value) && value >= 0 && getNumberFloatPart(Number(value)) * zoomFactor % 1 === 0 } }, { value: Number(value) * zoomFactor, message: `最大值不能超过65535,缩放因子为${zoomFactor}`, validator(value) { return Number(value) <= parseInt('ffff', 16) } }] : []), |
16309 | ...(method == '16' ? [{ value, message: '下发类型精确到两位小数', validator(value) { return /^-?\d+(\.\d{0,2})?$/.test(Math.floor(Number(value)) * zoomFactor + getNumberFloatPart(Number(value)) * zoomFactor) } }] : []) | 16310 | ...(method == '16' ? [{ value, message: '下发类型精确到两位小数', validator(value) { return /^-?\d+(\.\d{0,2})?$/.test(Math.floor(Number(value)) * zoomFactor + getNumberFloatPart(Number(value)) * zoomFactor) } }] : []) |
16310 | ]) | 16311 | ]) |
16311 | 16312 | ||
@@ -16453,7 +16454,7 @@ class HandleDataInteraction { | @@ -16453,7 +16454,7 @@ class HandleDataInteraction { | ||
16453 | name = `${deviceName || ''} - ${attrName || ''}` | 16454 | name = `${deviceName || ''} - ${attrName || ''}` |
16454 | } else { | 16455 | } else { |
16455 | name = `${deviceName || ''} - ${content?.serviceName}` | 16456 | name = `${deviceName || ''} - ${content?.serviceName}` |
16456 | - } | 16457 | + } |
16457 | layer.open({ | 16458 | layer.open({ |
16458 | title: `参数设置 - ${name}`, | 16459 | title: `参数设置 - ${name}`, |
16459 | content: createContent(), | 16460 | content: createContent(), |