Commit 0f93987f6755fe7da0bced59d9c2d731f5a5711a
1 parent
7cd64571
feat: implement line component running dynamic effect
Showing
2 changed files
with
78 additions
and
16 deletions
@@ -321,9 +321,14 @@ | @@ -321,9 +321,14 @@ | ||
321 | SWITCH_STATE_SETTING: 'stateSetting', | 321 | SWITCH_STATE_SETTING: 'stateSetting', |
322 | 322 | ||
323 | /** | 323 | /** |
324 | - * @description 只有单机事件 | 324 | + * @description 只有单击事件 |
325 | */ | 325 | */ |
326 | - ONLY_SINGLE_EVENT: 'onlySingleEvent' | 326 | + ONLY_SINGLE_EVENT: 'onlySingleEvent', |
327 | + | ||
328 | + /** | ||
329 | + * @description 运行于停止 | ||
330 | + */ | ||
331 | + RUNNING_AND_STOP: 'runningAndStop' | ||
327 | } | 332 | } |
328 | 333 | ||
329 | /** | 334 | /** |
@@ -680,9 +685,9 @@ | @@ -680,9 +685,9 @@ | ||
680 | //更多图形,显示出来的的标题跟id,同时包括图片 | 685 | //更多图形,显示出来的的标题跟id,同时包括图片 |
681 | 686 | ||
682 | // TODO thingsKit 设置数据绑定展示面板 | 687 | // TODO thingsKit 设置数据绑定展示面板 |
683 | - const { LINE_CHART_EXPAND, BAR_CHART_EXPAND, DYNAMIC_EFFECT, DATA_SOURCE, VAR_IMAGE, INTERACTION, VIDEO: VIDEO_PANEL, SWITCH_STATE_SETTING, ONLY_SINGLE_EVENT } = this.enumPermissionPanel | 688 | + const { LINE_CHART_EXPAND, BAR_CHART_EXPAND, DYNAMIC_EFFECT, DATA_SOURCE, VAR_IMAGE, INTERACTION, VIDEO: VIDEO_PANEL, SWITCH_STATE_SETTING, ONLY_SINGLE_EVENT, RUNNING_AND_STOP } = this.enumPermissionPanel |
684 | const { LINE, LINE_CHART, REAL_TIME, TITLE, VARIABLE, DEFAULT, BAR_CHART, VIDEO, SWITCH, PARAMS_SETTING_BUTTON } = this.enumComponentType | 689 | const { LINE, LINE_CHART, REAL_TIME, TITLE, VARIABLE, DEFAULT, BAR_CHART, VIDEO, SWITCH, PARAMS_SETTING_BUTTON } = this.enumComponentType |
685 | - this.setComponentPermission(LINE, [DYNAMIC_EFFECT]) | 690 | + this.setComponentPermission(LINE, [RUNNING_AND_STOP, DYNAMIC_EFFECT]) |
686 | this.setComponentPermission(DEFAULT, [DYNAMIC_EFFECT]) | 691 | this.setComponentPermission(DEFAULT, [DYNAMIC_EFFECT]) |
687 | this.setComponentPermission(REAL_TIME, [DYNAMIC_EFFECT]) | 692 | this.setComponentPermission(REAL_TIME, [DYNAMIC_EFFECT]) |
688 | this.setComponentPermission(TITLE, [INTERACTION, DYNAMIC_EFFECT]) | 693 | this.setComponentPermission(TITLE, [INTERACTION, DYNAMIC_EFFECT]) |
@@ -5016,7 +5016,8 @@ DataFormatPanel.prototype.addDataFont = function (container) { | @@ -5016,7 +5016,8 @@ DataFormatPanel.prototype.addDataFont = function (container) { | ||
5016 | FLASH: 'FLASH', | 5016 | FLASH: 'FLASH', |
5017 | ROTATE: 'ROTATE', | 5017 | ROTATE: 'ROTATE', |
5018 | IMAGE: 'IMAGE', | 5018 | IMAGE: 'IMAGE', |
5019 | - SWITCH: 'SWITCH' | 5019 | + SWITCH: 'SWITCH', |
5020 | + RUNNING: 'RUNNING' | ||
5020 | } | 5021 | } |
5021 | 5022 | ||
5022 | const interactionList = [ | 5023 | const interactionList = [ |
@@ -5133,7 +5134,8 @@ DataFormatPanel.prototype.addDataFont = function (container) { | @@ -5133,7 +5134,8 @@ DataFormatPanel.prototype.addDataFont = function (container) { | ||
5133 | [permissionKey.VAR_IMAGE]: createVarImagePanel, | 5134 | [permissionKey.VAR_IMAGE]: createVarImagePanel, |
5134 | [permissionKey.VIDEO]: createVideoBindPanel, | 5135 | [permissionKey.VIDEO]: createVideoBindPanel, |
5135 | [permissionKey.SWITCH_STATE_SETTING]: createSwitchStateSettingPanel, | 5136 | [permissionKey.SWITCH_STATE_SETTING]: createSwitchStateSettingPanel, |
5136 | - [permissionKey.ONLY_SINGLE_EVENT]: createParamsSettingButtonPanel | 5137 | + [permissionKey.ONLY_SINGLE_EVENT]: createParamsSettingButtonPanel, |
5138 | + [permissionKey.RUNNING_AND_STOP]: createRunningAndStopPanel | ||
5137 | } | 5139 | } |
5138 | 5140 | ||
5139 | 5141 | ||
@@ -5404,6 +5406,17 @@ DataFormatPanel.prototype.addDataFont = function (container) { | @@ -5404,6 +5406,17 @@ DataFormatPanel.prototype.addDataFont = function (container) { | ||
5404 | } | 5406 | } |
5405 | 5407 | ||
5406 | /** | 5408 | /** |
5409 | + * @description 运行停止 | ||
5410 | + */ | ||
5411 | + function createRunningAndStopPanel() { | ||
5412 | + dynamicEffectList.push({ | ||
5413 | + label: '运行与停止', | ||
5414 | + type: enumDynamicEffectType.RUNNING, | ||
5415 | + category: enumCategory.ACT | ||
5416 | + }) | ||
5417 | + } | ||
5418 | + | ||
5419 | + /** | ||
5407 | * @description 是否是折线图 | 5420 | * @description 是否是折线图 |
5408 | * @param {boolean} isLineChart | 5421 | * @param {boolean} isLineChart |
5409 | */ | 5422 | */ |
@@ -6991,12 +7004,14 @@ DataFormatPanel.prototype.addDataFont = function (container) { | @@ -6991,12 +7004,14 @@ DataFormatPanel.prototype.addDataFont = function (container) { | ||
6991 | */ | 7004 | */ |
6992 | function handleDataDynamicEffect(event) { | 7005 | function handleDataDynamicEffect(event) { |
6993 | 7006 | ||
6994 | - const IS_DISPLAY = event.data.type === 'DISPLAY' | 7007 | + const IS_DISPLAY = event.data.type === enumDynamicEffectType.DISPLAY |
7008 | + const IS_RUNNING = event.data.type === enumDynamicEffectType.RUNNING | ||
6995 | 7009 | ||
6996 | const enumEventType = { | 7010 | const enumEventType = { |
6997 | FLASH: '闪烁', | 7011 | FLASH: '闪烁', |
6998 | DISPLAY: '显示/隐藏', | 7012 | DISPLAY: '显示/隐藏', |
6999 | ROTATE: '旋转', | 7013 | ROTATE: '旋转', |
7014 | + RUNNING: '运行于停止' | ||
7000 | } | 7015 | } |
7001 | 7016 | ||
7002 | const enumActionEl = { | 7017 | const enumActionEl = { |
@@ -7031,6 +7046,18 @@ DataFormatPanel.prototype.addDataFont = function (container) { | @@ -7031,6 +7046,18 @@ DataFormatPanel.prototype.addDataFont = function (container) { | ||
7031 | 7046 | ||
7032 | const enumDisplayType = HandleDynamicEffect.enumDisplayType | 7047 | const enumDisplayType = HandleDynamicEffect.enumDisplayType |
7033 | 7048 | ||
7049 | + const enumRunningType = HandleDynamicEffect.enumRunningType | ||
7050 | + | ||
7051 | + const displayOptions = [ | ||
7052 | + { name: '显示', id: enumDisplayType.SHOW }, | ||
7053 | + { name: '隐藏', id: enumDisplayType.HIDDEN }, | ||
7054 | + ] | ||
7055 | + | ||
7056 | + const runningOptions = [ | ||
7057 | + { name: '运行', id: enumRunningType.RUN }, | ||
7058 | + { name: '停止', id: enumRunningType.STOP }, | ||
7059 | + ] | ||
7060 | + | ||
7034 | /** | 7061 | /** |
7035 | * @description | 7062 | * @description |
7036 | */ | 7063 | */ |
@@ -7040,12 +7067,8 @@ DataFormatPanel.prototype.addDataFont = function (container) { | @@ -7040,12 +7067,8 @@ DataFormatPanel.prototype.addDataFont = function (container) { | ||
7040 | enabled: false | 7067 | enabled: false |
7041 | } | 7068 | } |
7042 | 7069 | ||
7043 | - function generatorDisplayOptions() { | ||
7044 | - const options = [ | ||
7045 | - { name: '显示', id: enumDisplayType.SHOW }, | ||
7046 | - { name: '隐藏', id: enumDisplayType.HIDDEN }, | ||
7047 | - ] | ||
7048 | - const template = UseLayUi.generateOptionTemplate({ dataSource: options }) | 7070 | + function generateStateOptions(options = []) { |
7071 | + const template = UseLayUi.generateOptionTemplate({ dataSource: options, addPlaceholderOption: false }) | ||
7049 | return ` | 7072 | return ` |
7050 | <div class="layui-form-item" style="margin-bottom: 0px"> | 7073 | <div class="layui-form-item" style="margin-bottom: 0px"> |
7051 | <div class="layui-input-block" style="margin-left: 0px;"> | 7074 | <div class="layui-input-block" style="margin-left: 0px;"> |
@@ -7061,7 +7084,8 @@ DataFormatPanel.prototype.addDataFont = function (container) { | @@ -7061,7 +7084,8 @@ DataFormatPanel.prototype.addDataFont = function (container) { | ||
7061 | function addRecord() { | 7084 | function addRecord() { |
7062 | const content = ` | 7085 | const content = ` |
7063 | <tr class="layui-form" lay-filter="${getRowFilter(addRowNumber)}"> | 7086 | <tr class="layui-form" lay-filter="${getRowFilter(addRowNumber)}"> |
7064 | - ${IS_DISPLAY && `<td>${generatorDisplayOptions()}</td>`} | 7087 | + ${IS_DISPLAY && `<td>${generateStateOptions(displayOptions)}</td>`} |
7088 | + ${IS_RUNNING && `<td>${generateStateOptions(runningOptions)}</td>`} | ||
7065 | <td> | 7089 | <td> |
7066 | <input autocomplete="off" lay-verType="tips" lay-verify="required" type="number" name="${enumConst.MIN}" class="layui-input ${enumActionEl.MIN_FILTER}"> | 7090 | <input autocomplete="off" lay-verType="tips" lay-verify="required" type="number" name="${enumConst.MIN}" class="layui-input ${enumActionEl.MIN_FILTER}"> |
7067 | </td> | 7091 | </td> |
@@ -7075,7 +7099,7 @@ DataFormatPanel.prototype.addDataFont = function (container) { | @@ -7075,7 +7099,7 @@ DataFormatPanel.prototype.addDataFont = function (container) { | ||
7075 | ` | 7099 | ` |
7076 | addRowNumber++ | 7100 | addRowNumber++ |
7077 | $(`#${enumActionEl.TABLE_BODY_EL}`).append(content) | 7101 | $(`#${enumActionEl.TABLE_BODY_EL}`).append(content) |
7078 | - if (IS_DISPLAY) { | 7102 | + if (IS_DISPLAY || IS_RUNNING) { |
7079 | form.render() | 7103 | form.render() |
7080 | } | 7104 | } |
7081 | } | 7105 | } |
@@ -7232,6 +7256,7 @@ DataFormatPanel.prototype.addDataFont = function (container) { | @@ -7232,6 +7256,7 @@ DataFormatPanel.prototype.addDataFont = function (container) { | ||
7232 | <thead> | 7256 | <thead> |
7233 | <tr> | 7257 | <tr> |
7234 | ${IS_DISPLAY ? '<th style="text-align:center">类型</th>' : ''} | 7258 | ${IS_DISPLAY ? '<th style="text-align:center">类型</th>' : ''} |
7259 | + ${IS_RUNNING ? '<th style="text-align:center">类型</th>' : ''} | ||
7235 | <th style="text-align:center">最小值(>=)</th> | 7260 | <th style="text-align:center">最小值(>=)</th> |
7236 | <th style="text-align:center">最大值(<=)</th> | 7261 | <th style="text-align:center">最大值(<=)</th> |
7237 | <th style="text-align:center">操作</th> | 7262 | <th style="text-align:center">操作</th> |
@@ -7251,7 +7276,7 @@ DataFormatPanel.prototype.addDataFont = function (container) { | @@ -7251,7 +7276,7 @@ DataFormatPanel.prototype.addDataFont = function (container) { | ||
7251 | skin: 'event-layer__override', | 7276 | skin: 'event-layer__override', |
7252 | btn: ['保存', '取消'], | 7277 | btn: ['保存', '取消'], |
7253 | offset: '100px', | 7278 | offset: '100px', |
7254 | - area: IS_DISPLAY ? '1000px' : '800PX', | 7279 | + area: (IS_DISPLAY || IS_RUNNING) ? '1000px' : '800PX', |
7255 | success(layero) { | 7280 | success(layero) { |
7256 | $(layero).addClass('layui-form').find('.layui-layer-btn0').attr({ | 7281 | $(layero).addClass('layui-form').find('.layui-layer-btn0').attr({ |
7257 | 'lay-submit': '', | 7282 | 'lay-submit': '', |
@@ -8166,8 +8191,11 @@ DataFormatPanel.prototype.addDataFont = function (container) { | @@ -8166,8 +8191,11 @@ DataFormatPanel.prototype.addDataFont = function (container) { | ||
8166 | $(`#${enumDynamicEffectType.FLASH}`).click({ type: enumDynamicEffectType.FLASH }, proxyFn(handleDataDynamicEffect)); | 8191 | $(`#${enumDynamicEffectType.FLASH}`).click({ type: enumDynamicEffectType.FLASH }, proxyFn(handleDataDynamicEffect)); |
8167 | $(`#${enumDynamicEffectType.DISPLAY}`).click({ type: enumDynamicEffectType.DISPLAY }, proxyFn(handleDataDynamicEffect)); | 8192 | $(`#${enumDynamicEffectType.DISPLAY}`).click({ type: enumDynamicEffectType.DISPLAY }, proxyFn(handleDataDynamicEffect)); |
8168 | $(`#${enumDynamicEffectType.ROTATE}`).click({ type: enumDynamicEffectType.ROTATE }, proxyFn(handleDataDynamicEffect)); | 8193 | $(`#${enumDynamicEffectType.ROTATE}`).click({ type: enumDynamicEffectType.ROTATE }, proxyFn(handleDataDynamicEffect)); |
8194 | + $(`#${enumDynamicEffectType.RUNNING}`).click({ type: enumDynamicEffectType.RUNNING }, proxyFn(handleDataDynamicEffect)) | ||
8169 | 8195 | ||
8170 | $(`#${enumDynamicEffectType.SWITCH}`).click({ type: enumDynamicEffectType.SWITCH }, proxyFn(handleStateSetting)) | 8196 | $(`#${enumDynamicEffectType.SWITCH}`).click({ type: enumDynamicEffectType.SWITCH }, proxyFn(handleStateSetting)) |
8197 | + | ||
8198 | + | ||
8171 | }); | 8199 | }); |
8172 | }; | 8200 | }; |
8173 | 8201 | ||
@@ -14001,6 +14029,7 @@ class HandleDynamicEffect { | @@ -14001,6 +14029,7 @@ class HandleDynamicEffect { | ||
14001 | DISPLAY: 'DISPLAY', | 14029 | DISPLAY: 'DISPLAY', |
14002 | ROTATE: 'ROTATE', | 14030 | ROTATE: 'ROTATE', |
14003 | IMAGE: 'IMAGE', | 14031 | IMAGE: 'IMAGE', |
14032 | + RUNNING: 'RUNNING' | ||
14004 | } | 14033 | } |
14005 | 14034 | ||
14006 | static enumDisplayType = { | 14035 | static enumDisplayType = { |
@@ -14008,6 +14037,11 @@ class HandleDynamicEffect { | @@ -14008,6 +14037,11 @@ class HandleDynamicEffect { | ||
14008 | HIDDEN: 'hidden', | 14037 | HIDDEN: 'hidden', |
14009 | } | 14038 | } |
14010 | 14039 | ||
14040 | + static enumRunningType = { | ||
14041 | + RUN: 'run', | ||
14042 | + STOP: 'stop' | ||
14043 | + } | ||
14044 | + | ||
14011 | static enumVideoConst = { | 14045 | static enumVideoConst = { |
14012 | ORG_ID: 'orgId', | 14046 | ORG_ID: 'orgId', |
14013 | RECORD_ID: 'id', | 14047 | RECORD_ID: 'id', |
@@ -14199,6 +14233,9 @@ class HandleDynamicEffect { | @@ -14199,6 +14233,9 @@ class HandleDynamicEffect { | ||
14199 | case HandleDynamicEffect.enumActType.IMAGE: | 14233 | case HandleDynamicEffect.enumActType.IMAGE: |
14200 | invoke = this.varImage.bind(this) | 14234 | invoke = this.varImage.bind(this) |
14201 | break | 14235 | break |
14236 | + case HandleDynamicEffect.enumActType.RUNNING: | ||
14237 | + invoke = this.running.bind(this) | ||
14238 | + break | ||
14202 | } | 14239 | } |
14203 | return invoke | 14240 | return invoke |
14204 | } | 14241 | } |
@@ -14327,6 +14364,26 @@ class HandleDynamicEffect { | @@ -14327,6 +14364,26 @@ class HandleDynamicEffect { | ||
14327 | } | 14364 | } |
14328 | } | 14365 | } |
14329 | 14366 | ||
14367 | + running(message) { | ||
14368 | + const { subscriptionId, data = {} } = message | ||
14369 | + const { flag, condition } = this.validate(subscriptionId, HandleDynamicEffect.enumActType.RUNNING, data) | ||
14370 | + if (!flag) return | ||
14371 | + const node = this.getNodeByCmdId(subscriptionId) | ||
14372 | + let isRun = false | ||
14373 | + if (condition.type === HandleDynamicEffect.enumRunningType.RUN) { | ||
14374 | + isRun = true | ||
14375 | + } else if (condition.type === HandleDynamicEffect.enumRunningType.STOP) { | ||
14376 | + isRun = false | ||
14377 | + } | ||
14378 | + | ||
14379 | + const updateFn = () => { | ||
14380 | + const reg = /flowAnimation[^;]+/ | ||
14381 | + const style = node.getStyle() | ||
14382 | + node.setStyle(style.replace(reg, `flowAnimation=${isRun ? 1 : 0}`)) | ||
14383 | + } | ||
14384 | + this.insertOnceUpdateFn(node, updateFn) | ||
14385 | + } | ||
14386 | + | ||
14330 | /** | 14387 | /** |
14331 | * @description 播放视频 | 14388 | * @description 播放视频 |
14332 | */ | 14389 | */ |