wui-components-v2 1.2.38 → 1.2.39

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.
@@ -588,6 +588,16 @@ function submit() {
588
588
  } else {
589
589
  data[key] = model.value[key]
590
590
  }
591
+ } else if (ControlTypeSupportor.getControlType(item) === 'date') {
592
+ data[key] = model.value[key] ? dayjs(model.value[key]).format('YYYY-MM-DD') : ''
593
+ } else if (ControlTypeSupportor.getControlType(item) === 'datetime') {
594
+ data[key] = model.value[key] ? dayjs(model.value[key]).format('YYYY-MM-DD HH:mm:ss') : ''
595
+ } else if (ControlTypeSupportor.getControlType(item) === 'time') {
596
+ data[key] = model.value[key] ? dayjs(model.value[key]).format('HH:mm:ss') : ''
597
+ } else if (ControlTypeSupportor.getControlType(item) === 'date-YY') {
598
+ data[key] = model.value[key] ? dayjs(model.value[key]).format('YYYY') : ''
599
+ } else if (ControlTypeSupportor.getControlType(item) === 'date-M1') {
600
+ data[key] = model.value[key] ? dayjs(model.value[key]).format('YYYY-MM') : ''
591
601
  } else {
592
602
  data[key] = model.value[key]
593
603
  }
@@ -213,7 +213,12 @@ async function fetchData() {
213
213
  timeCriteria.value.forEach(item => {
214
214
  const defaultVal = item.transDefaultValue || item.defaultValue
215
215
  if (defaultVal && defaultVal !== '') {
216
- const formatted = /^\d+$/.test(String(defaultVal)) ? dayjs(Number(defaultVal)).format('YYYY-MM-DD') : defaultVal
216
+ const formatted =
217
+ defaultVal === '$$currentD'
218
+ ? dayjs().format('YYYY-MM-DD')
219
+ : /^\d+$/.test(String(defaultVal))
220
+ ? dayjs(Number(defaultVal)).format('YYYY-MM-DD')
221
+ : defaultVal
217
222
  defaultTimeData = defaultTimeData
218
223
  ? `${defaultTimeData}&c_${item.sourceId}=${formatted}`
219
224
  : `c_${item.sourceId}=${formatted}`
@@ -2,6 +2,7 @@
2
2
  import { computed, defineEmits, defineOptions, defineProps, ref } from 'vue'
3
3
  import type { Enums, Fields, Split2TabCriterias } from '../../type'
4
4
  import formControl from '../form-control/form-control.vue'
5
+ import ControlTypeSupportor from '../../utils/control-type-supportor'
5
6
  import { useManualThemeStore } from '../../store/manualThemeStore'
6
7
 
7
8
  defineOptions({ name: 'Search' })
@@ -21,19 +22,32 @@ const show = ref(false)
21
22
  const search = ref('')
22
23
  const formControlRef = ref()
23
24
  const entity = ref({})
25
+ // 判断字段实际渲染的控件类型是否为纯文本输入(优先 extControlType,回退 controlType)
26
+ const isTextCriterion = (item: Fields) => ControlTypeSupportor.getControlType(item) === 'text'
27
+ // 用于 wd-search 的搜索字段:优先使用 primaryCriterion,否则取 criteria 中第一个文本类型的筛选项
28
+ const searchCriterion = computed(() => {
29
+ if (props.primaryCriterion && isTextCriterion(props.primaryCriterion)) {
30
+ return props.primaryCriterion
31
+ }
32
+ return props.criteria.find(item => isTextCriterion(item)) || null
33
+ })
34
+ // 仅当 searchCriterion 为文本类型时显示搜索框
35
+ const showSearch = computed(() => searchCriterion.value !== null)
24
36
  const filterCriteria = computed(() => {
25
37
  const criteriaSourceIds = props.split2TabCriterias?.map(item => item.sourceId) || []
26
- const primarySourceId = props.primaryCriterion?.sourceId
27
- if (!primarySourceId) return props.criteria
28
- return props.criteria.filter(item => ![primarySourceId, ...criteriaSourceIds].includes(item.sourceId))
38
+ // 仅当搜索框真正显示时,才把 searchCriterion 从筛选弹窗中排除;
39
+ // 否则(extControlType 存在)该字段应回落到筛选弹窗中参与筛选
40
+ const searchSourceId = showSearch.value ? searchCriterion.value?.sourceId : undefined
41
+ if (!searchSourceId) return props.criteria.filter(item => !criteriaSourceIds.includes(item.sourceId))
42
+ return props.criteria.filter(item => ![searchSourceId, ...criteriaSourceIds].includes(item.sourceId))
29
43
  })
30
44
  function handleClose() {
31
45
  show.value = false
32
46
  }
33
47
  function handleSubmit() {
34
48
  if (!formControlRef.value) {
35
- if (!props.primaryCriterion?.sourceId) return
36
- const data = `c_${props.primaryCriterion.sourceId}=${search.value}`
49
+ if (!showSearch.value || !searchCriterion.value?.sourceId) return
50
+ const data = `c_${searchCriterion.value.sourceId}=${search.value}`
37
51
  emits('submit', data)
38
52
  handleClose()
39
53
  return
@@ -41,19 +55,28 @@ function handleSubmit() {
41
55
  formControlRef.value.submit().then((fdata: any) => {
42
56
  entity.value = {
43
57
  ...fdata,
44
- ...(props.primaryCriterion?.sourceId ? { [props.primaryCriterion.sourceId]: search.value } : {}),
58
+ ...(showSearch.value && searchCriterion.value?.sourceId
59
+ ? { [searchCriterion.value.sourceId]: search.value }
60
+ : {}),
45
61
  }
46
62
  let data = ''
47
63
 
48
- if (props.primaryCriterion?.sourceId) {
49
- data = `c_${props.primaryCriterion.sourceId}=${search.value}`
64
+ if (showSearch.value && searchCriterion.value?.sourceId) {
65
+ data = `c_${searchCriterion.value.sourceId}=${search.value}`
50
66
  }
51
67
 
52
68
  filterCriteria.value.forEach(item => {
53
69
  const element = fdata[item.sourceId]
54
- // 跳过空值(空字符串、undefined、null、空数组),避免拼接无意义的参数
55
- if (element === undefined || element === null || element === '') return
56
- if (Array.isArray(element) && element.length === 0) return
70
+ // 空值(空字符串、undefined、null、空数组)仍拼接 `c_${sourceId}=` 空参数,
71
+ // 让父组件识别「该字段已被用户清空」,从而跳过 defaultCriteriaValue 的默认值兜底
72
+ if (element === undefined || element === null || element === '') {
73
+ data = `${data}&c_${item.sourceId}=`
74
+ return
75
+ }
76
+ if (Array.isArray(element) && element.length === 0) {
77
+ data = `${data}&c_${item.sourceId}=`
78
+ return
79
+ }
57
80
  // 跳过用户未修改的默认值(时间字段常被自动填充当前时间,不应作为查询条件)
58
81
  if (item.transDefaultValue && String(element) === String(item.transDefaultValue)) return
59
82
  if (item.extControlType === 'relselectvalue') {
@@ -83,11 +106,11 @@ function handleSubmit() {
83
106
 
84
107
  <template>
85
108
  <wd-config-provider :theme="theme">
86
- <view v-if="primaryCriterion?.controlType === 'text'" class="w-full">
109
+ <view v-if="showSearch" class="w-full">
87
110
  <wd-search
88
111
  v-model="search"
89
112
  cancel-txt="搜索"
90
- :placeholder="`请输入${primaryCriterion?.title || ''}搜索`"
113
+ :placeholder="`请输入${searchCriterion?.title || ''}搜索`"
91
114
  @clear="handleSubmit"
92
115
  @cancel="handleSubmit"
93
116
  >
@@ -103,6 +126,12 @@ function handleSubmit() {
103
126
  </template>
104
127
  </wd-search>
105
128
  </view>
129
+ <view v-else-if="filterCriteria.length" class="px-[8px] mt-2">
130
+ <wd-button block custom-class="search-filter-btn" @click="show = true">
131
+ <wd-icon name="filter" size="17px" class="mr-1" />
132
+ 筛选
133
+ </wd-button>
134
+ </view>
106
135
  <wd-popup v-model="show" position="bottom" custom-class="h-80vh" closable @close="handleClose">
107
136
  <view class="relative box-border h-full p-1 bg-white dark:bg-[var(--wot-dark-background)]">
108
137
  <view class="h-34px flex items-center justify-center text-black dark:text-[var(--wot-dark-color)]">筛选</view>
@@ -8,6 +8,7 @@ import Search from '../search/search.vue'
8
8
  import ListTopButtons from '../list-top-buttons/list-top-buttons.vue'
9
9
  import CardBotomButtons from '../card-botom-buttons/card-botom-buttons.vue'
10
10
  import { generateHighResolutionID } from '../../utils/index'
11
+ import dayjs from 'dayjs/esm/index'
11
12
  import productCard from '../product-card/product-card.vue'
12
13
  import tabSearch from '../tab-search/tab-search.vue'
13
14
  import { useEnums } from '../../composables/useEnumes'
@@ -67,7 +68,7 @@ const props = withDefaults(
67
68
  sourceId: '',
68
69
  // 查询条件默认为空
69
70
  query: '',
70
- },
71
+ }
71
72
  )
72
73
 
73
74
  const Zpaging = ref<any>(null)
@@ -181,7 +182,13 @@ async function queryList(pageNo: number, pageSize: number) {
181
182
  if (config.value.defaultCriteriaValue) {
182
183
  for (const key in config.value.defaultCriteriaValue) {
183
184
  if (Object.prototype.hasOwnProperty.call(config.value.defaultCriteriaValue, key)) {
184
- const element = config.value.defaultCriteriaValue[key]
185
+ let element = config.value.defaultCriteriaValue[key]
186
+ // $$currentD 占位符转换为当日时间(年-月-日),没有值则传空字符串
187
+ if (element === '$$currentD') {
188
+ element = dayjs().format('YYYY-MM-DD')
189
+ } else if (element === undefined || element === null) {
190
+ element = ''
191
+ }
185
192
  if (!qre.includes(key)) {
186
193
  qre = `${qre}&${key}=${element}`
187
194
  }
@@ -190,6 +197,7 @@ async function queryList(pageNo: number, pageSize: number) {
190
197
  }
191
198
 
192
199
  try {
200
+ console.log('qre', qre)
193
201
  const res = await pageKey(internalSourceId.value, mainCode.value, qre) // 获取key
194
202
  const data = await listData(res.key, pageNo, pageSize) // 获取数据
195
203
  // 缓存最新一次的 queryKey,给顶部「导出」接口使用
@@ -8,6 +8,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
10
  import foldCard from '../fold-card/fold-card.vue'
11
+ import dayjs from 'dayjs/esm/index'
11
12
 
12
13
  defineOptions({
13
14
  name: 'WuiSelectList',
@@ -155,7 +156,13 @@ async function queryList(pageNo: number, pageSize: number) {
155
156
  if (config.value.defaultCriteriaValue) {
156
157
  for (const key in config.value.defaultCriteriaValue) {
157
158
  if (Object.prototype.hasOwnProperty.call(config.value.defaultCriteriaValue, key)) {
158
- const element = config.value.defaultCriteriaValue[key]
159
+ let element = config.value.defaultCriteriaValue[key]
160
+ // $$currentD 占位符转换为当日时间(年-月-日),没有值则传空字符串
161
+ if (element === '$$currentD') {
162
+ element = dayjs().format('YYYY-MM-DD')
163
+ } else if (element === undefined || element === null) {
164
+ element = ''
165
+ }
159
166
  if (!qre.includes(key)) {
160
167
  qre = `${qre}&${key}=${element}`
161
168
  }
@@ -6,6 +6,7 @@ import Search from '../search/search.vue'
6
6
  import type { Config, Entities, Enums, FoldCardModel } from '../../type'
7
7
  import { useGlobalToast } from '../../composables/useGlobalToast'
8
8
  import listTopButtons from '../list-top-buttons/list-top-buttons.vue'
9
+ import dayjs from 'dayjs/esm/index'
9
10
 
10
11
  defineOptions({
11
12
  name: 'WuiSelectPopup',
@@ -301,7 +302,13 @@ async function queryList(pageNo: number, pageSize: number) {
301
302
  if (config.value.defaultCriteriaValue) {
302
303
  for (const key in config.value.defaultCriteriaValue) {
303
304
  if (Object.prototype.hasOwnProperty.call(config.value.defaultCriteriaValue, key)) {
304
- const element = config.value.defaultCriteriaValue[key]
305
+ let element = config.value.defaultCriteriaValue[key]
306
+ // $$currentD 占位符转换为当日时间(年-月-日),没有值则传空字符串
307
+ if (element === '$$currentD') {
308
+ element = dayjs().format('YYYY-MM-DD')
309
+ } else if (element === undefined || element === null) {
310
+ element = ''
311
+ }
305
312
  if (!qre.includes(key)) {
306
313
  qre = `${qre}&${key}=${element}`
307
314
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "wui-components-v2",
3
- "version": "1.2.38",
3
+ "version": "1.2.39",
4
4
  "description": "wui 组件库",
5
5
  "author": "wgxshh",
6
6
  "license": "MIT",