Commit 2638b4c50a41f073a94526e40a7506a126de3d79

Authored by xp.Huang
2 parents 50b90be9 ff27dfce

Merge branch 'fix/control-component-service-identifer' into 'main_dev'

fix: 控制组件调用服务时携带标识符

See merge request yunteng/thingskit-scada!83
@@ -7532,7 +7532,12 @@ DataFormatPanel.prototype.addDataFont = function (container) { @@ -7532,7 +7532,12 @@ DataFormatPanel.prototype.addDataFont = function (container) {
7532 */ 7532 */
7533 ATTR_PLACEHOLDER: 'attrPlaceholder', 7533 ATTR_PLACEHOLDER: 'attrPlaceholder',
7534 7534
7535 - WAY: 'way' 7535 + WAY: 'way',
  7536 +
  7537 + /**
  7538 + * @description 标识符号
  7539 + */
  7540 + IDENTIFIER: 'identifier'
7536 } 7541 }
7537 7542
7538 /** 7543 /**
@@ -7651,6 +7656,7 @@ DataFormatPanel.prototype.addDataFont = function (container) { @@ -7651,6 +7656,7 @@ DataFormatPanel.prototype.addDataFont = function (container) {
7651 [enumGetValue[content.type]]: content.value, 7656 [enumGetValue[content.type]]: content.value,
7652 7657
7653 // 参数设置 7658 // 参数设置
  7659 + [enumConst.IDENTIFIER]: content[enumConst.IDENTIFIER],
7654 [enumConst.JSON_COMMAND]: content[enumConst.JSON_COMMAND], 7660 [enumConst.JSON_COMMAND]: content[enumConst.JSON_COMMAND],
7655 [enumConst.WAY]: content[enumConst.WAY] || enumWayType.ONE_WAY, 7661 [enumConst.WAY]: content[enumConst.WAY] || enumWayType.ONE_WAY,
7656 [enumConst.COMMAND_TYPE]: content[enumConst.COMMAND_TYPE], 7662 [enumConst.COMMAND_TYPE]: content[enumConst.COMMAND_TYPE],
@@ -7781,6 +7787,7 @@ DataFormatPanel.prototype.addDataFont = function (container) { @@ -7781,6 +7787,7 @@ DataFormatPanel.prototype.addDataFont = function (container) {
7781 type: formVal[enumConst.ACTION], 7787 type: formVal[enumConst.ACTION],
7782 value: formVal[enumGetValue[formVal[enumConst.ACTION]]], 7788 value: formVal[enumGetValue[formVal[enumConst.ACTION]]],
7783 ...(isParamsSetting ? { 7789 ...(isParamsSetting ? {
  7790 + [enumConst.IDENTIFIER]: formVal[enumConst.IDENTIFIER],
7784 [enumConst.JSON_COMMAND]: formVal[enumConst.JSON_COMMAND], 7791 [enumConst.JSON_COMMAND]: formVal[enumConst.JSON_COMMAND],
7785 [enumConst.WAY]: formVal[enumConst.WAY], 7792 [enumConst.WAY]: formVal[enumConst.WAY],
7786 [enumConst.COMMAND_TYPE]: formVal[enumConst.COMMAND_TYPE], 7793 [enumConst.COMMAND_TYPE]: formVal[enumConst.COMMAND_TYPE],
@@ -7867,7 +7874,7 @@ DataFormatPanel.prototype.addDataFont = function (container) { @@ -7867,7 +7874,7 @@ DataFormatPanel.prototype.addDataFont = function (container) {
7867 $(`#${enumActionEl.SERVICE_EL}`).css({ display: flag ? 'none' : 'block' }) 7874 $(`#${enumActionEl.SERVICE_EL}`).css({ display: flag ? 'none' : 'block' })
7868 $(`#${enumActionEl.TCP_COMMAND_INPUT}`).css({ display: isTCPTransportType && flag ? 'block' : 'none' }) 7875 $(`#${enumActionEl.TCP_COMMAND_INPUT}`).css({ display: isTCPTransportType && flag ? 'block' : 'none' })
7869 $(`#${enumActionEl.EDITOR_CONTAINER}`).css({ display: !isTCPTransportType && flag ? 'flex' : 'none' }) 7876 $(`#${enumActionEl.EDITOR_CONTAINER}`).css({ display: !isTCPTransportType && flag ? 'flex' : 'none' })
7870 - form.val(enumActionEl.FORM_FILTER, { [enumConst.TCP_COMMAND]: '', [enumConst.SERVICE]: '', [enumConst.COMMAND]: '' }) 7877 + form.val(enumActionEl.FORM_FILTER, { [enumConst.TCP_COMMAND]: '', [enumConst.SERVICE]: '', [enumConst.COMMAND]: '', [enumConst.IDENTIFIER]: '' })
7871 $(`#${enumActionEl.INPUT_DATA_FORM}`).html('') 7878 $(`#${enumActionEl.INPUT_DATA_FORM}`).html('')
7872 editorAssignValue() 7879 editorAssignValue()
7873 }) 7880 })
@@ -7886,7 +7893,7 @@ DataFormatPanel.prototype.addDataFont = function (container) { @@ -7886,7 +7893,7 @@ DataFormatPanel.prototype.addDataFont = function (container) {
7886 } else { 7893 } else {
7887 form.val(enumActionEl.FORM_FILTER, { [enumConst.SERVICE_COMMAND]: needRender.functionJson?.inputData?.[0]?.serviceCommand || '' }) 7894 form.val(enumActionEl.FORM_FILTER, { [enumConst.SERVICE_COMMAND]: needRender.functionJson?.inputData?.[0]?.serviceCommand || '' })
7888 } 7895 }
7889 - form.val(enumActionEl.FORM_FILTER, { [enumConst.SERVICE_ORIGINAL_CONFIGURATION]: JSON.stringify(needRender.functionJson?.inputData || []) }) 7896 + form.val(enumActionEl.FORM_FILTER, { [enumConst.SERVICE_ORIGINAL_CONFIGURATION]: JSON.stringify(needRender.functionJson?.inputData || []), [enumConst.IDENTIFIER]: needRender?.identifier })
7890 }) 7897 })
7891 7898
7892 try { 7899 try {
@@ -8026,6 +8033,9 @@ DataFormatPanel.prototype.addDataFont = function (container) { @@ -8026,6 +8033,9 @@ DataFormatPanel.prototype.addDataFont = function (container) {
8026 </div> 8033 </div>
8027 </div> 8034 </div>
8028 <div style="display: none;"> 8035 <div style="display: none;">
  8036 + <input type="text" name="${enumConst.IDENTIFIER}" placeholder="标识符" />
  8037 + </div>
  8038 + <div style="display: none;">
8029 <input type="text" name="${enumConst.SERVICE_COMMAND}" placeholder="服务命令" /> 8039 <input type="text" name="${enumConst.SERVICE_COMMAND}" placeholder="服务命令" />
8030 </div> 8040 </div>
8031 <div style="display: none;"> 8041 <div style="display: none;">
@@ -15896,7 +15906,7 @@ class HandleDataInteraction { @@ -15896,7 +15906,7 @@ class HandleDataInteraction {
15896 15906
15897 let flag = false 15907 let flag = false
15898 let value 15908 let value
15899 - 15909 +
15900 if (isCustom) { 15910 if (isCustom) {
15901 if (isTCP) { 15911 if (isTCP) {
15902 value = content.tcpCommand 15912 value = content.tcpCommand
@@ -15911,6 +15921,7 @@ class HandleDataInteraction { @@ -15911,6 +15921,7 @@ class HandleDataInteraction {
15911 if (isTCP) { 15921 if (isTCP) {
15912 value = content.serviceCommand 15922 value = content.serviceCommand
15913 if (value) flag = true 15923 if (value) flag = true
  15924 + else UseLayUi.topErrorMsg('服务命令为空')
15914 } else { 15925 } else {
15915 value = content.serviceCommand 15926 value = content.serviceCommand
15916 const { flag: validateFlag, value: validateValue } = UseLayUi.validateThingsModelInputDataForm(Utils.stringToJSON(content.serviceOriginalConfiguration), value, true) 15927 const { flag: validateFlag, value: validateValue } = UseLayUi.validateThingsModelInputDataForm(Utils.stringToJSON(content.serviceOriginalConfiguration), value, true)
@@ -16022,12 +16033,17 @@ class HandleDataInteraction { @@ -16022,12 +16033,17 @@ class HandleDataInteraction {
16022 * @type {command: string , commandType: string, service: string, wary: string, tcpCommand: string} 16033 * @type {command: string , commandType: string, service: string, wary: string, tcpCommand: string}
16023 */ 16034 */
16024 let { command, way, tcpCommand } = content 16035 let { command, way, tcpCommand } = content
16025 - 16036 + const identifier = content?.identifier
  16037 + const params = content?.transportType === 'TCP'
  16038 + ? value
  16039 + : identifier
  16040 + ? { [identifier]: value }
  16041 + : value
16026 const instructionData = { 16042 const instructionData = {
16027 method: "methodThingskit", 16043 method: "methodThingskit",
16028 additionalInfo: { cmdType: 'API' }, 16044 additionalInfo: { cmdType: 'API' },
16029 persistent: true, 16045 persistent: true,
16030 - params: value, 16046 + params,
16031 } 16047 }
16032 16048
16033 const [err, res = []] = way === 'twoway' ? await to(ConfigurationNodeApi.deviceIsOnLine(deviceId)) : [null, [{ value: true }]] 16049 const [err, res = []] = way === 'twoway' ? await to(ConfigurationNodeApi.deviceIsOnLine(deviceId)) : [null, [{ value: true }]]