zydx-plus 1.35.636 → 1.35.638
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
|
@@ -286,7 +286,7 @@ export default {
|
|
|
286
286
|
// 解析选项并回填答案
|
|
287
287
|
if (item.testKey) {
|
|
288
288
|
item.testKey = typeof item.testKey === 'string' ? JSON.parse(item.testKey) : item.testKey
|
|
289
|
-
this.markCheckedOptions(item)
|
|
289
|
+
// this.markCheckedOptions(item) // 选择题选项的选中状态checked的值是true还是false,在组件外面引用该组件的父级组件中根据参数设置好了,不再用此处方法在组件内部处理了
|
|
290
290
|
}
|
|
291
291
|
|
|
292
292
|
return item
|
|
@@ -46,73 +46,71 @@ export default {
|
|
|
46
46
|
watch: {
|
|
47
47
|
isShowsRight() {
|
|
48
48
|
this.$nextTick(() => {
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
this.handleResize()
|
|
52
|
-
} else if (this.$refs.leftRef) {
|
|
53
|
-
this.leftWidth = '100%'
|
|
54
|
-
}
|
|
49
|
+
this.resetWidth()
|
|
50
|
+
this.handleResize()
|
|
55
51
|
})
|
|
56
52
|
},
|
|
57
53
|
isShowsLeft() {
|
|
58
54
|
this.$nextTick(() => {
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
this.handleResize()
|
|
62
|
-
} else if (this.$refs.rightRef) {
|
|
63
|
-
this.rightWidth = '100%'
|
|
64
|
-
}
|
|
55
|
+
this.resetWidth()
|
|
56
|
+
this.handleResize()
|
|
65
57
|
})
|
|
66
58
|
}
|
|
67
59
|
},
|
|
68
60
|
data() {
|
|
69
|
-
// 由 props
|
|
70
|
-
|
|
71
|
-
if (this.isPercent) {
|
|
72
|
-
const lw = w <= 0 || w >= 100 ? 30 : w
|
|
73
|
-
return {
|
|
74
|
-
leftWidth: lw + '%',
|
|
75
|
-
rightWidth: (100 - lw) + '%'
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
return {
|
|
79
|
-
leftWidth: w + 'px',
|
|
80
|
-
// px 模式右侧占满剩余空间,无需测量容器宽度即可首屏正确
|
|
81
|
-
rightWidth: `calc(100% - ${w}px - 10px)`
|
|
82
|
-
}
|
|
61
|
+
// 由 props 与可见性直接计算初始宽度,保证首屏渲染即为正确宽度,避免闪动
|
|
62
|
+
return this.getInitWidth()
|
|
83
63
|
},
|
|
84
64
|
mounted() {
|
|
85
65
|
this.handleResize()
|
|
86
66
|
},
|
|
87
67
|
methods: {
|
|
88
|
-
//
|
|
89
|
-
|
|
68
|
+
// 根据 props 与可见性计算左右宽度
|
|
69
|
+
getInitWidth() {
|
|
70
|
+
// 右侧隐藏时,左侧占满 100%
|
|
71
|
+
if (!this.isShowsRight) {
|
|
72
|
+
return { leftWidth: '100%', rightWidth: '0' }
|
|
73
|
+
}
|
|
74
|
+
// 左侧隐藏时,右侧占满 100%
|
|
75
|
+
if (!this.isShowsLeft) {
|
|
76
|
+
return { leftWidth: '0', rightWidth: '100%' }
|
|
77
|
+
}
|
|
90
78
|
const w = this.leftInitWidth
|
|
91
79
|
if (this.isPercent) {
|
|
92
80
|
const lw = w <= 0 || w >= 100 ? 30 : w
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
81
|
+
return { leftWidth: lw + '%', rightWidth: (100 - lw) + '%' }
|
|
82
|
+
}
|
|
83
|
+
return {
|
|
84
|
+
leftWidth: w + 'px',
|
|
85
|
+
// px 模式右侧占满剩余空间,无需测量容器宽度即可首屏正确
|
|
86
|
+
rightWidth: `calc(100% - ${w}px - 10px)`
|
|
98
87
|
}
|
|
99
88
|
},
|
|
89
|
+
// 由 props 与可见性重新计算左右宽度(供显示切换/外部调用)
|
|
90
|
+
resetWidth() {
|
|
91
|
+
const { leftWidth, rightWidth } = this.getInitWidth()
|
|
92
|
+
this.leftWidth = leftWidth
|
|
93
|
+
this.rightWidth = rightWidth
|
|
94
|
+
},
|
|
100
95
|
handleResize() {
|
|
101
96
|
// 获取Dom节点
|
|
102
97
|
const boxDom = this.$refs.boxRef,
|
|
103
|
-
leftDom = this.$refs.leftRef,
|
|
104
98
|
resizeDom = this.$refs.resizeRef;
|
|
105
99
|
if (resizeDom) {
|
|
106
100
|
// 使用 .resize div 的实际宽度(10px)而非 img 宽度(30px),避免拖动位置偏左
|
|
107
101
|
const resizeWidth = resizeDom.parentElement.offsetWidth
|
|
108
|
-
const containerWidth = boxDom.clientWidth
|
|
109
|
-
const maxWidth = containerWidth - resizeWidth; // 左右两边区域的总宽度 = 外层容器宽度 - 中间区域拖拉框的宽度
|
|
110
102
|
resizeDom.onmousedown = e => {
|
|
111
|
-
|
|
112
|
-
|
|
103
|
+
e.preventDefault()
|
|
104
|
+
// 记录按下瞬间分隔条位置,计算鼠标相对分隔条左边缘的抓取偏移
|
|
105
|
+
const handleRect = resizeDom.parentElement.getBoundingClientRect()
|
|
106
|
+
const grabOffset = e.clientX - handleRect.left
|
|
113
107
|
document.onmousemove = e => {
|
|
114
|
-
|
|
115
|
-
|
|
108
|
+
// 每帧重新测量容器实际宽度与位置,避免整体宽度变化(窗口/父容器缩放)导致的累计偏移
|
|
109
|
+
const curBoxRect = boxDom.getBoundingClientRect()
|
|
110
|
+
const containerWidth = curBoxRect.width
|
|
111
|
+
const maxWidth = containerWidth - resizeWidth; // 左右两边区域的总宽度 = 外层容器宽度 - 中间区域拖拉框的宽度
|
|
112
|
+
// 鼠标相对容器左边缘的位置 - 抓取偏移 = 新的左区域宽度(px),使抓取点始终贴合分隔条
|
|
113
|
+
let moveLen = (e.clientX - curBoxRect.left) - grabOffset
|
|
116
114
|
// 限制左边区域的最小宽度为 leftMinWidth
|
|
117
115
|
if (moveLen < this.leftMinWidth) {
|
|
118
116
|
moveLen = this.leftMinWidth;
|