zhaoxiaoqiang1
2026-01-04 f1d30d03186c79ca2cbcfe60d6d2ce7d73fba97b
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
<template>
  <div class="product">
    <div class="borrower" v-for="(item, index) in borrowerArr" :key="index">
      <p class="title">
        <span></span>
        和解信息
      </p>
      <el-form
        :model="borrowerForm[index]"
        :rules="rules"
        :ref="`borrowerForm${index}`"
        size="small"
        inline
        label-width="165px"
      >
        <div class="form">
          <el-form-item
            label="委外律所"
            v-if="borrowerArr[index].lawName.visible"
            prop="lawName"
          >
            <el-select
              v-model="borrowerForm[index].lawName"
              filterable
              placeholder="请选择"
              :disabled="!borrowerArr[index].lawName.writeAble"
            >
              <el-option
                v-for="(item, index) in lawNameList"
                :key="index"
                :label="item.itemname"
                :value="item.itemname"
              >
              </el-option>
            </el-select>
          </el-form-item>
          <el-form-item
            label="委外律所时间"
            v-if="borrowerArr[index].outsourcingTime.visible"
            prop="outsourcingTime"
          >
            <el-date-picker
              v-model="borrowerForm[index].outsourcingTime"
              type="date"
              format="yyyy/MM/dd"
              value-format="yyyy/MM/dd"
              placeholder="选择日期"
              :disabled="!borrowerArr[index].outsourcingTime.writeAble"
            />
          </el-form-item>
          <el-form-item
            label="还款期限"
            v-if="borrowerArr[index].repayTerm.visible"
            prop="repayTerm"
          >
            <el-select
              v-model="borrowerForm[index].repayTerm"
              filterable
              placeholder="请选择"
              :disabled="!borrowerArr[index].repayTerm.writeAble"
            >
              <el-option
                v-for="(item, index) in repayTermList"
                :key="index"
                :label="item.repayTermName"
                :value="item.repayTermNo"
              >
              </el-option>
            </el-select>
          </el-form-item>
          <el-form-item
            label="是否增加直系亲属担保"
            v-if="borrowerArr[index].havingKin.visible"
            prop="havingKin"
          >
            <el-select
              v-model="borrowerForm[index].havingKin"
              filterable
              placeholder="请选择"
              :disabled="!borrowerArr[index].havingKin.writeAble"
            >
              <el-option
                v-for="(item, index) in havingKinList"
                :key="index"
                :label="item.havingKinName"
                :value="item.havingKinNo"
              >
              </el-option>
            </el-select>
          </el-form-item>
          <el-form-item
            label="贷款利率(%)"
            v-if="borrowerArr[index].loanRate.visible"
            prop="loanRate"
          >
            <el-input
              v-model="borrowerForm[index].loanRate"
              :disabled="!borrowerArr[index].loanRate.writeAble"
              placeholder="请输入"
            ></el-input>
          </el-form-item>
          <el-form-item
            label="是否完成回款账户变更流程"
            v-if="borrowerArr[index].changedAccountFlow.visible"
            prop="changedAccountFlow"
          >
            <el-select
              v-model="borrowerForm[index].changedAccountFlow"
              filterable
              placeholder="请选择"
              :disabled="!borrowerArr[index].changedAccountFlow.writeAble"
            >
              <el-option
                v-for="(item, index) in changedAccountFlowList"
                :key="index"
                :label="item.changedAccountFlowName"
                :value="item.changedAccountFlowNo"
              >
              </el-option>
            </el-select>
          </el-form-item>
          <el-form-item
            label="是否绑卡"
            v-if="borrowerArr[index].bindBankStatus.visible"
            prop="bindBankStatus"
          >
            <el-select
              v-model="borrowerForm[index].bindBankStatus"
              filterable
              placeholder="请选择"
              :disabled="!borrowerArr[index].bindBankStatus.writeAble"
            >
              <el-option
                v-for="(item, index) in bindBankStatusList"
                :key="index"
                :label="item.bindBankStatusName"
                :value="item.bindBankStatusNo"
              >
              </el-option>
            </el-select>
          </el-form-item>
          <el-form-item
            label="和解协议签署日期"
            v-if="borrowerArr[index].reconcileSignDate.visible"
            prop="reconcileSignDate"
          >
            <el-date-picker
              v-model="borrowerForm[index].reconcileSignDate"
              type="date"
              format="yyyy/MM/dd"
              value-format="yyyy/MM/dd"
              placeholder="选择日期"
              :disabled="!borrowerArr[index].reconcileSignDate.writeAble"
            />
          </el-form-item>
          <el-form-item
            label="首次还款日期"
            v-if="borrowerArr[index].firstRepayDate.visible"
            prop="firstRepayDate"
          >
            <el-date-picker
              v-model="borrowerForm[index].firstRepayDate"
              type="date"
              format="yyyy/MM/dd"
              value-format="yyyy/MM/dd"
              placeholder="选择日期"
              :disabled="!borrowerArr[index].firstRepayDate.writeAble"
            />
          </el-form-item>
          <el-form-item
            label="和解状态"
            v-if="borrowerArr[index].reconcileStatus.visible"
            prop="reconcileStatus"
          >
            <el-select
              v-model="borrowerForm[index].reconcileStatus"
              filterable
              placeholder="请选择"
              :disabled="!borrowerArr[index].reconcileStatus.writeAble"
            >
              <el-option
                v-for="(item, index) in reconcileStatusList"
                :key="index"
                :label="item.reconcileStatusName"
                :value="item.reconcileStatusNo"
              >
              </el-option>
            </el-select>
          </el-form-item>
        </div>
      </el-form>
      <el-button
        size="small"
        type="primary"
        style="margin: 0 0 20px 10px"
        @click="saveLawInfo()"
        >保存律所信息</el-button
      >
      <p class="title">
        <span></span>
        律所沟通记录
      </p>
      <el-form ref="lawForm" size="small" inline label-width="165px">
        <el-form-item
          label="律所沟通记录"
          class="content-input"
          style="width: 100%"
          prop="memo"
        >
          <el-input
            :rows="3"
            type="textarea"
            placeholder="请输入"
            v-model="currentLawCom"
            style="width: 1000px"
          ></el-input>
          <el-button
            size="small"
            type="primary"
            style="margin: 0 0 0 10px"
            @click="saveLawCommunication()"
            >保存</el-button
          >
        </el-form-item>
      </el-form>
      <KeysTable
        :list="lawCommunHistoryList"
        :header="lawCommunHistoryListHeader"
        :isShowPages="false"
        title="律所沟通历史记录"
      ></KeysTable>
      <p class="title" style="margin: 20px 0 20px 0">
        <span></span>
        首次还款试算
      </p>
      <el-button
        size="small"
        type="primary"
        style="margin: 0 0 0 10px"
        @click="firstRepaymentTrialCalculation()"
        >首次还款试算</el-button
      >
      <FormInfo
        :info="firstRepaymentInfo"
        :keys="firstRepaymentHeader"
        title="首次还款试算"
        :loading="firstRepaymentLoading"
      ></FormInfo>
      <KeysTable
        :list="vLoanReconcileRepaymentTrialList"
        :header="vLoanReconcileRepaymentTrialListHeader"
        :isShowPages="false"
        title=""
        @doAction="doAction"
      ></KeysTable>
      <KeysTable
        :list="first5DayScheduledRepaymentList"
        :header="first5DayScheduledRepaymentHeader"
        :isShowPages="false"
        title="首次还款预计金额"
      ></KeysTable>
    </div>
 
    <ListDetailDialog
      v-if="showDetailList"
      v-on:closeApply="closeApply"
      :visible="showDetailList"
      title="还款明细"
      :showList="detailList"
      :showListHeader="detailListHeader"
    />
    <div class="btn">
      <el-button size="medium" plain @click="prevPage()">上一页</el-button>
      <el-button
        size="medium"
        :loading="submitLoading"
        type="primary"
        @click="nextPage()"
        >下一页</el-button
      >
    </div>
  </div>
</template>
<script>
import FormInfo from "../../../../comprehensiveTransaction/components/FormInfo.vue";
import ListDetailDialog from "../../../components/ListDetailDialog.vue";
import KeysTable from "../../../../comprehensiveTransaction/components/KeysTable.vue";
import common from "@/utils/common";
import {
  qryMainCreditInfo, //查询主授信人信息
  qryReconcileInfoMap, //查询和解信息
  qryCommunicationInfo, //查询律所历史沟通信息
  saveCommunicationInfo, //  保存律所沟通记录
  saveReconcileInfo, //保存律所信息
  trialFirstPayment, //V贷首次还款试算
  queryPaymentCalcLog, //查询首次还款试算明细
  queryPaymentCalcResult, //查询首次还款试算结果
  getDictionaryList, //获取律所字典项
  trialFirst5DaysPayment, //V贷首次5天内还款试算
  saveFulfillment, //首次还款试算需要调这个接口生成履约数据
} from "@comprehensive/serve/public";
import {
  lawCommunHistoryListHeader,
  vLoanReconcileRepaymentTrialListHeader,
  vLoanReconcileRepaymentDetailListHeader,
  first5DayScheduledRepaymentHeader,
} from "@comprehensive/utils/tableHeaders";
import { firstRepaymentHeader } from "@comprehensive/utils/formHeaders";
export default {
  data() {
    return {
      mainCredit: this.$store.state.product.mainCredit,
      applyMenu: this.$store.state.product.applyMenu,
      mainCreditInfo: {}, //主授信人信息
      borrowerForm: [],
      borrowerArr: [],
      initialArr: [], //初始化数据
      rules: {},
      repayTermList: [
        { repayTermName: "6个月", repayTermNo: "6" },
        { repayTermName: "12个月", repayTermNo: "12" },
        { repayTermName: "24个月", repayTermNo: "24" },
        { repayTermName: "36个月", repayTermNo: "36" },
      ], //还款期限
      havingKinList: [
        { havingKinName: "无", havingKinNo: "0" },
        { havingKinName: "有", havingKinNo: "1" },
      ], //是否有直系亲属
      reconcileStatusList: [
        { reconcileStatusName: "未和解", reconcileStatusNo: "0" },
        { reconcileStatusName: "已和解", reconcileStatusNo: "1" },
        { reconcileStatusName: "沟通中", reconcileStatusNo: "2" },
        { reconcileStatusName: "拒绝和解", reconcileStatusNo: "3" },
        { reconcileStatusName: "已诉讼", reconcileStatusNo: "5" },
        { reconcileStatusName: "结清", reconcileStatusNo: "4" },
      ], //和解状态
      changedAccountFlowList: [
        { changedAccountFlowName: "是", changedAccountFlowNo: "1" },
        { changedAccountFlowName: "否", changedAccountFlowNo: "0" },
      ], //是否完成回款账户变更流程
      bindBankStatusList: [
        { bindBankStatusName: "已绑卡", bindBankStatusNo: "1" },
        { bindBankStatusName: "未绑卡", bindBankStatusNo: "0" },
      ], //是否绑卡
      lawCommunHistoryList: [], //律所和解数据
      lawCommunHistoryListHeader: [...lawCommunHistoryListHeader], //律所和解title
      vLoanReconcileRepaymentTrialList: [], // v贷试算还款明细列表
      vLoanReconcileRepaymentTrialListHeader: [
        ...vLoanReconcileRepaymentTrialListHeader,
      ], //v贷试算还款明细列表title
      currentLawCom: "",
      firstRepaymentLoading: false,
      submitLoading: false,
      firstRepaymentInfo: {
        totalFirstPrincipalAmt: "0",
        totalFirstInterestAmt: "0",
        totalFirstAmt: "0",
        totalLatestPayAmt: "0",
      }, //项目信息
      firstRepaymentHeader: [...firstRepaymentHeader],
      //是否展示还款明细列表
      showDetailList: false,
      //还款试算中,每笔还款的明细list
      detailList: [],
      //还款试算中,每笔还款的明细header
      detailListHeader: [...vLoanReconcileRepaymentDetailListHeader],
      //委外律所列表
      lawNameList: [],
      //首次还款预计金额,5-6天内
      first5DayScheduledRepaymentList: [],
      first5DayScheduledRepaymentHeader: [...first5DayScheduledRepaymentHeader],
    };
  },
  computed: {},
  components: {
    FormInfo,
    KeysTable,
    ListDetailDialog,
  },
  async created() {
    this.init();
  },
  methods: {
    init() {
      this.requestQryReconcileInfoMap();
      this.requestQryCommunicationInfo();
      this.requestQryMainCreditInfo();
      this.requestQueryPaymentCalcResult();
      this.initLawList();
    },
    //获取主授信人信息
    async requestQryReconcileInfoMap() {
      const resp = await qryReconcileInfoMap({
        applySerialNo: this.mainCredit.serialNo,
      });
      if (resp.result) {
        this.getBorrowerData(resp.result);
      }
    },
    //查询律所历史沟通信息
    async requestQryCommunicationInfo() {
      const resp = await qryCommunicationInfo({
        applySerialNo: this.mainCredit.serialNo,
      });
      if (resp.result) {
        this.lawCommunHistoryList = resp.result;
      }
    },
    //查询主授信人id
    async requestQryMainCreditInfo() {
      const { mainCredit } = this;
      const resp = await qryMainCreditInfo({
        applySerialNo: mainCredit.serialNo,
      });
      if (resp.code == "00") {
        this.mainCreditInfo = resp.result;
      }
    },
    //查询首次还款试算结果
    async requestQueryPaymentCalcResult() {
      const { mainCredit } = this;
      const resp = await queryPaymentCalcResult({
        serialNo: mainCredit.customerid,
      });
      if (resp.code == "00") {
        this.firstRepaymentInfo = {
          totalFirstAmt: resp.result.totalFirstAmt,
          totalFirstInterestAmt: resp.result.totalFirstInterestAmt,
          totalFirstPrincipalAmt: resp.result.totalFirstPrincipalAmt,
          totalLatestPayAmt: resp.result.totalLatestPayAmt,
        };
        this.vLoanReconcileRepaymentTrialList = resp.result.resultList;
      }
    },
    //查询V贷首次5天内还款试算
    async requestTrialFirst5DaysPayment() {
      const { mainCredit } = this;
      if (
        !this.borrowerForm[0].loanRate ||
        !this.borrowerForm[0].firstRepayDate
      ) {
        return;
      }
      const resp = await trialFirst5DaysPayment({
        businessRate: this.borrowerForm[0].loanRate, //贷款利率
        creditCustomerId: mainCredit.customerid, //主授信人id
        firstPayDate: this.borrowerForm[0].firstRepayDate, //首次还款日
      });
      if (resp.result) {
        // 将首次还款日期字符串转换为日期对象
        const firstRepaymentDateObj = new Date(
          this.borrowerForm[0].firstRepayDate
        );
        this.first5DayScheduledRepaymentList = resp.result.list.map(
          (item, index) => {
            const newDateObj = new Date(firstRepaymentDateObj);
            newDateObj.setDate(firstRepaymentDateObj.getDate() + index + 1); // 加上 index 天
            // 将日期对象转换回字符串格式
            const firstRepaymentDateString = newDateObj
              .toISOString()
              .split("T")[0]; // 转换为 yyyy-MM-dd 格式
            return {
              ...item,
              firstRepaymentDate: firstRepaymentDateString,
            };
          }
        );
      }
    },
    // 查询律所
    async initLawList() {
      let params = { codeNo: "LawNameCode" };
      let res = await getDictionaryList(params);
      this.lawNameList = res.result;
    },
    // 处理数据,将数据重新排列
    async getBorrowerData(result) {
      // 初始化数据
      this.borrowerArr = [];
      this.borrowerForm = [];
      this.initialArr = [];
      this.borrowerArr.push(result);
      this.borrowerArr.forEach(async (val, index) => {
        // 取数组第一个作为校验规则
        if (index == 0) {
          for (const key in val) {
            this.rules[key] = [];
            // 自定义规则校验
            switch (key) {
              case "loanRate":
                this.rules[key].push(common.validate("ratePattern"));
                break;
            }
            // 必填校验
            if (val[key].required) {
              this.rules[key].push({
                required: true,
                message: `请输入${val[key].filedDescription}`,
                trigger: "change",
              });
            }
          }
        }
        // 将数据重新排列
        const obj = {};
        for (const key in val) {
          obj[key] = val[key].value;
          val[key].value = "";
        }
        this.borrowerForm.push(obj);
        this.initialArr.push(Object.assign({}, obj));
        this.requestTrialFirst5DaysPayment();
      });
    },
 
    //保存律所沟通记录
    async saveLawCommunication() {
      console.log(
        "currentLawCom",
        this.currentLawCom,
        this.borrowerForm[0].lawName
      );
      if (!this.currentLawCom) {
        this.$message({
          type: "warning",
          message: "请输入沟通记录",
        });
        return;
      }
      if (!this.borrowerForm[0].lawName) {
        this.$message({
          type: "warning",
          message: "请输入委外律所",
        });
        return;
      }
      const resp = await saveCommunicationInfo({
        applySerialNo: this.mainCredit.serialNo,
        content: this.currentLawCom,
        objectName: this.borrowerForm[0].lawName,
      });
      if (resp.code == "00") {
        this.requestQryCommunicationInfo();
      }
    },
    //首次还款试算
    async firstRepaymentTrialCalculation() {
      const formRef = this.$refs[`borrowerForm${0}`];
      if (formRef) {
        return new Promise((resolve, reject) => {
          formRef[0].validate(async (valid) => {
            if (valid) {
              // 验证通过
              if (this.mainCreditInfo.customerid) {
                this.firstRepaymentLoading = true;
                const params = {
                  businessRate: this.borrowerForm[0].loanRate,
                  creditCustomerId: this.mainCreditInfo.customerid,
                  firstPayDate: this.borrowerForm[0].firstRepayDate,
                };
                const saveFulfillmentResp = await saveFulfillment(params);
                const resp = await trialFirstPayment(params);
                this.firstRepaymentLoading = false;
                if (resp.code == "00") {
                  this.firstRepaymentInfo = {
                    totalFirstAmt: resp.result.totalFirstAmt,
                    totalFirstInterestAmt: resp.result.totalFirstInterestAmt,
                    totalFirstPrincipalAmt: resp.result.totalFirstPrincipalAmt,
                    totalLatestPayAmt: resp.result.totalLatestPayAmt,
                  };
                  this.vLoanReconcileRepaymentTrialList =
                    resp.result.resultList;
 
                  this.requestTrialFirst5DaysPayment();
                }
              } else {
                this.$message.error("未获取到主授信人id,请退出重试");
              }
              resolve();
            } else {
              // 验证失败
              // 这里可以给出提示或者阻止下一步操作
              reject();
            }
          });
        });
      }
    },
    // 表单事件回调
    async doAction(name, item, { label }) {
      const resp = await queryPaymentCalcLog({ serialNo: item.serialno });
      if (resp.result) {
        this.detailList = resp.result;
      }
      this.showDetailList = true;
    },
 
    //保存律所信息
    async saveLawInfo() {
      const formRef = this.$refs[`borrowerForm${0}`];
      if (formRef) {
        return new Promise((resolve, reject) => {
          formRef[0].validate(async (valid) => {
            if (valid) {
              // 验证通过
              console.log("this.borrowerForm[0] resolve", this.borrowerForm[0]);
              const resp = await saveReconcileInfo({
                ...this.borrowerForm[0],
                applySerialNo: this.mainCredit.serialNo,
                termUnit: "M",
              });
              if (resp.code == "00") {
                this.$message.success("保存律所信息成功");
              }
              resolve();
            } else {
              // 验证失败
              // 这里可以给出提示或者阻止下一步操作
              reject();
            }
          });
        });
      }
    },
 
    prevPage() {
      this.applyMenu.forEach((val, index) => {
        if (val.tabname == "和解信息") {
          common.vLoanTabInfo(
            this.applyMenu[index - 1].tabname,
            "CreditFlowPublic",
            this
          );
        }
      });
    },
    nextPage() {
      const formRef = this.$refs[`borrowerForm${0}`];
      if (formRef) {
        return new Promise((resolve, reject) => {
          formRef[0].validate(async (valid) => {
            if (valid) {
              // 验证通过
              if (this.mainCreditInfo.customerid) {
                this.saveLawInfo();
                this.$parent.updateApplyTabTree("和解信息");
              } else {
                this.$message.error("未获取到主授信人id,请退出重试");
              }
              resolve();
            } else {
              // 验证失败
              // 这里可以给出提示或者阻止下一步操作
              reject();
            }
          });
        });
      }
    },
    // 关闭弹窗
    closeApply(data) {
      this.showDetailList = data;
    },
  },
  beforeRouteLeave(to, from, next) {
    next();
  },
};
</script>