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
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
<!--
 * @Author: your name
 * @Date: 2019-10-21 15:40:58
 * @LastEditTime : 2019-12-25 13:01:05
 * @LastEditors  : PengJianTian
 * @Description: In User Settings Edit
 * @FilePath: \cts-web\src\views\area\projectManagement\add\components\ProjectRegTable.vue
 -->
<template>
  <div>
    <el-button
        type="primary"
        size="mini"
        @click="handleAdd"
        style="margin-bottom: 20px"
        v-if="lastDouble">新增</el-button>
    <el-table :data="tableList" fit  stripe size="small" id="product">
      <el-table-column label=" " type="index"></el-table-column>
      <el-table-column prop="product" label="产品" >
        <template slot-scope="scope">
          <!-- <el-select v-model="scope.row.product" size="mini" disabled="disabled" >
            <el-option v-for="item in options.product" :key="item.value" :label="item.valueDesc" :value="item.value">
            </el-option>
          </el-select> -->
                    <div>{{ scope.row.productname }}</div>
        </template>
      </el-table-column>
      <!-- <el-table-column prop="cityDesc" label="城市" > </el-table-column> -->
      <el-table-column prop="levermultiple" label="杠杆倍数" > </el-table-column>
      <!-- <el-table-column prop="businesstype" label="业务类型" v-if="!config.levermultiple.visible"> </el-table-column> -->
      <!-- <el-table-column prop="paymenttype" label="付款类型" v-if="config.paymenttype.visible"> </el-table-column> -->
      <el-table-column prop="creditratio" label="住宅授信比例(%)" > </el-table-column>
      <el-table-column prop="ncreditratioDesc" label="非住宅授信比例(%)" >
      </el-table-column>
      <!-- <el-table-column prop="takeratiomax" label="可取现比例(%)" v-if="isShowFour">
      </el-table-column>
      <el-table-column prop="stageratiomax" label="可分期比例(%)" v-if="isShowFour">
      </el-table-column>
      <el-table-column prop="accountperiod" label="交易账期(月)" v-if="isShowFour">
      </el-table-column>
      <el-table-column prop="putoutwaitdays" label="放款等待期(天)" v-if="isShowFour">
            </el-table-column> -->
      <el-table-column label="产品管理" prop="status" v-if="lastDouble" width="140px" fixed="right">
        <template slot-scope="scope"  v-if="lastDouble">
          <el-button type="text" size="mini" @click="handleEdit(scope.row)">
            修改
          </el-button>
          <!-- <el-popover :ref="'popover-' + scope.$index" placement="top" trigger="click" width="100">
            <p>确定删除吗?</p>
            <div style="text-align: right; margin: 0">
              <el-button size="mini" type="text" @click="pClose(scope.$index)">取消</el-button>
              <el-button type="primary" size="mini" @click="handleDelete(scope.row, scope.$index)">确定</el-button>
            </div> -->
            <el-button type="text" size="mini" slot="reference"  @click="handleDelete(scope.row, scope.$index)">删除</el-button>
          <!-- </el-popover> -->
        </template>
      </el-table-column>
    </el-table>
    <pagination
      v-show="total > 1"
      :total="total"
      :page.sync="listQuery.currentPage"
      :limit.sync="listQuery.pageSize"
      @pagination="initTable"
    />
        <!-- 新增 -->
        <div id="accessMsg">
            <el-dialog style="font-weight:bold" title="新增产品信息" :close-on-click-modal="false" center @close="closeDialog" :visible.sync="dialogVisible" width="850px">
                <el-form class="msgForm" :model="form" ref="form">
                    <!-- 产品 -->
                    <el-col class="addTipOuter" :span="12">
                        <table-select v-if="config.product.visible" :config="config.product" v-model="form.product" @setProductName="setProductName" @input="filterDubProduct"></table-select>
                        <span v-if="showProduct" class="addTip" style="transform:translateX(-65%)">请输入{{config.product.filedDescription}}</span>
                    </el-col>
                    <!-- 城市 -->
                    <el-col :span="12">
                        <area-table-select v-if="config.city.visible" :config="config.city" v-model="form.city"></area-table-select>
                    </el-col>
                    <!-- 交易账期(月)* -->
                    <el-col class="addTipOuter" :span="12">
                        <!-- <area-add-input
                            v-if="config.accountperiod.visible"
                            :config="config.accountperiod"
                            v-model="form.accountperiod"
                        ></area-add-input> -->
                        <el-form-item :label="config.accountperiod.filedDescription" :rules="rules" v-if="config.accountperiod.visible">
                            <el-input v-model="form.accountperiod" @change="changData"></el-input>
                        </el-form-item>
                        <span v-if="showMonth" class="addTip">请输入{{config.accountperiod.filedDescription}}</span>
                    </el-col>
                    <el-col class="addTipOuter" :span="12">
                        <!-- 放款等待期(天)* -->
                        <!-- <area-add-input
                            v-if="config.putoutwaitdays.visible"
                            :config="config.putoutwaitdays"
                            v-model="form.putoutwaitdays"
                        ></area-add-input> -->
                        <el-form-item :label="config.putoutwaitdays.filedDescription" :rules="rules" v-if="config.putoutwaitdays.visible">
                            <el-input v-model="form.putoutwaitdays"></el-input>
                        </el-form-item>
                        <span v-if="showDays" class="addTip">请输入{{config.putoutwaitdays.filedDescription}}</span>
                    </el-col>
                    <el-col :span="12">
                        <!-- 可分期比例(%)* -->
                        <page-select
                            v-if="config.stageratiomax.visible"
                            :config="config.stageratiomax"
                            v-model="form.stageratiomax"
                        ></page-select>
                    </el-col>
                    <!-- 包装模式 -->
                    <el-col :span="12">
                        <area-add-input
                            v-if="config.packagingmode.visible"
                            :config="config.packagingmode"
                            v-model="form.packagingmode"
                        ></area-add-input>
                    </el-col>
                    <!-- 可取现比例(%)* -->
                    <el-col :span="12">
                        <page-select
                            v-if="config.takeratiomax.visible"
                            :config="config.takeratiomax"
                            v-model="form.takeratiomax"
                        ></page-select>
                    </el-col>
                    <!-- 基础额度杠杆倍数 -->
                    <el-col :span="12">
                        <area-add-input
                            v-if="config.levermultiple.visible"
                            :config="config.levermultiple"
                            v-model="form.levermultiple"
                        ></area-add-input>
                    </el-col>
                    <!-- 住宅授信比例(%)* -->
                    <el-col :span="12">
                        <table-select
                            v-if="config.creditratio.visible"
                            :config="config.creditratio"
                            v-model="form.creditratio"
                        ></table-select>
                    </el-col>
                    <!-- 非住宅授信比例(%)  -->
                    <el-col :span="12">
                        <table-select
                            v-if="config.ncreditratio.visible"
                            :config="config.ncreditratio"
                            v-model="form.ncreditratio"
                        ></table-select>
                    </el-col>
                    <!-- 付款类型 -->
                    <el-col :span="12">
                        <table-select
                            v-if="config.paymenttype.visible"
                            :config="config.paymenttype"
                            v-model="form.paymenttype"
                        ></table-select>
                    </el-col>
                    <!-- 业务类型  -->
                    <el-col :span="12">
                        <table-select
                            v-if="config.businesstype.visible"
                            :config="config.businesstype"
                            v-model="form.businesstype"
                        ></table-select>
                    </el-col>
                </el-form>
                <span slot="footer" class="dialog-footer">
                    <el-button class="cancel-btn dialog-btn" size="mini" @click="closeDialog">取 消</el-button>
                    <el-button class="save-btn dialog-btn" size="mini" type="primary" @click="handleSave"> 保 存 </el-button>
                </span>
            </el-dialog>
            <!-- 修改 -->
            <el-dialog style="font-weight:bold" title="修改产品信息" center @close="closeDialog" :visible.sync="dialogModifyFromVisible" width="850px">
                <el-form class="msgForm" :model="form" ref="form">
                    <el-col :span="12">
                        <TableSelectModify v-if="config.product.visible" :config="config.product" v-model="modifyFrom.product" @setProductName="setProductName" @input="filterDubProduct"></TableSelectModify>
                    </el-col>
                    <el-col :span="12">
                        <area-table-select v-if="config.city.visible" :config="config.city" v-model="modifyFrom.city"></area-table-select>
                    </el-col>
                    <!-- <table-select v-if="config.city.visible" :config="config.city" v-model="modifyFrom.city"></table-select> -->
                    <!-- 交易账期(月)* -->
                    <el-col class="addTipOuter" :span="12">
                        <!-- <area-add-input
                            v-if="config.accountperiod.visible"
                            :config="config.accountperiod"
                            v-model="modifyFrom.accountperiod"
                        ></area-add-input> -->
                        <el-form-item :label="config.accountperiod.filedDescription" :rules="rules" v-if="config.accountperiod.visible">
                            <el-input v-model="modifyFrom.accountperiod"></el-input>
                        </el-form-item>
                        <span v-if="showMonthMod" class="addTip">请输入{{config.accountperiod.filedDescription}}</span>
                    </el-col>
                    <!-- 放款等待期(天)* -->
                    <el-col class="addTipOuter" :span="12">
                        <!-- <area-add-input
                            v-if="config.putoutwaitdays.visible"
                            :config="config.putoutwaitdays"
                            v-model="modifyFrom.putoutwaitdays"
                        ></area-add-input> -->
                        <!-- {{config.putoutwaitdays.visible}} -->
                        <el-form-item :label="config.putoutwaitdays.filedDescription" :rules="rules" v-if="config.putoutwaitdays.visible">
                            <el-input v-model="modifyFrom.putoutwaitdays"></el-input>
                        </el-form-item>
                        <span v-if="showDaysMod" class="addTip">请输入{{config.putoutwaitdays.filedDescription}}</span>
                    </el-col>
                    <!-- 可分期比例(%)* -->
                    <el-col :span="12">
                        <page-select
                            v-if="config.stageratiomax.visible"
                            :config="config.stageratiomax"
                            v-model="modifyFrom.stageratiomax"
                        ></page-select>
                    </el-col>
                    <!-- 包装模式 -->
                    <el-col :span="12">
                        <area-add-input
                            v-if="config.packagingmode.visible"
                            :config="config.packagingmode"
                            v-model="modifyFrom.packagingmode"
                        ></area-add-input>
                    </el-col>
                    <!-- 可取现比例(%)* -->
                    <el-col :span="12">
                        <page-select
                            v-if="config.takeratiomax.visible"
                            :config="config.takeratiomax"
                            v-model="modifyFrom.takeratiomax"
                        ></page-select>
                    </el-col>
                    <!-- 基础额度杠杆倍数 -->
                    <el-col :span="12">
                        <area-add-input
                            v-if="config.levermultiple.visible"
                            :config="config.levermultiple"
                            v-model="modifyFrom.levermultiple"
                        ></area-add-input>
                    </el-col>
                    <!-- 住宅授信比例(%)* -->
                    <el-col :span="12">
                        <table-select
                            v-if="config.creditratio.visible"
                            :config="config.creditratio"
                            v-model="modifyFrom.creditratio"
                        ></table-select>
                    </el-col>
                    <!-- 非住宅授信比例(%)  -->
                    <el-col :span="12">
                        <table-select
                            v-if="config.ncreditratio.visible"
                            :config="config.ncreditratio"
                            v-model="modifyFrom.ncreditratio"
                        ></table-select>
                    </el-col>
                    <!-- 付款类型 -->
                    <el-col :span="12">
                        <table-select
                            v-if="config.paymenttype.visible"
                            :config="config.paymenttype"
                            v-model="modifyFrom.paymenttype"
                        ></table-select>
                    </el-col>
                    <!-- 业务类型  -->
                    <el-col :span="12">
                        <table-select
                            v-if="config.businesstype.visible"
                            :config="config.businesstype"
                            v-model="modifyFrom.businesstype"
                        ></table-select>
                    </el-col>
                </el-form>
                <span slot="footer" class="dialog-footer">
                    <el-button class="cancel-btn dialog-btn" size="mini" @click="closeDialog">取 消</el-button>
                    <el-button class="save-btn dialog-btn" size="mini" type="primary" @click="handleSaveMod"> 保 存 </el-button>
                </span>
            </el-dialog>
        </div>
  </div>
</template>
 
<script>
import Pagination from '@/components/Pagination'
import TableSelect from '../../../components/TableSelect'
import TableSelectModify from '../../../components/TableSelectModify'
import AreaTableSelect from '../../../components/AreaTableSelect'
import PageSelect from '../../../components/pageSelect'
import AreaAddInput from '../../../components/AreaAddInput'
import {
  queryProjectProductInfos,
  clickAddProjectProductInfo,
  updateProjectProductInfo,
  projectQrycondition,
  delProjectProductInfo
} from '@/api/area'
import { mapState } from 'vuex'
// import { errorMessage } from '@/utils/message'
export default {
  components: { TableSelectModify, AreaAddInput, TableSelect, PageSelect, Pagination, AreaTableSelect },
  data: function() {
    return {
      tableList: [],
      action: [],
      visible: false,
            dialogVisible: false,
            dialogModifyFromVisible: false,
      projectFlag: false,
      phaseno: '',
      config: {},
      form: {
        ncreditratio: '',
        accountperiod: '',
        product: '',
        productname: '',
        city: '',
        putoutwaitdays: '',
        stageratiomax: '',
        packagingmode: '',
        takeratiomax: '',
        levermultiple: '',
        creditratio: '',
        paymenttype: '',
        businesstype: ''
            },
            modifyFrom: {
        ncreditratio: '',
        accountperiod: '',
        product: '',
        productname: '',
        city: '',
        putoutwaitdays: '',
        stageratiomax: '',
        packagingmode: '',
        takeratiomax: '',
        levermultiple: '',
        creditratio: '',
        paymenttype: '',
        businesstype: ''
            },
      options: {
        product: ''
      },
      // 分页
      total: 0,
      listQuery: {
        currentPage: 1,
        pageSize: 10
            },
            modifyProduct: false, // 点击修改为true,否则false
            rules: {
        required: true,
        // message: '请输入' + this.config.putoutwaitdays.filedDescription,
        trigger: 'blur'
            },
            showProduct: false,
            // showMonth: false,
            // showDays: false
    }
  },
  created() {
    this.initTable()
    this.initForm()
    },
  computed: {
    ...mapState({
      detailsParams: state => state.risk.detailsParams
        }),
        isShowFour() {
            // const { phaseno } = this
            if (this.phaseno === '0010' || this.phaseno === '0020' || this.phaseno === '0030' || this.phaseno === '0040' || this.phaseno === '0050' || this.detailsParams.opertion === '02') {
                return true
            } else {
                return false
            }
        },
        lastDouble() {
            if (this.phaseno === '0040' || this.phaseno === '0050' || this.detailsParams.phaseNo === '0060' || this.detailsParams.phaseNo === '0070') {
        return false
      } else {
        return true
      }
        },
        showMonth: {
            get() {
                const { accountperiod, product } = this.form
                if (accountperiod === '' && product === 'AZ') {
                    return true
                } else {
                    return false
                }
            },
            set() {
                const { accountperiod } = this.form
                if (accountperiod === '') {
                    this.form.accountperiod = ''
                }
            }
        },
        showDays: {
            get() {
                const { putoutwaitdays, product } = this.form
                if (putoutwaitdays === '' && (product === 'JLD' || product === 'AZ')) {
                    return true
                } else {
                    return false
                }
            },
            set() {
                const { putoutwaitdays } = this.form
                if (putoutwaitdays === '') {
                    this.form.putoutwaitdays = ''
                }
            }
        },
        showMonthMod: {
            get() {
                const { accountperiod, product } = this.modifyFrom
                if (accountperiod === '' && product === 'AZ') {
                    return true
                } else {
                    return false
                }
            },
            set() {
                const { accountperiod } = this.form
                if (accountperiod === '') {
                    this.form.accountperiod = ''
                }
            }
        },
        showDaysMod: {
            get() {
                const { putoutwaitdays, product } = this.modifyFrom
                if (putoutwaitdays === '' && (product === 'JLD' || product === 'AZ')) {
                    return true
                } else {
                    return false
                }
            },
            set() {
                const { putoutwaitdays } = this.form
                if (putoutwaitdays === '') {
                    this.form.putoutwaitdays = ''
                }
            }
        }
    },
  watch: {
    'form.product': function(newVal) {
            if(newVal === 'YZD') return 
          // '爱家分期(购物)' --JLD  '爱家分期(装修)' --AZ  '装修贷' --ZXD
      // if (this.projectFlag || this.phaseno === '0030') {
      // if (this.phaseno === '0010' || this.phaseno === '0020' || this.phaseno === '0030' || this.detailsParams.opertion === '02') {
      //   // 可取现比例(%)
            // // this.config.takeratiomax.visible = Boolean(newVal === 'JLD')
            // // this.config.takeratiomax.required = Boolean(newVal === 'JLD')
            // // this.config.takeratiomax.writeAble = Boolean(newVal === 'JLD')
      // this.setConfig(newVal, 'takeratiomax', ['JLD'])
            // // 可分期比例(%)
            // // this.config.stageratiomax.visible = Boolean(newVal === 'JLD')
            // // this.config.stageratiomax.required = Boolean(newVal === 'JLD')
            // // this.config.stageratiomax.writeAble = Boolean(newVal === 'JLD')
      // this.setConfig(newVal, 'stageratiomax', ['JLD'])
            // // 交易账期
            // // this.config.accountperiod.required = Boolean(newVal === 'AZ')
            // // this.config.accountperiod.visible = Boolean(newVal === 'AZ')
            // // this.config.accountperiod.writeAble = Boolean(newVal === 'AZ')
      // this.setConfig(newVal, 'accountperiod', ['AZ'])
            // // 放款等待期
            // // this.config.putoutwaitdays.required = Boolean(newVal === 'JLD' || newVal === 'AZ')
            // // this.config.putoutwaitdays.visible = Boolean(newVal === 'JLD' || newVal === 'AZ')
            // // this.config.putoutwaitdays.writeAble = Boolean(newVal === 'JLD' || newVal === 'AZ')
      // this.setConfig(newVal, 'putoutwaitdays', ['JLD', 'AZ'])
            // // 住宅授信比例
            // // this.config.creditratio.required = Boolean(newVal === 'ZXD')
            // // this.config.creditratio.visible = Boolean(newVal === 'ZXD')
            // // this.config.creditratio.writeAble = Boolean(newVal === 'ZXD')
      // this.setConfig(newVal, 'creditratio', ['ZXD'])
 
            // // 非住宅授信比例
            // // this.config.ncreditratio.required = Boolean(newVal === 'ZXD')
      //   // this.config.ncreditratio.visible = Boolean(newVal === 'ZXD')
      //   // this.config.ncreditratio.writeAble = Boolean(newVal === 'ZXD')
      //   this.setConfig(newVal, 'ncreditratio', ['ZXD'])
 
      //   if (newVal === 'JLD') {
      //     if (!this.modifyProduct) {
      //       this.form.putoutwaitdays = '21'
      //       this.form.stageratiomax = '100'
      //       this.form.takeratiomax = '50'
      //     }
      //   }
      //   if (newVal === 'AZ') {
      //     if (!this.modifyProduct) {
      //       this.form.putoutwaitdays = '21'
      //       this.form.accountperiod = '6'
      //     }
      //   }
      // }
    },
    'modifyFrom.product': function(newVal) {
            // '爱家分期(购物)' --JLD  '爱家分期(装修)' --AZ
      // if (this.projectFlag || this.phaseno === '0030') {
      // if (this.phaseno === '0010' || this.phaseno === '0020' || this.phaseno === '0030' || this.detailsParams.opertion === '02') {
      //   // 可取现比例(%)
            //     // this.config.takeratiomax.visible = Boolean(newVal === 'JLD')
            //     // this.config.takeratiomax.required = Boolean(newVal === 'JLD')
            //     // this.config.takeratiomax.writeAble = Boolean(newVal === 'JLD')
      //   this.setConfig(newVal, 'takeratiomax', ['JLD'])
      //   // 可分期比例(%)
      //   // this.config.stageratiomax.visible = Boolean(newVal === 'JLD')
      //   // this.config.stageratiomax.required = Boolean(newVal === 'JLD')
      //   // this.config.stageratiomax.writeAble = Boolean(newVal === 'JLD')
      //   this.setConfig(newVal, 'stageratiomax', ['JLD'])
      //   // 交易账期
      //   // this.config.accountperiod.required = Boolean(newVal === 'AZ')
            //     // this.config.accountperiod.visible = Boolean(newVal === 'AZ')
      //   // this.config.accountperiod.writeAble = Boolean(newVal === 'AZ')
      //   this.setConfig(newVal, 'accountperiod', ['AZ'])
      //   // 放款等待期
      //   // this.config.putoutwaitdays.required = Boolean(newVal === 'JLD' || newVal === 'AZ')
      //   // this.config.putoutwaitdays.visible = Boolean(newVal === 'JLD' || newVal === 'AZ')
            //     // this.config.putoutwaitdays.writeAble = Boolean(newVal === 'JLD' || newVal === 'AZ')
      //   this.setConfig(newVal, 'putoutwaitdays', ['JLD', 'AZ'])
      //   this.setConfig(newVal, 'creditratio', ['ZXD'])
      //   this.setConfig(newVal, 'ncreditratio', ['ZXD'])
            //     // if (newVal === 'JLD') {
            //     //     this.modifyFrom.putoutwaitdays = '21'
            //     //     this.modifyFrom.stageratiomax = '100'
            //     //     this.modifyFrom.takeratiomax = '50'
            //     // } else {
            //     //     // this.modifyFrom.putoutwaitdays = ''
            //     //     this.modifyFrom.stageratiomax = ''
            //     //     this.modifyFrom.takeratiomax = ''
            //     // }
            //     // if (newVal === 'AZ') {
            //     //     this.modifyFrom.putoutwaitdays = '21'
            //     //     this.modifyFrom.accountperiod = '6'
            //     // } else {
            //     //     // this.modifyFrom.putoutwaitdays = ''
            //     //     this.modifyFrom.accountperiod = ''
            //     // }
            // }
        },
    },
  methods: {
    setConfig(value, product, productKey = []) {
      const isHasKey = Boolean(productKey.includes(value))
      if(this.config[product]) {
        this.config[product].visible = isHasKey
        this.config[product].required = isHasKey
        this.config[product].writeAble = isHasKey
      }
    },
    initTable() {
      let params = {
        objectType: this.detailsParams.objectType,
        dataType: this.detailsParams.dataType,
        projectFlag: this.detailsParams.projectFlag,
        projectType: this.detailsParams.projectType,
        serialno: this.detailsParams.objectNo
            }
      params = Object.assign({}, this.listQuery, params)
      queryProjectProductInfos(params).then(res => {
                this.tableList = res.result.records
                this.tableList.map(item => {
                    for (let key in item) {
                        // console.log(key)
                        if (item[key] === '' || item[key] === '0' || item[key] === 'null') {
                            item[key] = '--'
                        }
                    }
                })
        this.total = res.result.total
      })
    },
    initForm() {
      let params = {
        objectType: this.detailsParams.objectType,
        dataType: this.detailsParams.dataType,
        projectFlag: this.detailsParams.projectFlag,
        projectType: this.detailsParams.projectType,
        serialno: this.detailsParams.objectNo
      }
      let config = {
        visible: false,
        required: false,
        writeAble: false
            }
      Object.keys(this.form).forEach(key => {
        this.config[key] = config
            })
      // 产品下拉
            this.productSelect()
            if (this.detailsParams.phaseNo !== '0060' && this.detailsParams.phaseNo !== '0070') {
                clickAddProjectProductInfo(params).then(res => {
                    // console.log(res.result)
                    this.phaseno = res.result.phaseno // 阶段号
                    this.projectFlag = res.result.projectFlag // 立项
                    Object.keys(res.result).forEach(key => {
                        let merge = this._.merge({}, this.config, res.result)
            this.config = merge
            const val = res.result[key] && res.result[key].value
                        this.$set(this.form, key, val)
                        this.$set(this.modifyFrom, key, val)
                    })
                })
            }
        },
        // 新增
    handleAdd() {
        this.config.takeratiomax.visible = false
        this.config.stageratiomax.visible = false
        this.config.accountperiod.visible = false
        this.config.putoutwaitdays.visible = false
        this.form.product = ''
          this.dialogVisible = true
    },
    handleSaveMod() {
            const { product, accountperiod, putoutwaitdays } = this.modifyFrom
            // if (showProduct || showMonth || showDays) {
            //     this.$message.warning('当前页面存在必填项未录入或数据录入错误,请检查!')
            // } else {
            // }
            let tip = '修改'
            let tempDays = putoutwaitdays === '' ? -1 : putoutwaitdays * 1
            let tempMonth = accountperiod === '' ? -1 : accountperiod * 1
            console.log(tempDays, tempMonth)
            if (product === 'JLD') {
                if (tempDays > 0) {
                    this.realSave(tip)
                } else {
                    this.$message.warning('放款等待期(天)必须大于0!')
                }
            }
            if (product === 'AZ') {
                if (tempDays > 0 && tempMonth > 0) {
                    this.realSave(tip)
                } else {
                    this.$message.warning('放款等待期(天)和可分期比例(%)必须大于0!')
                }
            }
            if (product !== 'JLD' && product !== 'AZ') {
                this.realSave(tip)
            }
        },
    handleSave() {
            const { product, accountperiod, putoutwaitdays } = this.form
            // console.log(product)
            let tip = '新增'
            if (!product) {
                this.showProduct = true
            }
            if (!accountperiod && product === 'AZ') {
                this.showMonth = true
            }
            if (!putoutwaitdays && product === 'JLD') {
                this.showDays = true
            }
            // console.log(params)
            const { showProduct } = this
            // if (showProduct || showMonth || showDays) {
            //     this.$message.warning('当前页面存在必填项未录入或数据录入错误,请检查!')
            // } else {
            // }
            if (!showProduct) {
                let tempDays = putoutwaitdays === '' ? -1 : putoutwaitdays * 1
                let tempMonth = accountperiod === '' ? -1 : accountperiod * 1
                console.log(tempDays, tempMonth)
                if (product === 'JLD') {
                    if (tempDays > 0) {
                        this.realSave(tip)
                    } else {
                        this.$message.warning('放款等待期(天)必须大于0!')
                    }
                }
                if (product === 'AZ') {
                    if (tempDays > 0 && tempMonth > 0) {
                        this.realSave(tip)
                    } else {
                        this.$message.warning('放款等待期(天)和可分期比例(%)必须大于0!')
                    }
                }
                if (product !== 'JLD' && product !== 'AZ') {
                    this.realSave(tip)
                }
            } else {
                this.$message.warning('当前页面存在必填项未录入或数据录入错误,请检查!')
            }
        },
        realSave(tip) {
            let params = {
                objectno: this.detailsParams.objectNo,
                dataType: this.detailsParams.dataType,
                objecttype: this.detailsParams.objectType
            }
            if (this.modifyProduct) {
                if (this.modifyFrom.product !== 'AZ' && this.modifyFrom.product !== 'JLD') {
                    this.modifyFrom.putoutwaitdays = ''
                    this.modifyFrom.stageratiomax = ''
                    this.modifyFrom.takeratiomax = ''
                    this.modifyFrom.accountperiod = ''
                }
                // 修改
                Object.assign(params, this.modifyFrom)
                // console.log(this.modifyFrom)
            } else {
                // 新增
                Object.assign(params, this.form)
            }
            updateProjectProductInfo(params).then(res => {
                if (res.code === '00') {
                    this.$message.success(`${tip}成功`)
                    this.dialogVisible = false
                    this.dialogModifyFromVisible = false
                    this.modifyProduct = false
                    this.initTable()
                }
            })
        },
        // 修改
    handleEdit(row) {
            // ??\
            let tempRow = Object.assign({}, row)
            for (let key in row) {
                if (tempRow[key] === '--') {
                    tempRow[key] = ''
                }
            }
            // this.modifyRow = row
            this.modifyRow = tempRow
            this.modifyProduct = true
            this.dialogModifyFromVisible = true
            this.modifyFrom = Object.assign({}, this.form, tempRow)
            // this.modifyFrom = Object.assign({}, this.form, tempRow)
            // console.log(row)
            // this.modifyFrom.product = row.product
            // this.modifyFrom.putoutwaitdays = row.putoutwaitdays
            // this.form.putoutwaitdays = row.putoutwaitdays
            // // console.log(this.modifyFrom.putoutwaitdays)
            // this.modifyFrom.stageratiomax = row.stageratiomax
            // this.modifyFrom.takeratiomax = row.takeratiomax
    },
    handleDelete(row, index) {
      let params = {
        objecttype: this.detailsParams.objectType,
        serialno: row.serialno,
        dataType: this.detailsParams.dataType,
        projectFlag: this.detailsParams.projectFlag,
        projectType: this.detailsParams.projectType
      }
      delProjectProductInfo(params).then(res => {
        if (res.code === '00') {
          this.$message.success('删除成功')
          // this.pClose(index)
          this.initTable()
        }
      })
    },
    productSelect() {
      let params = { conditionName: 'product' }
      projectQrycondition(params).then(res => {
                this.options.product = res.result
      })
    },
    pClose(index) {
      this.$refs[`popover-` + index].doClose()
    },
    closeDialog() {
        // this.$refs['form'].resetFields()
        // const { form,modifyFrom } = this
        // this.form.putoutwaitdays = ''
        // for (let key in this.form) {
        //     if ( key !== 'city' || key !== 'levermultiple') {
        //         this.form[key] = ''
        //     }
        // }
        // for (let key in modifyFrom) {
        //     if ( key !== 'city' || key !== 'levermultiple') {
        //         modifyFrom[key] = ''
        //         console.log(modifyFrom[key])
        //     }
        // }
        this.initTable()
        // console.log(this.modifyRow)
        this.dialogVisible = false
        this.dialogModifyFromVisible = false
        this.modifyProduct = false
    },
    setProductName(value) {
        this.showProduct = false
        this.form.productname = value
        this.modifyFrom.productname = value
    },
    changData(value) {
        console.log(value)
    },
    // 过滤爱家分期(购物)和爱家分期(装修)
    filterDubProduct(val) {
        if (val !== 'JLD' || val !== 'AZ') {
            this.form.accountperiod = ''
            this.form.putoutwaitdays = ''
            this.form.stageratiomax = ''
            this.form.takeratiomax = ''
        }
    },
  }
}
</script>
 
<style lang="stylus" scoped>
#product
    >>> .el-input__inner
        border: none
    >>> .el-input__suffix
        display: none
 
#accessMsg
    >>>.el-dialog
        .el-dialog__header
            padding-top 40px
            >>>.el-dialog__title
                font-size 18px
                // font-family PingFangSC-Medium,PingFangSC
                font-weight bold
                color red
                line-height 25px
        .el-dialog__body
            min-height 130px
            padding 20px 25px 10px
            .msgForm
                .el-col
                    .el-form-item
                        margin-bottom 10px
                        .el-form-item__label
                            width 160px
                            color #666666
                            // font-family PingFangSC-Regular,PingFang SC
                            font-weight 400
                            line-height 16px
                        .el-form-item__content
                            .el-input__inner
                                min-width auto
                & > .addTipOuter
                    position relative
                    & > .addTip
                        font-size 12px
                        position absolute
                        left 50%
                        top 70%
                        color red
                        transform translateX(-35%)
        .el-dialog__footer
            padding-top 30px
            padding-bottom 30px
        .dialog-footer
            .dialog-btn
                width 120px
                height 30px
            .save-btn
                margin-left 40px
                background rgba(0,129,240,1)
                box-shadow 0px 1px 6px 1px rgba(0,0,0,0.08)
                border-radius 4px
            .cancel-btn
                background rgba(255,255,255,1)
                box-shadow 0px 1px 6px 1px rgba(0,0,0,0.08)
                border-radius 4px
                border 1px solid rgba(204,204,204,1)
</style>