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
<template>
  <div class="AddApply" v-loading.fullscreen.lock="loading" element-loading-background="transparent">
    <el-dialog :visible.sync="applyVisible" :title="title" center :close-on-click-modal='false' @close="closeDialog('form')">
      <el-form :model="form" :rules="rules" ref="form" label-width="100px" inline size="small">
        <el-form-item label="产品类型" prop="productTypeNo">
          <el-select v-model="form.productTypeNo" filterable placeholder="请选择" @change="selectProductTypeNo">
            <el-option
              v-for="(item,index) in productTypeList"
              :key="index"
              :label="item.productTypeName"
              :value="item.productTypeNo">
            </el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="产品名称" prop="productid">
          <el-select v-model="form.productid" filterable placeholder="请选择" @change="productidChange" >
            <el-option
              v-for="(item,index) in productList"
              :key="index"
              :label="item.productName"
              :value="item.productCode">
            </el-option>
          </el-select>
        </el-form-item>
        <!-- 预审批和贷款申请的业务类型要做区别 -->
        <el-form-item label="业务类型" v-if="title=='预审批申请信息'">
          <el-input v-model="form.occurtype" readonly v-show="false"></el-input>
          <el-input v-model="form.occurtypeDesc" readonly></el-input>
        </el-form-item>
        <el-form-item label="业务类型" prop="occurtype" v-else>
          <el-select v-model="form.occurtype" @change="selOccurtype" filterable placeholder="请选择">
            <el-option
              v-for="(item,index) in businessTypeList"
              :key="index"
              :label="item.itemname"
              :value="item.itemno"
              :disabled="item.disabled">
            </el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="新增方式" prop="addType" v-show="isTYCJ">
          <el-select v-model="form.addType" disabled='disabled' placeholder="请选择">
            <el-option label="新增" value="00"></el-option>
            <el-option label="复制" value="01"></el-option>
          </el-select>
        </el-form-item>
        <!-- 佣金贷产品才有借款人类型 -->
        <el-form-item label="借款人类型" prop="borrowerType" v-if="isCFD || isTYCJ" :rules="{
          required: true, message: '请选择借款人类型', trigger: 'change'
        }" >
          <el-select v-model="form.borrowerType" @change="selProject($event,'borrowerType')" filterable placeholder="请选择">
            <el-option
              v-for="(item,index) in borrowerTypeList"
              :key="index"
              :label="item.itemname"
              :value="item.itemno">
            </el-option>
          </el-select>
        </el-form-item>
 
        <!-- 判断如果产品类型是保理,写死证件类型为统一社会信用证件类型并且不可编辑 :disabled="form.productTypeNo == 525"-->
        <el-form-item label="证件类型" prop="certtype">
          <el-select v-model="form.certtype" filterable placeholder="请选择" @change="certtypeChange">
            <el-option
              v-for="(item,index) in certtypeList"
              :key="index"
              :label="item.itemname"
              :value="item.itemno"
            >
            </el-option>
          </el-select>
        </el-form-item> 
         <el-form-item label="客户名称" prop="customername">
          <el-autocomplete
            style="width:100%"
            clearable
            v-model="form.customername"
            :fetch-suggestions="remoteMethod"
            placeholder="请输入内容"
            @select="setCertid"
          ></el-autocomplete>
          <!-- <el-select
            style="width:100%"
            v-model="form.customername"
            filterable
            remote
            allow-create
            :loading='lodingy'
            @change="setCertid"
            @visible-change="editSelect"
            value-key="creditCode"
            clearable
            default-first-option
            :remote-method="remoteMethod"
            placeholder="请选择过滤内容">
            <el-option
              v-for="item in options"
              :key="item.creditCode"
              :label="item.name"
              :value="item">
            </el-option>
        </el-select> -->
          <!-- <el-input></el-input> -->
        </el-form-item>
        <el-form-item label="证件号码" prop="certid">
          <el-input v-model="form.certid" @input="certidChange"></el-input>
        </el-form-item>
       
        <!-- 易贷产品才有申请类型 -->
        <el-form-item label="申请类型" prop="applytype" v-if="form.productTypeNo==535">
          <el-select v-model="form.applytype" :disabled="title=='预审批申请信息'" filterable placeholder="请选择">
            <el-option
              v-for="(item,index) in applytypeList"
              :key="index"
              :label="item.itemname"
              :value="item.itemno"
              :disabled="item.disabled">
            </el-option>
          </el-select>
        </el-form-item>
        <!-- 佣金贷产品才有项目名称 -->
        <!-- <el-form-item label="项目名称" prop="projectSerialno" v-if="form.productid=='CFD'">
          <el-select v-model="form.projectSerialno" @change="selProject" filterable placeholder="请选择">
            <el-option
              v-for="(item,index) in projectList"
              :key="index"
              :label="item.projectname"
              :value="item.serialno">
            </el-option>
          </el-select>
        </el-form-item> -->
        <!-- 佣金贷产品才有核心企业 -->
        <el-form-item label="核心企业" prop="enterpriseNo" v-if="isCFD" :rules="{
          required: true, message: '请选择核心企业', trigger: 'change'
        }">
          <el-select v-model="form.enterpriseNo" @change="selProject($event,'enterpriseNo')" filterable placeholder="请选择">
            <el-option
              v-for="(item,index) in enpAdmitInList"
              :key="index"
              :label="item.enterprisename"
              :value="item.serialno">
            </el-option>
          </el-select>
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="confirm('form')">确定</el-button>
      </div>
    </el-dialog>
    <el-dialog :visible.sync="dialogTableVisible" title="申请编号选择" center :close-on-click-modal='false'>
      <el-table 
        stripe
        :data="applyData" 
        :header-cell-style="{background:'#f5f5f5',color:'#222222'}" 
        highlight-current-row 
        @current-change="getCurrentRow"
        max-height="540"
      >
        <el-table-column type="index" width="40" label=" "></el-table-column>
        <el-table-column property="serialno" label="申请编号" width="160"></el-table-column>
        <el-table-column property="customername" label="客户名称" width="120"></el-table-column>
        <el-table-column property="productname" label="产品名称" width="120"></el-table-column>
        <el-table-column property="projectname" label="项目名称" width="160"></el-table-column>
        <el-table-column property="operateusername" label="报单人" width="150"></el-table-column>
        <el-table-column property="inputdate" label="报单日期" width="150"></el-table-column>
      </el-table>
      <div slot="footer" class="dialog-footer">
        <el-button plain @click="back">返回</el-button>
        <el-button type="primary" @click="submit(form)">确定</el-button>
      </div>
    </el-dialog>
  </div>
</template>
<script>
import { 
  qryProdTypeList,
  qryProdList,
  getDictionaryList,
  qryCopiedApplyList,
  savePreApplyLoan,
  saveApplyLoan,
  listCommissionProjects,
  qryEnterpriseList,
  findDataByNameOrCodes,
  getOccurTypeList
} from '@/api/product'
 
import { setStorage,getStorage } from '@/utils/storage'
import common from "@/utils/common";
export default {
  props:['title','visible'],
  data () {
    return {
      form:{
        addType:'00',
        occurtype:'',
        applytype:'',
        productTypeNo: '',
        certtype: '',
      },
      lodingy:false,
      options:[],
      allowCreate:true,
      dialogTableVisible:false,
      applyData:[],
      productTypeList:[],
      productList:[],
      certtypeList:[],
      applytypeList:[],
      businessTypeList:[],
      projectList:[],
      enpAdmitInList: [],
      borrowerTypeList: [],
      rules:{
        productTypeNo:[{ required: true, message: '请输入产品类型', trigger: 'change' }],
        productid:[{ required: true, message: '请输入产品名称', trigger: 'change' }],
        addType:[{ required: true, message: '请输入新增方式', trigger: 'change' }],
        customername:[
          { required: true, message: '请输入客户名称', trigger: 'change' },
          { validator: (rule, value, callback) => {
            if(!(/^[\u4e00-\u9fa5/()()]{2,50}$/.test(value))&&this.form.productTypeNo != '525'){
              callback(new Error('格式不正确'));
            }else{
              callback()
            }
          }, trigger: 'change' }
        ],
        certtype:[{ required: true, message: '请输入证件类型', trigger: 'change' }],
        certid:[
          { required: true, message: '请输入证件号码', trigger: 'change' },
          { validator: (rule, value, callback) => {
            if (value) {
              common.checkCertid(this.form.certtype,value,callback)
            }
          }, trigger: 'change' }
        ],
        occurtype:[{ required: true, message: '请输入业务类型', trigger: 'change' }],
        applytype:[{ required: true, message: '请输入申请类型', trigger: 'change' }],
      },
      loading:false,
      isCopy:false
    }
  },
  computed: {
    applyVisible:{
      get(){
        return this.visible
      },
      set(){}
    },
    isCFD() {
      // 二手车例外
      return (this.form.productid && this.form.productid.slice(0, 3) == 'CFD' || this.form.productid && this.form.productid.slice(0, 3) == 'OFF-TYCJ') && this.form.productid !='CFD_ESCKRD'
    },
    isTYCJ() {
      // 二手车例外
      return (this.form.productid && this.form.productid.indexOf('OFF_') > -1 ||  this.form.productid && this.form.productid.indexOf('OUT_JGKD') > -1) && this.form.productid !='CFD_ESCKRD'
    }
  },
  async created () {
    // 预审批申请新增业务类型默认是授信,并且不可编辑
    if(this.title == '预审批申请信息'){
      this.form.occurtype = '01'
      this.form.occurtypeDesc = '授信'
    }
    this.getProdTypeList()
    // 产品列表
    this.getProdList('')
    //证件类型
    this.certtypeList = await this.qryDictionaryList('CertType');
    // 业务类型
    // this.businessTypeList = await this.qryDictionaryList('BuildingBusinessTypeCredit');
    // 借款人类型
    this.borrowerTypeList = await this.qryDictionaryList('BorrowerType');
    // 企业核心
    // this.qryEnterpriseList()
    // 项目名称
    // this.listCommissionProjects()
 
 
  },
  methods: {
    // 设置证件号码值
    setCertid(e){
      console.log(e)
      if(e.creditCode){
        this.$set(this.form, 'certid', e.creditCode)
        this.$set(this.form, 'customername', e.name)
        this.qryEnterpriseList()
      }
    },
    editSelect(e){
        if(!e){
          this.remoteMethod()
        }
      },
    // 远程搜索枚举值
   async remoteMethod(columnValue='',cb){
      this.lodingy=true
      var results = [];
      if(!columnValue){
        this.options=[]
        this.lodingy=false
        return
      }
     await findDataByNameOrCodes({code:columnValue}).then(res=>{
        if(res.result){
          const list = res.result.map(res=>{
            res.value = res.name
            res.id = res.creditCode
            return  res
          })
          cb(list)
        }
        
      }).catch(err=>{
          this.options=[]
          this.lodingy=false
      })
    },
    //证件类型修改
    certtypeChange(val) {
      this.form.certtype = val
      this.$forceUpdate()
    },
    //借款人类型,核心企业取值变更
    selProject(val, type){
      const { projectList } = this
      console.log(type)
      if(type == 'borrowerType') {
        this.form.borrowerType = val
        //借款人类型 01为企业,证件类型改为统一社会信用代码
        if (val == '01') {
          this.form.certtype = '05'
        }
        //02为个人,证件类型改为身份证
        else if (val == '02') {
          this.form.certtype = '01'
        }
      }else if( type == 'enterpriseNo') {
        this.form.enterpriseNo = val
      }
      this.$forceUpdate()
      for (let i = 0; i < projectList.length; i++) {
        if(projectList[i].serialno == val){
          this.form.projectName = projectList[i].projectname
          break
        }        
      }
    },
    async listCommissionProjects(){
      const projectList = await listCommissionProjects()
      this.projectList = projectList.result
    },
    async qryEnterpriseList() {
 
      let {occurtype, certtype, certid, productid} = this.form
      if(!occurtype || !certtype || !certid || !productid) {
        return
      }
      const enpAdmitInList = await qryEnterpriseList({
        occurType: occurtype,
        certType: certtype,
        certId: certid,
        productId: productid
      })
      this.enpAdmitInList = enpAdmitInList.result
    },
    selOccurtype(val){
      // 当产品类型为对公类新增无论业务类型选择哪个新增方式都是固定新增
      if(this.form.productTypeNo==530){
        this.form.addType = '00'
        this.isCopy = true
      }else{
        // 当业务类型为分期或者取现时新增方式固定为新增
        if((val=='02'||val=='03')&&this.form.productTypeNo!=521){
          this.form.addType = '00'
          this.isCopy = true
        }else{
          this.isCopy = false
        }
      }
 
      this.qryEnterpriseList()
    },
    qryDictionaryList(code){
      return new Promise(resolve=>{
        getDictionaryList({
          codeNo: code
        }).then(res=>{
          resolve(res.result)
        })
      })
    },
    getCurrentRow(row){
      this.form.copiedSerialNo = row.serialno
    },
    // 查询产品类型
    getProdTypeList(){
      qryProdTypeList({}).then(res=>{
        this.productTypeList = res.result 
        this.$nextTick(() => {
          this.form.productTypeNo = '525'
          this.selectProductTypeNo(525)
        })
      })
    },
    // 监听产品类型获取产品名称下拉
    async selectProductTypeNo(val){
      // 判断如果是抵押贷,就添加申请类型
      if(val==535){
        //申请类型
        this.applytypeList = await this.qryDictionaryList('applyCode');
        // 如果是贷款申请,不能选择首次借款
        if(this.title == '贷款申请信息'){
          this.applytypeList.forEach(val => {
            if(val.itemno == 0){
              val.disabled = true
            }
          });
        }
      }
      // 判断如果是抵押贷和预审批阶段,申请类型默认是首次借款
      if(val==535&&this.title=='预审批申请信息'){
        this.form.applytype = '0'
      }else{
        delete this.form.applytype
      }
      // 判断如果是快贷
      if(val==521){
        // 新增方式可以选择复制
        this.isCopy = false
        //更新业务类型下拉值
        this.businessTypeList = await this.qryDictionaryList('BuildingBusinessType');
      }else{
        this.businessTypeList = await this.qryDictionaryList('BuildingBusinessTypeCredit');
      }
      // 判断是招标贷,业务类型的分期不可选
      if(val==530){
        this.businessTypeList.forEach(val => {
          if(val.itemno == '02'){
            val.disabled = true
          }
        });
      }
      // 判断是保理证件类型写死是统一社会信用证件类型
      if(val == 525){
        this.form.certtype = '05'
      }
      // 更新业务类型值,如果是预审批阶段不用置空
      if(this.title!='预审批申请信息'){
        this.form.occurtype = ''
      }
      // 根据产品类型获取产品名称下拉
      this.getProdList(val)
    },
    // 产品名称
    getProdList(productTypeNo){
      const obj = {}
      obj.productTypeNo=productTypeNo
      if(this.title == '预审批申请信息'){
        obj.preApproved='1'
      }else{
        obj.preApproved='0'
      }
      qryProdList(obj).then(res=>{
        this.productList = res.result
        if(this.form.productid){
          for (let i = 0; i < this.productList.length; i++) {
            if(this.productList[i].productCode==this.form.productid){
              return
            }
          }
          this.form.productid = ''
        }
      })
    },
    // 返回并关闭当前弹窗
    back(){
      this.dialogTableVisible = false
    },
    closeDialog(formName){
      this.$refs[formName].resetFields();
      this.$emit('closeApply',false)
    },
    // 提交复制申请单
    submit(form){
      if(!form.copiedSerialNo){
        this.$message.warning('请单击选中数据');
        return;
      }
      this.loading = true
      if(this.title=='预审批申请信息'){
        this.submitLoanAndPreApply(savePreApplyLoan)
      }else{
        this.submitLoanAndPreApply(saveApplyLoan)
      }
    },
    // 封装预审批和贷款申请提交接口
    submitLoanAndPreApply(data){
      data(this.form).then(res=>{
        this.loading = false
        if(res.code=='00'){
          res.result.objectType = res.result.objecttype
          res.result.phaseNo = res.result.phaseno
          res.result.productID = res.result.productid
          delete res.result.objecttype
          delete res.result.phaseno
          delete res.result.productid
          this.$store.commit('SET_applyInfo',res.result)
          this.$message.success('新增成功')
          this.$emit('closeApply',false)
          this.$router.push({path:'/loanApplyEdit'})
        }
      })
    },
    async productidChange() {
      this.$refs['form'].clearValidate();
      //如果借款人类型是企业,则证件类型默认为统一社会信用代码
      if(this.isCFD || this.isTYCJ) {
        this.form.borrowerType = '01'
        this.form.certtype = '05'
      }
      //如果借款人类型是企业,则证件类型默认为统一社会信用代码
      if(this.form.productid == 'YZD') {
        this.form.certtype = '01'
      }
       // 业务类型
       getOccurTypeList({productid: this.form.productid}).then(res=>{
        this.businessTypeList = res.result
 
        const type3 = res.result.find(res=> res.itemno == '03')
        if(type3) {
          this.form.occurtype = '03'
        } else {
          this.form.occurtype = res.result[0].itemno
        }
      })
      this.qryEnterpriseList()
    },
    certidChange() {
      this.form.certid = this.form.certid.toUpperCase().trim()
    // 当类型为企业的时候调用天眼查去获取客户名称
      if(this.form.certid.length == 18 && this.form.borrowerType == '01') {
        this.qryEnterpriseList()
        findDataByNameOrCodes({codes:[this.form.certid]}).then((res)=>{
          if(res.code == '00') {
            this.$set(this.form, 'customername', res.result.length > 0 ? res.result[0].name : '')
            // this.form.customername = res.result[0].name
          }
        })
      } else {
        this.qryEnterpriseList()
      }
    },
    // 提交新增申请单
    confirm(formName){
      this.$refs[formName].validate((valid) => {
        if (valid) {
          // applychannel预审批和贷款申请有区别
          if(this.title=='预审批申请信息'){
            this.form.applychannel='06'
          }else{
            this.form.applychannel='03'
          }
          if(this.form.addType=='00'){
            this.loading = true
            if(this.title=='预审批申请信息'){
              this.submitLoanAndPreApply(savePreApplyLoan)
            }else{
              this.submitLoanAndPreApply(saveApplyLoan)
            }
          }else{
            this.loading = true
            qryCopiedApplyList(this.form).then(res=>{
              this.loading = false
              if(res.result.length){
                this.applyData = res.result
                this.dialogTableVisible = true
              }
            })
          }
        } else {
          return false;
        }
      });
    }
  }
}
</script>
<style lang="stylus">
.AddApply
  .el-dialog
    width auto
    max-width calc(100% - 180px)
    min-width 850px
    max-height 100%
    overflow hidden
    margin 0 !important
    position absolute
    left 50%
    top 50%
    transform translate(-50%,-50%)
    p 
      text-align: center
      color: #222222
      font-size: 18px
      font-weight:500
      margin-bottom: 20px
    .el-dialog__header
      padding: 40px 0 30px
      .el-dialog__headerbtn
        top:12px
    .el-dialog__body
      padding 0 20px 26px
      .el-table
        td,th
          height 48px
          padding 0
          .cell
            line-height 18px
    .el-dialog__footer
      padding 0
    .dialog-footer
      padding 0 0 40px
    .el-button
      width: 120px
      font-size: 14px
      line-height: 20px
      padding: 5px 0
    .el-form
      display: flex
      justify-content: flex-start
      flex-wrap: wrap
      .el-form-item
        display: flex
        width:45%
        margin: 0 30px 24px 0
        .el-form-item__label
          color: #888
        .el-form-item__content
          flex:1
          .el-date-editor
            width: auto
          .el-select
            display: block
</style>