wui-components-v2 1.1.69 → 1.1.71

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.
Files changed (117) hide show
  1. package/api/core/index.ts +74 -74
  2. package/api/feishu.ts +20 -20
  3. package/api/index.ts +4 -4
  4. package/api/login.ts +51 -51
  5. package/api/menu.ts +45 -45
  6. package/api/page.ts +114 -114
  7. package/api/sys.ts +12 -12
  8. package/api/tree.ts +28 -28
  9. package/components/action-popup/action-popup.vue +116 -116
  10. package/components/add-address-list/add-address-list.vue +187 -187
  11. package/components/add-address-page/add-address-page.vue +77 -77
  12. package/components/add-address-page/config.ts +297 -297
  13. package/components/audio-play/audio-play.vue +220 -220
  14. package/components/batch-upload-file/batch-upload-file.vue +75 -75
  15. package/components/card-botom-buttons/card-botom-buttons.vue +279 -279
  16. package/components/custom-date-picker/custom-date-picker.vue +106 -106
  17. package/components/custom-select-picker/custom-select-picker.vue +95 -95
  18. package/components/demo-block/demo-block.vue +63 -63
  19. package/components/demo-card/demo-card.vue +44 -44
  20. package/components/detail-popup/detail-popup.vue +99 -99
  21. package/components/evaluation-page/evaluation-page.vue +196 -196
  22. package/components/fold-card/fold-card.vue +171 -171
  23. package/components/form-control/form-control.vue +661 -661
  24. package/components/global-loading/GlobalLoading.md +366 -366
  25. package/components/global-loading/global-loading.vue +55 -55
  26. package/components/global-message/GlobalMessage.md +570 -570
  27. package/components/global-message/global-message.vue +68 -68
  28. package/components/global-toast/GlobalToast.md +261 -261
  29. package/components/global-toast/global-toast.vue +56 -56
  30. package/components/label-value/label-value.vue +144 -144
  31. package/components/label-value/open-value-more.vue +56 -56
  32. package/components/list-top-buttons/list-top-buttons.vue +19 -19
  33. package/components/loading/loading.vue +5 -5
  34. package/components/login-form/login-form.vue +126 -126
  35. package/components/login-form-box/login-form-box.vue +65 -65
  36. package/components/mulselect-picker/mulselect-picker.vue +86 -86
  37. package/components/phone-login-form/phone-login-form.vue +204 -204
  38. package/components/privacy-popup/privacy-popup.vue +191 -191
  39. package/components/product-card/product-card.vue +201 -201
  40. package/components/scan-input/scan-input.vue +406 -406
  41. package/components/search/search.vue +128 -128
  42. package/components/select-col-picker/select-col-picker.vue +168 -168
  43. package/components/tab-search/tab-search.vue +73 -73
  44. package/components/tree-select/components/TreeNode.vue +200 -200
  45. package/components/tree-select/components/index.vue +471 -471
  46. package/components/tree-select/components/tree-select.vue +56 -56
  47. package/components/tree-select/index.vue +93 -93
  48. package/components/user-choose/user-choose.vue +169 -151
  49. package/components/video-play/video-play.vue +56 -56
  50. package/components/wui-auto-update-component/wui-auto-update-component.vue +132 -132
  51. package/components/wui-default/wui-default.vue +49 -49
  52. package/components/wui-details-page/wui-details-page.vue +147 -147
  53. package/components/wui-edit-page/wui-edit-page-copy.vue +757 -757
  54. package/components/wui-edit-page/wui-edit-page.vue +793 -793
  55. package/components/wui-enume-select-control/wui-enume-select-control.vue +92 -92
  56. package/components/wui-list/wui-list.vue +235 -235
  57. package/components/wui-login/wui-login.vue +43 -43
  58. package/components/wui-login1/wui-login.vue +41 -41
  59. package/components/wui-menus/wui-menus-top.vue +137 -137
  60. package/components/wui-menus/wui-menus-top1.vue +8 -8
  61. package/components/wui-menus/wui-menus.vue +247 -247
  62. package/components/wui-menus1/components/banner-carousel.vue +320 -320
  63. package/components/wui-menus1/components/navbar.vue +43 -43
  64. package/components/wui-menus1/components/quick-panel.vue +55 -55
  65. package/components/wui-menus1/components/search-bar.vue +49 -49
  66. package/components/wui-menus1/components/section-menus.vue +208 -208
  67. package/components/wui-menus1/wui-menus-top.vue +718 -718
  68. package/components/wui-menus1/wui-menus-top1.vue +398 -398
  69. package/components/wui-menus1/wui-menus.vue +564 -564
  70. package/components/wui-notify-info/notify-handle.vue +53 -53
  71. package/components/wui-notify-info/wui-notify-info.vue +280 -280
  72. package/components/wui-scan-binding-sensor/wui-scan-binding-sensor.vue +75 -75
  73. package/components/wui-search-history-babbar/components/SearchBar.vue +70 -70
  74. package/components/wui-search-history-babbar/wui-search-history-babbar.vue +204 -204
  75. package/components/wui-select-list/wui-select-list.vue +310 -310
  76. package/components/wui-select-popup/wui-select-popup.vue +613 -612
  77. package/components/wui-system-settings/wui-system-settings.vue +144 -144
  78. package/components/wui-tabbar/wui-tabbar.vue +106 -106
  79. package/components/wui-tree-page/components/tree-item.vue +238 -238
  80. package/components/wui-tree-page/wui-tree-page.vue +297 -297
  81. package/components/wui-update-component/wui-update-component.vue +221 -221
  82. package/components/wui-user/wui-user.vue +202 -202
  83. package/composables/types/theme.ts +65 -65
  84. package/composables/types/user.ts +5 -5
  85. package/composables/useColorGenerator.ts +221 -221
  86. package/composables/useCompanyFieldFilter.ts +91 -91
  87. package/composables/useEnumes.ts +43 -43
  88. package/composables/useEventBus.ts +37 -37
  89. package/composables/useGlobalLoading.ts +47 -47
  90. package/composables/useGlobalMessage.ts +53 -53
  91. package/composables/useGlobalToast.ts +63 -63
  92. package/composables/useLocale.ts +54 -54
  93. package/composables/useManualTheme.ts +179 -179
  94. package/composables/useMenus.ts +193 -193
  95. package/composables/useSectionMenus.ts +120 -120
  96. package/composables/useTabbar.ts +50 -50
  97. package/composables/useTheme.ts +74 -74
  98. package/composables/useUser.ts +24 -24
  99. package/index.d.ts +90 -90
  100. package/index.ts +83 -83
  101. package/package.json +24 -24
  102. package/static/iconfont/iconfont.css +63 -63
  103. package/store/language.ts +151 -151
  104. package/store/manualThemeStore.ts +143 -143
  105. package/store/persist.ts +41 -41
  106. package/store/themeStore.ts +74 -74
  107. package/store/userStore.ts +22 -22
  108. package/styles/dark-mode.css +523 -523
  109. package/styles/dark-mode.min.css +1 -1
  110. package/styles/dark-mode.scss +498 -498
  111. package/type.ts +154 -154
  112. package/utils/control-tree.ts +353 -353
  113. package/utils/control-type-supportor.ts +148 -148
  114. package/utils/eventBus.ts +36 -36
  115. package/utils/idata-scan.ts +99 -99
  116. package/utils/index.ts +979 -979
  117. package/utils/rsaEncrypt.ts +10 -10
@@ -1,56 +1,56 @@
1
- <script setup lang="ts">
2
- import { defineEmits, defineOptions, defineProps } from 'vue'
3
- // import type { SelectMode, TreeNode as TreeNodeType } from '../index.vue'
4
- import TreeNode from './TreeNode.vue'
5
- // 树形节点数据结构定义
6
- interface TreeNodeType {
7
- id: string
8
- name: string
9
- children?: TreeNodeType[]
10
- [key: string]: any // 允许其他自定义属性
11
- }
12
- // 选择模式类型
13
- type SelectMode = 'single' | 'multiple'
14
- defineOptions({
15
- name: 'TreeSelect',
16
- })
17
- defineProps<{
18
- treeData: TreeNodeType[]
19
- selectMode: SelectMode
20
- selectedKeys: string[]
21
- setNodeRef: (id: string, el: HTMLElement | null) => void
22
- }>()
23
- const emit = defineEmits<{
24
- (e: 'update:selectedKeys', keys: string[], node: TreeNodeType): void
25
- (e: 'toggleExpand', keys: TreeNodeType): void
26
- }>()
27
-
28
- function handleSelect(keys: string[], node: TreeNodeType) {
29
- emit('update:selectedKeys', keys, node)
30
- }
31
-
32
- function toggleExpand(node: TreeNodeType) {
33
- emit('toggleExpand', node)
34
- }
35
- </script>
36
-
37
- <template>
38
- <view class="tree-select">
39
- <tree-node
40
- v-for="node in treeData"
41
- :key="node.id"
42
- :node="node"
43
- :select-mode="selectMode"
44
- :selected-keys="selectedKeys"
45
- :set-node-ref="setNodeRef"
46
- @update:selected-keys="handleSelect"
47
- @toggle-expand="toggleExpand"
48
- />
49
- </view>
50
- </template>
51
-
52
- <style scoped>
53
- .tree-select {
54
- padding: 0 16px;
55
- }
56
- </style>
1
+ <script setup lang="ts">
2
+ import { defineEmits, defineOptions, defineProps } from 'vue'
3
+ // import type { SelectMode, TreeNode as TreeNodeType } from '../index.vue'
4
+ import TreeNode from './TreeNode.vue'
5
+ // 树形节点数据结构定义
6
+ interface TreeNodeType {
7
+ id: string
8
+ name: string
9
+ children?: TreeNodeType[]
10
+ [key: string]: any // 允许其他自定义属性
11
+ }
12
+ // 选择模式类型
13
+ type SelectMode = 'single' | 'multiple'
14
+ defineOptions({
15
+ name: 'TreeSelect',
16
+ })
17
+ defineProps<{
18
+ treeData: TreeNodeType[]
19
+ selectMode: SelectMode
20
+ selectedKeys: string[]
21
+ setNodeRef: (id: string, el: HTMLElement | null) => void
22
+ }>()
23
+ const emit = defineEmits<{
24
+ (e: 'update:selectedKeys', keys: string[], node: TreeNodeType): void
25
+ (e: 'toggleExpand', keys: TreeNodeType): void
26
+ }>()
27
+
28
+ function handleSelect(keys: string[], node: TreeNodeType) {
29
+ emit('update:selectedKeys', keys, node)
30
+ }
31
+
32
+ function toggleExpand(node: TreeNodeType) {
33
+ emit('toggleExpand', node)
34
+ }
35
+ </script>
36
+
37
+ <template>
38
+ <view class="tree-select">
39
+ <tree-node
40
+ v-for="node in treeData"
41
+ :key="node.id"
42
+ :node="node"
43
+ :select-mode="selectMode"
44
+ :selected-keys="selectedKeys"
45
+ :set-node-ref="setNodeRef"
46
+ @update:selected-keys="handleSelect"
47
+ @toggle-expand="toggleExpand"
48
+ />
49
+ </view>
50
+ </template>
51
+
52
+ <style scoped>
53
+ .tree-select {
54
+ padding: 0 16px;
55
+ }
56
+ </style>
@@ -1,93 +1,93 @@
1
- <script setup lang="ts">
2
- import { computed, defineOptions, defineProps, ref } from 'vue'
3
- import type { FoldCardModel } from '../../type'
4
- import TreeSelectIndex from './components/index.vue'
5
-
6
- defineOptions({
7
- name: 'TreeSelectControl',
8
- })
9
-
10
- const props = defineProps<{
11
- extControlType: string
12
- sourceId: string
13
- title?: string
14
- modelValue: { value: string, sourceId: string }
15
- readonly: boolean
16
- clearable: boolean
17
- foldCardModel?: FoldCardModel
18
- selectMode: 'single' | 'multiple'
19
- }>()
20
- const emits = defineEmits<{
21
- (e: 'update:modelValue', value: { value: string | string[], sourceId: string }): void
22
- }>()
23
- const showPopup = ref(false)
24
- const selectData = ref<string | string[]>(props.modelValue.value)
25
- const selectformatData = computed(() => {
26
- if (Array.isArray(selectData.value)) {
27
- return selectData.value.map(item => item.split('@R@')[1]).join(',')
28
- }
29
- return selectData.value.split('@R@')[1] || ''
30
- })
31
- // const router = useRouter()
32
-
33
- function gotoSlect() {
34
- if (props.readonly)
35
- return
36
- showPopup.value = true
37
- }
38
-
39
- // 清空勾选
40
- function clearSelect() {
41
- // 清空单选
42
- if (props.extControlType === 'relselect') {
43
- selectData.value = ''
44
- emits('update:modelValue', { value: '', sourceId: '' })
45
- }
46
- else {
47
- selectData.value = []
48
- emits('update:modelValue', { value: [], sourceId: '' })
49
- }
50
- }
51
-
52
- // 关闭弹窗
53
- function handleClose() {
54
- showPopup.value = false
55
- }
56
-
57
- // 确认选择
58
- function handleConfirm(value: string | string[], node: any, sourceId: string = '') {
59
- selectData.value = node.map((item: any) => {
60
- return `${item.id}@R@${item.name}`
61
- })
62
- emits('update:modelValue', { value: value[0], sourceId })
63
- handleClose()
64
- }
65
- </script>
66
-
67
- <template>
68
- <view>
69
- <view class="relative" @click="gotoSlect">
70
- <view class="flex flex-wrap text-left">
71
- <text v-if="selectformatData">
72
- {{ selectformatData }}
73
- </text>
74
- <text v-else class="text-gray-400">
75
- 请选择{{ title }}
76
- </text>
77
- </view>
78
- <view v-if="clearable" class="absolute bottom-0 right-0 top-0">
79
- <wd-icon v-if="selectformatData" name="error-fill" size="17px" @click.stop="clearSelect" />
80
- <wd-icon v-else name="arrow-right" size="17px" />
81
- </view>
82
- </view>
83
- <wd-popup v-model="showPopup" position="bottom" custom-style="height:100vh;width:100vw" :z-index="99999">
84
- <TreeSelectIndex :select-mode="props.selectMode" :source-id="props.sourceId" @handle-confirm="handleConfirm" @handle-close="handleClose" />
85
- </wd-popup>
86
- </view>
87
- </template>
88
-
89
- <style scoped>
90
- :deep(.wd-tag__close){
91
- line-height:0.6
92
- }
93
- </style>
1
+ <script setup lang="ts">
2
+ import { computed, defineOptions, defineProps, ref } from 'vue'
3
+ import type { FoldCardModel } from '../../type'
4
+ import TreeSelectIndex from './components/index.vue'
5
+
6
+ defineOptions({
7
+ name: 'TreeSelectControl',
8
+ })
9
+
10
+ const props = defineProps<{
11
+ extControlType: string
12
+ sourceId: string
13
+ title?: string
14
+ modelValue: { value: string, sourceId: string }
15
+ readonly: boolean
16
+ clearable: boolean
17
+ foldCardModel?: FoldCardModel
18
+ selectMode: 'single' | 'multiple'
19
+ }>()
20
+ const emits = defineEmits<{
21
+ (e: 'update:modelValue', value: { value: string | string[], sourceId: string }): void
22
+ }>()
23
+ const showPopup = ref(false)
24
+ const selectData = ref<string | string[]>(props.modelValue.value)
25
+ const selectformatData = computed(() => {
26
+ if (Array.isArray(selectData.value)) {
27
+ return selectData.value.map(item => item.split('@R@')[1]).join(',')
28
+ }
29
+ return selectData.value.split('@R@')[1] || ''
30
+ })
31
+ // const router = useRouter()
32
+
33
+ function gotoSlect() {
34
+ if (props.readonly)
35
+ return
36
+ showPopup.value = true
37
+ }
38
+
39
+ // 清空勾选
40
+ function clearSelect() {
41
+ // 清空单选
42
+ if (props.extControlType === 'relselect') {
43
+ selectData.value = ''
44
+ emits('update:modelValue', { value: '', sourceId: '' })
45
+ }
46
+ else {
47
+ selectData.value = []
48
+ emits('update:modelValue', { value: [], sourceId: '' })
49
+ }
50
+ }
51
+
52
+ // 关闭弹窗
53
+ function handleClose() {
54
+ showPopup.value = false
55
+ }
56
+
57
+ // 确认选择
58
+ function handleConfirm(value: string | string[], node: any, sourceId: string = '') {
59
+ selectData.value = node.map((item: any) => {
60
+ return `${item.id}@R@${item.name}`
61
+ })
62
+ emits('update:modelValue', { value: value[0], sourceId })
63
+ handleClose()
64
+ }
65
+ </script>
66
+
67
+ <template>
68
+ <view>
69
+ <view class="relative" @click="gotoSlect">
70
+ <view class="flex flex-wrap text-left">
71
+ <text v-if="selectformatData">
72
+ {{ selectformatData }}
73
+ </text>
74
+ <text v-else class="text-gray-400">
75
+ 请选择{{ title }}
76
+ </text>
77
+ </view>
78
+ <view v-if="clearable" class="absolute bottom-0 right-0 top-0">
79
+ <wd-icon v-if="selectformatData" name="error-fill" size="17px" @click.stop="clearSelect" />
80
+ <wd-icon v-else name="arrow-right" size="17px" />
81
+ </view>
82
+ </view>
83
+ <wd-popup v-model="showPopup" position="bottom" custom-style="height:100vh;width:100vw" :z-index="99999">
84
+ <TreeSelectIndex :select-mode="props.selectMode" :source-id="props.sourceId" @handle-confirm="handleConfirm" @handle-close="handleClose" />
85
+ </wd-popup>
86
+ </view>
87
+ </template>
88
+
89
+ <style scoped>
90
+ :deep(.wd-tag__close){
91
+ line-height:0.6
92
+ }
93
+ </style>
@@ -1,151 +1,169 @@
1
-
2
- <template>
3
- <div class="flex items-center justify-between gap-3">
4
- <view @click="addUser" class=" flex-1 min-h-[20px]">
5
- <view class="flex items-center gap-2">
6
- <view class=" font-black font-bold">{{ showValue.name }}</view>
7
- <view>{{ formatPhone(showValue.phone) }}</view>
8
- </view>
9
- <view>{{ showValue.address }}</view>
10
- </view>
11
- <wd-icon name="user" size="18px" @tap="toAddressList" />
12
-
13
- </div>
14
- </template>
15
-
16
- <script setup lang="ts">
17
- import { ref, reactive, watch, onMounted, onUnmounted } from 'vue'
18
- import { useRouter } from 'uni-mini-router'
19
- import { pageKey, listData,pageConfig } from '../../api/page'
20
- import { generateHighResolutionID,formatPhone } from '../../utils/index'
21
-
22
- defineOptions({
23
- name: 'UserChoose',
24
- })
25
-
26
- const props = defineProps({
27
- modelValue: [String, Array],
28
- placeholder: String,
29
- sourceId: String,
30
- title: String,
31
- extControlType: String,
32
- })
33
-
34
- const emit = defineEmits<{
35
- 'update:modelValue': [value: string]
36
- }>()
37
-
38
- const router = useRouter()
39
-
40
- const currentValue = ref<string>(props.modelValue as string || '')
41
- const showValue = reactive({
42
- name: '',
43
- phone: '',
44
- address: '',
45
- })
46
-
47
- const EVENT_NAME = `userChooseSelected_${generateHighResolutionID()}`
48
-
49
- const addUser = () => {
50
- const addEvent = generateHighResolutionID()
51
- router.push(`/pages/edit-page/index?sourceId=${props.sourceId}&title=${props.title}&addEvent=${addEvent}`)
52
- uni.$once(addEvent, (data: any) => {
53
- uni.$off(addEvent)
54
- currentValue.value = data.entityCode
55
- fetchDataById(data.entityCode)
56
- })
57
- }
58
-
59
- const toAddressList = () => {
60
- uni.navigateTo({
61
- url: `/pages/select-list/index?sourceId=${props.sourceId}&title=${props.title}&extControlType=${props.extControlType}&selectEvent=${EVENT_NAME}`,
62
- })
63
- }
64
-
65
- const fetchDataById = async (id: string) => {
66
- if (!id || !props.sourceId) return
67
- const newId=Array.isArray(id)?id[0]:id
68
- const requestId = newId?.split('@R@')[0] || props.sourceId
69
- try {
70
- const config = await pageConfig(props.sourceId)
71
- const newConfig=config.ltmplConfig
72
- const onlyCode=newConfig.extDisplayConfig?.cardShowCols?.[0]?.sourceId //获取回显字段对应参数名
73
- const query=`c_${newConfig.secondCriteria?.sourceId}=${requestId}` //构建查询参数
74
- const res = await pageKey(props.sourceId, '', query)
75
- const data = await listData(res.key, 1, 10)
76
- const item = data.entities.find((e: any) => e.code === requestId)as any
77
- const {fieldMap={}}=item
78
- const textArr=(fieldMap[onlyCode] || '').split(',') //拆分字符串 姓名,手机号,地址 分别对应数组的0,1,2索引
79
- if (item) {
80
- showValue.name = textArr?.[0] || ''
81
- showValue.phone = textArr?.[1] || ''
82
- showValue.address = textArr?.[2] || ''
83
- }
84
- // 数据获取完成后,触发 emit
85
- emitIfNeeded(id)
86
- } catch (error) {
87
- console.error('获取数据失败:', error)
88
- }
89
- }
90
-
91
- const emitIfNeeded = (val: string) => {
92
- if (!val) return
93
- let emitVal = val
94
- if (typeof val === 'string' && !val.includes('@R@')) {
95
- emitVal = val + '@R@' + showValue.name
96
- }
97
- if (emitVal !== props.modelValue) {
98
- emit('update:modelValue', emitVal)
99
- }
100
- }
101
-
102
- onMounted(() => {
103
- const raw = currentValue.value
104
- if (raw && typeof raw === 'string') {
105
- const requestId = raw.includes('$$user.') ? raw.split('$$user.')[1] : raw
106
- fetchDataById(requestId)
107
- }
108
-
109
- uni.$on(EVENT_NAME, (id: string) => {
110
- currentValue.value = id
111
- fetchDataById(id)
112
- })
113
- })
114
-
115
- onUnmounted(() => {
116
- uni.$off(EVENT_NAME)
117
- })
118
-
119
- watch(() => props.modelValue, (val) => {
120
- const newId = val as string
121
- if (newId && newId !== currentValue.value) {
122
- currentValue.value = newId
123
- fetchDataById(newId)
124
- }
125
- })
126
-
127
- watch(currentValue, (val) => {
128
- if (!val) return
129
- // 如果值已经包含@R@(无需异步获取数据),直接 emit
130
- if (typeof val === 'string' && val.includes('@R@')) {
131
- if (val !== props.modelValue) {
132
- emit('update:modelValue', val)
133
- }
134
- }
135
- // 否则由 fetchDataById 成功后调用 emitIfNeeded 来 emit
136
- }, { immediate: true })
137
- </script>
138
- <style scoped lang="scss">
139
- .custom-select-picker {
140
- width: 100%;
141
- :deep(.wd-select-picker__wrapper) {
142
- padding : 0 20px;
143
- overflow: auto;
144
- scrollbar-width: none;
145
- -ms-overflow-style: none;
146
- }
147
- :deep(.uni-scroll-view) {
148
- scrollbar-width: none;
149
- }
150
- }
151
- </style>
1
+ <template>
2
+ <div class="flex items-center justify-between gap-3">
3
+ <view @click="addUser" class="flex-1 min-h-[20px]">
4
+ <view class="flex items-center gap-2">
5
+ <view class="font-black font-bold">{{ showValue.name }}</view>
6
+ <view>{{ formatPhone(showValue.phone) }}</view>
7
+ </view>
8
+ <view>{{ showValue.address }}</view>
9
+ </view>
10
+ <view class="flex items-center gap-1 text-3">
11
+ 通讯录
12
+ <wd-icon name="user" size="18px" @tap="toAddressList" />
13
+ </view>
14
+ </div>
15
+ </template>
16
+ s
17
+
18
+ <script setup lang="ts">
19
+ import { ref, reactive, watch, onMounted, onUnmounted } from 'vue'
20
+ import { useRouter } from 'uni-mini-router'
21
+ import { pageKey, listData, pageConfig } from '../../api/page'
22
+ import { generateHighResolutionID, formatPhone } from '../../utils/index'
23
+
24
+ defineOptions({
25
+ name: 'UserChoose',
26
+ })
27
+
28
+ const props = defineProps({
29
+ modelValue: [String, Array],
30
+ placeholder: String,
31
+ sourceId: String,
32
+ title: String,
33
+ extControlType: String,
34
+ })
35
+
36
+ const emit = defineEmits<{
37
+ 'update:modelValue': [value: string]
38
+ }>()
39
+
40
+ const router = useRouter()
41
+
42
+ const currentValue = ref<string>((props.modelValue as string) || '')
43
+ const showValue = reactive({
44
+ name: '',
45
+ phone: '',
46
+ address: '',
47
+ })
48
+
49
+ const EVENT_NAME = `userChooseSelected_${generateHighResolutionID()}`
50
+
51
+ const addUser = () => {
52
+ const addEvent = generateHighResolutionID()
53
+ // 当前已有数据时,跳转到编辑页面
54
+ if (currentValue.value) {
55
+ // 和 fetchDataById 中的 requestId 逻辑保持一致
56
+ const entityId = currentValue.value.split('@R@')[0]
57
+ router.push(
58
+ `/pages/edit-page/index?sourceId=${props.sourceId}&title=${props.title}&addEvent=${addEvent}&id=${entityId}`
59
+ )
60
+ } else {
61
+ router.push(`/pages/edit-page/index?sourceId=${props.sourceId}&title=${props.title}&addEvent=${addEvent}`)
62
+ }
63
+ uni.$once(addEvent, (data: any) => {
64
+ uni.$off(addEvent)
65
+ currentValue.value = data.entityCode
66
+ fetchDataById(data.entityCode)
67
+ })
68
+ }
69
+
70
+ const toAddressList = () => {
71
+ uni.navigateTo({
72
+ url: `/pages/select-list/index?sourceId=${props.sourceId}&title=${props.title}&extControlType=${props.extControlType}&selectEvent=${EVENT_NAME}`,
73
+ })
74
+ }
75
+
76
+ const fetchDataById = async (id: string) => {
77
+ if (!id || !props.sourceId) return
78
+ const newId = Array.isArray(id) ? id[0] : id
79
+ const requestId = newId?.split('@R@')[0] || props.sourceId
80
+ try {
81
+ const config = await pageConfig(props.sourceId)
82
+ const newConfig = config.ltmplConfig
83
+ const onlyCode = newConfig.extDisplayConfig?.cardShowCols?.[0]?.sourceId //获取回显字段对应参数名
84
+ const query = `c_${newConfig.secondCriterion?.sourceId}=${requestId}` //构建查询参数
85
+ const res = await pageKey(props.sourceId, '', query)
86
+ const data = await listData(res.key, 1, 10)
87
+ const item = data.entities.find((e: any) => e.code === requestId) as any
88
+ const { fieldMap = {} } = item
89
+ const textArr = (fieldMap[onlyCode] || '').split(',') //拆分字符串 姓名,手机号,地址 分别对应数组的0,1,2索引
90
+ if (item) {
91
+ showValue.name = textArr?.[0] || ''
92
+ showValue.phone = textArr?.[1] || ''
93
+ showValue.address = textArr?.[2] || ''
94
+ }
95
+ // 数据获取完成后,触发 emit
96
+ emitIfNeeded(id)
97
+ } catch (error) {
98
+ console.error('获取数据失败:', error)
99
+ }
100
+ }
101
+
102
+ const emitIfNeeded = (val: string) => {
103
+ if (!val) return
104
+ let emitVal = val
105
+ if (typeof val === 'string' && !val.includes('@R@')) {
106
+ emitVal = val + '@R@' + showValue.name
107
+ }
108
+ if (emitVal !== props.modelValue) {
109
+ emit('update:modelValue', emitVal)
110
+ }
111
+ }
112
+
113
+ onMounted(() => {
114
+ const raw = currentValue.value
115
+ if (raw && typeof raw === 'string') {
116
+ const requestId = raw.includes('$$user.') ? raw.split('$$user.')[1] : raw
117
+ fetchDataById(requestId)
118
+ }
119
+
120
+ uni.$on(EVENT_NAME, (id: string) => {
121
+ currentValue.value = id
122
+ fetchDataById(id)
123
+ })
124
+ })
125
+
126
+ onUnmounted(() => {
127
+ uni.$off(EVENT_NAME)
128
+ })
129
+
130
+ watch(
131
+ () => props.modelValue,
132
+ val => {
133
+ const newId = val as string
134
+ if (newId && newId !== currentValue.value) {
135
+ currentValue.value = newId
136
+ fetchDataById(newId)
137
+ }
138
+ }
139
+ )
140
+
141
+ watch(
142
+ currentValue,
143
+ val => {
144
+ if (!val) return
145
+ // 如果值已经包含@R@(无需异步获取数据),直接 emit
146
+ if (typeof val === 'string' && val.includes('@R@')) {
147
+ if (val !== props.modelValue) {
148
+ emit('update:modelValue', val)
149
+ }
150
+ }
151
+ // 否则由 fetchDataById 成功后调用 emitIfNeeded 来 emit
152
+ },
153
+ { immediate: true }
154
+ )
155
+ </script>
156
+ <style scoped lang="scss">
157
+ .custom-select-picker {
158
+ width: 100%;
159
+ :deep(.wd-select-picker__wrapper) {
160
+ padding: 0 20px;
161
+ overflow: auto;
162
+ scrollbar-width: none;
163
+ -ms-overflow-style: none;
164
+ }
165
+ :deep(.uni-scroll-view) {
166
+ scrollbar-width: none;
167
+ }
168
+ }
169
+ </style>