wui-components-v2 1.2.66 → 1.2.68

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/api/page.ts CHANGED
@@ -23,9 +23,11 @@ export async function pageConfig(sourceId: string): Promise<PageConfig> {
23
23
  }
24
24
 
25
25
  // 获取列表页面数据key
26
- export function pageKey(sourceId: string, mainCode: string = '', query: string = '') {
26
+ export function pageKey(sourceId: string, mainCode: string = '', query: string = '', menuId: string = '') {
27
+ // menuId 未传时回退为 sourceId,保持原有行为
28
+ const menu = menuId || sourceId
27
29
  return req({
28
- url: `/v3/ltmpl/query/key?sourceId=${sourceId}&mainCode=${mainCode}&menuId=${sourceId}&${query}`,
30
+ url: `/v3/ltmpl/query/key?sourceId=${sourceId}&mainCode=${mainCode}&menuId=${menu}&${query}`,
29
31
  })
30
32
  }
31
33
 
@@ -260,7 +260,11 @@ function detail() {
260
260
  props.detailButtonHandle(props.data)
261
261
  return
262
262
  }
263
- router.push(`/pages/details-page/index?sourceId=${props.sourceId}&id=${props.code}&title=${props.item.title}`)
263
+ router.push(
264
+ `/pages/details-page/index?sourceId=${encodeURIComponent(props.sourceId)}&id=${encodeURIComponent(
265
+ props.code
266
+ )}&title=${encodeURIComponent(props.item.title || '')}`
267
+ )
264
268
  }
265
269
 
266
270
  // 判断按钮是否满足条件显示
@@ -1,6 +1,6 @@
1
1
  <script lang="ts" setup>
2
2
  import { computed, defineEmits, defineOptions, defineProps, ref } from 'vue'
3
- import type { Columns, Entities, Enums, FoldCardModel, Groups } from '../../type'
3
+ import type { Columns, Entities, Enums, FieldJump, FoldCardModel, Groups } from '../../type'
4
4
  import { formatItemData } from '../../utils'
5
5
  import LabelValue from '../label-value/label-value.vue'
6
6
  import { useManualTheme } from '../../composables/useManualTheme'
@@ -37,6 +37,10 @@ const props = withDefaults(
37
37
  * 自定义详情按钮回调,透传给 LabelValue。showDetailPopup 为 false 时优先使用
38
38
  */
39
39
  detailButtonHandle?: (data: Entities) => void
40
+ /**
41
+ * 字段跳转配置(ltmplConfig.fieldJumps),透传给 LabelValue
42
+ */
43
+ fieldJumps?: FieldJump[]
40
44
  }>(),
41
45
  {
42
46
  showDetailPopup: true,
@@ -156,12 +160,12 @@ function toggleCollapse(contentId: string) {
156
160
  <view class="mb-3">
157
161
  <!-- 订单信息 -->
158
162
  <view class="text-sm space-y-3">
159
- <LabelValue :exhibit-data="exhibitData" :data="data" :index="index" :show-detail-popup="showDetailPopup" :detail-button-handle="detailButtonHandle" />
163
+ <LabelValue :exhibit-data="exhibitData" :data="data" :index="index" :show-detail-popup="showDetailPopup" :detail-button-handle="detailButtonHandle" :field-jumps="fieldJumps" />
160
164
 
161
165
  <!-- 可折叠内容 -->
162
166
  <view :id="`${data.code}`" ref="contentRef">
163
167
  <view class="space-y-3">
164
- <LabelValue :exhibit-data="collapseData" :data="data" :index="index" :show-detail-popup="showDetailPopup" :detail-button-handle="detailButtonHandle" />
168
+ <LabelValue :exhibit-data="collapseData" :data="data" :index="index" :show-detail-popup="showDetailPopup" :detail-button-handle="detailButtonHandle" :field-jumps="fieldJumps" />
165
169
  </view>
166
170
  </view>
167
171
  </view>
@@ -1,6 +1,6 @@
1
1
  <script lang="ts" setup>
2
2
  import { computed, defineEmits, defineOptions, defineProps, ref } from 'vue'
3
- import type { Columns, Entities, Enums, FoldCardModel, Groups } from '../../type'
3
+ import type { Columns, Entities, Enums, FieldJump, FoldCardModel, Groups } from '../../type'
4
4
  import { formatItemData, getEnumColor } from '../../utils'
5
5
  import LabelValue from '../label-value/label-value.vue'
6
6
  import { useManualTheme } from '../../composables/useManualTheme'
@@ -47,6 +47,10 @@ const props = withDefaults(
47
47
  * 自定义详情按钮回调,透传给 LabelValue。showDetailPopup 为 false 时优先使用
48
48
  */
49
49
  detailButtonHandle?: (data: Entities) => void
50
+ /**
51
+ * 字段跳转配置(ltmplConfig.fieldJumps),透传给 LabelValue
52
+ */
53
+ fieldJumps?: FieldJump[]
50
54
  }>(),
51
55
  {
52
56
  // 标题旁标签默认不展示
@@ -198,6 +202,7 @@ function toggleCollapse(contentId: string) {
198
202
  :index="index"
199
203
  :show-detail-popup="showDetailPopup"
200
204
  :detail-button-handle="detailButtonHandle"
205
+ :field-jumps="fieldJumps"
201
206
  />
202
207
 
203
208
  <!-- 可折叠内容 -->
@@ -209,6 +214,7 @@ function toggleCollapse(contentId: string) {
209
214
  :index="index"
210
215
  :show-detail-popup="showDetailPopup"
211
216
  :detail-button-handle="detailButtonHandle"
217
+ :field-jumps="fieldJumps"
212
218
  />
213
219
  </view>
214
220
  </view>
@@ -1,6 +1,6 @@
1
1
  <script setup lang="ts">
2
2
  import { computed, defineOptions, defineProps, ref } from 'vue'
3
- import type { Columns, Entities } from '../../type'
3
+ import type { Columns, Entities, FieldJump } from '../../type'
4
4
  import { downloadFile, formatItemData } from '../../utils'
5
5
  import ControlTypeSupportor from '../../utils/control-type-supportor'
6
6
  import VideoPlay from '../video-play/video-play.vue'
@@ -27,6 +27,11 @@ const props = withDefaults(
27
27
  * 自定义详情按钮回调,showDetailPopup 为 false 时优先使用
28
28
  */
29
29
  detailButtonHandle?: (data: Entities) => void
30
+ /**
31
+ * 字段跳转配置(ltmplConfig.fieldJumps)。
32
+ * 当字段存在于 fieldJumps 中时,才渲染可点击的跳转文字。
33
+ */
34
+ fieldJumps?: FieldJump[]
30
35
  }>(),
31
36
  {
32
37
  showDetailPopup: true,
@@ -49,10 +54,27 @@ function isControlType(item: Columns): string {
49
54
  )
50
55
  }
51
56
 
57
+ /**
58
+ * 判断当前字段是否配置了字段跳转(fieldJumps)。
59
+ * 通过字段的 mstrucId 与 fieldJumps 中的 appendMstrucId 匹配。
60
+ */
61
+ function hasFieldJump(item: Columns): boolean {
62
+ return !!getFieldJump(item)
63
+ }
64
+
65
+ /**
66
+ * 获取当前字段在 fieldJumps 中匹配的配置项。
67
+ * 通过字段的 mstrucId 与 fieldJumps 中的 appendMstrucId 匹配。
68
+ */
69
+ function getFieldJump(item: Columns): FieldJump | undefined {
70
+ if (!props.fieldJumps?.length) return undefined
71
+ return props.fieldJumps.find(fieldJump => fieldJump.appendMstrucId === item.mstrucId)
72
+ }
73
+
52
74
  /**
53
75
  * 跳转详情页面(showDetailPopup 为 false 时触发)
54
- * 参考 aldehyde-uniapp-template w-card.vue 的 goto('link', item, subItem) 逻辑
55
- * 使用字段自身的 sourceId 和值的 code 进行跳转
76
+ * 当字段命中 fieldJumps 时,使用配置中的 mobilePath 直接跳转;
77
+ * 否则使用字段自身的 sourceId 和值的 code 跳转到默认详情页。
56
78
  */
57
79
  function goDetail(item: Columns) {
58
80
  if (props.detailButtonHandle) {
@@ -68,9 +90,30 @@ function goDetail(item: Columns) {
68
90
  if (typeof rawValue === 'string' && rawValue.includes('@,@')) {
69
91
  code = rawValue.split('@,@')[0]?.split('@R@')[0]
70
92
  }
93
+ // 命中 fieldJumps 时,使用 mobilePath 跳转,并将 searchParams 中的
94
+ // title 作为参数名,参数值优先用 id 从当前行 fieldMap 取值,取不到则回退 defaultValue
95
+ const fieldJump = getFieldJump(item)
96
+ if (fieldJump?.mobilePath) {
97
+ const params = (fieldJump.searchParams || [])
98
+ .map(param => {
99
+ const fieldValue = props.data.fieldMap[param.id]
100
+ const value = fieldValue ?? param.defaultValue ?? ''
101
+ return `${encodeURIComponent(param.title ?? '')}=${encodeURIComponent(String(value))}`
102
+ })
103
+ .join('&')
104
+ const sep = params ? (fieldJump.mobilePath.includes('?') ? '&' : '?') : ''
105
+ // 对完整 URL 编码,避免 mobilePath 中的中文/全角字符在 H5 hash 路由下解析错乱
106
+ uni.navigateTo({
107
+ url: encodeURI(`${fieldJump.mobilePath}${sep}${params}`),
108
+ })
109
+ return
110
+ }
71
111
  // 使用字段自身的 sourceId(参考 w-card.vue goto('link'))
112
+ // 参数统一 encodeURIComponent,避免中文/特殊字符在 App 端被截断导致乱码、参数错位
72
113
  uni.navigateTo({
73
- url: `/pages/details-page/index?sourceId=${item.sourceId}&id=${code}&title=${item.title || ''}`,
114
+ url: `/pages/details-page/index?sourceId=${encodeURIComponent(item.sourceId)}&id=${encodeURIComponent(
115
+ String(code)
116
+ )}&title=${encodeURIComponent(item.title || '')}`,
74
117
  })
75
118
  }
76
119
  </script>
@@ -180,6 +223,9 @@ function goDetail(item: Columns) {
180
223
  {{ formatItemData(data.fieldMap[item.sourceId], isControlType(item)) }}
181
224
  </view>
182
225
  </view>
226
+ <view v-else-if="hasFieldJump(item)" class="text-[#1c64fd]" @click="goDetail(item)">
227
+ {{ formatItemData(data.fieldMap[item.sourceId], isControlType(item)) }}
228
+ </view>
183
229
  <openValueMore v-else :text="formatItemData(data.fieldMap[item.sourceId], isControlType(item))" />
184
230
  </view>
185
231
  <VideoPlay ref="videoPlayRef" />
@@ -1,5 +1,5 @@
1
1
  <script setup lang="ts">
2
- import { computed, defineEmits, defineOptions, defineProps, ref } from 'vue'
2
+ import { computed, defineEmits, defineOptions, defineProps, ref, watch } from 'vue'
3
3
  import type { Enums, Fields, Split2TabCriterias } from '../../type'
4
4
  import formControl from '../form-control/form-control.vue'
5
5
  import ControlTypeSupportor from '../../utils/control-type-supportor'
@@ -12,6 +12,11 @@ const props = defineProps<{
12
12
  enumColumn?: Enums
13
13
  mainCode?: string
14
14
  split2TabCriterias?: Split2TabCriterias[]
15
+ /**
16
+ * URL 跳转携带的筛选默认值(key 为字段 sourceId)。
17
+ * 首次提供时填充到筛选表单作为默认值,不会覆盖用户后续修改。
18
+ */
19
+ defaultEntity?: { [key: string]: any }
15
20
  }>()
16
21
  const emits = defineEmits(['submit'])
17
22
  // 自行携带暗色主题,避免在非 tabBar 页面(无 wd-config-provider 祖先)时
@@ -27,6 +32,18 @@ const preferredFormControlRef = ref()
27
32
  const preferredRefreshKey = ref(0)
28
33
  // 共享实体:外置 preferred 字段与弹窗筛选字段通过它进行双向同步
29
34
  const entity = ref<{ [key: string]: any }>({})
35
+ // URL 跳转携带的筛选默认值:首次提供非空值时填充到 entity(仅一次,不覆盖用户后续修改)
36
+ let defaultFilled = false
37
+ watch(
38
+ () => props.defaultEntity,
39
+ val => {
40
+ if (val && Object.keys(val).length && !defaultFilled) {
41
+ Object.assign(entity.value, normalizeForEntity(val))
42
+ defaultFilled = true
43
+ }
44
+ },
45
+ { immediate: true }
46
+ )
30
47
  // 判断字段实际渲染的控件类型是否为纯文本输入(优先 extControlType,回退 controlType)
31
48
  const isTextCriterion = (item: Fields) => ControlTypeSupportor.getControlType(item) === 'text'
32
49
  // 用于 wd-search 的搜索字段:primaryCriterion 存在时直接使用,否则取 criteria 中第一个文本类型的筛选项
@@ -58,18 +58,31 @@ const groups = ref<Groups>({
58
58
  const loading = ref(false)
59
59
  // 折叠面板
60
60
  const collapses = ref()
61
+ /**
62
+ * 安全解码:仅当字符串仍为编码态时解码。
63
+ * H5 / 小程序等平台 onLoad 参数可能已被框架自动解码一次,
64
+ * 对已解码的中文再 decodeURIComponent 会抛 URIError,此处兜底原样返回。
65
+ */
66
+ function safeDecode(value?: string): string {
67
+ if (!value) return ''
68
+ try {
69
+ return decodeURIComponent(value)
70
+ } catch {
71
+ return value
72
+ }
73
+ }
61
74
  onLoad((option: any) => {
62
- sourceId.value = option.sourceId
63
- id.value = option.id
75
+ sourceId.value = safeDecode(option.sourceId)
76
+ id.value = safeDecode(option.id)
64
77
  // #ifdef MP-WEIXIN
65
78
  const q = decodeURIComponent(option.q) // 获取到二维码原始链接内容
66
79
  const sc: any = getQueryParams(q)
67
80
  sourceId.value = sc.sourceId || option.sourceId
68
81
  id.value = sc.id || option.id
69
82
  // #endif
70
- title.value = option.title
83
+ title.value = safeDecode(option.title)
71
84
  uni.setNavigationBarTitle({
72
- title: `${option.title}`,
85
+ title: title.value,
73
86
  })
74
87
  getPageConfig()
75
88
  })
@@ -168,6 +168,10 @@ const tabSearchData = ref('')
168
168
  const pageType = ref('')
169
169
  const mainCode = ref('')
170
170
  const queryKey = ref('') // 用于导出接口的列表查询 key
171
+ /** URL 跳转携带的菜单 ID,用于 pageKey 请求的 menuId 参数 */
172
+ const menuId = ref('')
173
+ /** URL 跳转携带的筛选默认值(key 为字段 sourceId,去掉 c_ 前缀),作为筛选条件默认值 */
174
+ const urlDefaultCriteria = ref<{ [key: string]: any }>({})
171
175
  const addEvent = generateHighResolutionID() // 全局事件名称
172
176
  const toast = useGlobalToast()
173
177
  const message = useGlobalMessage()
@@ -393,9 +397,18 @@ onLoad((option: any) => {
393
397
  pageTitle.value = option.title
394
398
  pageType.value = option.pageType
395
399
  mainCode.value = option.mainCode || ''
400
+ menuId.value = option.menuId || ''
396
401
  uni.setNavigationBarTitle({
397
402
  title: option.title,
398
403
  })
404
+ // 解析 URL 中 c_* 参数作为筛选字段默认值(c_{sourceId}={value})
405
+ const criteria: { [key: string]: any } = {}
406
+ Object.keys(option || {}).forEach(key => {
407
+ if (key.startsWith('c_')) {
408
+ criteria[key.slice(2)] = option[key]
409
+ }
410
+ })
411
+ urlDefaultCriteria.value = criteria
399
412
  getPageConfig()
400
413
  })
401
414
  onMounted(async () => {
@@ -441,6 +454,11 @@ async function queryList(pageNo: number, pageSize: number) {
441
454
  if (props.query) {
442
455
  qre = qre ? `${qre}&${props.query}` : props.query
443
456
  }
457
+ // URL 跳转携带的筛选默认值:无其他查询条件时,作为初始查询条件并入
458
+ const urlKeys = Object.keys(urlDefaultCriteria.value)
459
+ if (!qre && urlKeys.length) {
460
+ qre = urlKeys.map(key => `c_${key}=${urlDefaultCriteria.value[key]}`).join('&')
461
+ }
444
462
  if (config.value.defaultCriteriaValue) {
445
463
  for (const key in config.value.defaultCriteriaValue) {
446
464
  if (Object.prototype.hasOwnProperty.call(config.value.defaultCriteriaValue, key)) {
@@ -460,7 +478,7 @@ async function queryList(pageNo: number, pageSize: number) {
460
478
 
461
479
  try {
462
480
  console.log('qre', qre)
463
- const res = await pageKey(internalSourceId.value, mainCode.value, qre) // 获取key
481
+ const res = await pageKey(internalSourceId.value, mainCode.value, qre, menuId.value) // 获取key
464
482
  const data = await listData(res.key, pageNo, pageSize) // 获取数据
465
483
  // 缓存最新一次的 queryKey,给顶部「导出」接口使用
466
484
  queryKey.value = res.key || res.data?.key || ''
@@ -516,6 +534,7 @@ function tabSearchClick(data: any) {
516
534
  :criteria="config.criteria"
517
535
  :primary-criterion="config.primaryCriterion"
518
536
  :split2-tab-criterias="config.split2TabCriterias"
537
+ :default-entity="urlDefaultCriteria"
519
538
  @submit="submitSearch"
520
539
  />
521
540
  <view>
@@ -601,6 +620,7 @@ function tabSearchClick(data: any) {
601
620
  :show-label="showLabel"
602
621
  :show-detail-popup="showDetailPopup"
603
622
  :detail-button-handle="detailButtonHandle"
623
+ :field-jumps="config.fieldJumps"
604
624
  model="complex"
605
625
  :select-mode="inSelectMode"
606
626
  @select="toggleSelect"
@@ -120,9 +120,13 @@ const tabSearchData = ref('')
120
120
  const pageType = ref('')
121
121
  const mainCode = ref('')
122
122
  const queryKey = ref('') // 用于导出接口的列表查询 key
123
+ /** URL 跳转携带的菜单 ID,用于 pageKey 请求的 menuId 参数 */
124
+ const menuId = ref('')
123
125
  const addEvent = generateHighResolutionID() // 全局事件名称
124
126
  // 优先使用 props 传入的 sourceId,未传则走 onLoad 路由获取
125
127
  const internalSourceId = ref(props.sourceId)
128
+ /** URL 跳转携带的筛选默认值(key 为字段 sourceId,去掉 c_ 前缀),作为筛选条件默认值 */
129
+ const urlDefaultCriteria = ref<{ [key: string]: any }>({})
126
130
  onLoad((option: any) => {
127
131
  // 如果 props 没传 sourceId,则从路由参数获取
128
132
  if (!internalSourceId.value) {
@@ -131,9 +135,18 @@ onLoad((option: any) => {
131
135
  pageTitle.value = option.title
132
136
  pageType.value = option.pageType
133
137
  mainCode.value = option.mainCode || ''
138
+ menuId.value = option.menuId || ''
134
139
  uni.setNavigationBarTitle({
135
140
  title: option.title,
136
141
  })
142
+ // 解析 URL 中 c_* 参数作为筛选字段默认值(c_{sourceId}={value})
143
+ const criteria: { [key: string]: any } = {}
144
+ Object.keys(option || {}).forEach(key => {
145
+ if (key.startsWith('c_')) {
146
+ criteria[key.slice(2)] = option[key]
147
+ }
148
+ })
149
+ urlDefaultCriteria.value = criteria
137
150
  getPageConfig()
138
151
  })
139
152
  onMounted(async () => {
@@ -179,6 +192,11 @@ async function queryList(pageNo: number, pageSize: number) {
179
192
  if (props.query) {
180
193
  qre = qre ? `${qre}&${props.query}` : props.query
181
194
  }
195
+ // URL 跳转携带的筛选默认值:无其他查询条件时,作为初始查询条件并入
196
+ const urlKeys = Object.keys(urlDefaultCriteria.value)
197
+ if (!qre && urlKeys.length) {
198
+ qre = urlKeys.map(key => `c_${key}=${urlDefaultCriteria.value[key]}`).join('&')
199
+ }
182
200
  if (config.value.defaultCriteriaValue) {
183
201
  for (const key in config.value.defaultCriteriaValue) {
184
202
  if (Object.prototype.hasOwnProperty.call(config.value.defaultCriteriaValue, key)) {
@@ -198,7 +216,7 @@ async function queryList(pageNo: number, pageSize: number) {
198
216
 
199
217
  try {
200
218
  console.log('qre', qre)
201
- const res = await pageKey(internalSourceId.value, mainCode.value, qre) // 获取key
219
+ const res = await pageKey(internalSourceId.value, mainCode.value, qre, menuId.value) // 获取key
202
220
  const data = await listData(res.key, pageNo, pageSize) // 获取数据
203
221
  // 缓存最新一次的 queryKey,给顶部「导出」接口使用
204
222
  queryKey.value = res.key || res.data?.key || ''
@@ -254,6 +272,7 @@ function tabSearchClick(data: any) {
254
272
  :criteria="config.criteria"
255
273
  :primary-criterion="config.primaryCriterion"
256
274
  :split2-tab-criterias="config.split2TabCriterias"
275
+ :default-entity="urlDefaultCriteria"
257
276
  @submit="submitSearch"
258
277
  />
259
278
  <view>
@@ -332,6 +351,7 @@ function tabSearchClick(data: any) {
332
351
  :show-label="showLabel"
333
352
  :show-detail-popup="showDetailPopup"
334
353
  :detail-button-handle="detailButtonHandle"
354
+ :field-jumps="config.fieldJumps"
335
355
  model="complex"
336
356
  >
337
357
  <template #buttons>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "wui-components-v2",
3
- "version": "1.2.66",
3
+ "version": "1.2.68",
4
4
  "description": "wui 组件库",
5
5
  "author": "wgxshh",
6
6
  "license": "MIT",
package/type.ts CHANGED
@@ -43,6 +43,24 @@ export interface rowActions {
43
43
  multible?: boolean
44
44
  }
45
45
 
46
+ // 字段跳转参数(fieldJumps.searchParams 中的一项)
47
+ export interface FieldJumpParam {
48
+ id: string
49
+ title?: string
50
+ defaultValue?: string | null
51
+ }
52
+
53
+ // 字段跳转配置(fieldJumps 中的一项)
54
+ export interface FieldJump {
55
+ appendMstrucId?: string
56
+ id: string
57
+ title?: string
58
+ path?: string
59
+ mobilePath?: string
60
+ searchParams?: FieldJumpParam[]
61
+ [key: string]: any
62
+ }
63
+
46
64
  // 列表页面配置
47
65
  export interface Config extends Groups {
48
66
  columns: Columns[]
@@ -63,6 +81,8 @@ export interface Config extends Groups {
63
81
  extShowConfig?: { [key: string]: any }
64
82
  extDisplayConfig?: { [key: string]: any }
65
83
  copyMode?: string
84
+ /** 字段跳转配置,用于判断某个字段是否支持点击跳转到其他详情页 */
85
+ fieldJumps?: FieldJump[]
66
86
  }
67
87
 
68
88
  // 列表数据