FUYU
2023-12-13 4488f711dbc01a8db6753907cae2ef4021dede68
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
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616
2617
2618
2619
2620
2621
2622
2623
2624
2625
2626
2627
2628
2629
2630
2631
2632
2633
2634
2635
2636
2637
2638
2639
2640
2641
2642
2643
2644
2645
2646
2647
2648
2649
2650
2651
2652
2653
2654
2655
2656
2657
2658
2659
2660
2661
2662
2663
2664
2665
2666
2667
2668
2669
2670
2671
2672
2673
2674
2675
2676
2677
2678
2679
2680
2681
2682
2683
2684
2685
2686
2687
2688
2689
2690
2691
2692
2693
2694
2695
2696
2697
2698
2699
2700
2701
2702
2703
2704
2705
2706
2707
2708
2709
2710
2711
2712
2713
2714
2715
2716
2717
2718
2719
2720
2721
2722
2723
2724
2725
2726
2727
2728
2729
2730
2731
2732
2733
2734
2735
2736
2737
2738
2739
2740
2741
2742
2743
2744
2745
2746
2747
2748
2749
2750
2751
2752
2753
2754
2755
2756
2757
2758
2759
2760
2761
2762
2763
2764
2765
2766
2767
2768
2769
2770
2771
2772
2773
2774
2775
2776
2777
2778
2779
2780
2781
2782
2783
2784
2785
2786
2787
2788
2789
2790
2791
2792
2793
2794
2795
2796
2797
2798
2799
2800
2801
2802
2803
2804
2805
2806
2807
2808
2809
2810
2811
2812
2813
2814
2815
2816
2817
2818
2819
2820
2821
2822
2823
2824
2825
2826
2827
2828
2829
2830
2831
2832
2833
2834
2835
2836
2837
2838
2839
2840
2841
2842
2843
2844
2845
2846
2847
2848
2849
2850
2851
2852
2853
2854
2855
2856
2857
2858
2859
2860
2861
2862
2863
2864
2865
2866
2867
2868
2869
2870
2871
2872
2873
2874
2875
2876
2877
2878
2879
2880
2881
2882
2883
2884
2885
2886
2887
2888
2889
2890
2891
2892
2893
2894
2895
2896
2897
2898
2899
2900
2901
2902
2903
2904
2905
2906
2907
2908
2909
2910
2911
2912
2913
2914
2915
2916
2917
2918
2919
2920
2921
2922
2923
2924
2925
2926
2927
2928
2929
2930
2931
2932
2933
2934
2935
2936
2937
2938
2939
2940
2941
2942
2943
2944
2945
2946
2947
2948
2949
2950
2951
2952
2953
2954
2955
2956
2957
2958
2959
2960
2961
2962
2963
2964
2965
2966
2967
2968
2969
2970
2971
2972
2973
2974
2975
2976
2977
2978
2979
2980
2981
2982
2983
2984
2985
2986
2987
2988
2989
2990
2991
2992
2993
2994
2995
2996
2997
2998
2999
3000
3001
3002
3003
3004
3005
3006
3007
3008
3009
3010
3011
3012
3013
3014
3015
3016
3017
3018
3019
3020
3021
3022
3023
3024
3025
3026
3027
3028
3029
3030
3031
3032
3033
3034
3035
3036
3037
3038
3039
3040
3041
3042
3043
3044
3045
3046
3047
3048
3049
3050
3051
3052
3053
3054
3055
3056
3057
3058
3059
3060
3061
3062
3063
3064
3065
3066
3067
3068
3069
3070
3071
3072
3073
3074
3075
3076
3077
3078
3079
3080
3081
3082
3083
3084
3085
3086
3087
3088
3089
3090
3091
3092
3093
3094
3095
3096
3097
3098
3099
3100
3101
3102
3103
3104
3105
3106
3107
3108
3109
3110
3111
3112
3113
3114
3115
3116
3117
3118
3119
3120
3121
3122
3123
3124
3125
3126
3127
3128
3129
3130
3131
3132
3133
3134
3135
3136
3137
3138
3139
3140
3141
3142
3143
3144
3145
3146
3147
3148
3149
3150
3151
3152
3153
3154
3155
3156
3157
3158
3159
3160
3161
3162
3163
3164
3165
3166
3167
3168
3169
3170
3171
3172
3173
3174
3175
3176
3177
3178
3179
3180
3181
3182
3183
3184
3185
3186
3187
3188
3189
3190
3191
3192
3193
3194
3195
3196
3197
3198
3199
3200
3201
3202
3203
3204
3205
3206
3207
3208
3209
3210
3211
3212
3213
3214
3215
3216
3217
3218
3219
3220
3221
3222
3223
3224
3225
3226
3227
3228
3229
3230
3231
3232
3233
3234
3235
3236
3237
3238
3239
3240
3241
3242
3243
3244
3245
3246
3247
3248
3249
3250
3251
3252
3253
3254
3255
3256
3257
3258
3259
3260
3261
3262
3263
3264
3265
3266
3267
3268
3269
3270
3271
3272
3273
3274
3275
3276
3277
3278
3279
3280
3281
3282
3283
3284
3285
3286
3287
3288
3289
3290
3291
3292
3293
3294
3295
3296
3297
3298
3299
3300
3301
3302
3303
3304
3305
3306
3307
3308
3309
3310
3311
3312
3313
3314
3315
3316
3317
3318
3319
3320
3321
3322
3323
3324
3325
3326
3327
3328
3329
3330
3331
3332
3333
3334
3335
3336
3337
3338
3339
3340
3341
3342
3343
3344
3345
3346
3347
const initSearchFormProduct = [{
    label: "产品型号",
    type: "text",
    name: "Asset_Model_No__c",
    isInput: true
},
{
    label: "产品名称",
    type: "text",
    name: "Name__c",
    isInput: true
}
]
export var arrTempsss = [];
export var arrProductTempsss = [];
export var NewDefaultDatass = [];
export var AddProductDatass = [];
export var jzDataFixedPriceTemps = [];
export var jzDataDiscountTemps = [];
export var DeftCopyQtyLists = [];
export var jzDataDefaultExp = [];
export var jzDataProductExp = [];
export var jzDataFixedPriceExp = [];
export var jzDataDiscountExp = [];
export var jzDataDefaultCopyQuantityListExp = [];
export var newArrsTemp3Exp = [];
export var newArrsTemp4Exp = [];
export var jzDataDefaultCopyExp = [];
export var newArrsTempExp = [];
export var newArrsTemp2Exp = [];
export var booleanExp = 0;
export var boolean2Exp = false;
export var boolean3Exp = false;
export var dataExp = [];
export var newDataExp = [];
export var newData2Exp = [];
export var newData3Exp = [];
export var editnewDateExp = [];
export var GuaranteeDiscount__cZuiXiaoExp =0;
export var NormalDiscount__cZuiXiaoExp =0;
export var CompareFullDataExp =[];
export var HeTongTotalExp =[];
export var SelectedFnDataFixedPriceExp = [];
export var idsExp = [];
export var CompareFullDataTempExp = [];
export var jzDataDefaultNotChangeExp = [];
export var iflagExp = false;
export var falgExp = false;
export var newTempExp = [];
export var ifnullExp = true;
export var isChangeExp;
export var buttonIsShowE;
export var initDTFP;
export var initDTD;
export var initDTOD;
export var initDTC;
 
 
 
 
export function GetName() {
}
//=======更新促销方案次数数据逻辑
export function updatesNumsLogic(jzDataFixedPriceTemp,jzDataDiscountTemp,CompareFullData) {
    CompareFullData.forEach(item => {
        if (item.ListName == "价格政策") {
            var filterTemp = jzDataFixedPriceTemp.filter(fItem => {
                if (fItem.Id == item.Id) {
                    return true;
                } else {
                    return false;
                }
            })
            if (filterTemp != undefined || filterTemp.length > 0) {
                var fileterTempObject = {
                    ...{},
                    ...filterTemp[0]
                };
                fileterTempObject.Counts = item.num;
                jzDataFixedPriceTemp = jzDataFixedPriceTemp.map(element => {
                    if (element.Id == fileterTempObject.Id) {
                        element = fileterTempObject;
                    } else {
                        let elementTemp = {
                            ...{},
                            ...element
                        };
                        element = elementTemp;
                    }
                    return element;
                });
            }
        }
        if (item.ListName == "折扣政策") {
            var filterTemp = jzDataDiscountTemp.filter(fItem => {
                if (fItem.Id == item.Id) {
                    return true;
                } else {
                    return false;
                }
            })
            if (filterTemp != undefined || filterTemp.length > 0) {
                var fileterTempObject = {
                    ...{},
                    ...filterTemp[0]
                };
                fileterTempObject.Counts = item.num;
                jzDataDiscountTemp = jzDataDiscountTemp.map(element => {
                    if (element.Id == fileterTempObject.Id) {
                        element = fileterTempObject;
                    } else {
                        let elementTemp = {
                            ...{},
                            ...element
                        };
                        element = elementTemp;
                    }
                    return element;
                });
            }
        }
    })
    jzDataFixedPriceTemps = jzDataFixedPriceTemp;
    jzDataDiscountTemps = jzDataDiscountTemp;
}
//反算折扣时修改折扣政策逻辑
export function ReverseCalculationModifyDiscountLogic(arrTemp1,arrProductTemp,Id,Category__c,GuaranteeDiscount__c_Input, NormalDiscount__c_Input,GuaranteeDiscount_H_Money__c, NormalDiscount_H_Money__c, item){
    //price和
    var sumListCount = 0;
    //nod和
    var sumNodCount = 0;
    //特约折扣nod和list合
    var sumListAndNod = 0;
    //含多年保产品list
    var ObjectProducList=[];
    //不含多年保产品list
    var NotObjectProducList=[];
    //折扣
    var NormalDisN = 0;
    var NormalDisG = 0;
    var distinguish = 0;
    var distinguish2 = 0;
    arrProductTemp.forEach(itemss => {
        if(itemss.recordTypeName__c=="Authorizer"){
            if (itemss.PromotionId==Id&&
                itemss.NormalDiscount__c_Input == NormalDiscount__c_Input &&
                itemss.GuaranteeDiscount__c_Input == GuaranteeDiscount__c_Input) {
                if(itemss.warrantyType__c=="市场多年保修"){
                    sumListAndNod +=itemss.Quantity *(itemss.ListPrice+itemss.ServicePrice__c);
                    ObjectProducList.push(itemss);
                }else if(itemss.warrantyType__c!="市场多年保修"){
                    sumListCount += itemss.Quantity * itemss.ListPrice;
                    sumNodCount += itemss.Quantity * itemss.ServicePrice__c;
                    NotObjectProducList.push(itemss);
                }
            }
        }else{
            if (itemss.NormalDiscount__c_Input == NormalDiscount__c_Input &&
                itemss.Category__c == Category__c) {
                sumListCount += itemss.Quantity * itemss.ListPrice;
                sumNodCount += itemss.Quantity * itemss.ServicePrice__c;
            }
        }
    });
   if (sumListCount != 0||sumListAndNod!=0) {
       if(item.JxsType=='一般折扣'||NotObjectProducList.length!=0){
            NormalDisN = ((NormalDiscount_H_Money__c - sumNodCount) / sumListCount * 100).toFixed(2);
            if(item.JxsType!='一般折扣'){
                if(item.NormalDiscount__c!=undefined&&item.NormalDiscount__c!=''){
                    var NormalDiscount__cc=parseFloat(item.NormalDiscount__c);
                    if(NormalDisN<NormalDiscount__cc){
                        distinguish=1;
                    }
                }
            }else if(NormalDisN<0){
                distinguish=3;
            }
       }
       debugger
       if(ObjectProducList.length!=0){
            NormalDisG =(GuaranteeDiscount_H_Money__c/sumListAndNod*100).toFixed(2);
            if(item.GuaranteeDiscount__c!=undefined&&item.GuaranteeDiscount__c!=''){
                var GuaranteeDiscount__cc=parseFloat(item.GuaranteeDiscount__c);
                if(NormalDisG<GuaranteeDiscount__cc){
                    distinguish2 = 2;
                }
            }
       }
        arrTemp1.forEach(arrte => {
            if (item.JxsType=="一般折扣") {
                if(arrte.NormalDiscount__c_Input == NormalDiscount__c_Input &&
                    arrte.Category__c == Category__c){
                        if(distinguish==1||distinguish==3){
                            arrte.NormalDiscount_H_Money__c = arrte.NormalDiscount_H_Money_yuan;
                            item.NormalDiscount_H_Money__c = item.NormalDiscount_H_Money_yuan;
                        }else{
                            arrte.NormalDiscount__c_Input = NormalDisN+'%';
                            item.NormalDiscount__c_Input = NormalDisN+'%';
                        }
                }
            }else if(item.JxsType=="特约折扣"){
                if(arrte.Id==Id&&
                    arrte.NormalDiscount__c_Input == NormalDiscount__c_Input &&
                    arrte.GuaranteeDiscount__c_Input == GuaranteeDiscount__c_Input){
                        
                        if(distinguish2==2||distinguish==1||distinguish==3){
                                arrte.NormalDiscount_H_Money__c = arrte.NormalDiscount_H_Money_yuan;
                                item.NormalDiscount_H_Money__c = item.NormalDiscount_H_Money_yuan;
                                arrte.GuaranteeDiscount_H_Money__c = arrte.GuaranteeDiscount_H_Money_yuan;
                                item.GuaranteeDiscount_H_Money__c = item.GuaranteeDiscount_H_Money_yuan;
                        }else{
                            if(NormalDisN!=0){
                                arrte.NormalDiscount__c_Input = NormalDisN+'%';
                                item.NormalDiscount__c_Input = NormalDisN+'%';
                            }
                            if(NormalDisG!=0){
                                arrte.GuaranteeDiscount__c_Input = NormalDisG+'%';
                                item.GuaranteeDiscount__c_Input = NormalDisG+'%';
                            }
                        }
                }
            }
        });
        if(distinguish!=1&&distinguish2!=2&&distinguish!=3){
            arrProductTemp.forEach(arrpt => {
                if(arrpt.recordTypeName__c=="Authorizer"){
                    if(arrpt.PromotionId==Id&&
                        arrpt.NormalDiscount__c_Input == NormalDiscount__c_Input &&
                        arrpt.GuaranteeDiscount__c_Input == GuaranteeDiscount__c_Input){
                            if(NormalDisN!=0){
                                arrpt.NormalDiscount__c_Input = NormalDisN+'%';
                            }
                            if(NormalDisG!=0){
                                arrpt.GuaranteeDiscount__c_Input = NormalDisG+'%';
                            }
                    }
                }else{
                    if (arrpt.NormalDiscount__c_Input == NormalDiscount__c_Input &&
                        arrpt.Category__c == Category__c) {
                        arrpt.NormalDiscount__c_Input = NormalDisN+'%';
                    }
                }
            });
        }
        arrTempsss =arrTemp1;
        arrProductTempsss = arrProductTemp;
    }
    debugger
    if(distinguish==1&&distinguish2!=2){
        return 1;
    }else if(distinguish!=1&&distinguish2==2){
        return 2;
    }else if(distinguish==1&&distinguish2==2){
        return 12;
    }else if(distinguish==3){
        return 3;
    }else{
        return item;
    }
}
//反算折扣提示信息
export function InverseCalculationTiShi(ffgg,GuaranteeDiscount__cZuiXiao,NormalDiscount__cZuiXiao){
    if(ffgg==1){
        return "修改错误,非对象品折扣不得小于非对象品最低折扣:"+NormalDiscount__cZuiXiao+"%";
    }else if(ffgg==2){
        return "修改错误,对象品折扣不得小于对象品最低折扣:"+GuaranteeDiscount__cZuiXiao+"%";
    }else if(ffgg==12){
        return "修改错误,对象品折扣不得小于对象品最低折扣:"+GuaranteeDiscount__cZuiXiao+"%"+",且非对象品折扣不得小于非对象品最低折扣:"+NormalDiscount__cZuiXiao+"%";
    }else if(ffgg==3){
        return "修改错误,非对象品折扣不得小于0";
    }else{
        return "数据修改成功";
    }
}
//合同价格汇总逻辑
export function ContractPriceComputeLogic(sum,jzDataProductList,jzDataDiscountList,jzDataFixedPriceList){
    var DataDiscount = []; //折扣政策产品明细
    jzDataProductList.forEach(jdpd => {
        jzDataDiscountList.forEach(jddp => {
            var PromotionHeadRecordId = jddp.recordTypeName__c;
            if (PromotionHeadRecordId == "Authorizer") {
                if (jdpd.PromotionId == jddp.Id && //方案Id
                    jddp.NormalDiscount__c_Input == jdpd.NormalDiscount__c_Input && //非对象品折扣录入
                    jddp.GuaranteeDiscount__c_Input == jdpd.GuaranteeDiscount__c_Input) { //对象品折扣录入
                    DataDiscount.push(jdpd);
                }
            } else {
                if (jddp.NormalDiscount__c_Input == jdpd.NormalDiscount__c_Input && //非对象品折扣录入
                    jddp.Category__c == jdpd.Category__c) { //折扣政策分类
                    DataDiscount.push(jdpd);
                }
            }
        });
    });
    DataDiscount.forEach(jjc => {
        jjc.AgencySubtotal__c = parseFloat(jjc.AgencySubtotal__c)
        sum = sum + jjc.AgencySubtotal__c;
    });
    jzDataFixedPriceList.forEach(jzdfp => {
        var HeTongTotals = parseFloat(jzdfp.HeTongTotal)
        if (jzdfp.HeTongTotal == undefined || jzdfp.HeTongTotal == "") {
            HeTongTotals = 0;
        }
        sum = sum + HeTongTotals;
    });
    sum = Math.round(sum * 100) / 100;
    return sum;
}
 //计算过后特约折扣的合同价格
 export function SpecialPriceComputeReverse(DataDiscount,fag){
    var sum=0;
    var sum1=0
    DataDiscount.forEach(jjc => {
        if(jjc.warrantyType__c=="市场多年保修"){
            jjc.AgencySubtotal__c = parseFloat(jjc.AgencySubtotal__c)
            sum = sum + jjc.AgencySubtotal__c;
            sum=parseFloat(sum.toFixed(2));
        }
        if(jjc.warrantyType__c!="市场多年保修"){
            jjc.AgencySubtotal__c = parseFloat(jjc.AgencySubtotal__c)
            sum1 = sum1 + jjc.AgencySubtotal__c;
            sum1=parseFloat(sum1.toFixed(2));
        }
    });
    if(fag){
        return sum;
    }else{
        return sum1;
    }
}
//更改一般折扣合同价格计算合同总价逻辑
export function GeneralDiscountContractSummaryLogic(sum,jzDataDiscountList,jzDataFixedPriceList){
    jzDataDiscountList.forEach(jddp => {
        var HeTongPrice = parseFloat(jddp.HeTongPrice)
        if (jddp.HeTongPrice == undefined || jddp.HeTongPrice == "") {
            HeTongPrice = 0;
        }
        sum =sum + HeTongPrice;
    });
    jzDataFixedPriceList.forEach(jzdfp =>{
        var HeTongTotals = parseFloat(jzdfp.HeTongTotal)
        if (jzdfp.HeTongTotal == undefined || jzdfp.HeTongTotal == "") {
            HeTongTotals = 0;
        }
        sum =sum + HeTongTotals;
    });
    sum = Math.round(sum * 100) / 100;
    return sum;
}
//折扣政策匹配规则部分逻辑
//SelectedData 选中的数据  IdStr 选中的数据Id CompareId 方案中用到的uuid
export function SpecialSavesChangePartLogic(jzDataDefaultList,SaveName, SelectedData, IdStr, CompareId,DefalutQuantity,newDicountData,jzDataDiscountList){
    var NewDefaultData = [];
    var AddProductData = [];
    jzDataDefaultList.forEach(defaultItem => { //待选产品
        var defaultItemTemp = {
            ...{},
            ...defaultItem
        };
        var SelectedList = SelectedData.itemss.filter(items => {
            if (items.Id == defaultItem.Id) {
                return true;
            } else {
                return false;
            }
        })
        if (SelectedList != undefined && SelectedList.length > 0) {
            var SelectedListDataTemp = {
                ...{},
                ...SelectedList[0]
            };
            SelectedListDataTemp.PromotionNo__c = SelectedData.PromotionNo__c;
            SelectedListDataTemp.Name = SelectedData.Name;
            SelectedListDataTemp.TypeName = "折扣政策";
            SelectedListDataTemp.PromotionId = IdStr;
            if (SaveName == "一般折扣") {
                SelectedListDataTemp.NormalDiscount__c_Input = SelectedData.NormalDiscount__c_Input;
            } else {
                SelectedListDataTemp.NormalDiscount__c_Input = SelectedData.NormalDiscount__c;
            }
            SelectedListDataTemp.GuaranteeDiscount__c_Input = SelectedData.GuaranteeDiscount__c;
            SelectedListDataTemp.Category__c = SelectedData.Category__c;
            SelectedListDataTemp.CompareId = CompareId;
            SelectedListDataTemp.Quantity = SelectedListDataTemp.SplitQuantity;
            if (defaultItemTemp.Quantity != SelectedListDataTemp.Quantity) {
                defaultItemTemp.Quantity = defaultItemTemp.Quantity - SelectedListDataTemp.Quantity;
                DefalutQuantity += defaultItemTemp.Quantity;
                NewDefaultData.push(defaultItemTemp);
                AddProductData.push(SelectedListDataTemp);
            } else {
                DefalutQuantity += SelectedListDataTemp.Quantity;
                AddProductData.push(SelectedListDataTemp);
                return
            }
        } else {
            NewDefaultData.push(defaultItemTemp);
        }
    })
    NewDefaultDatass=NewDefaultData;
    AddProductDatass=AddProductData;
     //添加数量
    jzDataDiscountList.forEach(disItem => { //折扣政策
         var newTemp = {
             ...{},
             ...disItem
         };
         if (newTemp.Id == IdStr) {
             newTemp.Counts = DefalutQuantity;
         }
         newDicountData.push(newTemp);
    })
    return newDicountData;
}
//折扣政策合同价格汇总逻辑
export function HeTongPriceComputeLogic(jzdateList,jzDataProductList){
    var HeTongPriceList = [];
    jzdateList.forEach(jddp => {
        var sum = 0;
        var sumNor = 0;
        var sumGua = 0;
        var PromotionHeadRecordId = jddp.recordTypeName__c;
        jzDataProductList.forEach(jdpd => {
            if (PromotionHeadRecordId == "Authorizer") {
                if (jddp.Id == jdpd.PromotionId && //方案Id
                    jddp.NormalDiscount__c_Input == jdpd.NormalDiscount__c_Input && //非对象品折扣录入
                    jddp.GuaranteeDiscount__c_Input == jdpd.GuaranteeDiscount__c_Input) { //对象品折扣录入 
                        if(jdpd.warrantyType__c=="市场多年保修"){
                            sumGua = sumGua +jdpd.AgencySubtotal__c;
                        }else if(jdpd.warrantyType__c!="市场多年保修"){
                            sumNor = sumNor +jdpd.AgencySubtotal__c;
                        }
                    sum = sum + jdpd.AgencySubtotal__c;
                }
            } else {
                if (jddp.NormalDiscount__c_Input == jdpd.NormalDiscount__c_Input && //非对象品折扣录入
                    jddp.Category__c == jdpd.Category__c) { //折扣政策分类
                    sum = sum + jdpd.AgencySubtotal__c;
                }
            }
        });
        sum = Math.round(sum * 100) / 100;
        sumGua = Math.round(sumGua * 100) / 100;
        sumNor = Math.round(sumNor * 100) / 100;
        jddp.HeTongPrice = sum;
        if(PromotionHeadRecordId == "Authorizer"){
            jddp.GuaranteeDiscount_H_Money__c = sumGua;
            jddp.NormalDiscount_H_Money__c = sumNor;
        }else{
            jddp.NormalDiscount_H_Money__c = sum;
        }
        HeTongPriceList.push(jddp);
    });
    return HeTongPriceList;
}
//价格策合并明细逻辑
export function PriceConsolidation(arrSchemes,jzdataList){
    arrSchemes.forEach(arrsch=>{
        var Setmap=new Map();
        var arrList=[];
        jzdataList.forEach(jdpd=>{
            if(arrsch.Id==jdpd.PromotionId){
                var object={};
                if(Setmap.has(jdpd.Id)){
                    object={...{},...Setmap.get(jdpd.Id)};
                    object.Quantity=object.Quantity+jdpd.Quantity;
                    Setmap.set(jdpd.Id,object);
                }else{
                    Setmap.set(jdpd.Id,jdpd);
                }
            }else{
                arrList.push(jdpd);
            }
        });
        for (let [k, v] of Setmap) {
            arrList.push(v);
        }
        // jzdataList=[...[],...arrList];//20230214
        jzdataList = [].concat(arrList);//20230214
    });
    return jzdataList;
}
 //合并折扣政策重复方案逻辑
export function  ConsolidatedDiscountPolicyLogic(SchemeSet,arr){
    var Setmap=new Map();
    var arr2=SchemeSet;
    arr2.forEach(arrs=>{
        var object={};
        var PromotionHeadRecordId = arrs.recordTypeName__c;
        if(PromotionHeadRecordId == "Authorizer"){
            var key=arrs.Id+"_"+arrs.NormalDiscount__c_Input+"_"+arrs.GuaranteeDiscount__c_Input;//方案Id/非对象品折扣录入/对象品折扣录入
            if(Setmap.has(key)){
                object={...{},...Setmap.get(key)};
                object.determine='';
                arrs.HeTongPrice=Number(arrs.HeTongPrice);
                object.HeTongPrice=Number(object.HeTongPrice);
                object.HeTongPrice +=arrs.HeTongPrice;
                arrs.GuaranteeDiscount_H_Money__c=Number(arrs.GuaranteeDiscount_H_Money__c);
                object.GuaranteeDiscount_H_Money__c=Number(object.GuaranteeDiscount_H_Money__c);
                object.GuaranteeDiscount_H_Money__c +=arrs.GuaranteeDiscount_H_Money__c;
                arrs.NormalDiscount_H_Money__c=Number(arrs.NormalDiscount_H_Money__c);
                object.NormalDiscount_H_Money__c=Number(object.NormalDiscount_H_Money__c);
                object.NormalDiscount_H_Money__c +=arrs.NormalDiscount_H_Money__c;
                Setmap.set(key,object);
            }else{
                Setmap.set(key,arrs);
            }
        }else{
            var key=arrs.NormalDiscount__c_Input+"_"+arrs.Category__c;//非对象品折扣录入、折扣政策分类
            if(Setmap.has(key)){
                object={...{},...Setmap.get(key)};
                object.determine='';
                arrs.HeTongPrice=Number(arrs.NormalDiscount_H_Money__c);
                object.HeTongPrice=Number(object.HeTongPrice);
                object.HeTongPrice +=arrs.HeTongPrice;
                arrs.NormalDiscount_H_Money__c=Number(arrs.NormalDiscount_H_Money__c);
                object.NormalDiscount_H_Money__c=Number(object.NormalDiscount_H_Money__c);
                object.NormalDiscount_H_Money__c +=arrs.NormalDiscount_H_Money__c;
                
                Setmap.set(key,object);
            }else{
                Setmap.set(key,arrs);
            }
        }
    });
    for (let [k, v] of Setmap) {
            arr.push(v);
    }
    return arr;
}
//合并折扣政策产品明细逻辑
export function ConsolidatedDiscountDetailsLogic(arrSchemes,jzdataList){
    arrSchemes.forEach(arrsch=>{
        var Setmap=new Map();
        var arrList=[];
        jzdataList.forEach(jdpd=>{
            var PromotionHeadRecordId = arrsch.recordTypeName__c;
            if(PromotionHeadRecordId == "Authorizer"){
                if(arrsch.Id==jdpd.PromotionId&&//方案Id
                    arrsch.NormalDiscount__c_Input==jdpd.NormalDiscount__c_Input&&//非对象品折扣录入
                    arrsch.GuaranteeDiscount__c_Input==jdpd.GuaranteeDiscount__c_Input){//对象品折扣录入
                    var object={};
                    if(Setmap.has(jdpd.Id)){
                        object={...{},...Setmap.get(jdpd.Id)};
                        object.Quantity=object.Quantity+jdpd.Quantity;
                        Setmap.set(jdpd.Id,object);
                    }else{
                        Setmap.set(jdpd.Id,jdpd);
                    }
                }else{
                    arrList.push(jdpd);
                }
            }else{
                if(arrsch.NormalDiscount__c_Input==jdpd.NormalDiscount__c_Input&&//非对象品折扣录入
                   arrsch.Category__c==jdpd.Category__c){//折扣政策分类
                    var object={};
                    if(Setmap.has(jdpd.Id)){
                        object={...{},...Setmap.get(jdpd.Id)};
                        object.Quantity=object.Quantity+jdpd.Quantity;
                        Setmap.set(jdpd.Id,object);
                    }else{
                        Setmap.set(jdpd.Id,jdpd);
                    }
                }else{
                    arrList.push(jdpd);
                }
            }
        });
        for (let [k, v] of Setmap) {
            arrList.push(v);
        }
        // jzdataList=[...[],...arrList];//20230214
        jzdataList = [].concat(arrList);//20230214
    });
    return jzdataList;
}
//合并上一次的报价行的逻辑
export function addOfferLogic(TrialLine){
    var Offermap=new Map();
    var arr=[];
    var arr2=TrialLine;
    arr2.forEach(arrs=>{
        var object={};
        if(Offermap.has(arrs.Id)){
            object={...{},...Offermap.get(arrs.Id)};
            object.Quantity=object.Quantity+arrs.Quantity;
            Offermap.set(arrs.Id,object);
        }else{
            Offermap.set(arrs.Id,arrs);
        }
    });
    for (let [k, v] of Offermap) {
            arr.push(v);
    }
    return arr;
}
// ==============生成UUID
export function GetUUID() {
    var s = [];
    var hexDigits = "0123456789abcdef";
    for (var i = 0; i < 36; i++) {
        s[i] = hexDigits.substr(Math.floor(Math.random() * 0x10), 1);
    }
    s[14] = "4"; // bits 12-15 of the time_hi_and_version field to 0010
    s[19] = hexDigits.substr((s[19] & 0x3) | 0x8, 1); // bits 6-7 of the clock_seq_hi_and_reserved to 01
    s[8] = s[13] = s[18] = s[23] = "-";
    var uuid = s.join("");
    return uuid;
}
//一般产品部分逻辑
export function partGeneralDiscountLogical(itemsss,item){
    itemsss.AgencySubtotal__c = itemsss.AgencyUnitPrice__c * itemsss.Quantity;
    itemsss.AgencySubtotal__c = Math.round(itemsss.AgencySubtotal__c * 100) / 100;
    itemsss.AgencyUnitPrice__c = Math.round(itemsss.AgencyUnitPrice__c * 100) / 100;
    itemsss.NoDiscountTotal__c = itemsss.ServicePrice__c * itemsss.Quantity;
    itemsss.UseCount__c = item.Counts;
    itemsss.ifNecessary__c = item.ifNecessary__c;
    itemsss.recordTypeName__c = item.recordTypeName__c;
    return itemsss;
}
//促销方案部分逻辑
export function partPromotionSchemeLogical(itemsss,item,multiYearWarranty__c){
    debugger
    if(multiYearWarranty__c){
        itemsss.AgencyUnitPrice__c = (item.HeTongTotal / item.Counts) * (itemsss.ListPrice / item.sumListPrice);
    }else{
        itemsss.AgencyUnitPrice__c = ((item.HeTongTotal / item.Counts) - item.sumNoDiscount) * (itemsss.ListPrice / item.sumListPrice) + itemsss.ServicePrice__c;
    }
    itemsss.AgencySubtotal__c = itemsss.AgencyUnitPrice__c * itemsss.Quantity;
    itemsss.AgencySubtotal__c = Math.round(itemsss.AgencySubtotal__c * 100) / 100;
    itemsss.AgencyUnitPrice__c = Math.round(itemsss.AgencyUnitPrice__c * 100) / 100;
    itemsss.NoDiscountTotal__c = itemsss.ServicePrice__c * itemsss.Quantity;
    itemsss.UseCount__c = item.Counts;
    itemsss.if_Fix__c = item.if_Fix__c;
    itemsss.if_Contain_Nod__c = item.if_Contain_Nod__c;
    itemsss.recordTypeName__c = item.recordTypeName__c;
    return itemsss;
}
//一般折扣计算逻辑
export function commonlyDiscountLogic(itemss,item){
    var Discount__c_Input = parseFloat(item.NormalDiscount__c_Input)*0.01;
    debugger
    itemss.AgencyUnitPrice__c = itemss.ListPrice * (Discount__c_Input) + itemss.ServicePrice__c;
    itemss.AgencySubtotal__c = itemss.AgencyUnitPrice__c * itemss.Quantity;
    itemss.AgencySubtotal__c = Math.round(itemss.AgencySubtotal__c * 100) / 100;
    itemss.AgencyUnitPrice__c = Math.round(itemss.AgencyUnitPrice__c * 100) / 100;
    itemss.NoDiscountTotal__c = itemss.ServicePrice__c * itemss.Quantity;
    itemss.Discount__c_Input = item.NormalDiscount__c_Input;
    itemss.Category__c=item.Category__c;
    return itemss
}
//特约折扣计算逻辑
export function contributingDiscountLogic(itemss,Discount__c_Input,item){
    if (itemss.warrantyType__c=="市场多年保修") {
        itemss.AgencyUnitPrice__c = (itemss.ListPrice + itemss.ServicePrice__c) * (Discount__c_Input*0.01);
    } else {
        itemss.AgencyUnitPrice__c = itemss.ListPrice * (Discount__c_Input*0.01) + itemss.ServicePrice__c;
    }
    itemss.AgencySubtotal__c = itemss.AgencyUnitPrice__c * itemss.Quantity;
    itemss.AgencySubtotal__c = Math.round(itemss.AgencySubtotal__c * 100) / 100;
    itemss.AgencyUnitPrice__c = Math.round(itemss.AgencyUnitPrice__c * 100) / 100;
    itemss.NoDiscountTotal__c = itemss.ServicePrice__c * itemss.Quantity;
    debugger
    itemss.Discount__c_Input = Discount__c_Input+"%";
    // itemss.Discount__c_Input = Discount__c_Input;
    itemss.GuaranteeDiscount__c_Input=item.GuaranteeDiscount__c_Input;
    itemss.NormalDiscount__c_Input=item.NormalDiscount__c_Input;
    itemss.recordTypeName__c = item.recordTypeName__c;
    return itemss
}
//计算价格政策的最大次数逻辑
export function ComputationalLogic(Pricepolicy,b,selectproducts){
    var num=0;
    var flag=true;
    for(var j=0;j<b.length;j++){
        if(b[j].Id_H==Pricepolicy.PromotionNo__c){
            var fg=true;
            for(var i=0;i<selectproducts.length;i++){
                if(b[j].Asset_Model_No__c==selectproducts[i].Product2.MDM_Model_No__c){
                    var frequency = parseInt(selectproducts[i].Quantity/b[j].Quantity__c__c);
                    if(frequency<1){
                        fg=true;
                        break;
                    }else{
                        if(flag){
                            num=frequency;
                            flag=false;
                        }else{
                            if(num>frequency){
                                num=frequency;
                            }
                        }
                    }
                    fg=false;
                }
            }
            if(fg){
                num=0;
                break;
            }
        }
    }
    var Counts = Number(Pricepolicy.Counts);
    return Counts+num;
}
//替换listprice单价逻辑
export function ReplacementUnitPriceLogic(arr,ifTrade){
    arr.forEach(jdpct => { //产品明细
        if (ifTrade == "内貿") {
            jdpct.ListPrice = jdpct.Product2.Intra_Trade_List_RMB__c;
            if (jdpct.multiYearWarranty__c) {
                jdpct.ServicePrice__c = jdpct.Product2.Intra_Trade_Service_RMB__c;
            } else {
                jdpct.ServicePrice__c = 0;
            }
        } else if (ifTrade == "外貿") {
            jdpct.ListPrice = jdpct.Product2.Foreign_Trade_List_US__c;
            if (jdpct.multiYearWarranty__c) {
                jdpct.ServicePrice__c = jdpct.Product2.NoDiscount_Foreign__c;
            } else {
                jdpct.ServicePrice__c = 0;
            }
        }
    });
    return arr
}
//合并方案
export function ConsolidationScheme(data,ParamIdStr,Trade__c){
    var NewData = [];
    data.forEach(itms => { //价格政策和折和折扣政策
        let Temp = {};
        Temp.itemCounts = itms.Counts + "";
        Temp.Id = itms.Id;
        Temp.JxsType = itms.JxsType;
        //促销方案
        if (itms.JxsType != "一般折扣") {
            var PromotionHeadRecordId = itms.recordTypeName__c;
            //tt
            if (itms.JxsType == "特约折扣") {
                Temp.GuaranteeDiscountcInput = parseFloat(itms.GuaranteeDiscount__c_Input);
                Temp.GuaranteeDiscountc = parseFloat(itms.GuaranteeDiscount__c);
                Temp.NormalDiscountc = parseFloat(itms.NormalDiscount__c);
                Temp.NormalDiscountcInput = parseFloat(itms.NormalDiscount__c_Input);
            }
        }else{
            //tt
            Temp.NormalDiscountcInput = parseFloat(itms.NormalDiscount__c_Input);
        }
        if (PromotionHeadRecordId == 'Promotion') {
            Temp.Categoryc = '促销方案';
        }
        //一般产品
        else if (PromotionHeadRecordId == 'NormalProduct') {
            Temp.Categoryc = '一般产品';
        }
        //特约固定
        else if (PromotionHeadRecordId == 'Authorizer') {
            Temp.Categoryc = '经销商固定折扣';
        } else {
            Temp.Categoryc = itms.Category__c;
        }
        Temp.PromotionNocEqual = itms.PromotionNo__cEqual;
        Temp.typess = itms.typess;
        Temp.PromotionNoc = itms.PromotionNo__c;
        Temp.Name = itms.Name;
        Temp.ParamIdStr = ParamIdStr;
        Temp.Descriptionc = itms.Description__c;
        Temp.ifContainNodc = itms.if_Contain_Nod__c;
        Temp.ifFixc = itms.if_Fix__c;
        Temp.PriceCNYc = itms.Price_CNY__c;
        Temp.Total = itms.Total;
 
        Temp.ListPriceTotalc = itms.sumListPrice;
        Temp.sumNod = itms.sumNoDiscount;
        //    Temp.sumNodUSD=itms.sumNodUSD;
        Temp.HeTongTotal = itms.HeTongTotal;
        Temp.ifNecessaryc = itms.ifNecessary__c;
        Temp.Trade = Trade__c;
        Temp.maxCounts = itms.maxCounts;
        Temp.CompareId = itms.CompareId;
        Temp.sumNoDiscountTotal = itms.sumNoDiscountTotal;
        Temp.GuaranteeDiscountHMoneyc = itms.GuaranteeDiscount_H_Money__c;
        Temp.NormalDiscountHMoneyc = itms.NormalDiscount_H_Money__c;
        //...c/compent
        NewData.push(Temp);
    });
    return NewData;
}
//待选产品数据变化字段赋值
export function ProductAssignmentSelect(item){
    item.Quantity = item.Quantity__c;
    item.Name = item.Name__c;
    item.Name__c = item.Name_c__c;
    item.ListPrice = item.ListPrice__c;
    item.Id = item.QuoteTrialKey__c;
    item.PromotionId = item.Promotion_id__c;
    item.TypeName = item.TypeName__c;
    item.RecordTypeId = item.RecordTypeId__c;
    item.ParamIdStr = item.QuantityId__c;
    item.Product2Id = item.Product2__c;
    item.QuiteLineitem__c = item.QuiteLineitem__c;
    return item;
}
//已选产品数据变化字段赋值
export function ProductSelected(item){
    item.Quantity = item.Quantity__c;
    item.Name = item.Name__c;
    item.Name__c = item.Name_c__c;
    item.ListPrice = item.ListPrice__c;
    item.Id = item.QuoteTrialKey__c;
    item.Product2Id = item.Product2__c;
    item.Product2 = item.Product2__r;
    if (item.Name == "一般折扣") {
        item.PromotionId = item.PromotionSales__c;
        // item.GuaranteeDiscount__c_Input = item.GuaranteeDiscountcInput__c;
        // item.Discount__c_Input = item.DiscountRate__c;
        item.Discount__c_Input = item.DiscountRate__c+'%';
        // item.NormalDiscount__c_Input = item.NormalDiscountcInput__c
        item.NormalDiscount__c_Input = item.NormalDiscountcInput__c+'%';
    } else {
        item.PromotionId = item.Promotion_id__c;
        if(item.TypeName__c != "价格政策"){
            // item.GuaranteeDiscount__c_Input = item.GuaranteeDiscountcInput__c;
            item.GuaranteeDiscount__c_Input = item.GuaranteeDiscountcInput__c+'%';
            // item.Discount__c_Input = item.DiscountRate__c;
            item.Discount__c_Input = item.DiscountRate__c+'%';
            // item.NormalDiscount__c_Input = item.NormalDiscountcInput__c;
            item.NormalDiscount__c_Input = item.NormalDiscountcInput__c+'%';
        // item.GuaranteeDiscount__c_Input=Number(item.GuaranteeDiscount__c_Input.toFixed(2));
        }
    }
    item.warrantyType__c=item.GuranteeType__c;
    item.TypeName = item.TypeName__c;
    item.RecordTypeId = item.RecordTypeId__c;
    item.ParamIdStr = item.QuantityId__c;
    item.QuiteLineitem__c = item.QuiteLineitem__c;
    item.CompareId = item.CompareId__c;
    // item.Discount__c_Input=Number(item.Discount__c_Input.toFixed(2));
    // item.NormalDiscount__c_Input = item.NormalDiscountcInput__c;
    // item.NormalDiscount__c_Input=Number(item.NormalDiscount__c_Input.toFixed(2));
    return item;
}
//折扣方案数据变化字段赋值
export function UnselectedScheme(items){
    items.JxsType = items.JxsType__c;
    // items.NormalDiscount__c_Input = items.NormalDiscount_c_Input__c;
    items.NormalDiscount__c_Input=items.NormalDiscount_c_Input__c+'%';
    // items.NormalDiscount__c_Input=Number(items.NormalDiscount__c_Input.toFixed(2));
    items.TypeName = items.TypeName__c;
    if (items.JxsType__c != "一般折扣") {
        items.Id = items.PromotionHead__c;
        // items.NormalDiscount__c = items.NormalDiscountc__c;
        items.NormalDiscount__c=items.NormalDiscountc__c+'%';
        // items.NormalDiscount__c=Number(items.NormalDiscount__c.toFixed(2));
        // items.GuaranteeDiscount__c = items.GuaranteeDiscount__c;
        items.GuaranteeDiscount__c=items.GuaranteeDiscount__c+'%';
        // items.GuaranteeDiscount__c=Number(items.GuaranteeDiscount__c.toFixed(2));
        // items.GuaranteeDiscount__c_Input = items.GuaranteeDiscount_c_Input__c;
        items.GuaranteeDiscount__c_Input=items.GuaranteeDiscount_c_Input__c+'%';
        // items.GuaranteeDiscount__c_Input=Number(items.GuaranteeDiscount__c_Input.toFixed(2));
        
    }
    // else{
        // items.NormalDiscount__c = items.NormalDiscountc__c;
        // items.NormalDiscount__c=items.NormalDiscountc__c+'%';
        // items.NormalDiscount__c=Number(items.NormalDiscount__c.toFixed(2));
        // items.GuaranteeDiscount__c = items.GuaranteeDiscount__c;
        // items.GuaranteeDiscount__c=Number(items.GuaranteeDiscount__c.toFixed(2));
        // items.GuaranteeDiscount__c_Input = items.GuaranteeDiscount_c_Input__c;
        // items.GuaranteeDiscount__c_Input=Number(items.GuaranteeDiscount__c_Input.toFixed(2));
    // }
    items.ParamIdStr = items.Quote__c;
    items.sumNoDiscountTotal = items.sumNoDiscountTotal__c;
    items.maxCounts = items.maxCounts__c;
    items.CompareId = items.CompareId__c;
    return items;
}
//循环判断空
export function IfCopyProperties(x){
    debugger
    if(x.Asset_Model_No__c==undefined){
        x.Asset_Model_No__c='';
    }
    if(x.Name_c__c==undefined){
        x.Name_c__c='';
    }
    if(x.Quantity__c==undefined){
        x.Quantity__c='';
    }
    if(x.GuranteeType__c==undefined){
        x.GuranteeType__c='';
    }
    if(x.PromotionNo__c==undefined){
        x.PromotionNo__c='';
    }
    if(x.Name__c==undefined){
        x.Name__c='';
    }
    if(x.ListPrice__c==undefined){
        x.ListPrice__c='';
    }
    if(x.NoDiscountTotal__c==undefined){
        x.NoDiscountTotal__c='';
    }
    if(x.DiscountRate__c==undefined){
        x.DiscountRate__c='';
    }
    if(x.AgencyUnitPrice__c==undefined){
        x.AgencyUnitPrice__c='';
    }
    if(x.AgencySubtotal__c==undefined){
        x.AgencySubtotal__c='';
    }
    return x;
}
//价格方案数据变化字段赋值
export function SelectedScheme(items){
    items.Counts = items.itemCounts__c;
    items.Total = items.Price_total__c;
    items.HeTongTotal = items.contractPrice__c;
    items.TypeName = items.TypeName__c;
    items.Id = items.PromotionHead__c;
    items.ParamIdStr = items.Quote__c;
    if (items.trade__c == "内貿") {
        items.sumListPrice = items.ListPriceTotal__c;
        items.sumNoDiscount = items.NodiscountTotal__c;
    } else if (items.trade__c == "外貿") {
        items.sumListPrice = items.ListPriceTotalUSD__c;
        items.sumNoDiscount = items.NodiscountTotalUSD__c;
    }
    items.sumNoDiscountTotal = items.sumNoDiscountTotal__c;
    items.maxCounts = items.maxCounts__c;
    return items;
}
 
//合并产品
export function MergeProducts(arr3,arr4,data,ParamIdStr){
    var NewData1 = [];
    var newTemp3 = [];
    arr3.forEach(itmsss => { //产品明细
        var itemTemp = {
            ...{},
            ...itmsss
        };
        // itemTemp.分类名称(根据 产品状态  1) 0未匹配 2)1以匹配)
        itemTemp.ismatch = '1';
        newTemp3.push(itemTemp);
    });
    var newTemp4 = [];
    arr4.forEach(itmsss => { //待选产品
        var itemTemp = {
            ...{},
            ...itmsss
        };
        // itemTemp.分类名称(根据 产品状态  1) 0未匹配 2)1以匹配)
        itemTemp.ismatch = '0';
        newTemp4.push(itemTemp);
    });
    // var data2 = [...newTemp3, ...newTemp4];//20230213
    var data2 = newTemp3.concat(newTemp4);//20230213
    data2.forEach(itmss => { //产品明细和待选产品
        let Temp1 = {};
        Temp1.Id = itmss.Id;
        Temp1.AssetModelNoc = itmss.Asset_Model_No__c;
        Temp1.Namec = itmss.Name__c;
        Temp1.Quantity = itmss.Quantity;
        Temp1.GuranteeTypec = itmss.warrantyType__c;
        Temp1.PromotionNoc = itmss.PromotionNo__c;
        Temp1.Name = itmss.Name;
        Temp1.ListPrice = itmss.ListPrice;
        Temp1.AgencyUnitPricec = itmss.AgencyUnitPrice__c;
        Temp1.AgencySubtotalc = itmss.AgencySubtotal__c;
        Temp1.NoDiscountTotalc = itmss.NoDiscountTotal__c;
        Temp1.ParamIdStr =ParamIdStr;
        Temp1.TypeName = itmss.TypeName;
        Temp1.UseCountc = itmss.UseCount__c;
        if (itmss.TypeName == "价格政策") {
            data.forEach(itemsss => {
                if (itemsss.PromotionNo__c == itemsss.PromotionNo__c) {
                    Temp1.fanan_id = itemsss.Id;
                }
            });
        } else if (itmss.TypeName == "折扣政策") {
            data.forEach(itemss => {
                if (itemss.PromotionNo__c == itemss.PromotionNo__c) {
                    Temp1.fanan_id = itemss.Id;
                }
            });
            
            Temp1.DiscountcInput = parseFloat(itmss.Discount__c_Input);
            if(itmss.Name=="一般折扣"){
                Temp1.NormalDiscountcInput = parseFloat(itmss.NormalDiscount__c_Input);
            }else{
                Temp1.GuaranteeDiscountcInput = parseFloat(itmss.GuaranteeDiscount__c_Input);
                Temp1.NormalDiscountcInput = parseFloat(itmss.NormalDiscount__c_Input);
            }
        }
        Temp1.ismatch = itmss.ismatch;
        Temp1.PromotionId = itmss.PromotionId;
        Temp1.Product2c = itmss.Product2Id;
        Temp1.ServicePricec = itmss.ServicePrice__c;
        Temp1.ifFixc = itmss.if_Fix__c;
        Temp1.ifNecessaryc = itmss.ifNecessary__c;
        Temp1.CompareId = itmss.CompareId;
        Temp1.multiYearWarrantyc = itmss.multiYearWarranty__c;
        Temp1.Categoryc = itmss.Category__c;
        
        NewData1.push(Temp1);
    });
    return NewData1;
}
// //方案需要更新的字段
export function ChangeFiexedData(key) {
    var keyArr = ['Status__c', 'ifNecessary__c', 'OrderNo__c', 'Price_CNY__c', 'Price_USD__c'];
    var flag = false;
    keyArr.forEach(item => {
        if (item == key) {
            flag = true;
        }
    })
    return flag;
}
export function getQueryVariable(variable,location) { //id字符串
    debugger
    var query = window.location.search.substring(1);
    if(!query){
        query = location;
    }
    var vars = query.split("&");
    for (var i = 0; i < vars.length; i++) {
        var pair = vars[i].split("=");
        if (pair[0] == variable) {
            return pair[1];
        }
    }
    return '';
}
//跳转路径
export function  PathJump(DeveloperName,ParamIdStr){
    if(DeveloperName=='Opportunity'){
        // 测试非完整路径是不是可以正确跳转
        window.open('/apex/NewQuoteEntry?id=' + ParamIdStr, '_self');
    }else if(DeveloperName=='SI_Oppor'){
        // 测试非完整路径是不是可以正确跳转
        window.open('/apex/SI_NewQuoteEntry?id=' + ParamIdStr, '_self');
    }
}
//计算过后一般折扣的合同价格
export function ContractPriceComputeReverse(DataDiscount){
    var sum=0;
    DataDiscount.forEach(jjc => {
        jjc.AgencySubtotal__c = parseFloat(jjc.AgencySubtotal__c)
        sum = sum + jjc.AgencySubtotal__c;
    });
    sum=sum.toFixed(2);
    return sum;
}
//复制逻辑
export function copyLogic(Check_Your_Clipboard,records,x,targetString,reslut){
    records=reslut;
    for (var i = 0; i < records.length; i++) {
        x = records[i];
        //判断空
        x=IfCopyProperties(x);
        targetString += '\r\n' + x.    Asset_Model_No__c + '\t' + x.Name_c__c + '\t' + x.Quantity__c + '\t' + x.GuranteeType__c + '\t' + x.PromotionNo__c +'\t' + x.Name__c + '\t' + x.ListPrice__c + '\t' + x.NoDiscountTotal__c + '\t' + x.DiscountRate__c +
            '\t' + x.AgencyUnitPrice__c + '\t' + x.AgencySubtotal__c ;
        console.warn(x.PromotionNo__c);
    }
    try {
        console.warn(targetString);
        var tag = document.createElement('textarea');
        tag.setAttribute('id', 'cp_hgz_textarea');
        var strlenght=targetString.replace(/[\u0000-\u007f]/g,"a").replace(/[\u0080-\u07ff]/g,"aa").replace(/[\u0800-\uffff]/g,"aaa").length;
        tag.maxLength=strlenght+666;
        tag.value = targetString;
        document.getElementsByTagName('body')[0].appendChild(tag);
        document.getElementById('cp_hgz_textarea').select();
        document.execCommand('copy');
        document.getElementById('cp_hgz_textarea').remove();
        alert(Check_Your_Clipboard);
    } catch (error) {
        alert(error);
    }
}
//一般折扣更改过合同价格计算逻辑
export function updateCDLogic(Id,JxsType,GuaranteeDiscount__c_Input,NormalDiscount__c_Input,Category__c,jzDataDiscount,arrProductTemp){
    var newArrsTempplus1=[];
    var newArrsTempplus2=[];
    var jzDataProductlast=[];
    jzDataDiscount.forEach(item=>{
        if(JxsType=="特约折扣"){
            if(item.JxsType=="特约折扣"){
                if (Id == item.Id) {
                    if (NormalDiscount__c_Input == item.NormalDiscount__c_Input && //非对象品折扣录入
                        GuaranteeDiscount__c_Input == item.GuaranteeDiscount__c_Input) { //对象品折扣录入
                        arrProductTemp.forEach(itemss => { //itemss产品明细
                            var Discount__c_Input = 0;
                            if (itemss.warrantyType__c=="市场多年保修") {
                                Discount__c_Input = item.GuaranteeDiscount__c_Input;
                                Discount__c_Input = parseFloat(Discount__c_Input);
                            } else {
                                Discount__c_Input = item.NormalDiscount__c_Input;
                                Discount__c_Input = parseFloat(Discount__c_Input);
                            }
                            debugger
                            if (itemss.PromotionId == item.Id && //方案Id
                                itemss.GuaranteeDiscount__c_Input == item.GuaranteeDiscount__c_Input && //对象品折扣录入
                                itemss.NormalDiscount__c_Input == item.NormalDiscount__c_Input) { //非对象品折扣录入
                                itemss = contributingDiscountLogic(itemss, Discount__c_Input, item); //特约折扣计算逻辑
                                newArrsTempplus1.push(itemss);
                            } else if (itemss.PromotionId != item.Id ||
                                itemss.GuaranteeDiscount__c_Input != item.GuaranteeDiscount__c_Input ||
                                itemss.NormalDiscount__c_Input != item.NormalDiscount__c_Input) {
                                newArrsTempplus2.push(itemss);
                            }
                        });
                        var newArrsplusG=[];
                        var newArrsplusN=[];
                        newArrsTempplus1.forEach(ntp=>{
                            if(ntp.warrantyType__c=="市场多年保修"){
                                newArrsplusG.push(ntp);
                            }else if(ntp.warrantyType__c!="市场多年保修"){
                                newArrsplusN.push(ntp);
                            }
                        });
                        if(newArrsplusG.length!=0){
                            var yibanSumG = SpecialPriceComputeReverse(newArrsTempplus1,true);
                            var chazhiG=(Number(item.GuaranteeDiscount_H_Money__c)*100-Number(yibanSumG)*100)/100;
                            var dangechazhiG=Math.round((chazhiG/newArrsplusG[0].Quantity) * 100) / 100;
                            newArrsplusG[0].AgencySubtotal__c =newArrsplusG[0].AgencySubtotal__c+chazhiG;
                            newArrsplusG[0].AgencyUnitPrice__c =newArrsplusG[0].AgencyUnitPrice__c+dangechazhiG;
                        }
                        if(newArrsplusN.length!=0){
                            var yibanSumN = SpecialPriceComputeReverse(newArrsTempplus1,false);
                            var chazhiN=(Number(item.NormalDiscount_H_Money__c)*100-Number(yibanSumN)*100)/100;
                            var dangechazhiN=Math.round((chazhiN/newArrsplusN[0].Quantity) * 100) / 100;
                            newArrsplusN[0].AgencySubtotal__c =newArrsplusN[0].AgencySubtotal__c+chazhiN;
                            newArrsplusN[0].AgencyUnitPrice__c =newArrsplusN[0].AgencyUnitPrice__c+dangechazhiN;
                        }
                        // newArrsTempplus1=[...newArrsplusG,...newArrsplusN];//20230213
                        newArrsTempplus1=newArrsplusG.concat(newArrsplusN);//20230213
                        // jzDataProductlast = [...newArrsTempplus1,...newArrsTempplus2];//20230213
                        jzDataProductlast = newArrsTempplus1.concat(newArrsTempplus2);//20230213
                    }
                }
            }
        }else if(JxsType=="一般折扣"){
            if(item.JxsType=="一般折扣"){
                if (NormalDiscount__c_Input == item.NormalDiscount__c_Input &&
                    Category__c == item.Category__c){
                    arrProductTemp.forEach(itemss => { //itemss产品明细
                        if (itemss.NormalDiscount__c_Input == NormalDiscount__c_Input &&
                            itemss.Category__c == Category__c) {
                            itemss = commonlyDiscountLogic(itemss, item); //一般折扣计算逻辑
                            newArrsTempplus1.push(itemss);
                        } else if (itemss.Category__c != Category__c ||
                            itemss.NormalDiscount__c_Input != NormalDiscount__c_Input) {
                            newArrsTempplus2.push(itemss);
                        }
                    });
                    var yibanSum = ContractPriceComputeReverse(newArrsTempplus1);//计算过后一般折扣的合同价格
                    var chazhi=(Number(item.NormalDiscount_H_Money__c)*100-Number(yibanSum)*100)/100;
                    var dangechazhi=Math.round((chazhi/newArrsTempplus1[0].Quantity) * 100) / 100;
                    newArrsTempplus1[0].AgencySubtotal__c =newArrsTempplus1[0].AgencySubtotal__c+chazhi;
                    newArrsTempplus1[0].AgencyUnitPrice__c =newArrsTempplus1[0].AgencyUnitPrice__c+dangechazhi;
                    // jzDataProductlast = [...newArrsTempplus1,...newArrsTempplus2];//20230213
                    jzDataProductlast =newArrsTempplus1.concat(newArrsTempplus2);//20230213
                    console.warn('newArrsTempplus2'+newArrsTempplus2);
                    console.warn('jzDataProductlast'+jzDataProductlast);
                }
            }
        }
    });
    return jzDataProductlast;
}
 
export function countListAndNodLogic(ifTrade,copydate,item,result,DeftCopyQtyList){
    var ListPrices = 0;
    var Nodiscounts = 0;
    result.forEach(itemss => { //方案主数据关联的产品
        copydate.forEach(jddc => { //报价行项目主数据
            if (itemss.Asset_Model_No__c == jddc.Product2.MDM_Model_No__c) {
                if (ifTrade == "内貿") {
                    ListPrices += itemss.Quantity__c * jddc.Product2.Intra_Trade_List_RMB__c;
                    Nodiscounts += itemss.Quantity__c * jddc.Product2.Intra_Trade_Service_RMB__c;
                } else if (ifTrade == "外貿") {
                    ListPrices += itemss.Quantity__c * jddc.Product2.Foreign_Trade_List_US__c;
                    Nodiscounts += itemss.Quantity__c * jddc.Product2.NoDiscount_Foreign__c;
                }
                var fl = true;
                if (DeftCopyQtyList.length == 0) {
                    DeftCopyQtyList.push({
                        Asset_Model_No__c: itemss.Asset_Model_No__c,
                        Quantity__c__c: itemss.Quantity__c,
                        Id_H: item.PromotionNo__c
                    });
                } else {
                    DeftCopyQtyList.forEach(jdcql => { //保存方案关联产品数量
                        if (itemss.Asset_Model_No__c == jdcql.Asset_Model_No__c && jdcql.Id_H == item.PromotionNo__c) {
                            fl = false;
                        }
                    });
                    if (fl) {
                        DeftCopyQtyList.push({
                            Asset_Model_No__c: itemss.Asset_Model_No__c,
                            Quantity__c__c: itemss.Quantity__c,
                            Id_H: item.PromotionNo__c
                        });
                    }
                }
            }
        });
    });
    item.sumListPrice = ListPrices;
    item.sumNoDiscount = Nodiscounts;
    DeftCopyQtyLists=DeftCopyQtyList;
    return item;
}
//比对报价行项目改变后试算界面的变化
//‘试算合成待选数据’是为了与现在报价行项目进行比对,用试算产品表数据合并出的上一次进行试算的报价行项目
//试算之前已将报价行项目相同的产品进行了合并
//1.‘报价行项目’条数少于‘试算合成待选数据’条数时将之前的试算清空,使用新的报价行项目
//2.当‘报价行项目’条数大于或等于‘试算合成待选数据’条数将两组数据进行比对
// 2-1)当‘报价行项目’条数等于‘试算合成待选数据’条数时先对比两组数据(根据产品Id进行匹配)
//  (2-1-1)当数据匹配成功后判断其数量字段,当‘报价行项目’数量小于‘试算合成待选数据’数量时将之前的试算清空,使用新的报价行项目
//  (2-1-2)等于则删除‘试算合成待选数据’中匹配成功的数据
//  (2-1-3)大于则用‘报价行项目’数量减去‘试算合成待选数据’数量并将这条数据存入待选报价行项目集合
// 2-2)当比对结束后如果‘试算合成待选数据’中有数据没有被匹配则将之前的试算清空,使用新的报价行项目
// 2-3)当‘报价行项目’条数大于‘试算合成待选数据’条数,且‘试算合成待选数据’都已匹配则将‘报价行项目’中未被匹配的数据全部存入待选报价行项目集合
export function comparisonUniqueKeyLogic(index,flagall,jzDataDefaultCopy,jzDataDefault,jzDataProduct,jzDataFixedPrice,jzDataDiscount,lastQuotationc){
    debugger
    if (index == 0) {
        if (flagall) {
           if (jzDataDefaultCopy.length < lastQuotationc.length) { //1、条数小于
                jzDataDefault = [].concat(jzDataDefaultCopy);
                jzDataProduct = [];
                jzDataFixedPrice = [];
                jzDataDiscount = [];
                jzDataDefaultExp = jzDataDefault;
                jzDataProductExp = jzDataProduct;
                jzDataFixedPriceExp = jzDataFixedPrice;
                jzDataDiscountExp = jzDataDiscount;
                return;
            } else { //2、
                var lastQuotation = [].concat(lastQuotationc);
                var DefaultCopy = [].concat(jzDataDefaultCopy);
                var Default = [];
                for (var j = 0; j < DefaultCopy.length; j++) {
                    var arrList = [];
                    var fag = true
                    if (lastQuotation.length != 0) {
                        for (var i = 0; i < lastQuotation.length; i++) {
                            if (DefaultCopy[j].Id == lastQuotation[i].Id) {
                                if (DefaultCopy[j].Quantity < lastQuotation[i].Quantity) { //2-1-1 数量小于 clear
                                    jzDataDefault = [].concat(jzDataDefaultCopy);
                                    jzDataProduct = [];
                                    jzDataFixedPrice = [];
                                    jzDataDiscount = [];
                                    jzDataDefaultExp = jzDataDefault;
                                    jzDataProductExp = jzDataProduct;
                                    jzDataFixedPriceExp = jzDataFixedPrice;
                                    jzDataDiscountExp = jzDataDiscount;
                                    return;
                                } else if (DefaultCopy[j].Quantity == lastQuotation[i].Quantity) { //2-1-2
                                    fag = false;
                                } else { //2-1-3   数量大于 塞到待选产品
                                    DefaultCopy[j].Quantity = DefaultCopy[j].Quantity - lastQuotation[i].Quantity;
                                    Default.push(DefaultCopy[j]);
                                    fag = false;
                                }
                            } else {
                                arrList.push(lastQuotation[i]);
                            }
                        }
                        lastQuotation = arrList;
                        if (fag) {
                            Default.push(DefaultCopy[j]);
                        }
 
                    } else { //2-3  条数大于 将数据塞到待选产品
                        Default.push(DefaultCopy[j]);
                    }
                }
                if (lastQuotation.length != 0) { //2-2  合成数据有剩余
                    jzDataDefault = [].concat(jzDataDefaultCopy);
                    jzDataProduct = [];
                    jzDataFixedPrice = [];
                    jzDataDiscount = [];
                    jzDataDefaultExp = jzDataDefault;
                    jzDataProductExp = jzDataProduct;
                    jzDataFixedPriceExp = jzDataFixedPrice;
                    jzDataDiscountExp = jzDataDiscount;
                    return;
                }
                jzDataDefault = [].concat(Default);
                jzDataDefaultExp = jzDataDefault;
            }
        }
    }
    jzDataDefaultExp = jzDataDefault;
    jzDataProductExp = jzDataProduct;
    jzDataFixedPriceExp = jzDataFixedPrice;
    jzDataDiscountExp = jzDataDiscount;
}
export function SearchProductByIdLogic(result,jzDataFixedPrice,jzDataDefaultCopyQuantityList,item){
    result.forEach(itemss => { //itemss方案关联的产品
        var fl = true;
        if (jzDataDefaultCopyQuantityList.length == 0) {
            jzDataDefaultCopyQuantityList.push({
                Asset_Model_No__c: itemss.Asset_Model_No__c,
                Quantity__c__c: itemss.Quantity__c,
                Id_H: item.PromotionNo__c
            });
        } else {
            jzDataDefaultCopyQuantityList.forEach(jdcql => { //保存方案关联产品的数量
                if (itemss.Asset_Model_No__c == jdcql.Asset_Model_No__c && jdcql.Id_H == item.PromotionNo__c) {
                    fl = false;
                }
            });
            if (fl) {
                jzDataDefaultCopyQuantityList.push({
                    Asset_Model_No__c: itemss.Asset_Model_No__c,
                    Quantity__c__c: itemss.Quantity__c,
                    Id_H: item.PromotionNo__c
                });
            }
        }
    });
    var iflag = true;
    var newarrjdf = [];
    jzDataFixedPrice.forEach(jdf => { //jdf价格政策
        if (jdf.Id == item.Id) {
            iflag = false;
            newarrjdf.push(jdf);
        } else {
            newarrjdf.push(jdf);
        }
    });
    jzDataDefaultCopyQuantityListExp = jzDataDefaultCopyQuantityList;
    return newarrjdf;
}
export function ComputeDataPromotionLogic(newArrsTemp3,newArrsTemp4,jzDataDefaultCopyQuantityList,jzDataDefaultCopy,QuoteData,arrProductTemp,item,arrTemp2,jzDataDefault){
    newArrsTemp3 = []; //需要计算的产品明细的数据
    newArrsTemp4 = []; //不需要计算的产品明细的数据
    var newArrsTemp5 = [];
    var newArrsTemp6 = [];
    arrProductTemp.forEach(itemsss => { //itemsss产品明细
 
        if (itemsss.PromotionId == item.Id) {
            if (item.determine == '改过') {
                var flag = true;
                var b = jzDataDefaultCopyQuantityList; //获取方案中的产品数量
                arrTemp2.forEach(datedefault => { //datedefault待选产品
 
                    var quantity = 0;
                    if (datedefault.Id == itemsss.Id) {
                        b.forEach(iem => { //iem方案中的产品数量
                            if (iem.Asset_Model_No__c == datedefault.Product2.MDM_Model_No__c && iem.Id_H == item.PromotionNo__c) {
                                quantity = (itemsss.Quantity - iem.Quantity__c__c * item.Counts) + datedefault.Quantity;
                                datedefault.Quantity = quantity;
                                itemsss.Quantity = iem.Quantity__c__c * item.Counts;
                            }
                        });
                        flag = false;
                    }
                });
                if (flag) {
                    jzDataDefaultCopy.forEach(add => { //add报价行项目主数据
                        var quantity = 0;
                        if (add.Id == itemsss.Id) {
                            b.forEach(iems => { //iems方案关联产品数量
                                if (iems.Asset_Model_No__c == add.Product2.MDM_Model_No__c && iems.Id_H == item.PromotionNo__c) {
                                    quantity = itemsss.Quantity - iems.Quantity__c__c * item.Counts;
                                    add.Quantity = quantity;
                                    itemsss.Quantity = iems.Quantity__c__c * item.Counts;
                                    arrTemp2.push(add);
                                }
                            });
                            flag = true;
                        }
                    });
                }
            }
            itemsss = partPromotionSchemeLogical(itemsss, item,QuoteData[0].multiYearWarranty__c);
            newArrsTemp3.push(itemsss);
        } else if (itemsss.PromotionId != item.Id) {
            newArrsTemp4.push(itemsss);
        }
    });
    if (item.determine == '改过') {
        arrTemp2.forEach(itsss => { //itsss待选产品
            if (itsss.Quantity != 0) {
                newArrsTemp6.push(itsss);
            }
        });
        newArrsTemp5 = [].concat(newArrsTemp6);
        jzDataDefault = newArrsTemp5;
    }
    newArrsTemp3Exp = newArrsTemp3;
    newArrsTemp4Exp = newArrsTemp4;
    jzDataDefaultExp = jzDataDefault;
    jzDataDefaultCopyExp = jzDataDefaultCopy;
    return arrProductTemp;
}
export function ComputeDataNormalProductLogic(newArrsTemp3,newArrsTemp4,jzDataDefaultCopyQuantityList,jzDataDefaultCopyc,QuoteData,arrProductTemp,item,arrTemp2,jzDataDefault){
    newArrsTemp3 = []; //需要计算的产品明细的数据
    newArrsTemp4 = []; //不需要计算的产品明细的数据
    var newArrsTemp5 = [];
    var newArrsTemp6 = [];
    var jzDataDefaultCopy = jzDataDefaultCopyc;
    arrProductTemp.forEach(itemsss => { //itemsss产品明细
        var flag = true;
        if (itemsss.PromotionId == item.Id) {
            if (item.determine == '改过') {
                var b = jzDataDefaultCopyQuantityList; //获取方案中的产品数量
                jzDataDefaultCopy = jzDataDefaultCopyc;
                arrTemp2.forEach(datedefault => { //datedefault待选产品
                    var quantity = 0;
                    if (datedefault.Id == itemsss.Id) {
                        b.forEach(iem => { //iem方案中的产品数量
                            if (iem.Asset_Model_No__c == datedefault.Product2.MDM_Model_No__c && iem.Id_H == item.PromotionNo__c) {
                                quantity = (itemsss.Quantity - iem.Quantity__c__c * item.Counts) + datedefault.Quantity;
                                datedefault.Quantity = quantity;
                                itemsss.Quantity = iem.Quantity__c__c * item.Counts;
                            }
                        });
                        flag = false;
                    }
                });
                if (flag) {
                    jzDataDefaultCopy.forEach(add => { //add报价行项目主数据
                        var quantity = 0;
                        if (add.Id == itemsss.Id) {
                            b.forEach(iems => { //iems方案关联产品数量
                                if (iems.Asset_Model_No__c == add.Product2.MDM_Model_No__c && iems.Id_H == item.PromotionNo__c) {
                                    quantity = itemsss.Quantity - iems.Quantity__c__c * item.Counts;
                                    add.Quantity = quantity;
                                    itemsss.Quantity = iems.Quantity__c__c * item.Counts;
                                    arrTemp2.push(add);
                                }
                            });
                        }
                    });
                }
            }
            if(QuoteData[0].multiYearWarranty__c){
                itemsss.AgencyUnitPrice__c = (item.HeTongTotal / item.Counts) * (itemsss.ListPrice / item.sumListPrice);
            }else{
                itemsss.AgencyUnitPrice__c = ((item.HeTongTotal / item.Counts) - item.sumNoDiscount) * (itemsss.ListPrice / item.sumListPrice) + itemsss.ServicePrice__c;
            }
            if (item.HeTongTotal == undefined || item.HeTongTotal == "") {
                itemsss.AgencyUnitPrice__c = 0;
            }
            itemsss = partGeneralDiscountLogical(itemsss, item);
            newArrsTemp3.push(itemsss);
        } else if (itemsss.PromotionId != item.Id) {
            newArrsTemp4.push(itemsss);
        }
    });
    if (item.determine == '改过') {
        arrTemp2.forEach(itsss => { //待选产品
            if (itsss.Quantity != 0) {
                newArrsTemp6.push(itsss);
            }
        });
        newArrsTemp5 = [].concat(newArrsTemp6);
        jzDataDefault = newArrsTemp5;
    }
    newArrsTemp3Exp = newArrsTemp3;
    newArrsTemp4Exp = newArrsTemp4;
    jzDataDefaultExp = jzDataDefault;
    jzDataDefaultCopyExp = jzDataDefaultCopy;
    return arrProductTemp;
}
export function ComputeDiscountAuthorizerLogic(newArrsTemp,newArrsTemp2,item,arrProductTemp){
    newArrsTemp = [];
    newArrsTemp2 = [];
    arrProductTemp.forEach(itemss => { //itemss产品明细
        var Discount__c_Input = 0;
        if (itemss.warrantyType__c=="市场多年保修") {
            Discount__c_Input = item.GuaranteeDiscount__c_Input;
            Discount__c_Input = parseFloat(Discount__c_Input);
        } else {
            Discount__c_Input = item.NormalDiscount__c_Input;
            Discount__c_Input = parseFloat(Discount__c_Input);
        }
        if (itemss.PromotionId == item.Id && //方案Id
            itemss.GuaranteeDiscount__c_Input == item.GuaranteeDiscount__c_Input && //对象品折扣录入
            itemss.NormalDiscount__c_Input == item.NormalDiscount__c_Input) { //非对象品折扣录入
            itemss = contributingDiscountLogic(itemss, Discount__c_Input, item); //特约折扣计算逻辑
            newArrsTemp.push(itemss);
        } else if (itemss.PromotionId != item.Id ||
            itemss.GuaranteeDiscount__c_Input != item.GuaranteeDiscount__c_Input ||
            itemss.NormalDiscount__c_Input != item.NormalDiscount__c_Input) {
            newArrsTemp2.push(itemss);
        }
    });
    newArrsTempExp = newArrsTemp;
    newArrsTemp2Exp = newArrsTemp2;
    return arrProductTemp;
}
export function handleSaveDiscountLogic(jzDataDiscount,jzDataProduct,event){
    var boolean = 0;
    var boolean2 = false;
    var boolean3 = false;
    var data = event.detail.rows;
    let newData = [];
    let newData2 = [];
    var newMap3 = new Map();
    let newData3 = [];
    var key=0;
    let editnewDate = [];
    var GuaranteeDiscount__cZuiXiao =0;
    var NormalDiscount__cZuiXiao =0;
    for (var i = 0; i < jzDataDiscount.length; i++) {
        var editData = {};
        var flag = false;
        for (var j = 0; j < data.length; j++) {
            var id = data[j].DelectId.replace("row-", "");
            if (jzDataDiscount[i].DelectId == id) {
                editData = {
                    GuaranteeDiscount__c_Input: '',
                    NormalDiscount__c_Input: '',
                    HeTongPrice: '',
                    GuaranteeDiscount_H_Money__c: '',
                    NormalDiscount_H_Money__c: ''
                };
                //对象折扣
                editData.GuaranteeDiscount__c_Input = data[j].GuaranteeDiscount__c_Input;
                //赋值 非对象折扣
                editData.NormalDiscount__c_Input = data[j].NormalDiscount__c_Input;
                //一般折扣合同价格
                editData.HeTongPrice = data[j].HeTongPrice;
                //对象品合同金额
                editData.GuaranteeDiscount_H_Money__c = data[j].GuaranteeDiscount_H_Money__c;
                //非对象品合同金额
                editData.NormalDiscount_H_Money__c = data[j].NormalDiscount_H_Money__c;
                // editData.id=id;
                flag = true;
            }
        }
        if (flag) {
            var newItem = {
                ...jzDataDiscount[i],
                ...{}
            };
            if (editData.GuaranteeDiscount__c_Input != undefined) {
                if(newItem.JxsType == "特约折扣"){
                    var GuaranteeDiscount__c_Input = parseFloat(editData.GuaranteeDiscount__c_Input);
                    editData.GuaranteeDiscount__c_Input=GuaranteeDiscount__c_Input+'%';
                    var GuaranteeDiscount__c = parseFloat(newItem.GuaranteeDiscount__c);
                    if (GuaranteeDiscount__c_Input < GuaranteeDiscount__c) {
                        GuaranteeDiscount__cZuiXiao=GuaranteeDiscount__c;
                        boolean = 1;
                        break;
                    } else {
                        jzDataProduct.forEach(jdpt => {
                            if (newItem.Id == jdpt.PromotionId &&
                                newItem.GuaranteeDiscount__c_Input == jdpt.GuaranteeDiscount__c_Input &&
                                newItem.NormalDiscount__c_Input == jdpt.NormalDiscount__c_Input) {
                                jdpt.GuaranteeDiscount__c_Input = editData.GuaranteeDiscount__c_Input;
                            }
                        });
                        newItem.GuaranteeDiscount__c_Input = editData.GuaranteeDiscount__c_Input;
                        newItem.iftrue = "改过";
                    }
                }else{
                    boolean = 3;
                    break;
                }
            }
            if (editData.NormalDiscount__c_Input != undefined) {
                if(editData.NormalDiscount__c_Input!=''&&editData.NormalDiscount__c_Input>=0){
                    var NormalDiscount__c_Input = parseFloat(editData.NormalDiscount__c_Input);
                    editData.NormalDiscount__c_Input = NormalDiscount__c_Input+'%';
                    var NormalDiscount__c = parseFloat(newItem.NormalDiscount__c);
                    if (NormalDiscount__c_Input < NormalDiscount__c) {
                        NormalDiscount__cZuiXiao=NormalDiscount__c;
                        boolean = 2;
                        break;
                    } else {
                        jzDataProduct.forEach(jdpt => {
                            if (newItem.Id == jdpt.PromotionId &&
                                newItem.GuaranteeDiscount__c_Input == jdpt.GuaranteeDiscount__c_Input &&
                                newItem.NormalDiscount__c_Input == jdpt.NormalDiscount__c_Input) {
                                jdpt.NormalDiscount__c_Input = editData.NormalDiscount__c_Input;
                            }
                        });
                        newItem.NormalDiscount__c_Input = editData.NormalDiscount__c_Input;
                        newItem.iftrue = "改过";
                    }
                }else{
                    boolean = 5
                    break;
                }
            }
            newItem.GuaranteeDiscount_H_Money_yuan=newItem.GuaranteeDiscount_H_Money__c;
            if (editData.GuaranteeDiscount_H_Money__c != undefined) {
                if(newItem.JxsType == "特约折扣"){
                    if(editData.GuaranteeDiscount_H_Money__c==""){
                        editData.GuaranteeDiscount_H_Money__c=0;
                    }
                    newItem.GuaranteeDiscount_H_Money__c = editData.GuaranteeDiscount_H_Money__c;
                    newMap3.set(key,newItem);
                    boolean = 4;
                    boolean2 = true ;
                }else{
                    boolean = 3;
                    break;
                }
                    
            }
            newItem.NormalDiscount_H_Money_yuan=newItem.NormalDiscount_H_Money__c;
            if (editData.NormalDiscount_H_Money__c != undefined) {
                    if(editData.NormalDiscount_H_Money__c==""){
                        editData.NormalDiscount_H_Money__c=0;
                    }
                    newItem.NormalDiscount_H_Money__c = editData.NormalDiscount_H_Money__c;
                    if(newItem.JxsType == "一般折扣"){
                        newData2.push(newItem);
                        boolean = 4;
                        boolean3 = true;
                    }else{
                        newMap3.set(key,newItem);
                        boolean = 4;
                        boolean2 = true;
                    }
            }
            if (editData.NormalDiscount_H_Money__c != undefined||editData.GuaranteeDiscount_H_Money__c != undefined) {
                if(newItem.JxsType == "一般折扣"){
                    newItem.HeTongPrice = parseFloat(newItem.NormalDiscount_H_Money__c)
                }else{
                    newItem.HeTongPrice = parseFloat(newItem.NormalDiscount_H_Money__c)+parseFloat(newItem.GuaranteeDiscount_H_Money__c);
                }
            }
            key++;
            newData.push(newItem);
            editnewDate.push(newItem);
        } else {
            newData.push({
                ...{},
                ...jzDataDiscount[i]
            });
        }
    }
    for (let [k, v] of newMap3) {
        newData3.push(v);
    }
    booleanExp = boolean;
    boolean2Exp = boolean2;
    boolean3Exp = boolean3;
    newDataExp = newData;
    newData2Exp = newData2;
    newData3Exp = newData3;
    editnewDateExp = editnewDate;
    GuaranteeDiscount__cZuiXiaoExp = GuaranteeDiscount__cZuiXiao;
    NormalDiscount__cZuiXiaoExp = NormalDiscount__cZuiXiao;
    jzDataProductExp = jzDataProduct;
    return jzDataDiscount;
}
export function AddNumsLogic(ListName, Asset_Model_No__c, addNums, Id,CompareFullData){
    var FilterList = CompareFullData.filter(item => {
        if (item.ListName == ListName && item.Id == Id) {
            return true;
        } else {
            return false;
        }
    })
    if (FilterList == undefined || FilterList.length <= 0) {
        var newTemp = {
            ListName: ListName,
            Asset_Model_No__c: Asset_Model_No__c,
            Id: Id,
            num: addNums
        }
        CompareFullData.push(newTemp);
    } else {
        FilterList[0].Asset_Model_No__c += Asset_Model_No__c + "||";
        FilterList[0].num = addNums;
    }
    return CompareFullData;
}
export function MergeDuplicateSchemesLogic(CompareFullData,SchemeSet){
    var a = CompareFullData;
    var CompareFullDataedit = [];
    var Setmap = new Map();
    var arr = [];
    var arr2 = SchemeSet;
    arr2.forEach(arrs => {
        var object = {};
        if (Setmap.has(arrs.Id)) {
            object = {
                ...{},
                ...Setmap.get(arrs.Id)
            };
            object.Counts = object.Counts + arrs.Counts;
            object.determine = '';
            a.forEach(editnum => {
                if (editnum.Id == object.Id) {
                    editnum.num = object.Counts;
                    CompareFullDataedit.push(editnum);
                } else {
                    CompareFullDataedit.push(editnum);
                }
            });
            CompareFullData = [].concat(CompareFullDataedit);
            Setmap.set(arrs.Id, object);
        } else {
            object = {
                ...{},
                ...arrs
            };
            Setmap.set(arrs.Id, object);
        }
    });
    for (let [k, v] of Setmap) {
        arr.push(v);
    }
    CompareFullDataExp = CompareFullData;
    return arr;
}
//计算价格政策的最大次数
export function ComputeMaximumTimes(priceArr,jzDataDefaultCopyQuantityList,jzDataDefault) {
    // var num=0;
    var Pricepolicy = {
        ...{},
        ...priceArr
    };
    var b = jzDataDefaultCopyQuantityList; //查出的每个方案的明细的数量
    var selectproducts = jzDataDefault; //待选产品
    Pricepolicy.maxCounts = ComputationalLogic(Pricepolicy, b, selectproducts);
    return Pricepolicy;
}
export function handleSaveFixedPriceLogic(CompareFullData,event,jzDataFixedPrice,jzDataDefaultCopyQuantityList,jzDataDefault){
    var a = CompareFullData;
    var CompareFullDataedit = [];
    var HeTongTotal = 0;
    var data = event.detail.rows;
    let newData = [];
    let editnewDate = [];
    var boolean = 1;
    for (var i = 0; i < jzDataFixedPrice.length; i++) {
        var editData = {};
        var flag = false;
        for (var j = 0; j < data.length; j++) {
            var id = data[j].DelectId.replace("row-", "");
            if (jzDataFixedPrice[i].DelectId == id) {
                // editData=data[j];
                editData = {
                    Counts: '',
                    HeTongTotal: ''
                };
                //对象折扣
                editData.Counts = data[j].Counts;
                //赋值 非对象折扣
                editData.HeTongTotal = data[j].HeTongTotal;
                // editData.id=id;
                flag = true;
            }
        }
        if (flag) {
            var newItem = {
                ...jzDataFixedPrice[i],
                ...{}
            }; //价格政策数据
            //计算最大次数
            newItem = ComputeMaximumTimes(newItem,jzDataDefaultCopyQuantityList,jzDataDefault);
            console.warn('ceshi1');
            if (editData.Counts != undefined) {
                var ifNec = true;
                if (newItem.recordTypeName__c == "NormalProduct") {
                    if (newItem.ifNecessary__c) {
                        ifNec = false;
                    }
                }
                newItem.maxCounts = Number(newItem.maxCounts);
                if (newItem.maxCounts >= editData.Counts && ifNec) {
                    if (editData.Counts == 0) {
                        boolean = 4;
                    } else {
                        if (newItem.if_Contain_Nod__c) {
                            HeTongTotal = newItem.Price_CNY__c * editData.Counts;
                        } else {
                            HeTongTotal = newItem.Price_CNY__c * editData.Counts + newItem.sumNoDiscount * editData.Counts;
                        }
                        newItem.Counts = editData.Counts;
                        if (newItem.recordTypeName__c == "Promotion") {
                            newItem.HeTongTotal = HeTongTotal;
                        }
                        newItem.determine = '改过';
                        a.forEach(editnum => {
                            if (editnum.Id == newItem.Id) {
                                editnum.num = newItem.Counts;
                                CompareFullDataedit.push(editnum);
                            } else {
                                CompareFullDataedit.push(editnum);
                            }
                        });
                        CompareFullData = [].concat(CompareFullDataedit);//20230214
                    }
                } else {
                    if (ifNec) {
                        boolean = 3;
                    } else {
                        boolean = 5;
                    }
                }
            }
            console.warn('ceshi2');
            if (editData.HeTongTotal != undefined) {
                if (newItem.if_Contain_Nod__c) {
                    HeTongTotal = newItem.Price_CNY__c * newItem.Counts;
                } else {
                    HeTongTotal = newItem.Price_CNY__c * newItem.Counts + newItem.sumNoDiscount * newItem.Counts;
                }
                if (editData.HeTongTotal < HeTongTotal) {
                    boolean = 6;
                } else {
                    newItem.HeTongTotal = editData.HeTongTotal;
                    newItem.determine = '改过';
                }
            }
            newData.push(newItem);
            editnewDate.push(newItem);
        } else {
            newData.push({
                ...{},
                ...jzDataFixedPrice[i]
            });
        }
    }
    CompareFullDataExp = CompareFullData;
    booleanExp = boolean;
    newDataExp = newData;
    HeTongTotalExp = HeTongTotal;
    return editnewDate;
}
export function deleteFixedPriceLogic(SelectedFnDataFixedPrice,CompareFullData){
    let ids = [];
    var fag = true;
    var select = [];
    for (var j = 0; j < SelectedFnDataFixedPrice.length; j++) {
        fag = true;
        var PromotionHeadRecordId = SelectedFnDataFixedPrice[j].recordTypeName__c;
        if (PromotionHeadRecordId == "NormalProduct") {
            if (SelectedFnDataFixedPrice[j].ifNecessary__c) {
                fag = false;
            } else {
                select.push(SelectedFnDataFixedPrice[j]);
            }
        } else {
            select.push(SelectedFnDataFixedPrice[j]);
        }
        if (fag) {
            var a = CompareFullData;
            var compareFu = [];
            ids.push(SelectedFnDataFixedPrice[j].Id);
            a.forEach(deletId => {
                if (SelectedFnDataFixedPrice[j].Id != deletId.Id) {
                    compareFu.push(deletId);
                }
            });
            CompareFullData = [].concat(compareFu);//20230214
        }
    }
    SelectedFnDataFixedPrice = [].concat(select);//20230214
    CompareFullDataExp = CompareFullData;
    SelectedFnDataFixedPriceExp = SelectedFnDataFixedPrice;
    idsExp = ids;
    return fag;
}
export function DeleteChangesFnLogic(id,TypeName,CompareFullDataTemp,CompareFullData,jzDataFixedPrice,jzDataDiscount,jzDataProduct,jzDataDefault,jzDataDefaultNotChange){
    //删除 规则数量
    CompareFullData.forEach(cItem => {
        if (cItem.Id == id && cItem.ListName == TypeName) {
        } else {
            CompareFullDataTemp.push(cItem);
        }
    })
    //删除 已选产品
    var CurrentTemp = {};
    if (TypeName == "价格政策") {
        CurrentTemp = jzDataFixedPrice.filter(fItem => {
            if (fItem.Id == id) {
                return true;
            }
            return false;
        })[0];
    }
    if (TypeName == "折扣政策") {
        CurrentTemp = jzDataDiscount.filter(fItem => {
            if (fItem.Id == id) {
                return true;
            }
            return false;
        })[0];
    }
    //匹配需要删除产品
    var ProductNumsTemp = [];
    var NewjzDataProduct = [];;
    if (TypeName == "价格政策") {
        jzDataProduct.forEach(proItem => {
            if (proItem.PromotionNo__c == CurrentTemp.PromotionNo__c) {
                ProductNumsTemp.push({
                    Id: proItem.Id,
                    num: proItem.Quantity
                })
            } else {
                NewjzDataProduct.push(proItem);
            }
        });
    } else if (TypeName == "折扣政策") {
        jzDataProduct.forEach(proItem => {
            if (proItem.CompareId == CurrentTemp.CompareId) {
                ProductNumsTemp.push({
                    Id: proItem.Id,
                    num: proItem.Quantity
                })
            } else {
                NewjzDataProduct.push(proItem);
            }
        });
    }
    // 执行删除
    jzDataProduct = NewjzDataProduct;
    // 添加数量
    var newjzDataDefaults = [];
    var AddnumsTemp = [];
    jzDataDefault.forEach(defItem => {
        var defItemTemp = {
            ...{},
            ...defItem
        };
        ProductNumsTemp.forEach(pTempItem => {
            if (pTempItem.Id == defItem.Id) {
                defItemTemp.Quantity += pTempItem.num;
                AddnumsTemp.push(pTempItem.Id);
            }
        });
        newjzDataDefaults.push(defItemTemp);
    })
    jzDataDefault = newjzDataDefaults;
    //添加整条数据
    var PFTempArr = ProductNumsTemp.filter(pTempItem => {
        var flag = true;
        AddnumsTemp.filter(addItem => {
            if (addItem == pTempItem.Id) {
                flag = false;
            }
        })
        return flag;
    })
    jzDataDefaultNotChange.forEach(noChangeItem => {
        PFTempArr.forEach(pftItem => {
            if (pftItem.Id == noChangeItem.Id) {
                let newChangeItem = {
                    ...{},
                    ...noChangeItem
                };
                newChangeItem.Quantity = pftItem.num;
                jzDataDefault.push(newChangeItem);
            }
        })
    })
    CompareFullDataTempExp = CompareFullDataTemp;
    jzDataFixedPriceExp = jzDataFixedPrice;
    jzDataDiscountExp = jzDataDiscount;
    jzDataDefaultExp = jzDataDefault;
    jzDataDefaultNotChangeExp = jzDataDefaultNotChange;
    return jzDataProduct;
}
export function deleteFixedPriceTempLogic(SelectedFnDataFixedPrice,jzDataFixedPrice,CompareFullData){
    let newarr = [];
    for (var j = 0; j < SelectedFnDataFixedPrice.length; j++) {
        for (var i = 0; i < jzDataFixedPrice.length; i++) {
            var a = CompareFullData;
            var compareFu = [];
            a.forEach(deletId => {
                if (SelectedFnDataFixedPrice[j].Id != deletId.Id) {
                    compareFu.push(deletId);
                }
            });
            CompareFullData = [].concat(compareFu);//20230214
            if (SelectedFnDataFixedPrice[j].Id == jzDataFixedPrice[i].Id) {
                jzDataFixedPrice.splice(i, 1); // 将使后面的元素依次前移,数组长度减1
                i--;
            }
        }
    }
    for (var i = 0; i < jzDataFixedPrice.length; i++) {
        newarr.push(jzDataFixedPrice[i]);
    }
    CompareFullDataExp = CompareFullData;
    return newarr;
}
export function GetSearchProductByIdLogic(item,results,jzDataDefaultCopyQuantityList,jzDataFixedPrice){
    results.forEach(itemss => { //方案关联的产品
        var fl = true;
        if (jzDataDefaultCopyQuantityList.length == 0) {
            jzDataDefaultCopyQuantityList.push({
                Asset_Model_No__c: itemss.Asset_Model_No__c,
                Quantity__c__c: itemss.Quantity__c,
                Id_H: item.PromotionNo__c
            });
        } else {
            jzDataDefaultCopyQuantityList.forEach(jdcql => {
                if (itemss.Asset_Model_No__c == jdcql.Asset_Model_No__c && jdcql.Id_H == item.PromotionNo__c) {
                    fl = false;
                }
            });
            if (fl) {
                jzDataDefaultCopyQuantityList.push({
                    Asset_Model_No__c: itemss.Asset_Model_No__c,
                    Quantity__c__c: itemss.Quantity__c,
                    Id_H: item.PromotionNo__c
                });
            }
        }
    });
    var iflag = true;
    var newarrjdf = [];
    jzDataFixedPrice.forEach(jdf => { //价格政策
        if (jdf.Id == item.Id) {
            iflag = false;
            // jdf.sumListPrice = sumListPrice;
            // jdf.sumNoDiscount = sumNoDiscount;
            newarrjdf.push(jdf);
        } else {
            newarrjdf.push(jdf);
        }
    });
    iflagExp = iflag;
    jzDataDefaultCopyQuantityListExp = jzDataDefaultCopyQuantityList;
    return newarrjdf;
}
export function getTableDataCommonlyLogic(jzDataCommonly){
    var jzDataCommonlyTemp = [];
    jzDataCommonly.forEach(items => {
        var ItemsTemp = {
            ...{},
            ...items
        };
        ItemsTemp.JxsType = "一般折扣";
        ItemsTemp.SplitQuantity = ItemsTemp.Quantity;
        jzDataCommonlyTemp.push(ItemsTemp);
    })
    return jzDataCommonlyTemp;
}
export function ComputeListPrice(PromotionId,jzDataProduct) {
    var sum = 0;
    jzDataProduct.forEach(jzdp => { //jzdp产品明细
        if (jzdp.PromotionId == PromotionId) {
            sum = sum + jzdp.ListPrice * jzdp.Quantity;
        }
    });
    return sum;
}
export function delectComputeData(item,jzDataProduct) {
    var sum = ComputeListPrice(item.PromotionId,jzDataProduct);
    var jzProductarry = [].concat(jzDataProduct);
    jzProductarry.forEach(japdt => {
        if (item.PromotionId == japdt.PromotionId) {
            japdt.AgencySubtotal__c = japdt.AgencySubtotal__c + item.AgencySubtotal__c * (japdt.ListPrice * japdt.Quantity / sum);
            japdt.AgencyUnitPrice__c = japdt.AgencySubtotal__c / japdt.Quantity;
            japdt.AgencySubtotal__c = Math.round(japdt.AgencySubtotal__c * 100) / 100;
            japdt.AgencyUnitPrice__c = Math.round(japdt.AgencyUnitPrice__c * 100) / 100;
        }
    });
    jzDataProduct = [].concat(jzProductarry);//20230214
    return jzDataProduct;
}
export function DeleteIsChangelogicExp(item,TypeName,jzDataProduct,jzDataDefault,jzDataDefaultCopy){
    var jzdatas = [];
    var flg = true;
    var booleanfag = 0;
    jzDataProduct.forEach(proItem => { //proItem产品明细
        if (TypeName == "价格政策") {
            var PromotionHeadRecordId = item.recordTypeName__c;
            if (PromotionHeadRecordId == "Promotion") {
                if (!item.if_Fix__c) {
                    if (proItem.Id == item.Id && item.PromotionId == proItem.PromotionId) {} else {
                        jzdatas.push(proItem);
                    }
                } else {
                    flg = false;
                    booleanfag = 1;
                    
                }
            } else if (PromotionHeadRecordId == "NormalProduct") {
                flg = false;
                booleanfag = 2;
            } else {
                jzdatas.push(proItem);
            }
        } else if (TypeName == "折扣政策") {
            var PromotionHeadRecordId = item.recordTypeName__c;
            if (PromotionHeadRecordId == "Authorizer") {
                if (proItem.Id == item.Id &&
                    item.PromotionId == proItem.PromotionId &&
                    item.NormalDiscount__c_Input == proItem.NormalDiscount__c_Input &&
                    item.GuaranteeDiscount__c_Input == proItem.GuaranteeDiscount__c_Input) {} else {
                    jzdatas.push(proItem);
                }
            } else {
                if (proItem.Id == item.Id &&
                    item.Category__c == proItem.Category__c &&
                    item.Discount__c_Input == proItem.Discount__c_Input) {} else {
                    jzdatas.push(proItem);
                }
            }
 
        }
    });
    if (flg) {
        jzDataProduct = [].concat(jzdatas);//20230214
        if (TypeName == "价格政策") {
            //删除价格计算
            jzDataProduct = delectComputeData(item,jzDataProduct);
        }
        var fg = true;
        var arr = jzDataDefault;
        arr.forEach(jddf => { //jddf待选产品
            if (jddf.Id == item.Id) {
                jddf.Quantity = jddf.Quantity + item.Quantity
                fg = false;
            }
        });
        if (fg) {
            jzDataDefaultCopy.forEach(itm => { //itm报价行项目主数据
                if (itm.Id == item.Id) {
                    itm.Quantity = item.Quantity
                    arr.push(itm);
                    fg = false;
                }
            });
        }
        jzDataDefault = [].concat(arr);//20230214
    }
    jzDataProductExp = jzDataProduct;
    jzDataDefaultExp = jzDataDefault;
    jzDataDefaultCopyExp = jzDataDefaultCopy;
    return booleanfag;
}
export function DeleteIsChangesFnjiage(jzDataFixedPrice,jzDataProduct,falg,item){
    console.warn('1111');
    var arrTemp = [].concat(jzDataFixedPrice);//20230214
     var TempItem = {};
     arrTemp.forEach(atItem => {
         if (atItem.Id == item.PromotionId) {
             TempItem = atItem;
             return;
         }
     })
     console.warn('2222');
     jzDataProduct.forEach(ite => { //ite产品明细
         if (ite.PromotionId == TempItem.Id) {
             falg = false;
         }
     });
     falgExp = falg;
     console.warn('3333');
     return TempItem;
}
export function DeleteIsChangesFnzhekou(jzDataDiscount,jzDataProduct,falg,item){
    var arrTempTOName = [].concat(jzDataDiscount);//20230214
    var TempItemTOName = {};
    var PromotionHeadRecordId = item.recordTypeName__c;
    if (PromotionHeadRecordId == "Authorizer") {
        arrTempTOName.forEach(atItem => {
            if (atItem.Id == item.PromotionId && //方案Id
                item.NormalDiscount__c_Input == atItem.NormalDiscount__c_Input && //非对象品折扣录入
                item.GuaranteeDiscount__c_Input == atItem.GuaranteeDiscount__c_Input) { //对象品折扣录入
                TempItemTOName = atItem;
                return;
            }
        })
        jzDataProduct.forEach(ite => {
            if (ite.PromotionId == TempItemTOName.Id &&
                ite.NormalDiscount__c_Input == TempItemTOName.NormalDiscount__c_Input &&
                ite.GuaranteeDiscount__c_Input == TempItemTOName.GuaranteeDiscount__c_Input) {
                falg = false;
            }
        });
    } else {
        arrTempTOName.forEach(atItem => {
            if (item.Category__c == atItem.Category__c &&
                item.Discount__c_Input == atItem.NormalDiscount__c_Input) {
                TempItemTOName = atItem;
                return;
            }
        })
        jzDataProduct.forEach(ite => {
            if (ite.Category__c == TempItemTOName.Category__c &&
                ite.Discount__c_Input == TempItemTOName.NormalDiscount__c_Input) {
                falg = false;
            }
        });
    }
    falgExp = falg;
    return TempItemTOName;
}
export function delectTableDiscountTempLogic(SelectedFnDataDiscount,jzDataDiscount){
    let newarr = [];
        for (var j = 0; j < SelectedFnDataDiscount.length; j++) {
            for (var i = 0; i < jzDataDiscount.length; i++) {
                var PromotionHeadRecordId = SelectedFnDataDiscount[j].recordTypeName__c;
                if (PromotionHeadRecordId == "Authorizer") {
                    if (SelectedFnDataDiscount[j].Id == jzDataDiscount[i].Id &&
                        SelectedFnDataDiscount[j].NormalDiscount__c_Input == jzDataDiscount[i].NormalDiscount__c_Input &&
                        SelectedFnDataDiscount[j].GuaranteeDiscount__c_Input == jzDataDiscount[i].GuaranteeDiscount__c_Input) {
                        jzDataDiscount.splice(i, 1); // 将使后面的元素依次前移,数组长度减1
                        i--;
                    }
                } else {
                    if (SelectedFnDataDiscount[j].Category__c == jzDataDiscount[i].Category__c &&
                        SelectedFnDataDiscount[j].NormalDiscount__c_Input == jzDataDiscount[i].NormalDiscount__c_Input) {
                        jzDataDiscount.splice(i, 1); // 将使后面的元素依次前移,数组长度减1
                        i--;
                    }
                }
            }
        }
        for (var i = 0; i < jzDataDiscount.length; i++) {
            newarr.push(jzDataDiscount[i]);
        }
        return newarr;
}
export function SelectedFnCommonlyLogic(arr){
    var newArr = [];
    arr.forEach(item => {
        var TempObject = {
            ...{},
            ...item
        };
        TempObject.JxsType = "一般折扣";
        newArr.push(TempObject);
    })
    return newArr;
}
export function SaveGeneralDiscountLogic(data,jzDataCommonly){
    debugger;
    let newData = [];
    let editnewDate = [];
    var boolean = 1;
    for (var i = 0; i < jzDataCommonly.length; i++) {
        var editData = {};
        var flag = false;
        for (var j = 0; j < data.length; j++) {
            var id = data[j].Id;
            if (jzDataCommonly[i].Id == id) {
                editData = {
                    SplitQuantity: ''
                };
                editData.SplitQuantity = data[j].SplitQuantity;
                flag = true;
            }
        }
        if (flag) {
            var newItem = {
                ...jzDataCommonly[i],
                ...{}
            };
            if (editData.SplitQuantity != undefined) {
                newItem.SplitQuantity = Number(editData.SplitQuantity);
            }
            newData.push(newItem);
            editnewDate.push(newItem);
        } else {
            newData.push({
                ...{},
                ...jzDataCommonly[i]
            });
        }
    }
    var newArrs = [].concat(editnewDate);//20230214
    newArrs.forEach(item => {
        if (item.Quantity < item.SplitQuantity) {
            boolean = 2;
        } else if (item.SplitQuantity == 0 || item.SplitQuantity == '') {
            boolean = 3;
        }
    });
    booleanExp = boolean;
    return newData;
}
export function DeleteSchemeMatchingLogic(id,TypeName,CompareFullDataTemp,CompareFullData,jzDataFixedPrice,jzDataDiscount,jzDataProduct,jzDataDefault,jzDataDefaultNotChange){
    //删除 规则数量
    CompareFullData.forEach(cItem => {
        if (cItem.Id == id.Id && cItem.ListName == TypeName) {
            console.warn("CompareFullData 删除");
        } else {
            CompareFullDataTemp.push(cItem);
        }
    })
    //删除 已选产品
    var CurrentTemp = {};
    if (TypeName == "价格政策") {
        CurrentTemp = jzDataFixedPrice.filter(fItem => {
            if (fItem.Id == id.Id) {
                return true;
            }
            return false;
        })[0];
    }
    if (TypeName == "折扣政策") {
        CurrentTemp = jzDataDiscount.filter(fItem => {
            var PromotionHeadRecordId = id.recordTypeName__c;
            if (PromotionHeadRecordId == "Authorizer") {
                if (fItem.Id == id.Id && //方案Id
                    fItem.NormalDiscount__c_Input == id.NormalDiscount__c_Input && //非对象品折扣录入
                    fItem.GuaranteeDiscount__c_Input == id.GuaranteeDiscount__c_Input) { //对象品折扣录入
                    return true;
                }
            } else {
                if (fItem.NormalDiscount__c_Input == id.NormalDiscount__c_Input &&
                    fItem.Category__c == id.Category__c) { //折扣政策分类
                    return true;
                }
            }
            return false;
        })[0];
    }
    //匹配需要删除产品
    var ProductNumsTemp = [];
    var NewjzDataProduct = [];;
    if (TypeName == "价格政策") {
        jzDataProduct.forEach(proItem => {
            if (proItem.PromotionNo__c == CurrentTemp.PromotionNo__c) {
                ProductNumsTemp.push({
                    Id: proItem.Id,
                    num: proItem.Quantity
                })
            } else {
                NewjzDataProduct.push(proItem);
            }
        });
    } else if (TypeName == "折扣政策") {
        jzDataProduct.forEach(proItem => {
            var PromotionHeadRecordId = id.recordTypeName__c;
            if (PromotionHeadRecordId == "Authorizer") {
                if (CurrentTemp.Id == proItem.PromotionId && //方案Id
                    CurrentTemp.NormalDiscount__c_Input == proItem.NormalDiscount__c_Input && //非对象品折扣录入
                    CurrentTemp.GuaranteeDiscount__c_Input == proItem.GuaranteeDiscount__c_Input) { //对象品折扣录入
                    ProductNumsTemp.push({
                        Id: proItem.Id,
                        num: proItem.Quantity
                    })
                } else {
                    NewjzDataProduct.push(proItem);
                }
            } else {
                if (CurrentTemp.NormalDiscount__c_Input == proItem.NormalDiscount__c_Input &&
                    CurrentTemp.Category__c == proItem.Category__c) { //折扣政策分类
                    ProductNumsTemp.push({
                        Id: proItem.Id,
                        num: proItem.Quantity
                    })
                } else {
                    NewjzDataProduct.push(proItem);
                }
            }
        });
    }
    jzDataProduct = NewjzDataProduct;
    var newjzDataDefaults = [];
    var AddnumsTemp = [];
    jzDataDefault.forEach(defItem => {
        var defItemTemp = {
            ...{},
            ...defItem
        };
        ProductNumsTemp.forEach(pTempItem => {
            if (pTempItem.Id == defItem.Id) {
                defItemTemp.Quantity += pTempItem.num;
                AddnumsTemp.push(pTempItem.Id);
            }
        });
        newjzDataDefaults.push(defItemTemp);
    })
    jzDataDefault = newjzDataDefaults;
    //添加整条数据
    var PFTempArr = ProductNumsTemp.filter(pTempItem => {
        var flag = true;
        AddnumsTemp.filter(addItem => {
            if (addItem == pTempItem.Id) {
                flag = false;
            }
        })
        return flag;
    })
    jzDataDefaultNotChange.forEach(noChangeItem => {
        PFTempArr.forEach(pftItem => {
            if (pftItem.Id == noChangeItem.Id) {
                let newChangeItem = {
                    ...{},
                    ...noChangeItem
                };
                newChangeItem.Quantity = pftItem.num;
                jzDataDefault.push(newChangeItem);
            }
        })
    })
    CompareFullDataTempExp = CompareFullDataTemp;
    jzDataFixedPriceExp = jzDataFixedPrice;
    jzDataDiscountExp = jzDataDiscount;
    jzDataDefaultExp = jzDataDefault;
    jzDataDefaultNotChangeExp = jzDataDefaultNotChange;
    return jzDataProduct;
}
export function savecountLogic(jzDataFixedPrice,idStr){
    var arr = []
    jzDataFixedPrice.forEach(item => { //价格政策
        if (idStr == item.Id) {
            item.maxCounts = item.Counts
            arr.push(item);
        } else {
            arr.push(item);
        }
    });
    jzDataFixedPrice = arr;
    return jzDataFixedPrice;
}
export function ComparePushDataLogic(jzDataDefault,jzDataProduct,Asset_Model_No__c,Id,TypeName,jzDataProductParam,Quantity,num){
    let addArr = [];
    var newss = [].concat(jzDataDefault);
    var newDataDefault = newss.map(item => {
        if (item == undefined) {
            console.warn("undefined!!");
        }
        if (item.Product2.MDM_Model_No__c == Asset_Model_No__c) {
            let ItemTemp = {
                ...{},
                ...item
            };
            ItemTemp.Quantity = Quantity * num
            ItemTemp.PromotionNo__c = jzDataProductParam.PromotionNo__c;
            ItemTemp.Name = jzDataProductParam.Name;
            ItemTemp.TypeName = TypeName;
            ItemTemp.PromotionId = Id;
            addArr.push(ItemTemp);
            item.Quantity -= num * Quantity;
        }
        return item;
    })
    jzDataProduct = jzDataProduct.concat(addArr);
    jzDataProductExp = jzDataProduct;
    return newDataDefault;
}
export function saveAllDataProductFnChuanshen(jzDataFixedPrice,jzDataDiscount,quoId,QuoteData,jzDataProduct,jzDataDefault,ContractPrice){
    var newTemp = [];
    jzDataFixedPrice.forEach(item => { //价格政策
        var itemTemp = {
            ...{},
            ...item
        };
        itemTemp.typess = "价格政策 ";
        newTemp.push(itemTemp);
    });
    var newTemp2 = [];
    jzDataDiscount.forEach(item => { //折扣政策
        var itemTemp = {
            ...{},
            ...item
        };
        itemTemp.typess = "折扣政策";
        newTemp2.push(itemTemp);
    });
    var data = newTemp.concat(newTemp2);//20230213
    var ParamIdStr = quoId;
    var Trade__c = QuoteData[0].Opportunity.Trade__c;
    var NewData = ConsolidationScheme(data, ParamIdStr, Trade__c);
    var NewData1 = MergeProducts(jzDataProduct, jzDataDefault, data, ParamIdStr);
    var jsondatasss = JSON.stringify(NewData);
    var jsondatassss = JSON.stringify(NewData1);
    var Sales_Root__c = QuoteData[0].Opportunity.Sales_Root__c;
    var QuoteId = QuoteData[0].Id;
    var OpportunityId = QuoteData[0].OpportunityId;
    var dataChunanshen = {
        JsonStr: jsondatasss,
        ParamIdStr: ParamIdStr,
        JsonStr2: jsondatassss,
        QuoteId: QuoteId,
        SalesRootc: Sales_Root__c,
        ContractPrice: ContractPrice,
        OpportunityId: OpportunityId,
        DealerFinalPriceFc: QuoteData[0].Dealer_Final_Price_F__c,
        Agent1Agent2Pricec: QuoteData[0].Agent1_Agent2_Price__c
        
    };
    newTempExp = newTemp;
    return dataChunanshen;
}
export function saveAllDataProductFnPanduan(jzDataProduct,newTemp){
    var ifnull = true;
    var ifnunum=1;
    newTemp.forEach(ntp => { //价格政策
        if (ntp.HeTongTotal == undefined || ntp.HeTongTotal == 0) {
            ifnull = false;
        }
    });
    jzDataProduct.forEach(jzdp=>{
        if(jzdp.AgencyUnitPrice__c<0){
            ifnunum=2;
            return;
        }
    });
    ifnullExp = ifnull;
    return ifnunum;
}
export function QTcssE(pricePolicyflag){
    var QTcss = '';
    if(pricePolicyflag){
        QTcss="slds-button slds-button_neutral slds-button_stretch lexBorder";
    }else{
        QTcss="slds-button slds-button_neutral slds-button_stretch quobutton";
    }
    return QTcss;
}
export function CompareDataL(list,jzDataDefault){
    debugger
    var isChange = false;
    var TempsJzData = []
    TempsJzData = [].concat(jzDataDefault); //待选产品
    var TempsJzDataToCompare = []
    TempsJzData.forEach(item => {
        list.forEach(element => { //促销方案主数据关联产品
            if (element.Asset_Model_No__c == item.Product2.MDM_Model_No__c) {
                if (item.Quantity >= element.Quantity__c) {
                    isChange = true;
                    let CompareTemp = {
                        item: item,
                        element: element
                    }
                    TempsJzDataToCompare.push(CompareTemp);
                }
            }
        });
    })
    //add 0602
    var CheckMinNum = 0;
    var newTempsJzDataToCompare = []
    TempsJzDataToCompare.forEach(item => { //符合规则的产品
        var intNum = parseInt(item.item.Quantity / item.element.Quantity__c);
        if (CheckMinNum == 0) {
            CheckMinNum = intNum;
        }
        if (intNum < CheckMinNum) {
            CheckMinNum = intNum;
        }
    })
    TempsJzDataToCompare.forEach(item => {
        var newItem = {
            ...{},
            ...item.item
        };
        var newElement = {
            ...{},
            ...item.element
        };
        newItem.Quantity = item.element.Quantity__c * CheckMinNum;
        var newObj = {};
        newObj.item = newItem;
        newObj.element = newElement;
        newTempsJzDataToCompare.push(newObj);
    })
    TempsJzDataToCompare = [].concat(newTempsJzDataToCompare);
    isChangeExp = isChange;
    return TempsJzDataToCompare;
}
export function initquoT(responseObj,buttonIsShow,initDataTableFixedPrice,initDataTableDiscount,initDataTableOtherData,initDataTableCommonly){
    var QuoteData = responseObj;
    if(QuoteData[0].Dealer_Final_Price_F__c==undefined||QuoteData[0].Dealer_Final_Price_F__c===''){
        QuoteData[0].Dealer_Final_Price_F__c=0
    }
    if(QuoteData[0].Agent1_Agent2_Price__c==undefined||QuoteData[0].Agent1_Agent2_Price__c===''){
        QuoteData[0].Agent1_Agent2_Price__c=null;
    }
    debugger
    if (QuoteData[0].Quote_Decision__c != "√") {
        buttonIsShow = true;
        initDataTableFixedPrice.columns[7].editable = true;
        initDataTableFixedPrice.columns[10].editable = true;
        initDataTableDiscount.columns[2].editable = true;
        initDataTableDiscount.columns[3].editable = true;
        initDataTableDiscount.columns[4].editable = true;
        initDataTableDiscount.columns[5].editable = true;
        initDataTableOtherData.columns[3].editable = true;
        initDataTableCommonly.columns[3].editable = true;
    }else{
        buttonIsShow = false;
    }
    buttonIsShowE = buttonIsShow;
    initDTFP = initDataTableFixedPrice;
    initDTD = initDataTableDiscount;
    initDTOD = initDataTableOtherData;
    initDTC = initDataTableCommonly;
    return QuoteData;
}
//产品需要更新的字段
export function ChangeProductData(key) {
    var keyArr = [''];
    var flag = false;
    keyArr.forEach(item => {
        if (item == key) {
            flag = true;
        }
    })
    return flag;
}
export const initDataTableProduct2 = {
    columns: [{
            label: '产品型号',
            fieldName: 'Asset_Model_No__c',
            sortable: true,
            typeAttributes: {
                
            },
            hideDefaultActions: true,
        },
        {
            label: '产品名称',
            fieldName: 'Name__c',
            sortable: true,
            hideDefaultActions: true,
            initialWidth: 205,
        },
        {
            label: '数量',
            fieldName: 'Quantity',
            type: 'number',
            sortable: true,
            hideDefaultActions: true,
            cellAttributes: {
                alignment: 'right'
            },
            initialWidth: 88
        },
        {
            label: '保修类型',
            fieldName: 'warrantyType__c',
            sortable: true,
            hideDefaultActions: true,
        },
        {
            label: '方案代码',
            fieldName: 'PromotionNo__c',
            sortable: true,
            hideDefaultActions: true,
        },
        {
            label: '促销方案名称/产品系列',
            fieldName: 'Name',
            sortable: true,
            hideDefaultActions: true,
            initialWidth: 124
        },
        {
            label: '主报价',
            fieldName: 'ListPrice',
            type: 'number',
            sortable: true,
            hideDefaultActions: true,
            cellAttributes: {
                alignment: 'right'
            }
        },
        {
            label: '多年保价格小计',
            fieldName: 'NoDiscountTotal__c',
            type: 'number',
            sortable: true,
            hideDefaultActions: true,
            cellAttributes: {
                alignment: 'right'
            }
        },
        {
            label: '折扣',
            fieldName: 'Discount__c_Input',
            sortable: true,
            hideDefaultActions: true,
            cellAttributes: {
                alignment: 'right'
            }
        },
        {
            label: '合同单价',
            fieldName: 'AgencyUnitPrice__c',
            type: 'number',
            sortable: true,
            hideDefaultActions: true,
            cellAttributes: {
                alignment: 'right'
            },
            typeAttributes: {
                minimumFractionDigits: '2',
                maximumFractionDigits: '2'
            }
        },
        {
            label: '合同总价',
            fieldName: 'AgencySubtotal__c',
            type: 'number',
            sortable: true,
            hideDefaultActions: true,
            cellAttributes: {
                alignment: 'right'
            },
            typeAttributes: {
                minimumFractionDigits: '2',
                maximumFractionDigits: '2'
            }
        },
        
 
    ],
    sortInterfaces: false,
    searchColumns:initSearchFormProduct
}
 
export const initSearchForm2 = [{
    label: "方案代码",
    type: "text",
    name: "PromotionNo__cEqual",
    isInput: true
},
{
    label: "名称",
    type: "text",
    name: "NameLike",
    isInput: true
}
]
 
export const initDataTable2 = {
    columns: [{
            label: '方案代码',
            fieldName: 'PromotionNo__c',
            sortable: true,
            hideDefaultActions: true,
            // initialWidth: 100
        },
        {
            label: '名称',
            fieldName: 'Name',
            sortable: true,
            hideDefaultActions: true,
            initialWidth: 300
        },
        {
            label: '描述',
            fieldName: 'Description__c',
            sortable: true,
            hideDefaultActions: true,
            initialWidth: 300
        },
        {
            label: '促销价格',
            fieldName: 'Price_CNY__c',
            type: 'number',
            sortable: true,
            hideDefaultActions: true,
            cellAttributes: {
                alignment: 'right'
            },
            initialWidth: 140
        },
        {
            label: '是否包含多年保修价格',
            fieldName: 'if_Contain_Nod__c',
            sortable: true,
            type: 'boolean',
            hideDefaultActions: true,
            cellAttributes: {
                alignment: 'center'
            },
            initialWidth: 170
        },
        {
            label: '是否固定数量',
            type: 'boolean',
            fieldName: 'if_Fix__c',
            sortable: true,
            hideDefaultActions: true,
            cellAttributes: {
                alignment: 'center'
            },
            initialWidth: 130
        },
    ],
    sortInterfaces: false,
    searchColumns: initSearchForm2
}
export const initSearchFormFix2 = [{
    label: "方案代码",
    type: "text",
    name: "PromotionNo__cEqual",
    isInput: true
},
{
    label: "名称",
    type: "text",
    name: "NameLike",
    isInput: true
}
]
export const initDataTableFix2 = {
    columns: [{
            label: '方案代码',
            fieldName: 'PromotionNo__c',
            sortable: true,
            hideDefaultActions: true
        },
        {
            label: '名称',
            fieldName: 'Name',
            sortable: true,
            hideDefaultActions: true,
            initialWidth: 351
        },
        {
            label: '描述',
            fieldName: 'Description__c',
            sortable: true,
            hideDefaultActions: true,
            initialWidth: 327
        },
        {
            label: '促销价格',
            fieldName: 'Price_CNY__c',
            type: 'number',
            sortable: true,
            hideDefaultActions: true,
            cellAttributes: {
                alignment: 'right'
            }
        },
        {
            label: '是否包含多年保修价格',
            fieldName: 'if_Contain_Nod__c',
            type: 'boolean',
            sortable: true,
            hideDefaultActions: true,
            cellAttributes: {
                alignment: 'center'
            }
        },
        {
            label: '是否固定数量',
            fieldName: 'if_Fix__c',
            type: 'boolean',
            hideDefaultActions: true,
            sortable: true,
            cellAttributes: {
                alignment: 'center'
            }
        }
    ],
    sortInterfaces: false,
    searchColumns: initSearchFormFix2
}
export const initSearchFormDefalt2 = [{
    label: "产品型号",
    type: "text",
    name: "Asset_Model_No__c",
    isInput: true
},
{
    label: "产品名称",
    type: "text",
    name: "Name__c",
    isInput: true
}
]
export const initDataTableDefault2 = {
    columns: [{
            label: '产品型号',
            fieldName: 'Asset_Model_No__c',
            hideDefaultActions: true,
            sortable: true
        },
        {
            label: '产品名称',
            fieldName: 'Name__c',
            sortable: true,
            hideDefaultActions: true,
            initialWidth: 251
        },
        {
            label: '数量',
            fieldName: 'Quantity',
            type: 'number',
            sortable: true,
            hideDefaultActions: true,
            cellAttributes: {
                alignment: 'right'
            }
        },
        {
            label: '保修类型',
            fieldName: 'warrantyType__c',
            sortable: true,
            hideDefaultActions: true,
        },
        {
            label: '主报价',
            fieldName: 'ListPrice',
            type: 'number',
            hideDefaultActions: true,
            sortable: true,
            cellAttributes: {
                alignment: 'right'
            }
        },
        {
            label: '多年保价格小计',
            fieldName: 'NoDiscountTotal__c',
            type: 'number',
            hideDefaultActions: true,
            sortable: true,
            cellAttributes: {
                alignment: 'right'
            }
        },
 
    ],
    sortInterfaces: false,
    searchColumns: initSearchFormDefalt2
}
export const initSearchFormFixedPrice2 = [{
    label: "产品型号",
    type: "text",
    name: "Asset_Model_No__c",
    isInput: true
},
{
    label: "产品名称",
    type: "text",
    name: "Name__c",
    isInput: true
}
]
export const initDataTableFixedPrice2 = {
    columns: [{
            label: '方案代码',
            fieldName: 'PromotionNo__c',
            sortable: true,
            hideDefaultActions: true
        },
        {
            label: '促销方案名称/产品系列',
            fieldName: 'Name',
            sortable: true,
            hideDefaultActions: true,
            initialWidth: 196
        },
        {
            label: '方案描述',
            fieldName: 'Description__c',
            sortable: true,
            hideDefaultActions: true,
            initialWidth: 105
        },
        {
            label: '分类',
            fieldName: 'Category__c',
            sortable: true,
            hideDefaultActions: true
        },
        {
            label: '是否包含多年保修价格',
            fieldName: 'if_Contain_Nod__c',
            type: 'boolean',
            hideDefaultActions: true,
            sortable: true,
            cellAttributes: {
                alignment: 'center'
            }
        },
        {
            label: '是否固定数量',
            fieldName: 'if_Fix__c',
            type: 'boolean',
            hideDefaultActions: true,
            sortable: true,
            cellAttributes: {
                alignment: 'center'
            }
        },
        {
            label: '促销单价',
            fieldName: 'Price_CNY__c',
            type: 'number',
            sortable: true,
            hideDefaultActions: true,
            cellAttributes: {
                alignment: 'right'
            }
        },
        {
            label: '次数',
            fieldName: 'Counts',
            type: 'number',
            hideDefaultActions: true,
            sortable: true,
            cellAttributes: {
                class: {},
                alignment: 'right'
            },
            editable: false
        },
        {
            label: '多年保价格合计',
            fieldName: 'sumNoDiscountTotal',
            type: 'number',
            sortable: true,
            hideDefaultActions: true,
            cellAttributes: {
                alignment: 'right'
            }
        },
        {
            label: '促销总价',
            fieldName: 'Total',
            type: 'number',
            hideDefaultActions: true,
            sortable: true,
            cellAttributes: {
                alignment: 'right'
            }
        },
        {
            label: '合同价格',
            fieldName: 'HeTongTotal',
            type: 'number',
            hideDefaultActions: true,
            sortable: true,
            cellAttributes: {
                class: {},
                alignment: 'right'
            },
            editable: false,
            initialWidth: 100
        },
 
    ],
    sortInterfaces: [],
    searchColumns: initSearchFormFixedPrice2
}
export const initSearchFormDiscount2 = []
export const initDataTableDiscount2 = {
    columns: [{
            label: '经销商分类',
            fieldName: 'JxsType',
            sortable: true,
            hideDefaultActions: true
        },
        {
            label: '分类',
            fieldName: 'Category__c',
            sortable: true,
            hideDefaultActions: true
        },
        // {
        //     label: '对象品折扣',
        //     fieldName: 'GuaranteeDiscount__c',
        //     sortable: true,
        //     cellAttributes: {
        //         alignment: 'center'
        //     }
        // },
        // {
        //     label: '非对象品折扣',
        //     fieldName: 'NormalDiscount__c',
        //     sortable: true,
        //     cellAttributes: {
        //         alignment: 'center'
        //     }
        // },
        {
            label: '对象品折扣',
            fieldName: 'GuaranteeDiscount__c_Input',
            editable: false,
            hideDefaultActions: true,
            cellAttributes: {
                class: {},
                alignment: 'right'
            },
        },
        {
            label: '对象品合同金额',
            fieldName: 'GuaranteeDiscount_H_Money__c',
            type: 'number',
            editable: false,
            hideDefaultActions: true,
            cellAttributes: {
                class: {},
                alignment: 'right'
            },
            typeAttributes: {
                minimumFractionDigits: '2',
                maximumFractionDigits: '2'
            }
        },
        {
            label: '非对象品折扣',
            fieldName: 'NormalDiscount__c_Input',
            editable: false,
            hideDefaultActions: true,
            cellAttributes: {
                class: {},
                alignment: 'right'
            },
        },
        {
            label: '非对象品合同金额',
            fieldName: 'NormalDiscount_H_Money__c',
            type: 'number',
            hideDefaultActions: true,
            editable: false,
            cellAttributes: {
                class: {},
                alignment: 'right'
            },
            typeAttributes: {
                minimumFractionDigits: '2',
                maximumFractionDigits: '2'
            }
        },
        {
            label: '合同价格',
            fieldName: 'HeTongPrice',
            type: 'number',
            hideDefaultActions: true,
            editable: false,
            cellAttributes: {
                class: {},
                alignment: 'right'
            },
            typeAttributes: {
                minimumFractionDigits: '2',
                maximumFractionDigits: '2'
            }
        }
    ],
    sortInterfaces: [],
    searchColumns: initSearchFormDiscount2
}
export const initSearchFormSpecial2 = []
export const initDataTableSpecial2 = {
    columns: [{
            label: '编码',
            fieldName: 'PromotionNo__c',
            sortable: true,
            hideDefaultActions: true
        },
        {
            label: '协议产品',
            fieldName: 'Department__c',
            sortable: true,
            hideDefaultActions: true
        },
        {
            label: '对象品折扣',
            fieldName: 'GuaranteeDiscount__c',
            sortable: true,
            hideDefaultActions: true,
            cellAttributes: {
                alignment: 'right'
            }
        },
        {
            label: '非对象品折扣',
            fieldName: 'NormalDiscount__c',
            sortable: true,
            hideDefaultActions: true,
            cellAttributes: {
                alignment: 'right'
            }
        },
        {
            label: '协议编码',
            fieldName: 'Contract__c',
            sortable: true,
            hideDefaultActions: true
        },
        {
            label: '经销商',
            fieldName: 'Agency__Name',
            sortable: true,
            hideDefaultActions: true
        },
    ],
    sortInterfaces: false,
    searchColumns: initSearchFormSpecial2
}
export const initSearchFormOtherData2 = []
export const initDataTableOtherData2 = {
    columns: [{
            label: '产品型号',
            fieldName: 'Asset_Model_No__c',
            sortable: true,
            hideDefaultActions: true,
            typeAttributes: {
            },
        },
        {
            label: '产品名称',
            fieldName: 'Name__c',
            hideDefaultActions: true,
            sortable: true,
            
            initialWidth: 268
        },
        {
            label: '数量',
            fieldName: 'Quantity',
            type: 'number',
            hideDefaultActions: true,
            sortable: true,
            cellAttributes: {
                alignment: 'right'
            }
        },
        {
            label: '使用数量',
            fieldName: 'SplitQuantity',
            type: 'number',
            sortable: true,
            hideDefaultActions: true,
            cellAttributes: {
                alignment: 'right',
                class: {}
            },
            editable: false
        },
        {
            label: '保修类型',
            fieldName: 'warrantyType__c',
            sortable: true,
            hideDefaultActions: true,
        },
        {
            label: '主报价',
            fieldName: 'ListPrice',
            type: 'number',
            sortable: true,
            hideDefaultActions: true,
            cellAttributes: {
                alignment: 'right'
            }
        },
        {
            label: '多年保价格小计',
            fieldName: 'NoDiscountTotal__c',
            type: 'number',
            sortable: true,
            hideDefaultActions: true,
            cellAttributes: {
                alignment: 'right'
            }
        },
    ],
    sortInterfaces: false,
    searchColumns: initSearchFormOtherData2
}
export const initSearchFormCommonly2 = [{
    label: "方案代码",
    type: "text",
    name: "PromotionNo__cEqual",
    isInput: true
},
{
    label: "名称",
    type: "text",
    name: "NameLike",
    isInput: true
}
]
export const initDataTableCommonly2 = {
    columns: [{
            label: '产品型号',
            fieldName: 'Asset_Model_No__c',
            sortable: true,
            hideDefaultActions: true,
            typeAttributes: {
            },
        },
        {
            label: '产品名称',
            fieldName: 'Name__c',
            sortable: true,
            hideDefaultActions: true,
            initialWidth: 268
        },
        {
            label: '数量',
            fieldName: 'Quantity',
            type: 'number',
            hideDefaultActions: true,
            sortable: true,
            cellAttributes: {
                alignment: 'right'
            }
        },
        {
            label: '使用数量',
            fieldName: 'SplitQuantity',
            type: 'number',
            sortable: true,
            hideDefaultActions: true,
            cellAttributes: {
                alignment: 'right',
                class: {}
            },
            editable: false
        },
        {
            label: '保修类型',
            fieldName: 'warrantyType__c',
            sortable: true,
            hideDefaultActions: true,
        },
        {
            label: '主报价',
            fieldName: 'ListPrice',
            type: 'number',
            sortable: true,
            hideDefaultActions: true,
            cellAttributes: {
                alignment: 'right'
            }
        },
        {
            label: '多年保价格小计',
            fieldName: 'NoDiscountTotal__c',
            type: 'number',
            sortable: true,
            hideDefaultActions: true,
            cellAttributes: {
                alignment: 'right'
            }
        },
 
    ],
    sortInterfaces: false,
    searchColumns: initSearchFormCommonly2
}