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
<template>
  <div class="apply-info">
    <CommForm
      :inline="true"
      :list="formList"
      @updateValue="updateValue"
      ref="applyForm"
      :formValues="formValues"
      :formRules="formRules"
      formType="info"
      title="申请信息"
    ></CommForm>
    <Dialog
      v-model="isShowDialog"
      icon="succ"
      iconText="提交成功"
      :buttons="[{text: '确定', type: 'primary'}]"
      @handleClick="commitSuccess"
    ></Dialog>
  </div>
</template>
<script>
// 中航信托线下转账还款通知-申请信息查询
import { mapActions, mapState, mapMutations } from 'vuex'
import CommForm from '@/components/CommForm'
import Dialog from '@/components/Dialog'
 
// import queryCodeValueList from '@/controller/queryCodeValueList'
import queryCodeValueList from '@/controller/queryCodeValueList'
 
// import queryZhPaymentNoticeInfo from '@/controller/queryZhPaymentNoticeInfo'
// import queryZhApplyHistoryDetail from '@/controller/queryZhApplyHistoryDetail'
import payMentZhTrustSubmit from '@/controller/payMentZhTrustSubmit'
 
export default {
  components: {
    CommForm,
    Dialog
  },
  props: {
    conf: {
      type: Object,
      default: () => ({})
    }
  },
  data() {
    return {
      query: {},
      formList: [],
      codeUrl: '',
      detailModel: null,
      model: null,
      selectModel: null,
      codeModel: null,
      bankModel: null,
      moneyModel: null,
      isShowDialog: false,
      visible: false,
      timmer: null
    }
  },
  created() {
    this.init()
  },
  methods: {
    init() {
      const { query } = this.$route
      this.query = query
      this.paymentMethodModel = queryCodeValueList()
      this.model = payMentZhTrustSubmit()
      this.getDetail()
    },
    getDetail() {
      const { query } = this
      const {
        serialNo,
        pageId,
        isApplyPhase,
        payNoticeSerialNo,
        useDetail
      } = query
      this.queryZhPaymentInfo({
        pageId,
        isApplyPhase,
        loanSerialNo: serialNo,
        payNoticeSerialNo,
        useDetail
      })
    },
 
    setForm() {
      const { model, conf, info } = this
      const formList = model.getFormList({ applyAmount: info.crtAmt, ...info })
      const { edit } = conf
      if (edit === 'Y') {
        this.formList = formList
        this.setSelectOptions()
      } else {
        this.formList = formList
          .filter(
            ({ name }) =>
              !['paymentDate', 'termid', 'waivePayinterestAmta5'].includes(name)
          )
          .map(item => {
            const { value, descName } = item
            return {
              ...item,
              // type: 'text',
              value: descName ? info[descName] : value,
              rules: []
            }
          })
      }
    },
 
    updateForm() {
      const { formList, termInitData } = this
      Object.keys(termInitData).forEach(key => {
        const index = formList.findIndex(({ name }) => name === key)
        if (index > -1) {
          this.$set(formList, index, {
            ...formList[index],
            value: termInitData[key]
          })
          this.updateAmount()
        }
      })
    },
 
    updateAmount() {
      const { formList, formValues, termInitData } = this
      const amountIndex = formList.findIndex(
        ({ name }) => name === 'paymentAmount'
      )
      const mixValues = { ...formValues, ...termInitData }
      let amount = [
        'payPrincipalAmt',
        'payInterestAmt',
        'payInterestAmtA4',
        'payInterestAmtA5'
      ].reduce((pre, curr) => {
        return pre + (Number(mixValues[curr]) || 0)
      }, 0)
 
      amount =
        amount -
        (Number(mixValues['waivePayInterestAmtA4']) || 0) -
        (Number(mixValues['waivePayinterestAmta5']) || 0)
 
      this.$set(formList, amountIndex, {
        ...formList[amountIndex],
        value: isNaN(amount) ? '' : amount.toFixed(2)
      })
    },
 
    // 更新表单数据
    updateValue(index, info, flg = true) {
      const { formList, formValues, info: detail } = this
      if (isNaN(index)) {
        // index is name
        index = formList.findIndex(({ name }) => name === index)
      }
 
      if (!isNaN(index) && index > -1) {
        const preInfo = formList[index]
        const detailDate = detail.inputDate ? detail.inputDate.split(' ')[0] : ''
        if (
          preInfo.name === 'waivePayinterestAmta5' &&
          Number(info.value) > Number(formValues.payInterestAmtA5)
        ) {
          this.$message.warning('减免违约金不能大于应还违约金')
          return false
        }
        if (
          preInfo.name === 'paymentDate' &&
          detailDate &&
          new Date(info.value).getTime() <=
            new Date(detailDate).getTime()
        ) {
          this.$message.warning('还款日期<=还款计划当前期的还款日期')
          // this.$message.warning('未逾期贷款不支持部分还款,必须整期结清')
          // return false
        }
 
        this.$set(formList, index, { ...preInfo, ...info })
 
        if (preInfo.name === 'termid' && info.value) {
          this.setTermid(info.value)
          this.updateInfo(info.value)
        }
        this.updateAmount()
      }
    },
 
    updateInfo(termid) {
      const { query } = this
      const { serialNo, customerId } = query
      if (!termid) {
        return false
      }
      this.paymentZhTermInitData({
        customerId,
        loanSerialNo: serialNo
      })
    },
 
    setFetch(info) {
      const { timmer } = this
      clearTimeout(timmer)
      this.timmer = setTimeout(() => {
        this.getMoneyInfo(info)
      }, 500)
    },
 
    // 表单按钮事件处理
    async submit() {
      const { model, query, info, conf } = this
      const {
        serialNo,
        transCode,
        objectNo,
        objectType,
        paymentSerialNo
      } = query
      const { edit } = conf
      if (edit !== 'Y') {
        return false
      }
 
      const values = this.$refs.applyForm.validate()
 
      if (values) {
        // const loading = this.$loading({
        //   fullscreen: true
        // })
        try {
          await model.request({
            ...info,
            imagObjectNo: objectNo,
            imagObjectType: objectType,
            loanSerialNo: serialNo,
            paymentSerialNo,
            transCode,
            ...values
          })
          // loading.close()
          this.getDetail()
          this.isShowDialog = true
        } catch (e) {
          // loading.close()
        }
      } else {
        this.$message.warning('当前页面存在必填项未录入或数据录入错误,请检查!')
      }
    },
 
    // 设置表单下拉菜单
    setSelectOptions() {
      const { formList } = this
      formList.forEach(({ name, attrs = [] }) => {
        if (
          attrs.some(
            item =>
              (typeof item === 'object' && item.readonly) || item === 'readonly'
          )
        ) {
          return false
        }
        if (name === 'termid') {
          this.queryCodeValueList(name, 'ZHTermType')
        }
      })
    },
 
    // 贷后交易名称下拉列表
    async queryCodeValueList(name, codeNo) {
      const { paymentMethodModel } = this
      const { list } = await paymentMethodModel.request({
        codeNo
      })
      this.updateValue(name, { options: list })
    },
 
    // 提交成功后返回原列表页
    commitSuccess() {
      this.isShowDialog = false
      this.$router.go(-1)
    },
    ...mapMutations(['setTermid']),
    ...mapActions(['queryZhPaymentInfo', 'paymentZhTermInitData'])
  },
  computed: {
    // 表单值信息
    formValues() {
      const { model, formList } = this
      return model ? model.getFormValues(formList) : {}
    },
    formRules() {
      const { model, formList } = this
      if (model) {
        return model.getFormRules(formList)
      }
      return {}
    },
    ...mapState({
      info: state => state.tabsModule.paymentInfo,
      termInitData: state => state.tabsModule.termInitData
    })
  },
  watch: {
    $route() {
      const { serialNo } = this.$route.query
      if (serialNo) {
        this.init()
      }
    },
    info() {
      this.setForm()
    },
    termInitData() {
      this.updateForm()
    }
  }
}
</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; */
  }
}
</style>