wui-components-v2 1.2.33 → 1.2.35

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.
@@ -16,19 +16,32 @@ const emit = defineEmits<{
16
16
  (e: 'click'): void
17
17
  }>()
18
18
 
19
- const props = defineProps<{
20
- columns: Columns[]
21
- collapseNum?: number
22
- primaryColumn?: Columns
23
- secondColumn?: Columns
24
- labelColumn?: Columns
25
- data: Entities
26
- model: FoldCardModel
27
- sourceId: string
28
- groups: Groups
29
- enumColumn?: Enums
30
- index: number
31
- }>()
19
+ const props = withDefaults(
20
+ defineProps<{
21
+ columns: Columns[]
22
+ collapseNum?: number
23
+ primaryColumn?: Columns
24
+ secondColumn?: Columns
25
+ labelColumn?: Columns
26
+ data: Entities
27
+ model: FoldCardModel
28
+ sourceId: string
29
+ groups: Groups
30
+ enumColumn?: Enums
31
+ index: number
32
+ /**
33
+ * 是否显示详情弹窗(detailPopup),透传给 LabelValue。默认 true。
34
+ */
35
+ showDetailPopup?: boolean
36
+ /**
37
+ * 自定义详情按钮回调,透传给 LabelValue。showDetailPopup 为 false 时优先使用
38
+ */
39
+ detailButtonHandle?: (data: Entities) => void
40
+ }>(),
41
+ {
42
+ showDetailPopup: true,
43
+ }
44
+ )
32
45
  const contentRef = ref<any>()
33
46
  const { currentThemeColor } = useManualTheme()
34
47
  // 展示内容
@@ -143,12 +156,12 @@ function toggleCollapse(contentId: string) {
143
156
  <view class="mb-3">
144
157
  <!-- 订单信息 -->
145
158
  <view class="text-sm space-y-3">
146
- <LabelValue :exhibit-data="exhibitData" :data="data" :index="index" />
159
+ <LabelValue :exhibit-data="exhibitData" :data="data" :index="index" :show-detail-popup="showDetailPopup" :detail-button-handle="detailButtonHandle" />
147
160
 
148
161
  <!-- 可折叠内容 -->
149
162
  <view :id="`${data.code}`" ref="contentRef">
150
163
  <view class="space-y-3">
151
- <LabelValue :exhibit-data="collapseData" :data="data" :index="index" />
164
+ <LabelValue :exhibit-data="collapseData" :data="data" :index="index" :show-detail-popup="showDetailPopup" :detail-button-handle="detailButtonHandle" />
152
165
  </view>
153
166
  </view>
154
167
  </view>
@@ -37,6 +37,10 @@ const props = withDefaults(
37
37
  * 是否显示详情弹窗(detailPopup),透传给 LabelValue。默认 true。
38
38
  */
39
39
  showDetailPopup?: boolean
40
+ /**
41
+ * 自定义详情按钮回调,透传给 LabelValue。showDetailPopup 为 false 时优先使用
42
+ */
43
+ detailButtonHandle?: (data: Entities) => void
40
44
  }>(),
41
45
  {
42
46
  // 标题旁标签默认不展示
@@ -182,12 +186,24 @@ function toggleCollapse(contentId: string) {
182
186
  <view class="mb-3">
183
187
  <!-- 订单信息 -->
184
188
  <view class="text-sm space-y-3">
185
- <LabelValue :exhibit-data="exhibitData" :data="data" :index="index" :show-detail-popup="showDetailPopup" />
189
+ <LabelValue
190
+ :exhibit-data="exhibitData"
191
+ :data="data"
192
+ :index="index"
193
+ :show-detail-popup="showDetailPopup"
194
+ :detail-button-handle="detailButtonHandle"
195
+ />
186
196
 
187
197
  <!-- 可折叠内容 -->
188
198
  <view class="fold-collapse" :class="expanded ? 'is-expanded' : 'is-collapsed'">
189
199
  <view class="space-y-3">
190
- <LabelValue :exhibit-data="collapseData" :data="data" :index="index" :show-detail-popup="showDetailPopup" />
200
+ <LabelValue
201
+ :exhibit-data="collapseData"
202
+ :data="data"
203
+ :index="index"
204
+ :show-detail-popup="showDetailPopup"
205
+ :detail-button-handle="detailButtonHandle"
206
+ />
191
207
  </view>
192
208
  </view>
193
209
  </view>
@@ -12,17 +12,26 @@ import detailPopup from '../detail-popup/detail-popup.vue'
12
12
  defineOptions({
13
13
  name: 'LabelValue',
14
14
  })
15
- const props = defineProps<{
16
- exhibitData: Columns[]
17
- data: Entities
18
- index: number
19
- /**
20
- * 是否显示详情弹窗(detailPopup)。默认 true。
21
- * 为 true 时:字段配置了 detail 按钮时显示可点击的 detailPopup 弹窗
22
- * 为 false 时:字段配置了 detail 按钮时仅显示「详情」文字,不可点击
23
- */
24
- showDetailPopup?: boolean
25
- }>()
15
+ const props = withDefaults(
16
+ defineProps<{
17
+ exhibitData: Columns[]
18
+ data: Entities
19
+ index: number
20
+ /**
21
+ * 是否显示详情弹窗(detailPopup)。默认 true。
22
+ * 为 true 时:字段配置了 detail 按钮时显示可点击的 detailPopup 弹窗
23
+ * 为 false 时:字段配置了 detail 按钮时显示可点击的文字,点击跳转详情页面
24
+ */
25
+ showDetailPopup?: boolean
26
+ /**
27
+ * 自定义详情按钮回调,showDetailPopup 为 false 时优先使用
28
+ */
29
+ detailButtonHandle?: (data: Entities) => void
30
+ }>(),
31
+ {
32
+ showDetailPopup: true,
33
+ }
34
+ )
26
35
  const { primary } = useManualTheme()
27
36
  const clums = computed(() => {
28
37
  return props.exhibitData.filter(item => !item.title?.includes('y'))
@@ -39,6 +48,31 @@ function isControlType(item: Columns): string {
39
48
  props.data.fieldMap?.[item.sourceId] || ''
40
49
  )
41
50
  }
51
+
52
+ /**
53
+ * 跳转详情页面(showDetailPopup 为 false 时触发)
54
+ * 参考 aldehyde-uniapp-template w-card.vue 的 goto('link', item, subItem) 逻辑
55
+ * 使用字段自身的 sourceId 和值的 code 进行跳转
56
+ */
57
+ function goDetail(item: Columns) {
58
+ if (props.detailButtonHandle) {
59
+ props.detailButtonHandle(props.data)
60
+ return
61
+ }
62
+ const rawValue = props.data.fieldMap[item.sourceId]
63
+ // 参考 w-card.vue:code 取 @R@ 前面的部分,如果包含 @,@ 则取第一段
64
+ let code = rawValue
65
+ if (typeof rawValue === 'string' && rawValue.includes('@R@')) {
66
+ code = rawValue.split('@R@')[0]
67
+ }
68
+ if (typeof rawValue === 'string' && rawValue.includes('@,@')) {
69
+ code = rawValue.split('@,@')[0]?.split('@R@')[0]
70
+ }
71
+ // 使用字段自身的 sourceId(参考 w-card.vue goto('link'))
72
+ uni.navigateTo({
73
+ url: `/pages/details-page/index?sourceId=${item.sourceId}&id=${code}&title=${item.title || ''}`,
74
+ })
75
+ }
42
76
  </script>
43
77
 
44
78
  <template>
@@ -136,14 +170,15 @@ function isControlType(item: Columns): string {
136
170
  {{ index + 1 }}
137
171
  </view>
138
172
  <view v-else-if="item.buttons?.includes('detail')" class="flex flex-1 items-center text-gray-800 dark:text-white">
139
- <template v-if="props.showDetailPopup !== false">
140
- <detailPopup
141
- :source="item"
142
- :text="formatItemData(data.fieldMap[item.sourceId], isControlType(item))"
143
- :code="data.fieldMap[item.sourceId]"
144
- />
145
- </template>
146
- <view>详情</view>
173
+ <detailPopup
174
+ v-if="props.showDetailPopup !== false"
175
+ :source="item"
176
+ :text="formatItemData(data.fieldMap[item.sourceId], isControlType(item))"
177
+ :code="data.fieldMap[item.sourceId]"
178
+ />
179
+ <view v-else class="text-[#1c64fd]" @click="goDetail(item)">
180
+ {{ formatItemData(data.fieldMap[item.sourceId], isControlType(item)) }}
181
+ </view>
147
182
  </view>
148
183
  <openValueMore v-else :text="formatItemData(data.fieldMap[item.sourceId], isControlType(item))" />
149
184
  </view>
@@ -10,6 +10,24 @@ import LabelValue from '../label-value/label-value.vue'
10
10
  defineOptions({
11
11
  name: 'WuiDetailsPage',
12
12
  })
13
+
14
+ const props = withDefaults(
15
+ defineProps<{
16
+ /**
17
+ * 是否显示详情弹窗(detailPopup),透传给 LabelValue。默认 true。
18
+ * 为 true 时:字段配置了 detail 按钮时显示可点击的 detailPopup 弹窗
19
+ * 为 false 时:字段配置了 detail 按钮时显示可点击的文字,点击跳转详情页面
20
+ */
21
+ showDetailPopup?: boolean
22
+ /**
23
+ * 自定义详情按钮回调,透传给 LabelValue / CardBotomButtons。showDetailPopup 为 false 时优先使用
24
+ */
25
+ detailButtonHandle?: (data: Entities) => void
26
+ }>(),
27
+ {
28
+ showDetailPopup: true,
29
+ }
30
+ )
13
31
  const sourceId = ref('')
14
32
  const id = ref('')
15
33
  const title = ref('')
@@ -130,7 +148,13 @@ async function getDetailData() {
130
148
  :name="group.id"
131
149
  >
132
150
  <view v-if="group.type === 'fieldGroup'" class="text-sm space-y-3">
133
- <LabelValue :index="index" :exhibit-data="group.fields" :data="data" />
151
+ <LabelValue
152
+ :index="index"
153
+ :exhibit-data="group.fields"
154
+ :data="data"
155
+ :show-detail-popup="props.showDetailPopup"
156
+ :detail-button-handle="props.detailButtonHandle"
157
+ />
134
158
  </view>
135
159
  <view v-if="group.type === 'relation'">
136
160
  <view v-for="(field, subindex) in data.arrayMap[group.id]" :key="field.code">
@@ -140,6 +164,8 @@ async function getDetailData() {
140
164
  :groups="group"
141
165
  :source-id="sourceId"
142
166
  :columns="group.fields"
167
+ :show-detail-popup="props.showDetailPopup"
168
+ :detail-button-handle="props.detailButtonHandle"
143
169
  model="complex"
144
170
  :data="field"
145
171
  >
@@ -152,6 +178,7 @@ async function getDetailData() {
152
178
  :item="groups"
153
179
  :code="field.code"
154
180
  :data="data"
181
+ :detail-button-handle="props.detailButtonHandle"
155
182
  />
156
183
  </template>
157
184
  </foldCard>
@@ -300,6 +300,7 @@ function tabSearchClick(data: any) {
300
300
  :label-column="config.labelColumn"
301
301
  :show-label="showLabel"
302
302
  :show-detail-popup="showDetailPopup"
303
+ :detail-button-handle="detailButtonHandle"
303
304
  model="complex"
304
305
  >
305
306
  <template #buttons>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "wui-components-v2",
3
- "version": "1.2.33",
3
+ "version": "1.2.35",
4
4
  "description": "wui 组件库",
5
5
  "author": "wgxshh",
6
6
  "license": "MIT",