vue2-client 1.18.10 → 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.10",
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>
@@ -1320,7 +1320,7 @@ export default {
1320
1320
  } else {
1321
1321
  this.attr.flex = {
1322
1322
  xs: 24,
1323
- sm: 24,
1323
+ sm: 12,
1324
1324
  md: 8,
1325
1325
  lg: 6,
1326
1326
  xl: 6,
@@ -19,12 +19,12 @@ const BREAKPOINTS = {
19
19
  }
20
20
 
21
21
  const defaultFlex = {
22
- xs: 24, // 超小屏(<576px):1个/行,保证手机端可读性
23
- sm: 12, // 小屏(576px-768px):2个/行,满足你的需求
22
+ xs: 24, // 超小屏(<576px):1个/行
23
+ sm: 12, // 小屏(576px-768px):2个/行
24
24
  md: 8, // 中屏(768px-992px):3个/行
25
- lg: 8, // 大屏(992px-1200px):3个/行
25
+ lg: 6, // 大屏(992px-1200px):4个/行
26
26
  xl: 6, // 超大屏(1200px-1600px):4个/行
27
- xxl: 6, // 超超大屏(>1600px):4个/行
27
+ xxl: 4, // 超超大屏(>1600px):4个/行
28
28
  }
29
29
 
30
30
  function debounce (fn, delay) {
@@ -42,14 +42,7 @@ export default {
42
42
  props: {
43
43
  flex: {
44
44
  type: Object,
45
- default: () => ({
46
- xs: 24,
47
- sm: 24,
48
- md: 8,
49
- lg: 6,
50
- xl: 6,
51
- xxl: 6,
52
- }),
45
+ default: () => defaultFlex,
53
46
  },
54
47
  occupyCol: {
55
48
  type: Number,
@@ -802,14 +802,6 @@ export default {
802
802
  this.tableModalVisible = false
803
803
  },
804
804
 
805
- /**
806
- * 暴露给外部的关闭弹框方法
807
- * 父组件可以通过 this.$refs.xformtable.closeModal() 调用
808
- */
809
- closeModal () {
810
- this.closeTableModal()
811
- },
812
-
813
805
  active (props) {
814
806
  let num = false
815
807
  for (const key in props) {
@@ -973,7 +965,10 @@ export default {
973
965
  * 更多条件是否展示
974
966
  */
975
967
  toggleAdvanced () {
976
- this.$refs.xTable.setScrollYHeight({})
968
+ // 只有在非弹出模式下才需要调整表格滚动高度
969
+ if (this.tableShowMode !== 'popup') {
970
+ this.$refs.xTable.setScrollYHeight({})
971
+ }
977
972
  },
978
973
  /**
979
974
  * 查询表单部分显示/隐藏切换
@@ -981,7 +976,10 @@ export default {
981
976
  toggleIsFormShow () {
982
977
  this.toggleIsFormIcon = this.toggleIsFormIcon === 'vertical-align-top' ? 'vertical-align-bottom' : 'vertical-align-top'
983
978
  this.$refs.xForm.toggleVisible()
984
- this.$refs.xTable.setScrollYHeight({})
979
+ // 只有在非弹出模式下才需要调整表格滚动高度
980
+ if (this.tableShowMode !== 'popup') {
981
+ this.$refs.xTable.setScrollYHeight({})
982
+ }
985
983
  },
986
984
  /**
987
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
  * 表格重新加载方法