Showing
2 changed files
with
37 additions
and
21 deletions
... | ... | @@ -7537,7 +7537,12 @@ DataFormatPanel.prototype.addDataFont = function (container) { |
7537 | 7537 | /** |
7538 | 7538 | * @description 标识符号 |
7539 | 7539 | */ |
7540 | - IDENTIFIER: 'identifier' | |
7540 | + IDENTIFIER: 'identifier', | |
7541 | + | |
7542 | + /** | |
7543 | + * @description 服务调用方式 | |
7544 | + */ | |
7545 | + CALL_TYPE: 'callType' | |
7541 | 7546 | } |
7542 | 7547 | |
7543 | 7548 | /** |
... | ... | @@ -7656,6 +7661,7 @@ DataFormatPanel.prototype.addDataFont = function (container) { |
7656 | 7661 | [enumGetValue[content.type]]: content.value, |
7657 | 7662 | |
7658 | 7663 | // 参数设置 |
7664 | + [enumConst.CALL_TYPE]: content[enumConst.CALL_TYPE], | |
7659 | 7665 | [enumConst.IDENTIFIER]: content[enumConst.IDENTIFIER], |
7660 | 7666 | [enumConst.JSON_COMMAND]: content[enumConst.JSON_COMMAND], |
7661 | 7667 | [enumConst.WAY]: content[enumConst.WAY] || enumWayType.ONE_WAY, |
... | ... | @@ -7711,10 +7717,10 @@ DataFormatPanel.prototype.addDataFont = function (container) { |
7711 | 7717 | $(`#${enumActionEl.LINK_EL_ID}`).css({ display: 'none' }) |
7712 | 7718 | $(`#${enumActionEl.PAGE_EL_ID}`).css({ display: 'none' }) |
7713 | 7719 | // $(`#${enumActionEl.EDITOR_CONTAINER}`).css({ display: 'flex' }) |
7714 | - $(`#${enumActionEl.WAY_SELECT}`).css({ display: 'block' }) | |
7715 | 7720 | $(`#${enumActionEl.COMMAND_TYPE_EL}`).css({ display: 'block' }) |
7716 | 7721 | |
7717 | 7722 | $(`#${enumActionEl.INPUT_DATA_FORM}`).css({ display: isCustom ? 'none' : 'block' }) |
7723 | + $(`#${enumActionEl.WAY_SELECT}`).css({ display: isCustom ? 'block' : 'none' }) | |
7718 | 7724 | $(`#${enumActionEl.SERVICE_EL}`).css({ display: isCustom ? 'none' : 'block' }) |
7719 | 7725 | $(`#${enumActionEl.TCP_COMMAND_INPUT}`).css({ display: isTCP && isCustom ? 'block' : 'none' }) |
7720 | 7726 | $(`#${enumActionEl.EDITOR_CONTAINER}`).css({ display: !isTCP && isCustom ? 'flex' : 'none' }) |
... | ... | @@ -7787,6 +7793,7 @@ DataFormatPanel.prototype.addDataFont = function (container) { |
7787 | 7793 | type: formVal[enumConst.ACTION], |
7788 | 7794 | value: formVal[enumGetValue[formVal[enumConst.ACTION]]], |
7789 | 7795 | ...(isParamsSetting ? { |
7796 | + [enumConst.CALL_TYPE]: formVal[enumConst.CALL_TYPE], | |
7790 | 7797 | [enumConst.IDENTIFIER]: formVal[enumConst.IDENTIFIER], |
7791 | 7798 | [enumConst.JSON_COMMAND]: formVal[enumConst.JSON_COMMAND], |
7792 | 7799 | [enumConst.WAY]: formVal[enumConst.WAY], |
... | ... | @@ -7871,6 +7878,7 @@ DataFormatPanel.prototype.addDataFont = function (container) { |
7871 | 7878 | const flag = value === COMMAND_TYPE_ENUM.CUSTOM |
7872 | 7879 | const isTCPTransportType = transportType === 'TCP' |
7873 | 7880 | $(`#${enumActionEl.INPUT_DATA_FORM}`).css({ display: flag ? 'none' : 'block' }) |
7881 | + $(`#${enumActionEl.WAY_SELECT}`).css({ display: flag ? 'block' : 'none' }) | |
7874 | 7882 | $(`#${enumActionEl.SERVICE_EL}`).css({ display: flag ? 'none' : 'block' }) |
7875 | 7883 | $(`#${enumActionEl.TCP_COMMAND_INPUT}`).css({ display: isTCPTransportType && flag ? 'block' : 'none' }) |
7876 | 7884 | $(`#${enumActionEl.EDITOR_CONTAINER}`).css({ display: !isTCPTransportType && flag ? 'flex' : 'none' }) |
... | ... | @@ -7893,7 +7901,7 @@ DataFormatPanel.prototype.addDataFont = function (container) { |
7893 | 7901 | } else { |
7894 | 7902 | form.val(enumActionEl.FORM_FILTER, { [enumConst.SERVICE_COMMAND]: needRender.functionJson?.inputData?.[0]?.serviceCommand || '' }) |
7895 | 7903 | } |
7896 | - form.val(enumActionEl.FORM_FILTER, { [enumConst.SERVICE_ORIGINAL_CONFIGURATION]: JSON.stringify(needRender.functionJson?.inputData || []), [enumConst.IDENTIFIER]: needRender?.identifier }) | |
7904 | + form.val(enumActionEl.FORM_FILTER, { [enumConst.SERVICE_ORIGINAL_CONFIGURATION]: JSON.stringify(needRender.functionJson?.inputData || []), [enumConst.IDENTIFIER]: needRender?.identifier, [enumConst.CALL_TYPE]: needRender?.callType }) | |
7897 | 7905 | }) |
7898 | 7906 | |
7899 | 7907 | try { |
... | ... | @@ -8009,14 +8017,6 @@ DataFormatPanel.prototype.addDataFont = function (container) { |
8009 | 8017 | </select> |
8010 | 8018 | </div> |
8011 | 8019 | </div> |
8012 | - <div class="layui-form-item" id="${enumActionEl.WAY_SELECT}" style="display:none;"> | |
8013 | - <label class="layui-form-label" style="width: 120px;">单向/双向 ${createHelpMessage(`单向:服务器向网关设备、直连设备发送指令。发送指令后,设备不会返回任何信息。\n | |
8014 | - 双向:服务器向网关设备、直连设备发送指令。发送指令后,设备返回响应信息。`, 'way')}</label> | |
8015 | - <div class="layui-input-block" style="margin-left: 150px;"> | |
8016 | - <input type="radio" name="${enumConst.WAY}" value="${enumWayType.ONE_WAY}" title="单向" checked> | |
8017 | - <input type="radio" name="${enumConst.WAY}" value="${enumWayType.TWO_WAY}" title="双向"> | |
8018 | - </div> | |
8019 | - </div> | |
8020 | 8020 | <div id="${enumActionEl.COMMAND_TYPE_EL}" class="layui-form-item" style="display: none;"> |
8021 | 8021 | <label class="layui-form-label" style="width: 120px;">命令下发方式</label> |
8022 | 8022 | <div class="layui-input-block" style="margin-left: 150px;"> |
... | ... | @@ -8025,6 +8025,14 @@ DataFormatPanel.prototype.addDataFont = function (container) { |
8025 | 8025 | </select> |
8026 | 8026 | </div> |
8027 | 8027 | </div> |
8028 | + <div class="layui-form-item" id="${enumActionEl.WAY_SELECT}" style="display:none;"> | |
8029 | + <label class="layui-form-label" style="width: 120px;">单向/双向 ${createHelpMessage(`单向:服务器向网关设备、直连设备发送指令。发送指令后,设备不会返回任何信息。\n | |
8030 | + 双向:服务器向网关设备、直连设备发送指令。发送指令后,设备返回响应信息。`, 'way')}</label> | |
8031 | + <div class="layui-input-block" style="margin-left: 150px;"> | |
8032 | + <input type="radio" name="${enumConst.WAY}" value="${enumWayType.ONE_WAY}" title="单向" checked> | |
8033 | + <input type="radio" name="${enumConst.WAY}" value="${enumWayType.TWO_WAY}" title="双向"> | |
8034 | + </div> | |
8035 | + </div> | |
8028 | 8036 | <div class="layui-form-item" id="${enumActionEl.SERVICE_EL}" style="display: none;"> |
8029 | 8037 | <label class="layui-form-label" style="width: 120px;">服务</label> |
8030 | 8038 | <div class="layui-input-block" style="margin-left: 150px;"> |
... | ... | @@ -8036,6 +8044,9 @@ DataFormatPanel.prototype.addDataFont = function (container) { |
8036 | 8044 | <input type="text" name="${enumConst.IDENTIFIER}" placeholder="标识符" /> |
8037 | 8045 | </div> |
8038 | 8046 | <div style="display: none;"> |
8047 | + <input type="text" name="${enumConst.CALL_TYPE}" placeholder="服务调用方式" /> | |
8048 | + </div> | |
8049 | + <div style="display: none;"> | |
8039 | 8050 | <input type="text" name="${enumConst.SERVICE_COMMAND}" placeholder="服务命令" /> |
8040 | 8051 | </div> |
8041 | 8052 | <div style="display: none;"> |
... | ... | @@ -13201,7 +13212,7 @@ class UseLayUi { |
13201 | 13212 | /** |
13202 | 13213 | * |
13203 | 13214 | * @param {{ |
13204 | - * accessMode: 'r' | 'w', | |
13215 | + * accessMode: 'r' | 'rw', | |
13205 | 13216 | * functionName: string, |
13206 | 13217 | * id: string, |
13207 | 13218 | * identifier: string, |
... | ... | @@ -13217,11 +13228,12 @@ class UseLayUi { |
13217 | 13228 | */ |
13218 | 13229 | static genThingsModelInputDataForm(inputData, labelWidth = 80, formFilter = 'inputDataFilter') { |
13219 | 13230 | const list = [] |
13220 | - inputData.forEach(item => { | |
13221 | - const { identifier, functionName, dataType = {} } = item | |
13231 | + for (const item of inputData) { | |
13232 | + const { identifier, functionName, dataType = {}, accessMode } = item | |
13233 | + if (accessMode === 'r') continue | |
13222 | 13234 | const { type } = dataType |
13223 | 13235 | list.push(UseLayUi.createInputTemplate({ label: functionName, value: identifier, labelWidth, type })) |
13224 | - }) | |
13236 | + } | |
13225 | 13237 | const template = ` |
13226 | 13238 | <form class="layui-form" action="" lay-filter="${formFilter}"> |
13227 | 13239 | ${list.join('')} |
... | ... | @@ -13252,9 +13264,10 @@ class UseLayUi { |
13252 | 13264 | } |
13253 | 13265 | |
13254 | 13266 | const validate = (item) => { |
13255 | - const { dataType, identifier, functionName } = item | |
13267 | + const { dataType, identifier, functionName, accessMode } = item | |
13256 | 13268 | const { type } = dataType || {} |
13257 | 13269 | const identifierValue = value[identifier] |
13270 | + if (accessMode === 'r') return true | |
13258 | 13271 | switch (type) { |
13259 | 13272 | case UseLayUi.thingsModelType.INT: |
13260 | 13273 | if (isNaN(identifierValue)) return error(`${functionName}字段需要一个数字`) |
... | ... | @@ -15906,7 +15919,7 @@ class HandleDataInteraction { |
15906 | 15919 | |
15907 | 15920 | let flag = false |
15908 | 15921 | let value |
15909 | - | |
15922 | + | |
15910 | 15923 | if (isCustom) { |
15911 | 15924 | if (isTCP) { |
15912 | 15925 | value = content.tcpCommand |
... | ... | @@ -16028,20 +16041,24 @@ class HandleDataInteraction { |
16028 | 16041 | |
16029 | 16042 | async function defaultHandler(value, callback) { |
16030 | 16043 | let { deviceId, attr } = contentData.dataSources.find(item => item.nodeId === nodeId) || {} |
16031 | - | |
16044 | + console.log(content) | |
16032 | 16045 | /** |
16033 | 16046 | * @type {command: string , commandType: string, service: string, wary: string, tcpCommand: string} |
16034 | 16047 | */ |
16035 | - let { command, way, tcpCommand } = content | |
16048 | + let { command, way, service, callType } = content | |
16036 | 16049 | const identifier = content?.identifier |
16037 | 16050 | const params = content?.transportType === 'TCP' |
16038 | 16051 | ? value |
16039 | 16052 | : identifier |
16040 | 16053 | ? { [identifier]: value } |
16041 | 16054 | : value |
16055 | + | |
16056 | + if (service) { | |
16057 | + way = callType === 'ASYNC' ? 'twoway' : 'oneway' | |
16058 | + } | |
16042 | 16059 | const instructionData = { |
16043 | 16060 | method: "methodThingskit", |
16044 | - additionalInfo: { cmdType: 'API' }, | |
16061 | + additionalInfo: { cmdType: service ? '1' : 'API' }, | |
16045 | 16062 | persistent: true, |
16046 | 16063 | params, |
16047 | 16064 | } | ... | ... |