wui-components-v2 1.2.90 → 1.2.93
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.
|
@@ -27,6 +27,8 @@ const props = defineProps<{
|
|
|
27
27
|
smartPaste?: boolean
|
|
28
28
|
/** 严格模式(筛选场景):entity 中存在 key 即视为用户显式设置的值,空值也生效,不再回落到字段默认值 */
|
|
29
29
|
strictEntity?: boolean
|
|
30
|
+
/** 弹窗选择类字段的 max 未配置时默认按单选处理(筛选场景使用,不影响配置了 max 的字段) */
|
|
31
|
+
selectDefaultSingle?: boolean
|
|
30
32
|
}>()
|
|
31
33
|
const fileTypes = [
|
|
32
34
|
{
|
|
@@ -55,6 +57,14 @@ const { filteredFields: fields } = useCompanyFieldFilter(
|
|
|
55
57
|
props.companyFilter, // 是否自适应显示快递公司填充框
|
|
56
58
|
props.companyFieldSourceId // 快递公司对应字段
|
|
57
59
|
)
|
|
60
|
+
// 弹窗选择类字段(WuiSelectPopup / WuiTreeCascaderPopup)是否单选:
|
|
61
|
+
// max 配置为 1 时单选;max 未配置时由 selectDefaultSingle 决定(筛选场景默认单选),配置了其他值则多选
|
|
62
|
+
function isSingleSelect(item: Fields) {
|
|
63
|
+
if (item.max === undefined || item.max === null || item.max === '') {
|
|
64
|
+
return props.selectDefaultSingle === true
|
|
65
|
+
}
|
|
66
|
+
return Number(item.max) === 1
|
|
67
|
+
}
|
|
58
68
|
const giveDefaultValue = (value: any) => {
|
|
59
69
|
const { extInfo = {} } = uni.getStorageSync('userInfo') || {}
|
|
60
70
|
const rawDefaultValue = extInfo.fieldMap || {}
|
|
@@ -992,7 +1002,7 @@ console.log('clearValueMap', clearValueMap)
|
|
|
992
1002
|
v-model="model[item.sourceId]"
|
|
993
1003
|
:source-id="item.sourceId"
|
|
994
1004
|
:title="item.title"
|
|
995
|
-
:ext-control-type="
|
|
1005
|
+
:ext-control-type="isSingleSelect(item) ? 'relselect' : 'ss'"
|
|
996
1006
|
:readonly="item.disabled || item.rowEditType === 'readonly'"
|
|
997
1007
|
:clearable="!item.disabled"
|
|
998
1008
|
:default-select-first="!!item.defaultSelectFirst"
|
|
@@ -1034,7 +1044,7 @@ console.log('clearValueMap', clearValueMap)
|
|
|
1034
1044
|
v-model="model[item.sourceId]"
|
|
1035
1045
|
:source-id="item.sourceId"
|
|
1036
1046
|
:title="item.title"
|
|
1037
|
-
:ext-control-type="
|
|
1047
|
+
:ext-control-type="isSingleSelect(item) ? 'relselect' : 'ss'"
|
|
1038
1048
|
:readonly="item.disabled || item.rowEditType === 'readonly'"
|
|
1039
1049
|
:clearable="!item.disabled"
|
|
1040
1050
|
:default-select-first="!!item.defaultSelectFirst"
|
|
@@ -1105,6 +1115,29 @@ console.log('clearValueMap', clearValueMap)
|
|
|
1105
1115
|
/>
|
|
1106
1116
|
</view>
|
|
1107
1117
|
</wd-form-item>
|
|
1118
|
+
<!-- yes-no-select / yes-no-radio:是/否 单选,取值与 yes-no-switch 一致(是/否) -->
|
|
1119
|
+
<wd-form-item
|
|
1120
|
+
v-else-if="
|
|
1121
|
+
['yes-no-select', 'yes-no-radio'].includes(
|
|
1122
|
+
ControlTypeSupportor.getControlType(item, props.entity && props.entity[item.sourceId])
|
|
1123
|
+
)
|
|
1124
|
+
"
|
|
1125
|
+
:class="{ 'no-border-top': fields.indexOf(item) === 0 }"
|
|
1126
|
+
:prop="item.sourceId"
|
|
1127
|
+
:title="item.title"
|
|
1128
|
+
>
|
|
1129
|
+
<wd-radio-group
|
|
1130
|
+
v-if="!item.disabled"
|
|
1131
|
+
v-model="model[item.sourceId]"
|
|
1132
|
+
inline
|
|
1133
|
+
shape="dot"
|
|
1134
|
+
custom-class="custom-radio"
|
|
1135
|
+
>
|
|
1136
|
+
<wd-radio value="是">是</wd-radio>
|
|
1137
|
+
<wd-radio value="否">否</wd-radio>
|
|
1138
|
+
</wd-radio-group>
|
|
1139
|
+
<view v-else class="text-left">{{ model[item.sourceId] }}</view>
|
|
1140
|
+
</wd-form-item>
|
|
1108
1141
|
<wd-form-item
|
|
1109
1142
|
v-else-if="
|
|
1110
1143
|
['tree-entity-select', 'ltree-entity-select', 'lab-tree-select'].includes(
|
|
@@ -1119,8 +1152,8 @@ console.log('clearValueMap', clearValueMap)
|
|
|
1119
1152
|
v-model="model[item.sourceId]"
|
|
1120
1153
|
:source-id="item.sourceId"
|
|
1121
1154
|
:title="item.title"
|
|
1122
|
-
:select-mode="
|
|
1123
|
-
:ext-control-type="
|
|
1155
|
+
:select-mode="isSingleSelect(item) ? 'single' : 'multiple'"
|
|
1156
|
+
:ext-control-type="isSingleSelect(item) ? 'relselect' : 'ss'"
|
|
1124
1157
|
:readonly="item.disabled || item.rowEditType === 'readonly'"
|
|
1125
1158
|
:clearable="!item.disabled"
|
|
1126
1159
|
:default-select-first="!!item.defaultSelectFirst"
|
|
@@ -141,11 +141,25 @@ function emitSubmit(fdata: { [key: string]: any }) {
|
|
|
141
141
|
emits('submit', buildQueryData(fdata))
|
|
142
142
|
handleClose()
|
|
143
143
|
}
|
|
144
|
-
function handleSubmit() {
|
|
144
|
+
async function handleSubmit() {
|
|
145
145
|
if (!formControlRef.value) {
|
|
146
|
-
|
|
147
|
-
//
|
|
148
|
-
//
|
|
146
|
+
// 弹窗未挂载(从未打开或已关闭)时,外置 preferred 字段选中的值还只存在于
|
|
147
|
+
// 外置 form-control 的内部 model 中(form-control 不回写 entity),
|
|
148
|
+
// 先 submit 同步进 entity,否则没打开过弹窗直接搜索会丢掉上面选中的筛选条件
|
|
149
|
+
if (preferredFormControlRef.value?.submit) {
|
|
150
|
+
try {
|
|
151
|
+
const pdata = await preferredFormControlRef.value.submit()
|
|
152
|
+
Object.assign(entity.value, normalizeForEntity(pdata))
|
|
153
|
+
} catch {
|
|
154
|
+
// 校验失败时仍用原 entity 提交,不阻塞搜索
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
if (!showSearch.value || !searchCriterion.value?.sourceId) {
|
|
158
|
+
emitSubmit({ ...entity.value })
|
|
159
|
+
return
|
|
160
|
+
}
|
|
161
|
+
// entity 中仍保留着已选中的筛选条件,不能只提交搜索框关键字,
|
|
162
|
+
// 需把搜索框值与 entity 中的筛选值合并后一并提交
|
|
149
163
|
const merged = normalizeForEntity({ ...entity.value })
|
|
150
164
|
merged[searchCriterion.value.sourceId] = search.value
|
|
151
165
|
emitSubmit(merged)
|
|
@@ -187,6 +201,7 @@ function handleSubmit() {
|
|
|
187
201
|
:entity="entity"
|
|
188
202
|
:enum-column="enumColumn"
|
|
189
203
|
strict-entity
|
|
204
|
+
select-default-single
|
|
190
205
|
/>
|
|
191
206
|
</view>
|
|
192
207
|
<view v-if="showSearch" class="w-full">
|
|
@@ -237,6 +252,7 @@ function handleSubmit() {
|
|
|
237
252
|
:entity="entity"
|
|
238
253
|
:enum-column="enumColumn"
|
|
239
254
|
strict-entity
|
|
255
|
+
select-default-single
|
|
240
256
|
/>
|
|
241
257
|
<view class="h-12" />
|
|
242
258
|
<view
|
|
@@ -51,7 +51,7 @@ function numColor(item: { themeColor?: string }) {
|
|
|
51
51
|
|
|
52
52
|
<template>
|
|
53
53
|
<view v-if="quickPanel.length > 0 || capsuleMenu.length > 0" class="mb-3">
|
|
54
|
-
<view class="rounded-2xl bg-white p-
|
|
54
|
+
<view class="rounded-2xl bg-white p-3 shadow-[0_4px_16px_rgba(0,0,0,0.04)] dark:bg-black">
|
|
55
55
|
<view class="mb-3 flex items-center gap-2 text-size-4 font-bold text-gray-800 dark:text-white">
|
|
56
56
|
{{ languageStore.t('数据统计') }}
|
|
57
57
|
</view>
|
|
@@ -78,12 +78,11 @@ function numColor(item: { themeColor?: string }) {
|
|
|
78
78
|
:style="{ background: pillTheme(i).bg }"
|
|
79
79
|
@click="handleClick(item)"
|
|
80
80
|
>
|
|
81
|
-
<
|
|
82
|
-
<text class="text-[11px] font-semibold" :style="{ color: pillTheme(i).text }">
|
|
81
|
+
<text class="min-w-0 whitespace-nowrap text-[11px] font-semibold" :style="{ color: pillTheme(i).text }">
|
|
83
82
|
{{ stripParen(languageStore.t(item.title)) }}
|
|
84
83
|
</text>
|
|
85
|
-
<text class="text-[15px] font-extrabold" :style="{ color: pillTheme(i).text }">{{ item.count }}</text>
|
|
86
|
-
<text class="text-[11px]" :style="{ color: pillTheme(i).text, opacity: 0.7 }">{{ languageStore.t('条') }}</text>
|
|
84
|
+
<text class="shrink-0 text-[15px] font-extrabold" :style="{ color: pillTheme(i).text }">{{ item.count }}</text>
|
|
85
|
+
<text class="shrink-0 text-[11px]" :style="{ color: pillTheme(i).text, opacity: 0.7 }">{{ languageStore.t('条') }}</text>
|
|
87
86
|
</view>
|
|
88
87
|
</view>
|
|
89
88
|
</slot>
|
package/package.json
CHANGED
package/store/language.ts
CHANGED
|
@@ -44,6 +44,9 @@ export const useLanguageStore = defineStore('language', () => {
|
|
|
44
44
|
}
|
|
45
45
|
}
|
|
46
46
|
|
|
47
|
+
// 进行中的加载 Promise(按语言缓存):并发调用共享同一个请求,避免重复请求语言包
|
|
48
|
+
const loadingPromises: Record<string, Promise<LanguagePackage>> = {}
|
|
49
|
+
|
|
47
50
|
/**
|
|
48
51
|
* 加载并设置语言
|
|
49
52
|
*/
|
|
@@ -54,14 +57,20 @@ export const useLanguageStore = defineStore('language', () => {
|
|
|
54
57
|
return
|
|
55
58
|
}
|
|
56
59
|
|
|
60
|
+
// 已有同语言请求在进行中时直接复用,不再发新请求
|
|
61
|
+
if (!loadingPromises[lang]) {
|
|
62
|
+
loadingPromises[lang] = loadLanguageFromNetwork(lang).then((langPack) => {
|
|
63
|
+
languagePackages.value[lang] = langPack
|
|
64
|
+
loadedLanguages.value.push(lang)
|
|
65
|
+
return langPack
|
|
66
|
+
}).finally(() => {
|
|
67
|
+
delete loadingPromises[lang]
|
|
68
|
+
})
|
|
69
|
+
}
|
|
70
|
+
|
|
57
71
|
loading.value = true
|
|
58
72
|
try {
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
languagePackages.value[lang] = langPack
|
|
62
|
-
|
|
63
|
-
loadedLanguages.value.push(lang)
|
|
64
|
-
|
|
73
|
+
await loadingPromises[lang]
|
|
65
74
|
currentLanguage.value = lang
|
|
66
75
|
}
|
|
67
76
|
finally {
|