vue2-client 1.14.15 → 1.14.17

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.14.15",
3
+ "version": "1.14.17",
4
4
  "private": false,
5
5
  "scripts": {
6
6
  "serve": "SET NODE_OPTIONS=--openssl-legacy-provider && vue-cli-service serve --no-eslint",
@@ -82,6 +82,7 @@
82
82
  @editButtonStateDataClick="editButtonStateDataClick"
83
83
  @importExcelOk="importExcelOk"
84
84
  @rowClick="handleRowClick"
85
+ @beforeDataChange="beforeDataChange"
85
86
  @expand="onExpand">
86
87
  <template slot="leftButton" slot-scope="{selectedRowKeys, selectedRows}">
87
88
  <slot name="leftButton" :selectedRowKeys="selectedRowKeys" :selectedRows="selectedRows"></slot>
@@ -824,6 +825,9 @@ export default {
824
825
  handleRowClick (record) {
825
826
  this.$emit('rowClick', record)
826
827
  },
828
+ beforeDataChange (record) {
829
+ this.$emit('beforeDataChange', record)
830
+ },
827
831
  onExpand (expanded, record) {
828
832
  this.$emit('expand', expanded, record)
829
833
  }
@@ -243,10 +243,44 @@ export default {
243
243
  isWidget: this.widget,
244
244
  currUser: this.currUser,
245
245
  getGlobalData: this.getGlobalData,
246
- setGlobalData: this.setGlobalData
246
+ setGlobalData: this.setGlobalData,
247
+ findComponentByName: this.findComponentByName
247
248
  }
248
249
  },
249
250
  methods: {
251
+ findComponentByName (instance, componentName, maxDepth, findType) {
252
+ // 基础判断:如果实例不存在或者已经超过最大深度,返回null
253
+ if (!instance || maxDepth <= 0) {
254
+ return null
255
+ }
256
+
257
+ // 检查当前实例是否有目标组件
258
+ try {
259
+ if (instance.getComponentByName && instance.getComponentByName(componentName)) {
260
+ return instance.getComponentByName(componentName)
261
+ }
262
+ } catch (e) {
263
+ console.warn('查找组件时发生错误:', e)
264
+ }
265
+
266
+ // 递归查找子组件
267
+ if (findType === 'parent') {
268
+ // 向上查找父组件
269
+ if (instance.$parent) {
270
+ return this.findComponentByName(instance.$parent, componentName, maxDepth - 1, findType)
271
+ }
272
+ } else {
273
+ if (instance.$children && instance.$children.length) {
274
+ for (const child of instance.$children) {
275
+ const result = this.findComponentByName(child, componentName, maxDepth - 1, findType)
276
+ if (result) {
277
+ return result
278
+ }
279
+ }
280
+ }
281
+ }
282
+ return null
283
+ },
250
284
  listClick (data) {
251
285
  this.$emit('listClick', data)
252
286
  },
@@ -34,6 +34,7 @@
34
34
  :serverName="cell.serviceName"
35
35
  v-on="getEventHandlers(cell)"
36
36
  @hook:mounted="(h)=>onComponentMounted(h,cell,cellIndex)"
37
+ @beforeDataChange="beforeDataChange"
37
38
  @rowClick="handleRowClick"
38
39
  @onExpand="onExpand"
39
40
  :queryParamsName="cell.slotConfig"
@@ -71,6 +72,7 @@
71
72
  :serverName="cell.serviceName"
72
73
  v-on="getEventHandlers(cell)"
73
74
  @hook:mounted="(h)=>onComponentMounted(h,cell,cellIndex)"
75
+ @beforeDataChange="beforeDataChange"
74
76
  @rowClick="handleRowClick"
75
77
  @onExpand="onExpand"
76
78
  :queryParamsName="cell.slotConfig"
@@ -210,7 +212,7 @@ export default {
210
212
  }
211
213
  }
212
214
  },
213
- inject: ['openDialog', 'emitEvent', 'registerComponent', 'setColSpanByName', 'setGlobalData', 'getGlobalData', 'getComponentByName', 'runLogic', 'getMixinData', 'getSelectedId', 'isInAModal', 'getConfigByName', 'getSelectedData', 'getOutEnv', 'currUser', 'isWidget'],
215
+ inject: ['openDialog', 'emitEvent', 'registerComponent', 'setColSpanByName', 'setGlobalData', 'getGlobalData', 'getComponentByName', 'runLogic', 'getMixinData', 'getSelectedId', 'isInAModal', 'getConfigByName', 'getSelectedData', 'getOutEnv', 'currUser', 'isWidget', 'findComponentByName'],
214
216
  methods: {
215
217
  getWindow,
216
218
  isMicroAppEnv,
@@ -220,6 +222,9 @@ export default {
220
222
  handleRowClick (record) {
221
223
  this.$emit('rowClick', record)
222
224
  },
225
+ beforeDataChange (record) {
226
+ this.$emit('beforeDataChange', record)
227
+ },
223
228
  onExpand (expanded, record) {
224
229
  this.$emit('expand', expanded, record)
225
230
  },
@@ -152,6 +152,7 @@
152
152
  <x-table-wrapper
153
153
  ref="table"
154
154
  @rowClick="handleRowClick"
155
+ @beforeDataChange="beforeDataChange"
155
156
  @expand="onExpand">
156
157
  <template slot="expandedRowRender">
157
158
  <!-- 列扩展栅格 -->
@@ -257,6 +258,7 @@
257
258
  <x-table-wrapper
258
259
  ref="selectedDataTable"
259
260
  :load-selected-data="true"
261
+ @beforeDataChange="beforeDataChange"
260
262
  @rowClick="handleRowClick">
261
263
  </x-table-wrapper>
262
264
  </a-modal>
@@ -1332,6 +1334,9 @@ export default {
1332
1334
  handleRowClick (record) {
1333
1335
  this.$emit('rowClick', record)
1334
1336
  },
1337
+ beforeDataChange (record) {
1338
+ this.$emit('beforeDataChange', record)
1339
+ },
1335
1340
  onExpand (expanded, record) {
1336
1341
  this.$emit('expand', expanded, record)
1337
1342
  }
@@ -18,6 +18,7 @@
18
18
  :setScrollYHeight="tableContext.setScrollYHeight"
19
19
  :selectRowMode="tableContext.selectRowMode"
20
20
  :size="tableContext.tableSize"
21
+ @beforeDataChange="beforeDataChange"
21
22
  @expand="onExpand"
22
23
  @rowClick="handleRowClick"
23
24
  >
@@ -152,6 +153,7 @@
152
153
  :selectRowMode="tableContext.selectRowMode"
153
154
  :size="tableContext.tableSize"
154
155
  @rowClick="handleRowClick"
156
+ @beforeDataChange="beforeDataChange"
155
157
  >
156
158
  <template
157
159
  v-for="(item, c_index) in tableContext.tableColumns"
@@ -297,6 +299,9 @@ export default {
297
299
  handleRowClick (record) {
298
300
  this.$emit('rowClick', record)
299
301
  },
302
+ beforeDataChange (record) {
303
+ this.$emit('beforeDataChange', record)
304
+ },
300
305
  onExpand (expanded, record) {
301
306
  this.$emit('expand', expanded, record)
302
307
  },
@@ -38,6 +38,10 @@ export default {
38
38
  queryParamsName: {
39
39
  type: Object,
40
40
  default: null
41
+ },
42
+ fixedQueryForm: {
43
+ type: Object,
44
+ default: { condition: '1=1' }
41
45
  }
42
46
  },
43
47
  inject: ['getComponentByName'],
@@ -51,17 +55,17 @@ export default {
51
55
  }
52
56
  },
53
57
  created () {
54
- this.getData(this.queryParamsName)
58
+ this.getData(this.queryParamsName, this.fixedQueryForm)
55
59
  },
56
60
  methods: {
57
- async getData (config) {
61
+ async getData (config, param) {
58
62
  const that = this
59
63
  getConfigByName(config, 'af-his', res => {
60
64
  that.button = res.button
61
65
  that.icon = res.icon
62
66
  that.buttonNames = res.buttonNames || []
63
67
  that.buttonMode = res.buttonMode || false
64
- runLogic(res.data, {}, 'af-his').then(ress => {
68
+ runLogic(res.data, param, 'af-his').then(ress => {
65
69
  that.data = ress
66
70
  })
67
71
  })
@@ -69,8 +73,8 @@ export default {
69
73
  handleClick (index) {
70
74
  this.$emit('listClick', this.data[index])
71
75
  },
72
- refreshList () {
73
- this.getData(this.queryParamsName)
76
+ refreshList (param) {
77
+ this.getData(this.queryParamsName, param)
74
78
  },
75
79
  click (index, buttonIndex) {
76
80
  this.$emit('click', { data: this.data[index], name: this.buttonNames[buttonIndex] })
@@ -85,6 +89,11 @@ export default {
85
89
  this.data = res.data
86
90
  })
87
91
  }
92
+ },
93
+ watch: {
94
+ 'fixedQueryForm' (val) {
95
+ this.refreshList(val)
96
+ }
88
97
  }
89
98
  }
90
99
  </script>
@@ -187,6 +187,18 @@ export default {
187
187
  (this.sortOrder && { sortOrder: this.sortOrder }) || {},
188
188
  { ...filters }
189
189
  )
190
+
191
+ // 在加载新数据前,将当前数据传递给父组件
192
+ if (this.localDataSource && this.localDataSource.length > 0) {
193
+ // 变化前的数据: oldData, 分页信息: pagination, 过滤条件: filters, 排序信息: sorter
194
+ this.$emit('beforeDataChange', {
195
+ oldData: this.localDataSource,
196
+ pagination: this.localPagination,
197
+ filters: filters,
198
+ sorter: sorter
199
+ })
200
+ }
201
+
190
202
  const result = this.data(parameter)
191
203
  // 对接自己的通用数据接口需要修改下方代码中的 r.pageNo, r.totalCount, r.data
192
204
  // eslint-disable-next-line