verce-vue-test 0.0.62 → 0.0.63

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.
@@ -0,0 +1,373 @@
1
+ <script setup lang="ts">
2
+ import { reactive, ref, type Component } from 'vue'
3
+ import { storeToRefs } from 'pinia'
4
+ import { ElMessage } from 'element-plus'
5
+ import { Search } from '@element-plus/icons-vue'
6
+ import NumberRange, { type RangeValue } from '@/components/NumberRange.vue'
7
+ import ElTablePro from '@/components/ElTablePro.vue'
8
+ import { formatThousands } from '@/utils/formatters'
9
+ import {
10
+ useForecastInfoStore,
11
+ type FlowInfoQueryParams,
12
+ type FlowInfoRow,
13
+ type ForecastInfoCardLayout,
14
+ } from '../store'
15
+
16
+ /**
17
+ * 流水信息业务卡片。
18
+ * 组件仅维护筛选抽屉和流水表展示,查询、分页、多选状态由 ForecastInfo Pinia 与预报信息共享。
19
+ */
20
+ type LayoutOption = {
21
+ label: string
22
+ value: ForecastInfoCardLayout
23
+ icon: Component
24
+ }
25
+
26
+ /** ElTablePro 动态列的最小描述。 */
27
+ type TableColumn = {
28
+ prop: string
29
+ label: string
30
+ minWidth: number
31
+ }
32
+
33
+ defineProps<{
34
+ layout: ForecastInfoCardLayout
35
+ layoutOptions: LayoutOption[]
36
+ }>()
37
+
38
+ const emit = defineEmits<{
39
+ changeLayout: [layout: ForecastInfoCardLayout]
40
+ }>()
41
+
42
+ /** 流水接口方向编码与预报不同:1 为收入,0 为支出。 */
43
+ const directionOptions = [
44
+ { label: '收入', value: '1' },
45
+ { label: '支出', value: '0' },
46
+ ]
47
+
48
+ /** 流水核销状态编码:1 为未核销,2 为已核销。 */
49
+ const statusOptions = [
50
+ { label: '未核销', value: '1' },
51
+ { label: '已核销', value: '2' },
52
+ ]
53
+
54
+ /** 当前为演示机构选项;真实接口接入后替换为机构字典即可。 */
55
+ const groundBranchOptions = [
56
+ { label: '总行营业部', value: 'head-office' },
57
+ { label: '上海分行', value: 'shanghai' },
58
+ { label: '深圳分行', value: 'shenzhen' },
59
+ ]
60
+
61
+ /**
62
+ * 流水表格动态列。
63
+ * 勾选列和序号列固定在模板中,金额列通过 prop 判断使用千分位和右对齐展示。
64
+ */
65
+ const flowColumns: TableColumn[] = [
66
+ { prop: 'amt', label: '金额', minWidth: 96 },
67
+ { prop: 'billDate', label: '出票日期', minWidth: 96 },
68
+ { prop: 'billNo', label: '票号', minWidth: 82 },
69
+ { prop: 'busiType', label: '支付系统业务类型', minWidth: 138 },
70
+ { prop: 'clientAcct', label: '我方账号', minWidth: 112 },
71
+ { prop: 'clientName', label: '我方户名', minWidth: 100 },
72
+ { prop: 'competAcct', label: '对方账号', minWidth: 112 },
73
+ { prop: 'competName', label: '对方户名', minWidth: 100 },
74
+ { prop: 'groundBranch', label: '我方机构', minWidth: 100 },
75
+ { prop: 'payChannel', label: '支付渠道', minWidth: 92 },
76
+ { prop: 'payDirec', label: '收支方向', minWidth: 90 },
77
+ { prop: 'refNo', label: '流水号', minWidth: 118 },
78
+ { prop: 'standardName', label: '标准名称', minWidth: 100 },
79
+ { prop: 'tranDate', label: '交易日期', minWidth: 96 },
80
+ { prop: 'tranTimeStamp', label: '清算时间', minWidth: 128 },
81
+ { prop: 'verifyStatus', label: '核销状态', minWidth: 90 },
82
+ ]
83
+
84
+ const defaultFlowForm = () => ({
85
+ tranDate: '2026-07-01',
86
+ payDirec: '',
87
+ clientName: '',
88
+ competName: '',
89
+ payChannel: '',
90
+ transAmtRange: [null, null] as RangeValue,
91
+ verifyStatus: '',
92
+ groundBranch: '',
93
+ })
94
+
95
+ /** 仅用于当前组件绑定的流水筛选表单。 */
96
+ const flowForm = reactive(defaultFlowForm())
97
+ /** 更多筛选抽屉的显示状态。 */
98
+ const flowDrawerVisible = ref(false)
99
+ /** 页面级 store 保存流水数据,也保存与预报表共享的多选结果。 */
100
+ const forecastInfoStore = useForecastInfoStore()
101
+ /** 分页、列表和最近一次查询参数从 Pinia 读取,翻页时不依赖组件局部状态。 */
102
+ const { flowRows, flowTotal, flowPage, flowPageSize, flowLoading, flowQueryParams } = storeToRefs(forecastInfoStore)
103
+
104
+ /** 恢复筛选表单初始值,不会立即请求列表。 */
105
+ function resetFlowForm() {
106
+ Object.assign(flowForm, defaultFlowForm())
107
+ }
108
+
109
+ /** 将输入标准化为接口需要的字符串,未填写时保留空字符串。 */
110
+ function toQueryText(value: unknown) {
111
+ if (value === null || value === undefined) return ''
112
+ return String(value).trim()
113
+ }
114
+
115
+ /** 流水查询日期以 YYYYMMDD 传给后端。 */
116
+ function toBackendDate(value: unknown) {
117
+ return toQueryText(value).replace(/-/g, '')
118
+ }
119
+
120
+ /**
121
+ * 组装完整流水查询参数。
122
+ * 机构名称由当前所选机构选项反查,金额范围拆成 startTransAmt/endTransAmt。
123
+ */
124
+ function buildFlowQueryParams(): FlowInfoQueryParams {
125
+ const [startTransAmt, endTransAmt] = flowForm.transAmtRange
126
+ const selectedGroundBranch = groundBranchOptions.find((option) => option.value === flowForm.groundBranch)
127
+
128
+ return {
129
+ clientName: toQueryText(flowForm.clientName),
130
+ competName: toQueryText(flowForm.competName),
131
+ endTransAmt: toQueryText(endTransAmt),
132
+ groundBranch: toQueryText(flowForm.groundBranch),
133
+ groundBranchName: toQueryText(selectedGroundBranch?.label),
134
+ payChannel: toQueryText(flowForm.payChannel),
135
+ payDirec: toQueryText(flowForm.payDirec),
136
+ startTransAmt: toQueryText(startTransAmt),
137
+ tranDate: toBackendDate(flowForm.tranDate),
138
+ verifyStatus: toQueryText(flowForm.verifyStatus),
139
+ }
140
+ }
141
+
142
+ /** 查询从第一页开始,并在成功请求后关闭更多筛选抽屉。 */
143
+ async function handleFlowQuery() {
144
+ flowPage.value = 1
145
+ const params = buildFlowQueryParams()
146
+ flowQueryParams.value = params
147
+ console.log('流水信息查询参数', params)
148
+ await forecastInfoStore.loadFlowInfoList(params)
149
+ flowDrawerVisible.value = false
150
+ ElMessage.success('已查询流水信息')
151
+ }
152
+
153
+ /** 只重置界面筛选条件,当前表格数据继续保留。 */
154
+ function handleFlowReset() {
155
+ resetFlowForm()
156
+ ElMessage.info('流水筛选条件已重置')
157
+ }
158
+
159
+ /** 翻页或改变每页条数时复用当前表单映射,避免遗漏后端参数字段。 */
160
+ function handleFlowPaginationChange(_value: { page: number; pageSize: number }) {
161
+ const params = buildFlowQueryParams()
162
+ flowQueryParams.value = params
163
+ forecastInfoStore.loadFlowInfoList(params)
164
+ }
165
+
166
+ /** 根据当前分页状态计算跨页连续序号。 */
167
+ function getFlowSequence(index: number) {
168
+ return (flowPage.value - 1) * flowPageSize.value + index + 1
169
+ }
170
+ </script>
171
+
172
+ <template>
173
+ <section class="business-card" aria-labelledby="flow-info-title">
174
+ <!-- 卡片标题和页面级布局切换;操作会同步影响预报卡片。 -->
175
+ <header class="card-header">
176
+ <h2 id="flow-info-title" class="section-title">流水信息</h2>
177
+ <div class="layout-switch" role="radiogroup" aria-label="切换流水信息卡片排列方式">
178
+ <el-tooltip
179
+ v-for="option in layoutOptions"
180
+ :key="option.value"
181
+ :content="option.label"
182
+ placement="top"
183
+ :show-after="200"
184
+ >
185
+ <button
186
+ type="button"
187
+ class="layout-switch__button"
188
+ :class="{ 'is-active': layout === option.value }"
189
+ role="radio"
190
+ :aria-label="option.label"
191
+ :aria-checked="layout === option.value"
192
+ @click="emit('changeLayout', option.value)"
193
+ >
194
+ <el-icon>
195
+ <component :is="option.icon" />
196
+ </el-icon>
197
+ </button>
198
+ </el-tooltip>
199
+ </div>
200
+ </header>
201
+
202
+ <!-- 水平布局收敛为一个快速筛选项,完整条件通过抽屉提供。 -->
203
+ <div class="forecast-filter-panel" :class="{ 'forecast-filter-panel--horizontal': layout === 'horizontal' }">
204
+ <div class="forecast-filter-panel__grid">
205
+ <label class="forecast-filter-panel__item">
206
+ <span>交易日期</span>
207
+ <el-date-picker
208
+ v-model="flowForm.tranDate"
209
+ size="small"
210
+ type="date"
211
+ placeholder="请选择日期"
212
+ format="YYYY-MM-DD"
213
+ value-format="YYYY-MM-DD"
214
+ :clearable="false"
215
+ />
216
+ </label>
217
+
218
+ <label v-if="layout === 'vertical'" class="forecast-filter-panel__item">
219
+ <span>收支方向</span>
220
+ <el-select v-model="flowForm.payDirec" size="small" placeholder="请选择" clearable>
221
+ <el-option v-for="option in directionOptions" :key="option.value" v-bind="option" />
222
+ </el-select>
223
+ </label>
224
+ </div>
225
+
226
+ <div class="forecast-filter-panel__actions">
227
+ <el-button type="primary" size="small" :icon="Search" @click="handleFlowQuery">查询</el-button>
228
+ <el-button size="small" @click="handleFlowReset">重置</el-button>
229
+ <el-button size="small" @click="flowDrawerVisible = true">更多筛选</el-button>
230
+ </div>
231
+ </div>
232
+
233
+ <!-- 表格填满卡片余高;多选值直接写入 Pinia,供预报核销与匡算联动读取。 -->
234
+ <section class="table-area" aria-label="流水信息列表">
235
+ <ElTablePro
236
+ v-model:page="flowPage"
237
+ v-model:page-size="flowPageSize"
238
+ :data="flowRows"
239
+ :total="flowTotal"
240
+ v-loading="flowLoading"
241
+ table-key="flow-info"
242
+ row-key="refNo"
243
+ border
244
+ stripe
245
+ size="small"
246
+ height="100%"
247
+ class="business-table-pro flow-table-pro"
248
+ pagination-size="small"
249
+ @selection-change="forecastInfoStore.handleFlowSelectionChange"
250
+ @pagination-change="handleFlowPaginationChange"
251
+ >
252
+ <!-- 勾选列保留行选择状态,事件入口位于 Pinia。 -->
253
+ <el-table-column
254
+ type="selection"
255
+ column-key="selection"
256
+ width="46"
257
+ align="center"
258
+ fixed="left"
259
+ reserve-selection
260
+ disabled
261
+ />
262
+ <!-- 序号按当前页和每页条数连续计算。 -->
263
+ <el-table-column
264
+ type="index"
265
+ column-key="sequence"
266
+ label="序号"
267
+ width="62"
268
+ align="center"
269
+ fixed="left"
270
+ :index="getFlowSequence"
271
+ />
272
+ <!-- 金额列使用千分位并靠右,其他字段统一居中便于扫描。 -->
273
+ <el-table-column
274
+ v-for="column in flowColumns"
275
+ :key="column.prop"
276
+ :prop="column.prop"
277
+ :label="column.label"
278
+ :min-width="column.minWidth"
279
+ :align="column.prop === 'amt' ? 'right' : 'center'"
280
+ >
281
+ <template v-if="column.prop === 'amt'" #default="{ row }">
282
+ {{ formatThousands(row.amt) }}
283
+ </template>
284
+ </el-table-column>
285
+ <template #empty>
286
+ <el-empty description="暂无数据" :image-size="54" />
287
+ </template>
288
+ </ElTablePro>
289
+ </section>
290
+
291
+ <!-- 流水完整筛选条件;抽屉内查询仍复用 buildFlowQueryParams。 -->
292
+ <el-drawer
293
+ v-model="flowDrawerVisible"
294
+ title="流水更多筛选"
295
+ size="520px"
296
+ append-to-body
297
+ class="forecast-filter-drawer"
298
+ >
299
+ <div class="forecast-filter-panel__drawer-grid">
300
+ <label class="forecast-filter-panel__item">
301
+ <span>交易日期</span>
302
+ <el-date-picker
303
+ v-model="flowForm.tranDate"
304
+ size="small"
305
+ type="date"
306
+ placeholder="请选择日期"
307
+ format="YYYY-MM-DD"
308
+ value-format="YYYY-MM-DD"
309
+ :clearable="false"
310
+ />
311
+ </label>
312
+
313
+ <label class="forecast-filter-panel__item">
314
+ <span>收支方向</span>
315
+ <el-select v-model="flowForm.payDirec" size="small" placeholder="请选择" clearable>
316
+ <el-option v-for="option in directionOptions" :key="option.value" v-bind="option" />
317
+ </el-select>
318
+ </label>
319
+
320
+ <label class="forecast-filter-panel__item">
321
+ <span>支付渠道</span>
322
+ <el-input v-model="flowForm.payChannel" size="small" placeholder="请输入" clearable />
323
+ </label>
324
+
325
+ <label class="forecast-filter-panel__item forecast-filter-panel__item--range">
326
+ <span>金额范围(万元)</span>
327
+ <NumberRange
328
+ v-model="flowForm.transAmtRange"
329
+ class="forecast-filter-panel__number-range"
330
+ separator="至"
331
+ min-placeholder="最小值"
332
+ max-placeholder="最大值"
333
+ :precision="2"
334
+ size="small"
335
+ unit="万元"
336
+ />
337
+ </label>
338
+
339
+ <label class="forecast-filter-panel__item">
340
+ <span>核销状态</span>
341
+ <el-select v-model="flowForm.verifyStatus" size="small" placeholder="请选择" clearable>
342
+ <el-option v-for="option in statusOptions" :key="option.value" v-bind="option" />
343
+ </el-select>
344
+ </label>
345
+
346
+ <label class="forecast-filter-panel__item">
347
+ <span>我方户名</span>
348
+ <el-input v-model="flowForm.clientName" size="small" placeholder="请输入" clearable />
349
+ </label>
350
+
351
+ <label class="forecast-filter-panel__item">
352
+ <span>对方户名</span>
353
+ <el-input v-model="flowForm.competName" size="small" placeholder="请输入" clearable />
354
+ </label>
355
+
356
+ <label class="forecast-filter-panel__item">
357
+ <span>我方机构</span>
358
+ <el-select v-model="flowForm.groundBranch" size="small" placeholder="请选择" clearable>
359
+ <el-option v-for="option in groundBranchOptions" :key="option.value" v-bind="option" />
360
+ </el-select>
361
+ </label>
362
+ </div>
363
+
364
+ <template #footer>
365
+ <div class="forecast-filter-panel__drawer-actions">
366
+ <el-button size="small" @click="flowDrawerVisible = false">取消</el-button>
367
+ <el-button size="small" @click="handleFlowReset">重置</el-button>
368
+ <el-button type="primary" size="small" :icon="Search" @click="handleFlowQuery">查询</el-button>
369
+ </div>
370
+ </template>
371
+ </el-drawer>
372
+ </section>
373
+ </template>