settlementView.vue
10.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
<template>
<view>
<scroll-view scroll-y class="detail-content">
<!-- 结算基本信息 -->
<view class="card">
<view class="card-header">
<view class="header-left">结算信息</view>
</view>
<view class="card-body">
<view class="info-row">
<text class="label">结算编号</text>
<text class="value">{{ form.code || '--' }}</text>
</view>
<view class="info-row">
<text class="label">缴费名称</text>
<text class="value">{{ form.name || '--' }}</text>
</view>
<view class="info-row">
<text class="label">缴费单位</text>
<text class="value">{{ form.memName || '--' }}</text>
</view>
<view class="info-row">
<text class="label">考试人数</text>
<text class="value">{{ form.personCount || 0 }}人</text>
</view>
<view class="info-row">
<text class="label">费用合计</text>
<text class="value">¥{{ form.originPrice || 0 }}</text>
</view>
<view class="info-row">
<text class="label">结算金额</text>
<text class="value text-red">¥{{ form.price || 0 }}</text>
</view>
<view class="info-row">
<text class="label">支付方式</text>
<text class="value">民生付</text>
</view>
<view class="info-row">
<text class="label">提交日期</text>
<text class="value">{{ formatDate(form.commitTime) }}</text>
</view>
<view class="info-row">
<text class="label">结算日期</text>
<text class="value">{{ formatDate(form.auditTime) }}</text>
</view>
<view class="info-row" v-if="form.fileUrl">
<text class="label">发票</text>
<text class="value text-primary" @click="downloadInvoice">下载发票</text>
</view>
</view>
</view>
<!-- 关联缴费单 -->
<view class="card">
<view class="card-header">
<view class="header-left">关联缴费单</view>
</view>
<!-- 统计信息 -->
<view class="payment-stat" v-if="paymentList.length > 0">
<text>费用合计: <text class="stat-value">¥{{ paymentStat.totalAmount?.toFixed(2) }}</text></text>
<text>人数合计: <text class="stat-value">{{ paymentStat.totalNum }}</text>人</text>
</view>
<view v-if="loadingPayment" class="state-tip">加载中...</view>
<view v-else-if="paymentList.length === 0" class="state-tip">暂无关联缴费单</view>
<view class="payment-list" v-else>
<view class="payment-item" v-for="(pay, index) in paymentList" :key="pay.payId">
<!-- 头部:序号 + 名称 + 状态 -->
<view class="item-header">
<!-- <view class="item-index">{{ index + 1 }}</view> -->
<view class="item-name">{{ pay.name }}</view>
<view :class="['status-tag', pay.submitId ? 'passed' : 'pending']">
{{ pay.submitId ? '已结算' : '未结算' }}
</view>
</view>
<!-- 主体:单列列表 -->
<view class="item-body">
<view class="info-line">
<text class="info-label">缴费编号</text>
<text class="info-value">{{ pay.payCode || '--' }}</text>
</view>
<view class="info-line">
<text class="info-label">缴费单位</text>
<text class="info-value">{{ pay.memberName || '--' }}</text>
</view>
<view class="info-line">
<text class="info-label">考试人数</text>
<text class="info-value">{{ pay.totalNum || 0 }}人</text>
</view>
<view class="info-line">
<text class="info-label">总金额</text>
<text class="info-value text-red">¥{{ pay.totalAmount || 0 }}</text>
</view>
<view class="info-line">
<text class="info-label">支付方式</text>
<text class="info-value">民生付</text>
</view>
<view class="info-line">
<text class="info-label">审核状态</text>
<text :class="['info-value', getVerifyStatusClass(pay.verityStatus)]">{{ pay.verityStatusStr || '--' }}</text>
</view>
<view class="info-line">
<text class="info-label">提交日期</text>
<text class="info-value">{{ formatDate(pay.submitTime) }}</text>
</view>
<view class="info-line">
<text class="info-label">审核日期</text>
<text class="info-value">{{ formatDate(pay.verityDate) }}</text>
</view>
</view>
</view>
</view>
</view>
</scroll-view>
</view>
</template>
<script setup>
import { ref, onMounted } from 'vue'
import { onLoad } from '@dcloudio/uni-app'
import * as api from '@/common/api.js'
import config from '@/config.js'
const loading = ref(false)
const loadingPayment = ref(false)
const form = ref({})
const paymentList = ref([])
const paymentStat = ref({
totalAmount: 0,
totalNum: 0
})
onLoad((options) => {
if (options.data) {
try {
form.value = JSON.parse(decodeURIComponent(options.data))
} catch (e) {
console.error('解析结算数据失败', e)
}
}
})
onMounted(() => {
if (form.value.payids) {
getPaymentList()
}
})
async function getPaymentList() {
loadingPayment.value = true
paymentStat.value = { totalAmount: 0, totalNum: 0 }
try {
const res = await api.settlementDetailList({ payIds: form.value.payids ,type:1 })
paymentList.value = res.rows || []
// 计算统计
let totalAmount = 0
let totalNum = 0
for (const pay of paymentList.value) {
totalAmount += (pay.totalAmount * 1) || 0
totalNum += (pay.totalNum * 1) || 0
}
paymentStat.value = { totalAmount, totalNum }
} catch (err) {
console.error('获取缴费单列表失败', err)
paymentList.value = []
} finally {
loadingPayment.value = false
}
}
function formatDate(dateStr) {
if (!dateStr) return '--'
if (typeof dateStr === 'string' && dateStr.indexOf('T') > -1) {
return dateStr.slice(0, 10)
}
return dateStr
}
function getVerifyStatusClass(status) {
if (status == '1') return 'text-success'
if (status == '2') return 'text-danger'
if (status == '3') return 'text-warning'
return ''
}
function downloadInvoice() {
if (!form.value.fileUrl) {
uni.showToast({ title: '暂无发票', icon: 'none' })
return
}
try {
const invoice = JSON.parse(form.value.fileUrl)
if (invoice && invoice[0]?.url) {
let fileUrl = invoice[0].url
if (!fileUrl.startsWith('http')) {
fileUrl = config.baseUrl_api + fileUrl
}
uni.previewImage({
urls: [fileUrl],
success: () => {
console.log('previewImage success')
},
fail: (err) => {
console.error('previewImage fail:', err)
uni.showToast({ title: '打开图片失败', icon: 'none' })
}
})
}
} catch (e) {
console.error('解析发票数据失败', e)
uni.showToast({ title: '解析发票数据失败', icon: 'none' })
}
}
</script>
<style scoped lang="scss">
// 颜色变量
$primary-color: #C4121B;
$success-color: #52c41a;
$bg-color: #f5f5f5;
$card-bg: #ffffff;
$text-primary: #333;
$text-secondary: #666;
$text-placeholder: #999;
$border-color: #eee;
.detail-content {
padding: 20rpx;
background: $bg-color;
min-height: 100vh;
box-sizing: border-box;
}
.card {
background: $card-bg;
border-radius: 16rpx;
margin-bottom: 20rpx;
overflow: hidden;
box-shadow: 0 4rpx 12rpx rgba(0, 0, 0, 0.05);
}
.card-header {
display: flex;
justify-content: space-between;
align-items: center;
padding: 24rpx 24rpx 20rpx;
border-bottom: 1rpx solid $border-color;
.header-left {
font-size: 30rpx;
font-weight: 600;
color: $text-primary;
}
}
.card-body {
padding: 8rpx 24rpx 24rpx;
}
.info-row {
display: flex;
justify-content: space-between;
align-items: center;
padding: 18rpx 0;
border-bottom: 1rpx solid #f5f5f5;
&:last-child {
border-bottom: none;
}
.label {
font-size: 28rpx;
color: $text-placeholder;
flex-shrink: 0;
width: 170rpx;
}
.value {
font-size: 28rpx;
color: $text-primary;
text-align: right;
flex: 1;
word-break: break-all;
}
}
.text-red {
color: $primary-color !important;
font-weight: 600;
}
.text-primary {
color: #1561cb !important;
}
.state-tip {
text-align: center;
padding: 60rpx 0;
font-size: 26rpx;
color: $text-placeholder;
}
.payment-stat {
display: flex;
justify-content: space-between;
padding: 20rpx 24rpx;
background: #FFF0F0;
border-bottom: 1rpx solid $border-color;
font-size: 26rpx;
color: $text-secondary;
.stat-value {
color: $primary-color;
font-weight: 600;
}
}
.payment-list {
padding: 0 24rpx 24rpx;
}
.payment-item {
border-radius: 12rpx;
padding: 24rpx;
margin-top: 16rpx;
border: 1rpx solid $border-color;
background: #fff;
.item-header {
display: flex;
align-items: center;
margin-bottom: 20rpx;
padding-bottom: 16rpx;
border-bottom: 1rpx solid #f5f5f5;
.item-index {
width: 40rpx;
height: 40rpx;
line-height: 40rpx;
text-align: center;
font-size: 22rpx;
color: #fff;
background: $primary-color;
border-radius: 50%;
margin-right: 16rpx;
}
.item-name {
flex: 1;
font-size: 28rpx;
font-weight: 600;
color: $text-primary;
}
.status-tag {
font-size: 22rpx;
padding: 4rpx 16rpx;
border-radius: 20rpx;
&.passed {
background: rgba($success-color, 0.1);
color: $success-color;
}
&.pending {
background: rgba($primary-color, 0.1);
color: $primary-color;
}
}
}
.item-body {
.info-line {
display: flex;
justify-content: space-between;
align-items: center;
padding: 12rpx 0;
border-bottom: 1rpx solid #f5f5f5;
&:last-child {
border-bottom: none;
}
.info-label {
font-size: 26rpx;
color: $text-placeholder;
flex-shrink: 0;
}
.info-value {
font-size: 26rpx;
color: $text-primary;
text-align: right;
flex: 1;
margin-left: 24rpx;
word-break: break-all;
}
}
}
}
</style>