vue2-client 1.16.22 → 1.16.24

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.
@@ -1,283 +1,283 @@
1
- <template>
2
- <div
3
- class="drawer"
4
- :class="{ 'drawer-collapsed': !isOpen }">
5
- <div
6
- v-show="!isFrameConfig"
7
- class="drawer-toggle"
8
- :class="{ 'toggle-collapsed': !isOpen }"
9
- @click="toggleDrawer">
10
- <div class="arrow">
11
- {{ isOpen ? '›' : '‹' }}
12
- </div>
13
- </div>
14
- <div class="drawer-content" v-show="isOpen">
15
- <x-report
16
- ref="x_report"
17
- :configName="queryParamsName"
18
- :server-name="serverName"
19
- :show-img-in-cell="true"
20
- :display-only="true"
21
- :edit-mode="false"
22
- :show-save-button="false"
23
- :no-padding="true"
24
- :dont-format="true">
25
- </x-report>
26
- </div>
27
- </div>
28
- </template>
29
-
30
- <script>
31
-
32
- import XReport from '@vue2-client/base-client/components/common/XReportGrid'
33
-
34
- export default {
35
- components: {
36
- XReport
37
- },
38
- name: 'XSidebar',
39
- props: {
40
- // 配置参数
41
- queryParamsName: {
42
- type: String,
43
- default: ''
44
- },
45
- serverName: {
46
- type: String,
47
- default: 'af-his'
48
- },
49
- // 是否允许该组件主动调整同级布局(默认不影响其它页面)
50
- affectLayout: {
51
- type: Boolean,
52
- default: false
53
- },
54
- // 展开时所占宽度百分比(影响父级 ant-col 的 flex 与 max-width)
55
- expandedWidthPercent: {
56
- type: Number,
57
- default: 33.3
58
- },
59
- // 收缩时所占宽度百分比
60
- collapsedWidthPercent: {
61
- type: Number,
62
- default: 2
63
- }
64
- },
65
- data () {
66
- return {
67
- isOpen: this.queryParamsName?.endsWith('Frame') || false,
68
- // 定义主内容区域的最大和最小宽度百分比
69
- mainWithData: [{ max: 80, min: 50 }]
70
- }
71
- },
72
- mounted () {
73
- // 在挂载后调整父元素宽度(方法内部已区分是否影响布局)
74
- this.updateLayout(this.isOpen)
75
- // 如果抽屉初始状态为打开,设置padding
76
- if (this.isOpen) {
77
- this.updateCardBodyPadding()
78
- }
79
- },
80
- methods: {
81
- toggleDrawer () {
82
- this.isOpen = !this.isOpen
83
- this.$emit('on-drawer-change', this.isOpen)
84
- this.updateLayout(this.isOpen)
85
- if (this.isOpen) {
86
- this.$nextTick(() => {
87
- this.updateCardBodyPadding()
88
- })
89
- }
90
- },
91
- // 更新card-body的padding
92
- updateCardBodyPadding () {
93
- this.$nextTick(() => {
94
- const cardBody = this.$el.querySelector('.ant-card-body')
95
- if (cardBody) {
96
- cardBody.style.padding = '3%'
97
- } else {
98
- // 如果找不到元素,可能需要等待XReport完全渲染
99
- setTimeout(() => {
100
- const cardBody = this.$el.querySelector('.ant-card-body')
101
- if (cardBody) {
102
- cardBody.style.padding = '3%'
103
- }
104
- }, 500)
105
- }
106
- })
107
- },
108
- // 获取同级的其他所有a-col元素
109
- getSiblingCols () {
110
- try {
111
- // 找到当前组件所在的a-col
112
- let currentCol = this.$el.parentNode
113
- while (currentCol && !currentCol.className.includes('ant-col')) {
114
- currentCol = currentCol.parentNode
115
- }
116
- if (!currentCol) {
117
- console.warn('当前组件不在a-col内')
118
- return []
119
- }
120
- // 找到a-col的父元素(a-row)
121
- const row = currentCol.parentNode
122
- if (!row || !row.className.includes('ant-row')) {
123
- console.warn('未找到父级a-row元素')
124
- return []
125
- }
126
-
127
- // 修改这里:只获取直接子元素中的.ant-col-12
128
- const allCols = Array.from(row.children).filter(child =>
129
- child.className.includes('ant-col-12')
130
- )
131
-
132
- // 过滤掉当前a-col,返回其他所有a-col
133
- return allCols.filter(col => col !== currentCol)
134
- } catch (error) {
135
- console.error('获取同级a-col时出错:', error)
136
- return []
137
- }
138
- },
139
- updateLayout (isOpen) {
140
- this.$nextTick(() => {
141
- try {
142
- // 获取所有同级a-col(仅筛选出 .ant-col-12)
143
- const otherCols = this.getSiblingCols()
144
- if (otherCols.length > 0) {
145
- let currentCol = this.$el.parentNode
146
- while (currentCol && !currentCol.className.includes('ant-col')) {
147
- currentCol = currentCol.parentNode
148
- }
149
- if (currentCol) {
150
- // 触发XTab组件重新计算宽度
151
- const triggerResize = () => {
152
- this.$nextTick(() => {
153
- const tabComponent = this.$el.querySelector('.ant-tabs')
154
- if (tabComponent) {
155
- tabComponent.style.width = '100%'
156
- window.dispatchEvent(new Event('resize'))
157
- }
158
- })
159
- }
160
-
161
- if (isOpen) {
162
- // 展开:仅当显式允许时才改变布局百分比;否则恢复默认宽度
163
- if (this.affectLayout) {
164
- const drawerWidth = (this.expandedWidthPercent || 33.3)
165
- currentCol.style.cssText = `
166
- flex: 0 0 ${drawerWidth}% !important;
167
- max-width: ${drawerWidth}% !important;
168
- transition: all 0.3s;`
169
- if (otherCols.length === 1) {
170
- const mainCol = otherCols[0]
171
- const mainWidth = Math.max(0, 100 - drawerWidth)
172
- mainCol.style.cssText = `
173
- flex: 0 0 ${mainWidth}% !important;
174
- max-width: ${mainWidth}% !important;
175
- transition: all 0.3s;`
176
- }
177
- } else {
178
- // 恢复默认(移除我们加的内联样式)
179
- currentCol.style.removeProperty('flex')
180
- currentCol.style.removeProperty('max-width')
181
- if (otherCols.length === 1) {
182
- const mainCol = otherCols[0]
183
- mainCol.style.removeProperty('flex')
184
- mainCol.style.removeProperty('max-width')
185
- }
186
- }
187
- triggerResize()
188
- } else {
189
- // 收缩:为了消除空白,始终把侧栏压到 24px,并让相邻主列占满剩余
190
- currentCol.style.cssText = `
191
- flex: 0 0 24px !important;
192
- max-width: 24px !important;
193
- transition: all 0.3s;`
194
- if (otherCols.length === 1) {
195
- const mainCol = otherCols[0]
196
- mainCol.style.cssText = `
197
- flex: 1 1 auto !important;
198
- max-width: calc(100% - 24px) !important;
199
- transition: all 0.3s;`
200
- }
201
- triggerResize()
202
- }
203
- }
204
- }
205
- } catch (error) {
206
- console.error('布局更新失败:', error)
207
- }
208
- })
209
- }
210
- },
211
- watch: {
212
- queryParamsName: {
213
- immediate: true,
214
- handler (newVal) {
215
- if (newVal?.endsWith('Frame')) {
216
- this.isOpen = true
217
- // 确保布局更新
218
- this.$nextTick(() => {
219
- this.updateLayout(true)
220
- this.updateCardBodyPadding()
221
- })
222
- }
223
- }
224
- }
225
- },
226
- computed: {
227
- isFrameConfig () {
228
- return this.queryParamsName?.endsWith('Frame') || false
229
- }
230
- }
231
- }
232
- </script>
233
-
234
- <style scoped>
235
- .drawer {
236
- position: relative;
237
- height: 88vh;
238
- width: 100%;
239
- background-color: #fff;
240
- border-left: solid rgba(240, 242, 245) 2px;
241
- transition: all 0.3s;
242
- border-radius: 10px;
243
- }
244
-
245
- .drawer-collapsed {
246
- width: 24px;
247
- box-shadow: none;
248
- }
249
- .drawer-toggle {
250
- position: absolute;
251
- top: 50%;
252
- transform: translateY(-50%);
253
- width: 24px;
254
- height: 48px;
255
- cursor: pointer;
256
- background-color: rgba(255, 255, 255, 0) !important;
257
- display: flex;
258
- align-items: center;
259
- justify-content: center;
260
- z-index: 1000;
261
- transition: all 0.3s;
262
- }
263
- /* 打开状态:箭头在抽屉内 */
264
- .drawer:not(.drawer-collapsed) .drawer-toggle {
265
- left: 0;
266
- border-radius: 0;
267
- box-shadow: none;
268
- }
269
- /* 关闭状态:箭头在抽屉内 */
270
- .drawer-collapsed .drawer-toggle {
271
- left: 0;
272
- border-radius: 0;
273
- box-shadow: none;
274
- }
275
- .arrow {
276
- font-size: 20px;
277
- line-height: 1;
278
- color: #94979E;
279
- }
280
- .drawer-content {
281
- height: 100%;
282
- }
283
- </style>
1
+ <template>
2
+ <div
3
+ class="drawer"
4
+ :class="{ 'drawer-collapsed': !isOpen }">
5
+ <div
6
+ v-show="!isFrameConfig"
7
+ class="drawer-toggle"
8
+ :class="{ 'toggle-collapsed': !isOpen }"
9
+ @click="toggleDrawer">
10
+ <div class="arrow">
11
+ {{ isOpen ? '›' : '‹' }}
12
+ </div>
13
+ </div>
14
+ <div class="drawer-content" v-show="isOpen">
15
+ <x-report
16
+ ref="x_report"
17
+ :configName="queryParamsName"
18
+ :server-name="serverName"
19
+ :show-img-in-cell="true"
20
+ :display-only="true"
21
+ :edit-mode="false"
22
+ :show-save-button="false"
23
+ :no-padding="true"
24
+ :dont-format="true">
25
+ </x-report>
26
+ </div>
27
+ </div>
28
+ </template>
29
+
30
+ <script>
31
+
32
+ import XReport from '@vue2-client/base-client/components/common/XReportGrid'
33
+
34
+ export default {
35
+ components: {
36
+ XReport
37
+ },
38
+ name: 'XSidebar',
39
+ props: {
40
+ // 配置参数
41
+ queryParamsName: {
42
+ type: String,
43
+ default: ''
44
+ },
45
+ serverName: {
46
+ type: String,
47
+ default: 'af-his'
48
+ },
49
+ // 是否允许该组件主动调整同级布局(默认不影响其它页面)
50
+ affectLayout: {
51
+ type: Boolean,
52
+ default: false
53
+ },
54
+ // 展开时所占宽度百分比(影响父级 ant-col 的 flex 与 max-width)
55
+ expandedWidthPercent: {
56
+ type: Number,
57
+ default: 33.3
58
+ },
59
+ // 收缩时所占宽度百分比
60
+ collapsedWidthPercent: {
61
+ type: Number,
62
+ default: 2
63
+ }
64
+ },
65
+ data () {
66
+ return {
67
+ isOpen: this.queryParamsName?.endsWith('Frame') || false,
68
+ // 定义主内容区域的最大和最小宽度百分比
69
+ mainWithData: [{ max: 80, min: 50 }]
70
+ }
71
+ },
72
+ mounted () {
73
+ // 在挂载后调整父元素宽度(方法内部已区分是否影响布局)
74
+ this.updateLayout(this.isOpen)
75
+ // 如果抽屉初始状态为打开,设置padding
76
+ if (this.isOpen) {
77
+ this.updateCardBodyPadding()
78
+ }
79
+ },
80
+ methods: {
81
+ toggleDrawer () {
82
+ this.isOpen = !this.isOpen
83
+ this.$emit('on-drawer-change', this.isOpen)
84
+ this.updateLayout(this.isOpen)
85
+ if (this.isOpen) {
86
+ this.$nextTick(() => {
87
+ this.updateCardBodyPadding()
88
+ })
89
+ }
90
+ },
91
+ // 更新card-body的padding
92
+ updateCardBodyPadding () {
93
+ this.$nextTick(() => {
94
+ const cardBody = this.$el.querySelector('.ant-card-body')
95
+ if (cardBody) {
96
+ cardBody.style.padding = '3%'
97
+ } else {
98
+ // 如果找不到元素,可能需要等待XReport完全渲染
99
+ setTimeout(() => {
100
+ const cardBody = this.$el.querySelector('.ant-card-body')
101
+ if (cardBody) {
102
+ cardBody.style.padding = '3%'
103
+ }
104
+ }, 500)
105
+ }
106
+ })
107
+ },
108
+ // 获取同级的其他所有a-col元素
109
+ getSiblingCols () {
110
+ try {
111
+ // 找到当前组件所在的a-col
112
+ let currentCol = this.$el.parentNode
113
+ while (currentCol && !currentCol.className.includes('ant-col')) {
114
+ currentCol = currentCol.parentNode
115
+ }
116
+ if (!currentCol) {
117
+ console.warn('当前组件不在a-col内')
118
+ return []
119
+ }
120
+ // 找到a-col的父元素(a-row)
121
+ const row = currentCol.parentNode
122
+ if (!row || !row.className.includes('ant-row')) {
123
+ console.warn('未找到父级a-row元素')
124
+ return []
125
+ }
126
+
127
+ // 修改这里:只获取直接子元素中的.ant-col-12
128
+ const allCols = Array.from(row.children).filter(child =>
129
+ child.className.includes('ant-col-12')
130
+ )
131
+
132
+ // 过滤掉当前a-col,返回其他所有a-col
133
+ return allCols.filter(col => col !== currentCol)
134
+ } catch (error) {
135
+ console.error('获取同级a-col时出错:', error)
136
+ return []
137
+ }
138
+ },
139
+ updateLayout (isOpen) {
140
+ this.$nextTick(() => {
141
+ try {
142
+ // 获取所有同级a-col(仅筛选出 .ant-col-12)
143
+ const otherCols = this.getSiblingCols()
144
+ if (otherCols.length > 0) {
145
+ let currentCol = this.$el.parentNode
146
+ while (currentCol && !currentCol.className.includes('ant-col')) {
147
+ currentCol = currentCol.parentNode
148
+ }
149
+ if (currentCol) {
150
+ // 触发XTab组件重新计算宽度
151
+ const triggerResize = () => {
152
+ this.$nextTick(() => {
153
+ const tabComponent = this.$el.querySelector('.ant-tabs')
154
+ if (tabComponent) {
155
+ tabComponent.style.width = '100%'
156
+ window.dispatchEvent(new Event('resize'))
157
+ }
158
+ })
159
+ }
160
+
161
+ if (isOpen) {
162
+ // 展开:仅当显式允许时才改变布局百分比;否则恢复默认宽度
163
+ if (this.affectLayout) {
164
+ const drawerWidth = (this.expandedWidthPercent || 33.3)
165
+ currentCol.style.cssText = `
166
+ flex: 0 0 ${drawerWidth}% !important;
167
+ max-width: ${drawerWidth}% !important;
168
+ transition: all 0.3s;`
169
+ if (otherCols.length === 1) {
170
+ const mainCol = otherCols[0]
171
+ const mainWidth = Math.max(0, 100 - drawerWidth)
172
+ mainCol.style.cssText = `
173
+ flex: 0 0 ${mainWidth}% !important;
174
+ max-width: ${mainWidth}% !important;
175
+ transition: all 0.3s;`
176
+ }
177
+ } else {
178
+ // 恢复默认(移除我们加的内联样式)
179
+ currentCol.style.removeProperty('flex')
180
+ currentCol.style.removeProperty('max-width')
181
+ if (otherCols.length === 1) {
182
+ const mainCol = otherCols[0]
183
+ mainCol.style.removeProperty('flex')
184
+ mainCol.style.removeProperty('max-width')
185
+ }
186
+ }
187
+ triggerResize()
188
+ } else {
189
+ // 收缩:为了消除空白,始终把侧栏压到 24px,并让相邻主列占满剩余
190
+ currentCol.style.cssText = `
191
+ flex: 0 0 24px !important;
192
+ max-width: 24px !important;
193
+ transition: all 0.3s;`
194
+ if (otherCols.length === 1) {
195
+ const mainCol = otherCols[0]
196
+ mainCol.style.cssText = `
197
+ flex: 1 1 auto !important;
198
+ max-width: calc(100% - 24px) !important;
199
+ transition: all 0.3s;`
200
+ }
201
+ triggerResize()
202
+ }
203
+ }
204
+ }
205
+ } catch (error) {
206
+ console.error('布局更新失败:', error)
207
+ }
208
+ })
209
+ }
210
+ },
211
+ watch: {
212
+ queryParamsName: {
213
+ immediate: true,
214
+ handler (newVal) {
215
+ if (newVal?.endsWith('Frame')) {
216
+ this.isOpen = true
217
+ // 确保布局更新
218
+ this.$nextTick(() => {
219
+ this.updateLayout(true)
220
+ this.updateCardBodyPadding()
221
+ })
222
+ }
223
+ }
224
+ }
225
+ },
226
+ computed: {
227
+ isFrameConfig () {
228
+ return this.queryParamsName?.endsWith('Frame') || false
229
+ }
230
+ }
231
+ }
232
+ </script>
233
+
234
+ <style scoped>
235
+ .drawer {
236
+ position: relative;
237
+ height: 88vh;
238
+ width: 100%;
239
+ background-color: #fff;
240
+ border-left: solid rgba(240, 242, 245) 2px;
241
+ transition: all 0.3s;
242
+ border-radius: 10px;
243
+ }
244
+
245
+ .drawer-collapsed {
246
+ width: 24px;
247
+ box-shadow: none;
248
+ }
249
+ .drawer-toggle {
250
+ position: absolute;
251
+ top: 50%;
252
+ transform: translateY(-50%);
253
+ width: 24px;
254
+ height: 48px;
255
+ cursor: pointer;
256
+ background-color: rgba(255, 255, 255, 0) !important;
257
+ display: flex;
258
+ align-items: center;
259
+ justify-content: center;
260
+ z-index: 1000;
261
+ transition: all 0.3s;
262
+ }
263
+ /* 打开状态:箭头在抽屉内 */
264
+ .drawer:not(.drawer-collapsed) .drawer-toggle {
265
+ left: 0;
266
+ border-radius: 0;
267
+ box-shadow: none;
268
+ }
269
+ /* 关闭状态:箭头在抽屉内 */
270
+ .drawer-collapsed .drawer-toggle {
271
+ left: 0;
272
+ border-radius: 0;
273
+ box-shadow: none;
274
+ }
275
+ .arrow {
276
+ font-size: 20px;
277
+ line-height: 1;
278
+ color: #94979E;
279
+ }
280
+ .drawer-content {
281
+ height: 100%;
282
+ }
283
+ </style>