wui-components-v2 1.2.85 → 1.2.87
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.
- package/components/form-control/form-control.vue +26 -7
- package/components/list-top-buttons/list-top-buttons.vue +18 -3
- package/components/search/search.vue +2 -0
- package/components/wui-list/wui-list.vue +8 -2
- package/components/wui-menus1/components/quick-panel.vue +44 -31
- package/components/wui-menus1/wui-menus.vue +2 -2
- package/composables/useSectionMenus.ts +21 -0
- package/package.json +1 -1
|
@@ -25,6 +25,8 @@ const props = defineProps<{
|
|
|
25
25
|
companyFilter?: boolean
|
|
26
26
|
companyFieldSourceId?: string
|
|
27
27
|
smartPaste?: boolean
|
|
28
|
+
/** 严格模式(筛选场景):entity 中存在 key 即视为用户显式设置的值,空值也生效,不再回落到字段默认值 */
|
|
29
|
+
strictEntity?: boolean
|
|
28
30
|
}>()
|
|
29
31
|
const fileTypes = [
|
|
30
32
|
{
|
|
@@ -68,19 +70,36 @@ const giveDefaultValue = (value: any) => {
|
|
|
68
70
|
giveDefaultValue({})
|
|
69
71
|
// 初始化表单数据
|
|
70
72
|
function initFormData() {
|
|
73
|
+
// 读取 entity 中该字段的值:
|
|
74
|
+
// strictEntity(筛选场景)下 key 存在即生效 —— 空串也代表用户已显式清空,
|
|
75
|
+
// 不能回落到字段默认值,否则清空的条件会在下次打开弹窗时"复活";
|
|
76
|
+
// 非 strict 保持原行为:空值视为未设置,回落到 transDefaultValue / defaultValue
|
|
77
|
+
const readEntity = (sourceId: string): { set: boolean; val: any } => {
|
|
78
|
+
const has = !!props.entity && Object.prototype.hasOwnProperty.call(props.entity, sourceId)
|
|
79
|
+
if (has && props.strictEntity) {
|
|
80
|
+
return { set: true, val: props.entity![sourceId] }
|
|
81
|
+
}
|
|
82
|
+
const val = props.entity?.[sourceId]
|
|
83
|
+
if (val === undefined || val === null || val === '') return { set: false, val }
|
|
84
|
+
return { set: true, val }
|
|
85
|
+
}
|
|
71
86
|
const models: { [key: string]: any } = {}
|
|
72
87
|
props.fieldGroup?.fields.forEach((item: Fields) => {
|
|
88
|
+
const ent = readEntity(item.sourceId)
|
|
73
89
|
// 树、多选
|
|
74
90
|
if (
|
|
75
91
|
ControlTypeSupportor.getControlType(item, props.entity && props.entity[item.sourceId]) === 'tree-entity-select' ||
|
|
76
92
|
ControlTypeSupportor.getControlType(item, props.entity && props.entity[item.sourceId]) === 'multiselect'
|
|
77
93
|
) {
|
|
78
|
-
return (models[item.sourceId] =
|
|
79
|
-
(
|
|
94
|
+
return (models[item.sourceId] = ent.set
|
|
95
|
+
? String(ent.val ?? '')
|
|
96
|
+
.split(',')
|
|
97
|
+
.filter(Boolean)
|
|
98
|
+
: item.transDefaultValue || [])
|
|
80
99
|
}
|
|
81
100
|
|
|
82
101
|
if (ControlTypeSupportor.getControlType(item, props.entity && props.entity[item.sourceId]) === 'relselect') {
|
|
83
|
-
const rawRel =
|
|
102
|
+
const rawRel = ent.set ? ent.val : item.transDefaultValue || item.defaultValue || ''
|
|
84
103
|
// 解析 $$user. 占位符:取当前用户对应扩展字段的值(实体字段为 code@R@name,需保留完整值供回显)
|
|
85
104
|
let resolvedRel: any = rawRel
|
|
86
105
|
if (typeof rawRel === 'string' && rawRel.includes('$$user.')) {
|
|
@@ -123,9 +142,10 @@ function initFormData() {
|
|
|
123
142
|
ControlTypeSupportor.getControlType(item, props.entity && props.entity[item.sourceId]) === 'eetime' ||
|
|
124
143
|
ControlTypeSupportor.getControlType(item, props.entity && props.entity[item.sourceId]) === 'date'
|
|
125
144
|
) {
|
|
126
|
-
|
|
145
|
+
// strictEntity 下用户已显式清空(entity 值为空)时不回落到默认值,保持为 null(未选择)
|
|
146
|
+
const entityVal = ent.set ? ent.val : ''
|
|
127
147
|
// 解析默认值:支持 $$currentD(今天)、纯数字时间戳、日期字符串
|
|
128
|
-
const defaultVal = item.transDefaultValue || item.defaultValue || ''
|
|
148
|
+
const defaultVal = ent.set ? '' : item.transDefaultValue || item.defaultValue || ''
|
|
129
149
|
const resolvedDefault = defaultVal
|
|
130
150
|
? defaultVal === '$$currentD'
|
|
131
151
|
? dayjs().format('YYYY-MM-DD')
|
|
@@ -153,8 +173,7 @@ function initFormData() {
|
|
|
153
173
|
return (models[item.sourceId] = isYes ? '是' : '否')
|
|
154
174
|
}
|
|
155
175
|
|
|
156
|
-
return (models[item.sourceId] =
|
|
157
|
-
(props.entity && props.entity[item.sourceId]) || item.transDefaultValue || item.defaultValue || '')
|
|
176
|
+
return (models[item.sourceId] = ent.set ? ent.val ?? '' : item.transDefaultValue || item.defaultValue || '')
|
|
158
177
|
})
|
|
159
178
|
|
|
160
179
|
// 遍历 models,处理 $$user. 前缀
|
|
@@ -288,6 +288,15 @@ function downloadExportFile() {
|
|
|
288
288
|
|
|
289
289
|
console.log(props.buttons, '33333')
|
|
290
290
|
|
|
291
|
+
// 顶部可见按钮数量:仅剩一个时按钮不拉伸占满整行(去掉 flex-1,按内容自适应宽度)
|
|
292
|
+
const visibleBtnCount = computed(() => {
|
|
293
|
+
let count = 0
|
|
294
|
+
if (props.buttons.includes('dtmplAdd')) count++
|
|
295
|
+
if (props.buttons.includes('exportLtmplExcel')) count++
|
|
296
|
+
if (props.batchOpsVisible !== false) count++
|
|
297
|
+
return count
|
|
298
|
+
})
|
|
299
|
+
|
|
291
300
|
// 供父组件(如 wui-list 底部批量操作条)触发文件导出弹窗
|
|
292
301
|
defineExpose({
|
|
293
302
|
openExportPopup,
|
|
@@ -296,11 +305,17 @@ defineExpose({
|
|
|
296
305
|
|
|
297
306
|
<template>
|
|
298
307
|
<view v-if="showButtons" class="flex justify-end gap-1 py-2 px-2 bg-white dark:bg-[var(--wot-dark-background)]">
|
|
299
|
-
<wd-button
|
|
308
|
+
<wd-button
|
|
309
|
+
:class="visibleBtnCount > 1 ? 'flex-1' : ''"
|
|
310
|
+
v-if="buttons.includes('dtmplAdd')"
|
|
311
|
+
type="primary"
|
|
312
|
+
@click="gotoAddPage"
|
|
313
|
+
icon="plus"
|
|
314
|
+
>
|
|
300
315
|
{{ props.config?.editBtnTitle || '新增' }}
|
|
301
316
|
</wd-button>
|
|
302
317
|
<wd-button
|
|
303
|
-
class="flex-1"
|
|
318
|
+
:class="visibleBtnCount > 1 ? 'flex-1' : ''"
|
|
304
319
|
v-if="buttons.includes('exportLtmplExcel')"
|
|
305
320
|
type="primary"
|
|
306
321
|
@click="openExportPopup()"
|
|
@@ -312,7 +327,7 @@ defineExpose({
|
|
|
312
327
|
<slot />
|
|
313
328
|
<wd-button
|
|
314
329
|
v-if="props.batchOpsVisible !== false"
|
|
315
|
-
class="flex-1"
|
|
330
|
+
:class="visibleBtnCount > 1 ? 'flex-1' : ''"
|
|
316
331
|
type="primary"
|
|
317
332
|
@click="emit('batchEdit')"
|
|
318
333
|
:icon="props.batchEditing ? 'close' : 'edit'"
|
|
@@ -186,6 +186,7 @@ function handleSubmit() {
|
|
|
186
186
|
}"
|
|
187
187
|
:entity="entity"
|
|
188
188
|
:enum-column="enumColumn"
|
|
189
|
+
strict-entity
|
|
189
190
|
/>
|
|
190
191
|
</view>
|
|
191
192
|
<view v-if="showSearch" class="w-full">
|
|
@@ -235,6 +236,7 @@ function handleSubmit() {
|
|
|
235
236
|
}"
|
|
236
237
|
:entity="entity"
|
|
237
238
|
:enum-column="enumColumn"
|
|
239
|
+
strict-entity
|
|
238
240
|
/>
|
|
239
241
|
<view class="h-12" />
|
|
240
242
|
<view
|
|
@@ -183,6 +183,8 @@ const queryKey = ref('') // 用于导出接口的列表查询 key
|
|
|
183
183
|
const menuId = ref('')
|
|
184
184
|
/** URL 跳转携带的筛选默认值(key 为字段 sourceId,去掉 c_ 前缀),作为筛选条件默认值 */
|
|
185
185
|
const urlDefaultCriteria = ref<{ [key: string]: any }>({})
|
|
186
|
+
/** 用户是否已主动提交过筛选:提交后以用户条件为准,不再重新补默认值(否则清空的条件会被默认值"复活"传给后端) */
|
|
187
|
+
const userFiltered = ref(false)
|
|
186
188
|
const addEvent = generateHighResolutionID() // 全局事件名称
|
|
187
189
|
const toast = useGlobalToast()
|
|
188
190
|
const message = useGlobalMessage()
|
|
@@ -516,8 +518,9 @@ async function queryList(pageNo: number, pageSize: number) {
|
|
|
516
518
|
qre = qre ? `${qre}&${props.query}` : props.query
|
|
517
519
|
}
|
|
518
520
|
// URL 跳转携带的筛选默认值:无其他查询条件时,作为初始查询条件并入
|
|
521
|
+
// (用户主动筛选过后不再并入,避免清空的条件被默认值重新拼回查询串)
|
|
519
522
|
const urlKeys = Object.keys(urlDefaultCriteria.value)
|
|
520
|
-
if (!qre && urlKeys.length) {
|
|
523
|
+
if (!qre && !userFiltered.value && urlKeys.length) {
|
|
521
524
|
qre = urlKeys.map(key => `c_${key}=${urlDefaultCriteria.value[key]}`).join('&')
|
|
522
525
|
}
|
|
523
526
|
// 解析 qre 为键值对:search 组件会把用户未填写的筛选项拼成 `c_xxx=` 空参数,
|
|
@@ -533,7 +536,9 @@ async function queryList(pageNo: number, pageSize: number) {
|
|
|
533
536
|
if (v === '') return
|
|
534
537
|
parts.push([k, v])
|
|
535
538
|
})
|
|
536
|
-
|
|
539
|
+
// 页面级默认查询条件只在用户主动筛选前生效;
|
|
540
|
+
// 筛选弹窗里被清空的条件不会再被这里重新拼回查询串传给后端
|
|
541
|
+
if (config.value.defaultCriteriaValue && !userFiltered.value) {
|
|
537
542
|
for (const key in config.value.defaultCriteriaValue) {
|
|
538
543
|
if (Object.prototype.hasOwnProperty.call(config.value.defaultCriteriaValue, key)) {
|
|
539
544
|
let element = config.value.defaultCriteriaValue[key]
|
|
@@ -570,6 +575,7 @@ async function queryList(pageNo: number, pageSize: number) {
|
|
|
570
575
|
}
|
|
571
576
|
|
|
572
577
|
function submitSearch(data: any) {
|
|
578
|
+
userFiltered.value = true
|
|
573
579
|
searchData.value = data
|
|
574
580
|
// for (const key in data) {
|
|
575
581
|
// if (Object.prototype.hasOwnProperty.call(data, key)) {
|
|
@@ -1,29 +1,30 @@
|
|
|
1
1
|
<script lang="ts" setup>
|
|
2
|
-
import {
|
|
2
|
+
import type { PropType } from 'vue'
|
|
3
|
+
import { computed, defineOptions, defineProps } from 'vue'
|
|
3
4
|
import { useSectionMenus } from '../../../composables/useSectionMenus'
|
|
4
5
|
import { useLanguageStore } from '../../../store/language'
|
|
5
6
|
|
|
6
7
|
defineOptions({
|
|
7
8
|
name: 'QuickPanel',
|
|
8
9
|
})
|
|
9
|
-
const
|
|
10
|
-
|
|
10
|
+
const props = defineProps({
|
|
11
|
+
// 点击统计项回调:返回 true 表示已处理(不再走默认逻辑)
|
|
12
|
+
itemClick: {
|
|
13
|
+
type: Function as PropType<(item: any) => boolean | void>,
|
|
14
|
+
default: null,
|
|
15
|
+
},
|
|
16
|
+
})
|
|
11
17
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
{ id: 'mock-5', title: '声音报警', count: 23, icon: '', pageType: '' },
|
|
19
|
-
{ id: 'mock-6', title: '振动报警', count: 41, icon: '', pageType: '' },
|
|
20
|
-
{ id: 'mock-7', title: '温度报警', count: 9, icon: '', pageType: '' },
|
|
21
|
-
]
|
|
22
|
-
const stats = computed(() => (quickPanel.value.length > 0 ? quickPanel.value : mockItems))
|
|
18
|
+
function handleClick(item: any) {
|
|
19
|
+
if (props.itemClick)
|
|
20
|
+
props.itemClick(item)
|
|
21
|
+
}
|
|
22
|
+
const { quickPanel, capsuleMenu } = useSectionMenus(true)
|
|
23
|
+
const languageStore = useLanguageStore()
|
|
23
24
|
|
|
24
|
-
//
|
|
25
|
-
const tiles = computed(() =>
|
|
26
|
-
const pills = computed(() =>
|
|
25
|
+
// 统计块来自 QuickPanel,告警胶囊来自 CapsuleMenu
|
|
26
|
+
const tiles = computed(() => quickPanel.value)
|
|
27
|
+
const pills = computed(() => capsuleMenu.value)
|
|
27
28
|
|
|
28
29
|
// 胶囊配色循环使用(半透明底色,暗黑模式下同样适用)
|
|
29
30
|
const pillThemes = [
|
|
@@ -35,42 +36,54 @@ const pillThemes = [
|
|
|
35
36
|
function pillTheme(index: number) {
|
|
36
37
|
return pillThemes[index % pillThemes.length]
|
|
37
38
|
}
|
|
39
|
+
|
|
40
|
+
// 去掉标题中的括号及括号内容,如「设备总数(台)」→「设备总数」
|
|
41
|
+
function stripParen(text: string) {
|
|
42
|
+
return text.replace(/([^)]*)|\([^)]*\)/g, '')
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
// 数字字体色:取该项配置的图标颜色(themeColor 字段),非颜色值时回退默认色
|
|
46
|
+
function numColor(item: { themeColor?: string }) {
|
|
47
|
+
const color = item.themeColor || ''
|
|
48
|
+
return /^(#|rgb)/i.test(color) ? color : ''
|
|
49
|
+
}
|
|
38
50
|
</script>
|
|
39
51
|
|
|
40
52
|
<template>
|
|
41
|
-
<view v-if="
|
|
53
|
+
<view v-if="quickPanel.length > 0 || capsuleMenu.length > 0" class="mb-3">
|
|
42
54
|
<view class="rounded-2xl bg-white p-4 shadow-[0_4px_16px_rgba(0,0,0,0.04)] dark:bg-black">
|
|
43
55
|
<view class="mb-3 flex items-center gap-2 text-size-4 font-bold text-gray-800 dark:text-white">
|
|
44
56
|
{{ languageStore.t('数据统计') }}
|
|
45
57
|
</view>
|
|
46
58
|
<!-- 作用域插槽:调用方可完全自定义统计内容 -->
|
|
47
|
-
<slot :items="
|
|
59
|
+
<slot :items="quickPanel" :tiles="tiles" :pills="pills">
|
|
48
60
|
<!-- 统计块 -->
|
|
49
61
|
<view class="grid grid-cols-4 gap-2">
|
|
50
|
-
<view v-for="item in tiles" :key="item.id" class="rounded-xl bg-[#f6f7f9] px-1 py-3 dark:bg-white/10">
|
|
62
|
+
<view v-for="item in tiles" :key="item.id" class="rounded-xl bg-[#f6f7f9] px-1 py-3 dark:bg-white/10" @click="handleClick(item)">
|
|
51
63
|
<view class="flex items-baseline justify-center gap-0.5">
|
|
52
|
-
<text class="text-
|
|
53
|
-
<text class="text-
|
|
64
|
+
<text class="text-[16px] font-extrabold text-gray-900 dark:text-white" :style="{ color: numColor(item) }">{{ item.count }}</text>
|
|
65
|
+
<text class="text-[11px] text-gray-500 dark:text-gray-400">{{ languageStore.t('台') }}</text>
|
|
54
66
|
</view>
|
|
55
|
-
<view class="mt-1 text-center text-
|
|
56
|
-
{{ languageStore.t(item.title) }}
|
|
67
|
+
<view class="mt-1 text-center text-[11px] text-gray-500 dark:text-gray-400">
|
|
68
|
+
{{ stripParen(languageStore.t(item.title)) }}
|
|
57
69
|
</view>
|
|
58
70
|
</view>
|
|
59
71
|
</view>
|
|
60
72
|
<!-- 告警胶囊 -->
|
|
61
|
-
<view v-if="pills.length" class="mt-
|
|
73
|
+
<view v-if="pills.length" class="mt-1.5 flex gap-0.5 overflow-hidden">
|
|
62
74
|
<view
|
|
63
75
|
v-for="(item, i) in pills"
|
|
64
76
|
:key="item.id"
|
|
65
|
-
class="flex items-center gap-
|
|
77
|
+
class="flex flex-1 items-center justify-center gap-0.5 overflow-hidden whitespace-nowrap rounded-md py-1"
|
|
66
78
|
:style="{ background: pillTheme(i).bg }"
|
|
79
|
+
@click="handleClick(item)"
|
|
67
80
|
>
|
|
68
|
-
<view class="h-
|
|
69
|
-
<text class="text-
|
|
70
|
-
{{ languageStore.t(item.title) }}
|
|
81
|
+
<view class="h-1.5 w-1.5 shrink-0 rounded-full" :style="{ background: pillTheme(i).dot }" />
|
|
82
|
+
<text class="text-[11px] font-semibold" :style="{ color: pillTheme(i).text }">
|
|
83
|
+
{{ stripParen(languageStore.t(item.title)) }}
|
|
71
84
|
</text>
|
|
72
|
-
<text class="text-
|
|
73
|
-
<text class="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>
|
|
74
87
|
</view>
|
|
75
88
|
</view>
|
|
76
89
|
</slot>
|
|
@@ -142,8 +142,8 @@ onMounted(() => {
|
|
|
142
142
|
<slot name="section-item-text" :item="item" :t="t" :goto="goto" />
|
|
143
143
|
</template>
|
|
144
144
|
</sectionMenus>
|
|
145
|
-
<!-- 统计
|
|
146
|
-
<quickPanel v-if="props.showQuickPanel">
|
|
145
|
+
<!-- 统计 -->
|
|
146
|
+
<quickPanel v-if="themeConfig?.showHomePage && props.showQuickPanel" :item-click="handleItemClick">
|
|
147
147
|
<template #default="{ items, tiles, pills }">
|
|
148
148
|
<slot name="quickPanel" :items="items" :tiles="tiles" :pills="pills" />
|
|
149
149
|
</template>
|
|
@@ -11,6 +11,7 @@ export interface MenuCount {
|
|
|
11
11
|
export function useSectionMenus(isInterval: boolean = false) {
|
|
12
12
|
const messageBar = ref<MenuCount | null>(null)
|
|
13
13
|
const quickPanel = ref<MenuCount[]>([])
|
|
14
|
+
const capsuleMenu = ref<MenuCount[]>([])
|
|
14
15
|
const rightSidebar01 = ref<MenuCount[]>([])
|
|
15
16
|
const rightSidebar02 = ref<MenuCount[]>([])
|
|
16
17
|
// 手动调用并启动定时器
|
|
@@ -53,6 +54,15 @@ export function useSectionMenus(isInterval: boolean = false) {
|
|
|
53
54
|
)
|
|
54
55
|
}
|
|
55
56
|
|
|
57
|
+
if (capsuleMenu.value.length > 0) {
|
|
58
|
+
capsuleMenu.value = await Promise.all(
|
|
59
|
+
capsuleMenu.value.map(async (item) => {
|
|
60
|
+
const count = await getmenuCount(item.id)
|
|
61
|
+
return { ...item, count }
|
|
62
|
+
}),
|
|
63
|
+
)
|
|
64
|
+
}
|
|
65
|
+
|
|
56
66
|
// 设置定时器,每隔 1000*60*2 秒执行一次
|
|
57
67
|
const intervalId = setInterval(async () => {
|
|
58
68
|
try {
|
|
@@ -69,6 +79,15 @@ export function useSectionMenus(isInterval: boolean = false) {
|
|
|
69
79
|
}),
|
|
70
80
|
)
|
|
71
81
|
}
|
|
82
|
+
|
|
83
|
+
if (capsuleMenu.value.length > 0) {
|
|
84
|
+
capsuleMenu.value = await Promise.all(
|
|
85
|
+
capsuleMenu.value.map(async (item) => {
|
|
86
|
+
const count = await getmenuCount(item.id)
|
|
87
|
+
return { ...item, count }
|
|
88
|
+
}),
|
|
89
|
+
)
|
|
90
|
+
}
|
|
72
91
|
}
|
|
73
92
|
catch (error) {
|
|
74
93
|
console.log(error)
|
|
@@ -90,6 +109,7 @@ export function useSectionMenus(isInterval: boolean = false) {
|
|
|
90
109
|
if (res.fastMenu) {
|
|
91
110
|
messageBar.value = res.fastMenu.MessageBar ? res.fastMenu.MessageBar[0] : null
|
|
92
111
|
quickPanel.value = res.fastMenu?.QuickPanel || []
|
|
112
|
+
capsuleMenu.value = res.fastMenu?.CapsuleMenu || res.fastMenu?.capsuleMenu || []
|
|
93
113
|
rightSidebar01.value = res.fastMenu?.RightSidebar01 || []
|
|
94
114
|
rightSidebar02.value = res.fastMenu?.RightSidebar02 || []
|
|
95
115
|
// 清除之前的定时器(防止重复创建)
|
|
@@ -114,6 +134,7 @@ export function useSectionMenus(isInterval: boolean = false) {
|
|
|
114
134
|
return {
|
|
115
135
|
messageBar,
|
|
116
136
|
quickPanel,
|
|
137
|
+
capsuleMenu,
|
|
117
138
|
rightSidebar01,
|
|
118
139
|
rightSidebar02,
|
|
119
140
|
}
|