verce-vue-test 0.0.53 → 0.0.55
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/{mini2.0-main 2/src/App.vue → mini2.0-main/src/App.vue} +1 -1
- package/mini2.0-main/src/api/announcement.ts +405 -0
- package/mini2.0-main/src/api/rmb-position.ts +139 -0
- package/mini2.0-main/src/api/tam.ts +170 -0
- package/{mini2.0-main 2/src/api/user.ts → mini2.0-main/src/api/user.ts} +16 -0
- package/mini2.0-main/src/config/plugin.properties.test +6 -0
- package/{mini2.0-main 2/src/stores/user.ts → mini2.0-main/src/stores/user.ts} +56 -4
- package/{mini2.0-main 2/src/types/api.d.ts → mini2.0-main/src/types/api.d.ts} +1 -1
- package/{mini2.0-main 2/src/utils/auth-token.ts → mini2.0-main/src/utils/auth-token.ts} +50 -6
- package/mini2.0-main/src/utils/code-highlight.ts +165 -0
- package/mini2.0-main/src/utils/copy.ts +36 -0
- package/{mini2.0-main 2/src/utils/request.ts → mini2.0-main/src/utils/request.ts} +10 -6
- package/{mini2.0-main 2/src/views/article-detail/index.vue → mini2.0-main/src/views/article-detail/index.vue} +105 -7
- package/{mini2.0-main 2/src/views/article-edit/index.vue → mini2.0-main/src/views/article-edit/index.vue} +121 -16
- package/{mini2.0-main 2/src/views/articles/index.vue → mini2.0-main/src/views/articles/index.vue} +8 -8
- package/{mini2.0-main 2/src/views/login/index.vue → mini2.0-main/src/views/login/index.vue} +46 -6
- package/package.json +1 -1
- package/src/utils/code-highlight.ts +200 -0
- package/src/views/NoticeDetailView.vue +69 -1
- package/mini2.0-main 2/src/api/rmb-position.ts +0 -287
- package/mini2.0-main 2/src/config/plugin.properties.test +0 -6
- /package/{mini2.0-main 2 → mini2.0-main}/.editorconfig +0 -0
- /package/{mini2.0-main 2 → mini2.0-main}/.env.development +0 -0
- /package/{mini2.0-main 2 → mini2.0-main}/.env.production +0 -0
- /package/{mini2.0-main 2 → mini2.0-main}/.env.test +0 -0
- /package/{mini2.0-main 2 → mini2.0-main}/.gitattributes +0 -0
- /package/{mini2.0-main 2 → mini2.0-main}/.oxlintrc.json +0 -0
- /package/{mini2.0-main 2 → mini2.0-main}/.prettierrc.json +0 -0
- /package/{mini2.0-main 2 → mini2.0-main}/.vscode/extensions.json +0 -0
- /package/{mini2.0-main 2 → mini2.0-main}/README.md +0 -0
- /package/{mini2.0-main 2 → mini2.0-main}/auto-imports.d.ts +0 -0
- /package/{mini2.0-main 2 → mini2.0-main}/components.d.ts +0 -0
- /package/{mini2.0-main 2 → mini2.0-main}/design-qa.md +0 -0
- /package/{mini2.0-main 2 → mini2.0-main}/docs/MX_API.md +0 -0
- /package/{mini2.0-main 2 → mini2.0-main}/docs/REQUEST.md +0 -0
- /package/{mini2.0-main 2 → mini2.0-main}/docs/jsapi.js +0 -0
- /package/{mini2.0-main 2 → mini2.0-main}/docs/package-json-guide.md +0 -0
- /package/{mini2.0-main 2 → mini2.0-main}/env.d.ts +0 -0
- /package/{mini2.0-main 2 → mini2.0-main}/eslint.config.ts +0 -0
- /package/{mini2.0-main 2 → mini2.0-main}/index.html +0 -0
- /package/{mini2.0-main 2 → mini2.0-main}/output/playwright/rmb-position/design-comparison.png +0 -0
- /package/{mini2.0-main 2 → mini2.0-main}/output/playwright/rmb-position/rmb-position-back-top.png +0 -0
- /package/{mini2.0-main 2 → mini2.0-main}/output/playwright/rmb-position/rmb-position-page.png +0 -0
- /package/{mini2.0-main 2 → mini2.0-main}/output/playwright/rmb-position/rmb-position-sticky-check.png +0 -0
- /package/{mini2.0-main 2 → mini2.0-main}/output/playwright/rmb-position/rmb-position-sticky-scrolled.png +0 -0
- /package/{mini2.0-main 2 → mini2.0-main}/package-lock.json +0 -0
- /package/{mini2.0-main 2 → mini2.0-main}/package.json +0 -0
- /package/{mini2.0-main 2 → mini2.0-main}/plugins/bump-version.ts +0 -0
- /package/{mini2.0-main 2 → mini2.0-main}/postcss.config.ts +0 -0
- /package/{mini2.0-main 2 → mini2.0-main}/public/favicon.ico +0 -0
- /package/{mini2.0-main 2 → mini2.0-main}/public/images/12a73787-86a9-4891-a65f-66104746f6a8.png +0 -0
- /package/{mini2.0-main 2 → mini2.0-main}/public/images/5798d7aa-ba8b-4605-8079-58b35495ac55.png +0 -0
- /package/{mini2.0-main 2 → mini2.0-main}/public/images/73fef1e4-0fd0-4a1a-9b8b-a70a5b6acbbc.png +0 -0
- /package/{mini2.0-main 2 → mini2.0-main}/public/images/bc685b4c-0cca-4a79-924c-a8ee10e6f8eb.png +0 -0
- /package/{mini2.0-main 2 → mini2.0-main}/public/images/c3dbbd9d-be56-490e-b9f4-6ee17ebefffc.png +0 -0
- /package/{mini2.0-main 2 → mini2.0-main}/public/images/ea745a10-42aa-4f44-8d7f-3ab02cc0adcd.png +0 -0
- /package/{mini2.0-main 2 → mini2.0-main}/public/images/f5876785-b927-4347-ba19-999114240649.png +0 -0
- /package/{mini2.0-main 2 → mini2.0-main}/public/images/img.png +0 -0
- /package/{mini2.0-main 2 → mini2.0-main}/src/api/health.ts +0 -0
- /package/{mini2.0-main 2 → mini2.0-main}/src/auto-imports.d.ts +0 -0
- /package/{mini2.0-main 2 → mini2.0-main}/src/components.d.ts +0 -0
- /package/{mini2.0-main 2 → mini2.0-main}/src/config/config.properties +0 -0
- /package/{mini2.0-main 2 → mini2.0-main}/src/config/env.ts +0 -0
- /package/{mini2.0-main 2 → mini2.0-main}/src/config/plugin.properties.pro +0 -0
- /package/{mini2.0-main 2 → mini2.0-main}/src/core/mxApi/index.ts +0 -0
- /package/{mini2.0-main 2 → mini2.0-main}/src/core/request/index.ts +0 -0
- /package/{mini2.0-main 2 → mini2.0-main}/src/main.ts +0 -0
- /package/{mini2.0-main 2 → mini2.0-main}/src/router/index.ts +0 -0
- /package/{mini2.0-main 2 → mini2.0-main}/src/stores/app.ts +0 -0
- /package/{mini2.0-main 2 → mini2.0-main}/src/stores/counter.ts +0 -0
- /package/{mini2.0-main 2 → mini2.0-main}/src/types/nprogress.d.ts +0 -0
- /package/{mini2.0-main 2 → mini2.0-main}/src/utils/query.ts +0 -0
- /package/{mini2.0-main 2 → mini2.0-main}/src/views/clearing-detail/index.vue +0 -0
- /package/{mini2.0-main 2 → mini2.0-main}/src/views/foreign-position/index.vue +0 -0
- /package/{mini2.0-main 2 → mini2.0-main}/src/views/home/index.vue +0 -0
- /package/{mini2.0-main 2 → mini2.0-main}/src/views/mine/index.vue +0 -0
- /package/{mini2.0-main 2 → mini2.0-main}/src/views/net-debit/index.vue +0 -0
- /package/{mini2.0-main 2 → mini2.0-main}/src/views/pbc-position/index.vue +0 -0
- /package/{mini2.0-main 2 → mini2.0-main}/src/views/position-estimate/index.vue +0 -0
- /package/{mini2.0-main 2 → mini2.0-main}/src/views/rmb-position/index.vue +0 -0
- /package/{mini2.0-main 2 → mini2.0-main}/src/views/warning/index.vue +0 -0
- /package/{mini2.0-main 2 → mini2.0-main}/tsconfig.app.json +0 -0
- /package/{mini2.0-main 2 → mini2.0-main}/tsconfig.json +0 -0
- /package/{mini2.0-main 2 → mini2.0-main}/tsconfig.node.json +0 -0
- /package/{mini2.0-main 2 → mini2.0-main}/vite.config.ts +0 -0
|
@@ -4,7 +4,7 @@ const router = useRouter()
|
|
|
4
4
|
|
|
5
5
|
const tabItems = [
|
|
6
6
|
{ title: '首页', path: '/', icon: 'wap-home-o' },
|
|
7
|
-
{ title: '
|
|
7
|
+
{ title: '公告', path: '/articles', icon: 'records-o' },
|
|
8
8
|
{ title: '我的', path: '/mine', icon: 'manager-o' },
|
|
9
9
|
]
|
|
10
10
|
|
|
@@ -0,0 +1,405 @@
|
|
|
1
|
+
import { request } from '@/core/request'
|
|
2
|
+
import type { ApiResponse } from '@/types/api'
|
|
3
|
+
|
|
4
|
+
export interface Article {
|
|
5
|
+
id: string
|
|
6
|
+
title: string
|
|
7
|
+
content: string
|
|
8
|
+
author: string
|
|
9
|
+
createdAt: string
|
|
10
|
+
updatedAt: string
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export interface ArticlePayload {
|
|
14
|
+
title: string
|
|
15
|
+
content: string
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
type RawRecord = Record<string, unknown>
|
|
19
|
+
|
|
20
|
+
const LIST_URL = '/uaa/announcement/get/restricted'
|
|
21
|
+
const DETAIL_URL = '/uaa/announcement/get/id'
|
|
22
|
+
const ADD_URL = '/uaa/announcement/add'
|
|
23
|
+
const UPDATE_URL = '/uaa/announcement/update'
|
|
24
|
+
const DEFAULT_ANNOUNCEMENT_FIELDS = {
|
|
25
|
+
annouZrFteLag: '0',
|
|
26
|
+
annouSts: '0',
|
|
27
|
+
department: '100011',
|
|
28
|
+
efDt: '2026-07-01 00:00:00',
|
|
29
|
+
expireDt: '2026-07-31 00:00:00',
|
|
30
|
+
orgList: [],
|
|
31
|
+
orgNo: '25001',
|
|
32
|
+
roleList: [],
|
|
33
|
+
topFlag: '0',
|
|
34
|
+
userList: [],
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
const ALLOWED_TAGS = new Set([
|
|
38
|
+
'A',
|
|
39
|
+
'B',
|
|
40
|
+
'BLOCKQUOTE',
|
|
41
|
+
'BR',
|
|
42
|
+
'DIV',
|
|
43
|
+
'EM',
|
|
44
|
+
'H2',
|
|
45
|
+
'H3',
|
|
46
|
+
'I',
|
|
47
|
+
'LI',
|
|
48
|
+
'OL',
|
|
49
|
+
'P',
|
|
50
|
+
'PRE',
|
|
51
|
+
'S',
|
|
52
|
+
'SPAN',
|
|
53
|
+
'STRONG',
|
|
54
|
+
'U',
|
|
55
|
+
'UL',
|
|
56
|
+
'CODE',
|
|
57
|
+
])
|
|
58
|
+
|
|
59
|
+
export async function queryArticles() {
|
|
60
|
+
const response = await request<unknown>({
|
|
61
|
+
url: LIST_URL,
|
|
62
|
+
method: 'GET',
|
|
63
|
+
})
|
|
64
|
+
const data = unwrapResponse(response)
|
|
65
|
+
|
|
66
|
+
return extractRecords(data).map((record) => mapAnnouncementRecord(record))
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
export async function getArticleDetail(annouId: string) {
|
|
70
|
+
const response = await request<unknown>({
|
|
71
|
+
url: DETAIL_URL,
|
|
72
|
+
method: 'GET',
|
|
73
|
+
params: { annouId },
|
|
74
|
+
})
|
|
75
|
+
const data = unwrapResponse(response)
|
|
76
|
+
const record = extractDetailRecord(data)
|
|
77
|
+
|
|
78
|
+
return mapAnnouncementRecord(record, annouId)
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
export async function createArticle(payload: ArticlePayload) {
|
|
82
|
+
const content = sanitizeArticleHtml(payload.content)
|
|
83
|
+
const response = await request<unknown, RawRecord>({
|
|
84
|
+
url: ADD_URL,
|
|
85
|
+
method: 'POST',
|
|
86
|
+
data: buildAnnouncementPayload({ ...payload, content }),
|
|
87
|
+
})
|
|
88
|
+
const data = unwrapResponse(response)
|
|
89
|
+
const record = extractDetailRecord(data)
|
|
90
|
+
|
|
91
|
+
return mapAnnouncementRecord(record, readString(record, ['annouId', 'id']))
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
export async function updateArticle(annouId: string, payload: ArticlePayload) {
|
|
95
|
+
const content = sanitizeArticleHtml(payload.content)
|
|
96
|
+
const response = await request<unknown, RawRecord>({
|
|
97
|
+
url: UPDATE_URL,
|
|
98
|
+
method: 'POST',
|
|
99
|
+
data: buildAnnouncementPayload({ ...payload, content }, annouId),
|
|
100
|
+
})
|
|
101
|
+
const data = unwrapResponse(response)
|
|
102
|
+
const record = extractDetailRecord(data)
|
|
103
|
+
|
|
104
|
+
return mapAnnouncementRecord(record, annouId)
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
export function formatArticleDate(value: string) {
|
|
108
|
+
const date = new Date(value)
|
|
109
|
+
|
|
110
|
+
if (Number.isNaN(date.getTime())) {
|
|
111
|
+
return ''
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
return new Intl.DateTimeFormat('zh-CN', {
|
|
115
|
+
year: 'numeric',
|
|
116
|
+
month: '2-digit',
|
|
117
|
+
day: '2-digit',
|
|
118
|
+
hour: '2-digit',
|
|
119
|
+
minute: '2-digit',
|
|
120
|
+
}).format(date)
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
export function extractTextFromHtml(html: string) {
|
|
124
|
+
if (!html.trim()) {
|
|
125
|
+
return ''
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
const doc = new DOMParser().parseFromString(html, 'text/html')
|
|
129
|
+
|
|
130
|
+
return doc.body.textContent?.replace(/\s+/g, ' ').trim() || ''
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
export function sanitizeArticleHtml(html: string) {
|
|
134
|
+
if (!html.trim()) {
|
|
135
|
+
return ''
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
const doc = new DOMParser().parseFromString(`<article>${html}</article>`, 'text/html')
|
|
139
|
+
const root = doc.body.firstElementChild
|
|
140
|
+
|
|
141
|
+
if (!root) {
|
|
142
|
+
return ''
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
sanitizeChildren(root, doc)
|
|
146
|
+
|
|
147
|
+
return root.innerHTML.trim()
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
function buildAnnouncementPayload(payload: ArticlePayload, annouId = '') {
|
|
151
|
+
return {
|
|
152
|
+
annouTitle: payload.title.trim(),
|
|
153
|
+
annouConte: payload.content,
|
|
154
|
+
annouId,
|
|
155
|
+
...DEFAULT_ANNOUNCEMENT_FIELDS,
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
function unwrapResponse(response: ApiResponse<unknown> | unknown) {
|
|
160
|
+
if (!isRecord(response)) {
|
|
161
|
+
return response
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
if ('code' in response && 'data' in response) {
|
|
165
|
+
return response.data
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
return response
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
function extractRecords(data: unknown): RawRecord[] {
|
|
172
|
+
const candidates = [
|
|
173
|
+
data,
|
|
174
|
+
getValue(data, ['list']),
|
|
175
|
+
getValue(data, ['records']),
|
|
176
|
+
getValue(data, ['rows']),
|
|
177
|
+
getValue(data, ['resultList']),
|
|
178
|
+
getValue(data, ['content']),
|
|
179
|
+
getValue(data, ['body', 'list']),
|
|
180
|
+
getValue(data, ['body', 'records']),
|
|
181
|
+
getValue(data, ['body', 'rows']),
|
|
182
|
+
getValue(data, ['body', 'resultList']),
|
|
183
|
+
]
|
|
184
|
+
|
|
185
|
+
for (const candidate of candidates) {
|
|
186
|
+
if (Array.isArray(candidate)) {
|
|
187
|
+
return candidate.filter(isRecord)
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
return []
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
function extractDetailRecord(data: unknown): RawRecord {
|
|
195
|
+
const records = extractRecords(data)
|
|
196
|
+
|
|
197
|
+
if (records.length > 0) {
|
|
198
|
+
return records[0]!
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
const candidates = [
|
|
202
|
+
data,
|
|
203
|
+
getValue(data, ['announcement']),
|
|
204
|
+
getValue(data, ['announcementInfo']),
|
|
205
|
+
getValue(data, ['article']),
|
|
206
|
+
getValue(data, ['detail']),
|
|
207
|
+
getValue(data, ['info']),
|
|
208
|
+
getValue(data, ['record']),
|
|
209
|
+
getValue(data, ['body']),
|
|
210
|
+
getValue(data, ['body', 'announcement']),
|
|
211
|
+
getValue(data, ['body', 'detail']),
|
|
212
|
+
getValue(data, ['body', 'info']),
|
|
213
|
+
]
|
|
214
|
+
|
|
215
|
+
return candidates.find(isRecord) || {}
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
function mapAnnouncementRecord(record: RawRecord, fallbackId = ''): Article {
|
|
219
|
+
const now = new Date().toISOString()
|
|
220
|
+
const id =
|
|
221
|
+
readString(record, ['annouId', 'announcementId', 'articleId', 'id', 'uuid']) ||
|
|
222
|
+
fallbackId
|
|
223
|
+
const title = readString(record, [
|
|
224
|
+
'annouTitle',
|
|
225
|
+
'announTitle',
|
|
226
|
+
'announcementTitle',
|
|
227
|
+
'title',
|
|
228
|
+
'name',
|
|
229
|
+
'subject',
|
|
230
|
+
])
|
|
231
|
+
const content = readString(record, [
|
|
232
|
+
'annouConte',
|
|
233
|
+
'announContent',
|
|
234
|
+
'announcementContent',
|
|
235
|
+
'articleContent',
|
|
236
|
+
'contentHtml',
|
|
237
|
+
'htmlContent',
|
|
238
|
+
'content',
|
|
239
|
+
])
|
|
240
|
+
const createdAt =
|
|
241
|
+
readString(record, ['createTime', 'createdAt', 'publishTime', 'pubTime', 'gmtCreate']) || now
|
|
242
|
+
const updatedAt =
|
|
243
|
+
readString(record, ['updateTime', 'updatedAt', 'modifyTime', 'gmtModified']) || createdAt
|
|
244
|
+
|
|
245
|
+
return {
|
|
246
|
+
id,
|
|
247
|
+
title: title || '未命名公告',
|
|
248
|
+
content: sanitizeArticleHtml(content),
|
|
249
|
+
author:
|
|
250
|
+
readString(record, ['author', 'publisherName', 'pubUserName', 'creatorName', 'createBy']) ||
|
|
251
|
+
'管理员',
|
|
252
|
+
createdAt: normalizeDate(createdAt),
|
|
253
|
+
updatedAt: normalizeDate(updatedAt),
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
function readString(record: RawRecord, keys: string[]) {
|
|
258
|
+
for (const key of keys) {
|
|
259
|
+
const value = record[key]
|
|
260
|
+
|
|
261
|
+
if (typeof value === 'string' && value.trim()) {
|
|
262
|
+
return value.trim()
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
if (typeof value === 'number') {
|
|
266
|
+
return String(value)
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
return ''
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
function getValue(value: unknown, path: string[]) {
|
|
274
|
+
return path.reduce<unknown>((current, key) => {
|
|
275
|
+
if (!isRecord(current)) {
|
|
276
|
+
return undefined
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
return current[key]
|
|
280
|
+
}, value)
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
function normalizeDate(value: string) {
|
|
284
|
+
if (/^\d{4}-\d{2}-\d{2}/.test(value)) {
|
|
285
|
+
return value
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
if (/^\d{14}$/.test(value)) {
|
|
289
|
+
return `${value.slice(0, 4)}-${value.slice(4, 6)}-${value.slice(6, 8)}T${value.slice(8, 10)}:${value.slice(10, 12)}:${value.slice(12, 14)}`
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
if (/^\d{8}$/.test(value)) {
|
|
293
|
+
return `${value.slice(0, 4)}-${value.slice(4, 6)}-${value.slice(6, 8)}T00:00:00`
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
return value
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
function isRecord(value: unknown): value is RawRecord {
|
|
300
|
+
return Boolean(value) && typeof value === 'object' && !Array.isArray(value)
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
function sanitizeChildren(parent: ParentNode, doc: Document) {
|
|
304
|
+
Array.from(parent.childNodes).forEach((child) => {
|
|
305
|
+
if (child.nodeType === Node.COMMENT_NODE) {
|
|
306
|
+
child.remove()
|
|
307
|
+
return
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
if (child.nodeType !== Node.ELEMENT_NODE) {
|
|
311
|
+
return
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
const element = child as HTMLElement
|
|
315
|
+
|
|
316
|
+
if (!ALLOWED_TAGS.has(element.tagName)) {
|
|
317
|
+
const fragment = doc.createDocumentFragment()
|
|
318
|
+
|
|
319
|
+
while (element.firstChild) {
|
|
320
|
+
fragment.appendChild(element.firstChild)
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
element.replaceWith(fragment)
|
|
324
|
+
sanitizeChildren(parent, doc)
|
|
325
|
+
return
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
sanitizeAttributes(element)
|
|
329
|
+
sanitizeChildren(element, doc)
|
|
330
|
+
})
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
function sanitizeAttributes(element: HTMLElement) {
|
|
334
|
+
Array.from(element.attributes).forEach((attribute) => {
|
|
335
|
+
const name = attribute.name.toLowerCase()
|
|
336
|
+
|
|
337
|
+
if (element.tagName === 'A' && name === 'href') {
|
|
338
|
+
if (!isSafeHref(attribute.value)) {
|
|
339
|
+
element.removeAttribute(attribute.name)
|
|
340
|
+
return
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
element.setAttribute('target', '_blank')
|
|
344
|
+
element.setAttribute('rel', 'noopener noreferrer')
|
|
345
|
+
return
|
|
346
|
+
}
|
|
347
|
+
|
|
348
|
+
if (element.tagName === 'A' && (name === 'target' || name === 'rel')) {
|
|
349
|
+
return
|
|
350
|
+
}
|
|
351
|
+
|
|
352
|
+
if (element.tagName === 'CODE' && name === 'class') {
|
|
353
|
+
const languageClass = normalizeCodeLanguageClass(attribute.value)
|
|
354
|
+
|
|
355
|
+
if (languageClass) {
|
|
356
|
+
element.setAttribute('class', languageClass)
|
|
357
|
+
return
|
|
358
|
+
}
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
if (element.tagName === 'CODE' && name === 'data-language') {
|
|
362
|
+
const language = normalizeCodeLanguage(attribute.value)
|
|
363
|
+
|
|
364
|
+
if (language) {
|
|
365
|
+
element.setAttribute('data-language', language)
|
|
366
|
+
return
|
|
367
|
+
}
|
|
368
|
+
}
|
|
369
|
+
|
|
370
|
+
element.removeAttribute(attribute.name)
|
|
371
|
+
})
|
|
372
|
+
}
|
|
373
|
+
|
|
374
|
+
function normalizeCodeLanguageClass(value: string) {
|
|
375
|
+
const language = value
|
|
376
|
+
.split(/\s+/)
|
|
377
|
+
.find((className) => className.startsWith('language-'))
|
|
378
|
+
?.replace(/^language-/, '')
|
|
379
|
+
|
|
380
|
+
if (!language) {
|
|
381
|
+
return ''
|
|
382
|
+
}
|
|
383
|
+
|
|
384
|
+
return `language-${normalizeCodeLanguage(language)}`
|
|
385
|
+
}
|
|
386
|
+
|
|
387
|
+
function normalizeCodeLanguage(value: string) {
|
|
388
|
+
return value.trim().toLowerCase().replace(/[^a-z0-9_-]/g, '').slice(0, 24)
|
|
389
|
+
}
|
|
390
|
+
|
|
391
|
+
function isSafeHref(value: string) {
|
|
392
|
+
const href = value.trim()
|
|
393
|
+
|
|
394
|
+
if (href.startsWith('#')) {
|
|
395
|
+
return true
|
|
396
|
+
}
|
|
397
|
+
|
|
398
|
+
try {
|
|
399
|
+
const url = new URL(href, window.location.origin)
|
|
400
|
+
|
|
401
|
+
return ['http:', 'https:', 'mailto:', 'tel:'].includes(url.protocol)
|
|
402
|
+
} catch {
|
|
403
|
+
return false
|
|
404
|
+
}
|
|
405
|
+
}
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
import {
|
|
2
|
+
buildTamRequestPayload,
|
|
3
|
+
tamRequest,
|
|
4
|
+
type TamRequestPayload,
|
|
5
|
+
type TamResponse,
|
|
6
|
+
} from '@/api/tam'
|
|
7
|
+
|
|
8
|
+
export type RmbForecastRecord = {
|
|
9
|
+
/** 业务类型,用于映射列表中的业务名称。 */
|
|
10
|
+
busiType?: string
|
|
11
|
+
/** 客户名称,客户类型为空时作为展示兜底。 */
|
|
12
|
+
clientName?: string
|
|
13
|
+
/** 客户类型,用于映射列表中的客户类型文案。 */
|
|
14
|
+
clientType?: string
|
|
15
|
+
/** 交易对手名称,客户名称为空时作为展示兜底。 */
|
|
16
|
+
competName?: string
|
|
17
|
+
/** 落地机构,列表主标题展示字段。 */
|
|
18
|
+
groundBranch?: string
|
|
19
|
+
/** 预报金额,接口按元返回,页面转换为亿元展示。 */
|
|
20
|
+
predAmt?: string
|
|
21
|
+
/** 预报状态,用于判断列表状态标签。 */
|
|
22
|
+
predStatus?: string
|
|
23
|
+
/** 交易日期,列表日期展示字段。 */
|
|
24
|
+
tranDate?: string
|
|
25
|
+
/** 核销状态,用于判断列表状态标签。 */
|
|
26
|
+
verifyStatus?: string
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export type RmbForecastQueryForm = {
|
|
30
|
+
/** 交易时间,当前视图必填筛选项。 */
|
|
31
|
+
tranDate: string
|
|
32
|
+
/** 落地机构,当前视图按关键字查询。 */
|
|
33
|
+
groundBranch?: string
|
|
34
|
+
/** 起始金额,页面单位为亿元。 */
|
|
35
|
+
startTranAmt?: string
|
|
36
|
+
/** 截止金额,页面单位为亿元。 */
|
|
37
|
+
endTranAmt?: string
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export type RmbForecastQueryPayload = {
|
|
41
|
+
appHead: TamRequestPayload<RmbForecastQueryBody>['appHead']
|
|
42
|
+
body: RmbForecastQueryBody
|
|
43
|
+
head: TamRequestPayload<RmbForecastQueryBody>['head']
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export type RmbForecastQueryResult = {
|
|
47
|
+
body: RmbForecastQueryResultBody
|
|
48
|
+
head: TamResponse<RmbForecastQueryResultBody>['head']
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
type RmbForecastQueryBody = {
|
|
52
|
+
/** 业务类型,当前视图未开放筛选,固定传空。 */
|
|
53
|
+
busiType: string
|
|
54
|
+
/** 客户名称,当前视图未开放筛选,固定传空。 */
|
|
55
|
+
clientName: string
|
|
56
|
+
/** 交易对手名称,当前视图未开放筛选,固定传空。 */
|
|
57
|
+
competName: string
|
|
58
|
+
/** 截止金额,页面亿元转换为接口元级整数字符串。 */
|
|
59
|
+
endTransAmt: string
|
|
60
|
+
/** 落地机构,来自当前视图输入框。 */
|
|
61
|
+
groundBranch: string
|
|
62
|
+
/** 支付渠道,当前视图未开放筛选,固定传空。 */
|
|
63
|
+
payChannel: string
|
|
64
|
+
/** 收支方向,当前视图未开放筛选,固定传空。 */
|
|
65
|
+
payDirec: string
|
|
66
|
+
/** 预报状态,当前视图未开放筛选,固定传空。 */
|
|
67
|
+
predStatus: string
|
|
68
|
+
/** 排序规则,当前视图未开放筛选,固定传空。 */
|
|
69
|
+
sortRule: string
|
|
70
|
+
/** 起始金额,页面亿元转换为接口元级整数字符串。 */
|
|
71
|
+
startTransAmt: string
|
|
72
|
+
/** 交易时间,接口格式为 YYYYMMDD。 */
|
|
73
|
+
tranDate: string
|
|
74
|
+
/** 核销状态,当前视图未开放筛选,固定传空。 */
|
|
75
|
+
verifyStatus: string
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
type RmbForecastQueryResultBody = {
|
|
79
|
+
resultList: RmbForecastRecord[]
|
|
80
|
+
totalCount: string
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
type QueryOptions = {
|
|
84
|
+
form: RmbForecastQueryForm
|
|
85
|
+
pageIndex: number
|
|
86
|
+
pageSize: number
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
const TRAN_CODE = '/TAM/0001/140101001'
|
|
90
|
+
|
|
91
|
+
export function buildRmbForecastQueryPayload({
|
|
92
|
+
form,
|
|
93
|
+
pageIndex,
|
|
94
|
+
pageSize,
|
|
95
|
+
}: QueryOptions): RmbForecastQueryPayload {
|
|
96
|
+
const tranDate = normalizeDate(form.tranDate)
|
|
97
|
+
|
|
98
|
+
// 当前视图只提供交易日期、落地机构、起始金额、截止金额,其余查询字段按接口约定传空。
|
|
99
|
+
return buildTamRequestPayload({
|
|
100
|
+
tranCode: TRAN_CODE,
|
|
101
|
+
pageIndex,
|
|
102
|
+
pageSize,
|
|
103
|
+
body: {
|
|
104
|
+
busiType: '',
|
|
105
|
+
clientName: '',
|
|
106
|
+
competName: '',
|
|
107
|
+
endTransAmt: toRequestAmount(form.endTranAmt),
|
|
108
|
+
groundBranch: form.groundBranch || '',
|
|
109
|
+
payChannel: '',
|
|
110
|
+
payDirec: '',
|
|
111
|
+
predStatus: '',
|
|
112
|
+
sortRule: '',
|
|
113
|
+
// 后端字段名为 TransAmt,保持与交易入参一致。
|
|
114
|
+
startTransAmt: toRequestAmount(form.startTranAmt),
|
|
115
|
+
tranDate,
|
|
116
|
+
verifyStatus: '',
|
|
117
|
+
},
|
|
118
|
+
})
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
export async function queryRmbForecastPage(
|
|
122
|
+
payload: RmbForecastQueryPayload,
|
|
123
|
+
): Promise<RmbForecastQueryResult> {
|
|
124
|
+
return tamRequest<RmbForecastQueryBody, RmbForecastQueryResultBody>(payload)
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
function normalizeDate(value: string) {
|
|
128
|
+
// 日期选择器产出 YYYY-MM-DD;接口需要 YYYYMMDD。
|
|
129
|
+
if (/^\d{8}$/.test(value)) return value
|
|
130
|
+
return value.replaceAll('-', '')
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
function toRequestAmount(value?: string) {
|
|
134
|
+
if (!value?.trim()) return ''
|
|
135
|
+
|
|
136
|
+
// 页面按“亿元”录入,接口按元级整数金额查询。
|
|
137
|
+
const amount = Number(value)
|
|
138
|
+
return Number.isFinite(amount) ? String(Math.round(amount * 100000000)) : ''
|
|
139
|
+
}
|
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
import dayjs from 'dayjs'
|
|
2
|
+
import { request } from '@/core/request'
|
|
3
|
+
import { useUserStore } from '@/stores/user'
|
|
4
|
+
|
|
5
|
+
export type TamAppHead = {
|
|
6
|
+
fileName: string
|
|
7
|
+
opType: string
|
|
8
|
+
ip: string
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export type TamHead = {
|
|
12
|
+
adminUserId: string
|
|
13
|
+
apprUserId: string
|
|
14
|
+
areaCode: string
|
|
15
|
+
branchId: string
|
|
16
|
+
consumerId: string
|
|
17
|
+
consumerSeqNo: string
|
|
18
|
+
digitalSign: string
|
|
19
|
+
fileFlag: string
|
|
20
|
+
filePath: string
|
|
21
|
+
isBatch: boolean
|
|
22
|
+
pageIndex: number
|
|
23
|
+
pageSize: number
|
|
24
|
+
spanId: string
|
|
25
|
+
traceId: string
|
|
26
|
+
tranCode: string
|
|
27
|
+
tranDate: string
|
|
28
|
+
tranTimestamp: string
|
|
29
|
+
userId: string
|
|
30
|
+
verifyUserId: string
|
|
31
|
+
versionId: string
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export type TamRequestPayload<TBody> = {
|
|
35
|
+
appHead: TamAppHead
|
|
36
|
+
head: TamHead
|
|
37
|
+
body: TBody
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export type TamResponseHead = Omit<TamHead, 'pageIndex' | 'pageSize'> & {
|
|
41
|
+
ctrlBits?: string
|
|
42
|
+
extra?: Record<string, unknown>
|
|
43
|
+
pageIndex: number | string
|
|
44
|
+
pageSize: number | string
|
|
45
|
+
retCode: string
|
|
46
|
+
retMsg: string
|
|
47
|
+
retStatus: string
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export type TamResponse<TBody> = {
|
|
51
|
+
head: TamResponseHead
|
|
52
|
+
body: TBody
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
type BuildTamPayloadOptions<TBody> = {
|
|
56
|
+
tranCode: string
|
|
57
|
+
body: TBody
|
|
58
|
+
pageIndex?: number
|
|
59
|
+
pageSize?: number
|
|
60
|
+
appHead?: Partial<TamAppHead>
|
|
61
|
+
head?: Partial<TamHead>
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
let consumerSeqSeed = Math.floor(Math.random() * 100000000)
|
|
65
|
+
|
|
66
|
+
export function buildTamRequestPayload<TBody>({
|
|
67
|
+
tranCode,
|
|
68
|
+
body,
|
|
69
|
+
pageIndex = 1,
|
|
70
|
+
pageSize = 10,
|
|
71
|
+
appHead,
|
|
72
|
+
head,
|
|
73
|
+
}: BuildTamPayloadOptions<TBody>): TamRequestPayload<TBody> {
|
|
74
|
+
const now = dayjs()
|
|
75
|
+
const loginContext = getTamLoginContext()
|
|
76
|
+
|
|
77
|
+
return {
|
|
78
|
+
appHead: {
|
|
79
|
+
fileName: '',
|
|
80
|
+
opType: '',
|
|
81
|
+
ip: loginContext.ip,
|
|
82
|
+
...appHead,
|
|
83
|
+
},
|
|
84
|
+
head: {
|
|
85
|
+
adminUserId: '',
|
|
86
|
+
apprUserId: '',
|
|
87
|
+
areaCode: '0000',
|
|
88
|
+
branchId: loginContext.branchId,
|
|
89
|
+
consumerId: 'TAM001',
|
|
90
|
+
// 规则:当前登录用户 ID + 日期 + 8 位运行期递增序列。
|
|
91
|
+
consumerSeqNo: `${loginContext.userId}${now.format('YYYYMMDD')}${createConsumerSeq()}`,
|
|
92
|
+
digitalSign: '',
|
|
93
|
+
fileFlag: 'N',
|
|
94
|
+
filePath: '',
|
|
95
|
+
isBatch: false,
|
|
96
|
+
pageIndex,
|
|
97
|
+
pageSize,
|
|
98
|
+
spanId: '',
|
|
99
|
+
traceId: '',
|
|
100
|
+
tranCode,
|
|
101
|
+
tranDate: now.format('YYYYMMDD'),
|
|
102
|
+
tranTimestamp: now.format('HHmmss'),
|
|
103
|
+
userId: loginContext.userId,
|
|
104
|
+
verifyUserId: '',
|
|
105
|
+
versionId: '0001',
|
|
106
|
+
...head,
|
|
107
|
+
},
|
|
108
|
+
body,
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
export async function tamRequest<TBody, TResponseBody>(
|
|
113
|
+
payload: TamRequestPayload<TBody>,
|
|
114
|
+
): Promise<TamResponse<TResponseBody>> {
|
|
115
|
+
const response = await request<TamResponse<TResponseBody>, TamRequestPayload<TBody>>({
|
|
116
|
+
url: payload.head.tranCode,
|
|
117
|
+
method: 'POST',
|
|
118
|
+
data: payload,
|
|
119
|
+
})
|
|
120
|
+
const result = response as unknown as TamResponse<TResponseBody>
|
|
121
|
+
|
|
122
|
+
if (result.head?.retStatus && result.head.retStatus !== 'S') {
|
|
123
|
+
throw new Error(result.head.retMsg || '交易失败')
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
return result
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
function getTamLoginContext() {
|
|
130
|
+
const userStore = useUserStore()
|
|
131
|
+
const principal = userStore.authPayload?.principal
|
|
132
|
+
|
|
133
|
+
return {
|
|
134
|
+
// TAM 用户号优先取登录返回的 userId,兼容只返回 username 的场景。
|
|
135
|
+
userId: firstText(principal?.userId, principal?.username, userStore.username),
|
|
136
|
+
// 当前登录机构来自 /uaa/user/getOrgByUserName 的第一条记录。
|
|
137
|
+
branchId: firstText(
|
|
138
|
+
userStore.loginOrg?.orgNo,
|
|
139
|
+
userStore.loginOrg?.orgId,
|
|
140
|
+
principal?.branchId,
|
|
141
|
+
principal?.orgId,
|
|
142
|
+
principal?.currentOrgId,
|
|
143
|
+
getLastText(principal?.orgIds),
|
|
144
|
+
),
|
|
145
|
+
// appHead.ip 使用登录返回的请求 IP。
|
|
146
|
+
ip: firstText(principal?.reqIpAddr, principal?.ip, principal?.loginIp),
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
function createConsumerSeq() {
|
|
151
|
+
consumerSeqSeed = (consumerSeqSeed + 1) % 100000000
|
|
152
|
+
return String(consumerSeqSeed).padStart(8, '0')
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
function getLastText(value: unknown) {
|
|
156
|
+
if (!Array.isArray(value)) return undefined
|
|
157
|
+
|
|
158
|
+
return [...value].reverse().find((item) => typeof item === 'string' && item.trim())
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
function firstText(...values: unknown[]) {
|
|
162
|
+
for (const value of values) {
|
|
163
|
+
if (typeof value !== 'string') continue
|
|
164
|
+
|
|
165
|
+
const text = value.trim()
|
|
166
|
+
if (text) return text
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
return ''
|
|
170
|
+
}
|