wui-components-v2 1.1.69 → 1.1.71

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.
Files changed (117) hide show
  1. package/api/core/index.ts +74 -74
  2. package/api/feishu.ts +20 -20
  3. package/api/index.ts +4 -4
  4. package/api/login.ts +51 -51
  5. package/api/menu.ts +45 -45
  6. package/api/page.ts +114 -114
  7. package/api/sys.ts +12 -12
  8. package/api/tree.ts +28 -28
  9. package/components/action-popup/action-popup.vue +116 -116
  10. package/components/add-address-list/add-address-list.vue +187 -187
  11. package/components/add-address-page/add-address-page.vue +77 -77
  12. package/components/add-address-page/config.ts +297 -297
  13. package/components/audio-play/audio-play.vue +220 -220
  14. package/components/batch-upload-file/batch-upload-file.vue +75 -75
  15. package/components/card-botom-buttons/card-botom-buttons.vue +279 -279
  16. package/components/custom-date-picker/custom-date-picker.vue +106 -106
  17. package/components/custom-select-picker/custom-select-picker.vue +95 -95
  18. package/components/demo-block/demo-block.vue +63 -63
  19. package/components/demo-card/demo-card.vue +44 -44
  20. package/components/detail-popup/detail-popup.vue +99 -99
  21. package/components/evaluation-page/evaluation-page.vue +196 -196
  22. package/components/fold-card/fold-card.vue +171 -171
  23. package/components/form-control/form-control.vue +661 -661
  24. package/components/global-loading/GlobalLoading.md +366 -366
  25. package/components/global-loading/global-loading.vue +55 -55
  26. package/components/global-message/GlobalMessage.md +570 -570
  27. package/components/global-message/global-message.vue +68 -68
  28. package/components/global-toast/GlobalToast.md +261 -261
  29. package/components/global-toast/global-toast.vue +56 -56
  30. package/components/label-value/label-value.vue +144 -144
  31. package/components/label-value/open-value-more.vue +56 -56
  32. package/components/list-top-buttons/list-top-buttons.vue +19 -19
  33. package/components/loading/loading.vue +5 -5
  34. package/components/login-form/login-form.vue +126 -126
  35. package/components/login-form-box/login-form-box.vue +65 -65
  36. package/components/mulselect-picker/mulselect-picker.vue +86 -86
  37. package/components/phone-login-form/phone-login-form.vue +204 -204
  38. package/components/privacy-popup/privacy-popup.vue +191 -191
  39. package/components/product-card/product-card.vue +201 -201
  40. package/components/scan-input/scan-input.vue +406 -406
  41. package/components/search/search.vue +128 -128
  42. package/components/select-col-picker/select-col-picker.vue +168 -168
  43. package/components/tab-search/tab-search.vue +73 -73
  44. package/components/tree-select/components/TreeNode.vue +200 -200
  45. package/components/tree-select/components/index.vue +471 -471
  46. package/components/tree-select/components/tree-select.vue +56 -56
  47. package/components/tree-select/index.vue +93 -93
  48. package/components/user-choose/user-choose.vue +169 -151
  49. package/components/video-play/video-play.vue +56 -56
  50. package/components/wui-auto-update-component/wui-auto-update-component.vue +132 -132
  51. package/components/wui-default/wui-default.vue +49 -49
  52. package/components/wui-details-page/wui-details-page.vue +147 -147
  53. package/components/wui-edit-page/wui-edit-page-copy.vue +757 -757
  54. package/components/wui-edit-page/wui-edit-page.vue +793 -793
  55. package/components/wui-enume-select-control/wui-enume-select-control.vue +92 -92
  56. package/components/wui-list/wui-list.vue +235 -235
  57. package/components/wui-login/wui-login.vue +43 -43
  58. package/components/wui-login1/wui-login.vue +41 -41
  59. package/components/wui-menus/wui-menus-top.vue +137 -137
  60. package/components/wui-menus/wui-menus-top1.vue +8 -8
  61. package/components/wui-menus/wui-menus.vue +247 -247
  62. package/components/wui-menus1/components/banner-carousel.vue +320 -320
  63. package/components/wui-menus1/components/navbar.vue +43 -43
  64. package/components/wui-menus1/components/quick-panel.vue +55 -55
  65. package/components/wui-menus1/components/search-bar.vue +49 -49
  66. package/components/wui-menus1/components/section-menus.vue +208 -208
  67. package/components/wui-menus1/wui-menus-top.vue +718 -718
  68. package/components/wui-menus1/wui-menus-top1.vue +398 -398
  69. package/components/wui-menus1/wui-menus.vue +564 -564
  70. package/components/wui-notify-info/notify-handle.vue +53 -53
  71. package/components/wui-notify-info/wui-notify-info.vue +280 -280
  72. package/components/wui-scan-binding-sensor/wui-scan-binding-sensor.vue +75 -75
  73. package/components/wui-search-history-babbar/components/SearchBar.vue +70 -70
  74. package/components/wui-search-history-babbar/wui-search-history-babbar.vue +204 -204
  75. package/components/wui-select-list/wui-select-list.vue +310 -310
  76. package/components/wui-select-popup/wui-select-popup.vue +613 -612
  77. package/components/wui-system-settings/wui-system-settings.vue +144 -144
  78. package/components/wui-tabbar/wui-tabbar.vue +106 -106
  79. package/components/wui-tree-page/components/tree-item.vue +238 -238
  80. package/components/wui-tree-page/wui-tree-page.vue +297 -297
  81. package/components/wui-update-component/wui-update-component.vue +221 -221
  82. package/components/wui-user/wui-user.vue +202 -202
  83. package/composables/types/theme.ts +65 -65
  84. package/composables/types/user.ts +5 -5
  85. package/composables/useColorGenerator.ts +221 -221
  86. package/composables/useCompanyFieldFilter.ts +91 -91
  87. package/composables/useEnumes.ts +43 -43
  88. package/composables/useEventBus.ts +37 -37
  89. package/composables/useGlobalLoading.ts +47 -47
  90. package/composables/useGlobalMessage.ts +53 -53
  91. package/composables/useGlobalToast.ts +63 -63
  92. package/composables/useLocale.ts +54 -54
  93. package/composables/useManualTheme.ts +179 -179
  94. package/composables/useMenus.ts +193 -193
  95. package/composables/useSectionMenus.ts +120 -120
  96. package/composables/useTabbar.ts +50 -50
  97. package/composables/useTheme.ts +74 -74
  98. package/composables/useUser.ts +24 -24
  99. package/index.d.ts +90 -90
  100. package/index.ts +83 -83
  101. package/package.json +24 -24
  102. package/static/iconfont/iconfont.css +63 -63
  103. package/store/language.ts +151 -151
  104. package/store/manualThemeStore.ts +143 -143
  105. package/store/persist.ts +41 -41
  106. package/store/themeStore.ts +74 -74
  107. package/store/userStore.ts +22 -22
  108. package/styles/dark-mode.css +523 -523
  109. package/styles/dark-mode.min.css +1 -1
  110. package/styles/dark-mode.scss +498 -498
  111. package/type.ts +154 -154
  112. package/utils/control-tree.ts +353 -353
  113. package/utils/control-type-supportor.ts +148 -148
  114. package/utils/eventBus.ts +36 -36
  115. package/utils/idata-scan.ts +99 -99
  116. package/utils/index.ts +979 -979
  117. package/utils/rsaEncrypt.ts +10 -10
@@ -1,53 +1,53 @@
1
- <script setup lang="ts">
2
- import { defineOptions, ref } from 'vue'
3
- import { onLoad } from '@dcloudio/uni-app'
4
- import wuiDetailsPage from '../wui-details-page/wui-details-page.vue'
5
- import cardBotomButtons from '../card-botom-buttons/card-botom-buttons.vue'
6
-
7
- defineOptions({
8
- name: 'NotifyHandle',
9
- })
10
- const item = ref<any>(null)
11
- const sourceId = ref<any>(null)
12
- const pagedata = ref<any>(null)
13
- const rowActions = ref<any>(null)
14
- const actions = ref<any>(null)
15
- const ractions = ref<any>(null)
16
- const primaryColumn = ref<any>(null)
17
- const enumColumn = ref<any>(null)
18
- onLoad(() => {
19
- console.log('load')
20
- uni.$on('notify-click', (data: any) => {
21
- console.log(data, 'kkkk')
22
- item.value = data.item
23
- sourceId.value = data.sourceId
24
- pagedata.value = data.data
25
- rowActions.value = data.rowActions
26
- actions.value = data.actions
27
- ractions.value = data.ractions
28
- primaryColumn.value = data.primaryColumn
29
- enumColumn.value = data.enumColumn
30
- })
31
- })
32
- onUnload(() => {
33
- console.log('unload')
34
- uni.$off('notify-click')
35
- })
36
- </script>
37
-
38
- <template>
39
- <view>
40
- <wuiDetailsPage>
41
- <template #botombuttons>
42
- <view class="flex justify-end bg-#ffff p-4">
43
- <cardBotomButtons v-if="sourceId" :item="item" :source-id="sourceId" :code="pagedata.code" :data="pagedata" :row-actions="rowActions" :actions="actions" :ractions="ractions" :primary-column="primaryColumn" />
44
- </view>
45
- </template>
46
- </wuiDetailsPage>
47
- <view />
48
- </view>
49
- </template>
50
-
51
- <style scoped>
52
-
53
- </style>
1
+ <script setup lang="ts">
2
+ import { defineOptions, ref } from 'vue'
3
+ import { onLoad } from '@dcloudio/uni-app'
4
+ import wuiDetailsPage from '../wui-details-page/wui-details-page.vue'
5
+ import cardBotomButtons from '../card-botom-buttons/card-botom-buttons.vue'
6
+
7
+ defineOptions({
8
+ name: 'NotifyHandle',
9
+ })
10
+ const item = ref<any>(null)
11
+ const sourceId = ref<any>(null)
12
+ const pagedata = ref<any>(null)
13
+ const rowActions = ref<any>(null)
14
+ const actions = ref<any>(null)
15
+ const ractions = ref<any>(null)
16
+ const primaryColumn = ref<any>(null)
17
+ const enumColumn = ref<any>(null)
18
+ onLoad(() => {
19
+ console.log('load')
20
+ uni.$on('notify-click', (data: any) => {
21
+ console.log(data, 'kkkk')
22
+ item.value = data.item
23
+ sourceId.value = data.sourceId
24
+ pagedata.value = data.data
25
+ rowActions.value = data.rowActions
26
+ actions.value = data.actions
27
+ ractions.value = data.ractions
28
+ primaryColumn.value = data.primaryColumn
29
+ enumColumn.value = data.enumColumn
30
+ })
31
+ })
32
+ onUnload(() => {
33
+ console.log('unload')
34
+ uni.$off('notify-click')
35
+ })
36
+ </script>
37
+
38
+ <template>
39
+ <view>
40
+ <wuiDetailsPage>
41
+ <template #botombuttons>
42
+ <view class="flex justify-end bg-#ffff p-4">
43
+ <cardBotomButtons v-if="sourceId" :item="item" :source-id="sourceId" :code="pagedata.code" :data="pagedata" :row-actions="rowActions" :actions="actions" :ractions="ractions" :primary-column="primaryColumn" />
44
+ </view>
45
+ </template>
46
+ </wuiDetailsPage>
47
+ <view />
48
+ </view>
49
+ </template>
50
+
51
+ <style scoped>
52
+
53
+ </style>
@@ -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 criterias = config?.criterias ?? []
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
- criterias.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>
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>