@tplc/wot 0.1.63 → 0.1.65
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/CHANGELOG.md +15 -0
- package/components/wd-select-picker/index.scss +13 -0
- package/components/wd-select-picker/types.ts +14 -0
- package/components/wd-select-picker/wd-select-picker.vue +74 -13
- package/package.json +1 -1
- package/types/components/wd-select-picker/types.d.ts +19 -0
- package/types/components/wd-select-picker/wd-select-picker.vue.d.ts +8 -0
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,21 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
|
|
4
4
|
|
|
5
|
+
### [0.1.65](http://gitlab888.30jia.com.cn/bhBank/zero-code-pro/compare/v0.1.64...v0.1.65) (2025-03-10)
|
|
6
|
+
|
|
7
|
+
### [0.1.64](http://gitlab888.30jia.com.cn/bhBank/zero-code-pro/compare/v0.3.75...v0.1.64) (2025-03-10)
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
### 🚀 Chore | 构建/工程依赖/工具
|
|
11
|
+
|
|
12
|
+
* **release:** 0.1.63 ([6286500](http://gitlab888.30jia.com.cn/bhBank/zero-code-pro/commit/6286500e9cf7b2096ea980ecc69949324cf12859))
|
|
13
|
+
* **release:** 0.3.76 ([74cab95](http://gitlab888.30jia.com.cn/bhBank/zero-code-pro/commit/74cab959ceab17fcc46662bd9bdc9e219e551547))
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
### ✨ Features | 新功能
|
|
17
|
+
|
|
18
|
+
* 支持banner 底部 ([1e0b38c](http://gitlab888.30jia.com.cn/bhBank/zero-code-pro/commit/1e0b38ccba18240f4b18f78a84e0810ae8b67460))
|
|
19
|
+
|
|
5
20
|
### [0.1.63](http://gitlab888.30jia.com.cn/bhBank/zero-code-pro/compare/v0.3.76...v0.1.63) (2025-03-10)
|
|
6
21
|
|
|
7
22
|
### [0.1.62](http://gitlab888.30jia.com.cn/bhBank/zero-code-pro/compare/v0.3.57...v0.1.62) (2025-02-24)
|
|
@@ -146,6 +146,19 @@
|
|
|
146
146
|
justify-content: center;
|
|
147
147
|
background: $-picker-loading-bg;
|
|
148
148
|
}
|
|
149
|
+
@include e(no-more) {
|
|
150
|
+
text-align: center;
|
|
151
|
+
color: $-cell-arrow-color;
|
|
152
|
+
padding: 24rpx 0;
|
|
153
|
+
font-size: 28rpx;
|
|
154
|
+
}
|
|
155
|
+
@include e(innerLoading) {
|
|
156
|
+
display: flex;
|
|
157
|
+
align-items: center;
|
|
158
|
+
justify-content: center;
|
|
159
|
+
background: $-picker-loading-bg;
|
|
160
|
+
padding: 24rpx 0;
|
|
161
|
+
}
|
|
149
162
|
// selectPiceker多出的样式
|
|
150
163
|
@include edeep(header) {
|
|
151
164
|
height: 72px;
|
|
@@ -10,6 +10,14 @@ import {
|
|
|
10
10
|
import type { FormItemRule } from '../wd-form/types'
|
|
11
11
|
|
|
12
12
|
export type SelectPickerType = 'checkbox' | 'radio' | 'button'
|
|
13
|
+
export type SelectPickerRemote = {
|
|
14
|
+
action: (
|
|
15
|
+
search: string,
|
|
16
|
+
params: { pageSearch: { page: number; limit: number } },
|
|
17
|
+
) => Promise<Record<string, any>[]>
|
|
18
|
+
pageSize?: number
|
|
19
|
+
isPage?: boolean
|
|
20
|
+
}
|
|
13
21
|
|
|
14
22
|
export const selectPickerProps = {
|
|
15
23
|
...baseProps,
|
|
@@ -75,6 +83,10 @@ export const selectPickerProps = {
|
|
|
75
83
|
safeAreaInsetBottom: makeBooleanProp(true),
|
|
76
84
|
/** 可搜索(目前只支持本地搜索) */
|
|
77
85
|
filterable: makeBooleanProp(false),
|
|
86
|
+
/** 远程搜索配置 */
|
|
87
|
+
remoteConfig: {
|
|
88
|
+
type: Object as PropType<SelectPickerRemote>,
|
|
89
|
+
},
|
|
78
90
|
/** 搜索框占位符 */
|
|
79
91
|
filterPlaceholder: String,
|
|
80
92
|
/** 是否超出隐藏 */
|
|
@@ -93,6 +105,8 @@ export const selectPickerProps = {
|
|
|
93
105
|
customValueClass: makeStringProp(''),
|
|
94
106
|
/** 是否显示确认按钮(radio类型生效),默认值为:true */
|
|
95
107
|
showConfirm: makeBooleanProp(true),
|
|
108
|
+
/** 默认展示文案 */
|
|
109
|
+
defaultLabel: String,
|
|
96
110
|
}
|
|
97
111
|
export type SelectPickerProps = ExtractPropTypes<typeof selectPickerProps>
|
|
98
112
|
|
|
@@ -58,13 +58,16 @@
|
|
|
58
58
|
:placeholder="filterPlaceholder || translate('filterPlaceholder')"
|
|
59
59
|
hide-cancel
|
|
60
60
|
placeholder-left
|
|
61
|
+
@search="handleFilterSearch"
|
|
61
62
|
@change="handleFilterChange"
|
|
62
63
|
/>
|
|
64
|
+
|
|
63
65
|
<scroll-view
|
|
64
66
|
:class="`wd-select-picker__wrapper ${filterable ? 'is-filterable' : ''} ${loading ? 'is-loading' : ''} ${customContentClass}`"
|
|
65
67
|
:scroll-y="!loading"
|
|
66
68
|
:scroll-top="scrollTop"
|
|
67
69
|
:scroll-with-animation="true"
|
|
70
|
+
@scrolltolower="handleScrollToLower"
|
|
68
71
|
>
|
|
69
72
|
<!-- 多选 -->
|
|
70
73
|
<view v-if="type === 'checkbox' && isArray(selectList)" id="wd-checkbox-group">
|
|
@@ -144,7 +147,7 @@
|
|
|
144
147
|
:id="'radio' + item[valueKey]"
|
|
145
148
|
>
|
|
146
149
|
<wd-radio :value="item[valueKey]" :disabled="item.disabled">
|
|
147
|
-
<block v-if="filterable && filterVal">
|
|
150
|
+
<block v-if="filterable && filterVal && !remoteConfig">
|
|
148
151
|
<block v-for="text in item[labelKey]" :key="text.label">
|
|
149
152
|
<text
|
|
150
153
|
:clsss="`${text.type === 'active' ? 'wd-select-picker__text-active' : ''}`"
|
|
@@ -163,6 +166,10 @@
|
|
|
163
166
|
<view v-if="loading" class="wd-select-picker__loading" @touchmove="noop">
|
|
164
167
|
<wd-loading :color="loadingColor" />
|
|
165
168
|
</view>
|
|
169
|
+
<view v-if="innerLoading" class="wd-select-picker__innerLoading">
|
|
170
|
+
<wd-loading :color="loadingColor" />
|
|
171
|
+
</view>
|
|
172
|
+
<view v-if="noMore" class="wd-select-picker__no-more">没有更多数据了</view>
|
|
166
173
|
</scroll-view>
|
|
167
174
|
<!-- 确认按钮 -->
|
|
168
175
|
<view v-if="showConfirm" class="wd-select-picker__footer">
|
|
@@ -185,7 +192,7 @@ export default {
|
|
|
185
192
|
</script>
|
|
186
193
|
|
|
187
194
|
<script lang="ts" setup>
|
|
188
|
-
import { getCurrentInstance, onBeforeMount, ref, watch, nextTick, computed } from 'vue'
|
|
195
|
+
import { getCurrentInstance, onBeforeMount, ref, watch, nextTick, computed, watchEffect } from 'vue'
|
|
189
196
|
import { useCell } from '../composables/useCell'
|
|
190
197
|
import { getRect, isArray, isDef, isFunction, requestAnimationFrame } from '../common/util'
|
|
191
198
|
import { useParent } from '../composables/useParent'
|
|
@@ -206,34 +213,53 @@ const filterVal = ref<string>('')
|
|
|
206
213
|
const filterColumns = ref<Array<Record<string, any>>>([])
|
|
207
214
|
const scrollTop = ref<number | null>(0) // 滚动位置
|
|
208
215
|
const cell = useCell()
|
|
216
|
+
const pageNum = ref<number>(1)
|
|
217
|
+
const noMore = ref<boolean>(false)
|
|
218
|
+
const innerLoading = ref<boolean>(false)
|
|
219
|
+
const currentColumns = ref<Record<string, any>>()
|
|
220
|
+
const showValue = ref<string>('')
|
|
209
221
|
|
|
210
|
-
|
|
222
|
+
watchEffect(() => {
|
|
211
223
|
const value = valueFormat(props.modelValue)
|
|
212
|
-
let showValueTemp: string = ''
|
|
213
224
|
|
|
214
225
|
if (props.displayFormat) {
|
|
215
|
-
|
|
226
|
+
showValue.value = props.displayFormat(value, props.columns || filterColumns.value)
|
|
216
227
|
} else {
|
|
217
228
|
const { type, labelKey } = props
|
|
218
229
|
if (type === 'checkbox') {
|
|
219
230
|
const selectedItems = (isArray(value) ? value : []).map((item) => {
|
|
220
231
|
return getSelectedItem(item)
|
|
221
232
|
})
|
|
222
|
-
|
|
233
|
+
showValue.value = selectedItems
|
|
223
234
|
.map((item) => {
|
|
224
235
|
return item[labelKey]
|
|
225
236
|
})
|
|
226
237
|
.join(', ')
|
|
227
238
|
} else if (type === 'radio') {
|
|
228
239
|
const selectedItem = getSelectedItem(value as string | number | boolean)
|
|
229
|
-
|
|
240
|
+
showValue.value = selectedItem[labelKey] || currentColumns.value?.[labelKey]
|
|
241
|
+
if (selectedItem[labelKey]) {
|
|
242
|
+
currentColumns.value = selectedItem
|
|
243
|
+
}
|
|
230
244
|
} else {
|
|
231
|
-
|
|
245
|
+
showValue.value = value as string
|
|
232
246
|
}
|
|
233
247
|
}
|
|
234
|
-
return showValueTemp
|
|
235
248
|
})
|
|
236
|
-
|
|
249
|
+
watch(
|
|
250
|
+
() => props.defaultLabel,
|
|
251
|
+
(defaultLabel) => {
|
|
252
|
+
if (defaultLabel) {
|
|
253
|
+
currentColumns.value = {
|
|
254
|
+
[props.valueKey]: props.modelValue,
|
|
255
|
+
[props.labelKey]: defaultLabel,
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
},
|
|
259
|
+
{
|
|
260
|
+
immediate: true,
|
|
261
|
+
},
|
|
262
|
+
)
|
|
237
263
|
watch(
|
|
238
264
|
() => props.modelValue,
|
|
239
265
|
(newValue) => {
|
|
@@ -316,10 +342,34 @@ const isRequired = computed(() => {
|
|
|
316
342
|
}
|
|
317
343
|
return props.required || props.rules.some((rule) => rule.required) || formRequired
|
|
318
344
|
})
|
|
345
|
+
/** 获取远程数据 */
|
|
346
|
+
const getRemoteData = async () => {
|
|
347
|
+
innerLoading.value = true
|
|
348
|
+
const list = await props.remoteConfig?.action(filterVal.value, {
|
|
349
|
+
pageSearch: {
|
|
350
|
+
page: pageNum.value,
|
|
351
|
+
limit: props.remoteConfig?.pageSize || 10,
|
|
352
|
+
},
|
|
353
|
+
})
|
|
319
354
|
|
|
355
|
+
if (list) {
|
|
356
|
+
filterColumns.value = pageNum.value === 1 ? list : [...filterColumns.value, ...list]
|
|
357
|
+
pageNum.value++
|
|
358
|
+
noMore.value = !list.length
|
|
359
|
+
}
|
|
360
|
+
innerLoading.value = false
|
|
361
|
+
}
|
|
362
|
+
const handleScrollToLower = () => {
|
|
363
|
+
if (noMore.value || innerLoading.value || !props.remoteConfig?.isPage) return
|
|
364
|
+
getRemoteData()
|
|
365
|
+
}
|
|
320
366
|
onBeforeMount(() => {
|
|
321
367
|
selectList.value = valueFormat(props.modelValue)
|
|
322
|
-
|
|
368
|
+
if (props.remoteConfig) {
|
|
369
|
+
getRemoteData()
|
|
370
|
+
} else {
|
|
371
|
+
filterColumns.value = props.columns
|
|
372
|
+
}
|
|
323
373
|
})
|
|
324
374
|
|
|
325
375
|
const { proxy } = getCurrentInstance() as any
|
|
@@ -377,8 +427,8 @@ function noop() {}
|
|
|
377
427
|
|
|
378
428
|
function getSelectedItem(value: string | number | boolean) {
|
|
379
429
|
const { valueKey, labelKey, columns } = props
|
|
380
|
-
|
|
381
|
-
const selecteds =
|
|
430
|
+
const list = columns.length > 0 ? columns : filterColumns.value
|
|
431
|
+
const selecteds = list.filter((item) => {
|
|
382
432
|
return item[valueKey] === value
|
|
383
433
|
})
|
|
384
434
|
|
|
@@ -474,6 +524,9 @@ function getFilterText(label: string, filterVal: string) {
|
|
|
474
524
|
}
|
|
475
525
|
|
|
476
526
|
function handleFilterChange({ value }: { value: string }) {
|
|
527
|
+
if (props.remoteConfig) {
|
|
528
|
+
return
|
|
529
|
+
}
|
|
477
530
|
if (value === '') {
|
|
478
531
|
filterColumns.value = []
|
|
479
532
|
filterVal.value = value
|
|
@@ -486,6 +539,14 @@ function handleFilterChange({ value }: { value: string }) {
|
|
|
486
539
|
}
|
|
487
540
|
}
|
|
488
541
|
|
|
542
|
+
function handleFilterSearch(value: string) {
|
|
543
|
+
if (!props.remoteConfig) {
|
|
544
|
+
return
|
|
545
|
+
}
|
|
546
|
+
pageNum.value = 1
|
|
547
|
+
getRemoteData()
|
|
548
|
+
}
|
|
549
|
+
|
|
489
550
|
function formatFilterColumns(columns: Record<string, any>[], filterVal: string) {
|
|
490
551
|
const filterColumnsTemp = columns.filter((item) => {
|
|
491
552
|
return item[props.labelKey].indexOf(filterVal) > -1
|
package/package.json
CHANGED
|
@@ -1,6 +1,19 @@
|
|
|
1
1
|
import type { ComponentPublicInstance, ExtractPropTypes, PropType } from 'vue'
|
|
2
2
|
import type { FormItemRule } from '../wd-form/types'
|
|
3
3
|
export type SelectPickerType = 'checkbox' | 'radio' | 'button'
|
|
4
|
+
export type SelectPickerRemote = {
|
|
5
|
+
action: (
|
|
6
|
+
search: string,
|
|
7
|
+
params: {
|
|
8
|
+
pageSearch: {
|
|
9
|
+
page: number
|
|
10
|
+
limit: number
|
|
11
|
+
}
|
|
12
|
+
},
|
|
13
|
+
) => Promise<Record<string, any>[]>
|
|
14
|
+
pageSize?: number
|
|
15
|
+
isPage?: boolean
|
|
16
|
+
}
|
|
4
17
|
export declare const selectPickerProps: {
|
|
5
18
|
/** 选择器左侧文案 */
|
|
6
19
|
label: StringConstructor
|
|
@@ -122,6 +135,10 @@ export declare const selectPickerProps: {
|
|
|
122
135
|
type: BooleanConstructor
|
|
123
136
|
default: boolean
|
|
124
137
|
}
|
|
138
|
+
/** 远程搜索配置 */
|
|
139
|
+
remoteConfig: {
|
|
140
|
+
type: PropType<SelectPickerRemote>
|
|
141
|
+
}
|
|
125
142
|
/** 搜索框占位符 */
|
|
126
143
|
filterPlaceholder: StringConstructor
|
|
127
144
|
/** 是否超出隐藏 */
|
|
@@ -161,6 +178,8 @@ export declare const selectPickerProps: {
|
|
|
161
178
|
type: BooleanConstructor
|
|
162
179
|
default: boolean
|
|
163
180
|
}
|
|
181
|
+
/** 默认展示文案 */
|
|
182
|
+
defaultLabel: StringConstructor
|
|
164
183
|
customStyle: {
|
|
165
184
|
type: PropType<string>
|
|
166
185
|
default: string
|
|
@@ -92,6 +92,9 @@ declare const _default: __VLS_WithTemplateSlots<
|
|
|
92
92
|
type: BooleanConstructor
|
|
93
93
|
default: boolean
|
|
94
94
|
}
|
|
95
|
+
remoteConfig: {
|
|
96
|
+
type: import('vue').PropType<import('./types').SelectPickerRemote>
|
|
97
|
+
}
|
|
95
98
|
filterPlaceholder: StringConstructor
|
|
96
99
|
ellipsis: {
|
|
97
100
|
type: BooleanConstructor
|
|
@@ -122,6 +125,7 @@ declare const _default: __VLS_WithTemplateSlots<
|
|
|
122
125
|
type: BooleanConstructor
|
|
123
126
|
default: boolean
|
|
124
127
|
}
|
|
128
|
+
defaultLabel: StringConstructor
|
|
125
129
|
customStyle: {
|
|
126
130
|
type: import('vue').PropType<string>
|
|
127
131
|
default: string
|
|
@@ -242,6 +246,9 @@ declare const _default: __VLS_WithTemplateSlots<
|
|
|
242
246
|
type: BooleanConstructor
|
|
243
247
|
default: boolean
|
|
244
248
|
}
|
|
249
|
+
remoteConfig: {
|
|
250
|
+
type: import('vue').PropType<import('./types').SelectPickerRemote>
|
|
251
|
+
}
|
|
245
252
|
filterPlaceholder: StringConstructor
|
|
246
253
|
ellipsis: {
|
|
247
254
|
type: BooleanConstructor
|
|
@@ -272,6 +279,7 @@ declare const _default: __VLS_WithTemplateSlots<
|
|
|
272
279
|
type: BooleanConstructor
|
|
273
280
|
default: boolean
|
|
274
281
|
}
|
|
282
|
+
defaultLabel: StringConstructor
|
|
275
283
|
customStyle: {
|
|
276
284
|
type: import('vue').PropType<string>
|
|
277
285
|
default: string
|