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,128 +1,128 @@
1
- <script setup lang="ts">
2
- import { defineEmits, defineOptions, defineProps, ref } from 'vue'
3
- import type { Enums, Fields, Split2TabCriterias } from '../../type'
4
- import formControl from '../form-control/form-control.vue'
5
-
6
- defineOptions({ name: 'Search' })
7
- const props = defineProps<{
8
- criterias: Fields[]
9
- primaryCriteria: Fields | null
10
- enumColumn?: Enums
11
- mainCode?: string
12
- split2TabCriterias?: Split2TabCriterias[]
13
- }>()
14
- const emits = defineEmits(['submit'])
15
- const show = ref(false)
16
- const search = ref('')
17
- const formControlRef = ref()
18
- const entity = ref({})
19
- const filterCriterias = computed(() => {
20
- const criteriaSourceIds = props.split2TabCriterias?.map(item => item.sourceId) || []
21
- const primarySourceId = props.primaryCriteria?.sourceId
22
- if (!primarySourceId)
23
- return props.criterias
24
- return props.criterias.filter(item => ![primarySourceId, ...criteriaSourceIds].includes(item.sourceId))
25
- })
26
- function handleClose() {
27
- show.value = false
28
- }
29
- function handleSubmit() {
30
- if (!formControlRef.value) {
31
- if (!props.primaryCriteria?.sourceId)
32
- return
33
- const data = `c_${props.primaryCriteria.sourceId}=${search.value}`
34
- emits('submit', data)
35
- handleClose()
36
- return
37
- }
38
- formControlRef.value.submit().then((fdata: any) => {
39
- entity.value = {
40
- ...fdata,
41
- ...(props.primaryCriteria?.sourceId ? { [props.primaryCriteria.sourceId]: search.value } : {}),
42
- }
43
- let data = ''
44
-
45
- if (props.primaryCriteria?.sourceId) {
46
- data = `c_${props.primaryCriteria.sourceId}=${search.value}`
47
- }
48
-
49
- filterCriterias.value.forEach((item) => {
50
- for (const key in fdata) {
51
- if (Object.prototype.hasOwnProperty.call(fdata, key)) {
52
- const element = fdata[key]
53
- if (item.sourceId === key) {
54
- if (item.extControlType === 'relselectvalue') {
55
- data = `${data}&c_${item.sourceId}=${element.map((item: string) => {
56
- return item.split('@R@')[1]
57
- }).join('@,@')}`
58
- }
59
- else if (item.extControlType === 'multiselect') {
60
- element.forEach((subitem: string) => {
61
- data = `${data}&c_${item.sourceId}=${subitem}`
62
- })
63
- }
64
- else {
65
- data = `${data}&c_${item.sourceId}=${element}`
66
- }
67
- }
68
- }
69
- }
70
- })
71
-
72
- console.log('查询条件', data)
73
-
74
- emits('submit', data)
75
- handleClose()
76
- })
77
- }
78
- </script>
79
-
80
- <template>
81
- <view v-if="primaryCriteria?.controlType === 'text'" class="w-full">
82
- <wd-search v-model="search" cancel-txt="搜索" :placeholder="`请输入${primaryCriteria?.title || ''}搜索`" @clear="handleSubmit" @cancel="handleSubmit">
83
- <template v-if="filterCriterias.length" #prefix>
84
- <view class="search-type">
85
- <wd-icon name="filter" size="17px" class="text-gray-500" @click="show = true" />
86
- </view>
87
- </template>
88
- </wd-search>
89
- </view>
90
- <wd-popup v-model="show" position="bottom" custom-class="h-80vh" closable @close="handleClose">
91
- <view class="relative box-border h-full p-1 bg-white dark:bg-[var(--wot-dark-background)]">
92
- <view class="h-34px flex items-center justify-center">
93
- 筛选
94
- </view>
95
- <formControl ref="formControlRef" :field-group="{ fields: filterCriterias, readOnly: false, displayConfig: [], id: '', buttons: [], title: '', type: '', pointSourceId: '', mstrucId: '', relationNames: [] }" :entity="entity" :enum-column="enumColumn" />
96
- <view class="h-12" />
97
- <view class="fixed bottom-0 left-0 right-0 box-border w-100% flex p-2 bg-white dark:bg-[var(--wot-dark-background)]">
98
- <wd-button block custom-class="flex-1" @click="handleSubmit">
99
- 确定
100
- </wd-button>
101
- </view>
102
- </view>
103
- </wd-popup>
104
- </template>
105
-
106
- <style scoped>
107
- .search-type {
108
- position: relative;
109
- height: 30px;
110
- line-height: 30px;
111
- padding: 0 8px 0 16px;
112
- }
113
- .search-type::after {
114
- position: absolute;
115
- content: '';
116
- width: 1px;
117
- right: 0;
118
- top: 5px;
119
- bottom: 5px;
120
- }
121
- ::deep(.icon-arrow) {
122
- display: inline-block;
123
- font-size: 20px;
124
- vertical-align: middle;
125
- }
126
-
127
-
128
- </style>
1
+ <script setup lang="ts">
2
+ import { computed, defineEmits, defineOptions, defineProps, ref } from 'vue'
3
+ import type { Enums, Fields, Split2TabCriterias } from '../../type'
4
+ import formControl from '../form-control/form-control.vue'
5
+
6
+ defineOptions({ name: 'Search' })
7
+ const props = defineProps<{
8
+ criteria: Fields[]
9
+ primaryCriterion: Fields | null
10
+ enumColumn?: Enums
11
+ mainCode?: string
12
+ split2TabCriterias?: Split2TabCriterias[]
13
+ }>()
14
+ const emits = defineEmits(['submit'])
15
+ const show = ref(false)
16
+ const search = ref('')
17
+ const formControlRef = ref()
18
+ const entity = ref({})
19
+ const filterCriteria = computed(() => {
20
+ const criteriaSourceIds = props.split2TabCriterias?.map(item => item.sourceId) || []
21
+ const primarySourceId = props.primaryCriterion?.sourceId
22
+ if (!primarySourceId)
23
+ return props.criteria
24
+ return props.criteria.filter(item => ![primarySourceId, ...criteriaSourceIds].includes(item.sourceId))
25
+ })
26
+ function handleClose() {
27
+ show.value = false
28
+ }
29
+ function handleSubmit() {
30
+ if (!formControlRef.value) {
31
+ if (!props.primaryCriterion?.sourceId)
32
+ return
33
+ const data = `c_${props.primaryCriterion.sourceId}=${search.value}`
34
+ emits('submit', data)
35
+ handleClose()
36
+ return
37
+ }
38
+ formControlRef.value.submit().then((fdata: any) => {
39
+ entity.value = {
40
+ ...fdata,
41
+ ...(props.primaryCriterion?.sourceId ? { [props.primaryCriterion.sourceId]: search.value } : {}),
42
+ }
43
+ let data = ''
44
+
45
+ if (props.primaryCriterion?.sourceId) {
46
+ data = `c_${props.primaryCriterion.sourceId}=${search.value}`
47
+ }
48
+
49
+ filterCriteria.value.forEach((item) => {
50
+ for (const key in fdata) {
51
+ if (Object.prototype.hasOwnProperty.call(fdata, key)) {
52
+ const element = fdata[key]
53
+ if (item.sourceId === key) {
54
+ if (item.extControlType === 'relselectvalue') {
55
+ data = `${data}&c_${item.sourceId}=${element.map((item: string) => {
56
+ return item.split('@R@')[1]
57
+ }).join('@,@')}`
58
+ }
59
+ else if (item.extControlType === 'multiselect') {
60
+ element.forEach((subitem: string) => {
61
+ data = `${data}&c_${item.sourceId}=${subitem}`
62
+ })
63
+ }
64
+ else {
65
+ data = `${data}&c_${item.sourceId}=${element}`
66
+ }
67
+ }
68
+ }
69
+ }
70
+ })
71
+
72
+ console.log('查询条件', data)
73
+
74
+ emits('submit', data)
75
+ handleClose()
76
+ })
77
+ }
78
+ </script>
79
+
80
+ <template>
81
+ <view v-if="primaryCriterion?.controlType === 'text'" class="w-full">
82
+ <wd-search v-model="search" cancel-txt="搜索" :placeholder="`请输入${primaryCriterion?.title || ''}搜索`" @clear="handleSubmit" @cancel="handleSubmit">
83
+ <template v-if="filterCriteria.length" #prefix>
84
+ <view class="search-type">
85
+ <wd-icon name="filter" size="17px" class="text-gray-500" @click="show = true" />
86
+ </view>
87
+ </template>
88
+ </wd-search>
89
+ </view>
90
+ <wd-popup v-model="show" position="bottom" custom-class="h-80vh" closable @close="handleClose">
91
+ <view class="relative box-border h-full p-1 bg-white dark:bg-[var(--wot-dark-background)]">
92
+ <view class="h-34px flex items-center justify-center">
93
+ 筛选
94
+ </view>
95
+ <formControl ref="formControlRef" :field-group="{ fields: filterCriteria, readOnly: false, displayConfig: [], id: '', buttons: [], title: '', type: '', pointSourceId: '', mstrucId: '', relationNames: [] }" :entity="entity" :enum-column="enumColumn" />
96
+ <view class="h-12" />
97
+ <view class="fixed bottom-0 left-0 right-0 box-border w-100% flex p-2 bg-white dark:bg-[var(--wot-dark-background)]">
98
+ <wd-button block custom-class="flex-1" @click="handleSubmit">
99
+ 确定
100
+ </wd-button>
101
+ </view>
102
+ </view>
103
+ </wd-popup>
104
+ </template>
105
+
106
+ <style scoped>
107
+ .search-type {
108
+ position: relative;
109
+ height: 30px;
110
+ line-height: 30px;
111
+ padding: 0 8px 0 16px;
112
+ }
113
+ .search-type::after {
114
+ position: absolute;
115
+ content: '';
116
+ width: 1px;
117
+ right: 0;
118
+ top: 5px;
119
+ bottom: 5px;
120
+ }
121
+ ::deep(.icon-arrow) {
122
+ display: inline-block;
123
+ font-size: 20px;
124
+ vertical-align: middle;
125
+ }
126
+
127
+
128
+ </style>
@@ -1,168 +1,168 @@
1
- <script setup lang="ts">
2
- import { computed, defineEmits, defineOptions, defineProps, reactive, ref } from 'vue'
3
- import { onLoad } from '@dcloudio/uni-app'
4
- import { treeConfigApi, treeDataApi, treeNodeDataApi } from '../../api/tree'
5
- import { pageConfig } from '../../api/page'
6
-
7
- defineOptions({
8
- name: 'SelectColPicker',
9
- })
10
- const props = defineProps<Props>()
11
-
12
- const emits = defineEmits<{
13
- (e: 'update:modelValue', value: string[]): void
14
- }>()
15
-
16
- // 定义 props 类型
17
- interface Props {
18
- sourceId: string
19
- label?: string
20
- labelWidth: string
21
- prop: string
22
- readonly: boolean
23
- clearable: boolean
24
- placeholder: string
25
- modelValue: Array<string>
26
- }
27
-
28
- const dataValue = computed(() => {
29
- return props.modelValue
30
- })
31
- const sourceId = ref('')
32
- const columns = ref<any[]>([])
33
- const treeConfigs = reactive({
34
- branchRatmplId: '',
35
- branchTitle: '',
36
- id: '',
37
- rootGtmplId: '',
38
- primaryColumnId1: '',
39
- primaryColumnId2: '',
40
- leafRatmplId: '',
41
- })
42
-
43
- // 获取配置1
44
- async function treeConfig1() {
45
- try {
46
- const res = await treeConfigApi(sourceId.value)
47
- console.log(res)
48
- treeConfigs.branchRatmplId = res.ttmplConfig.branchRatmplId
49
- treeConfigs.branchTitle = res.ttmplConfig.branchTitle
50
- treeConfigs.id = res.ttmplConfig.id
51
- treeConfigs.rootGtmplId = res.ttmplConfig.rootGtmplId
52
- treeConfigs.leafRatmplId = res.ttmplConfig.leafRatmplId
53
- treeConfig2(treeConfigs.branchRatmplId, treeConfigs.leafRatmplId)
54
- }
55
- catch (error) {
56
- console.log('error:', error)
57
- // TODO handle the exception
58
- }
59
- }
60
-
61
- onLoad((option: any) => {
62
- sourceId.value = props.sourceId || option.sourceId
63
- treeConfig1()
64
- })
65
-
66
- // 获取配置2
67
- async function treeConfig2(branchRatmplId: string, leafRatmplId: string) {
68
- try {
69
- const res1 = await pageConfig(branchRatmplId)
70
- const res2 = await pageConfig(leafRatmplId)
71
- treeConfigs.primaryColumnId1 = res1.ltmplConfig.primaryColumn.sourceId
72
- treeConfigs.primaryColumnId2 = res2.ltmplConfig.primaryColumn.sourceId
73
- getTreeData()
74
- }
75
- catch (error) {
76
- console.log('error:', error)
77
- // TODO handle the exception
78
- }
79
- }
80
-
81
- // 获取数据
82
- async function getTreeData() {
83
- try {
84
- const res = await treeDataApi(treeConfigs.id)
85
- console.log('res.entities:', res)
86
- columns.value = [res.entities.map((item: any) => {
87
- return {
88
- value: item.code,
89
- label: item.fieldMap[treeConfigs.primaryColumnId1],
90
- }
91
- })]
92
- }
93
- catch (error) {
94
- console.log('error:', error)
95
- // TODO handle the exception
96
- }
97
- }
98
-
99
- async function columnChange({ selectedItem, resolve, finish }: any) {
100
- try {
101
- const res2 = treeNodeDataApi(treeConfigs.leafRatmplId, selectedItem.value)
102
- const res1 = treeNodeDataApi(treeConfigs.branchRatmplId, selectedItem.value)
103
- const res3 = await Promise.all([res1, res2])
104
- console.log('res3:', res3)
105
- if (res3[0].entities.length || res3[1].entities.length) {
106
- resolve(
107
- [
108
- ...res3[0].entities.map((item: any) => {
109
- return {
110
- value: item.code,
111
- label: item.fieldMap[treeConfigs.primaryColumnId1],
112
- }
113
- }),
114
- ...res3[1].entities.map((item: any) => {
115
- return {
116
- value: item.code,
117
- label: item.fieldMap[treeConfigs.primaryColumnId2],
118
- }
119
- }),
120
- ],
121
- )
122
- }
123
- else {
124
- finish()
125
- }
126
- }
127
- catch (error) {
128
- console.log('error:', error)
129
- finish(false)
130
- // TODO handle the exception
131
- }
132
- }
133
-
134
- function handleConfirm(selectedItems: any) {
135
- console.log(selectedItems)
136
- emits('update:modelValue', [selectedItems[selectedItems.length - 1]])
137
- }
138
- // 格式化方法
139
- function displayFormat(selectedItems: Record<string, any>[]) {
140
- return selectedItems[selectedItems.length - 1]?.label
141
- }
142
- </script>
143
-
144
- <template>
145
- <view>
146
- <wd-col-picker
147
- :use-default-slot="true"
148
- :model-value="dataValue"
149
- :columns="columns"
150
- :column-change="columnChange"
151
- :display-format="displayFormat"
152
- :style="{ pointerEvents: props.readonly ? '' : 'none' }"
153
- @confirm="handleConfirm"
154
- >
155
- <wd-input
156
-
157
- type="text"
158
- model-value=""
159
- :prop="props.prop"
160
- :placeholder="props.placeholder"
161
- :label-width="props.labelWidth"
162
- :label="props.label"
163
- :readonly="true"
164
- :clearable="false"
165
- />
166
- </wd-col-picker>
167
- </view>
168
- </template>
1
+ <script setup lang="ts">
2
+ import { computed, defineEmits, defineOptions, defineProps, reactive, ref } from 'vue'
3
+ import { onLoad } from '@dcloudio/uni-app'
4
+ import { treeConfigApi, treeDataApi, treeNodeDataApi } from '../../api/tree'
5
+ import { pageConfig } from '../../api/page'
6
+
7
+ defineOptions({
8
+ name: 'SelectColPicker',
9
+ })
10
+ const props = defineProps<Props>()
11
+
12
+ const emits = defineEmits<{
13
+ (e: 'update:modelValue', value: string[]): void
14
+ }>()
15
+
16
+ // 定义 props 类型
17
+ interface Props {
18
+ sourceId: string
19
+ label?: string
20
+ labelWidth: string
21
+ prop: string
22
+ readonly: boolean
23
+ clearable: boolean
24
+ placeholder: string
25
+ modelValue: Array<string>
26
+ }
27
+
28
+ const dataValue = computed(() => {
29
+ return props.modelValue
30
+ })
31
+ const sourceId = ref('')
32
+ const columns = ref<any[]>([])
33
+ const treeConfigs = reactive({
34
+ branchRatmplId: '',
35
+ branchTitle: '',
36
+ id: '',
37
+ rootGtmplId: '',
38
+ primaryColumnId1: '',
39
+ primaryColumnId2: '',
40
+ leafRatmplId: '',
41
+ })
42
+
43
+ // 获取配置1
44
+ async function treeConfig1() {
45
+ try {
46
+ const res = await treeConfigApi(sourceId.value)
47
+ console.log(res)
48
+ treeConfigs.branchRatmplId = res.ttmplConfig.branchRatmplId
49
+ treeConfigs.branchTitle = res.ttmplConfig.branchTitle
50
+ treeConfigs.id = res.ttmplConfig.id
51
+ treeConfigs.rootGtmplId = res.ttmplConfig.rootGtmplId
52
+ treeConfigs.leafRatmplId = res.ttmplConfig.leafRatmplId
53
+ treeConfig2(treeConfigs.branchRatmplId, treeConfigs.leafRatmplId)
54
+ }
55
+ catch (error) {
56
+ console.log('error:', error)
57
+ // TODO handle the exception
58
+ }
59
+ }
60
+
61
+ onLoad((option: any) => {
62
+ sourceId.value = props.sourceId || option.sourceId
63
+ treeConfig1()
64
+ })
65
+
66
+ // 获取配置2
67
+ async function treeConfig2(branchRatmplId: string, leafRatmplId: string) {
68
+ try {
69
+ const res1 = await pageConfig(branchRatmplId)
70
+ const res2 = await pageConfig(leafRatmplId)
71
+ treeConfigs.primaryColumnId1 = res1.ltmplConfig.primaryColumn.sourceId
72
+ treeConfigs.primaryColumnId2 = res2.ltmplConfig.primaryColumn.sourceId
73
+ getTreeData()
74
+ }
75
+ catch (error) {
76
+ console.log('error:', error)
77
+ // TODO handle the exception
78
+ }
79
+ }
80
+
81
+ // 获取数据
82
+ async function getTreeData() {
83
+ try {
84
+ const res = await treeDataApi(treeConfigs.id)
85
+ console.log('res.entities:', res)
86
+ columns.value = [res.entities.map((item: any) => {
87
+ return {
88
+ value: item.code,
89
+ label: item.fieldMap[treeConfigs.primaryColumnId1],
90
+ }
91
+ })]
92
+ }
93
+ catch (error) {
94
+ console.log('error:', error)
95
+ // TODO handle the exception
96
+ }
97
+ }
98
+
99
+ async function columnChange({ selectedItem, resolve, finish }: any) {
100
+ try {
101
+ const res2 = treeNodeDataApi(treeConfigs.leafRatmplId, selectedItem.value)
102
+ const res1 = treeNodeDataApi(treeConfigs.branchRatmplId, selectedItem.value)
103
+ const res3 = await Promise.all([res1, res2])
104
+ console.log('res3:', res3)
105
+ if (res3[0].entities.length || res3[1].entities.length) {
106
+ resolve(
107
+ [
108
+ ...res3[0].entities.map((item: any) => {
109
+ return {
110
+ value: item.code,
111
+ label: item.fieldMap[treeConfigs.primaryColumnId1],
112
+ }
113
+ }),
114
+ ...res3[1].entities.map((item: any) => {
115
+ return {
116
+ value: item.code,
117
+ label: item.fieldMap[treeConfigs.primaryColumnId2],
118
+ }
119
+ }),
120
+ ],
121
+ )
122
+ }
123
+ else {
124
+ finish()
125
+ }
126
+ }
127
+ catch (error) {
128
+ console.log('error:', error)
129
+ finish(false)
130
+ // TODO handle the exception
131
+ }
132
+ }
133
+
134
+ function handleConfirm(selectedItems: any) {
135
+ console.log(selectedItems)
136
+ emits('update:modelValue', [selectedItems[selectedItems.length - 1]])
137
+ }
138
+ // 格式化方法
139
+ function displayFormat(selectedItems: Record<string, any>[]) {
140
+ return selectedItems[selectedItems.length - 1]?.label
141
+ }
142
+ </script>
143
+
144
+ <template>
145
+ <view>
146
+ <wd-col-picker
147
+ :use-default-slot="true"
148
+ :model-value="dataValue"
149
+ :columns="columns"
150
+ :column-change="columnChange"
151
+ :display-format="displayFormat"
152
+ :style="{ pointerEvents: props.readonly ? '' : 'none' }"
153
+ @confirm="handleConfirm"
154
+ >
155
+ <wd-input
156
+
157
+ type="text"
158
+ model-value=""
159
+ :prop="props.prop"
160
+ :placeholder="props.placeholder"
161
+ :label-width="props.labelWidth"
162
+ :label="props.label"
163
+ :readonly="true"
164
+ :clearable="false"
165
+ />
166
+ </wd-col-picker>
167
+ </view>
168
+ </template>