|
@@ -6425,7 +6425,7 @@ DataFormatPanel.prototype.addDataFont = function (container) { |
|
@@ -6425,7 +6425,7 @@ DataFormatPanel.prototype.addDataFont = function (container) { |
6425
|
}
|
6425
|
}
|
6426
|
|
6426
|
|
6427
|
const sendInstructionWay = {
|
6427
|
const sendInstructionWay = {
|
6428
|
- ONE_WAR: 'oneway',
|
6428
|
+ ONE_WAY: 'oneway',
|
6429
|
TWO_WAY: 'twoway',
|
6429
|
TWO_WAY: 'twoway',
|
6430
|
}
|
6430
|
}
|
6431
|
|
6431
|
|
|
@@ -6506,8 +6506,8 @@ DataFormatPanel.prototype.addDataFont = function (container) { |
|
@@ -6506,8 +6506,8 @@ DataFormatPanel.prototype.addDataFont = function (container) { |
6506
|
<td>
|
6506
|
<td>
|
6507
|
<form action="" style="display: flex">
|
6507
|
<form action="" style="display: flex">
|
6508
|
<div class="override__radio-default">
|
6508
|
<div class="override__radio-default">
|
6509
|
- <input id="${getRowFilter(addRowNumber)}${sendInstructionWay.ONE_WAR}" type="radio" name="${enumConst.WAY}" lay-ignore value="${sendInstructionWay.ONE_WAR}" title="单向" checked="">
|
|
|
6510
|
- <label for="${getRowFilter(addRowNumber)}${sendInstructionWay.ONE_WAR}" class="override__radio-label">单向</label>
|
6509
|
+ <input id="${getRowFilter(addRowNumber)}${sendInstructionWay.ONE_WAY}" type="radio" name="${enumConst.WAY}" lay-ignore value="${sendInstructionWay.ONE_WAY}" title="单向" checked="">
|
|
|
6510
|
+ <label for="${getRowFilter(addRowNumber)}${sendInstructionWay.ONE_WAY}" class="override__radio-label">单向</label>
|
6511
|
</div>
|
6511
|
</div>
|
6512
|
<div class="override__radio-default">
|
6512
|
<div class="override__radio-default">
|
6513
|
<input id="${getRowFilter(addRowNumber)}${sendInstructionWay.TWO_WAY}" type="radio" name="${enumConst.WAY}" lay-ignore value="${sendInstructionWay.TWO_WAY}" title="双向">
|
6513
|
<input id="${getRowFilter(addRowNumber)}${sendInstructionWay.TWO_WAY}" type="radio" name="${enumConst.WAY}" lay-ignore value="${sendInstructionWay.TWO_WAY}" title="双向">
|
|
@@ -6797,6 +6797,18 @@ DataFormatPanel.prototype.addDataFont = function (container) { |
|
@@ -6797,6 +6797,18 @@ DataFormatPanel.prototype.addDataFont = function (container) { |
6797
|
ACTION: 'actionType',
|
6797
|
ACTION: 'actionType',
|
6798
|
PAGE_VALUE: 'pageValue',
|
6798
|
PAGE_VALUE: 'pageValue',
|
6799
|
LINK_VALUE: 'linkValue',
|
6799
|
LINK_VALUE: 'linkValue',
|
|
|
6800
|
+
|
|
|
6801
|
+ /**
|
|
|
6802
|
+ * @description 下发指令
|
|
|
6803
|
+ */
|
|
|
6804
|
+ COMMAND: 'command',
|
|
|
6805
|
+
|
|
|
6806
|
+ /**
|
|
|
6807
|
+ * @description 属性占位符
|
|
|
6808
|
+ */
|
|
|
6809
|
+ ATTR_PLACEHOLDER: 'attrPlaceholder',
|
|
|
6810
|
+
|
|
|
6811
|
+ WAY: 'way'
|
6800
|
}
|
6812
|
}
|
6801
|
|
6813
|
|
6802
|
/**
|
6814
|
/**
|
|
@@ -6809,6 +6821,11 @@ DataFormatPanel.prototype.addDataFont = function (container) { |
|
@@ -6809,6 +6821,11 @@ DataFormatPanel.prototype.addDataFont = function (container) { |
6809
|
[enumActionType.LINK]: enumConst.LINK_VALUE,
|
6821
|
[enumActionType.LINK]: enumConst.LINK_VALUE,
|
6810
|
}
|
6822
|
}
|
6811
|
|
6823
|
|
|
|
6824
|
+ const enumWayType = {
|
|
|
6825
|
+ ONE_WAY: 'oneway',
|
|
|
6826
|
+ TWO_WAY: 'twoway'
|
|
|
6827
|
+ }
|
|
|
6828
|
+
|
6812
|
const enumActionEl = {
|
6829
|
const enumActionEl = {
|
6813
|
/**
|
6830
|
/**
|
6814
|
* @description 表单 lay-filter
|
6831
|
* @description 表单 lay-filter
|
|
@@ -6834,6 +6851,18 @@ DataFormatPanel.prototype.addDataFont = function (container) { |
|
@@ -6834,6 +6851,18 @@ DataFormatPanel.prototype.addDataFont = function (container) { |
6834
|
* @description layer submit filter
|
6851
|
* @description layer submit filter
|
6835
|
*/
|
6852
|
*/
|
6836
|
LAYER_SUBMIT_FILTER: 'dynamicLinkLayerFilter',
|
6853
|
LAYER_SUBMIT_FILTER: 'dynamicLinkLayerFilter',
|
|
|
6854
|
+
|
|
|
6855
|
+ /**
|
|
|
6856
|
+ * @description JSON 编辑器容器
|
|
|
6857
|
+ */
|
|
|
6858
|
+ EDITOR_CONTAINER: 'editorContainerEL',
|
|
|
6859
|
+
|
|
|
6860
|
+ /**
|
|
|
6861
|
+ * @description JSON 编辑器
|
|
|
6862
|
+ */
|
|
|
6863
|
+ EDITOR: 'EDITOR',
|
|
|
6864
|
+
|
|
|
6865
|
+ WAY_SELECT: 'dynamicWaySelectEl'
|
6837
|
}
|
6866
|
}
|
6838
|
|
6867
|
|
6839
|
/**
|
6868
|
/**
|
|
@@ -6851,15 +6880,33 @@ DataFormatPanel.prototype.addDataFont = function (container) { |
|
@@ -6851,15 +6880,33 @@ DataFormatPanel.prototype.addDataFont = function (container) { |
6851
|
const val = {
|
6880
|
const val = {
|
6852
|
[enumConst.ACTION]: content.type,
|
6881
|
[enumConst.ACTION]: content.type,
|
6853
|
[enumGetValue[content.type]]: content.value,
|
6882
|
[enumGetValue[content.type]]: content.value,
|
|
|
6883
|
+ [enumConst.WAY]: content[enumConst.WAY]
|
6854
|
}
|
6884
|
}
|
6855
|
- if (content.type === enumActionType.PAGE) {
|
|
|
6856
|
- $(`#${enumActionEl.PAGE_EL_ID}`).css({ display: 'block' })
|
6885
|
+ controlFormDisplay(content.type)
|
|
|
6886
|
+ form.val(enumActionEl.FORM_FILTER, val)
|
|
|
6887
|
+ }
|
|
|
6888
|
+
|
|
|
6889
|
+ /**
|
|
|
6890
|
+ * @description 控制form
|
|
|
6891
|
+ * @param {enumActionType} value
|
|
|
6892
|
+ */
|
|
|
6893
|
+ function controlFormDisplay(value) {
|
|
|
6894
|
+ if (value === enumActionType.PAGE) {
|
6857
|
$(`#${enumActionEl.LINK_EL_ID}`).css({ display: 'none' })
|
6895
|
$(`#${enumActionEl.LINK_EL_ID}`).css({ display: 'none' })
|
6858
|
- } else if (content.type === enumActionType.PARAMS_SETTING) {
|
6896
|
+ $(`#${enumActionEl.PAGE_EL_ID}`).css({ display: 'block' })
|
|
|
6897
|
+ $(`#${enumActionEl.EDITOR_CONTAINER}`).css({ display: 'none' })
|
|
|
6898
|
+ $(`#${enumActionEl.WAY_SELECT}`).css({ display: 'none' })
|
|
|
6899
|
+ } else if (value === enumActionType.LINK) {
|
6859
|
$(`#${enumActionEl.PAGE_EL_ID}`).css({ display: 'none' })
|
6900
|
$(`#${enumActionEl.PAGE_EL_ID}`).css({ display: 'none' })
|
|
|
6901
|
+ $(`#${enumActionEl.LINK_EL_ID}`).css({ display: 'block' })
|
|
|
6902
|
+ $(`#${enumActionEl.EDITOR_CONTAINER}`).css({ display: 'none' })
|
|
|
6903
|
+ $(`#${enumActionEl.WAY_SELECT}`).css({ display: 'none' })
|
|
|
6904
|
+ } else if (value === enumActionType.PARAMS_SETTING) {
|
6860
|
$(`#${enumActionEl.LINK_EL_ID}`).css({ display: 'none' })
|
6905
|
$(`#${enumActionEl.LINK_EL_ID}`).css({ display: 'none' })
|
|
|
6906
|
+ $(`#${enumActionEl.PAGE_EL_ID}`).css({ display: 'none' })
|
|
|
6907
|
+ $(`#${enumActionEl.EDITOR_CONTAINER}`).css({ display: 'flex' })
|
|
|
6908
|
+ $(`#${enumActionEl.WAY_SELECT}`).css({ display: 'block' })
|
6861
|
}
|
6909
|
}
|
6862
|
- form.val(enumActionEl.FORM_FILTER, val)
|
|
|
6863
|
}
|
6910
|
}
|
6864
|
|
6911
|
|
6865
|
/**
|
6912
|
/**
|
|
@@ -6867,6 +6914,15 @@ DataFormatPanel.prototype.addDataFont = function (container) { |
|
@@ -6867,6 +6914,15 @@ DataFormatPanel.prototype.addDataFont = function (container) { |
6867
|
*/
|
6914
|
*/
|
6868
|
async function submit(callback) {
|
6915
|
async function submit(callback) {
|
6869
|
const formVal = form.val(enumActionEl.FORM_FILTER)
|
6916
|
const formVal = form.val(enumActionEl.FORM_FILTER)
|
|
|
6917
|
+ const isParamsSetting = formVal[enumConst.ACTION] === enumActionType.PARAMS_SETTING
|
|
|
6918
|
+ if (isParamsSetting) {
|
|
|
6919
|
+ if (!isJson(formVal[enumConst.COMMAND])) {
|
|
|
6920
|
+ console.log()
|
|
|
6921
|
+ UseLayUi.topErrorMsg('命令配置存在错误')
|
|
|
6922
|
+ return
|
|
|
6923
|
+ }
|
|
|
6924
|
+ }
|
|
|
6925
|
+
|
6870
|
const data = {
|
6926
|
const data = {
|
6871
|
type: event.data.type,
|
6927
|
type: event.data.type,
|
6872
|
configurationId,
|
6928
|
configurationId,
|
|
@@ -6877,6 +6933,10 @@ DataFormatPanel.prototype.addDataFont = function (container) { |
|
@@ -6877,6 +6933,10 @@ DataFormatPanel.prototype.addDataFont = function (container) { |
6877
|
content: {
|
6933
|
content: {
|
6878
|
type: formVal[enumConst.ACTION],
|
6934
|
type: formVal[enumConst.ACTION],
|
6879
|
value: formVal[enumGetValue[formVal[enumConst.ACTION]]],
|
6935
|
value: formVal[enumGetValue[formVal[enumConst.ACTION]]],
|
|
|
6936
|
+ ...(isParamsSetting ? {
|
|
|
6937
|
+ [enumConst.COMMAND]: formVal[enumConst.COMMAND],
|
|
|
6938
|
+ [enumConst.WAY]: formVal[enumConst.WAY]
|
|
|
6939
|
+ } : {}),
|
6880
|
},
|
6940
|
},
|
6881
|
}
|
6941
|
}
|
6882
|
await to(autoSaveGraphInfo())
|
6942
|
await to(autoSaveGraphInfo())
|
|
@@ -6912,16 +6972,53 @@ DataFormatPanel.prototype.addDataFont = function (container) { |
|
@@ -6912,16 +6972,53 @@ DataFormatPanel.prototype.addDataFont = function (container) { |
6912
|
function generatorEventListen() {
|
6972
|
function generatorEventListen() {
|
6913
|
form.on(`select(${enumActionEl.ACTION_SELECT_FILTER})`, (data) => {
|
6973
|
form.on(`select(${enumActionEl.ACTION_SELECT_FILTER})`, (data) => {
|
6914
|
const { value } = data
|
6974
|
const { value } = data
|
6915
|
- if (value === enumActionType.PAGE) {
|
|
|
6916
|
- $(`#${enumActionEl.LINK_EL_ID}`).css({ display: 'none' })
|
|
|
6917
|
- $(`#${enumActionEl.PAGE_EL_ID}`).css({ display: 'block' })
|
|
|
6918
|
- } else if (value === enumActionType.LINK) {
|
|
|
6919
|
- $(`#${enumActionEl.PAGE_EL_ID}`).css({ display: 'none' })
|
|
|
6920
|
- $(`#${enumActionEl.LINK_EL_ID}`).css({ display: 'block' })
|
|
|
6921
|
- } else if (value === enumActionType.PARAMS_SETTING) {
|
|
|
6922
|
- $(`#${enumActionEl.LINK_EL_ID}`).css({ display: 'none' })
|
|
|
6923
|
- $(`#${enumActionEl.PAGE_EL_ID}`).css({ display: 'none' })
|
6975
|
+ controlFormDisplay(value)
|
|
|
6976
|
+ })
|
|
|
6977
|
+ }
|
|
|
6978
|
+
|
|
|
6979
|
+ function isJson(string) {
|
|
|
6980
|
+ if (typeof string === 'string') {
|
|
|
6981
|
+ try {
|
|
|
6982
|
+ const obj = JSON.parse(string)
|
|
|
6983
|
+ if (typeof obj === 'object' && obj !== null) {
|
|
|
6984
|
+ return true
|
|
|
6985
|
+ }
|
|
|
6986
|
+ } catch (e) {
|
|
|
6987
|
+ return false
|
6924
|
}
|
6988
|
}
|
|
|
6989
|
+ }
|
|
|
6990
|
+ return false
|
|
|
6991
|
+ }
|
|
|
6992
|
+
|
|
|
6993
|
+ function jsonParse(value) {
|
|
|
6994
|
+ try {
|
|
|
6995
|
+ return JSON.parse(value)
|
|
|
6996
|
+ } catch (error) {
|
|
|
6997
|
+ return {}
|
|
|
6998
|
+ }
|
|
|
6999
|
+ }
|
|
|
7000
|
+
|
|
|
7001
|
+
|
|
|
7002
|
+ /**
|
|
|
7003
|
+ * @description 创建JSON编辑器
|
|
|
7004
|
+ * @param el
|
|
|
7005
|
+ * @param datum
|
|
|
7006
|
+ */
|
|
|
7007
|
+ function createEditor(record) {
|
|
|
7008
|
+ let defaultValue = { [enumConst.ATTR_PLACEHOLDER]: 0 }
|
|
|
7009
|
+ const editor = ace.edit(enumActionEl.EDITOR, {
|
|
|
7010
|
+ maxLines: 18, // 最大行数,超过会自动出现滚动条
|
|
|
7011
|
+ minLines: 10, // 最小行数,还未到最大行数时,编辑器会自动伸缩大小
|
|
|
7012
|
+ fontSize: 14, // 编辑器内字体大小
|
|
|
7013
|
+ tabSize: 2, // 制表符设置为 4 个空格大小
|
|
|
7014
|
+ });
|
|
|
7015
|
+ if (record.content && record.content[enumConst.COMMAND]) defaultValue = jsonParse(record.content[enumConst.COMMAND])
|
|
|
7016
|
+ const stringValue = JSON.stringify(defaultValue, null, 2)
|
|
|
7017
|
+ editor.insert(stringValue)
|
|
|
7018
|
+ $(`#${enumActionEl.EDITOR_CONTAINER}`).parent().find(`textarea[name="${enumConst.COMMAND}"]`).val(stringValue)
|
|
|
7019
|
+ editor.session.setMode("ace/mode/json");
|
|
|
7020
|
+ editor.getSession().on('change', (event, editor) => {
|
|
|
7021
|
+ $(`#${enumActionEl.EDITOR_CONTAINER}`).parent().find(`textarea[name="${enumConst.COMMAND}"]`).val(editor.getValue())
|
6925
|
})
|
7022
|
})
|
6926
|
}
|
7023
|
}
|
6927
|
|
7024
|
|
|
@@ -6932,7 +7029,7 @@ DataFormatPanel.prototype.addDataFont = function (container) { |
|
@@ -6932,7 +7029,7 @@ DataFormatPanel.prototype.addDataFont = function (container) { |
6932
|
|
7029
|
|
6933
|
const content = `
|
7030
|
const content = `
|
6934
|
<form class="layui-form" lay-filter="${enumActionEl.FORM_FILTER}">
|
7031
|
<form class="layui-form" lay-filter="${enumActionEl.FORM_FILTER}">
|
6935
|
- <div style="width:400px">
|
7032
|
+ <div style="width: 450px">
|
6936
|
<div class="layui-form-item">
|
7033
|
<div class="layui-form-item">
|
6937
|
<label class="layui-form-label">事件</label>
|
7034
|
<label class="layui-form-label">事件</label>
|
6938
|
<div class="layui-input-block">
|
7035
|
<div class="layui-input-block">
|
|
@@ -6961,6 +7058,18 @@ DataFormatPanel.prototype.addDataFont = function (container) { |
|
@@ -6961,6 +7058,18 @@ DataFormatPanel.prototype.addDataFont = function (container) { |
6961
|
</select>
|
7058
|
</select>
|
6962
|
</div>
|
7059
|
</div>
|
6963
|
</div>
|
7060
|
</div>
|
|
|
7061
|
+ <div class="layui-form-item" id="${enumActionEl.WAY_SELECT}" style="display:none">
|
|
|
7062
|
+ <label class="layui-form-label">单向/双向</label>
|
|
|
7063
|
+ <div class="layui-input-block">
|
|
|
7064
|
+ <input type="radio" name="${enumConst.WAY}" value="${enumWayType.ONE_WAY}" title="单向" checked="">
|
|
|
7065
|
+ <input type="radio" name="${enumConst.WAY}" value="${enumWayType.TWO_WAY}" title="双向">
|
|
|
7066
|
+ </div>
|
|
|
7067
|
+ </div>
|
|
|
7068
|
+ <div id="${enumActionEl.EDITOR_CONTAINER}" style="display: none;">
|
|
|
7069
|
+ <div style="width: 80px; text-align: right; padding: 9px 15px;flex: 0 0 80px;">命令</div>
|
|
|
7070
|
+ <div id="${enumActionEl.EDITOR}" style="width: 100%; height: 100%;border: 2px solid #eee;"></div>
|
|
|
7071
|
+ <textarea name="${enumConst.COMMAND}" style="display: none;" />
|
|
|
7072
|
+ </div>
|
6964
|
</div>
|
7073
|
</div>
|
6965
|
</form>
|
7074
|
</form>
|
6966
|
`
|
7075
|
`
|
|
@@ -6989,6 +7098,7 @@ DataFormatPanel.prototype.addDataFont = function (container) { |
|
@@ -6989,6 +7098,7 @@ DataFormatPanel.prototype.addDataFont = function (container) { |
6989
|
generatorEventListen()
|
7098
|
generatorEventListen()
|
6990
|
const info = getLayerBindInfo('event', type)
|
7099
|
const info = getLayerBindInfo('event', type)
|
6991
|
Object.assign(recordData, { enabled: info.enabled })
|
7100
|
Object.assign(recordData, { enabled: info.enabled })
|
|
|
7101
|
+ createEditor(info)
|
6992
|
form.render(null, enumActionEl.FORM_FILTER)
|
7102
|
form.render(null, enumActionEl.FORM_FILTER)
|
6993
|
if (info) echoFormData(info)
|
7103
|
if (info) echoFormData(info)
|
6994
|
},
|
7104
|
},
|
|
@@ -8163,6 +8273,10 @@ DataFormatPanel.prototype.addDataFont = function (container) { |
|
@@ -8163,6 +8273,10 @@ DataFormatPanel.prototype.addDataFont = function (container) { |
8163
|
return { getValue, setValue }
|
8273
|
return { getValue, setValue }
|
8164
|
}
|
8274
|
}
|
8165
|
|
8275
|
|
|
|
8276
|
+ function createHelpMessage() {
|
|
|
8277
|
+ return `<span class="thingskit-help-message"><img src="${Proxy_Prefix}/images/thingskit/question.svg" /></span>`
|
|
|
8278
|
+ }
|
|
|
8279
|
+
|
8166
|
// 异步设置此处才能生效 -- 设置默认select和样式和初始化侧边栏生成组件和事件绑定
|
8280
|
// 异步设置此处才能生效 -- 设置默认select和样式和初始化侧边栏生成组件和事件绑定
|
8167
|
setTimeout(() => {
|
8281
|
setTimeout(() => {
|
8168
|
|
8282
|
|
|
@@ -13672,6 +13786,13 @@ class HandleDataInteraction { |
|
@@ -13672,6 +13786,13 @@ class HandleDataInteraction { |
13672
|
}
|
13786
|
}
|
13673
|
|
13787
|
|
13674
|
/**
|
13788
|
/**
|
|
|
13789
|
+ * @description 获取页面数据
|
|
|
13790
|
+ */
|
|
|
13791
|
+ get contentData() {
|
|
|
13792
|
+ return DispatchCenter.instance.contentData
|
|
|
13793
|
+ }
|
|
|
13794
|
+
|
|
|
13795
|
+ /**
|
13675
|
* @description 事件映射
|
13796
|
* @description 事件映射
|
13676
|
*/
|
13797
|
*/
|
13677
|
generatorEventMapping() {
|
13798
|
generatorEventMapping() {
|
|
@@ -13772,7 +13893,7 @@ class HandleDataInteraction { |
|
@@ -13772,7 +13893,7 @@ class HandleDataInteraction { |
13772
|
} else if (type === DispatchCenter.enumPageType.LINK && value) {
|
13893
|
} else if (type === DispatchCenter.enumPageType.LINK && value) {
|
13773
|
window.open(value)
|
13894
|
window.open(value)
|
13774
|
} else if (type === DispatchCenter.enumPageType.PARAMS_SETTING) {
|
13895
|
} else if (type === DispatchCenter.enumPageType.PARAMS_SETTING) {
|
13775
|
- this.paramsSetting(id)
|
13896
|
+ this.paramsSetting(id, content)
|
13776
|
}
|
13897
|
}
|
13777
|
}
|
13898
|
}
|
13778
|
}
|
13899
|
}
|
|
@@ -13865,13 +13986,15 @@ class HandleDataInteraction { |
|
@@ -13865,13 +13986,15 @@ class HandleDataInteraction { |
13865
|
/**
|
13986
|
/**
|
13866
|
* @description 参数设置
|
13987
|
* @description 参数设置
|
13867
|
*/
|
13988
|
*/
|
13868
|
- paramsSetting(nodeId) {
|
13989
|
+ paramsSetting(nodeId, content) {
|
13869
|
const { layer, jquery: $, form } = layui
|
13990
|
const { layer, jquery: $, form } = layui
|
|
|
13991
|
+ const contentData = this.contentData
|
13870
|
const enumConst = {
|
13992
|
const enumConst = {
|
13871
|
VALUE: 'value',
|
13993
|
VALUE: 'value',
|
13872
|
ISSUED_WAY: 'way',
|
13994
|
ISSUED_WAY: 'way',
|
13873
|
- ONE_WAR: 'oneway',
|
|
|
13874
|
- TWO_WAY: 'twoway'
|
13995
|
+ ONE_WAY: 'oneway',
|
|
|
13996
|
+ TWO_WAY: 'twoway',
|
|
|
13997
|
+ ATTR_PLACEHOLDER: 'attrPlaceholder'
|
13875
|
}
|
13998
|
}
|
13876
|
|
13999
|
|
13877
|
const enumActionEl = {
|
14000
|
const enumActionEl = {
|
|
@@ -13881,40 +14004,17 @@ class HandleDataInteraction { |
|
@@ -13881,40 +14004,17 @@ class HandleDataInteraction { |
13881
|
|
14004
|
|
13882
|
}
|
14005
|
}
|
13883
|
|
14006
|
|
13884
|
- /**
|
|
|
13885
|
- * @description 创建JSON编辑器
|
|
|
13886
|
- * @param el
|
|
|
13887
|
- * @param datum
|
|
|
13888
|
- */
|
|
|
13889
|
- function createEditor() {
|
|
|
13890
|
- const editor = ace.edit(enumActionEl.EDITOR, {
|
|
|
13891
|
- maxLines: 18, // 最大行数,超过会自动出现滚动条
|
|
|
13892
|
- minLines: 10, // 最小行数,还未到最大行数时,编辑器会自动伸缩大小
|
|
|
13893
|
- fontSize: 14, // 编辑器内字体大小
|
|
|
13894
|
- tabSize: 2, // 制表符设置为 4 个空格大小
|
|
|
13895
|
- });
|
|
|
13896
|
- editor.session.setMode("ace/mode/json");
|
|
|
13897
|
- editor.getSession().on('change', (event, editor) => {
|
|
|
13898
|
- $(`#${enumActionEl.CONTAINER}`).parent().find(`textarea[name="${enumConst.VALUE}"]`).val(editor.getValue())
|
|
|
13899
|
- })
|
|
|
13900
|
- }
|
|
|
13901
|
-
|
|
|
13902
|
function createContent() {
|
14007
|
function createContent() {
|
13903
|
return `
|
14008
|
return `
|
13904
|
<div>
|
14009
|
<div>
|
13905
|
<div class="layui-form" lay-filter="${enumActionEl.ISSUED_WAY_FILTER}">
|
14010
|
<div class="layui-form" lay-filter="${enumActionEl.ISSUED_WAY_FILTER}">
|
13906
|
<div class="layui-form-item">
|
14011
|
<div class="layui-form-item">
|
13907
|
- <label class="layui-form-label">单向/双向</label>
|
14012
|
+ <label class="layui-form-label">下发值</label>
|
13908
|
<div class="layui-input-block">
|
14013
|
<div class="layui-input-block">
|
13909
|
- <input type="radio" name="${enumConst.ISSUED_WAY}" value="${enumConst.ONE_WAR}" title="单向" checked="">
|
|
|
13910
|
- <input type="radio" name="${enumConst.ISSUED_WAY}" value="${enumConst.TWO_WAY}" title="双向">
|
14014
|
+ <input type="text" name="${enumConst.VALUE}" lay-verify="required" autocomplete="off" placeholder="请输入下发值" class="layui-input">
|
13911
|
</div>
|
14015
|
</div>
|
13912
|
</div>
|
14016
|
</div>
|
13913
|
</div>
|
14017
|
</div>
|
13914
|
- <div id="${enumActionEl.CONTAINER}">
|
|
|
13915
|
- <div id="${enumActionEl.EDITOR}"></div>
|
|
|
13916
|
- <textarea name="${enumConst.VALUE}" style="display: none;" />
|
|
|
13917
|
- </div>
|
|
|
13918
|
</div>`
|
14018
|
</div>`
|
13919
|
}
|
14019
|
}
|
13920
|
|
14020
|
|
|
@@ -13931,25 +14031,45 @@ class HandleDataInteraction { |
|
@@ -13931,25 +14031,45 @@ class HandleDataInteraction { |
13931
|
}
|
14031
|
}
|
13932
|
return false
|
14032
|
return false
|
13933
|
}
|
14033
|
}
|
13934
|
- const submitThrottle = this.throttle(submit)
|
|
|
13935
|
- async function submit(callback) {
|
|
|
13936
|
- const value = $(`#${enumActionEl.CONTAINER}`).parent().find(`textarea[name="${enumConst.VALUE}"]`).val() || ''
|
|
|
13937
|
- if (!isJson(value)) {
|
|
|
13938
|
- UseLayUi.topErrorMsg('下发值不正确')
|
|
|
13939
|
- return
|
14034
|
+
|
|
|
14035
|
+ function jsonParse(value) {
|
|
|
14036
|
+ try {
|
|
|
14037
|
+ return JSON.parse(value)
|
|
|
14038
|
+ } catch (error) {
|
|
|
14039
|
+ return {}
|
|
|
14040
|
+ }
|
|
|
14041
|
+ }
|
|
|
14042
|
+
|
|
|
14043
|
+ function replaceAttrPlaceholder(oldValue = {}, replaceAttr = '', replaceValue = '', newValue = {},) {
|
|
|
14044
|
+ if (typeof oldValue !== 'object') return newValue
|
|
|
14045
|
+
|
|
|
14046
|
+ for (const key of Object.keys(oldValue)) {
|
|
|
14047
|
+ if (key === enumConst.ATTR_PLACEHOLDER) {
|
|
|
14048
|
+ newValue[replaceAttr] = replaceValue
|
|
|
14049
|
+ continue
|
|
|
14050
|
+ }
|
|
|
14051
|
+ if (typeof oldValue[key] === 'object') {
|
|
|
14052
|
+ newValue[key] = replaceAttrPlaceholder(oldValue[key], replaceAttr, replaceValue)
|
|
|
14053
|
+ }
|
|
|
14054
|
+ newValue[key] = oldValue[key]
|
13940
|
}
|
14055
|
}
|
13941
|
- const { way } = form.val(enumActionEl.ISSUED_WAY_FILTER)
|
|
|
13942
|
- const data = JSON.parse(value)
|
|
|
13943
|
- let { deviceId, slaveDeviceId } = DispatchCenter.instance.contentData.dataSources.find(item => item.nodeId === nodeId) || {}
|
|
|
13944
|
|
14056
|
|
13945
|
- if (!value || !deviceId) return
|
14057
|
+ return newValue
|
|
|
14058
|
+ }
|
|
|
14059
|
+
|
|
|
14060
|
+ const submitThrottle = this.throttle(submit)
|
|
|
14061
|
+ async function submit(callback) {
|
|
|
14062
|
+ const { value } = form.val(enumActionEl.ISSUED_WAY_FILTER)
|
|
|
14063
|
+ let { deviceId, attr } = contentData.dataSources.find(item => item.nodeId === nodeId) || {}
|
|
|
14064
|
+ let { command, way } = content
|
|
|
14065
|
+ const validate = [value, deviceId, way, command, attr]
|
|
|
14066
|
+ if (!validate.every(Boolean)) return
|
|
|
14067
|
+ if (typeof command === 'string') command = jsonParse(command)
|
|
|
14068
|
+ const data = replaceAttrPlaceholder(command, attr, value)
|
13946
|
const instructionData = {
|
14069
|
const instructionData = {
|
13947
|
method: "methodThingskit",
|
14070
|
method: "methodThingskit",
|
13948
|
params: data,
|
14071
|
params: data,
|
13949
|
}
|
14072
|
}
|
13950
|
- // if (slaveDeviceId) {
|
|
|
13951
|
- // deviceId = slaveDeviceId
|
|
|
13952
|
- // }
|
|
|
13953
|
|
14073
|
|
13954
|
const [err, res = []] = await to(ConfigurationNodeApi.deviceIsOnLine(deviceId))
|
14074
|
const [err, res = []] = await to(ConfigurationNodeApi.deviceIsOnLine(deviceId))
|
13955
|
const { value: onlineFlag } = res[0] || {}
|
14075
|
const { value: onlineFlag } = res[0] || {}
|
|
@@ -13969,7 +14089,7 @@ class HandleDataInteraction { |
|
@@ -13969,7 +14089,7 @@ class HandleDataInteraction { |
13969
|
layer.open({
|
14089
|
layer.open({
|
13970
|
title: '参数设置',
|
14090
|
title: '参数设置',
|
13971
|
content: createContent(),
|
14091
|
content: createContent(),
|
13972
|
- area: '600px',
|
14092
|
+ area: '400px',
|
13973
|
btn: ["应用", "取消"],
|
14093
|
btn: ["应用", "取消"],
|
13974
|
yes(index) {
|
14094
|
yes(index) {
|
13975
|
submitThrottle(() => {
|
14095
|
submitThrottle(() => {
|
|
@@ -13980,12 +14100,7 @@ class HandleDataInteraction { |
|
@@ -13980,12 +14100,7 @@ class HandleDataInteraction { |
13980
|
|
14100
|
|
13981
|
},
|
14101
|
},
|
13982
|
async success(layero, index) {
|
14102
|
async success(layero, index) {
|
13983
|
- createEditor(enumActionEl.EDITOR)
|
|
|
13984
|
form.render()
|
14103
|
form.render()
|
13985
|
- // $(layero).addClass('layui-form').find('.layui-layer-btn0').attr({
|
|
|
13986
|
- // 'lay-submit': '',
|
|
|
13987
|
- // 'lay-filter': enumActionEl.IMAGE_LAYER_FILTER,
|
|
|
13988
|
- // })
|
|
|
13989
|
},
|
14104
|
},
|
13990
|
})
|
14105
|
})
|
13991
|
}
|
14106
|
}
|