n20-common-lib 3.3.28 → 3.3.29

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "n20-common-lib",
3
- "version": "3.3.28",
3
+ "version": "3.3.29",
4
4
  "private": false,
5
5
  "scripts": {
6
6
  "serve": "vue-cli-service serve",
@@ -54,6 +54,7 @@
54
54
  "axios": "*",
55
55
  "dayjs": "*",
56
56
  "decimal.js": "^10.5.0",
57
+ "dom-zindex": "^1.0.6",
57
58
  "js-cookie": "^3.0.1",
58
59
  "jsencrypt": "^3.3.2",
59
60
  "jsonwebtoken": "^8.5.1",
@@ -6,6 +6,7 @@ import dayjs from 'dayjs'
6
6
  import XEUtils from 'xe-utils'
7
7
  import { $lc } from '../../utils/i18n/index.js'
8
8
  import zhCN from 'vxe-table/lib/locale/lang/zh-CN'
9
+ import installPopupZIndexBridge from '../../utils/popupZIndex'
9
10
  // 打平对象
10
11
  function flattenObject(obj, prefix = '', result = {}) {
11
12
  // 遍历对象的每个属性
@@ -158,6 +159,8 @@ vxeTable.formats.mixin({
158
159
  }
159
160
  }) */
160
161
  function install(Vue) {
162
+ // 原生 vxe-table 与 TablePro 使用同一套弹层层级。
163
+ installPopupZIndexBridge()
161
164
  Vue.use(vxeTable)
162
165
  }
163
166
 
@@ -138,6 +138,7 @@ import tableSetSize from '../TableSetSize/index.vue'
138
138
  import { $lc } from '../../utils/i18n/index.js'
139
139
  import XEUtils from 'xe-utils'
140
140
  import { isTableCellInteractiveTarget } from './cellClick'
141
+ import installPopupZIndexBridge from '../../utils/popupZIndex'
141
142
  const DEFAULT_SCROLL_Y = {
142
143
  enabled: true,
143
144
  gt: 30,
@@ -161,6 +162,10 @@ const renderer = {
161
162
  }
162
163
  export default {
163
164
  name: 'TablePro',
165
+ beforeCreate() {
166
+ // 按需引用组件时,也要在子表格创建 tooltip 前完成层级桥接。
167
+ installPopupZIndexBridge()
168
+ },
164
169
  components: {
165
170
  tableSetSize,
166
171
  empty,
@@ -3,8 +3,9 @@ import 'vxe-table/lib/style.css'
3
3
  import filterContent from './filterContent.vue'
4
4
  import numerify from 'numerify'
5
5
  import dayjs from 'dayjs'
6
- import { $lc } from '../../utils/i18n/index.js'
6
+ import { $lc } from '../../../utils/i18n/index.js'
7
7
  import zhCN from 'vxe-table/lib/locale/lang/zh-CN'
8
+ import installPopupZIndexBridge from '../../../utils/popupZIndex'
8
9
  // 打平对象
9
10
  function flattenObject(obj, prefix = '', result = {}) {
10
11
  // 遍历对象的每个属性
@@ -123,6 +124,8 @@ vxeTable.formats.mixin({
123
124
  })
124
125
 
125
126
  function install(Vue) {
127
+ // v3 独立安装时也复用公共层级桥接。
128
+ installPopupZIndexBridge()
126
129
  Vue.use(vxeTable)
127
130
  }
128
131
 
@@ -454,6 +454,7 @@ import { saveTransform } from '../../ShowColumn/index.vue'
454
454
  import tableOperate from '../../TableOperate/index.vue'
455
455
  import { isTableCellInteractiveTarget } from '../../TablePro/cellClick'
456
456
  import OperateBtns from '../../TableProOperateColumn/OperateBtns.vue'
457
+ import installPopupZIndexBridge from '../../../utils/popupZIndex'
457
458
 
458
459
  const DEFAULT_OPERATE_COLUMN_WIDTH = 180
459
460
 
@@ -473,6 +474,10 @@ const renderer = {
473
474
  }
474
475
  export default {
475
476
  name: 'TableProV3',
477
+ beforeCreate() {
478
+ // 按需引用 v3 组件时,也在子表格创建 tooltip 前完成公共桥接。
479
+ installPopupZIndexBridge()
480
+ },
476
481
  components: {
477
482
  tableOperate,
478
483
  tableShowColumn,
@@ -0,0 +1,42 @@
1
+ import Vue from 'vue'
2
+ import DomZIndex from 'dom-zindex'
3
+ import PopupManager from 'element-ui/lib/utils/popup/popup-manager'
4
+ import SourcePopupManager from 'element-ui/src/utils/popup/popup-manager'
5
+
6
+ const BRIDGE_FLAG = '__n20PopupZIndexBridge__'
7
+
8
+ function bridgePopupManager(manager) {
9
+ if (manager[BRIDGE_FLAG]) return
10
+
11
+ const descriptor = Object.getOwnPropertyDescriptor(manager, 'zIndex')
12
+
13
+ // Element 保存下一次可用的层级,dom-zindex 保存最后一次已分配的层级。
14
+ DomZIndex.setCurrent(Math.max(DomZIndex.getCurrent(), manager.zIndex - 1))
15
+ Object.defineProperty(manager, 'zIndex', {
16
+ configurable: true,
17
+ get() {
18
+ // 兼容先安装表格、后安装 Element 的顺序,保留业务配置的初始层级。
19
+ const configuredZIndex = Number((Vue.prototype.$ELEMENT || {}).zIndex) || 2000
20
+ return Math.max(descriptor.get.call(manager), DomZIndex.getCurrent() + 1, configuredZIndex)
21
+ },
22
+ set(value) {
23
+ const nextZIndex = Number(value)
24
+ if (!Number.isFinite(nextZIndex)) return
25
+
26
+ // 两套组件共用递增水位,避免打开嵌套弹窗或设置较小层级时发生回退。
27
+ const currentZIndex = Math.max(DomZIndex.getCurrent(), nextZIndex - 1)
28
+ DomZIndex.setCurrent(currentZIndex)
29
+ descriptor.set.call(manager, currentZIndex + 1)
30
+ }
31
+ })
32
+ Object.defineProperty(manager, BRIDGE_FLAG, { value: true })
33
+ }
34
+
35
+ /** 统一 Element 弹层与 vxe tooltip 的层级,重复安装 v2/v3 时只桥接一次。 */
36
+ export default function installPopupZIndexBridge() {
37
+ if (typeof document === 'undefined') return
38
+
39
+ bridgePopupManager(PopupManager)
40
+ // 组件库的 loading 等指令仍引用 Element 源码入口,需要同步这份管理器。
41
+ bridgePopupManager(SourcePopupManager)
42
+ }