@tplc/wot 0.1.64 → 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 CHANGED
@@ -2,6 +2,8 @@
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
+
5
7
  ### [0.1.64](http://gitlab888.30jia.com.cn/bhBank/zero-code-pro/compare/v0.3.75...v0.1.64) (2025-03-10)
6
8
 
7
9
 
@@ -13,10 +13,8 @@ export type SelectPickerType = 'checkbox' | 'radio' | 'button'
13
13
  export type SelectPickerRemote = {
14
14
  action: (
15
15
  search: string,
16
- params: { pageNum: number; pageSize: number },
16
+ params: { pageSearch: { page: number; limit: number } },
17
17
  ) => Promise<Record<string, any>[]>
18
- valueKey?: string
19
- labelKey?: string
20
18
  pageSize?: number
21
19
  isPage?: boolean
22
20
  }
@@ -107,6 +105,8 @@ export const selectPickerProps = {
107
105
  customValueClass: makeStringProp(''),
108
106
  /** 是否显示确认按钮(radio类型生效),默认值为:true */
109
107
  showConfirm: makeBooleanProp(true),
108
+ /** 默认展示文案 */
109
+ defaultLabel: String,
110
110
  }
111
111
  export type SelectPickerProps = ExtractPropTypes<typeof selectPickerProps>
112
112
 
@@ -58,6 +58,7 @@
58
58
  :placeholder="filterPlaceholder || translate('filterPlaceholder')"
59
59
  hide-cancel
60
60
  placeholder-left
61
+ @search="handleFilterSearch"
61
62
  @change="handleFilterChange"
62
63
  />
63
64
 
@@ -146,7 +147,7 @@
146
147
  :id="'radio' + item[valueKey]"
147
148
  >
148
149
  <wd-radio :value="item[valueKey]" :disabled="item.disabled">
149
- <block v-if="filterable && filterVal">
150
+ <block v-if="filterable && filterVal && !remoteConfig">
150
151
  <block v-for="text in item[labelKey]" :key="text.label">
151
152
  <text
152
153
  :clsss="`${text.type === 'active' ? 'wd-select-picker__text-active' : ''}`"
@@ -191,7 +192,7 @@ export default {
191
192
  </script>
192
193
 
193
194
  <script lang="ts" setup>
194
- import { getCurrentInstance, onBeforeMount, ref, watch, nextTick, computed } from 'vue'
195
+ import { getCurrentInstance, onBeforeMount, ref, watch, nextTick, computed, watchEffect } from 'vue'
195
196
  import { useCell } from '../composables/useCell'
196
197
  import { getRect, isArray, isDef, isFunction, requestAnimationFrame } from '../common/util'
197
198
  import { useParent } from '../composables/useParent'
@@ -215,34 +216,50 @@ const cell = useCell()
215
216
  const pageNum = ref<number>(1)
216
217
  const noMore = ref<boolean>(false)
217
218
  const innerLoading = ref<boolean>(false)
218
- const innerColumns = ref<Array<Record<string, any>>>([])
219
- const showValue = computed(() => {
219
+ const currentColumns = ref<Record<string, any>>()
220
+ const showValue = ref<string>('')
221
+
222
+ watchEffect(() => {
220
223
  const value = valueFormat(props.modelValue)
221
- let showValueTemp: string = ''
222
224
 
223
225
  if (props.displayFormat) {
224
- showValueTemp = props.displayFormat(value, props.columns)
226
+ showValue.value = props.displayFormat(value, props.columns || filterColumns.value)
225
227
  } else {
226
228
  const { type, labelKey } = props
227
229
  if (type === 'checkbox') {
228
230
  const selectedItems = (isArray(value) ? value : []).map((item) => {
229
231
  return getSelectedItem(item)
230
232
  })
231
- showValueTemp = selectedItems
233
+ showValue.value = selectedItems
232
234
  .map((item) => {
233
235
  return item[labelKey]
234
236
  })
235
237
  .join(', ')
236
238
  } else if (type === 'radio') {
237
239
  const selectedItem = getSelectedItem(value as string | number | boolean)
238
- showValueTemp = selectedItem[labelKey]
240
+ showValue.value = selectedItem[labelKey] || currentColumns.value?.[labelKey]
241
+ if (selectedItem[labelKey]) {
242
+ currentColumns.value = selectedItem
243
+ }
239
244
  } else {
240
- showValueTemp = value as string
245
+ showValue.value = value as string
241
246
  }
242
247
  }
243
- return showValueTemp
244
248
  })
245
-
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
+ )
246
263
  watch(
247
264
  () => props.modelValue,
248
265
  (newValue) => {
@@ -328,18 +345,17 @@ const isRequired = computed(() => {
328
345
  /** 获取远程数据 */
329
346
  const getRemoteData = async () => {
330
347
  innerLoading.value = true
331
- const res = await props.remoteConfig?.action(filterVal.value, {
332
- pageNum: pageNum.value,
333
- pageSize: props.remoteConfig?.pageSize || 10,
348
+ const list = await props.remoteConfig?.action(filterVal.value, {
349
+ pageSearch: {
350
+ page: pageNum.value,
351
+ limit: props.remoteConfig?.pageSize || 10,
352
+ },
334
353
  })
335
354
 
336
- if (res) {
337
- if (res.length) {
338
- pageNum.value++
339
- innerColumns.value = [...innerColumns.value, ...res]
340
- } else {
341
- noMore.value = true
342
- }
355
+ if (list) {
356
+ filterColumns.value = pageNum.value === 1 ? list : [...filterColumns.value, ...list]
357
+ pageNum.value++
358
+ noMore.value = !list.length
343
359
  }
344
360
  innerLoading.value = false
345
361
  }
@@ -349,9 +365,10 @@ const handleScrollToLower = () => {
349
365
  }
350
366
  onBeforeMount(() => {
351
367
  selectList.value = valueFormat(props.modelValue)
352
- filterColumns.value = props.columns
353
368
  if (props.remoteConfig) {
354
369
  getRemoteData()
370
+ } else {
371
+ filterColumns.value = props.columns
355
372
  }
356
373
  })
357
374
 
@@ -410,8 +427,8 @@ function noop() {}
410
427
 
411
428
  function getSelectedItem(value: string | number | boolean) {
412
429
  const { valueKey, labelKey, columns } = props
413
-
414
- const selecteds = columns.filter((item) => {
430
+ const list = columns.length > 0 ? columns : filterColumns.value
431
+ const selecteds = list.filter((item) => {
415
432
  return item[valueKey] === value
416
433
  })
417
434
 
@@ -507,6 +524,9 @@ function getFilterText(label: string, filterVal: string) {
507
524
  }
508
525
 
509
526
  function handleFilterChange({ value }: { value: string }) {
527
+ if (props.remoteConfig) {
528
+ return
529
+ }
510
530
  if (value === '') {
511
531
  filterColumns.value = []
512
532
  filterVal.value = value
@@ -519,6 +539,14 @@ function handleFilterChange({ value }: { value: string }) {
519
539
  }
520
540
  }
521
541
 
542
+ function handleFilterSearch(value: string) {
543
+ if (!props.remoteConfig) {
544
+ return
545
+ }
546
+ pageNum.value = 1
547
+ getRemoteData()
548
+ }
549
+
522
550
  function formatFilterColumns(columns: Record<string, any>[], filterVal: string) {
523
551
  const filterColumnsTemp = columns.filter((item) => {
524
552
  return item[props.labelKey].indexOf(filterVal) > -1
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "id": "@tplc/wot",
3
3
  "name": "@tplc/wot",
4
- "version": "0.1.64",
4
+ "version": "0.1.65",
5
5
  "keywords": [
6
6
  "wot-design-uni",
7
7
  "国际化",
@@ -5,12 +5,12 @@ export type SelectPickerRemote = {
5
5
  action: (
6
6
  search: string,
7
7
  params: {
8
- pageNum: number
9
- pageSize: number
8
+ pageSearch: {
9
+ page: number
10
+ limit: number
11
+ }
10
12
  },
11
13
  ) => Promise<Record<string, any>[]>
12
- valueKey?: string
13
- labelKey?: string
14
14
  pageSize?: number
15
15
  isPage?: boolean
16
16
  }
@@ -178,6 +178,8 @@ export declare const selectPickerProps: {
178
178
  type: BooleanConstructor
179
179
  default: boolean
180
180
  }
181
+ /** 默认展示文案 */
182
+ defaultLabel: StringConstructor
181
183
  customStyle: {
182
184
  type: PropType<string>
183
185
  default: string
@@ -125,6 +125,7 @@ declare const _default: __VLS_WithTemplateSlots<
125
125
  type: BooleanConstructor
126
126
  default: boolean
127
127
  }
128
+ defaultLabel: StringConstructor
128
129
  customStyle: {
129
130
  type: import('vue').PropType<string>
130
131
  default: string
@@ -278,6 +279,7 @@ declare const _default: __VLS_WithTemplateSlots<
278
279
  type: BooleanConstructor
279
280
  default: boolean
280
281
  }
282
+ defaultLabel: StringConstructor
281
283
  customStyle: {
282
284
  type: import('vue').PropType<string>
283
285
  default: string