Commit ad950e6785f9db43f576811bc284c981840c239f
1 parent
df4c41a0
feat: complete right data source console
Showing
2 changed files
with
494 additions
and
179 deletions
@@ -87,4 +87,7 @@ class ConfigurationNodeApi { | @@ -87,4 +87,7 @@ class ConfigurationNodeApi { | ||
87 | static updateNodeInfo(data) { | 87 | static updateNodeInfo(data) { |
88 | return defHttp.post('/yt/configuration/node', data) | 88 | return defHttp.post('/yt/configuration/node', data) |
89 | } | 89 | } |
90 | + | ||
91 | + | ||
92 | + | ||
90 | } | 93 | } |
@@ -4878,12 +4878,13 @@ DataFormatPanel.prototype.addDataFont = function (container) { | @@ -4878,12 +4878,13 @@ DataFormatPanel.prototype.addDataFont = function (container) { | ||
4878 | const editor = ui.editor; | 4878 | const editor = ui.editor; |
4879 | const graph = editor.graph; | 4879 | const graph = editor.graph; |
4880 | const ss = ui.getSelectionState(); | 4880 | const ss = ui.getSelectionState(); |
4881 | + const vertices = ss.vertices || [] | ||
4881 | 4882 | ||
4882 | - console.log(ss.vertices) | 4883 | + console.log(vertices) |
4883 | /** | 4884 | /** |
4884 | * @description 不是单一节点则不进入数据绑定 | 4885 | * @description 不是单一节点则不进入数据绑定 |
4885 | */ | 4886 | */ |
4886 | - if (!isSingleNode(ss.vertices)) return | 4887 | + if (!isSingleNode(vertices)) return |
4887 | 4888 | ||
4888 | // 组态id | 4889 | // 组态id |
4889 | const configurationId = getRequest().configurationId; | 4890 | const configurationId = getRequest().configurationId; |
@@ -4891,7 +4892,7 @@ DataFormatPanel.prototype.addDataFont = function (container) { | @@ -4891,7 +4892,7 @@ DataFormatPanel.prototype.addDataFont = function (container) { | ||
4891 | const currentPageId = ui.currentPage.node; | 4892 | const currentPageId = ui.currentPage.node; |
4892 | 4893 | ||
4893 | // 图形的id | 4894 | // 图形的id |
4894 | - const graphId = ss.vertices[0].id; | 4895 | + const graphId = vertices[0].id; |
4895 | 4896 | ||
4896 | // 解构全局属性layui要用到的模块 | 4897 | // 解构全局属性layui要用到的模块 |
4897 | const { layer, form, jquery: $ } = layui; | 4898 | const { layer, form, jquery: $ } = layui; |
@@ -4914,7 +4915,7 @@ DataFormatPanel.prototype.addDataFont = function (container) { | @@ -4914,7 +4915,7 @@ DataFormatPanel.prototype.addDataFont = function (container) { | ||
4914 | * @description 选中节点信息来源 | 4915 | * @description 选中节点信息来源 |
4915 | * @param {string} nodeInfo.id - 节点ID | 4916 | * @param {string} nodeInfo.id - 节点ID |
4916 | */ | 4917 | */ |
4917 | - const nodeInfo = getNodeInfo(ss.vertices) | 4918 | + const nodeInfo = getNodeInfo(vertices) |
4918 | 4919 | ||
4919 | 4920 | ||
4920 | /** | 4921 | /** |
@@ -5008,15 +5009,16 @@ DataFormatPanel.prototype.addDataFont = function (container) { | @@ -5008,15 +5009,16 @@ DataFormatPanel.prototype.addDataFont = function (container) { | ||
5008 | }, | 5009 | }, |
5009 | ]; | 5010 | ]; |
5010 | 5011 | ||
5011 | - const enumDataSourceConst = (() => { | ||
5012 | - return { | ||
5013 | - ORG_ID: 'orgId', | ||
5014 | - DEVICE_ID: 'deviceId', | ||
5015 | - SLAVE_DEVICE_ID: 'slaveDeviceId', | ||
5016 | - ATTR: 'attr', | ||
5017 | - GATEWAY: 'GATEWAY' | ||
5018 | - } | ||
5019 | - })() | 5012 | + const enumDataSourceConst = { |
5013 | + ORG_ID: 'orgId', | ||
5014 | + DEVICE_ID: 'deviceId', | ||
5015 | + SLAVE_DEVICE_ID: 'slaveDeviceId', | ||
5016 | + ATTR: 'attr', | ||
5017 | + GATEWAY: 'GATEWAY' | ||
5018 | + } | ||
5019 | + | ||
5020 | + let echoRefreshFn = null | ||
5021 | + | ||
5020 | 5022 | ||
5021 | 5023 | ||
5022 | // 获取url的请求参数函数 | 5024 | // 获取url的请求参数函数 |
@@ -5067,12 +5069,16 @@ DataFormatPanel.prototype.addDataFont = function (container) { | @@ -5067,12 +5069,16 @@ DataFormatPanel.prototype.addDataFont = function (container) { | ||
5067 | /** | 5069 | /** |
5068 | * @description 获取节点绑定信息 | 5070 | * @description 获取节点绑定信息 |
5069 | */ | 5071 | */ |
5070 | - function getNodeBindInfo() { | 5072 | + async function getNodeBindInfo() { |
5071 | const { id } = nodeInfo | 5073 | const { id } = nodeInfo |
5072 | - return ConfigurationNodeApi.getConfigurationInfo('NODE', id) | 5074 | + const [err, res] = await to(ConfigurationNodeApi.getConfigurationInfo('NODE', id)) |
5075 | + currentNodeData = res | ||
5076 | + if (echoRefreshFn && typeof echoRefreshFn === 'function') echoRefreshFn() | ||
5073 | } | 5077 | } |
5074 | 5078 | ||
5075 | 5079 | ||
5080 | + | ||
5081 | + | ||
5076 | /** | 5082 | /** |
5077 | * @description 生成数据交互面板 | 5083 | * @description 生成数据交互面板 |
5078 | * @returns {Array} | 5084 | * @returns {Array} |
@@ -5157,8 +5163,6 @@ DataFormatPanel.prototype.addDataFont = function (container) { | @@ -5157,8 +5163,6 @@ DataFormatPanel.prototype.addDataFont = function (container) { | ||
5157 | treeProps: { | 5163 | treeProps: { |
5158 | data: treeList, | 5164 | data: treeList, |
5159 | onlyIconControl: true, | 5165 | onlyIconControl: true, |
5160 | - onReady(setValue) { | ||
5161 | - }, | ||
5162 | click(node) { | 5166 | click(node) { |
5163 | currentCheckedOrgNode = node.data.id | 5167 | currentCheckedOrgNode = node.data.id |
5164 | getDevicesByOrgId(node.data.id) | 5168 | getDevicesByOrgId(node.data.id) |
@@ -5262,37 +5266,44 @@ DataFormatPanel.prototype.addDataFont = function (container) { | @@ -5262,37 +5266,44 @@ DataFormatPanel.prototype.addDataFont = function (container) { | ||
5262 | * @description 数据回显 | 5266 | * @description 数据回显 |
5263 | */ | 5267 | */ |
5264 | async function echoData() { | 5268 | async function echoData() { |
5265 | - const [err, res] = await to(getNodeBindInfo()) | ||
5266 | - if (err || !Object.keys(res).length) return | ||
5267 | - currentNodeData = res | ||
5268 | 5269 | ||
5269 | - echoDataSource() | ||
5270 | - echoActionType() | 5270 | + echoRefreshFn = () => { |
5271 | + echoDataSource() | ||
5272 | + echoActionType() | ||
5273 | + form.render(null, CONTAINER_FILTER) | ||
5274 | + } | ||
5275 | + | ||
5276 | + await getNodeBindInfo() | ||
5277 | + | ||
5278 | + | ||
5271 | 5279 | ||
5272 | function echoDataSource() { | 5280 | function echoDataSource() { |
5273 | const { dataSources = [] } = currentNodeData | 5281 | const { dataSources = [] } = currentNodeData |
5274 | - const [ dataSource = {} ] = dataSources | ||
5275 | - const { orgId, deviceId, slaveDeviceId, attr: [bindAttr] = [] } = dataSource | 5282 | + const [dataSource = {}] = dataSources |
5283 | + const { orgId, deviceId, slaveDeviceId, attr } = dataSource | ||
5276 | const queue = [] | 5284 | const queue = [] |
5277 | if (orgId) { | 5285 | if (orgId) { |
5278 | currentCheckedOrgNode = orgId | 5286 | currentCheckedOrgNode = orgId |
5279 | queue.push(() => getDevicesByOrgId(orgId)) | 5287 | queue.push(() => getDevicesByOrgId(orgId)) |
5280 | } | 5288 | } |
5281 | if (slaveDeviceId) { | 5289 | if (slaveDeviceId) { |
5282 | - queue.push(() => getSlaveDeviceByMasterDeviceId(orgId, deviceId)) | 5290 | + queue.push(() => { |
5291 | + getSlaveDeviceByMasterDeviceId(orgId, deviceId) | ||
5292 | + $(`#${enumActionEl.SLAVE_DEVICE_EL}`).css({ display: 'block' }) | ||
5293 | + }) | ||
5283 | queue.push(() => getAttrByDeviceId(slaveDeviceId)) | 5294 | queue.push(() => getAttrByDeviceId(slaveDeviceId)) |
5284 | } else { | 5295 | } else { |
5285 | queue.push(() => getAttrByDeviceId(deviceId)) | 5296 | queue.push(() => getAttrByDeviceId(deviceId)) |
5286 | } | 5297 | } |
5287 | Promise.all(queue.map(item => item())) | 5298 | Promise.all(queue.map(item => item())) |
5288 | .finally(() => { | 5299 | .finally(() => { |
5289 | - const orgNode = UseLayUi.findTreeObjectByField(treeList, orgId) | ||
5290 | - $(`#${enumActionEl.ORG_EL} input`).parent().find('span').html(orgNode.name) | 5300 | + const orgNode = UseLayUi.findTreeObjectByField(treeList, currentCheckedOrgNode) |
5301 | + $(`#${enumActionEl.ORG_EL} input[name="${enumDataSourceConst.ORG_ID}"]`).parent().find('span').html(orgNode?.name) | ||
5291 | form.val(CONTAINER_FILTER, { | 5302 | form.val(CONTAINER_FILTER, { |
5292 | orgId, | 5303 | orgId, |
5293 | deviceId, | 5304 | deviceId, |
5294 | slaveDeviceId, | 5305 | slaveDeviceId, |
5295 | - attr: bindAttr | 5306 | + attr |
5296 | }) | 5307 | }) |
5297 | }) | 5308 | }) |
5298 | } | 5309 | } |
@@ -5301,11 +5312,8 @@ DataFormatPanel.prototype.addDataFont = function (container) { | @@ -5301,11 +5312,8 @@ DataFormatPanel.prototype.addDataFont = function (container) { | ||
5301 | const all = [...(currentNodeData.act ?? []), ...(currentNodeData.event ?? [])] | 5312 | const all = [...(currentNodeData.act ?? []), ...(currentNodeData.event ?? [])] |
5302 | const actionType = {} | 5313 | const actionType = {} |
5303 | for (const item of all) { | 5314 | for (const item of all) { |
5304 | - if (!item.enabled) { | ||
5305 | - actionType[item.type] = 'on' | ||
5306 | - } | 5315 | + actionType[item.type] = item.enabled |
5307 | } | 5316 | } |
5308 | - console.log(actionType) | ||
5309 | form.val(CONTAINER_FILTER, actionType) | 5317 | form.val(CONTAINER_FILTER, actionType) |
5310 | } | 5318 | } |
5311 | } | 5319 | } |
@@ -5321,8 +5329,6 @@ DataFormatPanel.prototype.addDataFont = function (container) { | @@ -5321,8 +5329,6 @@ DataFormatPanel.prototype.addDataFont = function (container) { | ||
5321 | 5329 | ||
5322 | $(container).append(fragment) | 5330 | $(container).append(fragment) |
5323 | 5331 | ||
5324 | - UseLayUi.nextTick(() => form.render(null, CONTAINER_FILTER)) | ||
5325 | - | ||
5326 | } | 5332 | } |
5327 | mount() | 5333 | mount() |
5328 | 5334 | ||
@@ -5370,37 +5376,38 @@ DataFormatPanel.prototype.addDataFont = function (container) { | @@ -5370,37 +5376,38 @@ DataFormatPanel.prototype.addDataFont = function (container) { | ||
5370 | const panel = createPanel() | 5376 | const panel = createPanel() |
5371 | $(panel).addClass('data-source__submit-panel').append(`<button type="button" lay-submit lay-filter="formDataSource" class="layui-btn">保存</button>`) | 5377 | $(panel).addClass('data-source__submit-panel').append(`<button type="button" lay-submit lay-filter="formDataSource" class="layui-btn">保存</button>`) |
5372 | $(container).append(panel) | 5378 | $(container).append(panel) |
5373 | - form.on('submit(formDataSource)', function (data) { | 5379 | + form.on('submit(formDataSource)', async function (data) { |
5374 | const ENABLED_FLAG = 'on' | 5380 | const ENABLED_FLAG = 'on' |
5375 | const { field } = data | 5381 | const { field } = data |
5376 | - const value = { [enumCategory.ACT]: [], [enumCategory.EVENT]: [], [enumCategory.DATA_SOURCE]: [] } | 5382 | + const value = { |
5383 | + configurationId, | ||
5384 | + contentId: currentPageId.id, | ||
5385 | + nodeId: graphId, | ||
5386 | + [enumCategory.ACT]: [], | ||
5387 | + [enumCategory.EVENT]: [], | ||
5388 | + [enumCategory.DATA_SOURCE]: { | ||
5389 | + [enumDataSourceConst.ORG_ID]: field[enumDataSourceConst.ORG_ID], | ||
5390 | + [enumDataSourceConst.DEVICE_ID]: field[enumDataSourceConst.DEVICE_ID], | ||
5391 | + ...(field[enumDataSourceConst.SLAVE_DEVICE_ID] && { [enumDataSourceConst.SLAVE_DEVICE_ID]: field[enumDataSourceConst.SLAVE_DEVICE_ID] }), | ||
5392 | + [enumDataSourceConst.ATTR]: field[enumDataSourceConst.ATTR], | ||
5393 | + } | ||
5394 | + } | ||
5377 | const allType = [...interactionList, ...dynamicEffectList] | 5395 | const allType = [...interactionList, ...dynamicEffectList] |
5378 | for (const item of allType) { | 5396 | for (const item of allType) { |
5379 | if (field[item.type] === ENABLED_FLAG) { | 5397 | if (field[item.type] === ENABLED_FLAG) { |
5380 | const enableItem = currentNodeData[item.category].find(each => each.type === item.type) | 5398 | const enableItem = currentNodeData[item.category].find(each => each.type === item.type) |
5381 | if (!enableItem) continue | 5399 | if (!enableItem) continue |
5382 | value[item.category].push({ | 5400 | value[item.category].push({ |
5383 | - configurationId, | ||
5384 | - contentId: currentPageId.id, | ||
5385 | - id: graphId, | ||
5386 | type: item.type, | 5401 | type: item.type, |
5387 | enabled: true | 5402 | enabled: true |
5388 | }) | 5403 | }) |
5389 | } | 5404 | } |
5390 | } | 5405 | } |
5391 | - value[enumCategory.DATA_SOURCE].push({ | ||
5392 | - [enumDataSourceConst.ORG_ID]: field[enumDataSourceConst.ORG_ID], | ||
5393 | - [enumDataSourceConst.DEVICE_ID]: field[enumDataSourceConst.DEVICE_ID], | ||
5394 | - [enumDataSourceConst.SLAVE_DEVICE_ID]: field[enumDataSourceConst.SLAVE_DEVICE_ID], | ||
5395 | - [enumDataSourceConst.ATTR]: [field[enumDataSourceConst.ATTR]], | ||
5396 | - }) | ||
5397 | 5406 | ||
5398 | - ConfigurationNodeApi.updateNodeInfo(value) | ||
5399 | - .then(res => { | ||
5400 | - console.log(res) | ||
5401 | - }).catch(err => { | ||
5402 | - console.log(err) | ||
5403 | - }) | 5407 | + const [err, res] = await to(ConfigurationNodeApi.updateNodeInfo(value)) |
5408 | + if (err) return | ||
5409 | + UseLayUi.successMsg() | ||
5410 | + await getNodeBindInfo() | ||
5404 | return false; | 5411 | return false; |
5405 | }); | 5412 | }); |
5406 | } | 5413 | } |
@@ -5415,18 +5422,41 @@ DataFormatPanel.prototype.addDataFont = function (container) { | @@ -5415,18 +5422,41 @@ DataFormatPanel.prototype.addDataFont = function (container) { | ||
5415 | return | 5422 | return |
5416 | } | 5423 | } |
5417 | // 事件类型 | 5424 | // 事件类型 |
5418 | - const eventType = { | 5425 | + const enumenumEventType = { |
5419 | DOWN: "按下", | 5426 | DOWN: "按下", |
5420 | UP: "抬起", | 5427 | UP: "抬起", |
5421 | SINGLE: "单击", | 5428 | SINGLE: "单击", |
5422 | DOUBLE: "双击", | 5429 | DOUBLE: "双击", |
5423 | }; | 5430 | }; |
5424 | 5431 | ||
5425 | - /** | ||
5426 | - * @description 表格表体 | ||
5427 | - * @type {string} | ||
5428 | - */ | ||
5429 | - const deviceDataTbody = 'deviceDataTbody' | 5432 | + const enumActionEl = { |
5433 | + /** | ||
5434 | + * @description 表体节点 | ||
5435 | + */ | ||
5436 | + DEVICE_DATA_BODY_EL: 'deviceDataTbody', | ||
5437 | + | ||
5438 | + /** | ||
5439 | + * @description 删除行节点 | ||
5440 | + */ | ||
5441 | + DEL_ROW_EL: 'deleteRow', | ||
5442 | + | ||
5443 | + /** | ||
5444 | + * @description 增加行节点 | ||
5445 | + */ | ||
5446 | + ADD_ROW_EL: 'addRow', | ||
5447 | + | ||
5448 | + /** | ||
5449 | + * @descripton | ||
5450 | + */ | ||
5451 | + ROW_FILTER: 'interactionRowFilter', | ||
5452 | + | ||
5453 | + /** | ||
5454 | + * @description 弹出层保存 filter | ||
5455 | + */ | ||
5456 | + LAYER_SUBMIT_FILTER: 'interactionLayerSubmit' | ||
5457 | + } | ||
5458 | + | ||
5459 | + | ||
5430 | 5460 | ||
5431 | /** | 5461 | /** |
5432 | * @description 所有设备选项 | 5462 | * @description 所有设备选项 |
@@ -5436,25 +5466,25 @@ DataFormatPanel.prototype.addDataFont = function (container) { | @@ -5436,25 +5466,25 @@ DataFormatPanel.prototype.addDataFont = function (container) { | ||
5436 | 5466 | ||
5437 | let addRowNumber = 0 | 5467 | let addRowNumber = 0 |
5438 | 5468 | ||
5439 | - const rowFormList = [] | 5469 | + const getRowFilter = (rowNumber) => `${enumActionEl.ROW_FILTER}${rowNumber}` |
5440 | 5470 | ||
5441 | /** | 5471 | /** |
5442 | * @description 枚举常量 | 5472 | * @description 枚举常量 |
5443 | - * @enum DEVICE - | 5473 | + * @enum DEVICE |
5444 | */ | 5474 | */ |
5445 | const enumConst = { | 5475 | const enumConst = { |
5446 | /** | 5476 | /** |
5447 | * @description 设备 | 5477 | * @description 设备 |
5448 | */ | 5478 | */ |
5449 | - DEVICE: 'device', | 5479 | + DEVICE: 'deviceId', |
5450 | /** | 5480 | /** |
5451 | * @description 子设备 | 5481 | * @description 子设备 |
5452 | */ | 5482 | */ |
5453 | - CHILD_DEVICE: 'childDevice', | 5483 | + SLAVE_DEVICE: 'slaveDeviceId', |
5454 | /** | 5484 | /** |
5455 | * @description 变量 | 5485 | * @description 变量 |
5456 | */ | 5486 | */ |
5457 | - VARIABLE: 'variable', | 5487 | + ATTR: 'attr', |
5458 | /** | 5488 | /** |
5459 | * @description 下发值 | 5489 | * @description 下发值 |
5460 | */ | 5490 | */ |
@@ -5464,39 +5494,36 @@ DataFormatPanel.prototype.addDataFont = function (container) { | @@ -5464,39 +5494,36 @@ DataFormatPanel.prototype.addDataFont = function (container) { | ||
5464 | /** | 5494 | /** |
5465 | * @description 创建回显数据 查询出所有网关设备和直连设备 | 5495 | * @description 创建回显数据 查询出所有网关设备和直连设备 |
5466 | */ | 5496 | */ |
5467 | - function getAllDevice() { | 5497 | + async function getMaterDevice() { |
5468 | if (!currentCheckedOrgNode) return | 5498 | if (!currentCheckedOrgNode) return |
5469 | - ConfigurationNodeApi.getMasterDevice(currentCheckedOrgNode) | ||
5470 | - .then(res => { | ||
5471 | - allDeviceOptions = res | ||
5472 | - setDeviceOptions() | ||
5473 | - }) | 5499 | + const [err, res] = await to(ConfigurationNodeApi.getMasterDevice(currentCheckedOrgNode)) |
5500 | + allDeviceOptions = res | ||
5474 | } | 5501 | } |
5475 | 5502 | ||
5476 | function addRecord() { | 5503 | function addRecord() { |
5477 | - addRowNumber++ | ||
5478 | - rowFormList.push(addRowNumber) | ||
5479 | const content = ` | 5504 | const content = ` |
5480 | - <tr class="layui-form" lay-filter="deviceDataRow${addRowNumber}"> | 5505 | + <tr class="layui-form" lay-filter="${enumActionEl.ROW_FILTER}${addRowNumber}"> |
5481 | <td> | 5506 | <td> |
5482 | - <select name="${enumConst.DEVICE}" lay-filter="device" lay-verify="required"></select> | 5507 | + <select name="${enumConst.DEVICE}" lay-filter="${enumConst.DEVICE}" lay-verType="tips" lay-verify="required"></select> |
5483 | </td> | 5508 | </td> |
5484 | <td> | 5509 | <td> |
5485 | - <select name="${enumConst.CHILD_DEVICE}" lay-filter="childDevice" lay-verify="required" ></select> | 5510 | + <select name="${enumConst.SLAVE_DEVICE}" lay-filter="${enumConst.SLAVE_DEVICE}" lay-verType="tips"></select> |
5486 | </td> | 5511 | </td> |
5487 | <td> | 5512 | <td> |
5488 | - <select name="${enumConst.VARIABLE}" lay-verify="required"></select> | 5513 | + <select name="${enumConst.ATTR}" lay-verType="tips" lay-verify="required"></select> |
5489 | </td> | 5514 | </td> |
5490 | <td> | 5515 | <td> |
5491 | - <textarea name="${enumConst.VALUE}" placeholder="请输入命令" class="layui-textarea" ></textarea> | 5516 | + <textarea name="${enumConst.VALUE}" placeholder="请输入命令" lay-verType="tips" class="layui-textarea" ></textarea> |
5492 | </td> | 5517 | </td> |
5493 | <td> | 5518 | <td> |
5494 | - <button type="button" class="layui-btn layui-btn-primary layui-border-red deleteRow">删除</button> | 5519 | + <button type="button" class="layui-btn layui-btn-primary layui-border-red ${enumActionEl.DEL_ROW_EL}">删除</button> |
5495 | </td> | 5520 | </td> |
5496 | </tr> | 5521 | </tr> |
5497 | ` | 5522 | ` |
5498 | - $('#deviceDataTbody').append(content) | ||
5499 | - form.render(null, `deviceDataRow${addRowNumber}`) | 5523 | + $(`#${enumActionEl.DEVICE_DATA_BODY_EL}`).append(content) |
5524 | + setDeviceOptions(addRowNumber) | ||
5525 | + form.render('select', getRowFilter(addRowNumber)) | ||
5526 | + addRowNumber++ | ||
5500 | } | 5527 | } |
5501 | 5528 | ||
5502 | /** | 5529 | /** |
@@ -5507,8 +5534,8 @@ DataFormatPanel.prototype.addDataFont = function (container) { | @@ -5507,8 +5534,8 @@ DataFormatPanel.prototype.addDataFont = function (container) { | ||
5507 | const [err, res] = await to(ConfigurationNodeApi.getDeviceAttr(data.value)) | 5534 | const [err, res] = await to(ConfigurationNodeApi.getDeviceAttr(data.value)) |
5508 | if (!res) return | 5535 | if (!res) return |
5509 | const generateOption = UseLayUi.generateOptionTemplate({ dataSource: res }) | 5536 | const generateOption = UseLayUi.generateOptionTemplate({ dataSource: res }) |
5510 | - $(data.elem).parents('tr').find(`select[name="${enumConst.VARIABLE}"]`).html(generateOption) | ||
5511 | - UseLayUi.nextTick(() => form.render()) | 5537 | + $(data.elem).parents('tr').find(`select[name="${enumConst.ATTR}"]`).html(generateOption) |
5538 | + form.render('select') | ||
5512 | } | 5539 | } |
5513 | 5540 | ||
5514 | /** | 5541 | /** |
@@ -5521,14 +5548,14 @@ DataFormatPanel.prototype.addDataFont = function (container) { | @@ -5521,14 +5548,14 @@ DataFormatPanel.prototype.addDataFont = function (container) { | ||
5521 | if (isGATEWAY && data.value) { | 5548 | if (isGATEWAY && data.value) { |
5522 | const [err, res] = await to(ConfigurationNodeApi.getSlaveDevice(currentCheckedOrgNode, data.value)) | 5549 | const [err, res] = await to(ConfigurationNodeApi.getSlaveDevice(currentCheckedOrgNode, data.value)) |
5523 | if (!res) return | 5550 | if (!res) return |
5524 | - const generateOption = UseLayUi.generateOptionTemplate({ dataSource: res.items }) | ||
5525 | - $(data.elem).parents('tr').find(`select[name="${enumConst.CHILD_DEVICE}"]`).html(generateOption) | 5551 | + const generateOption = UseLayUi.generateOptionTemplate({ dataSource: res }) |
5552 | + $(data.elem).parents('tr').find(`select[name="${enumConst.SLAVE_DEVICE}"]`).html(generateOption) | ||
5526 | } else { | 5553 | } else { |
5527 | updateVariableOptions(data) | 5554 | updateVariableOptions(data) |
5528 | } | 5555 | } |
5529 | - UseLayUi.nextTick(() => form.render()) | 5556 | + form.render('select') |
5530 | }) | 5557 | }) |
5531 | - form.on(`select(${enumConst.CHILD_DEVICE})`, (data) => { | 5558 | + form.on(`select(${enumConst.SLAVE_DEVICE})`, (data) => { |
5532 | updateVariableOptions(data) | 5559 | updateVariableOptions(data) |
5533 | }) | 5560 | }) |
5534 | } | 5561 | } |
@@ -5537,7 +5564,7 @@ DataFormatPanel.prototype.addDataFont = function (container) { | @@ -5537,7 +5564,7 @@ DataFormatPanel.prototype.addDataFont = function (container) { | ||
5537 | * @description 删除行 | 5564 | * @description 删除行 |
5538 | */ | 5565 | */ |
5539 | function createDeleteRowListenEvent() { | 5566 | function createDeleteRowListenEvent() { |
5540 | - $('.deleteRow').click((event) => { | 5567 | + $(`.${enumActionEl.DEL_ROW_EL}`).click((event) => { |
5541 | $(event.target).parents('tr').remove() | 5568 | $(event.target).parents('tr').remove() |
5542 | }) | 5569 | }) |
5543 | } | 5570 | } |
@@ -5546,21 +5573,21 @@ DataFormatPanel.prototype.addDataFont = function (container) { | @@ -5546,21 +5573,21 @@ DataFormatPanel.prototype.addDataFont = function (container) { | ||
5546 | * @description 新增行 | 5573 | * @description 新增行 |
5547 | */ | 5574 | */ |
5548 | function createAddRowListenEvent() { | 5575 | function createAddRowListenEvent() { |
5549 | - $('#addRow').click(() => { | 5576 | + $(`#${enumActionEl.ADD_ROW_EL}`).click(() => { |
5550 | addRecord() | 5577 | addRecord() |
5551 | const generateOption = UseLayUi.generateOptionTemplate({ dataSource: allDeviceOptions }) | 5578 | const generateOption = UseLayUi.generateOptionTemplate({ dataSource: allDeviceOptions }) |
5552 | - $(`#${deviceDataTbody} tr`).last().find(`select[name="${enumConst.DEVICE}"]`).html(generateOption) | 5579 | + $(`#${enumActionEl.DEVICE_DATA_BODY_EL} tr`).last().find(`select[name="${enumConst.DEVICE}"]`).html(generateOption) |
5553 | createDeleteRowListenEvent() | 5580 | createDeleteRowListenEvent() |
5554 | - form.render() | 5581 | + form.render('select') |
5555 | }) | 5582 | }) |
5556 | } | 5583 | } |
5557 | 5584 | ||
5558 | /** | 5585 | /** |
5559 | * @description 设置设备选项 | 5586 | * @description 设置设备选项 |
5560 | */ | 5587 | */ |
5561 | - function setDeviceOptions() { | 5588 | + function setDeviceOptions(row) { |
5562 | const generateOption = UseLayUi.generateOptionTemplate({ dataSource: allDeviceOptions }) | 5589 | const generateOption = UseLayUi.generateOptionTemplate({ dataSource: allDeviceOptions }) |
5563 | - $(`#${deviceDataTbody}`).find(`select[name="${enumConst.DEVICE}"]`).html(generateOption) | 5590 | + $(`#${enumActionEl.DEVICE_DATA_BODY_EL} tr[lay-filter="${getRowFilter(row)}"]`).find(`select[name="${enumConst.DEVICE}"]`).html(generateOption) |
5564 | } | 5591 | } |
5565 | 5592 | ||
5566 | /** | 5593 | /** |
@@ -5580,52 +5607,23 @@ DataFormatPanel.prototype.addDataFont = function (container) { | @@ -5580,52 +5607,23 @@ DataFormatPanel.prototype.addDataFont = function (container) { | ||
5580 | */ | 5607 | */ |
5581 | function mountSelectOptions(row, key, data) { | 5608 | function mountSelectOptions(row, key, data) { |
5582 | const generateOption = UseLayUi.generateOptionTemplate({ dataSource: data }) | 5609 | const generateOption = UseLayUi.generateOptionTemplate({ dataSource: data }) |
5583 | - $(`#${deviceDataTbody}`).find(`tr[lay-filter="deviceDataRow${row}"] select[name="${key}"]`).html(generateOption) | 5610 | + $(`#${enumActionEl.DEVICE_DATA_BODY_EL}`).find(`tr[lay-filter="${getRowFilter(row)}"] select[name="${key}"]`).html(generateOption) |
5584 | } | 5611 | } |
5585 | 5612 | ||
5586 | /** | 5613 | /** |
5587 | - * @description 设置select val | ||
5588 | - * @param row | ||
5589 | - * @param key | ||
5590 | - * @param val | 5614 | + * @description 根据主设备ID获取从设备 |
5591 | */ | 5615 | */ |
5592 | - function setSelectVal(row, key, val) { | ||
5593 | - $(`#${deviceDataTbody}`).find(`tr[lay-filter="deviceDataRow${row}"] select[name="${key}"]`).val(val) | 5616 | + async function getSlaveDeviceByMasterDevice(deviceId, row) { |
5617 | + const res = await ConfigurationNodeApi.getSlaveDevice(currentCheckedOrgNode, deviceId) | ||
5618 | + mountSelectOptions(row, enumConst.SLAVE_DEVICE, res) | ||
5594 | } | 5619 | } |
5595 | 5620 | ||
5596 | /** | 5621 | /** |
5597 | - * @description 处理每条回显数据 | ||
5598 | - * @param datum | ||
5599 | - * @returns {Promise<void>} | 5622 | + * @description 根据设备ID获取设备属性 |
5600 | */ | 5623 | */ |
5601 | - async function handleEachDataEcho(datum) { | ||
5602 | - | ||
5603 | - addRecord() | ||
5604 | - setDeviceOptions() | ||
5605 | - const currentRow = addRowNumber | ||
5606 | - | ||
5607 | - const childDeviceId = datum[enumConst.CHILD_DEVICE] | ||
5608 | - const deviceId = datum[enumConst.DEVICE] | ||
5609 | - const variable = datum[enumConst.VARIABLE] | ||
5610 | - let findId = deviceId | ||
5611 | - | ||
5612 | - /** | ||
5613 | - * @description 存在子设备请求子设备列表 | ||
5614 | - */ | ||
5615 | - if (childDeviceId && deviceId) { | ||
5616 | - findId = childDeviceId | ||
5617 | - ConfigurationNodeApi.getSlaveDevice(currentCheckedOrgNode, deviceId) | ||
5618 | - .then(res => { | ||
5619 | - mountSelectOptions(currentRow, enumConst.CHILD_DEVICE, res.items) | ||
5620 | - setSelectVal(currentRow, enumConst.CHILD_DEVICE, childDeviceId) | ||
5621 | - form.val(`deviceDataRow${currentRow}`, datum) | ||
5622 | - }) | ||
5623 | - } | ||
5624 | - deviceId && ConfigurationNodeApi.getDeviceAttr(findId).then(res => { | ||
5625 | - mountSelectOptions(currentRow, enumConst.VARIABLE, res) | ||
5626 | - setSelectVal(currentRow, enumConst.CHILD_DEVICE, variable) | ||
5627 | - form.val(`deviceDataRow${currentRow}`, datum) | ||
5628 | - }) | 5624 | + async function getDeviceAttrByDeviceId(deviceId, row) { |
5625 | + const res = await ConfigurationNodeApi.getDeviceAttr(deviceId) | ||
5626 | + mountSelectOptions(row, enumConst.ATTR, res) | ||
5629 | } | 5627 | } |
5630 | 5628 | ||
5631 | /** | 5629 | /** |
@@ -5633,16 +5631,37 @@ DataFormatPanel.prototype.addDataFont = function (container) { | @@ -5633,16 +5631,37 @@ DataFormatPanel.prototype.addDataFont = function (container) { | ||
5633 | */ | 5631 | */ |
5634 | function echoFormData(info) { | 5632 | function echoFormData(info) { |
5635 | const { content: { data = [] } = {} } = info | 5633 | const { content: { data = [] } = {} } = info |
5636 | - for (const datum of data) { | ||
5637 | - handleEachDataEcho(datum) | 5634 | + data.forEach((datum, index) => echoEachData(datum, index)) |
5635 | + } | ||
5636 | + | ||
5637 | + /** | ||
5638 | + * @description 回显每条数据 | ||
5639 | + */ | ||
5640 | + function echoEachData(datum = {}, row) { | ||
5641 | + addRecord() | ||
5642 | + const deviceId = datum[enumConst.DEVICE] | ||
5643 | + const slaveDeviceId = datum[enumConst.SLAVE_DEVICE] | ||
5644 | + const queue = [] | ||
5645 | + | ||
5646 | + if (slaveDeviceId) { | ||
5647 | + queue.push(() => getSlaveDeviceByMasterDevice(deviceId, row)) | ||
5648 | + queue.push(() => getDeviceAttrByDeviceId(slaveDeviceId, row)) | ||
5649 | + } else { | ||
5650 | + queue.push(() => getDeviceAttrByDeviceId(deviceId, row)) | ||
5638 | } | 5651 | } |
5652 | + | ||
5653 | + Promise | ||
5654 | + .all(queue.map(item => item())) | ||
5655 | + .finally(() => { | ||
5656 | + form.val(getRowFilter(row), datum) | ||
5657 | + }) | ||
5639 | } | 5658 | } |
5640 | 5659 | ||
5641 | /** | 5660 | /** |
5642 | * @description 保存 | 5661 | * @description 保存 |
5643 | */ | 5662 | */ |
5644 | - function submit() { | ||
5645 | - const data = rowFormList.map(rowNumber => form.val(`deviceDataRow${rowNumber}`)).filter(item => Object.keys(item).length) | 5663 | + async function submit(callback) { |
5664 | + const data = Array.from({ length: addRowNumber }).map((_, row) => form.val(getRowFilter(row))).filter(item => Object.keys(item).length) | ||
5646 | const formModal = { | 5665 | const formModal = { |
5647 | configurationId, | 5666 | configurationId, |
5648 | contentId: currentPageId.id, | 5667 | contentId: currentPageId.id, |
@@ -5652,7 +5671,10 @@ DataFormatPanel.prototype.addDataFont = function (container) { | @@ -5652,7 +5671,10 @@ DataFormatPanel.prototype.addDataFont = function (container) { | ||
5652 | }, | 5671 | }, |
5653 | type: event.data.type | 5672 | type: event.data.type |
5654 | }; | 5673 | }; |
5655 | - ConfigurationNodeApi.updateNodeEvent(formModal) | 5674 | + const [err, res] = await to(ConfigurationNodeApi.updateNodeEvent(formModal)) |
5675 | + if (err) return | ||
5676 | + UseLayUi.successMsg() | ||
5677 | + callback() | ||
5656 | } | 5678 | } |
5657 | 5679 | ||
5658 | /** | 5680 | /** |
@@ -5666,7 +5688,7 @@ DataFormatPanel.prototype.addDataFont = function (container) { | @@ -5666,7 +5688,7 @@ DataFormatPanel.prototype.addDataFont = function (container) { | ||
5666 | <div class="layui-form-item"> | 5688 | <div class="layui-form-item"> |
5667 | <label class="layui-form-label">事件</label> | 5689 | <label class="layui-form-label">事件</label> |
5668 | <div class="layui-input-block"> | 5690 | <div class="layui-input-block"> |
5669 | - <input type="text" name="event" class="layui-input" value="${eventType[type]}" disabled> | 5691 | + <input type="text" name="event" class="layui-input" value="${enumenumEventType[type]}" disabled> |
5670 | </div> | 5692 | </div> |
5671 | </div> | 5693 | </div> |
5672 | <div class="layui-form-item"> | 5694 | <div class="layui-form-item"> |
@@ -5685,12 +5707,12 @@ DataFormatPanel.prototype.addDataFont = function (container) { | @@ -5685,12 +5707,12 @@ DataFormatPanel.prototype.addDataFont = function (container) { | ||
5685 | </div> | 5707 | </div> |
5686 | </div> | 5708 | </div> |
5687 | </div> | 5709 | </div> |
5688 | - <div style="height:255px;" id="tableContent"> | 5710 | + <div id="tableContent"> |
5689 | <table class="layui-table" > | 5711 | <table class="layui-table" > |
5690 | <colgroup> | 5712 | <colgroup> |
5691 | - <col> | ||
5692 | - <col> | ||
5693 | - <col> | 5713 | + <col width="240"> |
5714 | + <col width="240"> | ||
5715 | + <col width="240"> | ||
5694 | <col width="240"> | 5716 | <col width="240"> |
5695 | <col width="60"> | 5717 | <col width="60"> |
5696 | </colgroup> | 5718 | </colgroup> |
@@ -5703,10 +5725,10 @@ DataFormatPanel.prototype.addDataFont = function (container) { | @@ -5703,10 +5725,10 @@ DataFormatPanel.prototype.addDataFont = function (container) { | ||
5703 | <th style="text-align:center">操作</th> | 5725 | <th style="text-align:center">操作</th> |
5704 | </tr> | 5726 | </tr> |
5705 | </thead> | 5727 | </thead> |
5706 | - <tbody id="${deviceDataTbody}"></tbody> | 5728 | + <tbody id="${enumActionEl.DEVICE_DATA_BODY_EL}"></tbody> |
5707 | </table> | 5729 | </table> |
5708 | <div style="display:flex;justify-content:center;"> | 5730 | <div style="display:flex;justify-content:center;"> |
5709 | - <button type="button" class="layui-btn layui-btn-primary layui-border-blue" id="addRow">添加一条</button> | 5731 | + <button type="button" class="layui-btn layui-btn-primary layui-border-blue" id="${enumActionEl.ADD_ROW_EL}">添加一条</button> |
5710 | </div> | 5732 | </div> |
5711 | </div> | 5733 | </div> |
5712 | </form>` | 5734 | </form>` |
@@ -5716,21 +5738,23 @@ DataFormatPanel.prototype.addDataFont = function (container) { | @@ -5716,21 +5738,23 @@ DataFormatPanel.prototype.addDataFont = function (container) { | ||
5716 | content, | 5738 | content, |
5717 | skin: 'event-layer__override', | 5739 | skin: 'event-layer__override', |
5718 | // area: ["800px", "600px"], | 5740 | // area: ["800px", "600px"], |
5719 | - area: '800px', | 5741 | + area: '1100px', |
5720 | btn: ["保存", "取消"], | 5742 | btn: ["保存", "取消"], |
5721 | shade: ["0.7", "#fafafa"], | 5743 | shade: ["0.7", "#fafafa"], |
5722 | - async yes(index, layero) { | ||
5723 | - await submit() | ||
5724 | - layer.close(index) | ||
5725 | - const [err, res] = await to(getNodeBindInfo()) | ||
5726 | - if (err || !Object.keys(res).length) return | ||
5727 | - currentNodeData = res | 5744 | + yes(index) { |
5745 | + form.on(`submit(${enumActionEl.LAYER_SUBMIT_FILTER})`, data => { | ||
5746 | + submit(() => { | ||
5747 | + layer.close(index) | ||
5748 | + getNodeBindInfo() | ||
5749 | + }) | ||
5750 | + }) | ||
5728 | }, | 5751 | }, |
5729 | but2(index, layero) { | 5752 | but2(index, layero) { |
5730 | - | 5753 | + return false |
5731 | }, | 5754 | }, |
5732 | - success(layero, index) { | ||
5733 | - getAllDevice() | 5755 | + async success(layero, index) { |
5756 | + $(layero).addClass('layui-form').find('.layui-layer-btn0').attr({ 'lay-submit': '', 'lay-filter': enumActionEl.LAYER_SUBMIT_FILTER }) | ||
5757 | + await getMaterDevice() | ||
5734 | const info = getLayerBindInfo('event', type) | 5758 | const info = getLayerBindInfo('event', type) |
5735 | if (!info) { | 5759 | if (!info) { |
5736 | addRecord() | 5760 | addRecord() |
@@ -5751,7 +5775,7 @@ DataFormatPanel.prototype.addDataFont = function (container) { | @@ -5751,7 +5775,7 @@ DataFormatPanel.prototype.addDataFont = function (container) { | ||
5751 | */ | 5775 | */ |
5752 | function handleClickOrDbClick(event) { | 5776 | function handleClickOrDbClick(event) { |
5753 | 5777 | ||
5754 | - const eventType = { | 5778 | + const enumEventType = { |
5755 | DOWN: "按下", | 5779 | DOWN: "按下", |
5756 | UP: "抬起", | 5780 | UP: "抬起", |
5757 | SINGLE: "单击", | 5781 | SINGLE: "单击", |
@@ -5802,6 +5826,11 @@ DataFormatPanel.prototype.addDataFont = function (container) { | @@ -5802,6 +5826,11 @@ DataFormatPanel.prototype.addDataFont = function (container) { | ||
5802 | * @description 页面 ID | 5826 | * @description 页面 ID |
5803 | */ | 5827 | */ |
5804 | PAGE_EL_ID: 'dynamicInputPage', | 5828 | PAGE_EL_ID: 'dynamicInputPage', |
5829 | + | ||
5830 | + /** | ||
5831 | + * @description layer submit filter | ||
5832 | + */ | ||
5833 | + LAYER_SUBMIT_FILTER: 'dynamicLinkLayerFilter' | ||
5805 | } | 5834 | } |
5806 | 5835 | ||
5807 | /** | 5836 | /** |
@@ -5837,6 +5866,7 @@ DataFormatPanel.prototype.addDataFont = function (container) { | @@ -5837,6 +5866,7 @@ DataFormatPanel.prototype.addDataFont = function (container) { | ||
5837 | } | 5866 | } |
5838 | const [err] = await to(ConfigurationNodeApi.updateNodeEvent(data)) | 5867 | const [err] = await to(ConfigurationNodeApi.updateNodeEvent(data)) |
5839 | if (err) return | 5868 | if (err) return |
5869 | + UseLayUi.successMsg() | ||
5840 | callback() | 5870 | callback() |
5841 | } | 5871 | } |
5842 | 5872 | ||
@@ -5884,13 +5914,13 @@ DataFormatPanel.prototype.addDataFont = function (container) { | @@ -5884,13 +5914,13 @@ DataFormatPanel.prototype.addDataFont = function (container) { | ||
5884 | <div class="layui-form-item"> | 5914 | <div class="layui-form-item"> |
5885 | <label class="layui-form-label">事件</label> | 5915 | <label class="layui-form-label">事件</label> |
5886 | <div class="layui-input-block"> | 5916 | <div class="layui-input-block"> |
5887 | - <input type="text" name="${enumConst.EVENT}" disabled class="layui-input" value="${eventType[type]}"> | 5917 | + <input type="text" name="${enumConst.EVENT}" disabled class="layui-input" value="${enumEventType[type]}"> |
5888 | </div> | 5918 | </div> |
5889 | </div> | 5919 | </div> |
5890 | <div class="layui-form-item"> | 5920 | <div class="layui-form-item"> |
5891 | <label class="layui-form-label">动作</label> | 5921 | <label class="layui-form-label">动作</label> |
5892 | <div class="layui-input-block"> | 5922 | <div class="layui-input-block"> |
5893 | - <select name="${enumConst.ACTION}" lay-verify="required" lay-filter="${enumActionEl.ACTION_SELECT_FILTER}"> | 5923 | + <select name="${enumConst.ACTION}" lay-verType="tips" lay-verify="required" lay-filter="${enumActionEl.ACTION_SELECT_FILTER}"> |
5894 | ${generatorActionOptions()} | 5924 | ${generatorActionOptions()} |
5895 | </select> | 5925 | </select> |
5896 | </div> | 5926 | </div> |
@@ -5898,13 +5928,13 @@ DataFormatPanel.prototype.addDataFont = function (container) { | @@ -5898,13 +5928,13 @@ DataFormatPanel.prototype.addDataFont = function (container) { | ||
5898 | <div class="layui-form-item" id="${enumActionEl.LINK_EL_ID}"> | 5928 | <div class="layui-form-item" id="${enumActionEl.LINK_EL_ID}"> |
5899 | <label class="layui-form-label">链接</label> | 5929 | <label class="layui-form-label">链接</label> |
5900 | <div class="layui-input-block"> | 5930 | <div class="layui-input-block"> |
5901 | - <input type="text" name="${enumConst.LINK_VALUE}" class="layui-input"> | 5931 | + <input type="text" lay-verType="tips" name="${enumConst.LINK_VALUE}" class="layui-input"> |
5902 | </div> | 5932 | </div> |
5903 | </div> | 5933 | </div> |
5904 | <div class="layui-form-item" id="${enumActionEl.PAGE_EL_ID}" style="display:none"> | 5934 | <div class="layui-form-item" id="${enumActionEl.PAGE_EL_ID}" style="display:none"> |
5905 | <label class="layui-form-label">页面</label> | 5935 | <label class="layui-form-label">页面</label> |
5906 | <div class="layui-input-block"> | 5936 | <div class="layui-input-block"> |
5907 | - <select name="${enumConst.PAGE_VALUE}" lay-verify="required" id="pageSelect"> | 5937 | + <select name="${enumConst.PAGE_VALUE}" lay-verType="tips" id="pageSelect"> |
5908 | ${generatorPageOptions()} | 5938 | ${generatorPageOptions()} |
5909 | </select> | 5939 | </select> |
5910 | </div> | 5940 | </div> |
@@ -5920,13 +5950,19 @@ DataFormatPanel.prototype.addDataFont = function (container) { | @@ -5920,13 +5950,19 @@ DataFormatPanel.prototype.addDataFont = function (container) { | ||
5920 | content, | 5950 | content, |
5921 | area: ["800px", "500px"], | 5951 | area: ["800px", "500px"], |
5922 | btn: ["保存", "取消"], | 5952 | btn: ["保存", "取消"], |
5923 | - async yes(index) { | ||
5924 | - submit(() => layer.close(index)) | 5953 | + yes(index) { |
5954 | + form.on(`submit(${enumActionEl.LAYER_SUBMIT_FILTER})`, data => { | ||
5955 | + submit(() => { | ||
5956 | + layer.close(index) | ||
5957 | + getNodeBindInfo() | ||
5958 | + }) | ||
5959 | + }) | ||
5925 | }, | 5960 | }, |
5926 | btn2(index) { | 5961 | btn2(index) { |
5927 | layer.close(index); | 5962 | layer.close(index); |
5928 | }, | 5963 | }, |
5929 | - success() { | 5964 | + success(layero) { |
5965 | + $(layero).addClass('layui-form').find('.layui-layer-btn0').attr({ 'lay-submit': '', 'lay-filter': enumActionEl.LAYER_SUBMIT_FILTER }) | ||
5930 | generatorEventListen() | 5966 | generatorEventListen() |
5931 | const info = getLayerBindInfo('event', type) | 5967 | const info = getLayerBindInfo('event', type) |
5932 | form.render(null, enumActionEl.FORM_FILTER) | 5968 | form.render(null, enumActionEl.FORM_FILTER) |
@@ -5946,7 +5982,7 @@ DataFormatPanel.prototype.addDataFont = function (container) { | @@ -5946,7 +5982,7 @@ DataFormatPanel.prototype.addDataFont = function (container) { | ||
5946 | 5982 | ||
5947 | const IS_DISPLAY = event.data.type === 'DISPLAY' | 5983 | const IS_DISPLAY = event.data.type === 'DISPLAY' |
5948 | 5984 | ||
5949 | - const eventType = { | 5985 | + const enumEventType = { |
5950 | FLASH: '闪烁', | 5986 | FLASH: '闪烁', |
5951 | DISPLAY: '显示/隐藏', | 5987 | DISPLAY: '显示/隐藏', |
5952 | ROTATE: '旋转', | 5988 | ROTATE: '旋转', |
@@ -5964,7 +6000,8 @@ DataFormatPanel.prototype.addDataFont = function (container) { | @@ -5964,7 +6000,8 @@ DataFormatPanel.prototype.addDataFont = function (container) { | ||
5964 | ATTR_EL: 'dataDynamicEffectAtt', | 6000 | ATTR_EL: 'dataDynamicEffectAtt', |
5965 | DEL_BTN_EL: 'dataDynamicEffectDelBtn', | 6001 | DEL_BTN_EL: 'dataDynamicEffectDelBtn', |
5966 | ADD_BTN_EL: 'dataDynamicEffectAddBtn', | 6002 | ADD_BTN_EL: 'dataDynamicEffectAddBtn', |
5967 | - DISPLAY_SWITCH_EL: 'visibleOrHidden' | 6003 | + DISPLAY_SWITCH_EL: 'visibleOrHidden', |
6004 | + LAYER_SUBMIT_FILTER: 'dynamicEffectLayerFilter' | ||
5968 | } | 6005 | } |
5969 | 6006 | ||
5970 | const getRowFilter = (rowNumber) => `${enumActionEl.ROW_FILTER}${rowNumber}` | 6007 | const getRowFilter = (rowNumber) => `${enumActionEl.ROW_FILTER}${rowNumber}` |
@@ -6012,8 +6049,6 @@ DataFormatPanel.prototype.addDataFont = function (container) { | @@ -6012,8 +6049,6 @@ DataFormatPanel.prototype.addDataFont = function (container) { | ||
6012 | treeProps: { | 6049 | treeProps: { |
6013 | data: treeList, | 6050 | data: treeList, |
6014 | onlyIconControl: true, | 6051 | onlyIconControl: true, |
6015 | - onReady(setValue) { | ||
6016 | - }, | ||
6017 | click(node) { | 6052 | click(node) { |
6018 | currentOrgId = node.data.id | 6053 | currentOrgId = node.data.id |
6019 | getDeviceByOrg(node.data.id) | 6054 | getDeviceByOrg(node.data.id) |
@@ -6084,10 +6119,10 @@ DataFormatPanel.prototype.addDataFont = function (container) { | @@ -6084,10 +6119,10 @@ DataFormatPanel.prototype.addDataFont = function (container) { | ||
6084 | <tr class="layui-form" lay-filter="${getRowFilter(addRowNumber)}"> | 6119 | <tr class="layui-form" lay-filter="${getRowFilter(addRowNumber)}"> |
6085 | ${IS_DISPLAY && `<td>${generatorDisplayOptions()}</td>`} | 6120 | ${IS_DISPLAY && `<td>${generatorDisplayOptions()}</td>`} |
6086 | <td> | 6121 | <td> |
6087 | - <input type="text" name="${enumConst.MIN}" class="layui-input"> | 6122 | + <input lay-verType="tips" lay-verify="required" type="text" name="${enumConst.MIN}" class="layui-input"> |
6088 | </td> | 6123 | </td> |
6089 | <td> | 6124 | <td> |
6090 | - <input type="text" name="${enumConst.MAX}" class="layui-input"> | 6125 | + <input lay-verType="tips" lay-verify="required" type="text" name="${enumConst.MAX}" class="layui-input"> |
6091 | </td> | 6126 | </td> |
6092 | <td style="text-align: center;"> | 6127 | <td style="text-align: center;"> |
6093 | <button type="button" class="layui-btn layui-btn-primary layui-border-red ${enumActionEl.DEL_BTN_EL}">删除</button> | 6128 | <button type="button" class="layui-btn layui-btn-primary layui-border-red ${enumActionEl.DEL_BTN_EL}">删除</button> |
@@ -6158,15 +6193,18 @@ DataFormatPanel.prototype.addDataFont = function (container) { | @@ -6158,15 +6193,18 @@ DataFormatPanel.prototype.addDataFont = function (container) { | ||
6158 | const { slaveDeviceId, deviceId, attr, orgId, condition = [] } = info | 6193 | const { slaveDeviceId, deviceId, attr, orgId, condition = [] } = info |
6159 | echoEachData(condition) | 6194 | echoEachData(condition) |
6160 | echoOrgTree(orgId) | 6195 | echoOrgTree(orgId) |
6161 | - const queue = [getDeviceByOrg(orgId)] | 6196 | + const queue = [] |
6197 | + if (orgId) { | ||
6198 | + queue.push(() => getDeviceByOrg(orgId)) | ||
6199 | + } | ||
6162 | if (slaveDeviceId) { | 6200 | if (slaveDeviceId) { |
6163 | $(`#${enumActionEl.SLAVE_DEVICE_EL}`).css({ display: 'block' }) | 6201 | $(`#${enumActionEl.SLAVE_DEVICE_EL}`).css({ display: 'block' }) |
6164 | - queue.push(getSlaveDeviceByMasterDevice(orgId, deviceId)) | ||
6165 | - queue.push(getAttrsByDevice(slaveDeviceId)) | 6202 | + queue.push(() => getSlaveDeviceByMasterDevice(orgId, deviceId)) |
6203 | + queue.push(() => getAttrsByDevice(slaveDeviceId)) | ||
6166 | } else { | 6204 | } else { |
6167 | - queue.push(getAttrsByDevice(deviceId)) | 6205 | + queue.push(() => getAttrsByDevice(deviceId)) |
6168 | } | 6206 | } |
6169 | - Promise.all(queue).finally(() => { | 6207 | + Promise.all(queue.map(item => item())).finally(() => { |
6170 | form.val(enumActionEl.FORM_FILTER, { slaveDeviceId, deviceId, attr, orgId }) | 6208 | form.val(enumActionEl.FORM_FILTER, { slaveDeviceId, deviceId, attr, orgId }) |
6171 | }) | 6209 | }) |
6172 | } | 6210 | } |
@@ -6186,7 +6224,6 @@ DataFormatPanel.prototype.addDataFont = function (container) { | @@ -6186,7 +6224,6 @@ DataFormatPanel.prototype.addDataFont = function (container) { | ||
6186 | */ | 6224 | */ |
6187 | function echoOrgTree(id) { | 6225 | function echoOrgTree(id) { |
6188 | const node = UseLayUi.findTreeObjectByField(treeList, id) | 6226 | const node = UseLayUi.findTreeObjectByField(treeList, id) |
6189 | - console.log($(`#${enumActionEl.ORG_EL}`).find(`input[name="${enumConst.ORG_ID}"]`).parent().find('span')) | ||
6190 | $(`#${enumActionEl.ORG_EL}`).find(`input[name="${enumConst.ORG_ID}"]`).parent().find('span').html(node.name) | 6227 | $(`#${enumActionEl.ORG_EL}`).find(`input[name="${enumConst.ORG_ID}"]`).parent().find('span').html(node.name) |
6191 | } | 6228 | } |
6192 | 6229 | ||
@@ -6202,7 +6239,9 @@ DataFormatPanel.prototype.addDataFont = function (container) { | @@ -6202,7 +6239,9 @@ DataFormatPanel.prototype.addDataFont = function (container) { | ||
6202 | type: event.data.type | 6239 | type: event.data.type |
6203 | } | 6240 | } |
6204 | const [err, res] = await to(ConfigurationNodeApi.updateNodeAct(formModel)) | 6241 | const [err, res] = await to(ConfigurationNodeApi.updateNodeAct(formModel)) |
6205 | - if (!err) callback() | 6242 | + if (err) return |
6243 | + UseLayUi.successMsg() | ||
6244 | + callback() | ||
6206 | } | 6245 | } |
6207 | 6246 | ||
6208 | 6247 | ||
@@ -6223,7 +6262,7 @@ DataFormatPanel.prototype.addDataFont = function (container) { | @@ -6223,7 +6262,7 @@ DataFormatPanel.prototype.addDataFont = function (container) { | ||
6223 | <div class="layui-form-item" id="${enumActionEl.DEVICE_EL}"> | 6262 | <div class="layui-form-item" id="${enumActionEl.DEVICE_EL}"> |
6224 | <label class="layui-form-label">设备</label> | 6263 | <label class="layui-form-label">设备</label> |
6225 | <div class="layui-input-block"> | 6264 | <div class="layui-input-block"> |
6226 | - <select name="${enumConst.DEVICE_ID}" lay-verify="required" lay-filter="${enumActionEl.DEVICE_EL}"> | 6265 | + <select name="${enumConst.DEVICE_ID}" lay-verType="tips" lay-verify="required" lay-filter="${enumActionEl.DEVICE_EL}"> |
6227 | </select> | 6266 | </select> |
6228 | </div> | 6267 | </div> |
6229 | </div> | 6268 | </div> |
@@ -6231,7 +6270,7 @@ DataFormatPanel.prototype.addDataFont = function (container) { | @@ -6231,7 +6270,7 @@ DataFormatPanel.prototype.addDataFont = function (container) { | ||
6231 | <div class="layui-form-item" id="${enumActionEl.SLAVE_DEVICE_EL}" style="display: none"> | 6270 | <div class="layui-form-item" id="${enumActionEl.SLAVE_DEVICE_EL}" style="display: none"> |
6232 | <label class="layui-form-label">子设备</label> | 6271 | <label class="layui-form-label">子设备</label> |
6233 | <div class="layui-input-block"> | 6272 | <div class="layui-input-block"> |
6234 | - <select name="${enumConst.SLAVE_DEVICE_ID}" lay-verify="required" lay-filter="${enumActionEl.SLAVE_DEVICE_EL}"> | 6273 | + <select name="${enumConst.SLAVE_DEVICE_ID}" lay-verType="tips" lay-filter="${enumActionEl.SLAVE_DEVICE_EL}"> |
6235 | </select> | 6274 | </select> |
6236 | </div> | 6275 | </div> |
6237 | </div> | 6276 | </div> |
@@ -6239,7 +6278,7 @@ DataFormatPanel.prototype.addDataFont = function (container) { | @@ -6239,7 +6278,7 @@ DataFormatPanel.prototype.addDataFont = function (container) { | ||
6239 | <div class="layui-form-item" id="${enumActionEl.ATTR_EL}"> | 6278 | <div class="layui-form-item" id="${enumActionEl.ATTR_EL}"> |
6240 | <label class="layui-form-label">属性</label> | 6279 | <label class="layui-form-label">属性</label> |
6241 | <div class="layui-input-block"> | 6280 | <div class="layui-input-block"> |
6242 | - <select name="${enumConst.ATTR}" lay-verify="required" lay-filter="${enumActionEl.ATTR_EL}"></select> | 6281 | + <select name="${enumConst.ATTR}" lay-verType="tips" lay-verify="required" lay-filter="${enumActionEl.ATTR_EL}"></select> |
6243 | </div> | 6282 | </div> |
6244 | </div> | 6283 | </div> |
6245 | </div> | 6284 | </div> |
@@ -6269,12 +6308,13 @@ DataFormatPanel.prototype.addDataFont = function (container) { | @@ -6269,12 +6308,13 @@ DataFormatPanel.prototype.addDataFont = function (container) { | ||
6269 | ` | 6308 | ` |
6270 | 6309 | ||
6271 | layer.open({ | 6310 | layer.open({ |
6272 | - title: eventType[type], | 6311 | + title: enumEventType[type], |
6273 | content, | 6312 | content, |
6274 | skin: 'event-layer__override', | 6313 | skin: 'event-layer__override', |
6275 | btn: ['保存', '取消'], | 6314 | btn: ['保存', '取消'], |
6276 | - area: [IS_DISPLAY ? '1000px' : '800PX', '500px'], | ||
6277 | - success() { | 6315 | + area: IS_DISPLAY ? '1000px' : '800PX', |
6316 | + success(layero) { | ||
6317 | + $(layero).addClass('layui-form').find('.layui-layer-btn0').attr({ 'lay-submit': '', 'lay-filter': enumActionEl.LAYER_SUBMIT_FILTER }) | ||
6278 | generatorOrgTreeSelect() | 6318 | generatorOrgTreeSelect() |
6279 | const info = getLayerBindInfo('act', type) | 6319 | const info = getLayerBindInfo('act', type) |
6280 | if (info) { | 6320 | if (info) { |
@@ -6286,7 +6326,12 @@ DataFormatPanel.prototype.addDataFont = function (container) { | @@ -6286,7 +6326,12 @@ DataFormatPanel.prototype.addDataFont = function (container) { | ||
6286 | form.render() | 6326 | form.render() |
6287 | }, | 6327 | }, |
6288 | yes(index) { | 6328 | yes(index) { |
6289 | - submit(() => layer.close(index)) | 6329 | + form.on(`submit(${enumActionEl.LAYER_SUBMIT_FILTER})`, data => { |
6330 | + submit(() => { | ||
6331 | + layer.close(index) | ||
6332 | + getNodeBindInfo() | ||
6333 | + }) | ||
6334 | + }) | ||
6290 | }, | 6335 | }, |
6291 | btn2() { | 6336 | btn2() { |
6292 | 6337 | ||
@@ -10332,6 +10377,11 @@ class UseLayUi { | @@ -10332,6 +10377,11 @@ class UseLayUi { | ||
10332 | 10377 | ||
10333 | template = singleUsage ? UseLayUi.createSingleUseFormItem(template) : template | 10378 | template = singleUsage ? UseLayUi.createSingleUseFormItem(template) : template |
10334 | 10379 | ||
10380 | + /** | ||
10381 | + * @description 设置下拉树值 | ||
10382 | + * @param {string} id - layui tree 树形结构 title字段 | ||
10383 | + * @param {string} title - layui tree 树形结构 id字段 | ||
10384 | + */ | ||
10335 | function setValue({ id, title }) { | 10385 | function setValue({ id, title }) { |
10336 | $(elem) | 10386 | $(elem) |
10337 | .find('.layui-form-select').removeClass('layui-form-selected').end() | 10387 | .find('.layui-form-select').removeClass('layui-form-selected').end() |
@@ -10349,7 +10399,7 @@ class UseLayUi { | @@ -10349,7 +10399,7 @@ class UseLayUi { | ||
10349 | tree.render({ | 10399 | tree.render({ |
10350 | ...treeProps, | 10400 | ...treeProps, |
10351 | ...(autoFormatDataSource ? { data: UseLayUi.formatTreeDataSource(data, customSetTree, valueField, labelField, childrenField) } : {}), | 10401 | ...(autoFormatDataSource ? { data: UseLayUi.formatTreeDataSource(data, customSetTree, valueField, labelField, childrenField) } : {}), |
10352 | - elem: `#${layFilter}`, | 10402 | + elem: $(elem).find(`#${layFilter}`), |
10353 | click(node) { | 10403 | click(node) { |
10354 | setValue(node.data) | 10404 | setValue(node.data) |
10355 | if (UseLayUi.isFunction(click)) click(node) | 10405 | if (UseLayUi.isFunction(click)) click(node) |
@@ -10492,6 +10542,14 @@ class UseLayUi { | @@ -10492,6 +10542,14 @@ class UseLayUi { | ||
10492 | }) | 10542 | }) |
10493 | } | 10543 | } |
10494 | 10544 | ||
10545 | + static msg(msg, options) { | ||
10546 | + const { layer } = layui | ||
10547 | + layer.msg(msg, options) | ||
10548 | + } | ||
10549 | + | ||
10550 | + static successMsg(msg = '操作成功', options) { | ||
10551 | + UseLayUi.msg(msg, { ...options, icon: 6 }) | ||
10552 | + } | ||
10495 | 10553 | ||
10496 | } | 10554 | } |
10497 | 10555 | ||
@@ -10512,3 +10570,257 @@ function to(promise, errorExt) { | @@ -10512,3 +10570,257 @@ function to(promise, errorExt) { | ||
10512 | return [err, undefined] | 10570 | return [err, undefined] |
10513 | }) | 10571 | }) |
10514 | } | 10572 | } |
10573 | + | ||
10574 | + | ||
10575 | +class Ws { | ||
10576 | + /** | ||
10577 | + * @description url 连接地址 | ||
10578 | + */ | ||
10579 | + url | ||
10580 | + | ||
10581 | + /** | ||
10582 | + * @description 协议 | ||
10583 | + */ | ||
10584 | + protocols | ||
10585 | + | ||
10586 | + /** | ||
10587 | + * @description socket 实例 | ||
10588 | + * @type {WebSocket} | ||
10589 | + */ | ||
10590 | + ws | ||
10591 | + | ||
10592 | + /** | ||
10593 | + * @description 重连标志 | ||
10594 | + * @type {boolean} | ||
10595 | + */ | ||
10596 | + isReconnectionLoading = false | ||
10597 | + | ||
10598 | + /** | ||
10599 | + * @description 重连定时器 | ||
10600 | + */ | ||
10601 | + timeId = null | ||
10602 | + | ||
10603 | + /** | ||
10604 | + * @description 手动关闭标志位 | ||
10605 | + * @type {boolean} | ||
10606 | + */ | ||
10607 | + isCustomClose = false | ||
10608 | + | ||
10609 | + /** | ||
10610 | + * @description 消息队列 重新连接后会将之前断开期间发送的消息重新推送 | ||
10611 | + * @type {Array} | ||
10612 | + */ | ||
10613 | + errorStack = [] | ||
10614 | + | ||
10615 | + /** | ||
10616 | + * @description 创建websocket实例 | ||
10617 | + * @params {string} url - 连接路径 | ||
10618 | + * @params {string} protocols - 协议 | ||
10619 | + */ | ||
10620 | + constructor(url, protocols) { | ||
10621 | + this.url = url | ||
10622 | + this.protocols = protocols | ||
10623 | + this.createWs() | ||
10624 | + } | ||
10625 | + | ||
10626 | + /** | ||
10627 | + * @description | ||
10628 | + */ | ||
10629 | + createWs() { | ||
10630 | + this.ws = new WebSocket(this.url, this.protocols) | ||
10631 | + this.onopen() | ||
10632 | + this.onerror() | ||
10633 | + this.onclose() | ||
10634 | + this.onmessage() | ||
10635 | + } | ||
10636 | + | ||
10637 | + /** | ||
10638 | + * @description 建立连接时 | ||
10639 | + */ | ||
10640 | + onopen() { | ||
10641 | + this.ws.onopen = () => { | ||
10642 | + console.log(this.ws, 'onopen') | ||
10643 | + this.errorStack.forEach(message => { | ||
10644 | + this.send(message) | ||
10645 | + }) | ||
10646 | + this.errorStack = [] | ||
10647 | + this.isReconnectionLoading = false | ||
10648 | + } | ||
10649 | + } | ||
10650 | + | ||
10651 | + /** | ||
10652 | + * @description 连接发生错误 | ||
10653 | + */ | ||
10654 | + onerror() { | ||
10655 | + this.ws.onerror = (err) => { | ||
10656 | + console.log(err, 'onerror') | ||
10657 | + this.reconnection() | ||
10658 | + this.isReconnectionLoading = false | ||
10659 | + } | ||
10660 | + } | ||
10661 | + | ||
10662 | + /** | ||
10663 | + * @description 连接断开时 | ||
10664 | + */ | ||
10665 | + onclose() { | ||
10666 | + this.ws.onclose = () => { | ||
10667 | + console.log('onclose') | ||
10668 | + if (this.isCustomClose) return | ||
10669 | + | ||
10670 | + this.reconnection() | ||
10671 | + this.isReconnectionLoading = false | ||
10672 | + } | ||
10673 | + } | ||
10674 | + | ||
10675 | + /** | ||
10676 | + * @description 接受消息 | ||
10677 | + */ | ||
10678 | + async onmessage() { | ||
10679 | + this.ws.onmessage = (event) => { | ||
10680 | + try { | ||
10681 | + const data = JSON.parse(event.data) | ||
10682 | + this.eventCenter.emit(data.type, data.data) | ||
10683 | + } catch (error) { | ||
10684 | + console.log(error, 'error') | ||
10685 | + } | ||
10686 | + } | ||
10687 | + } | ||
10688 | + | ||
10689 | + /** | ||
10690 | + * @description 断开重连 | ||
10691 | + */ | ||
10692 | + reconnection() { | ||
10693 | + if (this.isReconnectionLoading) return | ||
10694 | + | ||
10695 | + this.isReconnectionLoading = true | ||
10696 | + clearTimeout(this.timeId) | ||
10697 | + this.timeId = setTimeout(() => { | ||
10698 | + this.createWs() | ||
10699 | + }, 10000) | ||
10700 | + } | ||
10701 | + | ||
10702 | + /** | ||
10703 | + * @description 发送消息 | ||
10704 | + */ | ||
10705 | + send(message) { | ||
10706 | + if (this.ws.readyState !== 1) { | ||
10707 | + this.errorStack.push(message) | ||
10708 | + return | ||
10709 | + } | ||
10710 | + | ||
10711 | + this.ws.send(message) | ||
10712 | + } | ||
10713 | + | ||
10714 | + /** | ||
10715 | + * @description 手动关闭 | ||
10716 | + */ | ||
10717 | + close() { | ||
10718 | + this.isCustomClose = true | ||
10719 | + this.ws.close() | ||
10720 | + } | ||
10721 | + | ||
10722 | + /** | ||
10723 | + * @description 手动开启 | ||
10724 | + */ | ||
10725 | + start() { | ||
10726 | + this.isCustomClose = false | ||
10727 | + this.reconnection() | ||
10728 | + } | ||
10729 | + | ||
10730 | + /** | ||
10731 | + * @description 销毁 | ||
10732 | + */ | ||
10733 | + destroy() { | ||
10734 | + this.close() | ||
10735 | + this.ws = null | ||
10736 | + this.errorStack = null | ||
10737 | + this.eventCenter = null | ||
10738 | + } | ||
10739 | +} | ||
10740 | + | ||
10741 | + | ||
10742 | +class EventCenter { | ||
10743 | + | ||
10744 | + /** | ||
10745 | + * @description 调度中心 | ||
10746 | + * @type {Map<string, Function[]} | ||
10747 | + */ | ||
10748 | + eventStack | ||
10749 | + | ||
10750 | + /** | ||
10751 | + * @description | ||
10752 | + */ | ||
10753 | + constructor() { | ||
10754 | + this.eventStack = new Map() | ||
10755 | + } | ||
10756 | + | ||
10757 | + /** | ||
10758 | + * @description 监听事件 | ||
10759 | + */ | ||
10760 | + on(eventName, callback) { | ||
10761 | + if (this.eventStack.has(eventName)) { | ||
10762 | + this.eventStack.get(eventName).push(callback) | ||
10763 | + return | ||
10764 | + } | ||
10765 | + this.eventStack.set(eventName, [callback]) | ||
10766 | + } | ||
10767 | + | ||
10768 | + /** | ||
10769 | + * @description 触发事件 | ||
10770 | + */ | ||
10771 | + emit(eventName, ...args) { | ||
10772 | + if (this.eventStack.has(eventName)) | ||
10773 | + this.eventStack.get(eventName).forEach(fn => fn(...args)) | ||
10774 | + | ||
10775 | + } | ||
10776 | + | ||
10777 | + /** | ||
10778 | + * @description 移除事件 | ||
10779 | + */ | ||
10780 | + off(eventName) { | ||
10781 | + if (this.eventStack.has(eventName)) | ||
10782 | + this.eventStack.delete(eventName) | ||
10783 | + } | ||
10784 | + | ||
10785 | + /** | ||
10786 | + * @description 清除事件 | ||
10787 | + */ | ||
10788 | + clean(eventName) { | ||
10789 | + this.eventStack.clear() | ||
10790 | + } | ||
10791 | + | ||
10792 | + | ||
10793 | +} | ||
10794 | + | ||
10795 | + | ||
10796 | +// TODO preview action | ||
10797 | +function previewAction() { | ||
10798 | + | ||
10799 | + setTimeout(() => { | ||
10800 | + console.dir(GLOBAL_EDITOR_UI) | ||
10801 | + }, 5000); | ||
10802 | + | ||
10803 | + function getContentInfo() { | ||
10804 | + | ||
10805 | + } | ||
10806 | + | ||
10807 | + const sendMsgTemplate = { | ||
10808 | + tsSubCmds: [ | ||
10809 | + { | ||
10810 | + entityType: "DEVICE", | ||
10811 | + entityId: "a5ef5840-d68a-11ec-9c71-a9680487d1e0", | ||
10812 | + scope: "LATEST_TELEMETRY", | ||
10813 | + cmdId: 1 | ||
10814 | + } | ||
10815 | + ] | ||
10816 | + } | ||
10817 | + | ||
10818 | + const GLOBAL_TOKEN = JSON.parse(localStorage.getItem("UNDEFINED__DEVELOPMENT__2.7.1__COMMON__LOCAL__KEY__")).value.JWT_TOKEN.value | ||
10819 | + | ||
10820 | + const wsUrl = `ws://192.168.10.115:8080/api/ws/plugins/telemetry?token=${GLOBAL_TOKEN}` | ||
10821 | + | ||
10822 | + const websocket = new Ws(wsUrl) | ||
10823 | + | ||
10824 | +} | ||
10825 | + | ||
10826 | +previewAction() |