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 | 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 | 685 | //更多图形,显示出来的的标题跟id,同时包括图片 |
681 | 686 | |
682 | 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 | 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 | 691 | this.setComponentPermission(DEFAULT, [DYNAMIC_EFFECT]) |
687 | 692 | this.setComponentPermission(REAL_TIME, [DYNAMIC_EFFECT]) |
688 | 693 | this.setComponentPermission(TITLE, [INTERACTION, DYNAMIC_EFFECT]) | ... | ... |
... | ... | @@ -5016,7 +5016,8 @@ DataFormatPanel.prototype.addDataFont = function (container) { |
5016 | 5016 | FLASH: 'FLASH', |
5017 | 5017 | ROTATE: 'ROTATE', |
5018 | 5018 | IMAGE: 'IMAGE', |
5019 | - SWITCH: 'SWITCH' | |
5019 | + SWITCH: 'SWITCH', | |
5020 | + RUNNING: 'RUNNING' | |
5020 | 5021 | } |
5021 | 5022 | |
5022 | 5023 | const interactionList = [ |
... | ... | @@ -5133,7 +5134,8 @@ DataFormatPanel.prototype.addDataFont = function (container) { |
5133 | 5134 | [permissionKey.VAR_IMAGE]: createVarImagePanel, |
5134 | 5135 | [permissionKey.VIDEO]: createVideoBindPanel, |
5135 | 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 | 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 | 5420 | * @description 是否是折线图 |
5408 | 5421 | * @param {boolean} isLineChart |
5409 | 5422 | */ |
... | ... | @@ -6991,12 +7004,14 @@ DataFormatPanel.prototype.addDataFont = function (container) { |
6991 | 7004 | */ |
6992 | 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 | 7010 | const enumEventType = { |
6997 | 7011 | FLASH: '闪烁', |
6998 | 7012 | DISPLAY: '显示/隐藏', |
6999 | 7013 | ROTATE: '旋转', |
7014 | + RUNNING: '运行于停止' | |
7000 | 7015 | } |
7001 | 7016 | |
7002 | 7017 | const enumActionEl = { |
... | ... | @@ -7031,6 +7046,18 @@ DataFormatPanel.prototype.addDataFont = function (container) { |
7031 | 7046 | |
7032 | 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 | 7062 | * @description |
7036 | 7063 | */ |
... | ... | @@ -7040,12 +7067,8 @@ DataFormatPanel.prototype.addDataFont = function (container) { |
7040 | 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 | 7072 | return ` |
7050 | 7073 | <div class="layui-form-item" style="margin-bottom: 0px"> |
7051 | 7074 | <div class="layui-input-block" style="margin-left: 0px;"> |
... | ... | @@ -7061,7 +7084,8 @@ DataFormatPanel.prototype.addDataFont = function (container) { |
7061 | 7084 | function addRecord() { |
7062 | 7085 | const content = ` |
7063 | 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 | 7089 | <td> |
7066 | 7090 | <input autocomplete="off" lay-verType="tips" lay-verify="required" type="number" name="${enumConst.MIN}" class="layui-input ${enumActionEl.MIN_FILTER}"> |
7067 | 7091 | </td> |
... | ... | @@ -7075,7 +7099,7 @@ DataFormatPanel.prototype.addDataFont = function (container) { |
7075 | 7099 | ` |
7076 | 7100 | addRowNumber++ |
7077 | 7101 | $(`#${enumActionEl.TABLE_BODY_EL}`).append(content) |
7078 | - if (IS_DISPLAY) { | |
7102 | + if (IS_DISPLAY || IS_RUNNING) { | |
7079 | 7103 | form.render() |
7080 | 7104 | } |
7081 | 7105 | } |
... | ... | @@ -7232,6 +7256,7 @@ DataFormatPanel.prototype.addDataFont = function (container) { |
7232 | 7256 | <thead> |
7233 | 7257 | <tr> |
7234 | 7258 | ${IS_DISPLAY ? '<th style="text-align:center">类型</th>' : ''} |
7259 | + ${IS_RUNNING ? '<th style="text-align:center">类型</th>' : ''} | |
7235 | 7260 | <th style="text-align:center">最小值(>=)</th> |
7236 | 7261 | <th style="text-align:center">最大值(<=)</th> |
7237 | 7262 | <th style="text-align:center">操作</th> |
... | ... | @@ -7251,7 +7276,7 @@ DataFormatPanel.prototype.addDataFont = function (container) { |
7251 | 7276 | skin: 'event-layer__override', |
7252 | 7277 | btn: ['保存', '取消'], |
7253 | 7278 | offset: '100px', |
7254 | - area: IS_DISPLAY ? '1000px' : '800PX', | |
7279 | + area: (IS_DISPLAY || IS_RUNNING) ? '1000px' : '800PX', | |
7255 | 7280 | success(layero) { |
7256 | 7281 | $(layero).addClass('layui-form').find('.layui-layer-btn0').attr({ |
7257 | 7282 | 'lay-submit': '', |
... | ... | @@ -8166,8 +8191,11 @@ DataFormatPanel.prototype.addDataFont = function (container) { |
8166 | 8191 | $(`#${enumDynamicEffectType.FLASH}`).click({ type: enumDynamicEffectType.FLASH }, proxyFn(handleDataDynamicEffect)); |
8167 | 8192 | $(`#${enumDynamicEffectType.DISPLAY}`).click({ type: enumDynamicEffectType.DISPLAY }, proxyFn(handleDataDynamicEffect)); |
8168 | 8193 | $(`#${enumDynamicEffectType.ROTATE}`).click({ type: enumDynamicEffectType.ROTATE }, proxyFn(handleDataDynamicEffect)); |
8194 | + $(`#${enumDynamicEffectType.RUNNING}`).click({ type: enumDynamicEffectType.RUNNING }, proxyFn(handleDataDynamicEffect)) | |
8169 | 8195 | |
8170 | 8196 | $(`#${enumDynamicEffectType.SWITCH}`).click({ type: enumDynamicEffectType.SWITCH }, proxyFn(handleStateSetting)) |
8197 | + | |
8198 | + | |
8171 | 8199 | }); |
8172 | 8200 | }; |
8173 | 8201 | |
... | ... | @@ -14001,6 +14029,7 @@ class HandleDynamicEffect { |
14001 | 14029 | DISPLAY: 'DISPLAY', |
14002 | 14030 | ROTATE: 'ROTATE', |
14003 | 14031 | IMAGE: 'IMAGE', |
14032 | + RUNNING: 'RUNNING' | |
14004 | 14033 | } |
14005 | 14034 | |
14006 | 14035 | static enumDisplayType = { |
... | ... | @@ -14008,6 +14037,11 @@ class HandleDynamicEffect { |
14008 | 14037 | HIDDEN: 'hidden', |
14009 | 14038 | } |
14010 | 14039 | |
14040 | + static enumRunningType = { | |
14041 | + RUN: 'run', | |
14042 | + STOP: 'stop' | |
14043 | + } | |
14044 | + | |
14011 | 14045 | static enumVideoConst = { |
14012 | 14046 | ORG_ID: 'orgId', |
14013 | 14047 | RECORD_ID: 'id', |
... | ... | @@ -14199,6 +14233,9 @@ class HandleDynamicEffect { |
14199 | 14233 | case HandleDynamicEffect.enumActType.IMAGE: |
14200 | 14234 | invoke = this.varImage.bind(this) |
14201 | 14235 | break |
14236 | + case HandleDynamicEffect.enumActType.RUNNING: | |
14237 | + invoke = this.running.bind(this) | |
14238 | + break | |
14202 | 14239 | } |
14203 | 14240 | return invoke |
14204 | 14241 | } |
... | ... | @@ -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 | 14388 | * @description 播放视频 |
14332 | 14389 | */ | ... | ... |