vue3-element-plus-app-chu 0.0.7 → 0.0.8
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/README.md +14 -0
- package/package.json +1 -1
- package/src/view/dcps/digital-rmb-authorization/index.vue +1 -1
- package/src/view/dcps/digital-rmb-forecast/api.ts +220 -0
- package/src/view/dcps/digital-rmb-forecast/components/ForecastDetailView.vue +145 -0
- package/src/view/dcps/digital-rmb-forecast/components/ForecastEditorView.vue +320 -0
- package/src/view/dcps/digital-rmb-forecast/components/ForecastListView.vue +322 -0
- package/src/view/dcps/digital-rmb-forecast/components/ForecastPageShell.vue +56 -0
- package/src/view/dcps/digital-rmb-forecast/index.vue +66 -0
- package/src/view/dcps/digital-rmb-forecast/runtime.ts +8 -0
- package/src/view/dcps/digital-rmb-forecast/typs.ts +50 -0
- package/src/view/dcps/layout/index.vue +46 -43
|
@@ -0,0 +1,320 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import { computed, onBeforeUnmount, onMounted, reactive, ref, watch } from 'vue'
|
|
3
|
+
import { ElMessage } from 'element-plus'
|
|
4
|
+
import ForecastPageShell from './ForecastPageShell.vue'
|
|
5
|
+
import API, {
|
|
6
|
+
createFormValues, ensureSuccess, getErrorMessage, getToday, normalizeAmount, validateForm,
|
|
7
|
+
} from '../api'
|
|
8
|
+
import runtime from '../runtime'
|
|
9
|
+
import type {
|
|
10
|
+
ForecastCreateBody,
|
|
11
|
+
ForecastDetail,
|
|
12
|
+
ForecastDetailFields,
|
|
13
|
+
ForecastEditBody,
|
|
14
|
+
ForecastEditorMode,
|
|
15
|
+
ForecastFormValues,
|
|
16
|
+
ForecastRow,
|
|
17
|
+
} from '../typs'
|
|
18
|
+
|
|
19
|
+
defineOptions({ name: 'ForecastEditorView' })
|
|
20
|
+
|
|
21
|
+
/** 新增和修改共用同一张表单页;row 为修改时选中的列表记录,用于补齐详情没有返回的字段。 */
|
|
22
|
+
const props = defineProps<{
|
|
23
|
+
mode: ForecastEditorMode // create 为新增,edit 为修改。
|
|
24
|
+
row?: ForecastRow | null // 修改模式的预报记录。
|
|
25
|
+
tranDate?: string // 新增模式的默认交易日期,格式为 YYYYMMDD。
|
|
26
|
+
}>()
|
|
27
|
+
|
|
28
|
+
const emit = defineEmits<{ back: []; saved: [] }>()
|
|
29
|
+
|
|
30
|
+
type FieldKey = Exclude<keyof ForecastFormValues, 'custRefSeq'>
|
|
31
|
+
type EditorField = {
|
|
32
|
+
key: FieldKey
|
|
33
|
+
label: string
|
|
34
|
+
kind?: 'date' | 'amount' | 'textarea'
|
|
35
|
+
placeholder?: string
|
|
36
|
+
createOnly?: boolean
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/** 修改时允许提交的字段;与新增接口保持同一组业务字段。 */
|
|
40
|
+
const editableFields = [
|
|
41
|
+
'billNo', 'busiType', 'clientName', 'clientType', 'competAcct', 'competName', 'groundBranch',
|
|
42
|
+
'groundBranchName', 'linkMan', 'payChannel', 'payDirec', 'phoneNo', 'predAmt', 'predDate',
|
|
43
|
+
'purpose', 'remark', 'tranDate',
|
|
44
|
+
] as const
|
|
45
|
+
|
|
46
|
+
const fieldGroups: { title: string; fields: EditorField[] }[] = [
|
|
47
|
+
{
|
|
48
|
+
title: '基本预报',
|
|
49
|
+
fields: [
|
|
50
|
+
{ key: 'tranDate', label: '交易日期', kind: 'date' },
|
|
51
|
+
{ key: 'predDate', label: '预报日期', kind: 'date' },
|
|
52
|
+
{ key: 'predAmt', label: '预报金额(元)', kind: 'amount', placeholder: '请输入金额,最多两位小数' },
|
|
53
|
+
{ key: 'payDirec', label: '收支方向代码', placeholder: '请输入收支方向代码' },
|
|
54
|
+
{ key: 'busiType', label: '业务类型代码', placeholder: '请输入业务类型代码' },
|
|
55
|
+
{ key: 'payChannel', label: '支付渠道代码', placeholder: '请输入支付渠道代码' },
|
|
56
|
+
{ key: 'clientName', label: '客户名称' },
|
|
57
|
+
{ key: 'clientType', label: '客户类型代码', placeholder: '请输入客户类型代码' },
|
|
58
|
+
],
|
|
59
|
+
},
|
|
60
|
+
{
|
|
61
|
+
title: '机构与客户',
|
|
62
|
+
fields: [
|
|
63
|
+
{ key: 'groundBranch', label: '落地机构代码' },
|
|
64
|
+
{ key: 'groundBranchName', label: '落地机构名称' },
|
|
65
|
+
{ key: 'competName', label: '交易对手名称' },
|
|
66
|
+
{ key: 'competAcct', label: '交易对手账号' },
|
|
67
|
+
{ key: 'custInfoSeq', label: '客户信息流水号' },
|
|
68
|
+
{ key: 'linkMan', label: '联系人' },
|
|
69
|
+
{ key: 'phoneNo', label: '联系电话' },
|
|
70
|
+
],
|
|
71
|
+
},
|
|
72
|
+
{
|
|
73
|
+
title: '其他信息',
|
|
74
|
+
fields: [
|
|
75
|
+
{ key: 'predName', label: '预报人员姓名', createOnly: true },
|
|
76
|
+
{ key: 'predOrgName', label: '预报机构名称', createOnly: true },
|
|
77
|
+
{ key: 'billNo', label: '票号' },
|
|
78
|
+
{ key: 'billDate', label: '出票日期', kind: 'date' },
|
|
79
|
+
{ key: 'purpose', label: '用途', kind: 'textarea' },
|
|
80
|
+
{ key: 'remark', label: '备注', kind: 'textarea' },
|
|
81
|
+
],
|
|
82
|
+
},
|
|
83
|
+
]
|
|
84
|
+
|
|
85
|
+
const form = reactive<ForecastFormValues>(createFormValues())
|
|
86
|
+
const formError = ref('')
|
|
87
|
+
const loading = ref(false) // 读取修改前的原始数据。
|
|
88
|
+
const submitting = ref(false) // 提交新增或修改。
|
|
89
|
+
const loadError = ref('')
|
|
90
|
+
const initialValues = ref<Partial<ForecastFormValues>>({})
|
|
91
|
+
const requiredFields = new Set<FieldKey>(['clientName', 'payDirec', 'busiType', 'payChannel', 'groundBranch', 'tranDate', 'predDate', 'predAmt'])
|
|
92
|
+
const disabled = computed(() => loading.value || submitting.value)
|
|
93
|
+
const predRefNo = computed(() => props.row?.predRefNo?.trim() || '')
|
|
94
|
+
const title = computed(() => props.mode === 'create' ? '新增数字人民币头寸预报' : '修改数字人民币头寸预报')
|
|
95
|
+
const visibleGroups = computed(() => fieldGroups.map(group => ({
|
|
96
|
+
...group,
|
|
97
|
+
fields: group.fields.filter(field => !field.createOnly || props.mode === 'create'),
|
|
98
|
+
})))
|
|
99
|
+
|
|
100
|
+
const initialFieldValue = (key: FieldKey) => {
|
|
101
|
+
if (key === 'custInfoSeq') return initialValues.value.custInfoSeq ?? initialValues.value.custRefSeq
|
|
102
|
+
return initialValues.value[key]
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
// 修改模式下接口没有返回的字段留空保存,避免用空值覆盖服务端已有内容。
|
|
106
|
+
const isMissingField = (key: FieldKey) => props.mode === 'edit' && initialFieldValue(key) === undefined
|
|
107
|
+
|
|
108
|
+
const fieldPlaceholder = (field: EditorField) => {
|
|
109
|
+
if (isMissingField(field.key)) return '未返回,留空保留原值'
|
|
110
|
+
if (field.kind === 'date') return '请选择日期'
|
|
111
|
+
return field.placeholder || `请输入${field.label}`
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
// 新增模式带出默认日期;修改模式只回填接口返回的字段。
|
|
115
|
+
const initializeForm = () => {
|
|
116
|
+
const nextValues = createFormValues()
|
|
117
|
+
if (props.mode === 'create') {
|
|
118
|
+
nextValues.tranDate = props.tranDate || runtime.tranDate
|
|
119
|
+
nextValues.predDate = getToday()
|
|
120
|
+
} else {
|
|
121
|
+
for (const key of Object.keys(nextValues) as FieldKey[]) {
|
|
122
|
+
const value = initialFieldValue(key)
|
|
123
|
+
if (value !== undefined) nextValues[key] = value
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
delete nextValues.custRefSeq
|
|
127
|
+
Object.assign(form, nextValues)
|
|
128
|
+
formError.value = ''
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
// 详情接口没有的字段由同一条列表记录补充,这里只挑选可提交的字符串字段。
|
|
132
|
+
const buildInitialValues = (detail: ForecastDetail): Partial<ForecastFormValues> => {
|
|
133
|
+
const initial: Partial<ForecastFormValues> = {}
|
|
134
|
+
for (const key of editableFields) {
|
|
135
|
+
const value = detail[key as keyof ForecastDetail]
|
|
136
|
+
if (typeof value === 'string') initial[key] = value
|
|
137
|
+
}
|
|
138
|
+
if (detail.groundBranchCode) initial.groundBranch = detail.groundBranchCode
|
|
139
|
+
if (detail.billSignDate !== undefined) initial.billDate = detail.billSignDate
|
|
140
|
+
const customerFields = detail as ForecastDetailFields
|
|
141
|
+
const customerReference = customerFields.custRefSeq ?? customerFields.custInfoSeq
|
|
142
|
+
if (typeof customerReference === 'string') initial.custInfoSeq = customerReference
|
|
143
|
+
return initial
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
let disposed = false
|
|
147
|
+
// 修改模式先读取原始数据,再回填表单;读取失败时停留在页面提示原因。
|
|
148
|
+
const loadDetail = async () => {
|
|
149
|
+
if (props.mode !== 'edit' || !props.row) return
|
|
150
|
+
loading.value = true
|
|
151
|
+
loadError.value = ''
|
|
152
|
+
try {
|
|
153
|
+
initialValues.value = buildInitialValues(await API.fetchDetail(props.row))
|
|
154
|
+
if (disposed) return
|
|
155
|
+
initializeForm()
|
|
156
|
+
} catch (error) {
|
|
157
|
+
if (!disposed) loadError.value = getErrorMessage(error)
|
|
158
|
+
} finally {
|
|
159
|
+
if (!disposed) loading.value = false
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
onMounted(() => {
|
|
164
|
+
if (props.mode === 'create') initializeForm()
|
|
165
|
+
else void loadDetail()
|
|
166
|
+
})
|
|
167
|
+
onBeforeUnmount(() => { disposed = true })
|
|
168
|
+
|
|
169
|
+
watch(form, () => { formError.value = '' }, { deep: true })
|
|
170
|
+
|
|
171
|
+
// 日期控件清空时可能产生 null,提交前统一回到协议要求的字符串。
|
|
172
|
+
const submit = async () => {
|
|
173
|
+
if (disabled.value || loadError.value) return
|
|
174
|
+
const values = Object.fromEntries(Object.entries(form).map(([key, value]) => [key, String(value ?? '').trim()])) as ForecastFormValues
|
|
175
|
+
formError.value = validateForm(values, props.mode)
|
|
176
|
+
if (!formError.value && props.mode === 'edit') {
|
|
177
|
+
const clearedField = fieldGroups.flatMap(group => group.fields).find(field =>
|
|
178
|
+
requiredFields.has(field.key) && initialFieldValue(field.key)?.trim() && !values[field.key],
|
|
179
|
+
)
|
|
180
|
+
if (clearedField) formError.value = `请填写${clearedField.label}`
|
|
181
|
+
}
|
|
182
|
+
if (formError.value) return
|
|
183
|
+
|
|
184
|
+
submitting.value = true
|
|
185
|
+
try {
|
|
186
|
+
if (props.mode === 'create') {
|
|
187
|
+
const body: ForecastCreateBody = {}
|
|
188
|
+
for (const [key, value] of Object.entries(values)) {
|
|
189
|
+
if (key !== 'custRefSeq' && value?.trim()) Object.assign(body, { [key]: value.trim() })
|
|
190
|
+
}
|
|
191
|
+
if (body.predAmt) body.predAmt = normalizeAmount(body.predAmt)
|
|
192
|
+
ensureSuccess(await API.addApi(body), '新增预报失败')
|
|
193
|
+
} else {
|
|
194
|
+
if (!predRefNo.value) throw new Error('预报流水号缺失,无法修改')
|
|
195
|
+
const body: ForecastEditBody = { predRefSeq: predRefNo.value }
|
|
196
|
+
for (const key of [...editableFields, 'billDate'] as const) {
|
|
197
|
+
const value = values[key]?.trim() || ''
|
|
198
|
+
if (Object.hasOwn(initialValues.value, key) || value) Object.assign(body, { [key]: value })
|
|
199
|
+
}
|
|
200
|
+
const customerReference = values.custRefSeq?.trim() || values.custInfoSeq.trim()
|
|
201
|
+
if (Object.hasOwn(initialValues.value, 'custInfoSeq') || Object.hasOwn(initialValues.value, 'custRefSeq') || customerReference) {
|
|
202
|
+
body.custRefSeq = customerReference
|
|
203
|
+
}
|
|
204
|
+
if (body.predAmt) body.predAmt = normalizeAmount(body.predAmt)
|
|
205
|
+
ensureSuccess(await API.editApi(body), '修改预报失败')
|
|
206
|
+
}
|
|
207
|
+
if (disposed) return
|
|
208
|
+
ElMessage.success(props.mode === 'create' ? '新增请求已处理' : '修改请求已处理')
|
|
209
|
+
emit('saved')
|
|
210
|
+
} catch (error) {
|
|
211
|
+
if (!disposed) ElMessage.error(getErrorMessage(error))
|
|
212
|
+
} finally {
|
|
213
|
+
if (!disposed) submitting.value = false
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
</script>
|
|
217
|
+
|
|
218
|
+
<template>
|
|
219
|
+
<ForecastPageShell :title="title" :back-disabled="submitting" @back="emit('back')">
|
|
220
|
+
<el-card class="editor-card" shadow="never" :body-style="{ padding: '12px 16px' }">
|
|
221
|
+
<div class="editor-body">
|
|
222
|
+
<div v-loading="loading" class="editor-scroll">
|
|
223
|
+
<el-alert v-if="loadError" class="editor-load-error" :title="loadError" type="error" show-icon :closable="false">
|
|
224
|
+
<el-button link type="primary" :disabled="disabled" @click="loadDetail">重新加载</el-button>
|
|
225
|
+
<el-button link type="primary" :disabled="disabled" @click="emit('back')">返回列表</el-button>
|
|
226
|
+
</el-alert>
|
|
227
|
+
<template v-else>
|
|
228
|
+
<p class="editor-note">金额单位为元,方向、业务类型、支付渠道和客户类型按业务代码填写。</p>
|
|
229
|
+
<el-form :model="form" size="small" label-position="top" :disabled="disabled" @submit.prevent="submit">
|
|
230
|
+
<section v-for="group in visibleGroups" :key="group.title" class="editor-group" :aria-label="group.title">
|
|
231
|
+
<h3>{{ group.title }}</h3>
|
|
232
|
+
<div class="editor-fields">
|
|
233
|
+
<el-form-item
|
|
234
|
+
v-for="field in group.fields"
|
|
235
|
+
:key="field.key"
|
|
236
|
+
:prop="field.key"
|
|
237
|
+
:required="mode === 'create' && requiredFields.has(field.key)"
|
|
238
|
+
:class="{ 'editor-field--wide': field.kind === 'textarea' }"
|
|
239
|
+
>
|
|
240
|
+
<template #label>
|
|
241
|
+
<span>{{ field.label }}</span>
|
|
242
|
+
<span v-if="isMissingField(field.key)" class="field-unavailable">未返回</span>
|
|
243
|
+
</template>
|
|
244
|
+
<el-date-picker
|
|
245
|
+
v-if="field.kind === 'date'"
|
|
246
|
+
v-model="form[field.key]"
|
|
247
|
+
type="date"
|
|
248
|
+
format="YYYY-MM-DD"
|
|
249
|
+
value-format="YYYYMMDD"
|
|
250
|
+
:placeholder="fieldPlaceholder(field)"
|
|
251
|
+
:editable="false"
|
|
252
|
+
clearable
|
|
253
|
+
/>
|
|
254
|
+
<el-input
|
|
255
|
+
v-else-if="field.kind === 'textarea'"
|
|
256
|
+
v-model="form[field.key]"
|
|
257
|
+
type="textarea"
|
|
258
|
+
:rows="2"
|
|
259
|
+
:placeholder="fieldPlaceholder(field)"
|
|
260
|
+
resize="vertical"
|
|
261
|
+
/>
|
|
262
|
+
<el-input
|
|
263
|
+
v-else
|
|
264
|
+
v-model="form[field.key]"
|
|
265
|
+
:inputmode="field.kind === 'amount' ? 'decimal' : 'text'"
|
|
266
|
+
:placeholder="fieldPlaceholder(field)"
|
|
267
|
+
clearable
|
|
268
|
+
autocomplete="off"
|
|
269
|
+
/>
|
|
270
|
+
</el-form-item>
|
|
271
|
+
</div>
|
|
272
|
+
</section>
|
|
273
|
+
</el-form>
|
|
274
|
+
</template>
|
|
275
|
+
</div>
|
|
276
|
+
|
|
277
|
+
<div class="editor-footer">
|
|
278
|
+
<p v-if="formError" class="editor-error" role="alert" aria-live="polite">{{ formError }}</p>
|
|
279
|
+
<span v-else class="editor-tip">{{ mode === 'create' ? '带 * 的字段为新增必填项。' : '留空的字段表示不修改该字段的原值。' }}</span>
|
|
280
|
+
<el-space :size="8">
|
|
281
|
+
<el-button :disabled="submitting" @click="emit('back')">返回列表</el-button>
|
|
282
|
+
<el-button type="primary" :disabled="disabled || !!loadError" :loading="submitting" @click="submit">
|
|
283
|
+
{{ mode === 'create' ? '新增预报' : '保存修改' }}
|
|
284
|
+
</el-button>
|
|
285
|
+
</el-space>
|
|
286
|
+
</div>
|
|
287
|
+
</div>
|
|
288
|
+
</el-card>
|
|
289
|
+
</ForecastPageShell>
|
|
290
|
+
</template>
|
|
291
|
+
|
|
292
|
+
<style scoped>
|
|
293
|
+
.editor-card { flex: 1; min-height: 0; min-width: 0; }
|
|
294
|
+
.editor-body { display: flex; height: 100%; min-height: 0; flex-direction: column; gap: 10px; }
|
|
295
|
+
.editor-scroll { flex: 1; min-height: 0; padding-right: 2px; overflow-y: auto; }
|
|
296
|
+
.editor-load-error { margin-bottom: 12px; }
|
|
297
|
+
.editor-note { margin: 0 0 12px; color: var(--el-text-color-secondary); font-size: 12px; line-height: 1.6; }
|
|
298
|
+
.editor-group + .editor-group { margin-top: 10px; padding-top: 12px; border-top: 1px solid var(--el-border-color-lighter); }
|
|
299
|
+
.editor-group h3 { margin: 0 0 12px; color: var(--el-text-color-primary); font-size: 13px; font-weight: 600; line-height: 18px; }
|
|
300
|
+
.editor-fields { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); column-gap: 18px; }
|
|
301
|
+
.editor-fields :deep(.el-form-item) { min-width: 0; margin-bottom: 14px; }
|
|
302
|
+
.editor-fields :deep(.el-form-item__label) { display: flex; align-items: center; gap: 6px; margin-bottom: 5px; padding: 0; line-height: 20px; }
|
|
303
|
+
.editor-fields :deep(.el-date-editor.el-input) { width: 100%; }
|
|
304
|
+
.editor-field--wide { grid-column: 1 / -1; }
|
|
305
|
+
.field-unavailable { color: var(--el-text-color-secondary); font-size: 11px; font-weight: 400; }
|
|
306
|
+
.editor-footer { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 8px 12px; padding-top: 10px; border-top: 1px solid var(--el-border-color-lighter); }
|
|
307
|
+
.editor-tip { color: var(--el-text-color-secondary); font-size: 12px; }
|
|
308
|
+
.editor-error { margin: 0; padding: 6px 10px; border: 1px solid var(--el-color-danger-light-7); border-radius: 4px; background: var(--el-color-danger-light-9); color: var(--el-color-danger); font-size: 12px; line-height: 1.6; }
|
|
309
|
+
|
|
310
|
+
@media (max-width: 1400px) {
|
|
311
|
+
.editor-fields { grid-template-columns: repeat(3, minmax(0, 1fr)); }
|
|
312
|
+
}
|
|
313
|
+
@media (max-width: 1000px) {
|
|
314
|
+
.editor-fields { grid-template-columns: repeat(2, minmax(0, 1fr)); }
|
|
315
|
+
}
|
|
316
|
+
@media (max-width: 600px) {
|
|
317
|
+
.editor-fields { grid-template-columns: minmax(0, 1fr); }
|
|
318
|
+
.editor-field--wide { grid-column: auto; }
|
|
319
|
+
}
|
|
320
|
+
</style>
|
|
@@ -0,0 +1,322 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import { computed, onBeforeUnmount, onMounted, reactive, ref } from 'vue'
|
|
3
|
+
import { ElMessage, ElMessageBox } from 'element-plus'
|
|
4
|
+
import API, {
|
|
5
|
+
compareAmounts, ensureSuccess, formatAmount, formatDate, getErrorMessage, normalizeAmount,
|
|
6
|
+
} from '../api'
|
|
7
|
+
import runtime from '../runtime'
|
|
8
|
+
import { ArtDataTable, type ColumnOption, type PaginationOptions, type TableSettings } from '@/components/table'
|
|
9
|
+
import type { ForecastFilters, ForecastRow } from '../typs'
|
|
10
|
+
|
|
11
|
+
defineOptions({ name: 'ForecastListView' })
|
|
12
|
+
|
|
13
|
+
/** 列表页只负责查询和展示;新建、修改、详情由外层页面切换。 */
|
|
14
|
+
const emit = defineEmits<{
|
|
15
|
+
create: []
|
|
16
|
+
edit: [row: ForecastRow]
|
|
17
|
+
detail: [row: ForecastRow]
|
|
18
|
+
}>()
|
|
19
|
+
|
|
20
|
+
type ListMutation = 'delete' | null
|
|
21
|
+
const createFilters = (): ForecastFilters => ({
|
|
22
|
+
tranDate: runtime.tranDate, clientName: '', competName: '', payDirec: '', busiType: '', payChannel: '',
|
|
23
|
+
groundBranch: '', predStatus: '', verifyStatus: '', startTransAmt: '', endTransAmt: '', sortRule: '',
|
|
24
|
+
})
|
|
25
|
+
const filters = ref(createFilters())
|
|
26
|
+
let appliedQuery: ForecastFilters = { ...filters.value }
|
|
27
|
+
// 重复输入项共用一份配置,依次为字段、名称;输入框较窄,占位文案统一使用简短提示。
|
|
28
|
+
const textFilters = [
|
|
29
|
+
['clientName', '客户名称'],
|
|
30
|
+
['competName', '交易对手名称'],
|
|
31
|
+
['payDirec', '收支方向'],
|
|
32
|
+
['busiType', '业务类型'],
|
|
33
|
+
['payChannel', '支付渠道'],
|
|
34
|
+
['groundBranch', '落地机构'],
|
|
35
|
+
['predStatus', '预报状态'],
|
|
36
|
+
['verifyStatus', '核销状态'],
|
|
37
|
+
['sortRule', '排序规则'],
|
|
38
|
+
] as const
|
|
39
|
+
const rows = ref<ForecastRow[]>([])
|
|
40
|
+
const selectedRows = ref<ForecastRow[]>([])
|
|
41
|
+
const pagination = reactive({ current: 1, size: 15, total: 0 })
|
|
42
|
+
const paginationOptions: PaginationOptions = { align: 'right', pageSizes: [15, 30, 50, 100], background: false }
|
|
43
|
+
const tableSettings = ref<TableSettings>({ size: 'small', stripe: true, border: true, headerBackground: true })
|
|
44
|
+
const showSearchBar = ref(true)
|
|
45
|
+
const loading = ref(false)
|
|
46
|
+
const queryError = ref('')
|
|
47
|
+
const mutation = ref<ListMutation>(null)
|
|
48
|
+
const busy = computed(() => mutation.value !== null)
|
|
49
|
+
const tableRef = ref<InstanceType<typeof ArtDataTable> | null>(null)
|
|
50
|
+
let requestId = 0
|
|
51
|
+
let disposed = false
|
|
52
|
+
|
|
53
|
+
const hasReference = (row: ForecastRow) => Boolean(row.predRefNo?.trim())
|
|
54
|
+
const textColumn = (prop: keyof ForecastRow, label: string, width: number, visible = true): ColumnOption<ForecastRow> => ({
|
|
55
|
+
prop, label, width, visible, showOverflowTooltip: true,
|
|
56
|
+
formatter: (row) => row[prop]?.trim() || '—',
|
|
57
|
+
})
|
|
58
|
+
const columns: ColumnOption<ForecastRow>[] = [
|
|
59
|
+
{ type: 'selection', width: 42, fixed: 'left', selectable: hasReference },
|
|
60
|
+
{ type: 'globalIndex', label: '序号', width: 60, align: 'center' },
|
|
61
|
+
{ ...textColumn('predRefNo', '预报流水号', 190), useSlot: true, slotName: 'reference' },
|
|
62
|
+
{ ...textColumn('tranDate', '交易日期', 110), formatter: (row) => formatDate(row.tranDate) },
|
|
63
|
+
textColumn('clientName', '客户名称', 180),
|
|
64
|
+
textColumn('payDirec', '收支方向', 95),
|
|
65
|
+
textColumn('busiType', '业务类型', 110),
|
|
66
|
+
textColumn('payChannel', '支付渠道', 110),
|
|
67
|
+
{ prop: 'predAmt', label: '预报金额(元)', width: 180, align: 'right', useSlot: true, slotName: 'amount' },
|
|
68
|
+
{ prop: 'verifyAmt', label: '已核销金额(元)', width: 180, align: 'right', useSlot: true, slotName: 'verifiedAmount' },
|
|
69
|
+
textColumn('competName', '交易对手名称', 180),
|
|
70
|
+
textColumn('groundBranch', '落地机构', 160),
|
|
71
|
+
textColumn('predStatus', '预报状态', 100),
|
|
72
|
+
textColumn('verifyStatus', '核销状态', 100),
|
|
73
|
+
textColumn('competAcct', '交易对手账号', 190, false),
|
|
74
|
+
textColumn('clientType', '客户类型', 100, false),
|
|
75
|
+
textColumn('groundBranchCode', '落地机构代码', 150, false),
|
|
76
|
+
{ ...textColumn('predDate', '预报日期', 110, false), formatter: (row) => formatDate(row.predDate) },
|
|
77
|
+
textColumn('predCode', '预报人员编号', 130, false),
|
|
78
|
+
textColumn('standardName', '标准名称', 150, false),
|
|
79
|
+
{ key: 'actions', label: '操作', width: 165, fixed: 'right', align: 'center', useSlot: true },
|
|
80
|
+
]
|
|
81
|
+
|
|
82
|
+
const clearSelection = () => {
|
|
83
|
+
selectedRows.value = []
|
|
84
|
+
tableRef.value?.getElTable()?.clearSelection()
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
// 请求序号防止旧响应覆盖新结果;页码越界时最多补查一次。
|
|
88
|
+
const loadList = async () => {
|
|
89
|
+
if (disposed) return
|
|
90
|
+
const currentId = ++requestId
|
|
91
|
+
const query = { ...appliedQuery }
|
|
92
|
+
const pageSize = pagination.size
|
|
93
|
+
let pageIndex = pagination.current
|
|
94
|
+
loading.value = true
|
|
95
|
+
queryError.value = ''
|
|
96
|
+
clearSelection()
|
|
97
|
+
try {
|
|
98
|
+
for (let attempt = 0; attempt < 2; attempt += 1) {
|
|
99
|
+
const response = await API.queryListApi({ ...query, opType: 'query', pageIndex, pageSize })
|
|
100
|
+
if (disposed || currentId !== requestId) return
|
|
101
|
+
const page = API.readPage(ensureSuccess(response, '预报查询失败'))
|
|
102
|
+
const lastPage = Math.max(1, Math.ceil(page.total / pageSize))
|
|
103
|
+
if (pageIndex > lastPage && attempt === 0) {
|
|
104
|
+
pageIndex = lastPage
|
|
105
|
+
continue
|
|
106
|
+
}
|
|
107
|
+
pagination.current = pageIndex
|
|
108
|
+
pagination.total = page.total
|
|
109
|
+
rows.value = page.data
|
|
110
|
+
return
|
|
111
|
+
}
|
|
112
|
+
} catch (error) {
|
|
113
|
+
if (disposed || currentId !== requestId) return
|
|
114
|
+
rows.value = []
|
|
115
|
+
pagination.total = 0
|
|
116
|
+
queryError.value = getErrorMessage(error)
|
|
117
|
+
} finally {
|
|
118
|
+
if (!disposed && currentId === requestId) loading.value = false
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
// 新查询从第一页开始;重置后复用同一查询流程。
|
|
123
|
+
const search = () => {
|
|
124
|
+
if (busy.value) return
|
|
125
|
+
const next = Object.fromEntries(Object.entries(filters.value).map(([key, value]) => [key, String(value ?? '').trim()])) as ForecastFilters
|
|
126
|
+
if (!/^\d{8}$/.test(next.tranDate)) return void ElMessage.warning('请选择交易日期')
|
|
127
|
+
for (const key of ['startTransAmt', 'endTransAmt'] as const) {
|
|
128
|
+
if (!next[key]) continue
|
|
129
|
+
const normalized = normalizeAmount(next[key])
|
|
130
|
+
if (!/^\d+(?:\.\d{1,2})?$/.test(normalized)) return void ElMessage.warning('金额范围请输入非负数,最多保留两位小数')
|
|
131
|
+
next[key] = normalized
|
|
132
|
+
}
|
|
133
|
+
if (next.startTransAmt && next.endTransAmt && compareAmounts(next.startTransAmt, next.endTransAmt) > 0) {
|
|
134
|
+
return void ElMessage.warning('起始金额不能大于截止金额')
|
|
135
|
+
}
|
|
136
|
+
appliedQuery = next
|
|
137
|
+
pagination.current = 1
|
|
138
|
+
void loadList()
|
|
139
|
+
}
|
|
140
|
+
const resetFilters = () => {
|
|
141
|
+
filters.value = createFilters()
|
|
142
|
+
search()
|
|
143
|
+
}
|
|
144
|
+
// 更新分页;current 为目标页码,size 为每页条数,切换条数时 current 传入 1。
|
|
145
|
+
const changePage = (current: number, size = pagination.size) => {
|
|
146
|
+
if (busy.value) return
|
|
147
|
+
pagination.current = current
|
|
148
|
+
pagination.size = size
|
|
149
|
+
void loadList()
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
// 行内操作交给外层页面处理,这里只校验记录是否可用;整行记录用于补齐详情接口没有返回的字段。
|
|
153
|
+
const openEdit = (row: ForecastRow) => {
|
|
154
|
+
if (busy.value || !hasReference(row)) return
|
|
155
|
+
emit('edit', row)
|
|
156
|
+
}
|
|
157
|
+
const openDetail = (row: ForecastRow) => {
|
|
158
|
+
if (busy.value || !hasReference(row)) return
|
|
159
|
+
emit('detail', row)
|
|
160
|
+
}
|
|
161
|
+
const openCreate = () => {
|
|
162
|
+
if (busy.value) return
|
|
163
|
+
emit('create')
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
async function deleteRecords(records: ForecastRow[]) {
|
|
167
|
+
if (busy.value || !records.length) return
|
|
168
|
+
const references = [...new Set(records.map((row) => row.predRefNo?.trim()).filter((value): value is string => Boolean(value)))]
|
|
169
|
+
if (!references.length) return void ElMessage.warning('选中记录缺少预报流水号')
|
|
170
|
+
mutation.value = 'delete'
|
|
171
|
+
try {
|
|
172
|
+
await ElMessageBox.confirm(`确认删除选中的 ${references.length} 条预报记录?删除后将重新查询列表。`, '删除预报', {
|
|
173
|
+
confirmButtonText: '确认删除', cancelButtonText: '取消', type: 'warning', distinguishCancelAndClose: true,
|
|
174
|
+
})
|
|
175
|
+
if (disposed) return
|
|
176
|
+
ensureSuccess(await API.deleteApi(references), '删除预报失败')
|
|
177
|
+
if (disposed) return
|
|
178
|
+
ElMessage.success('删除请求已处理')
|
|
179
|
+
await loadList()
|
|
180
|
+
} catch (error) {
|
|
181
|
+
if (!disposed && error !== 'cancel' && error !== 'close') ElMessage.error(getErrorMessage(error))
|
|
182
|
+
} finally {
|
|
183
|
+
if (!disposed) mutation.value = null
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
onMounted(() => void loadList())
|
|
188
|
+
onBeforeUnmount(() => {
|
|
189
|
+
disposed = true
|
|
190
|
+
requestId += 1
|
|
191
|
+
})
|
|
192
|
+
|
|
193
|
+
// 供外层页面在保存后重新查询,以及新增时带出当前的交易日期。
|
|
194
|
+
defineExpose({ refresh: loadList, getQueryDate: () => appliedQuery.tranDate })
|
|
195
|
+
</script>
|
|
196
|
+
|
|
197
|
+
<template>
|
|
198
|
+
<main class="dcps-page">
|
|
199
|
+
<!-- 查询条件:紧凑排列为一整行,控件尺寸跟随表格设置,卡片内边距为 10px,点击查询生效。 -->
|
|
200
|
+
<el-card v-show="showSearchBar" class="forecast-search" shadow="never" :body-style="{ padding: '10px' }">
|
|
201
|
+
<el-form class="filter-form" :model="filters" :size="tableSettings.size" label-position="top" @submit.prevent="search">
|
|
202
|
+
<el-form-item class="filter-date" label="交易日期" required>
|
|
203
|
+
<el-date-picker v-model="filters.tranDate" type="date" format="YYYY-MM-DD" value-format="YYYYMMDD" :clearable="false" :editable="false" />
|
|
204
|
+
</el-form-item>
|
|
205
|
+
<!-- label 为查询字段名称,输入框较窄,占位文案统一为简短提示。 -->
|
|
206
|
+
<el-form-item v-for="[key, label] in textFilters" :key="key" :label="label">
|
|
207
|
+
<el-input v-model="filters[key]" placeholder="请输入" :maxlength="200" clearable />
|
|
208
|
+
</el-form-item>
|
|
209
|
+
<el-form-item class="filter-amount" label="起始金额(元)">
|
|
210
|
+
<el-input v-model="filters.startTransAmt" placeholder="不限制" inputmode="decimal" :maxlength="40" clearable />
|
|
211
|
+
</el-form-item>
|
|
212
|
+
<el-form-item class="filter-amount" label="截止金额(元)">
|
|
213
|
+
<el-input v-model="filters.endTransAmt" placeholder="不限制" inputmode="decimal" :maxlength="40" clearable />
|
|
214
|
+
</el-form-item>
|
|
215
|
+
<el-space class="filter-actions" :size="8">
|
|
216
|
+
<el-button :disabled="busy" @click="resetFilters">重置</el-button>
|
|
217
|
+
<el-button type="primary" native-type="submit" :loading="loading" :disabled="busy">查询</el-button>
|
|
218
|
+
</el-space>
|
|
219
|
+
</el-form>
|
|
220
|
+
</el-card>
|
|
221
|
+
|
|
222
|
+
<el-alert v-if="queryError" :title="queryError" type="error" show-icon :closable="false">
|
|
223
|
+
<el-button link type="primary" :disabled="busy" @click="loadList">重新查询</el-button>
|
|
224
|
+
</el-alert>
|
|
225
|
+
|
|
226
|
+
<div class="forecast-table-region">
|
|
227
|
+
<ArtDataTable
|
|
228
|
+
ref="tableRef"
|
|
229
|
+
v-model:settings="tableSettings"
|
|
230
|
+
v-model:show-search-bar="showSearchBar"
|
|
231
|
+
class="forecast-table"
|
|
232
|
+
fill
|
|
233
|
+
title="预报记录"
|
|
234
|
+
toolbar-layout="search,refresh,size,fullscreen,columns,settings"
|
|
235
|
+
:data="rows"
|
|
236
|
+
:columns="columns"
|
|
237
|
+
:loading="loading || busy"
|
|
238
|
+
:pagination="pagination"
|
|
239
|
+
:pagination-options="paginationOptions"
|
|
240
|
+
row-key="predRefNo"
|
|
241
|
+
:empty-text="queryError ? '查询失败,请重新查询' : '暂无符合条件的预报记录'"
|
|
242
|
+
@selection-change="(selection: ForecastRow[]) => selectedRows = selection"
|
|
243
|
+
@pagination:current-change="changePage"
|
|
244
|
+
@pagination:size-change="(size) => changePage(1, size)"
|
|
245
|
+
@refresh="!busy && loadList()"
|
|
246
|
+
@row-dblclick="openDetail"
|
|
247
|
+
>
|
|
248
|
+
<template #toolbar-left>
|
|
249
|
+
<div class="table-actions">
|
|
250
|
+
<el-button type="primary" :disabled="busy" @click="openCreate">新增预报</el-button>
|
|
251
|
+
<!-- 导入、导出由后端接口完成,按钮先保留页面入口,不在前端拼装文件。 -->
|
|
252
|
+
<el-button :disabled="busy">导入</el-button>
|
|
253
|
+
<el-button :disabled="busy || loading || !rows.length">导出</el-button>
|
|
254
|
+
<el-button type="danger" plain :disabled="busy || loading || !selectedRows.length" @click="deleteRecords(selectedRows)">
|
|
255
|
+
批量删除<span v-if="selectedRows.length">({{ selectedRows.length }})</span>
|
|
256
|
+
</el-button>
|
|
257
|
+
</div>
|
|
258
|
+
</template>
|
|
259
|
+
<template #reference="{ row }">
|
|
260
|
+
<el-button v-if="hasReference(row)" link type="primary" :disabled="busy" @click.stop="openDetail(row)" @dblclick.stop>
|
|
261
|
+
{{ row.predRefNo }}
|
|
262
|
+
</el-button>
|
|
263
|
+
<span v-else>—</span>
|
|
264
|
+
</template>
|
|
265
|
+
<template #amount="{ row }"><span class="amount-cell">{{ formatAmount(row.predAmt) }}</span></template>
|
|
266
|
+
<template #verifiedAmount="{ row }"><span class="amount-cell">{{ formatAmount(row.verifyAmt) }}</span></template>
|
|
267
|
+
<template #actions="{ row }">
|
|
268
|
+
<div class="row-actions" @dblclick.stop>
|
|
269
|
+
<el-button link type="primary" :disabled="busy || !hasReference(row)" @click.stop="openDetail(row)">详情</el-button>
|
|
270
|
+
<el-button link type="primary" :disabled="busy || !hasReference(row)" @click.stop="openEdit(row)">修改</el-button>
|
|
271
|
+
<el-button link type="danger" :disabled="busy || !hasReference(row)" @click.stop="deleteRecords([row])">删除</el-button>
|
|
272
|
+
</div>
|
|
273
|
+
</template>
|
|
274
|
+
</ArtDataTable>
|
|
275
|
+
</div>
|
|
276
|
+
</main>
|
|
277
|
+
</template>
|
|
278
|
+
|
|
279
|
+
<style scoped>
|
|
280
|
+
/* 页面先扣除宿主占用高度,再使用 flex 分配剩余高度,让列表内部滚动并保留分页。 */
|
|
281
|
+
.dcps-page {
|
|
282
|
+
/* 手动修改这里:顶部导航/页签 + 底部状态栏 + 宿主上下留白的合计高度。
|
|
283
|
+
独立页面保持 0px;例如顶部 90px、底部 24px、上下留白 6px,填写 120px。
|
|
284
|
+
不包含浏览器标签栏、地址栏,也不包含本页面自身的 padding。 */
|
|
285
|
+
--host-layout-height: 0px;
|
|
286
|
+
box-sizing: border-box;
|
|
287
|
+
display: flex;
|
|
288
|
+
flex-direction: column;
|
|
289
|
+
gap: 5px;
|
|
290
|
+
height: calc(100vh - var(--host-layout-height));
|
|
291
|
+
height: calc(100dvh - var(--host-layout-height));
|
|
292
|
+
min-width: 0;
|
|
293
|
+
min-height: 0;
|
|
294
|
+
padding: 5px;
|
|
295
|
+
overflow: hidden;
|
|
296
|
+
background: var(--el-bg-color-page, #f7f8fa);
|
|
297
|
+
}
|
|
298
|
+
/* 筛选项压成一行,等分剩余宽度,窗口过窄时才换行并限制高度,为列表保留空间。 */
|
|
299
|
+
.forecast-search {
|
|
300
|
+
flex: 0 0 auto;
|
|
301
|
+
max-height: min(42dvh, 360px);
|
|
302
|
+
overflow-y: auto;
|
|
303
|
+
}
|
|
304
|
+
.filter-form { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 8px 6px; }
|
|
305
|
+
.filter-form :deep(.el-form-item) { flex: 1 1 76px; min-width: 76px; margin: 0; }
|
|
306
|
+
/* 日期和金额输入框内容更长,给出略大的基准宽度,剩余空间再由各列均分。 */
|
|
307
|
+
.filter-form :deep(.filter-date) { flex: 1.5 0 116px; }
|
|
308
|
+
.filter-form :deep(.filter-amount) { flex: 1.2 0 92px; }
|
|
309
|
+
.filter-form :deep(.el-form-item__label) { height: auto; margin-bottom: 4px; padding: 0; font-size: 12px; line-height: 16px; }
|
|
310
|
+
.filter-form :deep(.el-date-editor) { width: 100%; min-width: 0; }
|
|
311
|
+
.filter-actions { flex: 0 0 auto; }
|
|
312
|
+
.forecast-table-region { flex: 1; min-width: 0; min-height: 0; }
|
|
313
|
+
.forecast-table { padding: 10px; }
|
|
314
|
+
.table-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
|
|
315
|
+
.table-actions :deep(.el-button + .el-button), .row-actions :deep(.el-button + .el-button) { margin-left: 0; }
|
|
316
|
+
.row-actions { display: flex; justify-content: center; gap: 10px; }
|
|
317
|
+
.amount-cell { color: var(--el-text-color-primary); font-variant-numeric: tabular-nums; }
|
|
318
|
+
@media (max-width: 640px) {
|
|
319
|
+
.filter-form :deep(.el-form-item) { flex-basis: 100%; }
|
|
320
|
+
.table-actions { gap: 5px; }
|
|
321
|
+
}
|
|
322
|
+
</style>
|