vue2-client 1.18.11 → 1.18.12

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": "vue2-client",
3
- "version": "1.18.11",
3
+ "version": "1.18.12",
4
4
  "private": false,
5
5
  "scripts": {
6
6
  "serve": "SET NODE_OPTIONS=--openssl-legacy-provider && vue-cli-service serve --no-eslint",
@@ -9,9 +9,9 @@
9
9
  layout="inline">
10
10
  <a-row :gutter="24" type="flex">
11
11
  <x-form-item
12
- v-for="(item, index) in visibleItems"
12
+ v-for="item in visibleItems"
13
13
  :showLabel="!simpleMode"
14
- :key="`${queryParamsName}-item-${index}`"
14
+ :key="`${queryParamsName}-item-${item._originalIndex}`"
15
15
  :attr="item.formItem"
16
16
  :form="form"
17
17
  :service-name="serviceName"
@@ -23,9 +23,9 @@
23
23
  />
24
24
  <x-form-item
25
25
  v-show="advanced"
26
- v-for="(item, index) in hiddenItems"
26
+ v-for="item in hiddenItems"
27
27
  :showLabel="!simpleMode"
28
- :key="`advanced-${queryParamsName}-item-${index}`"
28
+ :key="`${queryParamsName}-item-${item._originalIndex}`"
29
29
  :attr="item.formItem"
30
30
  :form="form"
31
31
  :service-name="serviceName"
@@ -42,10 +42,10 @@
42
42
  <template v-if="hiddenItems.length > 0">
43
43
  <a @click="toggleAdvanced">
44
44
  <span v-if="!advanced" style="display: inline-flex; align-items: center;">
45
- <a-icon type="eye" :style="iconStyle"></a-icon>&nbsp;更多条件
45
+ <a-icon type="eye" :style="iconStyle" class="form-expand-icon"></a-icon>&nbsp;更多条件
46
46
  </span>
47
47
  <span v-else style="display: inline-flex; align-items: center;">
48
- <a-icon type="eye-invisible" :style="iconStyle"></a-icon>&nbsp;收起更多
48
+ <a-icon type="eye-invisible" :style="iconStyle" class="form-expand-icon rotated"></a-icon>&nbsp;收起更多
49
49
  </span>
50
50
  </a>
51
51
  <a-divider type="vertical"/>
@@ -159,11 +159,17 @@ export default {
159
159
  },
160
160
  // 显示的表单项
161
161
  visibleItems: function () {
162
- return this.allFormItems.slice(0, this.visibleItemCount)
162
+ return this.allFormItems.slice(0, this.visibleItemCount).map((item, index) => ({
163
+ ...item,
164
+ _originalIndex: index
165
+ }))
163
166
  },
164
167
  // 隐藏的表单项(需要点击展开才显示)
165
168
  hiddenItems: function () {
166
- return this.allFormItems.slice(this.visibleItemCount)
169
+ return this.allFormItems.slice(this.visibleItemCount).map((item, index) => ({
170
+ ...item,
171
+ _originalIndex: this.visibleItemCount + index
172
+ }))
167
173
  },
168
174
  },
169
175
  provide () {
@@ -176,10 +182,63 @@ export default {
176
182
  }
177
183
  },
178
184
  methods: {
185
+ // 根据flex值计算可见表单项数量
186
+ updateVisibleItemCount (flex) {
187
+ // flex值与显示数量的映射关系
188
+ const flexToCountMap = {
189
+ 24: 2, // 小屏:1个/行,显示2个(2行)
190
+ 12: 3, // 中屏:2个/行,显示3个(2行-1个)
191
+ 8: 5, // 大屏:3个/行,显示5个(2行-1个)
192
+ 6: 7, // 超大屏:4个/行,显示7个(2行-1个)
193
+ 4: 11 // 超超大屏:6个/行,显示11个(2行-1个)
194
+ }
195
+
196
+ const newCount = flexToCountMap[flex] || 7
197
+ // 只有当数量真正变化时才更新,避免不必要的重新渲染
198
+ if (this.visibleItemCount !== newCount) {
199
+ this.visibleItemCount = newCount
200
+ }
201
+ },
202
+
203
+ // 递归查找第一个XFormCol实例
204
+ findFirstXFormCol (components = this.$children) {
205
+ for (const component of components) {
206
+ if (component.$options.name === 'XFormCol') {
207
+ return component
208
+ }
209
+ // 递归查找子组件
210
+ const found = this.findFirstXFormCol(component.$children)
211
+ if (found) return found
212
+ }
213
+ return null
214
+ },
215
+
216
+ // 设置flex监听
217
+ setupFlexWatcher () {
218
+ this.$nextTick(() => {
219
+ const firstXFormCol = this.findFirstXFormCol()
220
+ if (firstXFormCol) {
221
+ // 立即执行一次设置初始值
222
+ this.updateVisibleItemCount(firstXFormCol.computedFlex)
223
+
224
+ // 设置监听
225
+ this._flexWatcher = this.$watch(
226
+ () => firstXFormCol.computedFlex,
227
+ (newFlex) => {
228
+ this.updateVisibleItemCount(newFlex)
229
+ }
230
+ )
231
+ } else {
232
+ // 重试机制,直到找到XFormCol
233
+ setTimeout(() => this.setupFlexWatcher(), 100)
234
+ }
235
+ })
236
+ },
237
+
179
238
  init (params) {
180
239
  const {
181
240
  formItems, serviceName, getDataParams = {}, env = 'prod', simpleMode = false, funcData = {},
182
- queryParamsName = 'localConfig', visibleItemCount = 7, defaultQueryForm = {}
241
+ queryParamsName = 'localConfig', defaultQueryForm = {}
183
242
  } = params
184
243
  this.mountedCount = 0
185
244
  this.queryParamsName = queryParamsName
@@ -188,7 +247,7 @@ export default {
188
247
  this.serviceName = serviceName
189
248
  this.env = env
190
249
  this.simpleMode = simpleMode
191
- this.visibleItemCount = visibleItemCount
250
+ // visibleItemCount 现在由 flex 监听动态控制,不再需要手动设置
192
251
  const formData = {}
193
252
  for (let i = 0; i < this.realJsonData.length; i++) {
194
253
  const item = this.realJsonData[i]
@@ -412,7 +471,17 @@ export default {
412
471
  setForm (obj) {
413
472
  this.form = Object.assign(this.form, obj)
414
473
  },
415
- }
474
+ },
475
+ mounted () {
476
+ console.log('XForm mounted, setting up flex watcher')
477
+ this.setupFlexWatcher()
478
+ },
479
+ beforeDestroy () {
480
+ // 清理watcher
481
+ if (this._flexWatcher) {
482
+ this._flexWatcher()
483
+ }
484
+ },
416
485
  }
417
486
  </script>
418
487
  <style lang="less" scoped>
@@ -965,7 +965,10 @@ export default {
965
965
  * 更多条件是否展示
966
966
  */
967
967
  toggleAdvanced () {
968
- this.$refs.xTable.setScrollYHeight({})
968
+ // 只有在非弹出模式下才需要调整表格滚动高度
969
+ if (this.tableShowMode !== 'popup') {
970
+ this.$refs.xTable.setScrollYHeight({})
971
+ }
969
972
  },
970
973
  /**
971
974
  * 查询表单部分显示/隐藏切换
@@ -973,7 +976,10 @@ export default {
973
976
  toggleIsFormShow () {
974
977
  this.toggleIsFormIcon = this.toggleIsFormIcon === 'vertical-align-top' ? 'vertical-align-bottom' : 'vertical-align-top'
975
978
  this.$refs.xForm.toggleVisible()
976
- this.$refs.xTable.setScrollYHeight({})
979
+ // 只有在非弹出模式下才需要调整表格滚动高度
980
+ if (this.tableShowMode !== 'popup') {
981
+ this.$refs.xTable.setScrollYHeight({})
982
+ }
977
983
  },
978
984
  /**
979
985
  * 选择列事件
@@ -16,11 +16,6 @@
16
16
  serviceName="af-revenue"
17
17
  ref="xFormTable"
18
18
  >
19
- <template #formBtnExpand>
20
- <a-button @click="defaultF">默认</a-button>
21
- <a-button @click="middleF">中等</a-button>
22
- <a-button @click="smallF">小</a-button>
23
- </template>
24
19
  </x-form-table>
25
20
  <div style="height: 100px;width: 100%; background-color: #F7FAFC;">
26
21
  </div>
@@ -185,9 +185,6 @@ export default {
185
185
  this.needTotalList = this.initTotalList(this.columns)
186
186
  // this.loadData()
187
187
  },
188
- beforeDestroy () {
189
- this.clearClickTimer()
190
- },
191
188
  methods: {
192
189
  /**
193
190
  * 表格重新加载方法