wlzboy
2025-09-25 4648a3bee638e9a99d2d80b66f8833b261a2db91
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
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
<template>
  <view class="settlement-container">
    <view class="settlement-header">
      <text class="header-title">任务结算</text>
    </view>
    
    <scroll-view class="settlement-content" scroll-y="true">
      <view class="task-info-section">
        <view class="info-item">
          <view class="label">任务编号:</view>
          <view class="value">{{ task.taskNo }}</view>
        </view>
        
        <view class="info-item">
          <view class="label">任务类型:</view>
          <view class="value">{{ getTaskTypeText(task.type) }}</view>
        </view>
        
        <view class="info-item">
          <view class="label">车辆信息:</view>
          <view class="value">{{ task.vehicle }}</view>
        </view>
        
        <view class="info-item">
          <view class="label">出发地:</view>
          <view class="value">{{ task.startLocation }}</view>
        </view>
        
        <view class="info-item">
          <view class="label">目的地:</view>
          <view class="value">{{ task.endLocation }}</view>
        </view>
      </view>
      
      <view class="amount-section">
        <view class="section-title">费用信息</view>
        
        <view class="amount-item">
          <view class="label">基础费用:</view>
          <view class="value">¥{{ baseAmount }}</view>
        </view>
        
        <view class="amount-item additional-fees" @click="showAdditionalFees">
          <view class="label">附加费用:</view>
          <view class="value">¥{{ additionalAmount }} 
            <uni-icons type="arrowright" size="16" color="#999"></uni-icons>
          </view>
        </view>
        
        <view class="amount-item total-amount">
          <view class="label">总费用:</view>
          <view class="value total">¥{{ totalAmount }}</view>
        </view>
      </view>
      
      <view class="settlement-form">
        <view class="form-item">
          <view class="form-label">结算金额</view>
          <input 
            class="form-input" 
            type="digit" 
            placeholder="请输入结算金额" 
            v-model="settlementAmount"
          />
        </view>
        
        <view class="form-item">
          <view class="form-label">支付方式</view>
          <picker mode="selector" :range="paymentMethods" @change="onPaymentMethodChange">
            <view class="form-input picker-input">
              {{ selectedPaymentMethod || '请选择支付方式' }}
              <uni-icons type="arrowright" size="16" color="#999"></uni-icons>
            </view>
          </picker>
        </view>
        
        <view class="form-item">
          <view class="form-label">备注</view>
          <textarea 
            class="form-textarea" 
            placeholder="请输入备注信息" 
            v-model="remark"
          />
        </view>
      </view>
      
      <!-- 支付二维码区域 -->
      <view v-if="showQRCode" class="qr-code-section">
        <view class="section-title">请扫码支付</view>
        <view class="qr-code-container">
          <image class="qr-code" :src="qrCodeImage" mode="widthFix"></image>
          <view class="qr-tip">请使用{{ selectedPaymentMethod }}扫码支付</view>
        </view>
        <view class="payment-status">
          <view v-if="paymentStatus === 'pending'" class="status-pending">等待支付...</view>
          <view v-if="paymentStatus === 'success'" class="status-success">
            <uni-icons type="checkmarkempty" size="24" color="#4cd964"></uni-icons>
            支付成功
          </view>
        </view>
      </view>
    </scroll-view>
    
    <view class="action-section">
      <button 
        v-if="!showQRCode || paymentStatus === 'success'" 
        class="submit-btn" 
        @click="saveSettlement"
        :disabled="!canSave"
      >
        保存结算
      </button>
    </view>
    
    <!-- 附加费用弹窗 -->
    <uni-popup ref="additionalFeesPopup" type="bottom">
      <view class="popup-content">
        <view class="popup-header">
          <text class="header-title">附加费用</text>
          <view class="close-btn" @click="closeAdditionalFeesPopup">
            <uni-icons type="close" size="20" color="#999"></uni-icons>
          </view>
        </view>
        
        <!-- 简化版费用添加 -->
        <view class="simple-fee-section">
          <view class="form-item">
            <view class="form-label">费用类型</view>
            <picker mode="selector" :range="additionalFeeTypeNames" @change="onFeeTypeChange">
              <view class="form-input picker-input">
                {{ selectedFeeTypeName || '请选择费用类型' }}
                <uni-icons type="arrowright" size="16" color="#999"></uni-icons>
              </view>
            </picker>
          </view>
          
          <view class="form-item">
            <view class="form-label">费用金额</view>
            <input 
              class="form-input" 
              type="digit" 
              placeholder="请输入费用金额" 
              v-model="newFeePrice"
            />
          </view>
          
          <view class="add-fee-btn">
            <button class="confirm-btn" @click="addCustomFee">添加费用</button>
          </view>
        </view>
        
        <!-- 已添加的费用列表 -->
        <view class="added-fees-list" v-if="selectedAdditionalFees.length > 0">
          <view class="section-title">已添加费用</view>
          <view 
            class="fee-item" 
            v-for="(fee, index) in selectedAdditionalFees" 
            :key="index"
          >
            <view class="fee-info">
              <view class="fee-name">{{ fee.name }}</view>
              <view class="fee-price">¥{{ fee.price }} × {{ fee.quantity }}</view>
            </view>
            <view class="fee-total">¥{{ (fee.price * fee.quantity).toFixed(2) }}</view>
          </view>
        </view>
        
        <view class="popup-footer">
          <button class="confirm-btn" @click="confirmAdditionalFees">确定</button>
        </view>
      </view>
    </uni-popup>
  </view>
</template>
 
<script>
  export default {
    data() {
      return {
        task: {
          id: 1,
          taskNo: 'RW20230515001',
          type: 'emergency',
          vehicle: '粤A12345',
          startLocation: '广州市天河区XX路123号',
          endLocation: '广州市白云区YY路456号'
        },
        baseAmount: 1000, // 基础费用
        additionalAmount: 0, // 附加费用
        settlementAmount: '', // 结算金额
        remark: '', // 备注
        paymentMethods: ['现金', '支付宝', '微信', '挂帐'],
        selectedPaymentMethod: '',
        showQRCode: false,
        paymentStatus: 'pending', // pending, success
        qrCodeImage: '/static/images/qrcode.png', // 二维码图片路径
        additionalFeeTypes: [
          { name: '担架费', price: 200 },
          { name: '等待费', price: 100 },
          { name: '善后费', price: 150 },
          { name: '夜间服务费', price: 300 },
          { name: '长途费', price: 500 }
        ],
        selectedAdditionalFees: [], // 已选择的附加费用
        selectedFeeTypeName: '', // 选中的费用类型名称
        newFeePrice: '' // 新增费用价格
      }
    },
    computed: {
      totalAmount() {
        return this.baseAmount + this.additionalAmount;
      },
      canSave() {
        // 现金和挂帐可以直接保存,其他支付方式需要支付成功后才能保存
        if (!this.settlementAmount || !this.selectedPaymentMethod) {
          return false;
        }
        
        if (this.selectedPaymentMethod === '现金' || this.selectedPaymentMethod === '挂帐') {
          return true;
        }
        
        // 支付宝、微信等需要支付成功
        return this.paymentStatus === 'success';
      },
      // 获取费用类型名称数组
      additionalFeeTypeNames() {
        return this.additionalFeeTypes.map(fee => fee.name);
      }
    },
    onLoad(options) {
      // 实际项目中这里会通过API获取任务详情
      // const taskId = options.id;
      // this.getTaskDetail(taskId);
    },
    methods: {
      getTaskTypeText(type) {
        const typeMap = {
          'maintenance': '维修保养',
          'refuel': '加油',
          'inspection': '巡检',
          'emergency': '急救转运',
          'welfare': '福祉车'
        }
        return typeMap[type] || '未知类型'
      },
      
      onPaymentMethodChange(e) {
        this.selectedPaymentMethod = this.paymentMethods[e.detail.value];
        
        // 如果选择支付宝或微信,显示二维码
        if (this.selectedPaymentMethod === '支付宝' || this.selectedPaymentMethod === '微信') {
          this.showQRCode = true;
          this.paymentStatus = 'pending';
          // 模拟支付状态检查
          this.checkPaymentStatus();
        } else {
          this.showQRCode = false;
          this.paymentStatus = 'pending';
        }
      },
      
      // 费用类型选择
      onFeeTypeChange(e) {
        this.selectedFeeTypeName = this.additionalFeeTypeNames[e.detail.value];
      },
      
      checkPaymentStatus() {
        // 模拟支付状态检查,实际项目中应该通过API轮询检查支付状态
        setTimeout(() => {
          // 模拟支付成功
          this.paymentStatus = 'success';
        }, 5000);
      },
      
      showAdditionalFees() {
        this.$refs.additionalFeesPopup.open();
      },
      
      closeAdditionalFeesPopup() {
        this.$refs.additionalFeesPopup.close();
      },
      
      // 添加自定义费用
      addCustomFee() {
        if (!this.selectedFeeTypeName) {
          this.$modal.showToast('请选择费用类型');
          return;
        }
        
        if (!this.newFeePrice || isNaN(this.newFeePrice) || parseFloat(this.newFeePrice) <= 0) {
          this.$modal.showToast('请输入有效的费用金额');
          return;
        }
        
        // 查找选中的费用类型信息
        const selectedFeeType = this.additionalFeeTypes.find(fee => fee.name === this.selectedFeeTypeName);
        
        // 检查是否已存在同名费用
        const existingFee = this.selectedAdditionalFees.find(fee => fee.name === this.selectedFeeTypeName);
        if (existingFee) {
          existingFee.quantity += 1;
        } else {
          this.selectedAdditionalFees.push({
            name: this.selectedFeeTypeName,
            price: parseFloat(this.newFeePrice),
            quantity: 1
          });
        }
        
        // 清空输入框
        this.selectedFeeTypeName = '';
        this.newFeePrice = '';
        
        this.calculateAdditionalAmount();
        this.$modal.showToast('费用添加成功');
      },
      
      calculateAdditionalAmount() {
        this.additionalAmount = this.selectedAdditionalFees.reduce((total, fee) => {
          return total + (fee.price * fee.quantity);
        }, 0);
      },
      
      confirmAdditionalFees() {
        this.calculateAdditionalAmount();
        this.closeAdditionalFeesPopup();
      },
      
      saveSettlement() {
        if (!this.settlementAmount) {
          this.$modal.showToast('请输入结算金额');
          return;
        }
        
        if (!this.selectedPaymentMethod) {
          this.$modal.showToast('请选择支付方式');
          return;
        }
        
        // 检查结算金额是否合理
        if (parseFloat(this.settlementAmount) > this.totalAmount) {
          this.$modal.showToast('结算金额不能大于总费用');
          return;
        }
        
        this.$modal.confirm('确定要保存结算信息吗?').then(() => {
          // 这里应该调用API保存结算信息
          console.log('结算信息:', {
            taskId: this.task.id,
            baseAmount: this.baseAmount,
            additionalAmount: this.additionalAmount,
            totalAmount: this.totalAmount,
            settlementAmount: this.settlementAmount,
            paymentMethod: this.selectedPaymentMethod,
            remark: this.remark,
            additionalFees: this.selectedAdditionalFees
          });
          
          this.$modal.showToast('结算信息保存成功');
          // 返回任务列表
          this.$tab.navigateBack();
        }).catch(() => {
          // 取消操作
        });
      }
    }
  }
</script>
 
<style lang="scss">
  .settlement-container {
    padding: 20rpx;
    background-color: #f5f5f5;
    height: 100vh;
    display: flex;
    flex-direction: column;
    // 隐藏滚动条但保持滚动功能
    ::-webkit-scrollbar {
      display: none;
      width: 0 !important;
      height: 0 !important;
      background: transparent;
    }
    
    // Firefox滚动条隐藏
    * {
      scrollbar-width: none; /* Firefox */
    }
    
    // IE/Edge滚动条隐藏
    * {
      -ms-overflow-style: none; /* IE 10+ */
    }
  }
  
  .settlement-header {
    background-color: white;
    border-radius: 15rpx;
    padding: 30rpx;
    margin-bottom: 20rpx;
    box-shadow: 0 2rpx 10rpx rgba(0, 0, 0, 0.05);
    flex-shrink: 0;
    
    .header-title {
      font-size: 36rpx;
      font-weight: bold;
      color: #333;
      text-align: center;
    }
  }
  
  .settlement-content {
    flex: 1;
    
    .task-info-section {
      background-color: white;
      border-radius: 15rpx;
      padding: 30rpx;
      margin-bottom: 20rpx;
      box-shadow: 0 2rpx 10rpx rgba(0, 0, 0, 0.05);
      
      .info-item {
        display: flex;
        margin-bottom: 20rpx;
        padding-bottom: 20rpx;
        border-bottom: 1rpx solid #f0f0f0;
        
        &:last-child {
          margin-bottom: 0;
          padding-bottom: 0;
          border-bottom: none;
        }
        
        .label {
          font-size: 28rpx;
          color: #666;
          margin-right: 20rpx;
          white-space: nowrap;
          width: 150rpx;
        }
        
        .value {
          font-size: 28rpx;
          flex: 1;
          word-break: break-all;
        }
      }
    }
    
    .amount-section {
      background-color: white;
      border-radius: 15rpx;
      padding: 30rpx;
      margin-bottom: 20rpx;
      box-shadow: 0 2rpx 10rpx rgba(0, 0, 0, 0.05);
      
      .section-title {
        font-size: 32rpx;
        font-weight: bold;
        margin-bottom: 30rpx;
        color: #333;
      }
      
      .amount-item {
        display: flex;
        justify-content: space-between;
        margin-bottom: 20rpx;
        padding-bottom: 20rpx;
        border-bottom: 1rpx solid #f0f0f0;
        
        &:last-child {
          margin-bottom: 0;
          padding-bottom: 0;
          border-bottom: none;
        }
        
        &.additional-fees {
          .value {
            color: #007AFF;
          }
        }
        
        &.total-amount {
          .label {
            font-weight: bold;
          }
          
          .value.total {
            font-weight: bold;
            font-size: 32rpx;
            color: #e54d42;
          }
        }
        
        .label {
          font-size: 28rpx;
          color: #333;
        }
        
        .value {
          font-size: 28rpx;
          color: #333;
        }
      }
    }
    
    .settlement-form {
      background-color: white;
      border-radius: 15rpx;
      padding: 30rpx;
      margin-bottom: 20rpx;
      box-shadow: 0 2rpx 10rpx rgba(0, 0, 0, 0.05);
      
      .form-item {
        margin-bottom: 40rpx;
        
        &:last-child {
          margin-bottom: 0;
        }
        
        .form-label {
          font-size: 28rpx;
          margin-bottom: 15rpx;
          color: #333;
        }
        
        .form-input {
          height: 70rpx;
          padding: 0 20rpx;
          border: 1rpx solid #eee;
          border-radius: 10rpx;
          font-size: 28rpx;
          
          &.picker-input {
            display: flex;
            align-items: center;
            justify-content: space-between;
          }
        }
        
        .form-textarea {
          width: 100%;
          min-height: 150rpx;
          padding: 20rpx;
          border: 1rpx solid #eee;
          border-radius: 10rpx;
          font-size: 28rpx;
          resize: none;
        }
      }
    }
    
    .qr-code-section {
      background-color: white;
      border-radius: 15rpx;
      padding: 30rpx;
      margin-bottom: 20rpx;
      box-shadow: 0 2rpx 10rpx rgba(0, 0, 0, 0.05);
      text-align: center;
      
      .section-title {
        font-size: 32rpx;
        font-weight: bold;
        margin-bottom: 30rpx;
        color: #333;
      }
      
      .qr-code-container {
        margin-bottom: 30rpx;
        
        .qr-code {
          width: 300rpx;
          height: 300rpx;
          margin: 0 auto 20rpx;
        }
        
        .qr-tip {
          font-size: 26rpx;
          color: #666;
        }
      }
      
      .payment-status {
        .status-pending {
          font-size: 28rpx;
          color: #ff9900;
        }
        
        .status-success {
          font-size: 28rpx;
          color: #4cd964;
          display: flex;
          align-items: center;
          justify-content: center;
        }
      }
    }
  }
  
  .action-section {
    padding: 20rpx 0;
    flex-shrink: 0;
    
    .submit-btn {
      width: 80%;
      height: 80rpx;
      background-color: #007AFF;
      color: white;
      border-radius: 10rpx;
      font-size: 32rpx;
      margin: 0 auto;
      display: block;
      
      &[disabled] {
        background-color: #ccc;
      }
    }
  }
  
  .popup-content {
    background-color: white;
    border-top-left-radius: 20rpx;
    border-top-right-radius: 20rpx;
    padding: 30rpx;
    max-height: 80vh;
    
    .popup-header {
      display: flex;
      justify-content: space-between;
      align-items: center;
      margin-bottom: 30rpx;
      padding-bottom: 20rpx;
      border-bottom: 1rpx solid #f0f0f0;
      
      .header-title {
        font-size: 36rpx;
        font-weight: bold;
        color: #333;
      }
      
      .close-btn {
        padding: 10rpx;
      }
    }
    
    .simple-fee-section {
      padding: 20rpx 0;
      border-bottom: 1rpx solid #f0f0f0;
      margin-bottom: 20rpx;
      
      .form-item {
        margin-bottom: 30rpx;
        
        &:last-child {
          margin-bottom: 0;
        }
        
        .form-label {
          font-size: 28rpx;
          margin-bottom: 15rpx;
          color: #333;
        }
        
        .form-input {
          height: 70rpx;
          padding: 0 20rpx;
          border: 1rpx solid #eee;
          border-radius: 10rpx;
          font-size: 28rpx;
          
          &.picker-input {
            display: flex;
            align-items: center;
            justify-content: space-between;
          }
        }
      }
      
      .add-fee-btn {
        margin-top: 20rpx;
        
        .confirm-btn {
          width: 100%;
          height: 70rpx;
          background-color: #007AFF;
          color: white;
          border-radius: 10rpx;
          font-size: 28rpx;
        }
      }
    }
    
    .added-fees-list {
      margin-bottom: 30rpx;
      
      .section-title {
        font-size: 32rpx;
        font-weight: bold;
        margin-bottom: 20rpx;
        color: #333;
      }
      
      .fee-item {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 20rpx 0;
        border-bottom: 1rpx solid #f0f0f0;
        
        &:last-child {
          border-bottom: none;
        }
        
        .fee-info {
          .fee-name {
            font-size: 28rpx;
            color: #333;
            margin-bottom: 10rpx;
          }
          
          .fee-price {
            font-size: 26rpx;
            color: #666;
          }
        }
        
        .fee-total {
          font-size: 28rpx;
          font-weight: bold;
          color: #e54d42;
        }
      }
    }
    
    .popup-footer {
      .confirm-btn {
        width: 100%;
        height: 80rpx;
        background-color: #007AFF;
        color: white;
        border-radius: 10rpx;
        font-size: 32rpx;
      }
    }
  }
</style>