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
<template>
  <div class="product">
    <div v-for="(item,index) in moneyBackArr" :key="index">
      <div class="_block">
        <p class="title">
          <span></span>
          财务信息
        </p>
        <el-form :model="moneyBackForm[index]" :rules="rules" ref="moneyBackForm" label-width="165px" size="small" inline>
          <el-form-item
            label="应回款金额"
            v-if="item.receivableMessageRes.paymentAmt.visible"
          >
            <el-input
              v-model="moneyBackForm[index].receivableMessageRes.paymentAmt"
              disabled
            ></el-input>
          </el-form-item>
          <el-form-item
            label="已回款金额"
            v-if="item.receivableMessageRes.actualPayAmtSum.visible"
          >
            <el-input
              v-model="moneyBackForm[index].receivableMessageRes.actualPayAmtSum"
              disabled
            ></el-input>
          </el-form-item>
          <el-form-item
            label="仍需回款金额"
            v-if="item.receivableMessageRes.surplusTotalAmt.visible"
          >
            <el-input
              v-model="moneyBackForm[index].receivableMessageRes.surplusTotalAmt"
              disabled
            ></el-input>
          </el-form-item>
        </el-form>
      </div>
      <ClaimedFunds 
        :claimedFunds="receivableData"
        operationType='0'
      >
      </ClaimedFunds>
      <WaitFunds 
        v-if="isclaimed == '0'"
        :surplusTotalAmt='moneyBackForm[index].receivableMessageRes.stillbackpaysum'
        :isEntAdvanceMoney='moneyBackForm[index].receivableMessageRes.isEntAdvanceMoney'
        :entAdvanceMoneyStatus='moneyBackForm[index].receivableMessageRes.entAdvanceMoneyStatus'
        v-on:sendClaimResult='sendClaimResult'
        v-on:sendLoanInfo='sendLoanInfo'
        operationType='0'
      ></WaitFunds>
    </div>
    <div class="fixedBtn">
      <el-button
        size="medium"
        plain
        @click="refuse"
        v-if="applyInfo.phaseNo=='0203'"
      >驳回/拒绝</el-button>
      <el-button
        size="medium"
        plain
        @click="prevStep"
      >上一页</el-button>
      <el-button
        size="medium"
        type="primary"
        @click="nextPage()"
      >下一步</el-button>
    </div>
  </div>
</template>
<script>
import {
  qryReceivableInfo,
  getDictionaryList,
  saveReceivableInfo
} from '@api/product'
import WaitFunds from '../../../components/WaitFunds'
import ClaimedFunds from '../../../components/ClaimedFunds'
import common from "@/utils/common";
export default {
  data () {
    return {
      applyInfo:this.$store.state.product.applyInfo,
      applyMenu: this.$store.state.product.applyMenu,
      moneyBackForm:[],
      moneyBackArr:[],
      receivableData:[],
      initialArr:[],
      rules:{},
      YesNo:[],
      isclaimed: '',
    }
  },
  async created () {
    const result = await this.qryReceivableInfo()
    this.qryReceivableData(result)
    this.YesNo = await this.qryDictionaryList('YesNo')
  },
  components: {
    WaitFunds,
    ClaimedFunds
  },
  methods: {
    sendLoanInfo(data){
      for (const key in data) {
        // 格式化金额
        if (
          key == "paymentAmt" ||
          key == "actualPayAmtSum" ||
          key == "surplusTotalAmt"
        ) {
          data[key] = this.formatMoney(data[key]);
        }
        // 流水认领成功后更新部分字段
        if (
          key == "paymentAmt" ||
          key == "actualPayAmtSum" ||
          key == "surplusTotalAmt" 
        ) {
          this.moneyBackForm[0]['receivableMessageRes'][key] = data[key]
          this.initialArr[0]['receivableMessageRes'][key] = data[key]
        }
      }
    },
    // 接受子组件的传值并且更新已认领资金列表
    async sendClaimResult(){
      const result = await this.qryReceivableInfo()
      this.isclaimed = result.isclaimed.value
      this.getReceivableData(result.claimBankWaterMessageRes.receivableManage)
      for (const key in result) {
        if(key == 'receivableMessageRes'){
          for (const child in result[key]) {
            // 格式化金额
            if (
              child == "paymentAmt" ||
              child == "actualPayAmtSum" ||
              child == "surplusTotalAmt" 
            ) {
              result[key][child].value = this.formatMoney(
                result[key][child].value
              );
            }
            // 流水认领成功后更新部分字段
            if (
              child == "paymentAmt" ||
              child == "actualPayAmtSum" ||
              child == "surplusTotalAmt"
            ) {
              this.moneyBackForm[0][key][child] = result[key][child].value
              this.initialArr[0][key][child] = result[key][child].value
            }
          }
        }
      }
    },
    // 对已认领资金数据进行处理
    getReceivableData(array){
      this.receivableData = []
      array.forEach(val => {
        const obj = {}
        for (const key in val) {
          if(key == 'receivabletype'){
            obj[key] = val[key].valueDesc
          }else{
            obj[key] = val[key].value
          }
        }
        this.receivableData.push(obj)
      });
    },
    // 还款信息查询
    qryReceivableInfo(){
      return new Promise(resolve=>{
        qryReceivableInfo({applySerialno:this.applyInfo.serialNo,receivableType:'10'}).then(res=>{
          resolve(res.result)
        })
      })
    },
    // 对数据进行处理封装
    qryReceivableData(result){
      this.isclaimed = result.isclaimed.value
      this.getReceivableData(result.claimBankWaterMessageRes.receivableManage)
      this.moneyBackArr = [result]
      this.moneyBackForm = []
      this.initialArr = []
      this.moneyBackArr.forEach((val,index) => {
        // 格式化数据
        const obj = {}
        for (const key in val) {
          if(key == 'receivableMessageRes'){
            obj[key] = {};
            for (const child in val[key]) {
              // 格式化金额
              if (
                child == "paymentAmt" ||
                child == "actualPayAmtSum" ||
                child == "surplusTotalAmt"
              ) {
                val[key][child].value = this.formatMoney(
                  val[key][child].value
                );
              }
              this.rules["receivableMessageRes." + child] = [];
              if (val[key][child].required) {
                this.rules["receivableMessageRes." + child].push({
                  required: true,
                  message: `请输入${val[key][child].filedDescription}`,
                  trigger: "change"
                });
              }
              obj[key][child] = val[key][child].value;
            }
          }
        }
        this.moneyBackForm.push(obj)
        this.initialArr.push(Object.assign({},obj));
      });
    },
    // 金额格式化
    formatMoney(value) {
      if (value) {
        value =
          parseFloat((value + "").replace(/[^\d\.-]/g, "")).toFixed(2) + "";
        if (value == "NaN") return;
        let l = value
          .split(".")[0]
          .split("")
          .reverse();
        let r = value.split(".")[1];
        let t = "";
        for (let i = 0; i < l.length; i++) {
          t += l[i] + ((i + 1) % 3 === 0 && i + 1 !== l.length ? "," : "");
        }
        return (
          t
            .split("")
            .reverse()
            .join("") +
          "." +
          r
        );
      }
    },
    // 字典
    qryDictionaryList(code) {
      return new Promise(resolve => {
        getDictionaryList({
          codeNo: code
        }).then(res => {
          resolve(res.result);
        });
      });
    },
    // 驳回/拒绝
    refuse() {
      this.$parent._data.showCredit = true;
      this.applyMenu.forEach((val, index) => {
        if (val.tabname == "回款信息") {
          common.tabInfo(
            this.applyMenu[index + 1].tabname,
            this.applyInfo.flowno,
            this
          );
        }
      });
    },
    // 上一页
    prevStep(){
      this.applyMenu.forEach((val, index) => {
        if (val.tabname == "回款信息") {
          common.tabInfo(this.applyMenu[index - 1].tabname,this.applyInfo.flowno,this);
        }
      });
    },
    // 下一步校验必填
    nextPage(){
      if(!common.validateForm(this.$refs.moneyBackForm).flag)return;
      // 调用父组件的查询左侧tab的方法
      this.$parent.updateApplyTabTree('回款信息');
    },
  },
  // 路由离开需要校验比较数据是否发生变化
  beforeRouteLeave(to, from, next) {
    for (let i = 0; i < this.moneyBackForm.length; i++) {
      for (const key in this.moneyBackForm[i]) {
        if (this.initialArr[i].hasOwnProperty(key)) {
          if (this.moneyBackForm[i][key] != this.initialArr[i][key]) {
            // 页面有数据未保存
            common.comfirm("提示","当前页面有数据未保存,是否放弃保存?", ()=> {
              next();
            })
            return;
          }
        }
      }
    }
    next();
  }
}
</script>