From 248caf78891a6814ed34ca9168b98b45721acc75 Mon Sep 17 00:00:00 2001 From: Poised_flw Date: Fri, 29 Oct 2021 19:23:52 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=AF=E6=8C=81=E5=A4=9Adialog=E6=89=93?= =?UTF-8?q?=E5=BC=80=EF=BC=88=E6=8E=A7=E5=88=B6z-index=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/components/Dialog/DialogPc.vue | 181 +++--------------- .../src/components/Dialog/Pc.vue | 171 +++++++++++++++++ src/tis_app_template_kt/src/tis/bus.js | 36 +++- 3 files changed, 236 insertions(+), 152 deletions(-) create mode 100644 src/tis_app_template_kt/src/components/Dialog/Pc.vue diff --git a/src/tis_app_template_kt/src/components/Dialog/DialogPc.vue b/src/tis_app_template_kt/src/components/Dialog/DialogPc.vue index 614f920..14f8892 100644 --- a/src/tis_app_template_kt/src/components/Dialog/DialogPc.vue +++ b/src/tis_app_template_kt/src/components/Dialog/DialogPc.vue @@ -1,159 +1,38 @@ - - + }, + methods: { + } +} + diff --git a/src/tis_app_template_kt/src/components/Dialog/Pc.vue b/src/tis_app_template_kt/src/components/Dialog/Pc.vue new file mode 100644 index 0000000..85e5c71 --- /dev/null +++ b/src/tis_app_template_kt/src/components/Dialog/Pc.vue @@ -0,0 +1,171 @@ + + + + + diff --git a/src/tis_app_template_kt/src/tis/bus.js b/src/tis_app_template_kt/src/tis/bus.js index 1c15713..08cbd76 100644 --- a/src/tis_app_template_kt/src/tis/bus.js +++ b/src/tis_app_template_kt/src/tis/bus.js @@ -1,6 +1,8 @@ import Vue from "vue"; import {registerApps} from './scriptsLoader/index' +let dialogZIndex = 400 + // temp let curBaseUrl = '' const dev = process.env.NODE_ENV === 'development'; @@ -119,7 +121,12 @@ const bus = new Vue({ } if (!this.actives.some(l => l.component === c.component)) { - //弹窗暂定为同一时间只能打开一个 + //弹窗暂定为同一时间只能打开一个 "PopupWidget" 非dialog + // 计算z-index + if (!c.zIndex) { + c.zIndex = this.getNextDialogZIndex() + } + if (c.type === 'dialog') { this.actives = [c]; } else { @@ -137,17 +144,44 @@ const bus = new Vue({ console.log('actives变化状态', this.actives); this.menuStatusUpdate(); }, + + getNextDialogZIndex() { + let zIndex = 0 + for (let item of this.actives) { + if (item.zIndex && item.zIndex > zIndex) { + zIndex = item.zIndex + } + } + return zIndex > 0 ? zIndex + 1 : dialogZIndex + }, + // 最小化激活的弹窗 minimizeComponent(component) { this.actives.forEach(c => { const comp = c.component.name || c.component + console.log(comp, component, c) if (comp === component) { c.status = 'minimize' + c.zIndex = 0 } }) + this.actives = [...this.actives] + console.log('after minimize', this.actives) this.menuStatusUpdate() }, + // 激活窗口 + activeComponent(component) { + const curComponent = this.actives.find(v => (c.component.name || c.component) === component) + const maxZIndex = Math.max.apply(Math, this.actives.map(function(o) { return o.zIndex; })) + const maxComponent = this.actives.find(v => v.zIndex === maxZIndex) + if (curComponent === maxComponent) return; + + maxComponent.zIndex = curComponent.zIndex + curComponent.zIndex = maxZIndex + this.actives = [...this.actives] + }, + // 关闭组件 closeComponent(components) { //修改layout中的状态