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
<template>
  <div class="product">
    <Summary
      :update="update" 
      :serialNo="applyInfo.serialNo" 
      :customerid="applyInfo.customerid" 
      @sendUpdate="sendUpdate">
    </Summary>
    <div class="property">
      <p class="title">
        <span></span>
        物业明细信息
      </p>
      <el-tabs v-model="tabIndex" type="card" @tab-remove='delProperty'>
        <el-tab-pane
          v-for="(item, index) in propertyForm"
          :key="index"
          :label="`物业${index+1}`"
          :name="index+''"
          :closable="propertyForm.length!=1&&addAndDel"
        >
          <el-form
            :model="propertyForm[index]"
            :rules="rules"
            ref="propertyForm"
            inline
            label-width="165px"
            size="small"
          >
            <el-input v-model="propertyForm[index].serialno" v-show="false"></el-input>
            <el-form-item
              label="房产地址(省)"
              v-if="propertyArr[index].houseprovince.visible"
              prop="houseprovince"
            >
              <el-select
                v-model="propertyForm[index].houseprovince"
                :disabled="!propertyArr[index].houseprovince.writeAble"
                clearable
                filterable
                placeholder="支持输入搜索选择"
                @change="getprovince(propertyForm[index].houseprovince,'housecityList',propertyForm[index],function(arr){propertyArr[index].housecityList=arr,$set(propertyArr,index,propertyArr[index])})"
              >
                <el-option
                  v-for="(item,index) in provinceList"
                  :key="index"
                  :label="item.itemname"
                  :value="item.itemno"
                ></el-option>
              </el-select>
            </el-form-item>
            <el-form-item label="房产地址(市)" v-if="propertyArr[index].housecity.visible" prop="housecity">
              <el-select
                v-model="propertyForm[index].housecity"
                :disabled="!propertyArr[index].housecity.writeAble"
                clearable
                filterable
                placeholder="支持输入搜索选择"
                @change="getcity(propertyForm[index].housecity,'housecountyList',propertyForm[index],function(arr){propertyArr[index].housecountyList=arr,$set(propertyArr,index,propertyArr[index])})"
              >
                <el-option
                  v-for="(item,index) in propertyArr[index].housecityList"
                  :key="index"
                  :label="item.itemname"
                  :value="item.itemno"
                ></el-option>
              </el-select>
            </el-form-item>
            <el-form-item
              label="房产地址(区)"
              v-if="propertyArr[index].housecounty.visible"
              prop="housecounty"
            >
              <el-select
                v-model="propertyForm[index].housecounty"
                :disabled="!propertyArr[index].housecounty.writeAble"
                clearable
                filterable
                placeholder="支持输入搜索选择"
              >
                <el-option
                  v-for="(item,index) in propertyArr[index].housecountyList"
                  :key="index"
                  :label="item.itemname"
                  :value="item.itemno"
                ></el-option>
              </el-select>
            </el-form-item>
            <el-form-item
              label="小区或项目名称"
              v-if="propertyArr[index].communityname.visible"
              prop="communityname"
            >
              <el-input
                v-model="propertyForm[index].communityname"
                :disabled="!propertyArr[index].communityname.writeAble"
                @blur="gethouseaddr(propertyForm[index])"
              ></el-input>
            </el-form-item>
            <el-form-item
              label="楼栋单元或车位楼层"
              v-if="propertyArr[index].buildingno.visible"
              prop="buildingno"
            >
              <el-input
                v-model="propertyForm[index].buildingno"
                :disabled="!propertyArr[index].buildingno.writeAble"
                @blur="gethouseaddr(propertyForm[index])"
              ></el-input>
            </el-form-item>
            <el-form-item label="房号或车位号" v-if="propertyArr[index].roomno.visible" prop="roomno">
              <el-input
                v-model="propertyForm[index].roomno"
                :disabled="!propertyArr[index].roomno.writeAble"
                @blur="gethouseaddr(propertyForm[index])"
              ></el-input>
            </el-form-item>
            <el-form-item
              label="房产地址(街道/小区 名/单元/房号)"
              v-if="propertyArr[index].houseaddress.visible"
              prop="houseaddress"
            >
              <el-input
                v-model="propertyForm[index].houseaddress"
                :disabled="!propertyArr[index].houseaddress.writeAble"
              ></el-input>
            </el-form-item>
            <el-form-item
              label="物业类型"
              v-if="propertyArr[index].propertytype.visible"
              prop="propertytype"
            >
              <el-select
                v-model="propertyForm[index].propertytype"
                :disabled="!propertyArr[index].propertytype.writeAble"
                clearable
                filterable
                placeholder="支持输入搜索选择"
                @change="selPropertytype(propertyForm[index])"
              >
                <el-option
                  v-for="(item,index) in propertyTypelist"
                  :key="index"
                  :label="item.itemname"
                  :value="item.itemno"
                ></el-option>
              </el-select>
            </el-form-item>
            <el-form-item
              label="物业分类"
              v-if="propertyArr[index].propertyClassify.visible"
              prop="propertyClassify"
            >
              <el-select
                v-model="propertyForm[index].propertyClassify"
                :disabled="!propertyArr[index].propertyClassify.writeAble"
                clearable
                filterable
                placeholder="支持输入搜索选择"
              >
                <el-option
                  v-for="(item,index) in propertyClassifys"
                  :key="index"
                  :label="item.itemname"
                  :value="item.itemno"
                ></el-option>
              </el-select>
            </el-form-item>
            <el-form-item label="产权证号" v-if="propertyArr[index].certificate.visible" prop="certificate">
              <el-input
                v-model="propertyForm[index].certificate"
                :disabled="!propertyArr[index].certificate.writeAble"
              ></el-input>
            </el-form-item>
            <el-form-item
              label="权利性质"
              v-if="propertyArr[index].rightAgeLimit.visible"
              prop="rightAgeLimit"
            >
              <el-select
                v-model="propertyForm[index].rightAgeLimit"
                :disabled="!propertyArr[index].rightAgeLimit.writeAble"
                clearable
                filterable
                placeholder="支持输入搜索选择"
              >
                <el-option
                  v-for="(item,index) in rightAgeLimits"
                  :key="index"
                  :label="item.itemname"
                  :value="item.itemno"
                ></el-option>
              </el-select>
            </el-form-item>
            <el-form-item label="土地用途" v-if="propertyArr[index].useType.visible" prop="useType">
              <el-select
                v-model="propertyForm[index].useType"
                :disabled="!propertyArr[index].useType.writeAble"
                clearable
                filterable
                placeholder="支持输入搜索选择"
              >
                <el-option
                  v-for="(item,index) in useTypes"
                  :key="index"
                  :label="item.itemname"
                  :value="item.itemno"
                ></el-option>
              </el-select>
            </el-form-item>
            <el-form-item
              label="房屋使用状态"
              v-if="propertyArr[index].houseuseStatus.visible"
              prop="houseuseStatus"
            >
              <el-select
                v-model="propertyForm[index].houseuseStatus"
                :disabled="!propertyArr[index].houseuseStatus.writeAble"
                clearable
                filterable
                placeholder="支持输入搜索选择"
              >
                <el-option
                  v-for="(item,index) in houseuseStatusList"
                  :key="index"
                  :label="item.itemname"
                  :value="item.itemno"
                ></el-option>
              </el-select>
            </el-form-item>
            <el-form-item label="建筑面积(㎡)" v-if="propertyArr[index].coveredArea.visible" prop="coveredArea">
              <el-input
                v-model="propertyForm[index].coveredArea"
                :disabled="!propertyArr[index].coveredArea.writeAble"
                @blur="propertyForm[index].coveredArea = formatMoney(propertyForm[index].coveredArea)"
              ></el-input>
            </el-form-item>
            <el-form-item
              label="EVS估值(元)"
              v-if="propertyArr[index].evsassessment.visible"
              prop="evsassessment"
            >
              <el-input
                v-model="propertyForm[index].evsassessment"
                :disabled="!propertyArr[index].evsassessment.writeAble"
                @blur="propertyForm[index].evsassessment = formatMoney(propertyForm[index].evsassessment);selguarantycount(index)"
              ></el-input>
            </el-form-item>
            <el-form-item label="购房日期" v-if="propertyArr[index].timebuying.visible" prop="timebuying">
              <el-date-picker
                v-model="propertyForm[index].timebuying"
                type="date"
                format="yyyy/MM/dd"
                value-format="yyyy/MM/dd"
                size="small"
                placeholder="选择日期"
                :disabled="!propertyArr[index].timebuying.writeAble"
              ></el-date-picker>
            </el-form-item>
            <el-form-item
              label="竣工日期"
              v-if="propertyArr[index].completeAgeLimit.visible"
              prop="completeAgeLimit"
            >
              <el-date-picker
                v-model="propertyForm[index].completeAgeLimit"
                type="date"
                format="yyyy/MM/dd"
                value-format="yyyy/MM/dd"
                size="small"
                placeholder="选择日期"
                :disabled="!propertyArr[index].completeAgeLimit.writeAble"
              ></el-date-picker>
            </el-form-item>
            <el-form-item
              label="产权年限"
              v-if="propertyArr[index].propertyAgeLimit.visible"
              prop="propertyAgeLimit"
            >
              <el-select
                v-model="propertyForm[index].propertyAgeLimit"
                :disabled="!propertyArr[index].propertyAgeLimit.writeAble"
                clearable
                filterable
                placeholder="支持输入搜索选择"
              >
                <el-option
                  v-for="(item,index) in propertyAgeLimits"
                  :key="index"
                  :label="item.itemname"
                  :value="item.itemno"
                ></el-option>
              </el-select>
            </el-form-item>
            <el-form-item
              label="是否学区房"
              v-if="propertyArr[index].isschoolhouse.visible"
              prop="isschoolhouse"
            >
              <el-input
                v-model="propertyArr[index].isschoolhouse.valueDesc"
                :disabled="!propertyArr[index].isschoolhouse.writeAble"
              ></el-input>
            </el-form-item>
            <el-form-item
              label="小学学区名称"
              v-if="propertyArr[index].primaryschooldistrictname.visible"
              prop="primaryschooldistrictname"
            >
              <el-input
                v-model="propertyForm[index].primaryschooldistrictname"
                :disabled="!propertyArr[index].primaryschooldistrictname.writeAble"
              ></el-input>
            </el-form-item>
            <el-form-item
              label="初中学区名称"
              v-if="propertyArr[index].middleschooldistrictname.visible"
              prop="middleschooldistrictname"
            >
              <el-input
                v-model="propertyForm[index].middleschooldistrictname"
                :disabled="!propertyArr[index].middleschooldistrictname.writeAble"
              ></el-input>
            </el-form-item>
            <el-form-item
              label="一押/二押"
              v-if="propertyArr[index].guarantycount.visible"
              prop="guarantycount"
            >
              <el-select
                v-model="propertyForm[index].guarantycount"
                :disabled="!propertyArr[index].guarantycount.writeAble"
                @change="selguarantycount(index)"
                clearable
                filterable
                placeholder="支持输入搜索选择"
              >
                <el-option
                  v-for="(item,index) in guarantycounts"
                  :key="index"
                  :label="item.itemname"
                  :value="item.itemno"
                ></el-option>
              </el-select>
            </el-form-item>
            <el-form-item
              label="原一押循环授信类型"
              v-if="propertyArr[index].firstCreditType.visible"
              prop="firstCreditType"
            >
              <el-select
                v-model="propertyForm[index].firstCreditType"
                :disabled="!propertyArr[index].firstCreditType.writeAble"
                clearable
                filterable
                placeholder="支持输入搜索选择"
              >
                <el-option
                  v-for="(item,index) in firstCreditTypes"
                  :key="index"
                  :label="item.itemname"
                  :value="item.itemno"
                ></el-option>
              </el-select>
            </el-form-item>
            <el-form-item
              label="原一押贷款余额(元)"
              v-if="propertyArr[index].onebalance.visible"
              prop="onebalance"
            >
              <el-input
                v-model="propertyForm[index].onebalance"
                :disabled="!propertyArr[index].onebalance.writeAble"
                @blur="propertyForm[index].onebalance = formatMoney(propertyForm[index].onebalance);selguarantycount(index)"
              ></el-input>
            </el-form-item>
            <el-form-item
              label="授信额度"
              v-if="propertyArr[index].creditline.visible"
              prop="creditline"
            >
              <el-input
                v-model="propertyForm[index].creditline"
                :disabled="!propertyArr[index].creditline.writeAble"
                @blur="propertyForm[index].creditline = formatMoney(propertyForm[index].creditline);selguarantycount(index)"
              ></el-input>
            </el-form-item>
            <el-form-item
              label="抵押率"
              v-if="propertyArr[index].mortgagerate.visible"
              prop="mortgagerate"
            >
              <el-input
                v-model="propertyForm[index].mortgagerate"
                :disabled="!propertyArr[index].mortgagerate.writeAble"
              ></el-input>
            </el-form-item>
          </el-form>
          <SelectOwner
            v-if="propertyForm[index].isOwner" 
            :index="index"
            :propertyData="propertyForm[index]"
            @closeDialog="closeDialog" 
            @sendPropertyForm="sendProperty"
          ></SelectOwner>
          <Owner
            v-if="applyInfo.phaseNo>='0040'"
            :index="index"
            :show="propertyArr[index].communityname.writeAble"
            :propertyData="propertyForm[index]"
            :propertyList="propertyForm[index].propertyList"
            @sendPropertyForm="sendPropertyForm"
            @selectOwner='propertyForm[index].isOwner = true'
          ></Owner>
          <Warrant
            v-if="propertyArr[index].propertyCertGroup.visible"
            :writeAble="applyInfo.phaseNo=='0111'"
            :index="index"
            :propertyData="propertyForm[index]"
            @sendPropertyForm="sendPropertyForm"
          ></Warrant>
        </el-tab-pane>
      </el-tabs>
    </div>
    <div :class="[applyInfo.phaseNo >= '0040' ? 'fixedBtn':'btn']">
      <el-button
        size="medium"
        plain
        @click="addProperty"
        v-if="addAndDel"
      >添加物业信息</el-button>
      <el-button
        size="medium"
        plain
        @click="saveDraft(propertyForm)"
        v-if="applyInfo.phaseNo=='0040'||applyInfo.phaseNo=='0010'"
      >保存草稿</el-button>
      <el-button
        size="medium"
        plain
        @click="prevStep"
        v-if="applyInfo.phaseNo=='0040'||applyInfo.phaseNo=='0010'"
      >上一步</el-button>
      <el-button
        size="medium"
        type="primary"
        @click="submit(propertyForm)"
        v-if="applyInfo.phaseNo=='0040'||applyInfo.phaseNo=='0010'"
      >下一步</el-button>
      <el-button 
        size="medium" 
        plain 
        @click="save(propertyForm)" 
        v-if="applyInfo.phaseNo>'0040'&&writeAble">保存</el-button>
      <el-button
        size="medium"
        plain
        @click="prevStep"
        v-if="applyInfo.phaseNo!='0040'&&applyInfo.phaseNo!='0010'"
      >上一页</el-button>
      <el-button
        size="medium"
        type="primary"
        @click="nextPage()"
        v-if="applyInfo.phaseNo!='0040'&&applyInfo.phaseNo!='0010'"
      >下一页</el-button>
    </div>
  </div>
</template>
<script>
import {
  qryHouseList,
  getDictionaryList,
  delHouse,
  saveMultipleHouse,
  submitMultipleHouse,
  getProvinceCodeList,
  getPropertyClassify
} from "@/api/product";
import { setStorage, getStorage } from "@/utils/storage";
import common from "@/utils/common";
import Owner from "@views/product/components/Owner";
import Summary from "@views/product/components/Summary";
import Warrant from "@views/product/components/Warrant";
import SelectOwner from "@views/product/components/SelectOwner";
export default {
  data() {
    return {
      applyInfo:this.$store.state.product.applyInfo,
      applyMenu: this.$store.state.product.applyMenu,
      initialArr: [], //初始数据
      propertyForm: [],
      propertyArr: [],
      provinceList: [],
      propertyTypelist: [],
      propertyClassifys: [],
      rightAgeLimits: [],
      useTypes: [],
      houseuseStatusList: [],
      propertyAgeLimits: [],
      guarantycounts: [],
      firstCreditTypes: [],
      update: false,
      writeAble: false,
      addAndDel: false,
      tabIndex: '0',
      rules: {}
    };
  },
  async created() {
    this.$parent._data.loading = true;
    // 查询物业信息
    const result = await this.getHouseList();
    this.getPropertyData(result);
    // 获取物业类型下拉
    this.propertyTypelist = await this.qryDictionaryList("MortgagePropertyType");
    // 获取物业分类下拉
    this.propertyClassifys = await this.qryDictionaryList("property_classify");
    // 获取权利性质下拉
    this.rightAgeLimits = await this.qryDictionaryList("right_age_limit");
    // 获取土地用途下拉
    this.useTypes = await this.qryDictionaryList("use_type");
    // 获取房屋使用状态下拉
    this.houseuseStatusList = await this.qryDictionaryList("houseuse_status");
    // 获取产权年限下拉
    this.propertyAgeLimits = await this.qryDictionaryList("property_age_limit");
    // 获取一押/二押下拉
    this.guarantycounts = await this.qryDictionaryList("GuarantyCountCode");
    // 获取原一押循环授信类型下拉
    this.firstCreditTypes = await this.qryDictionaryList("first_credit_type");
    // 获取省枚举值
    getProvinceCodeList({}).then(res => {
      this.provinceList = res.result;
    });
    this.$parent._data.loading = false;
  },
  components: {
    Owner,
    Summary,
    Warrant,
    SelectOwner
  },
  methods: {
    // 计算抵押率
    selguarantycount(index){
      // 房产为一押时抵押率=授信额度/evs估值,房产为二押抵押率=(原一押贷款余额-授信额度)/evs估值
      const evsassessment = this.propertyForm[index].evsassessment?JSON.parse(this.propertyForm[index].evsassessment.replace(/,/g,'')):''
      const creditline = this.propertyForm[index].creditline?JSON.parse(this.propertyForm[index].creditline.replace(/,/g,'')):''
      const onebalance = this.propertyForm[index].onebalance?JSON.parse(this.propertyForm[index].onebalance.replace(/,/g,'')):''
      if(this.propertyForm[index].guarantycount == '01'){
        this.propertyForm[index].mortgagerate = (creditline/evsassessment).toFixed(2)
        this.initialArr[index].mortgagerate = (creditline/evsassessment).toFixed(2)
      }else{
        this.propertyForm[index].mortgagerate = ((onebalance+creditline)/evsassessment).toFixed(2)
        this.initialArr[index].mortgagerate = ((onebalance+creditline)/evsassessment).toFixed(2)
      }
    },
    closeDialog(data){
      this.propertyForm[data].isOwner = false
    },
    sendUpdate(val){
      this.update = val
    },
    // 根据物业类型查询物业分类下拉枚举值
    selPropertytype(form){
      getPropertyClassify({propertyClassify:form.propertytype}).then(res=>{
        this.propertyClassifys = res.result
        for (let i = 0; i < this.propertyClassifys.length; i++) {
          if(this.propertyClassifys[i].itemno==form.propertyClassify){
            return
          }
        }
        form.propertyClassify = ''
      })
    },
    // 根据小区,楼栋,房号拼接自动填充房产地址详细地址
    gethouseaddr(form) {
      if (form.communityname && form.buildingno && form.roomno) {
        form.houseaddress = `${form.communityname}-${form.buildingno}-${form.roomno}`;
      }
    },
    // 金额格式化
    formatMoney(value) {
      if (value) {
        value =
          parseFloat((value + "").replace(/[^\d\.-]/g, "")).toFixed(2) + "";
        if (value == "NaN") return;
        let l = value
          .split(".")[0]
          .split("")
          .reverse();
        let r = value.split(".")[1];
        let t = "";
        for (let i = 0; i < l.length; i++) {
          t += l[i] + ((i + 1) % 3 === 0 && i + 1 !== l.length ? "," : "");
        }
        return (
          t
            .split("")
            .reverse()
            .join("") +
          "." +
          r
        );
      }
    },
    // 处理数据,将数据重新排列
    async getPropertyData(result) {
      this.propertyArr = result;
      this.propertyForm = [];
      this.initialArr = [];
      this.propertyArr.forEach((val, index) => {
        // 取数组第一个值作为校验规则
        if (index == 0) {
          for (const key in val) {
            this.rules[key] = [];
            switch (key) {
              case "houseassessment":
                this.rules[key].push(common.validate("number"));
                break;
              default:
                break;
            }
            // 必填校验
            if (val[key].required) {
              this.rules[key].push({
                required: true,
                message: `请输入${val[key].filedDescription}`,
                trigger: "change"
              });
            }
          }
        }
        //将数据重新排列
        const obj = {};
        for (const key in val) {
          delete obj["propertyList"];
          delete obj["propertyCertList"];
          obj[key] = val[key].value;
          // 初始化value为空,金额格式化
          if (
            key == "coveredArea" ||
            key == "evsassessment" ||
            key == "onebalance" ||
            key == "creditline"
          ) {
            obj[key] = this.formatMoney(val[key].value);
          }
          if (
            key != "customername" &&
            key != "certid" &&
            key != "cuscerttype"
          ) {
            val[key].value = "";
          }
        }
        obj.isOwner = false
        // 正常赋值
        this.propertyForm.push(obj);
        // 将每个对象进行浅克隆在赋值
        this.initialArr.push(Object.assign({}, obj));
      });
      // 判断是否可以对表单进行增删改查操作
      this.writeAble = this.propertyArr[0].certificate.writeAble || this.applyInfo.phaseNo == '0111'
      this.addAndDel = this.propertyArr[0].communityname.writeAble
      this.propertyForm.forEach(async (val, index) => {
        this.selguarantycount(index)
        // 根据省获取市
        val.houseprovince
          ? (this.propertyArr[
              index
            ].housecityList = await common.qryCityCodeList(val.houseprovince))
          : "";
        // 根据市获取区
        val.housecity
          ? (this.propertyArr[
              index
            ].housecountyList = await common.qryAreaCodeList(val.housecity))
          : "";
        this.$set(this.propertyArr, index, this.propertyArr[index]);
      });
    },
    // 查询物业信息
    getHouseList() {
      return new Promise(resolve => {
        qryHouseList({
          businessNo: this.applyInfo.serialNo,
          customerId: this.applyInfo.customerid
        }).then(res => {
          resolve(res.result);
        });
      });
    },
    qryDictionaryList(code) {
      return new Promise(resolve => {
        getDictionaryList({
          codeNo: code
        }).then(res => {
          resolve(res.result);
        });
      });
    },
    // 添加物业信息
    addProperty() {
      const validateForm = common.validateForm(this.$refs.propertyForm)
      this.tabIndex = validateForm.index === undefined ? this.tabIndex : '' + validateForm.index
      if(!validateForm.flag)return;
      const obj = {};
      for (const key in this.propertyArr[0]) {
        obj[key] = this.propertyArr[0][key].value;
        delete obj["propertyList"];
      }
      obj.isOwner = false
      this.propertyForm.push(obj);
      this.initialArr.push(Object.assign({},obj))
      this.propertyArr.push(Object.assign({}, this.propertyArr[0]));
      this.tabIndex = `${this.propertyForm.length-1}`
    },
    // 保存接口
    saveMultipleProperty(arr) {
      return new Promise(resolve => {
        saveMultipleHouse({ houseInfoList: arr }).then(res => {
          resolve(res);
        });
      });
    },
    // 提交接口
    submitMultipleProperty(array) {
      return new Promise(resolve => {
        submitMultipleHouse({ houseInfoList: array }).then(res => {
          resolve(res);
        });
      });
    },
    // 物业信息保存并校验数据完整性
    async save(array) {
      const validateForm = common.validateForm(this.$refs.propertyForm)
      this.tabIndex = validateForm.index === undefined ? this.tabIndex : '' + validateForm.index
      if(!validateForm.flag)return;
      for (let i = 0; i < array.length; i++) {
        array[i].applyserialno = this.applyInfo.serialNo;
        if (this.applyInfo.phaseNo >= "0040") {
          if (!array[i].propertyList || !array[i].propertyList.length) {
            this.$message.warning("每个申请单至少填写一个产权人信息");
            return;
          }
          if ((!array[i].propertyCertList || !array[i].propertyCertList.length)&&array[i].propertyCertGroup.visible) {
            this.$message.warning("每个申请单至少填写一个权证信息");
            return;
          }
        }
      }
      this.$parent._data.loading = true;
      const res = await this.saveMultipleProperty(array);
      if (res.code == "00") {
        const result = await this.getHouseList();
        this.getPropertyData(result);
        // 通知子组件更新物业汇总信息
        this.update = true
        this.$message.success("保存成功");
      }
      this.$parent._data.loading = false;
    },
    // 物业信息保存草稿
    async saveDraft(array) {
      // 保存需要校验多个物业的项目名称都是一样的并且项目名称不能为空,最后重新调用查询物业信息渲染页面
      for (let i = 0; i < array.length; i++) {
        array[i].applyserialno = this.applyInfo.serialNo;
      }
      this.$parent._data.loading = true;
      const res = await this.saveMultipleProperty(array);
      if (res.code == "00") {
        const result = await this.getHouseList();
        this.getPropertyData(result);
        this.$message.success("保存成功");
        // 通知子组件更新物业汇总信息
        this.update = true
        // 保存草稿需要调用父组件的查询左侧tab的方法
        this.$parent.getApplyTabTree();
      }
      this.$parent._data.loading = false;
    },
    // 上一步
    prevStep() {
      this.applyMenu.forEach((val, index) => {
        if (val.tabname == "物业信息") {
          common.tabInfo(
            this.applyMenu[index - 1].tabname,
            this.applyInfo.flowno,
            this
          );
        }
      });
    },
    // 下一页
    nextPage() {
      // 调用父组件的查询左侧tab的方法
      this.$parent.updateApplyTabTree('物业信息');
    },
    // 下一步提交并且需要校验每个物业申请单的产权人至少一个
    async submit(array) {
      const validateForm = common.validateForm(this.$refs.propertyForm)
      this.tabIndex = validateForm.index === undefined ? this.tabIndex : '' + validateForm.index
      if(!validateForm.flag)return;
      for (let i = 0; i < array.length; i++) {
        array[i].applyserialno = this.applyInfo.serialNo;
        if (this.applyInfo.phaseNo >= "0040") {
          if (!array[i].propertyList || !array[i].propertyList.length) {
            this.$message.warning("每个申请单至少填写一个产权人信息");
            return;
          }
          if ((!array[i].propertyCertList || !array[i].propertyCertList.length)&&array[i].propertyCertGroup.visible) {
            this.$message.warning("每个申请单至少填写一个权证信息");
            return;
          }
        }
      }
      this.$parent._data.loading = true;
      const res = await this.submitMultipleProperty(array);
      if (res.code == "00") {
        const result = await this.getHouseList();
        this.getPropertyData(result);
        this.nextPage()
      }
      this.$parent._data.loading = false;
    },
    // 删除物业信息
    delProperty(index) {
      if (this.propertyForm[index].serialno) {
        common.comfirm('提示',`请确认是否需要删除物业信息(小区/项目名称:${this.propertyForm[index].communityname},房号/车位号:${this.propertyForm[index].buildingno})?`,()=>{
          delHouse({ serialNo: this.propertyForm[index].serialno }).then(res => {
            if (res.code == "00") {
              this.$message.success("删除成功");
              this.propertyForm.splice(index, 1);
              this.propertyArr.splice(index, 1);
              this.tabIndex = `${ index-1 >= 0 ? index-1 : index }`
            }
          });
        })
      } else {
        this.propertyForm.splice(index, 1);
        this.propertyArr.splice(index, 1);
        this.tabIndex = `${ index-1 >= 0 ? index-1 : index }`
      }
    },
    sendProperty(data){
      this.$set(this.propertyForm,data.index,data)
    },
    sendPropertyForm(data) {
      this.$set(this.propertyForm,data.index,data)
    }
  },
  beforeRouteLeave(to, from, next) {
    for (let i = 0; i < this.propertyForm.length; i++) {
      for (const key in this.propertyForm[i]) {
        if (this.initialArr[i].hasOwnProperty(key)) {
          if (this.propertyForm[i][key] != this.initialArr[i][key]) {
            // 页面有数据未保存
            common.comfirm("提示", "当前页面有数据未保存,是否放弃保存?", () => {
              next();
            });
            return;
          }
        }
      }
    }
    next();
  }
};
</script>