郑永安
2023-06-19 2befd4a5d3733520b69ed97da88e675b6b086a3c
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
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
<template>
    <el-dialog
        :visible.sync="applyFormVisible"
        append-to-body
        :title="title"
        :close-on-click-modal="false"
        width="60%"
    >
        <el-form ref="dataForm" :rules="dataFormRules" :model="dataForm" label-position="right" label-width="140px"  width="600px">
            <div class="enterpriseBasicInformation_title">
                <span>基本信息</span>
            </div>
            <el-divider></el-divider>
            <div>
                <el-row>
                    <el-col :span="10">
                        <el-form-item type="textarea" label="企业名称:" prop="supplyunitname">
                            <el-input v-model="dataForm.supplyunitname" :disabled="true"/>
                        </el-form-item>
                    </el-col>
                    <el-col :span="1">
                        <img src="@/assets/enterprise.png" class="enterpriseBasicInformation_image" @click="showEnterprise"></img>
                    </el-col>
                </el-row>
                <el-row>
                    <el-col :span="10">
                        <el-form-item type="textarea" label="签订地点:" prop="signlocation">
                            <el-input v-model="dataForm.signlocation"/>
                        </el-form-item>
                    </el-col>
                    <el-col :span="10">
                        <el-form-item label="签订时间:" prop="signtime">
                            <el-date-picker
                                value-format="yyyy-MM-dd"
                                v-model="dataForm.signtime"
                                type="date"
                                placeholder="选择日期时间">
                            </el-date-picker>
                        </el-form-item>
                    </el-col>
                </el-row>
            </div>
 
 
 
            <div class="enterpriseBasicInformation_title">
                <span>订货清单</span>
            </div>
            <el-divider></el-divider>
 
            <div>
                <el-row >
                    <el-col :span="6">
                        <el-form-item label="导入产品:"  ref="my-upload">
                            <el-upload
                                class="upload"
                                :action="actionUrlPrefixx+'/contract/'+this.dataForm.supplyenterprisenumber+'/product2json'"
                                :headers="headers"
                                :on-preview="handlePreview"
                                :on-remove="handleRemove"
                                :before-remove="beforeRemove"
                                :limit="1"
                                :before-upload="beforeUpload"
                                :on-exceed="handleExceed"
                                :on-success="handleSuccess"
                                :on-error="handleError"
                                :show-file-list="false"
                                :file-list="fileList">
                                <el-button size="small" type="primary">上传产品</el-button>
                            </el-upload>
                        </el-form-item>
                    </el-col>
 
                    <el-col :span="6">
                        <el-form-item label="参考模板:">
                            <el-button type="text" style="margin-left: 10px;" @click="viewHandle">下载excel</el-button>
                        </el-form-item>
                    </el-col>
                    <el-col :span="6">
                        <el-form-item label="注意事项:" >
                            <span class="tip-important" data-role="time-label">需要上传请先上传产品!</span>
                        </el-form-item>
                    </el-col>
                </el-row>
 
 
                <el-row >
 
                    <el-col :span="6">
                        <el-form-item label="添加产品:" >
                            <el-button class="el-button el-button--primary el-button--small"    @click="addProduct('新增','')">添加产品</el-button>
                        </el-form-item>
                    </el-col>
                    <el-col :span="6">
                        <el-form-item label="清空产品:" >
                            <el-button class="el-button el-button--primary el-button--small"    @click="clearProduct()">清空产品</el-button>
                        </el-form-item>
                    </el-col>
 
 
                </el-row>
                <el-table
                    v-loading="listLoading"
                    :key="tableKey"
                    :data="dataForm.productList"
                    border
                    fit
                    highlight-current-row
                    style="width: 100%;"
                    max-height="400"
                >
                    <el-table-column label="产品名称" prop="name" align="center">
                    </el-table-column>
                    <el-table-column label="流向码" prop="directionCode" align="center" >
                    </el-table-column>
                    <el-table-column label="数量" width="150" prop="num" align="center" >
                        <template slot-scope="scope">
                            <el-input
                                onkeyup="if(this.value.length==1){this.value=this.value.replace(/[^1-9]/g,'')}else{this.value=this.value.replace(/\D/g,'')}"
                                onafterpaste="if(this.value.length==1){this.value=this.value.replace(/[^1-9]/g,'')}else{this.value=this.value.replace(/\D/g,'')}"
                                v-model="scope.row.num"></el-input>
                        </template>
                    </el-table-column>
                    <el-table-column label="单箱进货价" prop="price" align="center" >
                        <template slot-scope="scope">
                            <el-input
                                onkeyup="this.value= this.value.match(/\d+(\.\d{0,2})?/) ? this.value.match(/\d+(\.\d{0,2})?/)[0] : ''"
                                v-model="scope.row.price"></el-input>
                        </template>
                    </el-table-column>
                    <el-table-column label="生产厂家" prop="manufacturer" align="center" >
                    </el-table-column>
                    <el-table-column label="规格" prop="specification" align="center" >
                    </el-table-column>
                    <el-table-column label="含药量" prop="explosiveContent" align="center" >
                    </el-table-column>
                    <el-table-column label="类型" prop="type" align="center" >
                    </el-table-column>
                    <el-table-column label="产品级别" prop="level" align="center" >
                    </el-table-column>
                    <el-table-column label="箱含量(挂)" prop="boxNumber" align="center" >
                    </el-table-column>
                    <el-table-column label="操作" align="center" width="100" class-name="small-padding fixed-width">
                        <template slot-scope="scope">
                            <el-button type="text" @click="deleteProduct(scope.$index)">删除</el-button>
                        </template>
                    </el-table-column>
                </el-table>
            </div>
 
            <div class="enterpriseBasicInformation_title">
                <span>合同内容</span>
            </div>
            <el-divider></el-divider>
 
            <div>
                <el-row style="padding-bottom: 20px;">
                    <el-col :span="20">
                        <span style="font-size: 14px;color: #606266;font-weight: bold">{{"一、本合同按照《中华人民共和国合同法》等有关规定执行。买卖双方应严格遵守《中华人民共和国安全生产法》、《烟花爆竹安全管理条例》等有关法律法规的规定,依法经营,保障安全。"}}</span>
                    </el-col>
 
                </el-row>
                <el-row>
                    <el-col :span="20">
                        <el-form-item label="二、产品质量标准与要求:" prop="qualitystandard">
                            <el-input type="textarea" :rows="2"  v-model="dataForm.qualitystandard"/>
                        </el-form-item>
                    </el-col>
                </el-row>
                <el-row>
                    <el-col :span="20">
                        <el-form-item label="三、禁(限)用药物要求:" prop="prohibiteddrug">
                            <el-input type="textarea" :rows="2"  v-model="dataForm.prohibiteddrug"/>
                        </el-form-item>
                    </el-col>
                </el-row>
                <el-row>
                    <el-col :span="20">
                        <el-form-item label="四、产品包装标准及要求:" prop="packingstandard">
                            <el-input type="textarea" :rows="2"  v-model="dataForm.packingstandard"/>
                        </el-form-item>
                    </el-col>
                </el-row>
                <el-row>
                    <el-col :span="20">
                        <el-form-item label="五、提(交)货时间和地点:" prop="timeandlocation">
                            <el-input type="textarea" :rows="2"  v-model="dataForm.timeandlocation"/>
                        </el-form-item>
                    </el-col>
                </el-row>
                <el-row>
                    <el-col :span="20">
                        <el-form-item label="六、运输方式及费用负担:" prop="transportandcost">
                            <el-input type="textarea" :rows="2"  v-model="dataForm.transportandcost"/>
                        </el-form-item>
                    </el-col>
                </el-row>
                <el-row>
                    <el-col :span="20">
                        <el-form-item label="七、验收标准与方法:" prop="acceptstandard">
                            <el-input type="textarea" :rows="2"  v-model="dataForm.acceptstandard"/>
                        </el-form-item>
                    </el-col>
                </el-row>
                <el-row>
                    <el-col :span="20">
                        <el-form-item label="八、提出异议期限:" prop="objectdeadline">
                            <el-input type="textarea" :rows="2"  v-model="dataForm.objectdeadline"/>
                        </el-form-item>
                    </el-col>
                </el-row>
                <el-row>
                    <el-col :span="20">
                        <el-form-item label="九、结算方式与期限:" prop="settlemethod">
                            <el-input type="textarea" :rows="2"  v-model="dataForm.settlemethod"/>
                        </el-form-item>
                    </el-col>
                </el-row>
                <el-row>
                    <el-col :span="20">
                        <el-form-item label="十、产品安全与质量责任:" prop="productsafetyandquality">
                            <el-input type="textarea" :rows="2"  v-model="dataForm.productsafetyandquality"/>
                        </el-form-item>
                    </el-col>
                </el-row>
                <el-row>
                    <el-col :span="20">
                        <el-form-item label="十一、运输安全责任:" prop="transportsafety">
                            <el-input type="textarea" :rows="2"  v-model="dataForm.transportsafety"/>
                        </el-form-item>
                    </el-col>
                </el-row>
                <el-row>
                    <el-col :span="20">
                        <el-form-item label="十二、违约责任:" prop="breakcontract">
                            <el-input type="textarea" :rows="2"  v-model="dataForm.breakcontract"/>
                        </el-form-item>
                    </el-col>
                </el-row>
                <el-row>
                    <el-col :span="20">
                        <span style="font-size: 14px;color: #606266;font-weight: bold">{{"十三、合同争议的解决方式:本合同在履行过程中发生争议,由双方协商解决,协商不成的,按下列第"}}</span>
                        <el-input v-model="dataForm.contractdisputesfelid" class="applyForm_input"></el-input>
                        <span style="font-size: 14px;color: #606266;font-weight: bold">{{"种方式解决(选择一种):"}}</span>
                    </el-col>
                </el-row>
                <el-row style="padding-left:50px;">
                    <el-col :span="20">
                        <span style="font-size: 14px;color: #606266;font-weight: bold">{{"1、双方同意将争议提交"}}</span>
                        <el-input style="width: 300px" v-model="dataForm.contractdisputesfelidcontent" class="applyForm_input"></el-input>
                        <span style="font-size: 14px;color: #606266;font-weight: bold">{{"仲裁委员会仲裁;"}}</span>
                    </el-col>
                </el-row>
                <el-row style="padding-left:50px;">
                    <el-col :span="20">
                        <span style="font-size: 14px;color: #606266;font-weight: bold">{{"2、依法向人民法院提起诉讼。"}}</span>
                    </el-col>
                </el-row>
                <el-row style="padding-top: 20px">
                    <el-col :span="20">
                        <el-form-item label="十四、其他约定事项(可另附页):" prop="otheragreedmatters ">
                            <el-input type="textarea" :rows="2"  v-model="dataForm.otheragreedmatters "/>
                        </el-form-item>
                    </el-col>
                </el-row>
            </div>
 
            <div class="enterpriseBasicInformation_title">
                <span>购货单位信息</span>
            </div>
            <el-divider></el-divider>
            <el-row>
                <el-col :span="10">
                    <el-form-item  label="可选择已添加的购买单位信息:" class="unit-wrap">
                        <el-button size="small" type="primary" @click="showUnit">选择</el-button>
                    </el-form-item>
                </el-col>
 
            </el-row>
 
            <div>
                <el-row>
                    <el-col :span="10">
                        <el-form-item  label="单位名称:" prop="purchaseunitname">
                            <el-input v-model="dataForm.purchaseunitname"/>
                        </el-form-item>
                    </el-col>
                    <el-col :span="10">
                        <el-form-item  label="许可证编号:" prop="purchaselicensenumber">
                            <el-input v-model="dataForm.purchaselicensenumber"/>
                        </el-form-item>
                    </el-col>
                </el-row>
                <el-row>
                    <el-col :span="10">
                        <el-form-item  label="单位地址" prop="purchaseunitaddress">
                            <el-input v-model="dataForm.purchaseunitaddress"/>
                        </el-form-item>
                    </el-col>
                    <el-col :span="10">
                        <el-form-item  label="邮政编码:" prop="purchasezipcode">
                            <el-input v-model="dataForm.purchasezipcode"/>
                        </el-form-item>
                    </el-col>
                </el-row>
                <el-row>
                    <el-col :span="10">
                        <el-form-item  label="法定代表人:" prop="purchaserepresentative">
                            <el-input v-model="dataForm.purchaserepresentative"/>
                        </el-form-item>
                    </el-col>
                    <el-col :span="10">
                        <el-form-item  label="委托代理人:" prop="purchaseagent">
                            <el-input v-model="dataForm.purchaseagent"/>
                        </el-form-item>
                    </el-col>
                </el-row>
                <el-row>
                    <el-col :span="10">
                        <el-form-item  label="法定代表人联系电话:" prop="purchaserepresentativephone">
                            <el-input v-model="dataForm.purchaserepresentativephone"/>
                        </el-form-item>
                    </el-col>
                    <el-col :span="10">
                        <el-form-item label="委托代理人联系电话:" prop="purchaseagentphone">
                            <el-input v-model="dataForm.purchaseagentphone"/>
                        </el-form-item>
                    </el-col>
                </el-row>
 
                <el-row>
                    <el-col :span="10">
                        <el-form-item  label="法定代表人电子邮箱:" prop="purchaserepresentativeemail">
                            <el-input v-model="dataForm.purchaserepresentativeemail"/>
                        </el-form-item>
                    </el-col>
                    <el-col :span="10">
                        <el-form-item  label="委托代理人电子邮箱:" prop="purchaseagentemail">
                            <el-input v-model="dataForm.purchaseagentemail"/>
                        </el-form-item>
                    </el-col>
                </el-row>
                <el-row>
                    <el-col :span="10">
                        <el-form-item  label="开户银行:" prop="purchasebank">
                            <el-input v-model="dataForm.purchasebank"/>
                        </el-form-item>
                    </el-col>
                    <el-col :span="10">
                        <el-form-item label="账户:" prop="purchaseaccount">
                            <el-input v-model="dataForm.purchaseaccount"/>
                        </el-form-item>
                    </el-col>
                </el-row>
            </div>
 
            <el-form-item label="上传附件:" prop="upload">
                <input id="upload" ref="upload"  type="file"/>
            </el-form-item>
            <el-form-item label="有效期:">
                <el-date-picker
                    value-format="yyyy-MM-dd"
                    v-model="validTime"
                    type="daterange"
                    range-separator="至"
                    start-placeholder="开始日期"
                    end-placeholder="结束日期"
                    @change="giveData"
                >
                </el-date-picker>
            </el-form-item>
 
        </el-form>
        <div  align="right" style="margin-top:10px;">
            <el-button @click="applyFormVisible = false">取消</el-button>
            <el-button type="primary" @click="submitApplyForm()">确认</el-button>
        </div>
        <el-dialog
            :visible.sync="productVisible"
            append-to-body
            :close-on-click-modal="false"
            width="60%"
        >
            <div class="filter-container">
                <el-input v-model="queryProductForm.name" placeholder="产品名称" style="width: 25%;"/>
                <el-input v-model="queryProductForm.directionCode" placeholder="流向码" style="width: 25%;"/>
                <el-select v-model="queryProductForm.type" clearable placeholder="类别">
                    <el-option
                        v-for="item in typeOptions"
                        :key="item.value"
                        :label="item.label"
                        :value="item.value">
                    </el-option>
                </el-select>
                <el-button style="margin-left: 10px;" type="primary" icon="el-icon-search" @click="getProductList"/>
            </div>
            <el-table
                v-loading="listLoading"
                :key="tableKey"
                :data="productData"
                ref="multipleTable"
                border
                fit
                @selection-change="handleSelectionChange"
                :row-key="getRowKey"
                highlight-current-row
                style="width: 100%;"
                max-height="500"
            >
                <el-table-column
                    :reserve-selection="true"
                    type="selection"
                    width="55">
                </el-table-column>
                <el-table-column label="产品名称" prop="name" align="center">
                </el-table-column>
                <el-table-column label="流向码" prop="directionCode" align="center" >
                </el-table-column>
                <el-table-column label="生产厂家" prop="manufacturer" align="center" >
                </el-table-column>
                <el-table-column label="规格" prop="specification" align="center" >
                </el-table-column>
                <el-table-column label="含药量" prop="explosiveContent" align="center" >
                </el-table-column>
                <el-table-column label="类型" prop="type" align="center" >
                </el-table-column>
                <el-table-column label="产品级别" prop="level" align="center" >
                </el-table-column>
            </el-table>
            <br>
            <el-pagination
                v-show="recordTotalProduct>0"
                :current-page="currentPageProduct"
                :page-sizes="[10, 20, 30, 50]"
                :page-size="pageSizeProduct"
                :total="recordTotalProduct"
                layout="total, sizes, prev, pager, next, jumper"
                background
                style="float:right;"
                @size-change="handleSizeChangeProduct"
                @current-change="handleCurrentChangeProduct"
            />
            <br>
            <div  align="right" style="margin-top:30px;">
                <el-button @click="productVisible = false">取消</el-button>
                <el-button type="primary" @click="submitProduct()">确认</el-button>
            </div>
        </el-dialog>
        <select-enterprise ref="selectEnterprise" @getinfo="changeEnterprise"></select-enterprise>
        <unitselect ref="selectUnit" @getinfo="changeUnit"></unitselect>
    </el-dialog>
</template>
 
<script>
import selectEnterprise from "./selectEnterprise";
import unitselect from "./unitselect";
import { createApply ,updateApply} from '@/api/contract'
import {computePageCount} from "../../../../utils";
import { productList } from "@/api/product";
import { getToken } from '@/utils/auth'
const exampleFile = require('@/assets/example/productInfo.xlsx')
export default {
    name: "index",
    data(){
        return{
            title:'',
            tableKey:'',
            validTime:['',''],
            listLoading:false,
            productVisible:false,
            applyFormVisible:false,
            actionUrlPrefixx:process.env.BASE_API,
            dataForm:{
                supplyunitname:'',
                supplyenterprisenumber:'',
                signtime:'',
                signlocation:'',
                purchaseunitname:'',
                purchaselicensenumber:'',
                purchaseunitaddress:'',
                purchasezipcode:'',
                purchaserepresentative:'',
                purchaseagent:'',
                purchaserepresentativephone:'',
                purchaseagentphone:'',
                purchaserepresentativeemail:'',
                purchaseagentemail:'',
                purchasebank:'',
                purchaseaccount:'',
                productList:[],
                file:"",
                validstarttime:'',
                validendtime:'',
                qualitystandard:'',
                prohibiteddrug:'',
                packingstandard:'',
                timeandlocation:'',
                transportandcost:'',
                acceptstandard:'',
                objectdeadline:'',
                settlemethod:'',
                productsafetyandquality:'',
                transportsafety:'',
                breakcontract:'',
                contractdisputesfelid:'',
                contractdisputesfelidcontent:'',
                otheragreedmatters:'',
            },
            dataFormRules:{
                supplyunitname:[
                    { required: true, message: '请选择企业', trigger: 'change' },
                ],
                signlocation:[
                    { required: true, message: '请填写签订地点', trigger: 'blur' },
                ],
                signtime:[
                    { required: true, message: '请填写签订时间', trigger: 'blur' },
                ],
                qualitystandard:[
                    { required: true, message: '请填写', trigger: 'blur' },
                ],
                prohibiteddrug:[
                    { required: true, message: '请填写', trigger: 'blur' },
                ],
                packingstandard:[
                    { required: true, message: '请填写', trigger: 'blur' },
                ],
                timeandlocation:[
                    { required: true, message: '请填写', trigger: 'blur' },
                ],
                transportandcost:[
                    { required: true, message: '请填写', trigger: 'blur' },
                ],
                acceptstandard:[
                    { required: true, message: '请填写', trigger: 'blur' },
                ],
                objectdeadline:[
                    { required: true, message: '请填写', trigger: 'blur' },
                ],
                settlemethod:[
                    { required: true, message: '请填写', trigger: 'blur' },
                ],
                productsafetyandquality:[
                    { required: true, message: '请填写', trigger: 'blur' },
                ],
                transportsafety:[
                    { required: true, message: '请填写', trigger: 'blur' },
                ],
                breakcontract:[
                    { required: true, message: '请填写', trigger: 'blur' },
                ],
                contractdisputesfelid:[
                    { required: true, message: '请填写', trigger: 'blur' },
                ],
                contractdisputesfelidcontent:[
                    { required: true, message: '请填写', trigger: 'blur' },
                ],
                otheragreedmatters:[
                    { required: true, message: '请填写', trigger: 'blur' },
                ],
                purchaseunitname:[
                    { required: true, message: '请填写', trigger: 'blur' },
                ],
                purchaselicensenumber:[
                    { required: true, message: '请填写许可证编号', trigger: 'blur' },
                ],
                purchaseunitaddress:[
                    { required: true, message: '请填写单位地址', trigger: 'blur' },
                ],
                purchasezipcode:[
                    { required: true, message: '请填写邮政编码', trigger: 'blur' },
                ],
                purchaserepresentative:[
                    { required: true, message: '请填写法定代表人', trigger: 'blur' },
                ],
                purchaseagent:[
                    { required: true, message: '请填写委托代理人', trigger: 'blur' },
                ],
                purchaserepresentativephone:[
                    { required: true, message: '请填写法定代表人联系电话', trigger: 'blur' },
                ],
                purchaseagentphone:[
                    { required: true, message: '请填写委托代表人联系电话', trigger: 'blur' },
                ],
                purchaserepresentativeemail:[
                    { required: true, message: '请填写法定代表人电子邮箱', trigger: 'blur' },
                ],
                purchaseagentemail:[
                    { required: true, message: '请填写委托代理人电子邮箱', trigger: 'blur' },
                ],
                purchasebank:[
                    { required: true, message: '请填写委托代理人电子邮箱', trigger: 'blur' },
                ],
                purchaseaccount:[
                    { required: true, message: '请填写委托代理人电子邮箱', trigger: 'blur' },
                ],
            },
            queryProductForm: {
                name: '',
                manufacturer:'',
                directionCode:'',
                type:'',
            },
            passList:[],
            productData:[],
            typeOptions: [{
                value: '爆竹类',
                label: '爆竹类'
            }, {
                value: '单个爆竹类',
                label: '单个爆竹类'
            }, {
                value: '喷花类',
                label: '喷花类'
            }, {
                value: '日景烟花',
                label: '日景烟花'
            }, {
                value: '吐珠类',
                label: '吐珠类'
            }, {
                value: '造型玩具类',
                label: '造型玩具类'
            }, {
                value: '玩具烟花类',
                label: '玩具烟花类'
            }, {
                value: '线香类',
                label: '线香类'
            }, {
                value: '组合类',
                label: '组合类'
            }, {
                value: '组合烟花',
                label: '组合烟花'
            }, {
                value: '组合烟花类',
                label: '组合烟花类'
            }, {
                value: '组合盆花类',
                label: '组合盆花类'
            }, {
                value: '鞭炮类',
                label: '鞭炮类'
            }, {
                value: '火箭类',
                label: '火箭类'
            }, {
                value: '旋转类',
                label: '旋转类'
            }, {
                value: '升空类',
                label: '升空类'
            }, {
                value: '旋转升空类',
                label: '旋转升空类'
            }, {
                value: '冷光类',
                label: '冷光类'
            }, {
                value: '烟雾类',
                label: '烟雾类'
            }, {
                value: '摩擦类',
                label: '摩擦类'
            }, {
                value: '小礼花类',
                label: '小礼花类'
            }, {
                value: '礼花弹类',
                label: '礼花弹类'
            }, {
                value: '架子烟类',
                label: '架子烟类'
            }, {
                value: '引火线',
                label: '引火线'
            }, {
                value: '黑火药',
                label: '黑火药'
            }, {
                value: '烟火药',
                label: '烟火药'
            }, {
                value: '氯酸钾',
                label: '氯酸钾'
            }, {
                value: '精品礼品箱类',
                label: '精品礼品箱类'
            }, {
                value: '彩箱烟花类',
                label: '彩箱烟花类'
            }, {
                value: '玩具类',
                label: '玩具类'
            }, {
                value: '同类组合烟花',
                label: '同类组合烟花'
            }],
            pageSizeProduct: 10,
            currentPageProduct: 1,
            recordTotalProduct: 0,
            pageTotalProduct: 0,
            correct:'',
            fileList:[],
          headers:{   'Authorization':getToken()}
        }
    },
    components:{
        selectEnterprise,
        unitselect
    },
    mounted() {
        this.getProductList()
    },
    methods:{
        showApplyForm(title,value){
                this.$nextTick(()=> {
                    this.$refs["dataForm"].clearValidate()
                })
            this.applyFormVisible = true
            this.title = title
            if(this.title === '新增'){
              this.clearForm();
            }else{
                this.dataForm = value
                this.dataForm.signtime = value.signtime.substr(0,10)
                this.validTime[0] = value.validstarttime.substr(0,10)
                this.validTime[1] = value.validendtime.substr(0,10)
                this.dataForm.validstarttime = value.validstarttime.substr(0,10)
                this.dataForm.validendtime = value.validendtime.substr(0,10)
                this.dataForm.productList = value.productInfoList
            }
        },
 
      showCopyApplyForm(title,value){
        this.$nextTick(()=> {
          this.$refs["dataForm"].clearValidate()
        })
        //1.清空dataForm
        this.clearForm();
        //2.赋值
        this.applyFormVisible = true
        this.title = title
        this.dataForm.purchaseunitname = value[0].purchaseunitname
        this.dataForm.purchaseunitaddress = value[0].purchaseunitaddress
        this.dataForm.purchaserepresentative= value[0].purchaserepresentative
        this.dataForm.purchaserepresentativephone= value[0].purchaserepresentativephone
        this.dataForm.purchaserepresentativeemail= value[0].purchaserepresentativeemail
        this.dataForm.purchasebank= value[0].purchasebank
        this.dataForm.purchaselicensenumber= value[0].purchaselicensenumber
        this.dataForm.purchasezipcode= value[0].purchasezipcode
        this.dataForm.purchaseagent= value[0].purchaseagent
        this.dataForm.purchaseagentphone= value[0].purchaseagentphone
        this.dataForm.purchaseagentemail= value[0].purchaseagentemail
        this.dataForm.purchaseaccount= value[0].purchaseaccount
        this.dataForm.purchaseenterprisenumber = value[0].purchaseenterprisenumber
 
        this.dataForm.supplyenterprisenumber = value[0].supplyenterprisenumber
        this.dataForm.supplyunitname= value[0].supplyunitname
 
        this.dataForm.signlocation = value[0].signlocation
 
        this.dataForm.qualitystandard = value[0].qualitystandard
        this.dataForm.prohibiteddrug= value[0].prohibiteddrug
        this.dataForm.packingstandard= value[0].packingstandard
        this.dataForm.timeandlocation= value[0].timeandlocation
        this.dataForm.transportandcost= value[0].transportandcost
        this.dataForm.acceptstandard= value[0].acceptstandard
        this.dataForm.objectdeadline= value[0].objectdeadline
        this.dataForm.settlemethod= value[0].settlemethod
        this.dataForm.productsafetyandquality= value[0].productsafetyandquality
        this.dataForm.transportsafety= value[0].transportsafety
        this.dataForm.breakcontract= value[0].breakcontract
        this.dataForm.contractdisputesfelid= value[0].contractdisputesfelid
        this.dataForm.contractdisputesfelidcontent= value[0].contractdisputesfelidcontent
        this.dataForm.otheragreedmatters= value[0].otheragreedmatters
 
        this.dataForm.productList = value[0].productInfoList
      },
 
      clearForm(){
        this.dataForm = {
          id:'',
          supplyunitname:'',
          supplyenterprisenumber:'',
          signtime:'',
          signlocation:'',
          purchaseunitname:'',
          purchaselicensenumber:'',
          purchaseunitaddress:'',
          purchasezipcode:'',
          purchaserepresentative:'',
          purchaseagent:'',
          purchaserepresentativephone:'',
          purchaseagentphone:'',
          purchaserepresentativeemail:'',
          purchaseagentemail:'',
          purchasebank:'',
          purchaseaccount:'',
          productList:[],
          file:[],
          validstarttime:'',
          validendtime:'',
          qualitystandard:'',
          prohibiteddrug:'',
          packingstandard:'',
          timeandlocation:'',
          transportandcost:'',
          acceptstandard:'',
          objectdeadline:'',
          settlemethod:'',
          productsafetyandquality:'',
          transportsafety:'',
          breakcontract:'',
          contractdisputesfelid:'',
          contractdisputesfelidcontent:'',
          otheragreedmatters:'',
        }
        //有效期置空
        this.validTime = []
      },
        async submitApplyForm(){
 
                this.$refs["dataForm"].validate((valid) =>{
                    if(valid){
                        this.correct = true
                    }else{
                        this.correct = false
                    }
                })
 
          //检查单子中的产品列表的数量,列和不超过5k,单产品总挂数不超过10w
          {
            let boxnumTotal = this.dataForm.productList.reduce((total,curProduct) => parseInt(total) + parseInt(curProduct.num),0)
            if(boxnumTotal > 5000) {
              this.$message({
                type:'warning',
                message:"所有产品的总箱数不能超过5000," +"现在总箱数为:"+boxnumTotal
              })
              return
            }
 
            for (let i = 0; i < this.dataForm.productList.length; i++) {
              let productInfo = this.dataForm.productList[i]
              let num = parseInt(productInfo.num) * parseInt(productInfo.boxNumber)
              if ( num > 100000) {
                this.$message({
                  type:'warning',
                  message:"单产品的总数不能超过100000," + productInfo.name + "的总数为:"+num
                })
                return
              }
            }
          }
 
 
 
            if(this.correct === true){
                if(this.title === '新增' || this.title === '快速创建'){
                    this.dataForm.productList = JSON.stringify(this.dataForm.productList)
                    this.dataForm.file = this.$refs["upload"].files[0]
                    const formData = new FormData();
                    for (const i in this.dataForm) {
                        if (
                            this.dataForm[i] != undefined &&
                            this.dataForm[i].toString() != ""
                        ) {
                            formData.append(i, this.dataForm[i]);
                        }
                    }
                    this.dataForm.productList = JSON.parse(this.dataForm.productList)
                    let res = await createApply(formData)
                    if(res.data.code === '200'){
                        this.applyFormVisible = false
                        this.$emit('getinfo')
                        this.$notify({
                            title:'成功',
                            duration:2000,
                            message:'新增成功',
                            type:'success'
                        })
                    }else{
                        this.$message({
                            type:'warning',
                            message:res.data.message
                        })
                    }
                    this.$refs.upload.value = []
                }else {
                    this.$delete(this.dataForm,'productInfoList')
                    this.$delete(this.dataForm,'contractFile')
                    this.dataForm.productList = JSON.stringify(this.dataForm.productList)
                    this.dataForm.file = this.$refs["upload"].files[0]
                    const formData = new FormData();
                    for (const i in this.dataForm) {
                        if (
                            this.dataForm[i] != undefined &&
                            this.dataForm[i].toString() != ""
                        ) {
                            formData.append(i, this.dataForm[i]);
                        }
                    }
                    this.dataForm.productList = JSON.parse(this.dataForm.productList)
                    let res = await updateApply(formData)
                    if (res.data.code === '200') {
                        this.applyFormVisible = false
                        this.$emit('getinfo')
                        this.$notify({
                            title: '成功',
                            duration: 2000,
                            message: '修改成功',
                            type: 'success'
                        })
                    } else {
                        this.$message({
                            type: 'warning',
                            message: res.data.message
                        })
                    }
                    this.$refs.upload.value = []
                }
            }else{
                this.$notify({
                    title:'警告',
                    message:'请完善基本信息',
                    type:'warning'
                })
            }
        },
        submitProduct(){
           //1.保留第一次选择所有的 产品
           //2.后选的补入前选的产品列表
          let productLength = this.dataForm.productList.length
          if (productLength > 0) {
            this.dataForm.productList.forEach(item=>{
              for (let ii = 0; ii < this.passList.length; ii++) {
                if (this.passList[ii].id === item.id) {
                  this.passList.splice(ii,1)
                }
              }
            })
          }
          this.dataForm.productList = this.dataForm.productList.concat(this.passList)
            this.productVisible = false
        },
        deleteProduct(index){
            this.dataForm.productList.splice(index,1)
        },
        showEnterprise(){
            this.$refs.selectEnterprise.showEnterPrise(this.safetySuperVisionList)
        },
          showUnit(){
            this.$refs.selectUnit.showEnterPrise(this.safetySuperVisionList)
          },
        changeEnterprise(val){
            this.dataForm.supplyenterprisenumber = val.enterprisenumber
            this.dataForm.supplyunitname = val.enterprisename
        },
      changeUnit(val){
        this.dataForm.purchaseunitname = val.unitname
        this.dataForm.purchaseunitaddress = val.unitaddress
        this.dataForm.purchaserepresentative = val.representative
        this.dataForm.purchaserepresentativephone = val.representativephone
        this.dataForm.purchaserepresentativeemail = val.representativeemail
        this.dataForm.purchasebank = val.bank
        this.dataForm.purchaselicensenumber = val.licensenumber
        this.dataForm.purchasezipcode = val.zipcode
        this.dataForm.purchaseagent = val.agent
        this.dataForm.purchaseagentphone = val.agentphone
        this.dataForm.purchaseagentemail = val.agentemail
        this.dataForm.purchaseaccount = val.account
 
      },
        async getProductList(value){
            this.listLoading = true
            const params = {}
            params['pageIndex'] = this.currentPageProduct
            params['pageSize'] = this.pageSizeProduct
            params['isOld'] = 0
            for (const i in this.queryProductForm) {
                if (this.queryProductForm[i] != undefined && this.queryProductForm[i].toString() != '') {
                    params[i] = this.queryProductForm[i]
                }
            }
            let res = await productList(params)
            if(res.data.code === '200'){
                this.recordTotalProduct = res.data.result.totalCount;
                this.pageSizeProduct = res.data.result.pageSize;
                this.pageTotalProduct = computePageCount(res.data.result.totalCount, res.data.result.pageSize);
                this.currentPageProduct = res.data.result.pageIndex;
                this.productData = res.data.result.result
                setTimeout(() =>{
                    if(value === '清空'){
                        this.$refs.multipleTable.clearSelection()
                    }
                    this.$refs.multipleTable.data = this.productData
                    for( let i = 0;i<this.dataForm.productList.length;i++){
                        for(let j=0;j<this.productData.length;j++){
                            if(this.dataForm.productList[i].directionCode === this.productData[j].directionCode){
                                this.$refs.multipleTable.toggleRowSelection(this.$refs.multipleTable.data[j],true);
                            }
                        }
                    }
                })
            }else{
                this.$message({
                    type:'warning',
                    message:res.data.message
                })
            }
            this.listLoading = false
        },
        addProduct(){
            if(this.dataForm.supplyunitname === '' || this.dataForm.supplyunitname === null){
                this.$message({
                    type:'warning',
                    message:'请选择企业'
                })
            }else{
                this.queryProductForm.manufacturer = this.dataForm.supplyunitname
                this.getProductList('清空')
                this.productVisible = true
            }
        },
 
      beforeUpload(file){
        const fileSuffix = file.name.substring(file.name.lastIndexOf(".") + 1);
 
        const whiteList = ["xls", "xlsx"];
 
        if (whiteList.indexOf(fileSuffix) === -1) {
          this.$message.warning("上传文件只能是 xls、xlsx格式", "error");
          return false;
        }
        if(this.dataForm.supplyunitname === '' || this.dataForm.supplyunitname === null){
          this.$message({
            type:'warning',
            message:'请选择企业'
          })
          return false;
        }
 
      },
      viewHandle(){
        window.open(exampleFile, '_blank')
      },
      clearProduct(){
        this.dataForm.productList = []
      },
 
        handleSizeChangeProduct(val){
            this.pageSizeProduct = val
            this.currentPageProduct = 1
            this.getProductList()
        },
        handleCurrentChangeProduct(val){
            this.currentPageProduct = val
            this.getProductList()
        },
        handleSelectionChange(val){
            this.passList = val
        },
        giveData(){
            if(this.validTime ===null){
                this.dataForm.validstarttime = ""
                this.dataForm.validendtime = ""
            }else{
                this.dataForm.validstarttime = this.validTime[0]
                this.dataForm.validendtime = this.validTime[1]
            }
        },
        getRowKey(row){
            return row.id
        },
      handleRemove(file, fileList) {
        if (file && file.status==="success") {
            this.dataForm.productList = []
            return this.$confirm(`已清空产品信息`);
        }
      },
      handlePreview(file) {
      },
      handleExceed(files, fileList) {
        this.$message.warning(`当前限制选择 1个文件,本次选择了 ${files.length} 个文件`);
      },
      beforeRemove(file, fileList) {
        if (file && file.status==="success") {
          //移除方法
          return this.$confirm(`确定移除 ${ file.name },并清空产品信息吗?`);
        }
      },
      handleSuccess(response, file, fileList) {
 
 
        if (response.code == '200') {
          this.dataForm.productList = response.result
          this.$notify({
            title: '成功',
            duration: 2000,
            message: '上传成功',
            type: 'success'
          })
          this.fileList = []
        }else{
          this.$message.warning(response.message);
          this.fileList = []
        }
      },
      handleError(response, file, fileList) {
        this.fileList = []
      },
 
    }
}
</script>
 
<style scoped>
.enterpriseBasicInformation_title{
    font-weight: bolder;
    font-size: large;
    text-align: center;
    margin-top: 24px;
}
/deep/.el-form-item__label {
    text-align: center;
    width: 150px;
}
.applyForm_input{
    width:50px;
}
.enterpriseBasicInformation_image{
    width:70%;
    height:70%;
    margin-left:10px;
}
    .tip-important{
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
        border-radius: 3px;
        margin: 2px 4px 0 0;
        padding: 0px 14px;
        color: #fff;
        background-color: #e62412;
        display: inline-block;
        height: 28px;
        line-height: 29px;
        font-size: 14px;
    }
    /deep/.unit-wrap>.el-form-item__label{
        width:200px !important;
        margin-left: 28px;
    }
 
</style>