wui-components-v2 1.1.69 → 1.1.70
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 +74 -74
- package/api/menu.ts +45 -45
- package/api/page.ts +114 -114
- package/api/sys.ts +12 -12
- package/components/add-address-page/add-address-page.vue +77 -77
- package/components/custom-date-picker/custom-date-picker.vue +106 -106
- package/components/custom-select-picker/custom-select-picker.vue +95 -95
- package/components/demo-block/demo-block.vue +63 -63
- package/components/detail-popup/detail-popup.vue +99 -99
- package/components/evaluation-page/evaluation-page.vue +196 -196
- package/components/fold-card/fold-card.vue +171 -171
- package/components/form-control/form-control.vue +661 -661
- package/components/global-message/global-message.vue +68 -68
- package/components/label-value/label-value.vue +144 -144
- package/components/list-top-buttons/list-top-buttons.vue +19 -19
- package/components/login-form/login-form.vue +126 -126
- package/components/mulselect-picker/mulselect-picker.vue +86 -86
- package/components/product-card/product-card.vue +201 -201
- package/components/search/search.vue +128 -128
- package/components/user-choose/user-choose.vue +1 -1
- package/components/wui-enume-select-control/wui-enume-select-control.vue +92 -92
- package/components/wui-list/wui-list.vue +235 -235
- package/components/wui-menus/wui-menus.vue +247 -247
- package/components/wui-menus1/components/navbar.vue +43 -43
- package/components/wui-menus1/wui-menus.vue +564 -564
- package/components/wui-notify-info/wui-notify-info.vue +280 -280
- package/components/wui-search-history-babbar/wui-search-history-babbar.vue +204 -204
- package/components/wui-select-list/wui-select-list.vue +310 -310
- package/components/wui-select-popup/wui-select-popup.vue +612 -612
- package/components/wui-system-settings/wui-system-settings.vue +144 -144
- package/components/wui-tabbar/wui-tabbar.vue +106 -106
- package/components/wui-tree-page/components/tree-item.vue +238 -238
- package/components/wui-user/wui-user.vue +202 -202
- package/composables/useCompanyFieldFilter.ts +91 -91
- package/composables/useEnumes.ts +2 -2
- package/composables/useMenus.ts +193 -193
- package/index.ts +83 -83
- package/package.json +1 -1
- package/static/iconfont/iconfont.css +63 -63
- package/store/language.ts +151 -151
- package/styles/dark-mode.css +523 -523
- package/styles/dark-mode.min.css +1 -1
- package/type.ts +2 -2
- package/utils/control-tree.ts +2 -2
- package/utils/control-type-supportor.ts +148 -148
|
@@ -1,280 +1,280 @@
|
|
|
1
|
-
<script setup lang="ts">
|
|
2
|
-
import { computed, defineOptions, watch } from 'vue'
|
|
3
|
-
import { useRouter } from 'uni-mini-router'
|
|
4
|
-
import { enums, listData, pageConfig, pageKey } from '../../api/page'
|
|
5
|
-
import { useSectionMenus } from '../../composables/useSectionMenus'
|
|
6
|
-
import { formatItemData } from '../../utils'
|
|
7
|
-
import ControlTypeSupportor from '../../utils/control-type-supportor'
|
|
8
|
-
import { useLanguageStore } from '../../store/language'
|
|
9
|
-
import type { Config, Entities, Enums } from '../../type'
|
|
10
|
-
|
|
11
|
-
defineOptions({
|
|
12
|
-
name: 'WuiNotifyInfo',
|
|
13
|
-
})
|
|
14
|
-
const languageStore = useLanguageStore()
|
|
15
|
-
const { rightSidebar01, rightSidebar02 } = useSectionMenus()
|
|
16
|
-
// const getIcon = (type: string) => {
|
|
17
|
-
// switch (type) {
|
|
18
|
-
// case 'system': return BellIcon
|
|
19
|
-
// case 'department': return MegaphoneIcon
|
|
20
|
-
// case 'colleague': return ChatBubbleLeftIcon
|
|
21
|
-
// default: return BellIcon
|
|
22
|
-
// }
|
|
23
|
-
// }
|
|
24
|
-
const dtmplConfig = ref<{ [key: string]: Config }>({})
|
|
25
|
-
const enumColumn = ref<{ [key: string]: Enums }>({})
|
|
26
|
-
interface Data {
|
|
27
|
-
type: 'system'
|
|
28
|
-
read: boolean
|
|
29
|
-
id: string
|
|
30
|
-
primaryColumn: string
|
|
31
|
-
primaryColumnLabel: string
|
|
32
|
-
secondColumn: string
|
|
33
|
-
secondColumnLabel: string
|
|
34
|
-
primaryColumnLabelConfig: any
|
|
35
|
-
primaryColumnConfig: any
|
|
36
|
-
secondColumnConfig: any
|
|
37
|
-
secondColumnLabelConfig: any
|
|
38
|
-
sourceid: string
|
|
39
|
-
data: Entities
|
|
40
|
-
}
|
|
41
|
-
interface Notification {
|
|
42
|
-
id: string
|
|
43
|
-
title: string
|
|
44
|
-
data: Data[]
|
|
45
|
-
}
|
|
46
|
-
const router = useRouter()
|
|
47
|
-
const notifications = ref<Notification[] | null>([])
|
|
48
|
-
const rightSidebars = computed(() => {
|
|
49
|
-
const data = []
|
|
50
|
-
if (rightSidebar01.value.length > 0) {
|
|
51
|
-
data.push(rightSidebar01.value[0])
|
|
52
|
-
}
|
|
53
|
-
if (rightSidebar02.value.length > 0) {
|
|
54
|
-
data.push(rightSidebar02.value[0])
|
|
55
|
-
}
|
|
56
|
-
return data
|
|
57
|
-
})
|
|
58
|
-
const sources = computed(() => {
|
|
59
|
-
return rightSidebars.value.map(item => {
|
|
60
|
-
return {
|
|
61
|
-
id: item.id,
|
|
62
|
-
title: item.title,
|
|
63
|
-
}
|
|
64
|
-
})
|
|
65
|
-
})
|
|
66
|
-
// 获取枚举
|
|
67
|
-
async function getEnums(sourceId: string, config: Config) {
|
|
68
|
-
try {
|
|
69
|
-
const params: string[] = []
|
|
70
|
-
const
|
|
71
|
-
const columns = config?.columns ?? []
|
|
72
|
-
const writes =
|
|
73
|
-
config?.rowActions?.reduce((acc: any, cur: any) => {
|
|
74
|
-
return [...acc, ...cur.writes]
|
|
75
|
-
}, []) || []
|
|
76
|
-
columns.forEach((item: any) => {
|
|
77
|
-
if (
|
|
78
|
-
ControlTypeSupportor.getControlType(item) === 'select' ||
|
|
79
|
-
ControlTypeSupportor.getControlType(item) === 'multiselect'
|
|
80
|
-
) {
|
|
81
|
-
params.push(`mstrucIds=${item.mstrucId}`)
|
|
82
|
-
}
|
|
83
|
-
})
|
|
84
|
-
|
|
85
|
-
if (
|
|
86
|
-
ControlTypeSupportor.getControlType(item) === 'select' ||
|
|
87
|
-
ControlTypeSupportor.getControlType(item) === 'multiselect'
|
|
88
|
-
) {
|
|
89
|
-
params.push(`mstrucIds=${item.mstrucId}`)
|
|
90
|
-
}
|
|
91
|
-
})
|
|
92
|
-
writes.forEach((item: any) => {
|
|
93
|
-
if (
|
|
94
|
-
ControlTypeSupportor.getControlType(item) === 'select' ||
|
|
95
|
-
ControlTypeSupportor.getControlType(item) === 'multiselect'
|
|
96
|
-
) {
|
|
97
|
-
params.push(`mstrucIds=${item.mstrucId}`)
|
|
98
|
-
}
|
|
99
|
-
})
|
|
100
|
-
if (!params.length) return
|
|
101
|
-
const res = await enums(params.join('&'))
|
|
102
|
-
enumColumn.value[sourceId] = res.enumMap || {}
|
|
103
|
-
} catch (error) {
|
|
104
|
-
console.log('error:', error)
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
// 获取数据
|
|
108
|
-
async function queryList(source: { id: string; title: string }): Promise<Notification | null> {
|
|
109
|
-
try {
|
|
110
|
-
const res = await pageConfig(source.id)
|
|
111
|
-
dtmplConfig.value[source.id] = res.ltmplConfig
|
|
112
|
-
getEnums(source.id, res.ltmplConfig)
|
|
113
|
-
const res1 = await pageKey(source.id, '', '') // 获取key
|
|
114
|
-
const data = await listData(res1.key, 1, 10) // 获取数据
|
|
115
|
-
return {
|
|
116
|
-
id: source.id,
|
|
117
|
-
title: source.title,
|
|
118
|
-
data: data.entities.map((item: Entities) => {
|
|
119
|
-
return {
|
|
120
|
-
type: 'system',
|
|
121
|
-
read: false,
|
|
122
|
-
id: item.code,
|
|
123
|
-
sourceid: source.id,
|
|
124
|
-
primaryColumn: item.fieldMap[res.ltmplConfig.primaryColumn?.sourceId] || '',
|
|
125
|
-
primaryColumnConfig: res.ltmplConfig.primaryColumn,
|
|
126
|
-
primaryColumnLabel: item.fieldMap[res.ltmplConfig.primaryColumnLabel?.sourceId] || '',
|
|
127
|
-
primaryColumnLabelConfig: res.ltmplConfig.primaryColumnLabel,
|
|
128
|
-
secondColumn: item.fieldMap[res.ltmplConfig.secondColumn?.sourceId] || '',
|
|
129
|
-
secondColumnConfig: res.ltmplConfig.secondColumn,
|
|
130
|
-
secondColumnLabel: item.fieldMap[res.ltmplConfig.secondColumnLabel?.sourceId] || '',
|
|
131
|
-
secondColumnLabelConfig: res.ltmplConfig.secondColumnLabel,
|
|
132
|
-
data: item,
|
|
133
|
-
}
|
|
134
|
-
}),
|
|
135
|
-
}
|
|
136
|
-
} catch (error) {
|
|
137
|
-
console.error(error)
|
|
138
|
-
return null
|
|
139
|
-
}
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
// 聚合数据
|
|
143
|
-
async function queryListAll() {
|
|
144
|
-
for (const source of sources.value) {
|
|
145
|
-
const data = await queryList(source)
|
|
146
|
-
if (data) {
|
|
147
|
-
console.log(data)
|
|
148
|
-
notifications.value?.push(data)
|
|
149
|
-
}
|
|
150
|
-
}
|
|
151
|
-
}
|
|
152
|
-
watch(sources, () => {
|
|
153
|
-
queryListAll()
|
|
154
|
-
})
|
|
155
|
-
|
|
156
|
-
function getIconColor(type: string) {
|
|
157
|
-
switch (type) {
|
|
158
|
-
case 'system':
|
|
159
|
-
return 'bg-blue-500'
|
|
160
|
-
case 'department':
|
|
161
|
-
return 'bg-amber-500'
|
|
162
|
-
case 'colleague':
|
|
163
|
-
return 'bg-purple-500'
|
|
164
|
-
default:
|
|
165
|
-
return 'bg-slate-500'
|
|
166
|
-
}
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
function handleNotificationClick(notification: any) {
|
|
170
|
-
if (!notification.read) {
|
|
171
|
-
notification.read = true
|
|
172
|
-
}
|
|
173
|
-
gotoDetailPage(notification)
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
// 跳转列表页面
|
|
177
|
-
function gotoPage(item: Notification) {
|
|
178
|
-
router.push(`/pages/list/index?sourceId=${item.id}&title=${item.title}`)
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
// 跳转详情页面
|
|
182
|
-
function gotoDetailPage(item: Data) {
|
|
183
|
-
router.push(`/pages/notify-handle/index?sourceId=${item.sourceid}&id=${item.id}&title=`)
|
|
184
|
-
|
|
185
|
-
// 延迟发送,确保事件被发送
|
|
186
|
-
setTimeout(() => {
|
|
187
|
-
uni.$emit('notify-click', {
|
|
188
|
-
item: dtmplConfig.value[item.sourceid],
|
|
189
|
-
sourceId: item.sourceid,
|
|
190
|
-
data: item.data,
|
|
191
|
-
rowActions: dtmplConfig.value[item.sourceid]?.rowActions,
|
|
192
|
-
actions: dtmplConfig.value[item.sourceid]?.actions,
|
|
193
|
-
ractions: dtmplConfig.value[item.sourceid]?.ractions,
|
|
194
|
-
primaryColumn: dtmplConfig.value[item.sourceid]?.primaryColumn,
|
|
195
|
-
enumColumn: enumColumn.value[item.sourceid],
|
|
196
|
-
})
|
|
197
|
-
}, 100)
|
|
198
|
-
}
|
|
199
|
-
</script>
|
|
200
|
-
|
|
201
|
-
<template>
|
|
202
|
-
<view v-if="notifications && notifications.length > 0" class="mb-6 mt-6">
|
|
203
|
-
<view class="mb-4 flex items-center justify-between">
|
|
204
|
-
<text class="text-base text-slate-800 font-semibold dark:text-white">
|
|
205
|
-
{{ languageStore.t('最新消息') }}
|
|
206
|
-
</text>
|
|
207
|
-
</view>
|
|
208
|
-
|
|
209
|
-
<view v-for="notification in notifications" :key="notification.id" class="space-y-3">
|
|
210
|
-
<view class="mt-2 flex justify-between text-size-3 color-gray dark:text-white">
|
|
211
|
-
<view>{{ languageStore.t(notification.title) }}</view>
|
|
212
|
-
<view
|
|
213
|
-
@click="
|
|
214
|
-
() => {
|
|
215
|
-
gotoPage(notification)
|
|
216
|
-
}
|
|
217
|
-
"
|
|
218
|
-
>
|
|
219
|
-
{{ languageStore.t('查看全部') }}
|
|
220
|
-
</view>
|
|
221
|
-
</view>
|
|
222
|
-
<button
|
|
223
|
-
v-for="item in notification.data"
|
|
224
|
-
:key="item.id"
|
|
225
|
-
class="w-full flex cursor-pointer items-start gap-3 rounded-xl bg-white p-4 text-left shadow-[0_4px_16px_rgba(99,102,241,0.1)] transition-all duration-200 dark:bg-black hover:shadow-md"
|
|
226
|
-
:class="{ 'opacity-60': item.read }"
|
|
227
|
-
@click="handleNotificationClick(item)"
|
|
228
|
-
>
|
|
229
|
-
<view
|
|
230
|
-
:class="getIconColor(item.type)"
|
|
231
|
-
class="h-10 w-10 flex flex-shrink-0 items-center justify-center rounded-full"
|
|
232
|
-
>
|
|
233
|
-
<wd-icon name="notification" size="40rpx" color="#fff" />
|
|
234
|
-
</view>
|
|
235
|
-
|
|
236
|
-
<view class="min-w-0 flex-1">
|
|
237
|
-
<view class="flex justify-between gap-1">
|
|
238
|
-
<span class="text-sm text-slate-800 font-medium dark:text-white">
|
|
239
|
-
{{ formatItemData(item.primaryColumn, ControlTypeSupportor.getControlType(item.primaryColumnConfig)) }}
|
|
240
|
-
</span>
|
|
241
|
-
<span class="whitespace-nowrap text-xs text-slate-400 dark:text-gray-300">
|
|
242
|
-
{{
|
|
243
|
-
formatItemData(
|
|
244
|
-
item.primaryColumnLabel,
|
|
245
|
-
ControlTypeSupportor.getControlType(item.primaryColumnLabelConfig)
|
|
246
|
-
)
|
|
247
|
-
}}
|
|
248
|
-
</span>
|
|
249
|
-
</view>
|
|
250
|
-
<p class="line-clamp-2 mt-1 text-sm text-slate-500 dark:text-gray-400">
|
|
251
|
-
<text class="mr-1">
|
|
252
|
-
{{
|
|
253
|
-
formatItemData(item.secondColumn, ControlTypeSupportor.getControlType(item.secondColumnConfig || {}))
|
|
254
|
-
}}
|
|
255
|
-
</text>
|
|
256
|
-
<text>
|
|
257
|
-
{{
|
|
258
|
-
formatItemData(
|
|
259
|
-
item.secondColumnLabel,
|
|
260
|
-
ControlTypeSupportor.getControlType(item.secondColumnLabelConfig || {})
|
|
261
|
-
)
|
|
262
|
-
}}
|
|
263
|
-
</text>
|
|
264
|
-
</p>
|
|
265
|
-
</view>
|
|
266
|
-
|
|
267
|
-
<view v-if="!item.read" class="mt-2 h-2 w-2 flex-shrink-0 rounded-full bg-indigo-500" />
|
|
268
|
-
</button>
|
|
269
|
-
</view>
|
|
270
|
-
</view>
|
|
271
|
-
</template>
|
|
272
|
-
|
|
273
|
-
<style scoped>
|
|
274
|
-
.line-clamp-2 {
|
|
275
|
-
display: -webkit-box;
|
|
276
|
-
-webkit-line-clamp: 2;
|
|
277
|
-
-webkit-box-orient: vertical;
|
|
278
|
-
overflow: hidden;
|
|
279
|
-
}
|
|
280
|
-
</style>
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import { computed, defineOptions, watch } from 'vue'
|
|
3
|
+
import { useRouter } from 'uni-mini-router'
|
|
4
|
+
import { enums, listData, pageConfig, pageKey } from '../../api/page'
|
|
5
|
+
import { useSectionMenus } from '../../composables/useSectionMenus'
|
|
6
|
+
import { formatItemData } from '../../utils'
|
|
7
|
+
import ControlTypeSupportor from '../../utils/control-type-supportor'
|
|
8
|
+
import { useLanguageStore } from '../../store/language'
|
|
9
|
+
import type { Config, Entities, Enums } from '../../type'
|
|
10
|
+
|
|
11
|
+
defineOptions({
|
|
12
|
+
name: 'WuiNotifyInfo',
|
|
13
|
+
})
|
|
14
|
+
const languageStore = useLanguageStore()
|
|
15
|
+
const { rightSidebar01, rightSidebar02 } = useSectionMenus()
|
|
16
|
+
// const getIcon = (type: string) => {
|
|
17
|
+
// switch (type) {
|
|
18
|
+
// case 'system': return BellIcon
|
|
19
|
+
// case 'department': return MegaphoneIcon
|
|
20
|
+
// case 'colleague': return ChatBubbleLeftIcon
|
|
21
|
+
// default: return BellIcon
|
|
22
|
+
// }
|
|
23
|
+
// }
|
|
24
|
+
const dtmplConfig = ref<{ [key: string]: Config }>({})
|
|
25
|
+
const enumColumn = ref<{ [key: string]: Enums }>({})
|
|
26
|
+
interface Data {
|
|
27
|
+
type: 'system'
|
|
28
|
+
read: boolean
|
|
29
|
+
id: string
|
|
30
|
+
primaryColumn: string
|
|
31
|
+
primaryColumnLabel: string
|
|
32
|
+
secondColumn: string
|
|
33
|
+
secondColumnLabel: string
|
|
34
|
+
primaryColumnLabelConfig: any
|
|
35
|
+
primaryColumnConfig: any
|
|
36
|
+
secondColumnConfig: any
|
|
37
|
+
secondColumnLabelConfig: any
|
|
38
|
+
sourceid: string
|
|
39
|
+
data: Entities
|
|
40
|
+
}
|
|
41
|
+
interface Notification {
|
|
42
|
+
id: string
|
|
43
|
+
title: string
|
|
44
|
+
data: Data[]
|
|
45
|
+
}
|
|
46
|
+
const router = useRouter()
|
|
47
|
+
const notifications = ref<Notification[] | null>([])
|
|
48
|
+
const rightSidebars = computed(() => {
|
|
49
|
+
const data = []
|
|
50
|
+
if (rightSidebar01.value.length > 0) {
|
|
51
|
+
data.push(rightSidebar01.value[0])
|
|
52
|
+
}
|
|
53
|
+
if (rightSidebar02.value.length > 0) {
|
|
54
|
+
data.push(rightSidebar02.value[0])
|
|
55
|
+
}
|
|
56
|
+
return data
|
|
57
|
+
})
|
|
58
|
+
const sources = computed(() => {
|
|
59
|
+
return rightSidebars.value.map(item => {
|
|
60
|
+
return {
|
|
61
|
+
id: item.id,
|
|
62
|
+
title: item.title,
|
|
63
|
+
}
|
|
64
|
+
})
|
|
65
|
+
})
|
|
66
|
+
// 获取枚举
|
|
67
|
+
async function getEnums(sourceId: string, config: Config) {
|
|
68
|
+
try {
|
|
69
|
+
const params: string[] = []
|
|
70
|
+
const criteria = config?.criteria ?? []
|
|
71
|
+
const columns = config?.columns ?? []
|
|
72
|
+
const writes =
|
|
73
|
+
config?.rowActions?.reduce((acc: any, cur: any) => {
|
|
74
|
+
return [...acc, ...cur.writes]
|
|
75
|
+
}, []) || []
|
|
76
|
+
columns.forEach((item: any) => {
|
|
77
|
+
if (
|
|
78
|
+
ControlTypeSupportor.getControlType(item) === 'select' ||
|
|
79
|
+
ControlTypeSupportor.getControlType(item) === 'multiselect'
|
|
80
|
+
) {
|
|
81
|
+
params.push(`mstrucIds=${item.mstrucId}`)
|
|
82
|
+
}
|
|
83
|
+
})
|
|
84
|
+
criteria.forEach((item: any) => {
|
|
85
|
+
if (
|
|
86
|
+
ControlTypeSupportor.getControlType(item) === 'select' ||
|
|
87
|
+
ControlTypeSupportor.getControlType(item) === 'multiselect'
|
|
88
|
+
) {
|
|
89
|
+
params.push(`mstrucIds=${item.mstrucId}`)
|
|
90
|
+
}
|
|
91
|
+
})
|
|
92
|
+
writes.forEach((item: any) => {
|
|
93
|
+
if (
|
|
94
|
+
ControlTypeSupportor.getControlType(item) === 'select' ||
|
|
95
|
+
ControlTypeSupportor.getControlType(item) === 'multiselect'
|
|
96
|
+
) {
|
|
97
|
+
params.push(`mstrucIds=${item.mstrucId}`)
|
|
98
|
+
}
|
|
99
|
+
})
|
|
100
|
+
if (!params.length) return
|
|
101
|
+
const res = await enums(params.join('&'))
|
|
102
|
+
enumColumn.value[sourceId] = res.enumMap || {}
|
|
103
|
+
} catch (error) {
|
|
104
|
+
console.log('error:', error)
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
// 获取数据
|
|
108
|
+
async function queryList(source: { id: string; title: string }): Promise<Notification | null> {
|
|
109
|
+
try {
|
|
110
|
+
const res = await pageConfig(source.id)
|
|
111
|
+
dtmplConfig.value[source.id] = res.ltmplConfig
|
|
112
|
+
getEnums(source.id, res.ltmplConfig)
|
|
113
|
+
const res1 = await pageKey(source.id, '', '') // 获取key
|
|
114
|
+
const data = await listData(res1.key, 1, 10) // 获取数据
|
|
115
|
+
return {
|
|
116
|
+
id: source.id,
|
|
117
|
+
title: source.title,
|
|
118
|
+
data: data.entities.map((item: Entities) => {
|
|
119
|
+
return {
|
|
120
|
+
type: 'system',
|
|
121
|
+
read: false,
|
|
122
|
+
id: item.code,
|
|
123
|
+
sourceid: source.id,
|
|
124
|
+
primaryColumn: item.fieldMap[res.ltmplConfig.primaryColumn?.sourceId] || '',
|
|
125
|
+
primaryColumnConfig: res.ltmplConfig.primaryColumn,
|
|
126
|
+
primaryColumnLabel: item.fieldMap[res.ltmplConfig.primaryColumnLabel?.sourceId] || '',
|
|
127
|
+
primaryColumnLabelConfig: res.ltmplConfig.primaryColumnLabel,
|
|
128
|
+
secondColumn: item.fieldMap[res.ltmplConfig.secondColumn?.sourceId] || '',
|
|
129
|
+
secondColumnConfig: res.ltmplConfig.secondColumn,
|
|
130
|
+
secondColumnLabel: item.fieldMap[res.ltmplConfig.secondColumnLabel?.sourceId] || '',
|
|
131
|
+
secondColumnLabelConfig: res.ltmplConfig.secondColumnLabel,
|
|
132
|
+
data: item,
|
|
133
|
+
}
|
|
134
|
+
}),
|
|
135
|
+
}
|
|
136
|
+
} catch (error) {
|
|
137
|
+
console.error(error)
|
|
138
|
+
return null
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
// 聚合数据
|
|
143
|
+
async function queryListAll() {
|
|
144
|
+
for (const source of sources.value) {
|
|
145
|
+
const data = await queryList(source)
|
|
146
|
+
if (data) {
|
|
147
|
+
console.log(data)
|
|
148
|
+
notifications.value?.push(data)
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
watch(sources, () => {
|
|
153
|
+
queryListAll()
|
|
154
|
+
})
|
|
155
|
+
|
|
156
|
+
function getIconColor(type: string) {
|
|
157
|
+
switch (type) {
|
|
158
|
+
case 'system':
|
|
159
|
+
return 'bg-blue-500'
|
|
160
|
+
case 'department':
|
|
161
|
+
return 'bg-amber-500'
|
|
162
|
+
case 'colleague':
|
|
163
|
+
return 'bg-purple-500'
|
|
164
|
+
default:
|
|
165
|
+
return 'bg-slate-500'
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
function handleNotificationClick(notification: any) {
|
|
170
|
+
if (!notification.read) {
|
|
171
|
+
notification.read = true
|
|
172
|
+
}
|
|
173
|
+
gotoDetailPage(notification)
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
// 跳转列表页面
|
|
177
|
+
function gotoPage(item: Notification) {
|
|
178
|
+
router.push(`/pages/list/index?sourceId=${item.id}&title=${item.title}`)
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
// 跳转详情页面
|
|
182
|
+
function gotoDetailPage(item: Data) {
|
|
183
|
+
router.push(`/pages/notify-handle/index?sourceId=${item.sourceid}&id=${item.id}&title=`)
|
|
184
|
+
|
|
185
|
+
// 延迟发送,确保事件被发送
|
|
186
|
+
setTimeout(() => {
|
|
187
|
+
uni.$emit('notify-click', {
|
|
188
|
+
item: dtmplConfig.value[item.sourceid],
|
|
189
|
+
sourceId: item.sourceid,
|
|
190
|
+
data: item.data,
|
|
191
|
+
rowActions: dtmplConfig.value[item.sourceid]?.rowActions,
|
|
192
|
+
actions: dtmplConfig.value[item.sourceid]?.actions,
|
|
193
|
+
ractions: dtmplConfig.value[item.sourceid]?.ractions,
|
|
194
|
+
primaryColumn: dtmplConfig.value[item.sourceid]?.primaryColumn,
|
|
195
|
+
enumColumn: enumColumn.value[item.sourceid],
|
|
196
|
+
})
|
|
197
|
+
}, 100)
|
|
198
|
+
}
|
|
199
|
+
</script>
|
|
200
|
+
|
|
201
|
+
<template>
|
|
202
|
+
<view v-if="notifications && notifications.length > 0" class="mb-6 mt-6">
|
|
203
|
+
<view class="mb-4 flex items-center justify-between">
|
|
204
|
+
<text class="text-base text-slate-800 font-semibold dark:text-white">
|
|
205
|
+
{{ languageStore.t('最新消息') }}
|
|
206
|
+
</text>
|
|
207
|
+
</view>
|
|
208
|
+
|
|
209
|
+
<view v-for="notification in notifications" :key="notification.id" class="space-y-3">
|
|
210
|
+
<view class="mt-2 flex justify-between text-size-3 color-gray dark:text-white">
|
|
211
|
+
<view>{{ languageStore.t(notification.title) }}</view>
|
|
212
|
+
<view
|
|
213
|
+
@click="
|
|
214
|
+
() => {
|
|
215
|
+
gotoPage(notification)
|
|
216
|
+
}
|
|
217
|
+
"
|
|
218
|
+
>
|
|
219
|
+
{{ languageStore.t('查看全部') }}
|
|
220
|
+
</view>
|
|
221
|
+
</view>
|
|
222
|
+
<button
|
|
223
|
+
v-for="item in notification.data"
|
|
224
|
+
:key="item.id"
|
|
225
|
+
class="w-full flex cursor-pointer items-start gap-3 rounded-xl bg-white p-4 text-left shadow-[0_4px_16px_rgba(99,102,241,0.1)] transition-all duration-200 dark:bg-black hover:shadow-md"
|
|
226
|
+
:class="{ 'opacity-60': item.read }"
|
|
227
|
+
@click="handleNotificationClick(item)"
|
|
228
|
+
>
|
|
229
|
+
<view
|
|
230
|
+
:class="getIconColor(item.type)"
|
|
231
|
+
class="h-10 w-10 flex flex-shrink-0 items-center justify-center rounded-full"
|
|
232
|
+
>
|
|
233
|
+
<wd-icon name="notification" size="40rpx" color="#fff" />
|
|
234
|
+
</view>
|
|
235
|
+
|
|
236
|
+
<view class="min-w-0 flex-1">
|
|
237
|
+
<view class="flex justify-between gap-1">
|
|
238
|
+
<span class="text-sm text-slate-800 font-medium dark:text-white">
|
|
239
|
+
{{ formatItemData(item.primaryColumn, ControlTypeSupportor.getControlType(item.primaryColumnConfig)) }}
|
|
240
|
+
</span>
|
|
241
|
+
<span class="whitespace-nowrap text-xs text-slate-400 dark:text-gray-300">
|
|
242
|
+
{{
|
|
243
|
+
formatItemData(
|
|
244
|
+
item.primaryColumnLabel,
|
|
245
|
+
ControlTypeSupportor.getControlType(item.primaryColumnLabelConfig)
|
|
246
|
+
)
|
|
247
|
+
}}
|
|
248
|
+
</span>
|
|
249
|
+
</view>
|
|
250
|
+
<p class="line-clamp-2 mt-1 text-sm text-slate-500 dark:text-gray-400">
|
|
251
|
+
<text class="mr-1">
|
|
252
|
+
{{
|
|
253
|
+
formatItemData(item.secondColumn, ControlTypeSupportor.getControlType(item.secondColumnConfig || {}))
|
|
254
|
+
}}
|
|
255
|
+
</text>
|
|
256
|
+
<text>
|
|
257
|
+
{{
|
|
258
|
+
formatItemData(
|
|
259
|
+
item.secondColumnLabel,
|
|
260
|
+
ControlTypeSupportor.getControlType(item.secondColumnLabelConfig || {})
|
|
261
|
+
)
|
|
262
|
+
}}
|
|
263
|
+
</text>
|
|
264
|
+
</p>
|
|
265
|
+
</view>
|
|
266
|
+
|
|
267
|
+
<view v-if="!item.read" class="mt-2 h-2 w-2 flex-shrink-0 rounded-full bg-indigo-500" />
|
|
268
|
+
</button>
|
|
269
|
+
</view>
|
|
270
|
+
</view>
|
|
271
|
+
</template>
|
|
272
|
+
|
|
273
|
+
<style scoped>
|
|
274
|
+
.line-clamp-2 {
|
|
275
|
+
display: -webkit-box;
|
|
276
|
+
-webkit-line-clamp: 2;
|
|
277
|
+
-webkit-box-orient: vertical;
|
|
278
|
+
overflow: hidden;
|
|
279
|
+
}
|
|
280
|
+
</style>
|