wui-components-v2 1.1.70 → 1.1.72

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 (82) hide show
  1. package/api/feishu.ts +20 -20
  2. package/api/index.ts +4 -4
  3. package/api/login.ts +51 -51
  4. package/api/tree.ts +28 -28
  5. package/components/action-popup/action-popup.vue +116 -116
  6. package/components/add-address-list/add-address-list.vue +187 -187
  7. package/components/add-address-page/config.ts +297 -297
  8. package/components/audio-play/audio-play.vue +220 -220
  9. package/components/batch-upload-file/batch-upload-file.vue +75 -75
  10. package/components/card-botom-buttons/card-botom-buttons.vue +279 -279
  11. package/components/demo-card/demo-card.vue +44 -44
  12. package/components/fold-card/fold-card.vue +2 -2
  13. package/components/form-control/form-control.vue +9 -1
  14. package/components/global-loading/GlobalLoading.md +366 -366
  15. package/components/global-loading/global-loading.vue +55 -55
  16. package/components/global-message/GlobalMessage.md +570 -570
  17. package/components/global-toast/GlobalToast.md +261 -261
  18. package/components/global-toast/global-toast.vue +56 -56
  19. package/components/label-value/open-value-more.vue +56 -56
  20. package/components/loading/loading.vue +5 -5
  21. package/components/login-form-box/login-form-box.vue +65 -65
  22. package/components/phone-login-form/phone-login-form.vue +204 -204
  23. package/components/privacy-popup/privacy-popup.vue +191 -191
  24. package/components/scan-input/scan-input.vue +406 -406
  25. package/components/select-col-picker/select-col-picker.vue +168 -168
  26. package/components/tab-search/tab-search.vue +73 -73
  27. package/components/tree-select/components/TreeNode.vue +200 -200
  28. package/components/tree-select/components/index.vue +471 -471
  29. package/components/tree-select/components/tree-select.vue +56 -56
  30. package/components/tree-select/index.vue +93 -93
  31. package/components/user-choose/user-choose.vue +169 -151
  32. package/components/video-play/video-play.vue +56 -56
  33. package/components/wui-auto-update-component/wui-auto-update-component.vue +132 -132
  34. package/components/wui-default/wui-default.vue +49 -49
  35. package/components/wui-details-page/wui-details-page.vue +147 -147
  36. package/components/wui-edit-page/wui-edit-page-copy.vue +757 -757
  37. package/components/wui-edit-page/wui-edit-page.vue +793 -793
  38. package/components/wui-login/wui-login.vue +43 -43
  39. package/components/wui-login1/wui-login.vue +41 -41
  40. package/components/wui-menus/wui-menus-top.vue +137 -137
  41. package/components/wui-menus/wui-menus-top1.vue +8 -8
  42. package/components/wui-menus1/components/banner-carousel.vue +320 -320
  43. package/components/wui-menus1/components/quick-panel.vue +55 -55
  44. package/components/wui-menus1/components/search-bar.vue +49 -49
  45. package/components/wui-menus1/components/section-menus.vue +208 -208
  46. package/components/wui-menus1/wui-menus-top.vue +718 -718
  47. package/components/wui-menus1/wui-menus-top1.vue +398 -398
  48. package/components/wui-notify-info/notify-handle.vue +53 -53
  49. package/components/wui-scan-binding-sensor/wui-scan-binding-sensor.vue +75 -75
  50. package/components/wui-search-history-babbar/components/SearchBar.vue +70 -70
  51. package/components/wui-select-list/wui-select-list.vue +1 -9
  52. package/components/wui-select-popup/wui-select-popup.vue +1 -0
  53. package/components/wui-tree-page/wui-tree-page.vue +297 -297
  54. package/components/wui-update-component/wui-update-component.vue +221 -221
  55. package/composables/types/theme.ts +65 -65
  56. package/composables/types/user.ts +5 -5
  57. package/composables/useColorGenerator.ts +221 -221
  58. package/composables/useCompanyFieldFilter.ts +26 -24
  59. package/composables/useEnumes.ts +43 -43
  60. package/composables/useEventBus.ts +37 -37
  61. package/composables/useGlobalLoading.ts +47 -47
  62. package/composables/useGlobalMessage.ts +53 -53
  63. package/composables/useGlobalToast.ts +63 -63
  64. package/composables/useLocale.ts +54 -54
  65. package/composables/useManualTheme.ts +179 -179
  66. package/composables/useSectionMenus.ts +120 -120
  67. package/composables/useTabbar.ts +50 -50
  68. package/composables/useTheme.ts +74 -74
  69. package/composables/useUser.ts +24 -24
  70. package/index.d.ts +90 -90
  71. package/package.json +24 -24
  72. package/store/manualThemeStore.ts +143 -143
  73. package/store/persist.ts +41 -41
  74. package/store/themeStore.ts +74 -74
  75. package/store/userStore.ts +22 -22
  76. package/styles/dark-mode.scss +498 -498
  77. package/type.ts +154 -154
  78. package/utils/control-tree.ts +353 -353
  79. package/utils/eventBus.ts +36 -36
  80. package/utils/idata-scan.ts +99 -99
  81. package/utils/index.ts +979 -979
  82. 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.secondCriterion?.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" @tap="toAddressList">
11
+ 通讯录
12
+ <wd-icon name="user" size="18px" />
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>