af-mobile-client-vue3 1.2.52 → 1.2.54

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,7 +1,7 @@
1
1
  {
2
2
  "name": "af-mobile-client-vue3",
3
3
  "type": "module",
4
- "version": "1.2.52",
4
+ "version": "1.2.54",
5
5
  "packageManager": "pnpm@10.12.3",
6
6
  "description": "Vue + Vite component lib",
7
7
  "engines": {
@@ -47,7 +47,6 @@ const renderableGroupItems = computed(() => {
47
47
 
48
48
  // 组件初始化函数
49
49
  function init(params: Form) {
50
- console.log('初始化数据------', { ...params })
51
50
  initStatus.value = true
52
51
  propsData.value = {
53
52
  configName: props.configName,
@@ -56,7 +55,6 @@ function init(params: Form) {
56
55
  mode: props.mode,
57
56
  ...params,
58
57
  }
59
- console.log('数据整合----', propsData.value)
60
58
  formData.value = propsData.value.groupFormData
61
59
  getConfigByName(propsData.value.configName, (result) => {
62
60
  if (result?.groups) {
@@ -72,12 +70,10 @@ function init(params: Form) {
72
70
  submitSimple.value = result?.showSubmitBtn
73
71
  groupItems.value = [{ ...result }]
74
72
  }
75
- console.log('即将加载完成的数据--:', formData.value)
76
73
  isInit.value = true
77
74
  }, propsData.value.serviceName)
78
75
  }
79
76
  watch(() => props.groupFormData, (_val) => {
80
- console.log('监听器-------', props.groupFormData)
81
77
  formData.value = { ...formData.value, ...props.groupFormData }
82
78
  })
83
79
  onBeforeMount(() => {
@@ -339,7 +339,6 @@ watch(
339
339
  watch(
340
340
  () => modelData.value,
341
341
  (newVal, oldVal) => {
342
- console.log('变更函数新旧值-----', newVal, oldVal)
343
342
  // 避免初始化时的调用
344
343
  if (newVal !== oldVal) {
345
344
  dataChangeFunc()
@@ -348,6 +347,19 @@ watch(
348
347
  { deep: true },
349
348
  )
350
349
 
350
+ // 监听 option.value 的变化
351
+ watch(
352
+ () => option.value,
353
+ (newOption) => {
354
+ if (attr.type === 'treeSelect' && newOption && newOption.length > 0) {
355
+ // 你可以在这里调用 findOptionInTree 函数来查找默认值对应的 label
356
+ const result = findOptionInTree(option.value, modelData.value)
357
+ if (attr.type === 'treeSelect' && result)
358
+ treeValue.value = result.label
359
+ }
360
+ },
361
+ )
362
+
351
363
  function updateFile(files, _index) {
352
364
  // 处理文件数据
353
365
  // 更新本地值
@@ -767,13 +779,36 @@ function cleanEmptyChildren(options, fieldNames = { text: 'label', value: 'value
767
779
  function onTreeSelectFinish({ selectedOptions }) {
768
780
  const index = selectedOptions.length - 1
769
781
  treeValue.value = selectedOptions[index].label
770
- modelData.value = [selectedOptions[index].value]
782
+ if (mode === '查询') {
783
+ modelData.value = [selectedOptions[index].value]
784
+ }
785
+ else {
786
+ modelData.value = selectedOptions[index].value
787
+ }
771
788
  showTreeSelect.value = false
772
789
  }
773
790
 
774
791
  function emitFunc(func, data) {
775
792
  emits('xFormItemEmitFunc', func, data, data?.model ? form[data.model] : form)
776
793
  }
794
+
795
+ function findOptionInTree(options, value) {
796
+ // 在当前层级查找
797
+ const foundItem = options.find(item => item[columnsField.value] === value)
798
+ if (foundItem) {
799
+ return foundItem
800
+ }
801
+ // 递归查找子级
802
+ for (const item of options) {
803
+ if (item.children?.length) {
804
+ const foundInChildren = findOptionInTree(item.children, value)
805
+ if (foundInChildren)
806
+ return foundInChildren
807
+ }
808
+ }
809
+
810
+ return null
811
+ }
777
812
  </script>
778
813
 
779
814
  <template>
@@ -60,17 +60,19 @@ function submit(res) {
60
60
  history.back()
61
61
  })
62
62
  }
63
+ const isInit = ref(false)
63
64
  function init() {
64
65
  if (model.value === '编辑') {
65
66
  runLogic('getFileDetailForEdit', { f_userinfo_id: userinfoid.value }, 'af-revenue').then((res) => {
66
- if (res.t_userfiles.f_gasbrand_id) {
67
- res.t_userfiles.f_gasbrand_id = [res.t_userfiles.f_gasbrand_id]
68
- }
69
- if (res.t_userfiles.f_price_id) {
70
- res.t_userfiles.f_price_id = [res.t_userfiles.f_price_id]
67
+ if (res.t_userfiles.f_gasmodel_id) {
68
+ res.t_userfiles.f_gasmodel_id = 76
71
69
  }
70
+ // if (res.t_userfiles.f_price_id) {
71
+ // res.t_userfiles.f_price_id = [res.t_userfiles.f_price_id]
72
+ // }
72
73
  console.log('1111111----,', res)
73
74
  groupFormData.value = res
75
+ isInit.value = true
74
76
  })
75
77
  }
76
78
  }
@@ -81,6 +83,7 @@ onMounted(() => {
81
83
 
82
84
  <template>
83
85
  <XFormGroup
86
+ v-if="isInit"
84
87
  mode="修改"
85
88
  :config-name="configName"
86
89
  :service-name="serviceName"