Showing
1 changed file
with
9 additions
and
5 deletions
... | ... | @@ -7043,7 +7043,6 @@ DataFormatPanel.prototype.addDataFont = function (container) { |
7043 | 7043 | */ |
7044 | 7044 | function echoFormData(data) { |
7045 | 7045 | const { content = {} } = data |
7046 | - console.log(data) | |
7047 | 7046 | const val = { |
7048 | 7047 | [enumConst.ACTION]: content.type, |
7049 | 7048 | [enumGetValue[content.type]]: content.value, |
... | ... | @@ -7141,6 +7140,8 @@ DataFormatPanel.prototype.addDataFont = function (container) { |
7141 | 7140 | UseLayUi.topErrorMsg('请输入自定义下发指令') |
7142 | 7141 | return false |
7143 | 7142 | } |
7143 | + } else { | |
7144 | + console.log(formVal) | |
7144 | 7145 | if (!isJson(formVal[enumConst.JSON_COMMAND])) { |
7145 | 7146 | UseLayUi.topErrorMsg('命令配置存在错误') |
7146 | 7147 | return false |
... | ... | @@ -7266,6 +7267,7 @@ DataFormatPanel.prototype.addDataFont = function (container) { |
7266 | 7267 | $(`#${enumActionEl.EDITOR_CONTAINER}`).css({ display: !isTCPTransportType && flag ? 'flex' : 'none' }) |
7267 | 7268 | form.val(enumActionEl.FORM_FILTER, { [enumConst.TCP_COMMAND]: '', [enumConst.SERVICE]: '', [enumConst.COMMAND]: '' }) |
7268 | 7269 | $(`#${enumActionEl.INPUT_DATA_FORM}`).html('') |
7270 | + editorAssignValue() | |
7269 | 7271 | }) |
7270 | 7272 | |
7271 | 7273 | /** |
... | ... | @@ -7335,6 +7337,9 @@ DataFormatPanel.prototype.addDataFont = function (container) { |
7335 | 7337 | } |
7336 | 7338 | } |
7337 | 7339 | |
7340 | + const editorAssignValue = (value = JSON.stringify({ [enumConst.ATTR_PLACEHOLDER]: 0 }, null, 2)) => { | |
7341 | + $(`#${enumActionEl.EDITOR_CONTAINER}`).parent().find(`textarea[name="${enumConst.JSON_COMMAND}"]`).val(value) | |
7342 | + } | |
7338 | 7343 | |
7339 | 7344 | /** |
7340 | 7345 | * @description 创建JSON编辑器 |
... | ... | @@ -12623,7 +12628,7 @@ class UseLayUi { |
12623 | 12628 | needFormat && (value[identifier] = Number(identifierValue)) |
12624 | 12629 | break |
12625 | 12630 | case UseLayUi.thingsModelType.STRUCT: |
12626 | - if (!Utils.stringIsJSON(identifierValue)) return error(`${functionName}字段需要一个JSON对象`) | |
12631 | + if (identifierValue && !Utils.stringIsJSON(identifierValue)) return error(`${functionName}字段需要一个JSON对象`) | |
12627 | 12632 | needFormat && (value[identifier] = Utils.stringToJSON(identifierValue)) |
12628 | 12633 | break |
12629 | 12634 | default: |
... | ... | @@ -13103,7 +13108,8 @@ class Utils { |
13103 | 13108 | */ |
13104 | 13109 | static stringIsJSON(value) { |
13105 | 13110 | try { |
13106 | - JSON.parse(value) | |
13111 | + const res = JSON.parse(value) | |
13112 | + if (typeof res !== 'object') return false | |
13107 | 13113 | return true |
13108 | 13114 | } catch (error) { |
13109 | 13115 | return false |
... | ... | @@ -15055,7 +15061,6 @@ class HandleDataInteraction { |
15055 | 15061 | |
15056 | 15062 | function createEditor() { |
15057 | 15063 | if (content.transportType === 'TCP' || content.commandType === '1') return |
15058 | - console.log('enter') | |
15059 | 15064 | const jsonCommand = content.jsonCommand || '' |
15060 | 15065 | let defaultValue = { [enumConst.ATTR_PLACEHOLDER]: 0 } |
15061 | 15066 | const editor = ace.edit(enumActionEl.EDITOR, { |
... | ... | @@ -15072,7 +15077,6 @@ class HandleDataInteraction { |
15072 | 15077 | editor.getSession().on('change', (event, editor) => { |
15073 | 15078 | $(`#${enumActionEl.EDITOR_CONTAINER}`).parent().find(`textarea[name="${enumActionEl.CUSTOM_JSON_COMMAND}"]`).val(editor.getValue()) |
15074 | 15079 | }) |
15075 | - console.log(editor) | |
15076 | 15080 | } |
15077 | 15081 | |
15078 | 15082 | function createCustomJSONParams() { | ... | ... |