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.
- package/api/feishu.ts +20 -20
- package/api/index.ts +4 -4
- package/api/login.ts +51 -51
- package/api/tree.ts +28 -28
- package/components/action-popup/action-popup.vue +116 -116
- package/components/add-address-list/add-address-list.vue +187 -187
- package/components/add-address-page/config.ts +297 -297
- package/components/audio-play/audio-play.vue +220 -220
- package/components/batch-upload-file/batch-upload-file.vue +75 -75
- package/components/card-botom-buttons/card-botom-buttons.vue +279 -279
- package/components/demo-card/demo-card.vue +44 -44
- package/components/fold-card/fold-card.vue +2 -2
- package/components/form-control/form-control.vue +9 -1
- package/components/global-loading/GlobalLoading.md +366 -366
- package/components/global-loading/global-loading.vue +55 -55
- package/components/global-message/GlobalMessage.md +570 -570
- package/components/global-toast/GlobalToast.md +261 -261
- package/components/global-toast/global-toast.vue +56 -56
- package/components/label-value/open-value-more.vue +56 -56
- package/components/loading/loading.vue +5 -5
- package/components/login-form-box/login-form-box.vue +65 -65
- package/components/phone-login-form/phone-login-form.vue +204 -204
- package/components/privacy-popup/privacy-popup.vue +191 -191
- package/components/scan-input/scan-input.vue +406 -406
- package/components/select-col-picker/select-col-picker.vue +168 -168
- package/components/tab-search/tab-search.vue +73 -73
- package/components/tree-select/components/TreeNode.vue +200 -200
- package/components/tree-select/components/index.vue +471 -471
- package/components/tree-select/components/tree-select.vue +56 -56
- package/components/tree-select/index.vue +93 -93
- package/components/user-choose/user-choose.vue +169 -151
- package/components/video-play/video-play.vue +56 -56
- package/components/wui-auto-update-component/wui-auto-update-component.vue +132 -132
- package/components/wui-default/wui-default.vue +49 -49
- package/components/wui-details-page/wui-details-page.vue +147 -147
- package/components/wui-edit-page/wui-edit-page-copy.vue +757 -757
- package/components/wui-edit-page/wui-edit-page.vue +793 -793
- package/components/wui-login/wui-login.vue +43 -43
- package/components/wui-login1/wui-login.vue +41 -41
- package/components/wui-menus/wui-menus-top.vue +137 -137
- package/components/wui-menus/wui-menus-top1.vue +8 -8
- package/components/wui-menus1/components/banner-carousel.vue +320 -320
- package/components/wui-menus1/components/quick-panel.vue +55 -55
- package/components/wui-menus1/components/search-bar.vue +49 -49
- package/components/wui-menus1/components/section-menus.vue +208 -208
- package/components/wui-menus1/wui-menus-top.vue +718 -718
- package/components/wui-menus1/wui-menus-top1.vue +398 -398
- package/components/wui-notify-info/notify-handle.vue +53 -53
- package/components/wui-scan-binding-sensor/wui-scan-binding-sensor.vue +75 -75
- package/components/wui-search-history-babbar/components/SearchBar.vue +70 -70
- package/components/wui-select-list/wui-select-list.vue +1 -9
- package/components/wui-select-popup/wui-select-popup.vue +1 -0
- package/components/wui-tree-page/wui-tree-page.vue +297 -297
- package/components/wui-update-component/wui-update-component.vue +221 -221
- package/composables/types/theme.ts +65 -65
- package/composables/types/user.ts +5 -5
- package/composables/useColorGenerator.ts +221 -221
- package/composables/useCompanyFieldFilter.ts +26 -24
- package/composables/useEnumes.ts +43 -43
- package/composables/useEventBus.ts +37 -37
- package/composables/useGlobalLoading.ts +47 -47
- package/composables/useGlobalMessage.ts +53 -53
- package/composables/useGlobalToast.ts +63 -63
- package/composables/useLocale.ts +54 -54
- package/composables/useManualTheme.ts +179 -179
- package/composables/useSectionMenus.ts +120 -120
- package/composables/useTabbar.ts +50 -50
- package/composables/useTheme.ts +74 -74
- package/composables/useUser.ts +24 -24
- package/index.d.ts +90 -90
- package/package.json +24 -24
- package/store/manualThemeStore.ts +143 -143
- package/store/persist.ts +41 -41
- package/store/themeStore.ts +74 -74
- package/store/userStore.ts +22 -22
- package/styles/dark-mode.scss +498 -498
- package/type.ts +154 -154
- package/utils/control-tree.ts +353 -353
- package/utils/eventBus.ts +36 -36
- package/utils/idata-scan.ts +99 -99
- package/utils/index.ts +979 -979
- 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
|
-
<
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
</
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
import {
|
|
20
|
-
import {
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
const
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
const
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
fetchDataById
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
}
|
|
150
|
-
}
|
|
151
|
-
|
|
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>
|