wui-components-v2 1.2.78 → 1.2.80

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.
@@ -67,7 +67,8 @@ const exhibitData = computed(() => {
67
67
  if (collapseNum === 0) return []
68
68
  const num = collapseNum || 5
69
69
  const columns = props.columns.length >= num ? props.columns.slice(0, num) : props.columns
70
- return columns.filter(item => item.title !== '操作')
70
+ // 配置层 hidden:true 的字段不在卡片中展示(与表单区显隐语义保持一致)
71
+ return columns.filter((item: any) => item.title !== '操作' && item.hidden !== true)
71
72
  })
72
73
 
73
74
  // 是否展示折叠按钮
@@ -121,7 +122,7 @@ function getCollapseColumns(): Columns[] {
121
122
  const num = collapseNum || 5
122
123
  columns = props.columns.length >= num ? props.columns.slice(num) : []
123
124
  }
124
- return columns.filter(item => item.title !== '操作')
125
+ return columns.filter((item: any) => item.title !== '操作' && item.hidden !== true)
125
126
  }
126
127
 
127
128
  // 切换折叠内容
@@ -547,6 +547,8 @@ const schema = computed((): FormSchema => {
547
547
  validate(_model: Record<string, any>): FormSchemaIssue[] {
548
548
  const issues: FormSchemaIssue[] = []
549
549
  props.fieldGroup?.fields.forEach((item: Fields) => {
550
+ // 配置层 hidden:true 的字段表单不渲染,跳过校验,避免出现无法修改的必填报错
551
+ if (item.hidden === true) return
550
552
  const value = _model[item.sourceId]
551
553
  // 必填校验
552
554
  if (item.required) {
@@ -39,7 +39,8 @@ const props = withDefaults(
39
39
  )
40
40
  const { primary } = useManualTheme()
41
41
  const clums = computed(() => {
42
- return props.exhibitData.filter(item => !item.title?.includes('y'))
42
+ // hidden:true 的字段不展示(与表单区显隐语义保持一致)
43
+ return props.exhibitData.filter((item: any) => !item.title?.includes('y') && item.hidden !== true)
43
44
  })
44
45
 
45
46
  const videoPlayRef = ref()
@@ -104,41 +104,36 @@ function handleClose() {
104
104
  }
105
105
  // 把合并后的数据对象(fdata)拼接为查询条件字符串
106
106
  function buildQueryData(fdata: { [key: string]: any }) {
107
- let data = ''
108
- if (showSearch.value && searchCriterion.value?.sourceId) {
109
- data = `c_${searchCriterion.value.sourceId}=${search.value}`
107
+ const parts: string[] = []
108
+ // 搜索框没输入关键字时不拼参数:空值参数(`c_xxx=`)会被后端当成"等于空串"的
109
+ // 过滤条件,也会把父组件 defaultCriteriaValue 的默认值顶掉,导致数据全被过滤掉
110
+ if (showSearch.value && searchCriterion.value?.sourceId && search.value !== '') {
111
+ parts.push(`c_${searchCriterion.value.sourceId}=${search.value}`)
110
112
  }
111
113
  filterCriteria.value.forEach(item => {
112
114
  const element = fdata[item.sourceId]
113
- // 空值(空字符串、undefined、null、空数组)仍拼接 `c_${sourceId}=` 空参数,
114
- // 让父组件识别「该字段已被用户清空」,从而跳过 defaultCriteriaValue 的默认值兜底
115
- if (element === undefined || element === null || element === '') {
116
- data = `${data}&c_${item.sourceId}=`
117
- return
118
- }
119
- if (Array.isArray(element) && element.length === 0) {
120
- data = `${data}&c_${item.sourceId}=`
121
- return
122
- }
115
+ // 空值(空字符串、undefined、null、空数组)不拼参数,直接跳过
116
+ if (element === undefined || element === null || element === '') return
117
+ if (Array.isArray(element) && element.length === 0) return
123
118
  // 跳过用户未修改的默认值(时间字段常被自动填充当前时间,不应作为查询条件)
124
119
  if (item.transDefaultValue && String(element) === String(item.transDefaultValue)) return
125
120
  if (item.extControlType === 'relselectvalue') {
126
121
  const elements = Array.isArray(element) ? element : [element]
127
- data = `${data}&c_${item.sourceId}=${elements
122
+ parts.push(`c_${item.sourceId}=${elements
128
123
  .map((item: string) => {
129
124
  return item.split('@R@')[1]
130
125
  })
131
- .join('@,@')}`
126
+ .join('@,@')}`)
132
127
  } else if (item.extControlType === 'multiselect') {
133
128
  const elements = Array.isArray(element) ? element : [element]
134
129
  elements.forEach((subitem: string) => {
135
- data = `${data}&c_${item.sourceId}=${subitem}`
130
+ parts.push(`c_${item.sourceId}=${subitem}`)
136
131
  })
137
132
  } else {
138
- data = `${data}&c_${item.sourceId}=${element}`
133
+ parts.push(`c_${item.sourceId}=${element}`)
139
134
  }
140
135
  })
141
- return data
136
+ return parts.join('&')
142
137
  }
143
138
  // 对外触发提交(点击搜索/确定时使用)
144
139
  function emitSubmit(fdata: { [key: string]: any }) {
@@ -497,22 +497,36 @@ async function queryList(pageNo: number, pageSize: number) {
497
497
  if (!qre && urlKeys.length) {
498
498
  qre = urlKeys.map(key => `c_${key}=${urlDefaultCriteria.value[key]}`).join('&')
499
499
  }
500
+ // 解析 qre 为键值对:search 组件会把用户未填写的筛选项拼成 `c_xxx=` 空参数,
501
+ // 空值条件传给后端会过滤掉全部数据;且原来的 qre.includes(key) 是子串匹配,
502
+ // 空参数也会命中,把 $$currentD 等默认值顶掉,导致「点击搜索后数据消失」。
503
+ // 这里统一丢弃空值条件,再按精确 key 合并默认值(用户已填非空值的字段不覆盖)。
504
+ const parts: [string, string][] = []
505
+ qre.split('&').forEach((part) => {
506
+ if (!part) return
507
+ const eq = part.indexOf('=')
508
+ const k = eq === -1 ? part : part.slice(0, eq)
509
+ const v = eq === -1 ? '' : part.slice(eq + 1)
510
+ if (v === '') return
511
+ parts.push([k, v])
512
+ })
500
513
  if (config.value.defaultCriteriaValue) {
501
514
  for (const key in config.value.defaultCriteriaValue) {
502
515
  if (Object.prototype.hasOwnProperty.call(config.value.defaultCriteriaValue, key)) {
503
516
  let element = config.value.defaultCriteriaValue[key]
504
- // $$currentD 占位符转换为当日时间(年-月-日),没有值则传空字符串
517
+ // $$currentD 占位符转换为当日时间(年-月-日),没有值则不追加
505
518
  if (element === '$$currentD') {
506
519
  element = dayjs().format('YYYY-MM-DD')
507
520
  } else if (element === undefined || element === null) {
508
521
  element = ''
509
522
  }
510
- if (!qre.includes(key)) {
511
- qre = `${qre}&${key}=${element}`
512
- }
523
+ // 用户已显式填写该条件,或默认值本身为空,则跳过
524
+ if (element === '' || parts.some(([k]) => k === key)) continue
525
+ parts.push([key, String(element)])
513
526
  }
514
527
  }
515
528
  }
529
+ qre = parts.map(([k, v]) => `${k}=${v}`).join('&')
516
530
 
517
531
  try {
518
532
  console.log('qre', qre)
@@ -77,11 +77,14 @@ export function useCompanyFieldFilter(
77
77
  }
78
78
 
79
79
  // 计算字段是否隐藏:依据 usableRuleCriteria 关联其它字段实时值
80
+ // - 配置层显式 hidden:true:始终隐藏(优先级最高)
80
81
  // - 无可用规则:保持字段自身 unusableMode 决定的显隐
81
82
  // - 有可用规则:
82
83
  // 1) 任一依赖字段无数据 -> 隐藏该项
83
84
  // 2) 依赖均有数据后,所有规则命中才显示,否则隐藏
84
85
  const computeHidden = (item: any, fieldsMap: Map<string, any>, modelValue: any, isEnabled: boolean) => {
86
+ // 后端配置显式指定 hidden:true 的字段始终隐藏,不能被后续规则计算结果覆盖
87
+ if (item?.hidden === true) return true
85
88
  const baseHidden = item?.unusableMode === 'hidden'
86
89
  if (!isEnabled) return baseHidden
87
90
  const criteria = item?.usableRuleCriteria
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "wui-components-v2",
3
- "version": "1.2.78",
3
+ "version": "1.2.80",
4
4
  "description": "wui 组件库",
5
5
  "author": "wgxshh",
6
6
  "license": "MIT",