wui-components-v2 1.2.86 → 1.2.88
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/api/core/index.ts +3 -1
- package/api/page.ts +30 -7
- package/components/form-control/form-control.vue +26 -7
- package/components/search/search.vue +2 -0
- package/components/wui-list/wui-list.vue +24 -7
- package/components/wui-menus1/components/quick-panel.vue +44 -31
- package/components/wui-menus1/wui-menus.vue +2 -2
- package/composables/useMenus.ts +6 -2
- package/composables/useSectionMenus.ts +21 -0
- package/package.json +1 -1
package/api/core/index.ts
CHANGED
|
@@ -43,10 +43,12 @@ function request(options: RequestOptions): Promise<any> {
|
|
|
43
43
|
timeout: options.timeout || 60000,
|
|
44
44
|
}
|
|
45
45
|
|
|
46
|
-
//
|
|
46
|
+
// 合并配置(header 以 defaultOptions 为准:默认项已并入 options.header,
|
|
47
|
+
// 不能被 ...options 整体覆盖,否则传自定义 header 会丢掉登录 token 等默认头)
|
|
47
48
|
const requestOptions = {
|
|
48
49
|
...defaultOptions,
|
|
49
50
|
...options,
|
|
51
|
+
header: defaultOptions.header,
|
|
50
52
|
url: baseUrl + options.url,
|
|
51
53
|
}
|
|
52
54
|
|
package/api/page.ts
CHANGED
|
@@ -7,9 +7,14 @@ interface PageConfig {
|
|
|
7
7
|
sourceId: string
|
|
8
8
|
sourceName: string
|
|
9
9
|
}
|
|
10
|
+
// targetProgram 存在时替换请求头中的 hydrocarbon-program-token(首页菜单跳转透传)
|
|
11
|
+
function targetHeader(targetProgram?: string) {
|
|
12
|
+
return targetProgram ? { header: { 'hydrocarbon-program-token': targetProgram } } : {}
|
|
13
|
+
}
|
|
14
|
+
|
|
10
15
|
// 列表页面配置
|
|
11
|
-
export async function pageConfig(sourceId: string): Promise<PageConfig> {
|
|
12
|
-
const res = (await req({ url: `/v3/ltmpl/config?sourceId=${sourceId}
|
|
16
|
+
export async function pageConfig(sourceId: string, targetProgram: string = ''): Promise<PageConfig> {
|
|
17
|
+
const res = (await req({ url: `/v3/ltmpl/config?sourceId=${sourceId}`, ...targetHeader(targetProgram) })) || {}
|
|
13
18
|
const { ltmplConfig = {} } = res
|
|
14
19
|
const { extDisplayConfig = {} } = ltmplConfig
|
|
15
20
|
return {
|
|
@@ -23,18 +28,34 @@ export async function pageConfig(sourceId: string): Promise<PageConfig> {
|
|
|
23
28
|
}
|
|
24
29
|
|
|
25
30
|
// 获取列表页面数据key
|
|
26
|
-
export function pageKey(
|
|
31
|
+
export function pageKey(
|
|
32
|
+
sourceId: string,
|
|
33
|
+
mainCode: string = '',
|
|
34
|
+
query: string = '',
|
|
35
|
+
menuId: string = '',
|
|
36
|
+
targetProgram: string = '',
|
|
37
|
+
serverKey: string = ''
|
|
38
|
+
) {
|
|
27
39
|
// menuId 未传时回退为 sourceId,保持原有行为
|
|
28
40
|
const menu = menuId || sourceId
|
|
41
|
+
// serverKey:cp_ 拼当前模块 sourceId,用于服务端路由数据源
|
|
42
|
+
const server = serverKey ? `&serverKey=${serverKey}` : ''
|
|
29
43
|
return req({
|
|
30
|
-
url: `/v3/ltmpl/query/key?sourceId=${sourceId}&mainCode=${mainCode}&menuId=${menu}&${query}`,
|
|
44
|
+
url: `/v3/ltmpl/query/key?sourceId=${sourceId}&mainCode=${mainCode}&menuId=${menu}${server}&${query}`,
|
|
45
|
+
...targetHeader(targetProgram),
|
|
31
46
|
})
|
|
32
47
|
}
|
|
33
48
|
|
|
34
49
|
// 获取列表页面数据
|
|
35
|
-
export function listData(
|
|
50
|
+
export function listData(
|
|
51
|
+
queryKey: string,
|
|
52
|
+
pageNo: number,
|
|
53
|
+
pageSize: number,
|
|
54
|
+
targetProgram: string = ''
|
|
55
|
+
): Promise<PageData> {
|
|
36
56
|
return req({
|
|
37
57
|
url: `/v3/ltmpl/query/data?queryKey=${queryKey}&pageNo=${pageNo}&pageSize=${pageSize}`,
|
|
58
|
+
...targetHeader(targetProgram),
|
|
38
59
|
})
|
|
39
60
|
}
|
|
40
61
|
|
|
@@ -109,7 +130,7 @@ export function detailPageData(sourceId: string, code: string) {
|
|
|
109
130
|
}
|
|
110
131
|
|
|
111
132
|
// action 按钮提交数据
|
|
112
|
-
export function actionDataSave(sourceId: string, codes: string = '', data: any) {
|
|
133
|
+
export function actionDataSave(sourceId: string, codes: string = '', data: any, targetProgram: string = '') {
|
|
113
134
|
return req({
|
|
114
135
|
url: `/v3/action`,
|
|
115
136
|
method: 'POST',
|
|
@@ -118,14 +139,16 @@ export function actionDataSave(sourceId: string, codes: string = '', data: any)
|
|
|
118
139
|
codes,
|
|
119
140
|
...data,
|
|
120
141
|
},
|
|
142
|
+
...targetHeader(targetProgram),
|
|
121
143
|
})
|
|
122
144
|
}
|
|
123
145
|
|
|
124
146
|
// 删除
|
|
125
|
-
export function deleteData(sourceId: string, code: string) {
|
|
147
|
+
export function deleteData(sourceId: string, code: string, targetProgram: string = '') {
|
|
126
148
|
return req({
|
|
127
149
|
url: `/v3/ltmpl/data?sourceId=${sourceId}&codes=${code}`,
|
|
128
150
|
method: 'DELETE',
|
|
151
|
+
...targetHeader(targetProgram),
|
|
129
152
|
})
|
|
130
153
|
}
|
|
131
154
|
// 复制数据(copyonly 模式):直接调用后端复制接口复制当前行
|
|
@@ -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. 前缀
|
|
@@ -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
|
|
@@ -181,8 +181,12 @@ const mainCode = ref('')
|
|
|
181
181
|
const queryKey = ref('') // 用于导出接口的列表查询 key
|
|
182
182
|
/** URL 跳转携带的菜单 ID,用于 pageKey 请求的 menuId 参数 */
|
|
183
183
|
const menuId = ref('')
|
|
184
|
+
/** 首页菜单携带的 targetProgram,存在时替换请求头中的 hydrocarbon-program-token */
|
|
185
|
+
const targetProgram = ref('')
|
|
184
186
|
/** URL 跳转携带的筛选默认值(key 为字段 sourceId,去掉 c_ 前缀),作为筛选条件默认值 */
|
|
185
187
|
const urlDefaultCriteria = ref<{ [key: string]: any }>({})
|
|
188
|
+
/** 用户是否已主动提交过筛选:提交后以用户条件为准,不再重新补默认值(否则清空的条件会被默认值"复活"传给后端) */
|
|
189
|
+
const userFiltered = ref(false)
|
|
186
190
|
const addEvent = generateHighResolutionID() // 全局事件名称
|
|
187
191
|
const toast = useGlobalToast()
|
|
188
192
|
const message = useGlobalMessage()
|
|
@@ -349,7 +353,7 @@ function batchDelete() {
|
|
|
349
353
|
title: '提示',
|
|
350
354
|
beforeConfirm: async ({ resolve }) => {
|
|
351
355
|
try {
|
|
352
|
-
const res = await deleteData(internalSourceId.value, codes.join(','))
|
|
356
|
+
const res = await deleteData(internalSourceId.value, codes.join(','), targetProgram.value)
|
|
353
357
|
if (res.status === 'success') {
|
|
354
358
|
toast.success({ msg: '删除成功!' })
|
|
355
359
|
props.batchDeleteSuccess?.(codes)
|
|
@@ -406,7 +410,7 @@ async function batchAction(item: rowActions) {
|
|
|
406
410
|
// 消费完立即清空,避免 messageOptions 残留
|
|
407
411
|
message.close()
|
|
408
412
|
try {
|
|
409
|
-
await actionDataSave(item.id, codes.join(','), {})
|
|
413
|
+
await actionDataSave(item.id, codes.join(','), {}, targetProgram.value)
|
|
410
414
|
toast.success({ msg: '操作成功!' })
|
|
411
415
|
clearSelection()
|
|
412
416
|
Zpaging.value.reload()
|
|
@@ -440,6 +444,7 @@ onLoad((option: any) => {
|
|
|
440
444
|
pageType.value = option.pageType
|
|
441
445
|
mainCode.value = option.mainCode || ''
|
|
442
446
|
menuId.value = option.menuId || ''
|
|
447
|
+
targetProgram.value = safeDecode(option.targetProgram)
|
|
443
448
|
uni.setNavigationBarTitle({
|
|
444
449
|
title: pageTitle.value,
|
|
445
450
|
})
|
|
@@ -486,7 +491,7 @@ onUnmounted(() => {
|
|
|
486
491
|
})
|
|
487
492
|
async function getPageConfig() {
|
|
488
493
|
try {
|
|
489
|
-
const res = await pageConfig(internalSourceId.value)
|
|
494
|
+
const res = await pageConfig(internalSourceId.value, targetProgram.value)
|
|
490
495
|
if (res.ltmplConfig) {
|
|
491
496
|
config.value = res.ltmplConfig
|
|
492
497
|
console.log('config', config.value)
|
|
@@ -516,8 +521,9 @@ async function queryList(pageNo: number, pageSize: number) {
|
|
|
516
521
|
qre = qre ? `${qre}&${props.query}` : props.query
|
|
517
522
|
}
|
|
518
523
|
// URL 跳转携带的筛选默认值:无其他查询条件时,作为初始查询条件并入
|
|
524
|
+
// (用户主动筛选过后不再并入,避免清空的条件被默认值重新拼回查询串)
|
|
519
525
|
const urlKeys = Object.keys(urlDefaultCriteria.value)
|
|
520
|
-
if (!qre && urlKeys.length) {
|
|
526
|
+
if (!qre && !userFiltered.value && urlKeys.length) {
|
|
521
527
|
qre = urlKeys.map(key => `c_${key}=${urlDefaultCriteria.value[key]}`).join('&')
|
|
522
528
|
}
|
|
523
529
|
// 解析 qre 为键值对:search 组件会把用户未填写的筛选项拼成 `c_xxx=` 空参数,
|
|
@@ -533,7 +539,9 @@ async function queryList(pageNo: number, pageSize: number) {
|
|
|
533
539
|
if (v === '') return
|
|
534
540
|
parts.push([k, v])
|
|
535
541
|
})
|
|
536
|
-
|
|
542
|
+
// 页面级默认查询条件只在用户主动筛选前生效;
|
|
543
|
+
// 筛选弹窗里被清空的条件不会再被这里重新拼回查询串传给后端
|
|
544
|
+
if (config.value.defaultCriteriaValue && !userFiltered.value) {
|
|
537
545
|
for (const key in config.value.defaultCriteriaValue) {
|
|
538
546
|
if (Object.prototype.hasOwnProperty.call(config.value.defaultCriteriaValue, key)) {
|
|
539
547
|
let element = config.value.defaultCriteriaValue[key]
|
|
@@ -553,8 +561,16 @@ async function queryList(pageNo: number, pageSize: number) {
|
|
|
553
561
|
|
|
554
562
|
try {
|
|
555
563
|
console.log('qre', qre)
|
|
556
|
-
|
|
557
|
-
const
|
|
564
|
+
// serverKey:cp_ 拼当前模块 sourceId
|
|
565
|
+
const res = await pageKey(
|
|
566
|
+
internalSourceId.value,
|
|
567
|
+
mainCode.value,
|
|
568
|
+
qre,
|
|
569
|
+
menuId.value,
|
|
570
|
+
targetProgram.value,
|
|
571
|
+
`cp_${internalSourceId.value}`
|
|
572
|
+
) // 获取key
|
|
573
|
+
const data = await listData(res.key, pageNo, pageSize, targetProgram.value) // 获取数据
|
|
558
574
|
// 缓存最新一次的 queryKey,给顶部「导出」接口使用
|
|
559
575
|
queryKey.value = res.key || res.data?.key || ''
|
|
560
576
|
// const count = await getPageTotal(key.data?.key)// 获取总数
|
|
@@ -570,6 +586,7 @@ async function queryList(pageNo: number, pageSize: number) {
|
|
|
570
586
|
}
|
|
571
587
|
|
|
572
588
|
function submitSearch(data: any) {
|
|
589
|
+
userFiltered.value = true
|
|
573
590
|
searchData.value = data
|
|
574
591
|
// for (const key in data) {
|
|
575
592
|
// 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>
|
package/composables/useMenus.ts
CHANGED
|
@@ -21,6 +21,7 @@ export interface MenuItem {
|
|
|
21
21
|
color: string
|
|
22
22
|
tip: string
|
|
23
23
|
pageType: string
|
|
24
|
+
targetProgram?: string
|
|
24
25
|
children?: MenuItem[]
|
|
25
26
|
}
|
|
26
27
|
export function useMenus(props?: Props, pagingRef?: Ref<any>) {
|
|
@@ -60,10 +61,13 @@ export function useMenus(props?: Props, pagingRef?: Ref<any>) {
|
|
|
60
61
|
function goto(item: MenuItem) {
|
|
61
62
|
console.log(item.pageType)
|
|
62
63
|
switch (item.pageType) {
|
|
63
|
-
case '列表':
|
|
64
|
+
case '列表': {
|
|
64
65
|
console.log(item, 'item ')
|
|
65
|
-
|
|
66
|
+
// 菜单数据存在 targetProgram 时携带给列表页,列表页请求接口时透传
|
|
67
|
+
const targetProgram = item.targetProgram ? `&targetProgram=${item.targetProgram}` : ''
|
|
68
|
+
router.push(`/pages/list/index?sourceId=${item.id}&title=${item.title}${targetProgram}`)
|
|
66
69
|
return true
|
|
70
|
+
}
|
|
67
71
|
case '树':
|
|
68
72
|
router.push(`/pages/tree-page/index?sourceId=${item.id}&title=${item.title}`)
|
|
69
73
|
return true
|
|
@@ -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
|
}
|