vue2-client 1.8.407 → 1.8.409

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.8.407",
3
+ "version": "1.8.409",
4
4
  "private": false,
5
5
  "scripts": {
6
6
  "serve": "SET NODE_OPTIONS=--openssl-legacy-provider && vue-cli-service serve --no-eslint",
@@ -660,6 +660,11 @@ export default {
660
660
  // 执行一次
661
661
  debounce(this.showFormItemFunc, 100)()
662
662
  }
663
+ if (this.attr.showQueryFormItemFunc) {
664
+ this.debouncedShowQueryFormItemFunc = debounce(this.showQueryFormItemFunc, 100)
665
+ // 执行一次
666
+ debounce(this.showQueryFormItemFunc, 100)()
667
+ }
663
668
  // 人员联动框增加监听
664
669
  if (this?.attr?.keyName?.toString()?.startsWith('search@根据表单项[') && this?.attr?.keyName?.toString().endsWith(']联动人员')) {
665
670
  this.debouncedUserLinkFunc = debounce(() => this.updateResOptions('人员'), 200)
@@ -695,6 +700,10 @@ export default {
695
700
  if (this.attr.showFormItemFunc) {
696
701
  this.debouncedShowFormItemFunc()
697
702
  }
703
+ // 如果有自定义是否展示查询表单项函数
704
+ if (this.attr.showQueryFormItemFunc) {
705
+ this.debouncedShowQueryFormItemFunc()
706
+ }
698
707
  // 地址搜索框赋值
699
708
  if (this.attr.type === 'addressSearch') {
700
709
  this.$refs.addressSearchCombobox.addressInput = this.form[this.attr.model]
@@ -835,6 +844,13 @@ export default {
835
844
  this.show = true
836
845
  }
837
846
  },
847
+ async showQueryFormItemFunc () {
848
+ if (this.attr.showQueryFormItemFunc) {
849
+ this.show = executeStrFunction(this.attr.showQueryFormItemFunc, [this.form, this.setForm, this.attr, util, this.mode])
850
+ } else {
851
+ this.show = true
852
+ }
853
+ },
838
854
  init () {
839
855
  if (this.mode === '新增/修改' && !this.attr.flex) {
840
856
  if (['horizontal', 'vertical'].includes(this.layout)) {
@@ -80,7 +80,7 @@
80
80
  <script>
81
81
  // 转PDF用
82
82
  import HtmlToPdf from '@vue2-client/utils/htmlToPDF'
83
- import { getConfigByName } from '@vue2-client/services/api/common'
83
+ import { getConfigByName, runLogic } from '@vue2-client/services/api/common'
84
84
  import XReportDesign from './XReportDesign.vue'
85
85
  import { printElement } from './print'
86
86
  // import XAddReport from '@vue2-client/base-client/components/common/XAddReport'
@@ -213,7 +213,7 @@ export default {
213
213
  // 保存最原始的数据,用于判断哪些数据被更改了
214
214
  dataCache: undefined,
215
215
  // 判断哪些数据被更改了,存储对应的key
216
- diff: []
216
+ diff: [],
217
217
  }
218
218
  },
219
219
  beforeDestroy () {
@@ -243,10 +243,25 @@ export default {
243
243
  },
244
244
  provide () {
245
245
  return {
246
- openDialog: this.openDialog
246
+ runLogic: runLogic,
247
+ openDialog: this.openDialog,
248
+ registerComponent: this.registerComponent,
249
+ getComponentByName: this.getComponentByName
247
250
  }
248
251
  },
249
252
  methods: {
253
+ // 把组件注册到refs中,方便调用
254
+ registerComponent (componentName, component) {
255
+ console.log('内部注册', this.$options.name, componentName)
256
+ this.$refs[componentName] = component
257
+ console.log('内部注册完成', this.$refs)
258
+ },
259
+ // 根据名字从注册到组件中获取组件
260
+ getComponentByName (componentName) {
261
+ console.log('内部取组件', this.$options.name, componentName)
262
+ console.log('内部组件内容', this.$refs)
263
+ return this.$refs[componentName]
264
+ },
250
265
  // 打开弹出框
251
266
  openDialog (configName, selectedId) {
252
267
  console.log('openDialog', configName, selectedId)
@@ -315,6 +330,10 @@ export default {
315
330
  console.log('')
316
331
  this.$emit('selectRow', selectedRowKeys, selectedRows)
317
332
  },
333
+ // 注册组件到$refs中
334
+ registerComponentToRefs (componentName, component) {
335
+ this.$refs[componentName] = component
336
+ },
318
337
 
319
338
  // 正常的保存方法,当前修改内容会直接全部导出到外部
320
339
  saveConfig () {
@@ -16,9 +16,8 @@
16
16
  <component
17
17
  :is="getComponentName(cell.slotConfig, cell.serviceName, cell.slotType)"
18
18
  :key="cellIndex"
19
+ :ref="`dynamicComponent_${ cell.slotRef || cellIndex}`"
19
20
  :serviceName="cell.serviceName"
20
- @selectRow="selectRow"
21
- :ref="cell.slotRef || cell.slotType + cellIndex"
22
21
  v-on="getEventHandlers(cell)"
23
22
  :queryParamsName="cell.slotConfig"/>
24
23
  </template>
@@ -477,7 +476,7 @@ export default {
477
476
  // tableConfig: {}
478
477
  }
479
478
  },
480
- inject: ['openDialog'],
479
+ inject: ['openDialog', 'registerComponent', 'getComponentByName', 'runLogic'],
481
480
  methods: {
482
481
  getEventHandlers (cell) {
483
482
  const handlers = {}
@@ -785,12 +784,42 @@ export default {
785
784
  console.log('1123123123')
786
785
  this.$emit('selectRow', selectedRowKeys, selectedRows)
787
786
  },
787
+ // 把用户定义的组件,传递到整个杉格中,方便调用
788
+ passComponentNamesToAncestor (refs) {
789
+ console.log('组件的keys', Object.entries(refs), refs)
790
+ // 遍历所有 refs
791
+ Object.entries(refs).forEach(([refKey, refValue]) => {
792
+ // 检查 ref 是否以 dynamicComponent_ 开头
793
+ if (refKey.startsWith('dynamicComponent_')) {
794
+ console.log('组件名存在')
795
+ const componentRef = refValue[0]
796
+ if (componentRef) {
797
+ // 去掉前缀并获取组件名字
798
+ const index = refKey.replace('dynamicComponent_', '') // 去掉前缀
799
+ console.log('注册组件', index)
800
+ // 传递给祖先组件
801
+ this.registerComponent(index, componentRef)
802
+ }
803
+ }
804
+ })
805
+ }
788
806
  },
789
807
  beforeMount () {
790
808
  if (this.useOssForImg) {
791
809
  this.uploadParams.resUploadMode = 'oss'
792
810
  }
793
- }
811
+ },
812
+ mounted () {
813
+ this.$nextTick(() => {
814
+ // 使用 setTimeout 延迟访问 $refs
815
+ this.$nextTick(() => {
816
+ console.log('组件加载了', this.$refs)
817
+ console.log('组件加载了1', this.$refs.dynamicComponent_a0)
818
+ console.log('组件加载了2', Object.entries(this.$refs))
819
+ this.passComponentNamesToAncestor(this.$refs)
820
+ })
821
+ })
822
+ },
794
823
  }
795
824
 
796
825
  </script>
@@ -50,6 +50,8 @@
50
50
  :item-size="40"
51
51
  :auto-expand-parent="true"
52
52
  @check-change="handleCheckChange"
53
+ :default-expanded-keys="expandedKeys"
54
+ @node-expand="nodeExpand"
53
55
  @node-click="handleNodeClick"
54
56
  :filter-node-method="filterNode"
55
57
  :props="props"
@@ -199,6 +201,13 @@ export default {
199
201
  }
200
202
  },
201
203
  methods: {
204
+ nodeExpand (node) {
205
+ if (this.expandedKeys.includes(node[this.replaceFields.key])) {
206
+ this.expandedKeys = this.expandedKeys.filter(item => item !== node[this.replaceFields.key])
207
+ } else {
208
+ this.expandedKeys.push(node[this.replaceFields.key])
209
+ }
210
+ },
202
211
  highlightKeyword (label, keyword) {
203
212
  const maxLen = this.config.deepNodeMaxWidth
204
213
 
@@ -241,11 +250,6 @@ export default {
241
250
  },
242
251
  nodeItemClick (e) {
243
252
  this.selectedNode = e
244
- if (this.expandedKeys.includes(e.eventKey)) {
245
- this.expandedKeys = this.expandedKeys.filter(item => item !== e.eventKey)
246
- } else {
247
- this.expandedKeys.push(e.eventKey)
248
- }
249
253
  },
250
254
  handleNodeClick (node) {
251
255
  this.nodeItemClick(node)