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
<template>
  <div class="apply-info">
    <CommForm
      :inline="true"
      :list="computedFormList"
      @updateValue="updateValue"
      ref="applyForm"
      :formValues="formValues"
      :formRules="formRules"
      title="退款申请信息"
      :conf="conf"
      formType="info"
    ></CommForm>
    <Dialog
      v-model="isShowDialog"
      icon="succ"
      iconText="提交成功"
      :buttons="[{ text: '确定', type: 'primary' }]"
      @handleClick="commitSuccess"
    ></Dialog>
    <div class="tab-form-buttons">
      <p>
        <el-button class="comm-button" @click="goBack">返回</el-button>
      </p>
      <p>
        <el-button
          class="comm-button"
          type="primary"
          @click="submit"
          :loading="submitLoading"
          >提交</el-button
        >
      </p>
    </div>
  </div>
</template>
<script>
// 退款申请信息
import { mapMutations } from "vuex";
import CommForm from "../CommForm.vue";
// import Dialog from '@/components/Dialog'
import Dialog from "../../components/Dialog.vue";
 
import queryCodeValueList from "@comprehensive/model/queryCodeValueList";
import claimRefundApply from "@comprehensive/model/claimRefundApply";
import queryCodeObject from "@comprehensive/model/queryCodeObject";
import claimRefundEditCommit from "@comprehensive/model/claimRefundEditCommit";
import getAllCityAreaList from "@comprehensive/model/getAllCityAreaList";
 
import claimRefundApplyInfo from "@comprehensive/model/claimRefundApplyInfo";
import claimRefundInfo from "@comprehensive/model/claimRefundInfo";
import { qryTrxnbrRelative, qryProjectAllInfo } from "@/api/product";
import {
  refundDepositApply, //保证金退还提交
  malGetAllCityAreaList,
} from "@comprehensive/serve/public";
 
export default {
  props: {
    // 申请编号
    serialNo: {
      type: String,
      required: true,
    },
    objectType: {
      type: String,
      default: "",
    },
    customerID: {
      type: String,
      default: "",
    },
    flowno: {
      type: String,
 
      // 默认为案场
      default: "CreditFlowCase",
    },
    conf: {
      type: Object,
      default: () => ({}),
    },
  },
  components: {
    CommForm,
    Dialog,
  },
  data() {
    return {
      info: {},
      transCode: "",
      rpyNam: "",
      stageNum: "",
      query: {},
      coreBalance: "",
      formList: [],
      codeObjectList: [],
      bankCodeObjectList: [],
      detailModel: null,
      model: null,
      selectModel: null,
      codeModel: null,
      updateModel: null,
      areaModel: null,
      isInitCity: false,
      isShowDialog: false,
      visible: false,
      claimFlowData: [],
 
      submitLoading: false,
    };
  },
  created() {
    this.init();
  },
  methods: {
    init() {
      const { query } = this.$route;
      const { transCode, isUpdate, stageNum } = query;
      this.query = query;
      this.transCode = transCode;
      this.stageNum = parseInt(stageNum);
      this.selectModel = queryCodeValueList();
      this.codeModel = queryCodeObject("PutOutAccountType");
 
      this.detailModel = claimRefundApplyInfo();
      this.model = claimRefundApply();
      this.updateModel = isUpdate === "1" ? claimRefundEditCommit() : null;
      this.areaModel = getAllCityAreaList();
      this.requestQryTrxnbrRelative(() => {
        this.getBankDetail();
      });
    },
    async requestQryTrxnbrRelative(callBack) {
      const { query } = this;
      const resp = await qryTrxnbrRelative({
        projectSerialNo: query.serialno,
      });
      if (resp.code == "00") {
        this.claimFlowData = resp.result.records;
        callBack ? callBack() : "";
      }
    },
    async getDetail(flg) {
      // isApply: '01', // 是否申请 01 是 02 否
      const { query, detailModel } = this;
      const { isApply = "02", objecttype, transSerialNo, serialno } = query; // transSerialNo,listObjectType和是从列表传过来的,没有通过continueModel接口
      const info = await detailModel.request({
        isApply,
        trxnBr: this.claimFlowData[0].trxnBr,
        refundLogId: transSerialNo,
        objectType: objecttype,
      });
      const resp = await qryProjectAllInfo({ projectSerialNo: serialno });
 
      this.coreBalance = resp.result.projectDepositQueryRsp.remainAmount;
      this.info = {
        ...info,
        bankCode: info.orgId,
        actualwaiveAmt: resp.result.projectDepositQueryRsp.remainAmount,
      };
      this.setRefundApplicationInfo(this.info);
      if (!flg) {
        this.setForm();
      }
    },
    async getBankDetail() {
      const model = claimRefundInfo();
      const { rpyNam, coreBalance } = await model.request({
        trxnBr: this.claimFlowData[0].trxnBr,
      });
      // this.coreBalance = coreBalance;
      this.rpyNam = rpyNam;
      this.getDetail();
    },
    setForm() {
      const { model, info, stageNum } = this;
      const formList = model.getFormList(info);
      this.formList =
        stageNum === 3
          ? formList.map((item) =>
              ["refundType", "accountingChannel"].includes(item.name)
                ? { ...item, attrs: [], rules: [] }
                : { ...item, attrs: ["readonly"], rules: [] }
            )
          : formList;
      formList.map((res) => {
        if (res.name == "accountType") {
          res.value = "02";
        }
        if (res.name == "refundType") {
          res.value = "01";
        }
        return res;
      });
      if (this.query.isApply == "02") {
        formList.splice(0, 1);
      }
      this.setSelectOptions();
    },
 
    // 更新表单数据
    updateValue(index, info, flg = true) {
      const { formList, codeObjectList } = this;
      if (info.name == "isNeedback" && info.value == 0) {
        const nameIndex = formList.findIndex((res) => res.name === "name");
        const accountNoIndex = formList.findIndex(
          (res) => res.name === "accountNo"
        );
        this.$set(formList, nameIndex, {
          ...formList[nameIndex],
          attrs: [],
          value: "",
        });
        this.$set(formList, accountNoIndex, {
          ...formList[accountNoIndex],
          attrs: [],
          value: "",
        });
      }
 
      if (info.name == "isNeedback" && info.value == 1) {
        this.setForm();
      }
      if (isNaN(index)) {
        // index is name
        index = formList.findIndex(({ name }) => name === index);
      }
 
      if (!isNaN(index) && index > -1) {
        const preInfo = formList[index];
        const { name } = preInfo;
        this.$set(formList, index, { ...preInfo, ...info });
        if (info.name == "bankCode" && info.value) {
          const bankName = info.options.filter(
            (res) => res.value == info.value
          );
          const bankNameIndex = formList.findIndex(
            (res) => res.name === "bankName"
          );
          this.$set(formList, bankNameIndex, {
            ...formList[bankNameIndex],
            attrs: [],
            value: bankName[0].label,
          });
        }
        if (
          info.name == "actualwaiveAmt" &&
          Number(info.value) > Number(this.coreBalance)
        ) {
          this.$message.error("退款金额不能大于剩余保证金金额!");
          this.$set(formList, index, {
            ...formList[index],
            attrs: [],
            value: this.coreBalance,
          });
        }
        if (name === "province") {
          this.getArea("city", "02", info.value);
        }
        if (name === "refundType" && info.value === "02") {
          const channel = formList.find(
            ({ name }) => name === "accountingChannel"
          );
          if (
            channel &&
            Array.isArray(channel.options) &&
            channel.options.length === 0
          ) {
            this.getCodeObject("accountingChannel", "PutOutAccountType");
          }
        }
        if (name === "accountingChannel" && info.value) {
          const curr = codeObjectList.find(
            ({ itemno }) => itemno === info.value
          );
          const settleAccountsIndex = formList.findIndex(
            ({ name }) => name === "settleAccounts"
          );
          const settleAccountsNameIndex = formList.findIndex(
            ({ name }) => name === "settleAccountsName"
          );
          // 线下退款账户类型 联动效果
          if (curr) {
            const { attribute1, attribute3 } = curr;
            this.$set(formList, settleAccountsIndex, {
              ...formList[settleAccountsIndex],
              value: attribute1,
            });
            this.$set(formList, settleAccountsNameIndex, {
              ...formList[settleAccountsNameIndex],
              value: attribute3,
            });
          }
        }
        this.$nextTick(() => this.setRefundInfo());
      }
    },
 
    setRefundInfo() {
      const { formValues } = this;
      this.setRefundApplicationInfo(formValues);
    },
 
    async getCodeObject(name, codeno) {
      const { codeModel } = this;
      const { list } = await codeModel.request({
        codeno,
      });
      // 线下退款账户类型
      if (name === "accountingChannel") {
        this.codeObjectList = list;
        this.updateValue(
          name,
          {
            options: list.map(({ itemname, itemno }) => ({
              label: itemname,
              value: itemno,
              text: itemno,
            })),
          },
          false
        );
      }
      // 退款收款账户开户银行简称
      if (name === "bankName") {
        this.bankCodeObjectList = list;
        this.updateValue(
          name,
          {
            options: list.map(({ itemname, attribute1, itemno }) => ({
              label: itemname,
              value: itemno,
              text: itemno,
            })),
          },
          false
        );
      }
    },
 
    // 表单按钮事件处理
    async submit() {
      const {
        model,
        query,
        info,
        conf,
        updateModel,
        stageNum,
        formList,
        bankCodeObjectList,
      } = this;
      const { objectNo, objecttype, serialno } = query;
      const { edit } = conf;
      // if (edit !== "Y" || stageNum === 3) {
      //   return false;
      // }
 
      const values = this.$refs.applyForm.validate();
      if (values) {
        const matchedItem = bankCodeObjectList.find(
          (item) => values.bankName === item.itemno
        );
        try {
          const resp = await refundDepositApply({
            ...values,
            bankCode: matchedItem.attribute1,
            objectType: objecttype,
            object: serialno,
            objectNo: serialno,
          });
          if (resp.code == "00") {
            this.getDetail("norefresh");
            this.isShowDialog = true;
          }
        } catch (e) {
          // loading.close()
        }
      } else {
        this.$message.warning(
          "当前页面存在必填项未录入或数据录入错误,请检查!"
        );
      }
    },
 
    // 设置表单下拉菜单
    setSelectOptions() {
      const { formList, query, conf } = this;
      const { isApply } = query;
      const { edit } = conf;
      if (
        this.query.isApply == "02" &&
        formList &&
        formList[0].name === "isNeedback"
      ) {
        formList.splice(0, 1);
      }
      // if (edit !== "Y") {
      //   console.log('edit',edit)
      //   return false;
      // }
      formList.forEach(({ name, attrs = [] }) => {
        if (
          attrs.some(
            (item) =>
              (typeof item === "object" && item.readonly) || item === "readonly"
          )
        ) {
          return false;
        }
        // 是否
        if (name === "isNeedback") {
          this.updateValue(
            name,
            {
              options: [
                { value: "1", label: "是" },
                { value: "0", label: "否" },
              ],
            },
            false
          );
        }
        // 退款收款账户类型
        if (name === "accountType") {
          this.queryCodeValueList(name, "RefundAccountType");
        }
        // 退款方式
        if (name === "refundType") {
          this.queryCodeValueList(name, "RefundType");
        }
        // 退款收款账户开户银行简称
        if (name === "bankName") {
          this.getCodeObject(name, "BankCode");
        }
        // 退款收款账户开户行所在省
        if (name === "province") {
          this.getArea(name);
        }
        if (isApply === "02") {
          this.getCodeObject("accountingChannel", "PutOutAccountType");
        }
        // 退款收款账户开户行所在市
        // if (name === 'city') {
        //   // this.getArea(name, '02')
        // }
      });
    },
 
    // 贷后交易名称下拉列表
    async getBank(name) {
      const { bankModel } = this;
      const { list } = await bankModel.request({ status: 3 });
      this.updateValue(name, { options: list }, false);
    },
 
    // 退款方式下拉列表
    async queryCodeValueList(name, codeNo) {
      const { selectModel, rpyNam } = this;
      let { list } = await selectModel.request({ codeNo });
      if (name === "refundType" && rpyNam === "深圳鹏友惠普商业保理有限公司") {
        list = list.filter(({ value }) => value !== "01");
      }
      this.updateValue(name, { options: list }, false);
    },
    // 贷后交易名称下拉列表
    async getArea(name, queryFlag = "01", areaCode = "") {
      const { areaModel, isInitCity, info } = this;
      const { city = "", province = "" } = info;
      if (!isInitCity && name === "city") {
        areaCode = areaCode || province;
      }
      if (name === "city" && !areaCode) {
        return false;
      }
      const { list } = await areaModel.request({ queryFlag, areaCode });
      // malGetAllCityAreaList
      const value = isInitCity ? "" : city;
      if (name === "city") {
        const resp = await malGetAllCityAreaList({ queryFlag, areaCode });
        let cityList = resp.result.reduce((pre, curr) => {
          const { itemname, itemno } = curr;
          pre.push({
            ...curr,
            label: itemname,
            value: itemno,
          });
          return pre;
        }, []);
        this.isInitCity = true;
        this.updateValue(name, { options: cityList, value }, false);
      } else {
        this.updateValue(name, { options: list }, false);
      }
    },
 
    // 提交成功后返回原列表页
    commitSuccess() {
      this.isShowDialog = false;
      this.$router.go(-1);
    },
    goBack() {
      this.isShowDialog = false;
      this.$router.go(-1);
    },
    ...mapMutations(["setRefundApplicationInfo"]),
  },
  computed: {
    // 表单值信息
    formValues() {
      const { model, formList } = this;
      return model ? model.getFormValues(formList) : {};
    },
    computedFormList() {
      const { formList, formValues, conf } = this;
      const { refundType } = formValues;
      const { edit } = conf;
      let tempList = [...formList];
 
      if (refundType !== "02" && edit === "Y") {
        // 01 自动退款, 02 人工转账退款
        tempList = tempList.filter(
          ({ name }) =>
            ![
              "accountingChannel",
              "settleAccounts",
              "settleAccountsName",
            ].includes(name)
        );
      }
 
      return tempList;
    },
    formRules() {
      // const { model, computedFormList } = this;
      // if (model) {
      //   console.log('formRules',model.getFormRules(computedFormList))
      //   return model.getFormRules(computedFormList);
      // }
      const rules = {
        name: [
          {
            required: true,
            message: "请输入退款收款账户户名",
            trigger: "blur",
          },
        ],
        accountNo: [
          {
            required: true,
            message: "请输入退款收款账户账号",
            trigger: "blur",
          },
        ],
        bankName: [
          {
            required: true,
            message: "请选择退款收款账户开户银行",
            trigger: "blur",
          },
        ],
        paymentAccountNo: [
          {
            required: true,
            message: "请输入退款收款账户开户分支行",
            trigger: "blur",
          },
        ],
        actualwaiveAmt: [
          { required: true, message: "请输入退款金额", trigger: "blur" },
          {
            pattern: /^[1-9]\d*(\.\d{1,2})?$/,
            message: "请输入数字值",
            trigger: "blur",
          },
        ],
      };
      return rules;
    },
  },
  watch: {
    $route() {
      if (this.claimFlowData[0].trxnBr) {
        this.init();
      }
    },
  },
};
</script>
<style lang="postcss" scoped>
.apply-info {
}
.apply-top-button {
  & >>> .el-button {
    margin-left: 20px;
  }
}
 
.qrcode-content {
  text-align: center;
  & .qrode-close {
    margin: 0;
    padding: 0;
    margin-bottom: 10px;
    & i {
      cursor: pointer;
      font-size: 18px;
    }
    /* text-align: right; */
  }
}
.tab-form-buttons {
  display: flex;
  justify-content: center;
  padding: 60px 0 30px 0;
  & p {
    margin: 0 40px 0 0;
  }
  & p:last-child {
    margin-right: 0;
  }
}
</style>