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
<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="95px" 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="请选择">
            <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">
          <el-select v-model="form.addType" :disabled='isCopy' 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="customername">
          <el-input v-model="form.customername"></el-input>
        </el-form-item>
        <!-- 判断如果产品类型是保理,写死证件类型为统一社会信用证件类型并且不可编辑 -->
        <el-form-item label="证件类型" prop="certtype">
          <el-select v-model="form.certtype" filterable placeholder="请选择" :disabled="form.productTypeNo == 525">
            <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="certid">
          <el-input v-model="form.certid" @change="form.certid = form.certid.toUpperCase()"></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>
      <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
} 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:''
      },
      dialogTableVisible:false,
      applyData:[],
      productTypeList:[],
      productList:[],
      certtypeList:[],
      applytypeList:[],
      businessTypeList:[],
      projectList:[],
      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(){}
    }
  },
  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.listCommissionProjects()
 
  },
  methods: {
    selProject(val){
      const { projectList } = this
      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
    },
    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
        }
      }
    },
    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
      })
    },
    // 监听产品类型获取产品名称下拉
    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'})
        }
      })
    },
    // 提交新增申请单
    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>