wui-components-v2 1.2.39 → 1.2.41

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.
@@ -122,9 +122,19 @@ function initFormData() {
122
122
  ControlTypeSupportor.getControlType(item, props.entity && props.entity[item.sourceId]) === 'eetime' ||
123
123
  ControlTypeSupportor.getControlType(item, props.entity && props.entity[item.sourceId]) === 'date'
124
124
  ) {
125
+ const entityVal = props.entity && props.entity[item.sourceId]
126
+ // 解析默认值:支持 $$currentD(今天)、纯数字时间戳、日期字符串
127
+ const defaultVal = item.transDefaultValue || item.defaultValue || ''
128
+ const resolvedDefault = defaultVal
129
+ ? defaultVal === '$$currentD'
130
+ ? dayjs().format('YYYY-MM-DD')
131
+ : /^\d+$/.test(String(defaultVal))
132
+ ? dayjs(Number(defaultVal)).format('YYYY-MM-DD')
133
+ : defaultVal
134
+ : ''
125
135
  return (models[item.sourceId] =
126
- (props.entity && dayjs(props.entity[item.sourceId]).valueOf()) ||
127
- (item.transDefaultValue && dayjs(item.transDefaultValue).valueOf()) ||
136
+ (entityVal && dayjs(entityVal).valueOf()) ||
137
+ (resolvedDefault && dayjs(resolvedDefault).valueOf()) ||
128
138
  null)
129
139
  }
130
140
 
@@ -127,7 +127,8 @@ const tableData = computed<Record<string, any>[]>(() => {
127
127
  })
128
128
 
129
129
  // 根据内容计算每列宽度(中文字符约16px,英文/数字约8px,最大宽度300px)
130
- // 无数据时用 1fr 让列均分占满整行
130
+ // 每列宽度用 minmax(最小px, 1fr):保证内容最小宽度,同时按比例拉伸铺满整行,
131
+ // 这样切换全屏/宽屏时表格会自动撑满,而不是固定像素。
131
132
  const columnWidths = computed<Record<string, string>>(() => {
132
133
  const widths: Record<string, string> = {}
133
134
  const MAX_WIDTH = 300
@@ -136,9 +137,7 @@ const columnWidths = computed<Record<string, string>>(() => {
136
137
  const CHAR_WIDTH_EN = 8
137
138
  const PADDING = 32
138
139
 
139
- // 无数据时,所有列按百分比均分占满整行
140
- // 注意:不能用 1fr,因为 wd-table 的 contentWidthStyle 会用 calc() 求和,
141
- // fr 单位在 calc() 中是非法值,这里改用百分比
140
+ // 无数据时,所有列按 1fr 均分占满整行
142
141
  if (datas.value.length === 0 && tableColumns.value.length > 0) {
143
142
  const colCount = tableColumns.value.length
144
143
  const percent = (100 / colCount).toFixed(4) + '%'
@@ -161,7 +160,8 @@ const columnWidths = computed<Record<string, string>>(() => {
161
160
  maxLen = Math.max(maxLen, charCount)
162
161
  })
163
162
  const px = Math.min(MAX_WIDTH, Math.max(MIN_WIDTH, maxLen * CHAR_WIDTH_EN + PADDING))
164
- widths[col.sourceId] = `${px}px`
163
+ // 用 minmax 保证列最小宽度为内容宽度,多余空间按 1fr 均分,让整表撑满容器
164
+ widths[col.sourceId] = `minmax(${px}px, 1fr)`
165
165
  })
166
166
  return widths
167
167
  })
@@ -279,7 +279,6 @@ function submitSearch(data: any) {
279
279
  const val = fdata[item.sourceId]
280
280
  if (val === undefined || val === null || val === '') return
281
281
  if (Array.isArray(val) && val.length === 0) return
282
- if (item.transDefaultValue && String(val) === String(item.transDefaultValue)) return
283
282
  // 时间戳转日期字符串
284
283
  const formatted = typeof val === 'number' ? dayjs(val).format('YYYY-MM-DD') : val
285
284
  timeData = timeData ? `${timeData}&c_${item.sourceId}=${formatted}` : `c_${item.sourceId}=${formatted}`
@@ -307,7 +306,6 @@ function submitTimeFilter() {
307
306
  const val = fdata[item.sourceId]
308
307
  if (val === undefined || val === null || val === '') return
309
308
  if (Array.isArray(val) && val.length === 0) return
310
- if (item.transDefaultValue && String(val) === String(item.transDefaultValue)) return
311
309
  // 时间戳转日期字符串
312
310
  const formatted = typeof val === 'number' ? dayjs(val).format('YYYY-MM-DD') : val
313
311
  data = data ? `${data}&c_${item.sourceId}=${formatted}` : `c_${item.sourceId}=${formatted}`
@@ -400,6 +398,13 @@ function tabSearchClick(data: any) {
400
398
  width: auto;
401
399
  }
402
400
 
401
+ // wd-table 内部内容容器宽度默认是 calc(各列宽之和),
402
+ // 当列宽使用 minmax() 时 calc() 失效,这里强制内容容器占满宽度,
403
+ // 让 grid 的 minmax(px, 1fr) 生效,使表格随屏幕宽度自动铺满。
404
+ :deep(.wd-table > scroll-view > view) {
405
+ width: 100%;
406
+ }
407
+
403
408
  // 修复合并单元格后内容不垂直居中
404
409
  ::deep(.wd-table__value) {
405
410
  display: flex !important;
@@ -410,7 +415,11 @@ function tabSearchClick(data: any) {
410
415
  .time-filter-bar {
411
416
  padding: 16rpx;
412
417
  }
418
+
419
+ // 用 box-shadow 画单元格边框:不占用布局空间,避免 border-box 下挤压内容导致换行
413
420
  :deep(.wd-table__cell) {
414
- border: 0.5px solid #e5e5e5;
421
+ box-shadow:
422
+ inset 0 -0.5px 0 #e5e5e5,
423
+ inset -0.5px 0 0 #e5e5e5;
415
424
  }
416
425
  </style>
@@ -24,14 +24,14 @@ const formControlRef = ref()
24
24
  const entity = ref({})
25
25
  // 判断字段实际渲染的控件类型是否为纯文本输入(优先 extControlType,回退 controlType)
26
26
  const isTextCriterion = (item: Fields) => ControlTypeSupportor.getControlType(item) === 'text'
27
- // 用于 wd-search 的搜索字段:优先使用 primaryCriterion,否则取 criteria 中第一个文本类型的筛选项
27
+ // 用于 wd-search 的搜索字段:primaryCriterion 存在时直接使用,否则取 criteria 中第一个文本类型的筛选项
28
28
  const searchCriterion = computed(() => {
29
- if (props.primaryCriterion && isTextCriterion(props.primaryCriterion)) {
29
+ if (props.primaryCriterion) {
30
30
  return props.primaryCriterion
31
31
  }
32
32
  return props.criteria.find(item => isTextCriterion(item)) || null
33
33
  })
34
- // 仅当 searchCriterion 为文本类型时显示搜索框
34
+ // 仅当 searchCriterion 存在时显示搜索框
35
35
  const showSearch = computed(() => searchCriterion.value !== null)
36
36
  const filterCriteria = computed(() => {
37
37
  const criteriaSourceIds = props.split2TabCriterias?.map(item => item.sourceId) || []
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "wui-components-v2",
3
- "version": "1.2.39",
3
+ "version": "1.2.41",
4
4
  "description": "wui 组件库",
5
5
  "author": "wgxshh",
6
6
  "license": "MIT",