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
<template>
  <div class="apply-info">
    <CommForm
      :inline="true"
      :list="tempFormList"
      ref="basicForm"
      title="基本信息"
      @updateValue="updateValue"
      :formValues="formValues"
      :formRules="formRules"
      :formType="formType"
    >
      <!-- formType="info" -->
    </CommForm>
    <!-- <div class="tab-form-buttons" v-if="isShowFooterBtn">
      <p>
        <el-button class="comm-button" @click="$router.go(-1)">返回</el-button>
      </p>
      <p>
        <el-button class="comm-button" @click="resetForm">重置</el-button>
      </p>
      <p>
        <el-button class="comm-button" @click="checkData">核对</el-button>
      </p>
      <p>
        <el-button class="comm-button" type="primary" @click="submit" :disabled="isCheck">提交</el-button>
      </p>
    </div>-->
    <Dialog
      v-model="isShowDialog"
      icon="succ"
      iconText="提交成功"
      :buttons="[{text: '确定', type: 'primary'}]"
      @handleClick="commitSuccess"
    ></Dialog>
  </div>
</template>
<script>
import { mapMutations } from 'vuex'
import CommForm from '@/components/CommForm'
import Dialog from '@/components/Dialog'
import voucherDetailCheck from '@/controller/voucherDetailCheck' // 核对
import voucherDetailSubmit from '@/controller/voucherDetailSubmit' // 提交
import voucherDetailDetails from '@/controller/voucherDetailDetails' // 详情
import voucherDetailDelete from '@/controller/voucherDetailDelete' // 详情
// 下拉options
import queryCodeValueList from '@/controller/queryCodeValueList' // 公共下拉列表接口
import queryCodeObject from '@/controller/queryCodeObject' // 公共下拉列表接口
 
export default {
  components: {
    CommForm,
    Dialog
  },
  props: {
    conf: {
      type: Object,
      default: () => ({})
    }
  },
  data() {
    return {
      serialNo: '',
      info: {},
      query: {},
      formList: [],
      model: null,
      submitModel: null,
      detailsModel: null,
      deleteModel: null,
      isShowDialog: false,
      isCheck: true,
      formInfoFilterPay: [
        // 支付通道回款表单需要被过滤的字段
        '收款账户账号',
        '收款账户户名',
        '放款账户账号',
        '放款账户户名'
      ],
      formInfoFilterCusDev: [
        // 客户线下转账&开发商贴息转账表单信息需要被过滤的字段
        '支付公司名称',
        '商户号',
        '放款账户账号',
        '放款账户户名'
      ],
      formInfoFilterLoan: [
        // 放款表单信息需要被过滤的字段
        '支付公司名称',
        '商户号',
        '收款账户账号',
        '收款账户户名'
      ],
      formInfoFilterBaisc: [
        // 基础字段
        '支付公司名称',
        '商户号',
        '收款账户账号',
        '收款账户户名',
        '放款账户账号',
        '放款账户户名'
      ]
    }
  },
  created() {
    this.init()
  },
  methods: {
    init() {
      let { query } = this.$route
      this.query = query
      // console.log(query)
      query = {
        ...query,
        serialNo: ''
      }
      // console.log(query)
      let model = voucherDetailCheck(query)
      this.model = model
      // this.model = queryCustomerInfoChange()
      this.checkModel = voucherDetailCheck()
      this.submitModel = voucherDetailSubmit()
      this.detailsModel = voucherDetailDetails()
      this.deleteModel = voucherDetailDelete()
      this.getDetail()
      this.setSelectOptions()
    },
    async getDetail() {
      const { query, model, detailsModel } = this
      const { command, serialNo } = query
      if (serialNo) {
        const info = await detailsModel.request({
          serialNo
        })
        info.checkType = info.checkTypeName
        this.formList = model.getFormList(info)
      } else {
        this.formList = model.getFormList(command)
      }
    },
    async setSelectOptions() {
      const { formList } = this
      // formList.forEach(({ name }) => {
      formList.forEach(item => {
        if (item.name === 'checkType') {
          this.queryCodeValueList(item.name, { codeNo: 'VoucherType' })
        }
        // 支付通道回款表单信息-支付公司名称
        // console.log(item.name)
        if (item.label === '支付公司名称' && item.type === 'select') {
          this.queryCodeObject(
            item.name,
            { codeno: 'incomeAccountType' },
            item.label
          )
        }
        if (item.label === '放款账户账号' && item.type === 'select') {
          // if ( item.label === '放款账户账号' && item.type === 'select' ) {
          this.queryCodeObjectIdent(
            item.name,
            {
              codeno: 'ContraryAccountType'
            },
            item.label
          )
        }
 
        if (item.label === '收款账户账号' && item.type === 'select') {
          this.queryCodeObjectIdent(
            item.name,
            {
              codeno: 'ContraryAccountType'
            },
            item.label
          )
        }
      })
    },
 
    // 获取select中options数据
    async queryCodeValueList(name, info = {}) {
      const tempModel = queryCodeValueList()
      const { list } = await tempModel.request(info)
      this.updateValue(name, { options: list })
    },
 
    // 获取select中options数据
    async queryCodeObject(name, info = {}, label) {
      const tempModel = queryCodeObject()
      const { list } = await tempModel.request(info)
      let listArray = []
      list.forEach(item => {
        let obj = {}
        obj.label = item.itemname
        obj.value = item.attribute4
        listArray.push(obj)
      })
      this.updateValue(name, { options: listArray }, label)
    },
 
    async queryCodeObjectIdent(name, info = {}, label) {
      const tempModel = queryCodeObject()
      const { list } = await tempModel.request(info)
      let listArray = []
      list.forEach(item => {
        let obj = {}
        obj.label = item.attribute1
        obj.value = item.attribute1
        obj.tempValue = item.attribute3
        listArray.push(obj)
      })
      this.updateValue(name, { options: listArray }, label)
    },
 
    // 重置表单 => 控制核对后的小类消失,基本信息可编辑
    async resetForm() {
      const { deleteModel, serialNo } = this
      if (serialNo) {
        await deleteModel.request({
          serialNo
        })
      }
      this.isCheck = true
      this.$emit('showCheck', true) // 按钮控制
      const { model } = this
      this.serialNo = ''
      this.setSerialNo(this.serialNo)
      this.setBasicInfo({})
      this.formList = model.getFormList()
      this.setSelectOptions()
    },
 
    // 核对 => 表单不可编辑,显示后面的小类信息
    // 测试用
    // async checkData() {
    //   this.isCheck = false
    //   this.serialNo = '201911051637502300597Y3M250000eb'
    //   this.$emit('showCheck', false)
    //   this.setSerialNo(this.serialNo)
    // },
 
    // 核对 => 表单不可编辑,显示后面的小类信息
    async checkData() {
      const { checkModel } = this
      // console.log(this.formList)
      const values = this.$refs.basicForm.validate()
      // console.log(values)
      // if (values) {
      //   try {
      //     const checkRes = await checkModel.request({
      //       ...values
      //     })
      //     const { serialNo } = checkRes
      //     this.serialNo = serialNo
      //     this.$emit('showCheck', false)
      //     this.setSerialNo(serialNo)
      //     this.setBasicInfo(checkRes)
      //     this.isCheck = false
      //   } catch (error) {
      //     this.$emit('showCheck', true)
      //     console.log(error)
      //   }
      // } else {
      //   this.$message.warning('当前页面有数据未输入!')
      // }
    },
    //  提交 => 初始不可点击/核对成功后科点击提交
    async submit() {
      const { submitModel, serialNo } = this
      await submitModel.request({
        serialNo
      })
      this.setSerialNo('')
      this.$emit('showCheck', true) // 按钮控制
      this.isShowDialog = true
    },
 
    // 提交成功后返回原列表页
    commitSuccess() {
      this.isShowDialog = false
      this.$router.go(-1)
    },
 
    //
    // setFormList() {
    //   const {
    //     formList,
    //     formInfoFilterPay,
    //     formInfoFilterCusDev,
    //     formInfoFilterLoan,
    //     formInfoFilterBaisc
    //   } = this
    //   const checkTypeIndex = formList.findIndex(
    //     item => item.name === 'checkType'
    //   )
    //   let dataList = null
    //   const { value } = formList[checkTypeIndex]
    //   if (value === 'TD') {
    //     dataList = formList.filter(
    //       ({ label }) => !formInfoFilterPay.includes(label)
    //     )
    //     this.queryCodeObject('institution', { codeno: 'incomeAccountType' }, '放款账户账号')
    //   } else if (value === 'KHZK' || value === 'KFSZK') {
    //     dataList = formList.filter(
    //       ({ label }) => !formInfoFilterCusDev.includes(label)
    //     )
    //   } else if (value === 'FK') {
    //     dataList = formList.filter(
    //       ({ label }) => !formInfoFilterLoan.includes(label)
    //     )
    //   } else {
    //     dataList = formList.filter(
    //       ({ label }) => !formInfoFilterBaisc.includes(label)
    //     )
    //   }
    //   // this.formList = dataList
    //   return dataList
    // },
    // 更新表单数据
    updateValue(index, info, labelName = '') {
      const { formList } = this
 
      // const { value } = formList[index]
      // console.log(index)
      if (isNaN(index)) {
        // index is name
        index = formList.findIndex(({ name }) => name === index)
        if (labelName) {
          index = formList.findIndex(({ label }) => label === labelName)
        }
      }
      if (!isNaN(index) && index > -1) {
        const preInfo = formList[index]
        this.$set(formList, index, { ...preInfo, ...info })
      }
 
      // 联动处理
      // console.log(index)
      // if (index === 3 && info.name === 'identifier') {
      //   const { options, value } = info
      //   // console.log(value)
      //   const institutionIndex = formList.findIndex(
      //     item => item.name === 'institution'
      //   )
      //   const targetIndex = options.findIndex(({ label }) => label === value)
      //   if (institutionIndex > -1) {
      //     if (value) {
      //       const { tempValue } = options[targetIndex]
      //       this.tempFormList[institutionIndex].value = tempValue
      //     } else {
      //       this.tempFormList[institutionIndex].value = ''
      //     }
      //   }
      // }
    },
    ...mapMutations(['setSerialNo', 'setBasicInfo'])
  },
  computed: {
    // 表单值信息
    formValues() {
      const { model, formList } = this
      if (model) {
        return model.getFormValues(formList)
      }
      return {}
    },
    formRules() {
      const { model, formList } = this
      if (model) {
        return model.getFormRules(formList)
      }
      return {}
    },
    tempFormList() {
      let {
        isCheck,
        formList,
        formInfoFilterPay,
        formInfoFilterCusDev,
        formInfoFilterLoan,
        formInfoFilterBaisc
      } = this
      let tempList = [...formList]
      const checkTypeIndex = formList.findIndex(
        item => item.name === 'checkType'
      )
      if (isCheck) {
        // const dataList = this.setFormList()
        if (checkTypeIndex > -1) {
          const { value } = formList[checkTypeIndex]
          if (value === 'TD') {
            tempList.map(item => {
              if (formInfoFilterPay.includes(item.label)) {
                item.value = ''
              }           
            })
            tempList = tempList.filter(
              ({ label }) => !formInfoFilterPay.includes(label)
            )
          } else if (value === 'KHZK' || value === 'KFSZK') {
            tempList.map(item => {
              if (formInfoFilterCusDev.includes(item.label)) {
                item.value = ''
              }           
            })
            tempList = tempList.filter(
              ({ label }) => !formInfoFilterCusDev.includes(label)
            )
          } else if (value === 'FK') {
            tempList.map(item => {
              if (formInfoFilterLoan.includes(item.label)) {
                item.value = ''
              }           
            })
            tempList = tempList.filter(
              ({ label }) => !formInfoFilterLoan.includes(label)
            )
            console.log(tempList)
          } else {
            tempList.map(item => {
              if (formInfoFilterBaisc.includes(item.label)) {
                item.value = ''
              }           
            })
            tempList = tempList.filter(
              ({ label }) => !formInfoFilterBaisc.includes(label)
            )
          }
        }
        return tempList
      } else {
        tempList.map(item => {
          if (item.type === 'select' || item.type === 'daterange') {
            item.attrs = [...item.attrs, 'disabled']
          } else {
            if (item.attrs) {
              item.attrs =
                item.attrs.indexOf('readonly') > -1
                  ? item.attrs
                  : [...item.attrs, 'readonly']
            } else {
              item.attrs = ['readonly']
            }
          }
          item.rules = []
        })
        return tempList
      }
    },
    formType() {
      const { query } = this.$route
      const { isApplyPhase } = query
      if (isApplyPhase === 2) {
        return 'text'
      } else {
        return ''
      }
    },
    isShowFooterBtn() {
      const { isApplyPhase } = this.$route.query
      if (isApplyPhase === 2) {
        return false
      } else {
        return true
      }
    }
  },
  watch: {
    $route() {
      const { transLogSerialno } = this.$route.query
      if (transLogSerialno) {
        this.init()
      }
    }
    // isCheck(val) {
    //   const { formList } = this
    //   if (!val) {
    //     formList.map(item => {
    //       if (item.attrs) {
    //         item.attrs =
    //           item.attrs.indexOf('readonly') > -1
    //             ? item.attrs
    //             : [...item.attrs, 'readonly']
    //       } else {
    //         item.attrs = ['readonly']
    //       }
    //     })
    //   }
    // }
  }
}
</script>
<style lang="postcss" scoped>
.apply-info {
}
.tab-form-buttons {
  display: flex;
  justify-content: center;
  padding: 20px 0 30px 0;
  & p {
    margin: 0 40px 0 0;
  }
  & p:last-child {
    margin-right: 0;
  }
}
</style>