@tplc/business 0.7.51 → 0.7.52

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,30 @@
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.7.52](https://gitlab888.30jia.com.cn/tourism-front/zero-code-pro/compare/v0.7.48...v0.7.52) (2026-01-07)
6
+
7
+
8
+ ### ♻️ Code Refactoring | 代码重构
9
+
10
+ * **lcb-area:** update comparison logic to use compareType prop for improved clarity ([525e606](https://gitlab888.30jia.com.cn/tourism-front/zero-code-pro/commit/525e606ba08288fc1f048a68208575214cf8f274))
11
+
12
+
13
+ ### ✨ Features | 新功能
14
+
15
+ * **lcb-block:** add styleKey to dynamic options and update style handling for improved flexibility ([014469d](https://gitlab888.30jia.com.cn/tourism-front/zero-code-pro/commit/014469da25766f682cff0d63a932b82504f41d7d))
16
+
17
+
18
+ ### 🚀 Chore | 构建/工程依赖/工具
19
+
20
+ * **release:** 0.7.49 ([173d24d](https://gitlab888.30jia.com.cn/tourism-front/zero-code-pro/commit/173d24dc7bcdc7c3112db232ac14c3509232cd89))
21
+ * **release:** 0.7.50 ([c6f5712](https://gitlab888.30jia.com.cn/tourism-front/zero-code-pro/commit/c6f5712c7bf9558a6336a148f15a4ba225d11104))
22
+ * **release:** 0.7.51 ([4acced8](https://gitlab888.30jia.com.cn/tourism-front/zero-code-pro/commit/4acced89cd89f3105b4797644ad7feefab55aa09))
23
+
24
+
25
+ ### 🐛 Bug Fixes | Bug 修复
26
+
27
+ * **lcb-area:** set default value for compareValues function to prevent potential errors ([4e5e48a](https://gitlab888.30jia.com.cn/tourism-front/zero-code-pro/commit/4e5e48a373ba00e491c5cd002da5792e57006aec))
28
+
5
29
  ### [0.7.51](https://gitlab888.30jia.com.cn/tourism-front/zero-code-pro/compare/v0.7.50...v0.7.51) (2026-01-06)
6
30
 
7
31
 
@@ -48,24 +48,14 @@ const innerBackgroundColor = computed(() => {
48
48
  })
49
49
 
50
50
  const getInnerStyle = computed(() => {
51
- const innerStyle = props.dynamicStyleOptions?.reduce(
52
- (acc, { styleKey }) => {
53
- if (styleKey) {
54
- const currentOptions = props.dynamicStyleOptions?.[styleKey]
55
- const data = get(
56
- currentOptions?.keyFrom === 'user' ? userStore?.userInfo : innerDynamicData.value,
57
- currentOptions?.dynamicKey || '',
58
- )
59
- if (data) {
60
- acc[styleKey] = data
61
- }
62
- }
63
-
64
- return acc
65
- },
66
- {} as Record<string, string>,
67
- )
68
- return innerStyle
51
+ if (props.dynamicStyleOptions?.dynamicKey) {
52
+ const innerStyle = get(
53
+ props.dynamicStyleOptions?.keyFrom === 'user' ? userStore?.userInfo : innerDynamicData.value,
54
+ props.dynamicStyleOptions?.dynamicKey,
55
+ )
56
+ return innerStyle
57
+ }
58
+ return {}
69
59
  })
70
60
 
71
61
  // 缓存 padding 计算结果,减少 transformValueUnit 调用次数
@@ -57,7 +57,7 @@ export interface LcbBlockProps {
57
57
  | 'bottom-right'
58
58
 
59
59
  // 动态样式集合
60
- dynamicStyleOptions?: DynamicOptions[]
60
+ dynamicStyleOptions?: DynamicOptions
61
61
  dynamicBgImage?: string
62
62
  }
63
63
  export interface LcbBlockInnerProps extends LcbBlockProps {
@@ -1,19 +1,46 @@
1
1
  <template>
2
- <lcb-block v-bind="$props" :custom-style="listStyle" v-if="renderList.length">
3
- <view
4
- v-for="(item, index) in renderList"
5
- :key="getItemKey(item, index)"
6
- class="flex-shrink-0"
7
- :style="itemStyle"
2
+ <lcb-block
3
+ v-bind="$props"
4
+ :custom-style="listStyle"
5
+ v-if="props.pageProps?.pagingEnabled || renderList.length"
6
+ >
7
+ <z-paging
8
+ ref="paging"
9
+ :auto="false"
10
+ v-model="renderList"
11
+ @query="queryList"
12
+ :fixed="false"
13
+ :default-page-size="props.pageProps?.pageLimit"
14
+ :use-page-scroll="props.pageProps?.pagingUsePageScroll"
15
+ :height="props.pageProps?.pagingUsePageScroll ? undefined : props.pageProps?.pagingHeight"
16
+ v-if="props.pageProps?.pagingEnabled"
8
17
  >
9
- <slot :data="item" :list="list" />
10
- </view>
18
+ <view
19
+ v-for="(item, index) in renderList"
20
+ :key="getItemKey(item, index)"
21
+ class="flex-shrink-0"
22
+ :style="itemStyle"
23
+ >
24
+ <slot :data="item" :list="list" />
25
+ </view>
26
+ </z-paging>
27
+ <template v-else>
28
+ <view
29
+ v-for="(item, index) in renderList"
30
+ :key="getItemKey(item, index)"
31
+ class="flex-shrink-0"
32
+ :style="itemStyle"
33
+ >
34
+ <slot :data="item" :list="list" />
35
+ </view>
36
+ </template>
11
37
  </lcb-block>
12
38
  </template>
13
39
 
14
40
  <script setup lang="ts">
15
41
  import { transformValueUnit } from '@tplc/business/utils/transform'
16
- import { computed, watch, shallowRef } from 'vue'
42
+ import { computed, watch, shallowRef, ref } from 'vue'
43
+ import useZPaging from 'z-paging/components/z-paging/js/hooks/useZPaging'
17
44
  import useDynamicData from '../../hooks/useDynamicData'
18
45
  import { dynamicRequest } from '../../utils/request'
19
46
  import { LcbWrapperListProps } from './types'
@@ -28,10 +55,19 @@ defineOptions({
28
55
  const props = withDefaults(defineProps<LcbWrapperListProps>(), {
29
56
  display: 'flex',
30
57
  flexDirection: 'column',
58
+ pagingEnabled: false,
59
+ pageLimit: 10,
60
+ pagingUsePageScroll: true,
31
61
  })
32
62
  const { userStore, innerDynamicData } = useDynamicData()
33
63
  // 使用 shallowRef 优化大数组的响应式性能
34
64
  const renderList = shallowRef<unknown[]>([])
65
+ const paging = ref()
66
+ useZPaging(paging)
67
+ const pageSearch = shallowRef<{ limit: number; page: number }>({
68
+ limit: props.pageLimit,
69
+ page: 1,
70
+ })
35
71
 
36
72
  // 优化:检查是否需要转换,避免不必要的遍历
37
73
  const transformStringArrayToObjectArray = (data: unknown[]): unknown[] => {
@@ -47,10 +83,38 @@ const transformStringArrayToObjectArray = (data: unknown[]): unknown[] => {
47
83
  })
48
84
  }
49
85
 
86
+ const queryList = async (page: number, limit: number) => {
87
+ pageSearch.value = { page, limit }
88
+ const { data } = await dynamicRequest(
89
+ props.dataSource,
90
+ innerDynamicData.value,
91
+ userStore?.userInfo,
92
+ {
93
+ pageSearch: pageSearch.value,
94
+ },
95
+ )
96
+ paging.value?.complete?.(data)
97
+ }
98
+
50
99
  watch(
51
- () => [props.dataSource, innerDynamicData.value, userStore?.userInfo] as const,
100
+ () =>
101
+ [
102
+ props.dataSource,
103
+ innerDynamicData.value,
104
+ userStore?.userInfo,
105
+ props.pageProps?.pagingEnabled,
106
+ props.pageProps?.pageLimit,
107
+ ] as const,
52
108
 
53
- async ([dataSource, dynamicData, userInfo]) => {
109
+ async ([dataSource, dynamicData, userInfo, pagingEnabled, pageLimit = 10]) => {
110
+ if (pagingEnabled) {
111
+ pageSearch.value = {
112
+ limit: pageLimit,
113
+ page: 1,
114
+ }
115
+ paging.value?.reload?.()
116
+ return
117
+ }
54
118
  // 防止重复请求
55
119
  let data: unknown[] = []
56
120
  const result = await dynamicRequest(dataSource, dynamicData, userInfo)
@@ -11,4 +11,22 @@ export interface LcbWrapperListProps extends LcbBlockProps {
11
11
  scrollX?: boolean
12
12
  list?: LcbAreaProps[]
13
13
  childrenAutoWidth?: boolean
14
+ pageProps: {
15
+ /**
16
+ * 开启下拉刷新+上拉加载(基于 z-paging)
17
+ */
18
+ pagingEnabled?: boolean
19
+ /**
20
+ * 分页大小,对应 pageSearch.limit,默认 10
21
+ */
22
+ pageLimit?: number
23
+ /**
24
+ * z-paging 是否使用页面滚动模式,默认 true
25
+ */
26
+ pagingUsePageScroll?: boolean
27
+ /**
28
+ * 非页面滚动模式下的高度(pagingUsePageScroll=false 时生效)
29
+ */
30
+ pagingHeight?: string
31
+ }
14
32
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tplc/business",
3
- "version": "0.7.51",
3
+ "version": "0.7.52",
4
4
  "keywords": [
5
5
  "业务组件"
6
6
  ],
@@ -54,7 +54,7 @@ export interface LcbBlockProps {
54
54
  | 'bottom-left'
55
55
  | 'bottom-center'
56
56
  | 'bottom-right'
57
- dynamicStyleOptions?: DynamicOptions[]
57
+ dynamicStyleOptions?: DynamicOptions
58
58
  dynamicBgImage?: string
59
59
  }
60
60
  export interface LcbBlockInnerProps extends LcbBlockProps {
@@ -66,7 +66,7 @@ declare const __VLS_component: import('vue').DefineComponent<
66
66
  | 'bottom-left'
67
67
  | 'bottom-center'
68
68
  | 'bottom-right'
69
- dynamicStyleOptions: import('../../action').DynamicOptions[]
69
+ dynamicStyleOptions: import('../../action').DynamicOptions
70
70
  dynamicBgImage: string
71
71
  gap: number
72
72
  imageWidth: number
@@ -1,6 +1,7 @@
1
1
  import { LcbWrapperListProps } from './types'
2
2
  declare function __VLS_template(): {
3
3
  default?(_: { data: unknown; list: import('../lcb-area/types').LcbAreaProps[] | undefined }): any
4
+ default?(_: { data: unknown; list: import('../lcb-area/types').LcbAreaProps[] | undefined }): any
4
5
  }
5
6
  declare const __VLS_component: import('vue').DefineComponent<
6
7
  __VLS_WithDefaults<
@@ -8,6 +9,9 @@ declare const __VLS_component: import('vue').DefineComponent<
8
9
  {
9
10
  display: string
10
11
  flexDirection: string
12
+ pagingEnabled: boolean
13
+ pageLimit: number
14
+ pagingUsePageScroll: boolean
11
15
  }
12
16
  >,
13
17
  {},
@@ -26,6 +30,9 @@ declare const __VLS_component: import('vue').DefineComponent<
26
30
  {
27
31
  display: string
28
32
  flexDirection: string
33
+ pagingEnabled: boolean
34
+ pageLimit: number
35
+ pagingUsePageScroll: boolean
29
36
  }
30
37
  >
31
38
  >
@@ -11,4 +11,22 @@ export interface LcbWrapperListProps extends LcbBlockProps {
11
11
  scrollX?: boolean
12
12
  list?: LcbAreaProps[]
13
13
  childrenAutoWidth?: boolean
14
+ pageProps: {
15
+ /**
16
+ * 开启下拉刷新+上拉加载(基于 z-paging)
17
+ */
18
+ pagingEnabled?: boolean
19
+ /**
20
+ * 分页大小,对应 pageSearch.limit,默认 10
21
+ */
22
+ pageLimit?: number
23
+ /**
24
+ * z-paging 是否使用页面滚动模式,默认 true
25
+ */
26
+ pagingUsePageScroll?: boolean
27
+ /**
28
+ * 非页面滚动模式下的高度(pagingUsePageScroll=false 时生效)
29
+ */
30
+ pagingHeight?: string
31
+ }
14
32
  }
@@ -3,4 +3,5 @@ export declare const dynamicRequest: (
3
3
  dataSource?: DataSource,
4
4
  pageInfo?: Record<string, any>,
5
5
  userInfo?: Record<string, any>,
6
+ extraParams?: Record<string, any>,
6
7
  ) => Promise<any>
package/utils/request.ts CHANGED
@@ -5,12 +5,17 @@ export const dynamicRequest = async (
5
5
  dataSource?: DataSource,
6
6
  pageInfo?: Record<string, any>,
7
7
  userInfo?: Record<string, any>,
8
+ extraParams?: Record<string, any>,
8
9
  ) => {
9
10
  if (dataSource?.source === 'remote') {
10
11
  if (dataSource.requestInfo?.requestUrl) {
12
+ const baseParams = JSON.parse(dataSource.requestInfo.requestParams || '{}')
11
13
  const response = await uni.$lcb.http.post(
12
14
  dataSource.requestInfo.requestUrl,
13
- JSON.parse(dataSource.requestInfo.requestParams || '{}'),
15
+ {
16
+ ...baseParams,
17
+ ...(extraParams || {}),
18
+ },
14
19
  )
15
20
  /** 如果依赖key存在,则取依赖key的值 */
16
21
  return response[dataSource?.dependKey || 'data'] as unknown