vue3-element-plus-app-chu 0.0.13 → 0.0.15

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 (28) hide show
  1. package/README.md +4 -4
  2. package/package.json +3 -2
  3. package/src/layout/index.vue +21 -36
  4. package/src/router/index.ts +107 -0
  5. package/src/router/menus.ts +16 -0
  6. package/src/utils/request.ts +3 -1
  7. package/src/view/dcps/README.md +52 -0
  8. package/src/view/dcps/auth/index.vue +151 -14
  9. package/src/view/dcps/balance/index.vue +4 -6
  10. package/src/view/dcps/common.css +7 -0
  11. package/src/view/dcps/estimation/api.ts +18 -148
  12. package/src/view/dcps/estimation/index.vue +312 -13
  13. package/src/view/dcps/forecast/api.ts +21 -218
  14. package/src/view/dcps/forecast/index.vue +996 -50
  15. package/src/view/dcps/injection/index.vue +154 -11
  16. package/src/view/dcps/write-off/api.ts +25 -180
  17. package/src/view/dcps/write-off/index.vue +776 -39
  18. package/src/view/dcps/auth/components/.gitkeep +0 -0
  19. package/src/view/dcps/auth/components/AuthorizationDetailDialog.vue +0 -171
  20. package/src/view/dcps/estimation/components/EstimationDetailDialog.vue +0 -222
  21. package/src/view/dcps/forecast/components/ForecastDetailView.vue +0 -145
  22. package/src/view/dcps/forecast/components/ForecastEditorView.vue +0 -320
  23. package/src/view/dcps/forecast/components/ForecastListView.vue +0 -322
  24. package/src/view/dcps/forecast/components/ForecastPageShell.vue +0 -56
  25. package/src/view/dcps/injection/components/InjectionDetailDialog.vue +0 -171
  26. package/src/view/dcps/runtime.ts +0 -38
  27. package/src/view/dcps/write-off/components/FlowWriteOffView.vue +0 -299
  28. package/src/view/dcps/write-off/components/ForecastWriteOffView.vue +0 -437
@@ -1,232 +1,35 @@
1
- import { postDigitalRmb } from '@/utils/digital-rmb-request'
2
- import type { ApiResponse } from '@/utils/request'
3
- import type {
4
- ForecastCreateBody,
5
- ForecastDetail,
6
- ForecastDetailParams,
7
- ForecastEditBody,
8
- ForecastFormValues,
9
- ForecastListBody,
10
- ForecastQueryParams,
11
- ForecastRow,
12
- Tam120501001InBody,
13
- Tam120501002InBody,
14
- Tam120501003InBody,
15
- Tam140501001InBody,
16
- Tam140501001OutBody,
17
- Tam140501002InBody,
18
- Tam140501002OutBody,
19
- } from './typs'
1
+ import baseHttpClient from "@chic/http"
20
2
 
21
- /**
22
- * 数字人民币头寸预报页面接口与共用工具。
23
- * 接口地址:新增 120501001、修改 120501002、删除 120501003、查询 140501001、详情 140501002;
24
- * 请求报文和接口类型均在本模块内维护。
25
- */
26
- const API = {
3
+ export default {
27
4
  /**
28
- * 分页查询头寸预报。
29
- * @param params 查询参数:opType 固定为 query;tranDate 为必查交易日期,格式为 YYYYMMDD。
30
- * 其余筛选条件为空字符串表示不限制;金额范围使用 startTransAmt、endTransAmt。
5
+ * 分页查询数字人民币头寸预报。
6
+ * @param params 查询参数:opType 固定为 query;pageIndex、pageSize 为页码和每页条数。
7
+ * 业务筛选:tranDate 为交易日期(必填,YYYYMMDD),busiType 为业务类型,
8
+ * clientName 为客户名称,competName 为交易对手名称,groundBranch 为落地机构,
9
+ * payChannel 为支付渠道,payDirec 为收支方向,predStatus 为预报状态,
10
+ * verifyStatus 为核销状态,startTransAmt、endTransAmt 为金额范围,sortRule 为排序规则。
31
11
  */
32
- queryListApi: (params: ForecastQueryParams) =>
33
- postDigitalRmb<Tam140501001InBody, Tam140501001OutBody>('/TAM/0001/140501001', params),
34
-
12
+ queryListApi: (params: unknown) => baseHttpClient.post<any>("/TAM/0001/140501001", params),
35
13
  /**
36
- * 新增一条头寸预报。
37
- * @param body 新增业务字段;金额字段由调用方标准化为十进制文本。
14
+ * 新增一条数字人民币头寸预报。
15
+ * @param params 新增参数:tranDate 为交易日期,predDate 为预报日期,predAmt 为预报金额;
16
+ * 其余为客户、机构、渠道、用途、备注等业务字段,未填写的字段可不传。
38
17
  */
39
- addApi: (body: ForecastCreateBody) =>
40
- postDigitalRmb<Tam120501001InBody, Record<string, unknown>>('/TAM/0001/120501001', { body }),
41
-
18
+ addApi: (params: unknown) => baseHttpClient.post<any>("/TAM/0001/120501001", params),
42
19
  /**
43
- * 修改一条头寸预报。
44
- * @param body 修改业务字段;predRefSeq 为待修改记录的预报流水号。
20
+ * 修改一条数字人民币头寸预报。
21
+ * @param params 修改参数:predRefSeq 为待修改记录的预报流水号;其余业务字段按修改后的值整条提交。
45
22
  */
46
- editApi: (body: ForecastEditBody) =>
47
- postDigitalRmb<Tam120501002InBody, Record<string, unknown>>('/TAM/0001/120501002', { body }),
48
-
23
+ editApi: (params: unknown) => baseHttpClient.post<any>("/TAM/0001/120501002", params),
49
24
  /**
50
- * 按预报流水号删除头寸预报。
25
+ * 批量删除数字人民币头寸预报。
51
26
  * @param predRefSeqs 待删除记录的预报流水号列表。
52
27
  */
53
28
  deleteApi: (predRefSeqs: string[]) =>
54
- postDigitalRmb<Tam120501003InBody, Record<string, unknown>>('/TAM/0001/120501003', { predRefSeqs }),
55
-
29
+ baseHttpClient.post<any>("/TAM/0001/120501003", { predRefSeqs }),
56
30
  /**
57
- * 读取单条预报详情。
58
- * @param params 详情参数:predRefNo 为预报流水号。
31
+ * 查询单条数字人民币头寸预报详情。
32
+ * @param params 查询参数:predRefNo 为预报流水号。
59
33
  */
60
- getDetailApi: (params: ForecastDetailParams) =>
61
- postDigitalRmb<Tam140501002InBody, Tam140501002OutBody>('/TAM/0001/140501002', params),
62
-
63
- /**
64
- * 读取详情并与列表记录合并:详情没有的字段由同一条列表记录补充,
65
- * 不为接口未返回的字段填入空值。
66
- * @param row 列表中的预报记录。
67
- */
68
- async fetchDetail(row: ForecastRow): Promise<ForecastDetail> {
69
- if (!row.predRefNo?.trim()) throw new Error('预报流水号缺失,无法读取详情')
70
- const body = ensureSuccess(await API.getDetailApi({ predRefNo: row.predRefNo }), '读取预报详情失败')
71
- if (!body || !Object.keys(body).length) throw new Error('服务端未返回预报详情')
72
- if (body.predRefNo && body.predRefNo !== row.predRefNo) throw new Error('返回的预报流水号与当前记录不一致')
73
- const definedBody = Object.fromEntries(Object.entries(body).filter(([, value]) => value !== undefined && value !== null))
74
- return { ...row, ...definedBody } as ForecastDetail
75
- },
76
-
77
- /**
78
- * 校验列表响应并取出当前页数据;列表缺失或总条数无效时抛出可提示的错误。
79
- * @param body 列表接口返回的业务数据。
80
- */
81
- readPage(body: ForecastListBody | null): ForecastPage {
82
- if (!body || !Array.isArray(body.resultList)) throw new Error('查询结果缺少预报列表,请联系服务端确认返回数据')
83
- const totalText = String(body.totalCount ?? body.resultList.length)
84
- const total = Number(totalText)
85
- if (!/^\d+$/.test(totalText) || !Number.isSafeInteger(total)) throw new Error('查询返回的总条数无效')
86
- return { data: body.resultList, total }
87
- },
88
- }
89
-
90
- /** 列表查询结果:当前页记录和符合条件的总条数。 */
91
- export interface ForecastPage {
92
- data: ForecastRow[] // 当前页的预报记录。
93
- total: number // 符合查询条件的总记录数。
94
- }
95
-
96
- /** 校验公共响应头;retCode 不是 00000 时按服务端提示或 fallback 抛错。 */
97
- export function ensureSuccess<T>(response: ApiResponse<T>, fallback: string): T | null {
98
- if (response?.head?.retCode !== '00000') {
99
- throw new Error(response?.head?.retMsg?.trim() || fallback)
100
- }
101
- return response.body
102
- }
103
-
104
- /** 提取可展示的错误信息;无法识别时给出统一提示。 */
105
- export function getErrorMessage(error: unknown): string {
106
- if (error instanceof Error && error.message.trim()) return error.message
107
- if (typeof error === 'string' && error.trim()) return error
108
- return '操作失败,请稍后重试'
34
+ getDetailApi: (params: unknown) => baseHttpClient.post<any>("/TAM/0001/140501002", params)
109
35
  }
110
-
111
- /** 业务日期始终按上海时区生成,不依赖浏览器所在时区,格式为 YYYYMMDD。 */
112
- export function getToday(): string {
113
- const parts = new Intl.DateTimeFormat('en-CA', {
114
- timeZone: 'Asia/Shanghai', year: 'numeric', month: '2-digit', day: '2-digit',
115
- }).formatToParts(new Date())
116
- const read = (type: Intl.DateTimeFormatPartTypes) => parts.find((part) => part.type === type)?.value || ''
117
- return read('year') + read('month') + read('day')
118
- }
119
-
120
- /** 判断是否为合法的 YYYYMMDD 日期。 */
121
- export function isValidDate(value: string): boolean {
122
- if (!/^\d{8}$/.test(value)) return false
123
- const year = Number(value.slice(0, 4))
124
- const month = Number(value.slice(4, 6))
125
- const day = Number(value.slice(6, 8))
126
- if (year < 1 || month < 1 || month > 12 || day < 1) return false
127
- const leap = year % 400 === 0 || (year % 4 === 0 && year % 100 !== 0)
128
- const monthDays = [31, leap ? 29 : 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
129
- return day <= (monthDays[month - 1] || 0)
130
- }
131
-
132
- /** 把 YYYYMMDD 格式化为 YYYY-MM-DD 展示;空值显示横线,其他格式保留原文。 */
133
- export function formatDate(value?: string): string {
134
- const text = value?.trim() || ''
135
- if (!text) return '—'
136
- return isValidDate(text) ? `${text.slice(0, 4)}-${text.slice(4, 6)}-${text.slice(6, 8)}` : text
137
- }
138
-
139
- /** 只接受十进制文本和合法千分位;保留全部小数位,避免改变输入精度。 */
140
- export function normalizeAmount(value: string): string {
141
- let text = value.trim()
142
- if (text.includes(',')) {
143
- if (!/^[+-]?\d{1,3}(?:,\d{3})+(?:\.\d*)?$/.test(text)) return ''
144
- text = text.replace(/,/g, '')
145
- }
146
- const match = /^([+-]?)(\d*)(?:\.(\d*))?$/.exec(text)
147
- if (!match || (!match[2] && !match[3])) return ''
148
- const integer = (match[2] || '0').replace(/^0+(?=\d)/, '')
149
- const fraction = match[3] || ''
150
- const negative = match[1] === '-' && /[1-9]/.test(integer + fraction)
151
- return `${negative ? '-' : ''}${integer}${fraction ? `.${fraction}` : ''}`
152
- }
153
-
154
- /** 千分位展示至少两位小数,超过两位的小数原样保留,不做浮点数转换或舍入。 */
155
- export function formatAmount(value?: string): string {
156
- const original = value?.trim() || ''
157
- if (!original) return '—'
158
- const normalized = normalizeAmount(original)
159
- if (!normalized) return original
160
- const negative = normalized.startsWith('-')
161
- const [integer = '0', fraction = ''] = (negative ? normalized.slice(1) : normalized).split('.')
162
- const grouped = integer.replace(/\B(?=(\d{3})+(?!\d))/g, ',')
163
- return `${negative ? '-' : ''}${grouped}.${fraction.padEnd(2, '0')}`
164
- }
165
-
166
- /** 按统一小数位数转为 BigInt,任意长度的十进制金额都可精确比较。 */
167
- export function compareAmounts(left: string, right: string): number {
168
- const leftText = normalizeAmount(left)
169
- const rightText = normalizeAmount(right)
170
- if (!leftText || !rightText) {
171
- if (!leftText && !rightText) return 0
172
- return leftText ? -1 : 1
173
- }
174
- const parts = (text: string) => {
175
- const negative = text.startsWith('-')
176
- const [integer = '0', fraction = ''] = (negative ? text.slice(1) : text).split('.')
177
- return { negative, integer, fraction }
178
- }
179
- const a = parts(leftText)
180
- const b = parts(rightText)
181
- const precision = Math.max(a.fraction.length, b.fraction.length)
182
- const toInteger = (amount: ReturnType<typeof parts>) =>
183
- BigInt(amount.integer + amount.fraction.padEnd(precision, '0')) * (amount.negative ? -1n : 1n)
184
- const aValue = toInteger(a)
185
- const bValue = toInteger(b)
186
- return aValue < bValue ? -1 : aValue > bValue ? 1 : 0
187
- }
188
-
189
- /** 新增和导入使用的表单初始值;日期默认取当天。 */
190
- export function createFormValues(): ForecastFormValues {
191
- const today = getToday()
192
- return {
193
- billDate: '', billNo: '', busiType: '', clientName: '', clientType: '',
194
- competAcct: '', competName: '', custInfoSeq: '', groundBranch: '', groundBranchName: '',
195
- linkMan: '', payChannel: '', payDirec: '', phoneNo: '', predAmt: '', predDate: today,
196
- predName: '', predOrgName: '', purpose: '', remark: '', tranDate: today,
197
- }
198
- }
199
-
200
- /**
201
- * 校验表单;新增校验全部必填项,修改只校验已填写的字段。
202
- * @param values 表单值。
203
- * @param mode create 为新增,edit 为修改。
204
- * @returns 错误提示文本,空字符串表示校验通过。
205
- */
206
- export function validateForm(values: ForecastFormValues, mode: 'create' | 'edit' = 'create'): string {
207
- const requiredFields = [
208
- ['clientName', '客户名称'], ['payDirec', '收支方向'], ['busiType', '业务类型'],
209
- ['payChannel', '支付渠道'], ['groundBranch', '落地机构'],
210
- ] as const
211
- if (mode === 'create') {
212
- for (const [key, label] of requiredFields) {
213
- if (!values[key].trim()) return `请填写${label}`
214
- }
215
- }
216
- for (const [key, label] of [['tranDate', '交易日期'], ['predDate', '预报日期']] as const) {
217
- const date = values[key].trim()
218
- if ((date || mode === 'create') && !isValidDate(date)) return `${label}须为有效日期,格式为 YYYYMMDD`
219
- }
220
- if (values.billDate.trim() && !isValidDate(values.billDate.trim())) {
221
- return '出票日须为有效日期,格式为 YYYYMMDD'
222
- }
223
- if (values.predAmt.trim() || mode === 'create') {
224
- const amount = normalizeAmount(values.predAmt)
225
- if (!amount || amount.startsWith('-') || (amount.split('.')[1]?.length || 0) > 2) {
226
- return '预报金额须为非负金额,最多保留两位小数'
227
- }
228
- }
229
- return ''
230
- }
231
-
232
- export default API