wui-components-v2 1.2.94 → 1.2.97

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.
@@ -267,6 +267,8 @@ function detail() {
267
267
 
268
268
  // 判断按钮是否满足条件显示
269
269
  function isActionVisible(item?: { preposes?: Fields[] }) {
270
+ // TODO: 临时跳过显隐条件判断,用于测试「报警处理」按钮显示,测试完删除这行恢复原逻辑
271
+ return true
270
272
  if (item?.preposes?.length) {
271
273
  return item.preposes.every((prepose: Fields) => {
272
274
  // 判断字段值是否满足要求
@@ -413,8 +415,44 @@ const morebutns = computed(() => {
413
415
  return buts
414
416
  })
415
417
 
418
+ // doType === 'show_window' 时跳转按钮配置的 path(rowCustomButtons 等行级按钮)
419
+ function goShowWindow(item: rowActions) {
420
+ if (!item.path) {
421
+ console.warn('[show_window] 按钮未配置 path', item)
422
+ return
423
+ }
424
+ // 只对 path 中未编码的非 ASCII 做编码,避免二次编码已编码的 % 导致 App 端乱码
425
+ let safePath = String(item.path).replace(/[^\x00-\x7F]+/g, s => encodeURIComponent(s))
426
+ // 绝对路径补前导斜杠(相对路径不受影响)
427
+ if (!safePath.startsWith('/') && !safePath.startsWith('./') && !safePath.startsWith('../')) {
428
+ safePath = `/${safePath}`
429
+ }
430
+ // 拼接当前列表的 sourceId 与当前行数据 code,供目标页面使用
431
+ const sep = safePath.includes('?') ? '&' : '?'
432
+ safePath = `${safePath}${sep}sourceId=${props.sourceId}&id=${props.code}`
433
+ console.log('[show_window] 跳转 path:', safePath)
434
+ try {
435
+ router.push(safePath)
436
+ } catch (e) {
437
+ // 项目注册了 beforeEach 守卫,uni-mini-router 会先在路由表中查找 path,
438
+ // 查不到时内部 JSON.parse(undefined) 抛错;此处回退原生跳转兜底
439
+ console.warn('[show_window] router.push 失败,回退 uni.navigateTo:', safePath, e)
440
+ uni.navigateTo({
441
+ url: safePath,
442
+ fail: err => {
443
+ console.error('[show_window] 页面跳转失败,请确认 path 已在 pages.json 注册:', safePath, err)
444
+ uni.showToast({ title: '页面跳转失败', icon: 'error' })
445
+ },
446
+ })
447
+ }
448
+ }
449
+
416
450
  // 点击操作按钮
417
451
  async function select({ item }: { item: any }) {
452
+ // 配置了 doType === 'show_window' 的按钮直接跳转配置的 path,不走确认与数据操作
453
+ if (item.doType === 'show_window') {
454
+ return goShowWindow(item)
455
+ }
418
456
  if (item.title.includes('评价') && item.actionType === 'rowActions') {
419
457
  return action(item)
420
458
  }
@@ -30,7 +30,11 @@ interface SelectOption {
30
30
  const open = ref(false)
31
31
  const currentValue = ref<any>(props.modelValue)
32
32
  // 传给 wd-calendar 的值:该组件只认 13 位时间戳,而表单里存的是 'YYYY-MM-DD HH:mm:ss' 之类的字符串
33
- const calendarValue = ref<number | null>(null)
33
+ const calendarValue = ref<number | number[] | null>(null)
34
+ // 范围类型:表单值用 ~ 分隔('开始~结束',后端按此格式解析范围),面板值是 [开始时间戳, 结束时间戳]
35
+ const RANGE_TYPES = ['daterange', 'datetimerange']
36
+ const isRange = computed(() => RANGE_TYPES.includes(props.type))
37
+
34
38
  function clear() {
35
39
  currentValue.value = ''
36
40
  }
@@ -40,6 +44,16 @@ function toDayjs(value: any) {
40
44
  return typeof value === 'string' ? dayjs(value.trim().replace(' ', 'T')) : dayjs(value)
41
45
  }
42
46
 
47
+ /** 范围表单值('开始~结束',兼容 @,@ 与逗号分隔的历史值)→ [开始时间戳, 结束时间戳],无法完整解析时返回 null */
48
+ function rangeToTimestamps(value: any): number[] | null {
49
+ if (!value) return null
50
+ const segs = String(value).split(/~|@,@|,/)
51
+ if (segs.length !== 2) return null
52
+ const start = toTimestamp(segs[0])
53
+ const end = toTimestamp(segs[1])
54
+ return start !== null && end !== null ? [start, end] : null
55
+ }
56
+
43
57
  /** 表单值(字符串/时间戳)→ 13 位时间戳,无法解析时返回 null */
44
58
  function toTimestamp(value: any): number | null {
45
59
  if (value === undefined || value === null || value === '') return null
@@ -79,13 +93,28 @@ watch(open, val => {
79
93
  if (!val) return
80
94
  const now = dayjs()
81
95
  // datetime 选中日期时若不给默认时刻会落到 00:00:00,这里统一用当前时分秒
82
- defaultTime.value = props.type === 'datetime' ? now.format('HH:mm:ss') : undefined
83
- calendarValue.value = toTimestamp(currentValue.value) ?? now.valueOf()
96
+ // datetimerange 的 defaultTime 是 [开始时刻, 结束时刻]
97
+ if (props.type === 'datetime') {
98
+ defaultTime.value = now.format('HH:mm:ss')
99
+ } else if (props.type === 'datetimerange') {
100
+ defaultTime.value = [now.format('HH:mm:ss'), now.format('HH:mm:ss')]
101
+ } else {
102
+ defaultTime.value = undefined
103
+ }
104
+ calendarValue.value = isRange.value
105
+ ? (rangeToTimestamps(currentValue.value) ?? [now.startOf('day').valueOf(), now.valueOf()])
106
+ : (toTimestamp(currentValue.value) ?? now.valueOf())
84
107
  })
85
108
 
86
109
  /** 日历确认后才写回表单,避免「打开即赋值」 */
87
110
  function handleCalendarConfirm({ value }: { value: number | number[] | null }) {
88
111
  if (value === undefined || value === null) return
112
+ if (isRange.value) {
113
+ const arr = Array.isArray(value) ? value : [value]
114
+ if (arr.length < 2) return
115
+ currentValue.value = arr.map(ts => toDayjs(ts).format('YYYY-MM-DD HH:mm:ss')).join('~')
116
+ return
117
+ }
89
118
  currentValue.value = value
90
119
  }
91
120
 
@@ -101,6 +130,17 @@ const labelText = computed(() => {
101
130
  year: 'YYYY',
102
131
  }
103
132
 
133
+ // 范围类型:'开始~结束' 回显成 '开始 ~ 结束'
134
+ if (isRange.value) {
135
+ const segs = String(currentValue.value || '').split(/~|@,@|,/)
136
+ if (segs.length !== 2 || !segs[0] || !segs[1]) return ''
137
+ const start = toDayjs(segs[0])
138
+ const end = toDayjs(segs[1])
139
+ return start.isValid() && end.isValid()
140
+ ? `${start.format('YYYY-MM-DD HH:mm:ss')} ~ ${end.format('YYYY-MM-DD HH:mm:ss')}`
141
+ : ''
142
+ }
143
+
104
144
  if (['date', 'datetime', 'year'].includes(props.type)) {
105
145
  const date = currentValue.value ? toDayjs(currentValue.value) : null
106
146
  return date && date.isValid() ? date.format(formatMap[props.type] as string) : ''
@@ -119,7 +159,7 @@ console.log('labelText', props)
119
159
  </div>
120
160
 
121
161
  <wd-calendar
122
- v-if="['date', 'datetime', 'month'].includes(type)"
162
+ v-if="['date', 'datetime', 'month', 'datetimerange', 'daterange'].includes(type)"
123
163
  v-model="calendarValue"
124
164
  v-model:visible="open"
125
165
  label-key="label"
@@ -113,7 +113,10 @@ function toggleCollapse(contentId: string) {
113
113
  <!-- 订单卡片容器 -->
114
114
  <view class="mx-auto max-w-md space-y-4">
115
115
  <!-- 订单卡片2 -->
116
- <view class="ma-2 overflow-hidden rounded-xl bg-white shadow-sm dark:bg-[var(--wot-dark-background2)]" @click="emit('click')">
116
+ <view
117
+ class="ma-2 overflow-hidden rounded-xl border border-gray-100 bg-white shadow-sm dark:border-gray-700 dark:bg-[var(--wot-dark-background2)]"
118
+ @click="emit('click')"
119
+ >
117
120
  <!-- 订单头部 -->
118
121
  <view v-if="props.primaryColumn" class="flex items-center justify-between border-b border-gray-100 p-4">
119
122
  <view class="flex items-center gap-4 text-base text-gray-800 font-medium dark:text-white">
@@ -155,7 +158,8 @@ function toggleCollapse(contentId: string) {
155
158
  </view>
156
159
 
157
160
  <!-- 订单内容 -->
158
- <view v-if="props.model === 'complex'" class="p-4 pt-0">
161
+ <!-- 有标题头时去掉上内边距(pt-0),无标题头的卡片(如详情关系卡片)保留 p-4,避免内容顶着上边框 -->
162
+ <view v-if="props.model === 'complex'" :class="props.primaryColumn ? 'p-4 pt-0' : 'p-4'">
159
163
  <!-- 商品列表 -->
160
164
  <view class="mb-3">
161
165
  <!-- 订单信息 -->
@@ -171,8 +175,8 @@ function toggleCollapse(contentId: string) {
171
175
  </view>
172
176
  </view>
173
177
 
174
- <!-- 订单底部 -->
175
- <view class="flex items-center justify-between border-t border-gray-100">
178
+ <!-- 订单底部:justify-end 保证无折叠按钮时操作按钮仍右对齐;折叠按钮靠 mr-auto 占住左侧 -->
179
+ <view class="flex items-center justify-end border-t border-gray-100">
176
180
  <!-- 折叠按钮 -->
177
181
  <!-- ★ @click.stop 必须写在原生 view 上(编译成 catchtap 才有效),wd-icon 组件上写 .stop 小程序端会失效 -->
178
182
  <view
@@ -151,7 +151,7 @@ function toggleCollapse(contentId: string) {
151
151
  <view class="mx-auto max-w-md space-y-4">
152
152
  <!-- 订单卡片2 -->
153
153
  <view
154
- class="ma-2 overflow-hidden rounded-xl bg-white shadow-sm dark:bg-[var(--wot-dark-background2)]"
154
+ class="ma-2 overflow-hidden rounded-xl border border-gray-200 bg-white shadow-[0_4px_12px_rgba(0,0,0,0.1)] dark:border-gray-700 dark:bg-[var(--wot-dark-background2)] dark:shadow-none"
155
155
  @click.stop="selectMode ? emit('select', data.code) : emit('click')"
156
156
  >
157
157
  <!-- 订单头部 -->
@@ -194,8 +194,8 @@ function toggleCollapse(contentId: string) {
194
194
  </view>
195
195
  </view>
196
196
 
197
- <!-- 订单内容 -->
198
- <view v-if="props.model === 'complex'" class="p-4 pt-0">
197
+ <!-- 订单内容:有标题头时去掉上内边距(pt-0),无标题头的卡片(如详情关系卡片)保留 p-4,避免内容顶着上边框 -->
198
+ <view v-if="props.model === 'complex'" :class="props.primaryColumn ? 'p-4 pt-0' : 'p-4'">
199
199
  <!-- 商品列表 -->
200
200
  <view class="mb-3">
201
201
  <!-- 订单信息 -->
@@ -906,6 +906,25 @@ console.log('clearValueMap', clearValueMap)
906
906
  :readonly="item.disabled || item.rowEditType === 'readonly'"
907
907
  />
908
908
  </wd-form-item>
909
+ <wd-form-item
910
+ v-else-if="
911
+ ControlTypeSupportor.getControlType(item, props.entity && props.entity[item.sourceId]) ===
912
+ 'datetimerange'
913
+ "
914
+ :class="{ 'no-border-top': fields.indexOf(item) === 0 }"
915
+ :prop="item.sourceId"
916
+ :title="item.title"
917
+ >
918
+ <!-- 时间范围:customDatePicker 范围模式,值格式 '开始~结束',提交时走 else 分支原样透传 -->
919
+ <customDatePicker
920
+ :min="item.min"
921
+ v-model="model[item.sourceId]"
922
+ type="datetimerange"
923
+ :clearable="!item.disabled"
924
+ :placeholder="`请选择${item.title}`"
925
+ :readonly="item.disabled || item.rowEditType === 'readonly'"
926
+ />
927
+ </wd-form-item>
909
928
  <wd-form-item
910
929
  v-else-if="
911
930
  ControlTypeSupportor.getControlType(item, props.entity && props.entity[item.sourceId]) === 'time'
@@ -46,9 +46,11 @@ watch(
46
46
  )
47
47
  // 判断字段实际渲染的控件类型是否为纯文本输入(优先 extControlType,回退 controlType)
48
48
  const isTextCriterion = (item: Fields) => ControlTypeSupportor.getControlType(item) === 'text'
49
- // 用于 wd-search 的搜索字段:primaryCriterion 存在时直接使用,否则取 criteria 中第一个文本类型的筛选项
49
+ // 用于 wd-search 的搜索字段:primaryCriterion 存在且实际控件类型是文本时才用作搜索框
50
+ // (服务端可能把 relselect/table-entity-select 等选择类字段指成 primaryCriterion,
51
+ // 文本框语义上无法承载它们的取值格式,此时让它回落到筛选弹窗渲染成正确控件)
50
52
  const searchCriterion = computed(() => {
51
- if (props.primaryCriterion) {
53
+ if (props.primaryCriterion && isTextCriterion(props.primaryCriterion)) {
52
54
  return props.primaryCriterion
53
55
  }
54
56
  return props.criteria.find(item => isTextCriterion(item)) || null
@@ -70,8 +72,14 @@ const filterCriteria = computed(() => {
70
72
  // 否则(extControlType 存在)该字段应回落到筛选弹窗中参与筛选
71
73
  const searchSourceId = showSearch.value ? searchCriterion.value?.sourceId : undefined
72
74
  // 弹窗筛选需保留 preferred 字段(与外置字段双向绑定),因此不排除 preferredCriteria
73
- if (!searchSourceId) return props.criteria.filter(item => !split2TabSourceIds.value.includes(item.sourceId))
74
- return props.criteria.filter(item => ![searchSourceId, ...split2TabSourceIds.value].includes(item.sourceId))
75
+ const list = props.criteria.filter(item => !split2TabSourceIds.value.includes(item.sourceId))
76
+ // primaryCriterion 若不在 criteria 数组里(服务端分开下发),回落时补进弹窗,避免字段静默消失
77
+ const primary = props.primaryCriterion
78
+ if (primary && primary.sourceId && !list.some(item => item.sourceId === primary.sourceId)) {
79
+ list.push(primary)
80
+ }
81
+ if (!searchSourceId) return list
82
+ return list.filter(item => item.sourceId !== searchSourceId)
75
83
  })
76
84
  // 把外部/弹窗表单返回的数据归一化后再写入 entity:
77
85
  // 数组值统一转成逗号分隔字符串,避免弹窗 initFormData 对数组调用 split 报错导致空白
@@ -6,7 +6,7 @@ import { actionDataSave, copyDataApi, deleteData, detailPageConfig, detailPageDa
6
6
  import type { Entities, Groups, dtmplConfig } from '../../type'
7
7
  import ActionPopup from '../action-popup/action-popup.vue'
8
8
  import CardBotomButtons from '../card-botom-buttons/card-botom-buttons.vue'
9
- import foldCard from '../fold-card/fold-card.vue'
9
+ import foldCard2 from '../fold-card2/fold-card2.vue'
10
10
  import LabelValue from '../label-value/label-value.vue'
11
11
  import { useGlobalMessage } from '../../composables/useGlobalMessage'
12
12
  import { useGlobalToast } from '../../composables/useGlobalToast'
@@ -254,7 +254,7 @@ onUnmounted(() => {
254
254
  </view>
255
255
  <view v-if="group.type === 'relation'">
256
256
  <view v-for="(field, subindex) in data.arrayMap[group.id]" :key="field.code">
257
- <foldCard
257
+ <foldCard2
258
258
  :index="subindex"
259
259
  :enum-column="{}"
260
260
  :groups="group"
@@ -283,7 +283,7 @@ onUnmounted(() => {
283
283
  :is-show-action="true"
284
284
  />
285
285
  </template>
286
- </foldCard>
286
+ </foldCard2>
287
287
  </view>
288
288
  </view>
289
289
  </wd-collapse-item>
@@ -16,10 +16,13 @@ import { useEnums } from '../../composables/useEnumes'
16
16
  import { useGlobalToast } from '../../composables/useGlobalToast'
17
17
  import { useGlobalMessage } from '../../composables/useGlobalMessage'
18
18
  import GlobalMessage from '../global-message/global-message.vue'
19
+ import { useManualThemeStore } from '../../store/manualThemeStore'
19
20
 
20
21
  defineOptions({
21
22
  name: 'WuiList',
22
23
  })
24
+ // 列表页通常没有 default 布局(无 wd-config-provider 祖先),暗色类需自行挂到 batch-bar 上
25
+ const themeStore = useManualThemeStore()
23
26
  const props = withDefaults(
24
27
  defineProps<{
25
28
  /** 数据源 ID,用于获取页面配置和列表数据 */
@@ -759,7 +762,7 @@ function tabSearchClick(data: any) {
759
762
  </view>
760
763
 
761
764
  <!-- 底部批量操作条 -->
762
- <view v-if="showBatchBar" class="batch-bar" @click.stop>
765
+ <view v-if="showBatchBar" class="batch-bar" :class="{ 'wot-theme-dark': themeStore.isDark }" @click.stop>
763
766
  <view class="batch-bar__inner">
764
767
  <view class="batch-bar__checkbox" @click.stop>
765
768
  <wd-checkbox :model-value="allChecked" @change="toggleSelectAll">
@@ -836,8 +839,10 @@ function tabSearchClick(data: any) {
836
839
  background: rgba(255, 255, 255, 0.98);
837
840
  box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.06);
838
841
  }
839
- :global(.wot-theme-dark) .batch-bar {
842
+ /* 暗色类直接挂在本元素上:列表页没有 config-provider 祖先,:global(.wot-theme-dark) 祖先选择器匹配不到 */
843
+ .batch-bar.wot-theme-dark {
840
844
  background: rgba(28, 28, 30, 0.98);
845
+ color: #fff;
841
846
  }
842
847
  .batch-bar__inner {
843
848
  display: flex;
@@ -7,7 +7,6 @@ import foldCard2 from '../fold-card2/fold-card2.vue'
7
7
  import type { Config, Entities, Enums, FoldCardModel } from '../../type'
8
8
  import { useGlobalToast } from '../../composables/useGlobalToast'
9
9
  import Search from '../search/search.vue'
10
- import foldCard from '../fold-card/fold-card.vue'
11
10
  import dayjs from 'dayjs/esm/index'
12
11
 
13
12
  defineOptions({
@@ -263,7 +262,7 @@ onUnmounted(() => {
263
262
  <slot name="top" />
264
263
  </template>
265
264
 
266
- <foldCard
265
+ <foldCard2
267
266
  v-for="(item, index) in datas"
268
267
  :key="item.code"
269
268
  :index="index"
@@ -298,7 +297,7 @@ onUnmounted(() => {
298
297
  <!-- <template #buttons>
299
298
  <CardBotomButtons :data="item" :groups="config" :source-id="sourceId" :item="config" :code="item.code" />
300
299
  </template> -->
301
- </foldCard>
300
+ </foldCard2>
302
301
 
303
302
  <template #bottom>
304
303
  <slot name="bottom">
@@ -214,7 +214,10 @@ function cancel() {
214
214
  .tree-check-panel {
215
215
  display: flex;
216
216
  flex-direction: column;
217
- height: 60vh;
217
+ // 撑满父容器(.tree-popup,80vh flex 纵向布局)剩余空间;
218
+ // 之前写死 60vh,footer 会缩在弹窗中部,下面留一大块空白
219
+ flex: 1;
220
+ min-height: 0;
218
221
 
219
222
  &__scroll {
220
223
  flex: 1;
@@ -363,6 +363,9 @@ function saveSensorConfig() {
363
363
  @click="setting"
364
364
  />
365
365
  <wd-cell title="清空缓存" :is-link="true" :clickable="true" :custom-style="cellStyle" @click="clearCache" />
366
+ <!-- 扩展插槽:由使用方在「退出登录」上方插入自定义行(可放任意 wd-cell / 自定义内容)
367
+ 通过插槽参数暴露 cellStyle,便于自定义行与现有列表样式(含暗黑模式)保持一致 -->
368
+ <slot name="before-logout" :cell-style="cellStyle" />
366
369
  <wd-cell
367
370
  v-if="showLogout"
368
371
  title="退出登录"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "wui-components-v2",
3
- "version": "1.2.94",
3
+ "version": "1.2.97",
4
4
  "description": "wui 组件库",
5
5
  "author": "wgxshh",
6
6
  "license": "MIT",
package/type.ts CHANGED
@@ -58,6 +58,8 @@ export interface rowActions {
58
58
  writes: Fields[]
59
59
  preposes: Fields[]
60
60
  path?: string
61
+ /** 动作类型:show_window 时点击跳转 path 配置的页面 */
62
+ doType?: string
61
63
  /** 是否为批量操作按钮,仅当为 true 时才展示在批量操作条上 */
62
64
  multible?: boolean
63
65
  }