gjj
2023-02-07 08690e2fd123a710406a101a2a5bd98fa0992502
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
<template>
  <create-view
    :loading="loading"
    :body-style="{ height: '100%'}">
    <flexbox
      direction="column"
      align="stretch"
      class="crm-create-container">
      <flexbox class="crm-create-header">
        <div style="flex:1;font-size:18px;color:#333;font-weight: 700;">{{ title }}</div>
        <img
          class="close"
          src="@/assets/img/task_close.png"
          @click="hidenView" >
      </flexbox>
      <div class="crm-create-flex">
        <create-sections title="基本信息">
          <flexbox
            direction="column"
            align="stretch">
            <div class="crm-create-body">
              <el-form
                ref="dialogRef"
                :model="formInline"
                :rules="formRules"
                label-position="left"
                label-width="auto"
                class="crm-create-box">
                <el-form-item
                  v-for="(item, index) in tableList"
                  :key="index"
                  :prop="item.field"
                  :class="{ 'crm-create-block-item': item.showblock, 'crm-create-item': !item.showblock }"
                  :style="{'padding-left': getPaddingLeft(item, index), 'padding-right': getPaddingRight(item, index)}">
                  <div
                    slot="label"
                    style="display: inline-block;">
                    <div style="margin:5px 0;font-size:16px;word-wrap:break-word;word-break:break-all;">
                      {{ item.value }}{{item.value?':': ''}}
                    </div>
                  </div>
                  <!-- 员工 和部门 为多选(radio=false)  relation 相关合同商机使用-->
                    <template v-if="item.type === 'select'">
                      <el-select
                        v-model="formInline[item.field]"
                        filterable
                        placeholder="请选择"
                        style='width: 100%;'
                        @change='getSelectVal(item.field)'>
                        <el-option
                          v-for="optionItem in optionsList[item.field].list"
                          :key="optionItem.value"
                          :label="optionItem.name"
                          :value="optionItem.value"/>
                      </el-select>
                    </template>
                    <template v-else-if="item.type === 'selectCheckout'">
                      <el-select
                        v-model="formInline[item.field]"
                        :popper-append-to-body="false"
                        popper-class="select-popper-class"
                        filterable
                        placeholder="请选择">
                        <el-option
                          v-for="item in optionsList[item.field].list"
                          :key="item.Id"
                          :label="item.DepartmentName"
                          :value="item.Id"/>
                      </el-select>
                    </template>
                    <template slot-scope="scope" v-else-if="item.type === 'relationInput'">
                      <el-popover
                        :offset="250"
                        placement="right"
                        popper-class="no-padding-popover"
                        width="700"
                        :disabled="action.type === 'update'"
                        trigger="click">
                        <div class="pop-container">
                          <flexbox class="pop-header">
                            <div class="pop-name">关联客户</div>
                            <!--<div class="detail"></div>-->
                            <img
                              class="pop-close"
                              src="@/assets/img/task_close.png"
                              @click="hidenRelationInput" >
                          </flexbox>
                          <flexbox class="pop-content">
                            <div class="pop-cropper-box">
                              <el-input class='pop-searchInput' v-model='popSearch' placeholder='请输入关键字'>
                               <template slot="append"><el-button  type="primary" class='pop-searchBtn' @click='getCustomerTable'>查询</el-button></template>
                              </el-input>
                            </div>
                          </flexbox>
                          <flexbox class="pop-content">
                            <el-table
                              class="pop-cropper-table"
                              v-loading="popLoading"
                              :data="popData"
                              :cell-style="popCellStyle"
                              :header-cell-style="headerCellStyle"
                              height="250"
                              style="margin-right:3px;"
                              highlight-current-row
                              @row-click="handlePopRowClick">
                              <el-table-column
                                v-for="(item, index) in popFieldList"
                                :key="index"
                                :prop="item.field"
                                :label="item.value"
                                :formatter="fieldFormatter"
                                align="center"
                                header-align="center"
                                show-overflow-tooltip/>
                            </el-table>
                          </flexbox>
                          <div class="p-contianer">
                            <el-pagination
                              :current-page="currentPopPage"
                              :page-sizes="pagePopSizes"
                              :page-size.sync="pagePopSize"
                              :total="totalPop"
                              class="p-bar"
                              layout="total, sizes, prev, pager, next, jumper"
                              @size-change="handlePopSizeChange"
                              @current-change="handlePopCurrentChange"/>
                          </div>
                        </div>
                        <el-input slot="reference" class='relationInput'
                         placeholder='请点击选择客户'
                         :disabled='true' v-model="customerChosed"></el-input>
                      </el-popover>
                    </template>
                    <template v-else-if="item.type === 'radio'">
                      <el-radio-group v-model="formInline[item.field]">
                        <el-radio :label="1">男</el-radio>
                        <el-radio :label="2">女</el-radio>
                      </el-radio-group>
                    </template>
                    <template v-else-if="item.type === 'switch'">
                      <el-switch v-model="formInline[item.field]" @change='getSwitch(item.field)'></el-switch>
                    </template>
                    <template v-else-if="item.type === 'inputPopover'">
                      <el-popover
                        class='pop'
                        :disabled="(action.type === 'update'&&crmType === 'customer') ||item.disabled"
                        :offset="250"
                        placement="right"
                        popper-class="no-padding-popover"
                        width="500"
                        trigger="click">
                        <div class="container">
                            <flexbox class="header">
                              <div class="name">行业</div>
                              <!--<div class="detail"></div>-->
                              <img
                                class="close"
                                src="@/assets/img/close.png"
                                @click="hidenPopoverView" >
                            </flexbox>
                            <flexbox class="content">
                              <div v-for="(item,index) of rightsList" :key="index" class='content-wrap'>
                                <p>{{rightsList[index].CategoryName || '暂无'}}</p>
                                <el-radio-group v-model="radioInput" class='con-group' :disabled='isOtherOpt'>
                                  <el-radio
                                    v-for="(item, i) in rightsList[index].IndustryData"
                                    @change="getRadioInput(item, i)"
                                    :key="item"
                                    :label="item"
                                    :value="item">{{item}}</el-radio>
                                </el-radio-group>
                              </div>
                              <!--<div class='otherOpt'>其他:请注明:
                              <el-input
                                  v-model="otherInput"
                                  maxlength="10"
                                  @blur='blurOtherOpt'
                                  @focus='getOtherOpt'/>
                              </div>-->
                            </flexbox>
                            <flexbox class="popover-foot">
                              <el-button @click="hidenPopoverView" style='margin-right:16px;'>取 消</el-button>
                              <el-button
                                type="primary"
                                @click="setIndustry">确 定</el-button>
                            </flexbox>
                        </div>
                        <el-input slot="reference" :class="(action.type === 'update'&&crmType === 'customer')?'cn':'inputPopover'" placeholder='请点击选择行业' :disabled='true' v-model="formInline['radioInput']" ></el-input>
                      </el-popover>
 
                    </template>
                    <template v-else-if="item.type === 'cascaderSingle'">
                      <el-cascader
                        ref="salesCas"
                        placeholder="请选择销售员"
                        :options="salesManList"
                        :props="{
                          children: 'children',
                          label: 'Name',
                          value: 'Id'
                        }"
                        v-model="salesId"
                        style="width: 100%;"
                        @change='getUser'/>
                    </template>
                    <template v-else-if="item.type === 'doubleSelect'">
                      <div class='doubleSelect'>
                        <el-select
                            v-model="formInline[item.field]"
                            filterable
                            class='leftSelect'
                            placeholder="请选择"
                            @change='getSelectVal(item.field)'>
                            <el-option
                              v-for="(optionItem, index) in optionsList[item.field].list[0]"
                              :key="index"
                              :label="optionItem"
                              :value="index"/>
                          </el-select>
                          <el-select
                            v-model="formInline[item.field]"
                            filterable
                            class='rightSelect'
                            placeholder="请选择"
                            @change='getSelectVal(item.field)'>
                            <el-option
                              v-for="(optionItem, index) in optionsList[item.field].list[1]"
                              :key="index"
                              :label="optionItem"
                              :value="index"/>
                          </el-select>
                      </div>
                    </template>
                    <template v-else-if="item.type === 'file'">
                      <el-input
                          v-model="file.name"
                          :disabled="true"
                          placeholder='请点击选择文件'/>
                        <el-button
                          type="primary"
                          @click="selectFile">选择文件</el-button>
                    </template>
                    <template v-else-if="item.type === 'radioList'">
                      <el-radio-group v-model="formInline[item.field]" class='radioList' @change='getPropertyName'>
                        <el-radio
                          v-for="(optionItem, index) in optionsList[item.field].list"
                          :key="index"
                          :label="optionItem.PropertyName"
                          :value="optionItem.PropertyName"></el-radio>
                      </el-radio-group>
                    </template>
                    <template v-else-if="item.type === 'date'">
                      <el-date-picker
                        v-model="formInline[item.field]"
                        style="width: 100%;"
                        type="date"
                        value-format="yyyy-MM-dd"
                        placeholder="选择日期"/>
                    </template>
                    <template v-else-if="item.type === 'map_address'">
                      <flexbox-item style="width: 100%;">
                        <XhCustomerAddress
                        :disabled="(action.type === 'update'&&crmType === 'customer') || item.disabled"
                        :hideArea='true'
                        :province="formInline[item.field].province"
                        :city="formInline[item.field].city"
                        @province="selectProvince"
                        @city="selectCity">
                        </XhCustomerAddress>
                        <!--<v-distpicker
                          :disabled="(action.type === 'update'&&crmType === 'customer') || item.disabled"
                          :province="formInline[item.field].province"
                          :city="formInline[item.field].city"
                          :area="formInline[item.field].area"
                          hide-area
                          @province="selectProvince"
                          @city="selectCity"/>-->
                          <!--hide-area-->
                      </flexbox-item>
                    </template>
                    <component
                      ref='xhProduct'
                      v-else-if="item.type === 'product'"
                      :is="item.type | typeToComponentName"
                      :key="timer"
                      :isLC='isLC'
                      :value="formInline[item.field]"
                      :index="index"
                      :item="item"
                      :relation="item.relation"
                      :radio="false"
                      :disabled="item.disabled"
                      :customerId="formInline['CustomerId']"
                      @value-change="fieldValueChange"/>
                    <el-input placeholder="注册信息、合作伙伴、竞争对手、以及相关预算等" type="textarea" v-model="formInline[item.field]"  v-else-if="item.type === 'textarea'" class='areaInput'>
                      </el-input>
                    <el-input placeholder="请输入" type="number" min='0' max='1000' v-model="formInline[item.field]"  v-else-if="item.type === 'number'">
                    </el-input>
                    <el-tooltip effect="light" :disabled='!item.tips' :content="item.tips" placement="right" v-else-if="item.type === 'disInput'">
                      <el-input
                        class='disInput'
                        placeholder="自动生成"
                        v-model="formInline[item.field]"
                        :disabled="item.disabled "/>
                    </el-tooltip>
                    <el-tooltip effect="light" :disabled='!item.tips' :content="item.tips" placement="right" v-else>
                      <el-input
                        placeholder="请输入"
                        v-model="formInline[item.field]"
                        :disabled="(action.type === 'update'&&item.field === 'CustomerName') || item.disabled"/>
                    </el-tooltip>
                  <!--<component
                    name='createcom'
                    :is="item.type | typeToComponentName"
                    :value="item.value"
                    :index="index"
                    :item="item"
                    :relation="item.relation"
                    :radio="false"
                    :disabled="item.disabled"
                    @value-change="fieldValueChange"/>-->
                </el-form-item>
              </el-form>
            </div>
          </flexbox>
        </create-sections>
        <create-sections title="联系人信息" v-if="crmType === 'customer'">
          <flexbox
            direction="column"
            align="stretch">
            <div class="crm-create-body">
              <el-form
                ref="userDialogRef"
                label-position="left"
                label-width="auto"
                class="crm-create-box"
                :model="formInline"
                :rules="dialogUserRules">
                <el-form-item
                  v-for="(item, index) in tableUserList"
                  :label="item.value"
                  :prop="item.field"
                  :class="{ 'crm-create-block-item': item.showblock, 'crm-create-item': !item.showblock }"
                  :style="{'padding-left': getPaddingLeft(item, index), 'padding-right': getPaddingRight(item, index)}"
                  :key="index">
                  <div
                    slot="label"
                    style="display: inline-block;">
                    <div style="margin:5px 0;font-size:16px;word-wrap:break-word;word-break:break-all;">
                      {{ item.value }}:
                    </div>
                  </div>
                  <el-input
                    v-model="formInline[item.field]"
                    :disabled="item.disabled "/>
                </el-form-item>
              </el-form>
            </div>
          </flexbox>
        </create-sections>
        <create-sections
          v-if="showExamine"
          title="审核信息">
          <div
            v-if="examineInfo.examineType===1 || examineInfo.examineType===2"
            slot="header"
            class="examine-type">{{ examineInfo.examineType===1 ? '固定审批流' : '授权审批人' }}</div>
          <create-examine-info
            ref="examineInfo"
            :types="'crm_' + crmType"
            :types-id="action.id"
            @value-change="examineValueChange"/>
        </create-sections>
      </div>
      <input
      id="importInputFile"
      type="file"
      accept=".csv, application/vnd.openxmlformats-officedocument.spreadsheetml.sheet, application/vnd.ms-excel"
      @change="uploadFile">
      <div class="handle-bar">
        <el-button
          class="handle-button"
          @click.native="hidenView">取消</el-button>
        <el-button
          :disabled="isClicked || (crmType === 'customer'&&radioInput === '')||(crmType !== 'customer'&&customerChosed === '')"
          class="handle-button"
          type="primary"
          @click.native="saveField(false)">保存</el-button>
        <el-button
          v-show="crmType === 'business'"
          :disabled="isClicked || crmType !== 'customer'&&customerChosed === ''||isSubmit"
          class="handle-button"
          type="primary"
          @click.native="saveField(true)">保存并申报</el-button>
        <!--<el-button
          class="handle-button"
          type="primary"
          @click.native="saveField(false)">{{ sureBtnTitle }}</el-button> -->
      </div>
      <el-dialog
        title="提交申报"
        :visible.sync="isCommited"
        width="24%"
        append-to-body
        class='productTitle'
        :before-close="handleClose">
        <div class='pushBody'>
          <div class='hintWord'>
            <i class="el-icon-warning" style="color: #e6a23c;"></i>
            <span>商机提交申报后,不能撤回修改。请确保提交信息准确有效!</span>
          </div>
          <div class='hintSelect'>
            <span>是否跨区:</span>
            <el-switch v-model="isCrossArea" @change='getCrossArea'></el-switch>
          </div>
          <div class='hintSelect' v-if="isUserSelect">
            <span>审批人:</span>
            <el-select v-model="pushStatus" placeholder="请选择">
              <el-option
                v-for="item in pushOptions"
                :key="item.UserId"
                :label="item.Name"
                :value="item.UserId">
              </el-option>
            </el-select>
          </div>
        </div>
        <span slot="footer" class="dialog-footer">
          <el-button @click="handleClose" class='closePushBtn'>取 消</el-button>
          <el-button type="primary" @click="saveField(false)" class='surePushBtn'>提交</el-button>
        </span>
      </el-dialog>
    </flexbox>
  </create-view>
</template>
<script type="text/javascript">
// import crmTypeModel from '@/views/clients/model/crmTypeModel'
import CreateView from '@/components/CreateView'
import CreateSections from '@/components/CreateSections'
import CreateExamineInfo from '@/components/Examine/CreateExamineInfo'
import VDistpicker from 'v-distpicker'
import {
// regexIsCRMNumber,
// regexIsCRMMoneyNumber,
// regexIsCRMMobile,
// regexIsCRMEmail,
// objDeepCopy
} from '@/utils'
import { GetDepartmentUserChildList, GetDepartmentAreaList } from '@/api/systemManagement/departmentManage'
import {GetCusomterNumber, GetIndustryListChildrenData, GetContacterNumber, GetSalesChanceNumber, GetProjectPropertyData, GetExtendProjectPropertyData, GetSalesChanceName, GetWxSpUserList} from '@/api/common'
import Lockr from 'lockr'
// import { isArray } from '@/utils/types'
 
import {
  XhInput,
  XhTextarea,
  XhSelect,
  XhMultipleSelect,
  XhDate,
  XhDateTime,
  XhUserCell,
  XhStructureCell,
  XhFiles,
  CrmRelativeCell,
  XhProuctCate,
  XhProduct,
  XhBusinessStatus,
  XhCustomerAddress,
  XhReceivablesPlan // 回款计划期数
} from '@/components/CreateCom'
 
import { AddCustomer, UpdateCustomer, GetPersonalCustomerPageList, GetCustomerDetail } from '@/api/customermanagement/customerManage'
import { AddContacter, UpdateContacter, GetContacterDetail } from '@/api/customermanagement/contacts'
import { AddSalesChance, UpdateSalesChance, GetSalesChanceDetail } from '@/api/customermanagement/business'
import axios from 'axios'
 
export default {
  name: 'CrmCreateView', // 所有新建效果的view
  components: {
    CreateView,
    CreateSections,
    CreateExamineInfo, // 审核信息
    XhInput,
    XhTextarea,
    XhSelect,
    XhMultipleSelect,
    XhDate,
    XhDateTime,
    XhUserCell,
    XhStructureCell,
    XhFiles,
    CrmRelativeCell,
    XhProuctCate,
    XhProduct,
    XhBusinessStatus,
    XhCustomerAddress,
    XhReceivablesPlan,
    VDistpicker
  },
  filters: {
    /** 根据type 找到组件 */
    typeToComponentName (formType) {
      if (
        formType === 'text' ||
        formType === 'number' ||
        formType === 'floatnumber' ||
        formType === 'mobile' ||
        formType === 'email'
      ) {
        return 'XhInput'
      } else if (formType === 'textarea') {
        return 'XhTextarea'
      } else if (formType === 'select' || formType === 'business_status') {
        return 'XhSelect'
      } else if (formType === 'checkbox') {
        return 'XhMultipleSelect'
      } else if (formType === 'date') {
        return 'XhDate'
      } else if (formType === 'datetime') {
        return 'XhDateTime'
      } else if (formType === 'user') {
        return 'XhUserCell'
      } else if (formType === 'structure') {
        return 'XhStructureCell'
      } else if (formType === 'file') {
        return 'XhFiles'
      } else if (
        formType === 'contacts' ||
        formType === 'customer' ||
        formType === 'contract' ||
        formType === 'business'
      ) {
        return 'CrmRelativeCell'
      } else if (formType === 'category') {
        // 产品类别
        return 'XhProuctCate'
      } else if (formType === 'business_type') {
        // 商机类别
        return 'XhBusinessStatus'
      } else if (formType === 'product') {
        return 'XhProduct'
      } else if (formType === 'map_address') {
        return 'XhCustomerAddress'
      } else if (formType === 'receivables_plan') {
        return 'XhReceivablesPlan'
      }
    }
  },
  props: {
    // CRM类型
    crmType: {
      type: String,
      default: ''
    },
    /**
     * save:添加、update:编辑(action_id)、read:详情、index:列表
     * relative: 相关 添加(目前用于客户等相关添加) 如果有relativeData 直接合并入上传
     */
    action: {
      type: Object,
      default: () => {
        return {
          type: 'save',
          id: '',
          data: {} // 编辑所需信息
        }
      }
    }
  },
  data () {
    var validateUsername = (rule, value, callback) => {
      let isPhone = /^1\d{10}$/
      let isMob = /^0\d{2,3}-?\d{7,8}$/
      if (value && value === 'admin') {
        callback()
      } else if (isPhone.test(value) || isMob.test(value)) {
        callback()
      } else {
        callback(new Error('目前只支持中国大陆的手机号码或座机号'))
      }
    }
    return {
      // 标题展示名称
      title: '',
      timer: '',
      loading: false,
      saveAndCreate: false, // 保存并新建
      file: { name: '' },
      // 自定义字段验证规则
      crmRules: {
        CustomerName: [
          { required: true, message: '客户名称不能为空', trigger: 'blur' }
        ],
        SaleOwerId: [
          { required: true, message: '请选择', trigger: 'blur' }
        ],
        CompanyType: [
          { required: true, message: '请选择', trigger: 'blur' }
        ],
        FirmSize: [
          { required: true, message: '请输入客户设计人数', trigger: 'blur' }
        ],
        mapAddress: [
          { required: true, message: '请选择地区', trigger: 'blur' }
        ],
        radioInput: [
          { required: true, message: '请选择行业', trigger: 'blur' }
        ],
        Address: [
          { required: true, message: '请输入通信地址', trigger: 'blur' }
        ],
        PostNumber: [
          { required: true, message: '请输入正确的客户邮编', pattern: /^[0-9]{6}$/, trigger: 'blur' }
        ]
      },
      dialogRules: {
        RealName: [
          { required: true, message: '联系人姓名不能为空', trigger: 'blur' }
        ],
        CustomerId: [
          { required: true, message: '客户名称不能为空', type: '', trigger: 'blur' }
        ],
        MobilePhone: [
          { required: true, message: '联系人手机号码不能为空' },
          {
            validator: validateUsername,
            trigger: 'blur'
          }
        ],
        OfficePhone: [
          { required: false, message: '联系人座机号码不能为空' },
          {
            validator: validateUsername,
            trigger: 'blur'
          }
        ],
        JobPosition: [
          { required: true, message: '联系人职位不能为空', trigger: 'blur' }
        ],
        Email: [
          {
            // eslint-disable-next-line no-useless-escape
            pattern: /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/,
            message: '请输入正确的邮箱格式',
            trigger: 'blur',
            required: true
          }
        ]
      },
      busDialogRules: {
        // ChanceNumber: [
        //   { required: true, message: '商机编号不能为空', trigger: 'blur' }
        // ],
        CustomerId: [
          { required: true, message: '请选择客户', trigger: 'blur' }
        ],
        // ContacterName: [
        //   { required: true, message: '请选择联系人', trigger: 'blur' }
        // ],
        // ContacterMobile: [
        //   { required: true, message: '联系人方式不能为空' },
        //   {
        //     validator: validateUsername,
        //     trigger: 'blur'
        //   }
        // ],
        OwerUserId: [
          { required: true, message: '请选择负责人', trigger: 'blur' }
        ],
        ChanceRequestType: [
          { required: true, message: '请选择商机类型', trigger: 'blur' }
        ],
        ExpectedDate: [
          { required: true, message: '预计成交日期', trigger: 'blur' }
        ]
      },
      dialogUserRules: {
        Contacter: [
          { required: true, message: '联系人不能为空', trigger: 'blur' }
        ],
        ContactMobile: [
          { required: true, message: '联系人手机号码不能为空' },
          {
            validator: validateUsername,
            trigger: 'blur'
          }
        ],
        OfficePhone: [
          { required: false, message: '联系人座机号码不能为空' },
          {
            validator: validateUsername,
            trigger: 'blur'
          }
        ],
        Email: [
          {
            // eslint-disable-next-line no-useless-escape
            pattern: /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/,
            message: '请输入正确的邮箱格式',
            trigger: 'blur',
            required: true
          }
        ],
        JobPosition: [
          { required: true, message: '请输入联系人职务' },
          {
            trigger: 'blur'
          }
        ]
      },
      // 自定义字段信息表单
      crmForm: {
        crmFields: []
      },
      // 审批信息
      examineInfo: {},
      formInline: {
        mapAddress: {
          province: '',
          city: ''
        }
      },
      customerChosed: '',
      otherInput: '',
      isOtherOpt: false,
      rightsList: [],
      salesManList: [],
      salesId: '',
      optionsList: {
        CustomerStatus: {
          field: 'CustomerStatus',
          list: ['潜在客户', '高意向潜在客户', '试用客户', '成交客户', '失败关闭', '销售线索', '在谈客户', '在谈休眠客户']
        },
        CustomerSource: {
          field: 'CustomerSource',
          list: ['电话来访', '公司分配', '客户介绍', '独立开发', '朋友介绍', ' 广告宣传', '市场活动', '合作伙伴', '公开招标', '老客户', '代理商', '400百度', '其他400', '老客户介绍', '代理商客户', '电话陌生拜访', '直接访问', '个人自找', '项目合作', '金蝶商机', '公司电话', '后台注册', '二次销售', '其他']
        },
        CustomerType: {
          field: 'CustomerType',
          list: ['大客户', '区域客户']
        },
        CostomerCategory: {
          field: 'CostomerCategory',
          list: ['普通客户', 'VIP客户', '合作伙伴', '竞争对手', '竞争对手客户', '集成商', '代理商', '供应商', '其他']
        },
        Industry: {
          field: 'Industry',
          list: ['电子', '通讯', '咨询', '教育', '酒店', '保险', '运输', '机械', '零售', '物流', '技术', '餐饮', '服装', '银行', '能源', '工程', '娱乐', '环境', '卫生保健', '食品饮料', '休闲娱乐', '公共事业', '生物技术', '其他行业']
        },
        ContacterMobile: {
          field: 'ContacterMobile',
          list: ['电话', '微信', '信息', '其他']
        },
        DepartmentId: {
          field: 'DepartmentId',
          list: ['初期沟通', '需求分析', '方案报价', '商务谈判', '成功', '搁置']
        },
        ChanceType: {
          field: 'ChanceType',
          list: ['暂无', '新业务', '已有业务来往']
        },
        ChanceSource: {
          field: 'ChanceSource',
          list: ['电话来访', '公司分配', '客户介绍', '独立开发', '朋友介绍', ' 广告宣传', '市场活动', '合作伙伴', '公开招标', '老客户', '代理商', '400百度', '其他400', '老客户介绍', '代理商客户', '电话陌生拜访', '直接访问', '个人自找', '项目合作', '金蝶商机', '公司电话', '后台注册', '二次销售', '其他']
        },
        projectStatus: {
          field: 'projectStatus',
          list: ['无', 'LC和商业商机', 'Solution行业商机', '仅提交LC商机']
        },
        winChance: {
          field: 'winChance',
          list: [{0: '无', 1: 'LC和商业商机', 2: 'Solution行业商机', 3: '仅提交LC商机'}, {0: '无', 1: 'LC和商业商机', 2: 'Solution行业商机', 3: '仅提交LC商机'}]
        },
        ProjectProperty: {
          field: 'projectType',
          list: ['普通项目', 'LC协作', 'ACAD项目', 'ACAD重点客户', 'AEC项目', 'AEC倍增计划', 'MFG项目', 'MNE项目', '企业信息特例', '特别案例', '区域重点客户']
        },
        ExtendProjectProperty: {
          field: 'ExtendProjectProperty',
          list: ['LC协作(ACAD)', 'LC协作(AEC)', 'LC协作(MFG)', 'LC协作(MNE)']
        },
        LcAgency: {
          field: 'LcAgency',
          list: [{value: 0, name: '暂无'}, {value: 1, name: '嘉禾'}, {value: 2, name: '信品'}]
        },
        CompanyType: {
          field: 'CompanyType',
          list: [{value: 1, name: '国企'}, {value: 2, name: '外企'}, {value: 3, name: '民营'}, {value: 4, name: '其他'}]
        },
        SalesChanceStage: {
          field: 'SalesChanceStage',
          list: [{value: 1, name: '初期沟通'}, {value: 2, name: '需求分析'}, {value: 3, name: '方案报价'}, {value: 4, name: '商务谈判'}, {value: 5, name: '成功'}, {value: 6, name: '搁置'}]
        },
        SalesChanceCustomerType: {
          field: 'SalesChanceCustomerType',
          list: [{value: 1, name: '普通客户'}, {value: 2, name: '大客户AEC客户'}, {value: 3, name: '大客户MFG客户'}, {value: 4, name: '大客户MNE客户'}]
        },
        ChancePercent: {
          field: 'ChancePercent',
          list: [{value: 1, name: 'Failed: 0%'}, {value: 2, name: 'pipeline: 10%'}, {value: 3, name: 'BusinessOpporutnity: 30%'}, {value: 4, name: 'Upside: 40%'}, {value: 5, name: 'Forecast: 60%'}, {value: 6, name: 'LPIOrdered: 80%'}]
        },
        ChanceRequestType: {
          field: 'ChanceRequestType',
          list: [{value: 1, name: 'LC'}, {value: 2, name: 'ACAD'}, {value: 3, name: 'AEC'}, {value: 4, name: 'MFG'}, {value: 5, name: 'MNE'}]
        }
      },
      // popField
      popFieldList: [
        { field: 'CustomerNumber', value: '客户编号', width: '20' },
        { field: 'CustomerName', value: '客户名称', width: '20' },
        { field: 'Contacter', value: '联系人', width: '20' },
        { field: 'ContactMobile', value: '手机号', width: '30' },
        { field: 'OfficePhone', value: '座机号', width: '30' },
        // { field: 'CustomerStatus', value: '客户业务状态', width: '30' },
        // { field: 'CustomerSource', value: '客户来源', width: '20' },
        // { field: 'CustomerType', value: '客户大类型', width: '20' },
        // { field: 'CostomerCategory', value: '客户类别', width: '20' },
        { field: 'Industry', value: '所属行业', width: '20' },
        { field: 'ProvinceCode', value: '所属地区', width: '20' },
        // { field: 'Address', value: '通信地址', width: '20' },
        // { field: 'SaleOwerId', value: '销售员', width: '150' },
        { field: 'SaleName', value: '销售负责人', width: '20' }
        // { field: 'CreateTime', value: '创建时间', width: '20' }
        // { field: 'NextFollowTime', value: '最新跟进时间', width: '150' }
      ],
      totalPop: 0,
      currentPopPage: 1,
      pagePopSize: 15,
      pagePopSizes: [10, 30, 60, 100],
      popSearch: '',
      popData: [],
      popLoading: false,
      editData: {},
      isLC: false,
      isSubmit: false,
      isCommited: false,
      pushStatus: '',
      isCrossArea: false,
      isUserSelect: false,
      pushOptions: [],
      radioInput: '',
      isClicked: false
    }
  },
  computed: {
    /** 合同 回款 下展示审批人信息 */
    showExamine () {
      if (this.crmType === 'contract' || this.crmType === 'receivables') {
        return true
      }
      return false
    },
    sureBtnTitle () {
      if (this.crmType === 'contract' || this.crmType === 'receivables') {
        return '提交审核'
      }
      return '保存'
    },
    formRules () {
      if (this.crmType === 'customer') {
        return this.crmRules
      } else if (this.crmType === 'contacts') {
        return this.dialogRules
      } else if (this.crmType === 'business') {
        return this.busDialogRules
      }
      return false
    },
    tableList: function () {
      if (this.crmType === 'customer') {
        return [
          { field: 'CustomerName', value: '客户名称', showblock: false, tips: '请录入营业执照的名称,不能录入空格、斜杠、逗号、分号、下划线、中杠等特殊符号。只能录入简体中文' },
          { field: 'SaleOwerId', value: '销售负责人', type: 'cascaderSingle', showblock: false },
          { field: 'CompanyType', value: '企业性质', type: 'select', showblock: false },
          { field: 'FirmSize', value: '客户设计人数', type: 'number', showblock: false },
          { field: 'radioInput', value: '行业细分', type: 'inputPopover', showblock: false },
          { field: 'PostNumber', value: '邮政编码', showblock: false },
          { field: 'Address', value: '通信地址', showblock: false },
          { field: 'Comment', value: '备注', showblock: false, type: 'textarea' },
          { field: 'mapAddress', value: '所属地区', type: 'map_address', showblock: true }
        ]
      } else if (this.crmType === 'contacts') {
        return [
          { field: 'RealName', value: '联系人姓名', showblock: false },
          { field: 'CustomerId', value: '关联客户', type: 'relationInput', showblock: false },
          { field: 'MobilePhone', value: '手机号', showblock: false },
          { field: 'OfficePhone', value: '座机号', showblock: false },
          { field: 'DepartmentName', value: '部门', showblock: false },
          { field: 'Email', value: '邮箱', showblock: false },
          { field: 'JobPosition', value: '职务', showblock: false }
        ]
      } else if (this.crmType === 'business') {
        return [
          { field: 'ChanceNumber', value: '编号', disabled: true, showblock: false },
          { field: 'SalesChanceCustomerType', value: '客户类型', type: 'select', showblock: false },
          { field: 'ChanceName', value: '名称', showblock: false, disabled: true, tips: '自动生成规则:“客户名称”+“年月日”+“序号”', type: 'disInput' },
          { field: 'ExpectedAmount', value: '商机金额/元', type: 'number', showblock: false },
          { field: 'CustomerId', value: '客户', type: 'relationInput', showblock: false, chosedCusName: '' },
          { field: 'ChanceRequestType', value: '商机类型', type: 'select', showblock: false },
          { field: 'SalesChanceStage', value: '销售阶段', type: 'select', showblock: false },
          { field: 'OwerUserId', value: '销售负责人', type: 'cascaderSingle', showblock: false },
          { field: 'mapAddress', value: '所属地区', type: 'map_address', showblock: false, disabled: true },
          { field: 'ChancePercent', value: '成交几率', type: 'select', showblock: false },
          { field: 'ExpectedDate', value: '预计成交日期', type: 'date', showblock: false },
          { field: 'Comment', value: '说明', type: 'textarea', showblock: false },
          // { field: 'PirateNumber', value: '盗版用量', type: 'number', showblock: false },
          { field: 'ProjectProperty', value: '项目属性', type: 'radioList', showblock: false },
          { field: 'Products', type: 'product', showblock: true }
        ]
      }
    },
    tableUserList: function () {
      if (this.crmType === 'customer') {
        return [
          { field: 'Contacter', value: '姓名', showblock: false },
          { field: 'ContactMobile', value: '手机号', showblock: false },
          { field: 'OfficePhone', value: '座机号', showblock: false },
          { field: 'JobPosition', value: '职务', showblock: false },
          { field: 'Email', value: '邮箱', showblock: false }
        ]
      }
    }
  },
  watch: {
    crmType: function (value) {
      this.title = this.getTitle()
      this.crmRules = {}
      // this.crmForm = {
      //   crmFields: []
      // }
      this.examineInfo = {}
      // this.getField()
    },
    radioInput: function (value) {
      this.formInline['radioInput'] = value
    }
  },
  mounted () {
    console.log(this.action)
    // 商务数据展示
    let userInfo = Lockr.get('User-Info')
    if (userInfo.PositionType === 4) {
      this.optionsList['ChanceRequestType'].list.push({value: 6, name: 'ACAD重点项目'})
    }
    console.log(this.optionsList['ChanceRequestType'])
    // 获取title展示名称
    document.body.appendChild(this.$el)
    this.title = this.getTitle()
    this.getSalesList()
    this.getField()
    this.getUserOpt()
  },
  destroyed () {
    // remove DOM node after destroy
    if (this.$el && this.$el.parentNode) {
      this.$el.parentNode.removeChild(this.$el)
    }
  },
  methods: {
    /** 格式化字段 */
    fieldFormatter (row, column) {
      // 如果需要格式化
      return row[column.property] || '--'
    },
    // 关联选择样式
    popCellStyle ({ row, column, rowIndex, columnIndex }) {
      return { fontSize: '12px', textAlign: 'center', cursor: 'pointer' }
    },
    headerCellStyle ({ row, column, rowIndex, columnIndex }) {
      return { fontSize: '12px', textAlign: 'center' }
    },
    handlePopRowClick (row, column, event) {
      this.formInline['CustomerId'] = row.Id
      this.customerChosed = row.CustomerName
      console.log(row)
      this.hidenRelationInput()
      if (this.crmType === 'business') {
        this.getSalesChanceName(row.Id)
        this.formInline['mapAddress'] = {
          province: row.ProvinceCode,
          city: row.CityCode
        }
        this.formInline['ProvinceCode'] = row.ProvinceCode
        this.formInline['CityCode'] = row.CityCode
      }
    },
    handlePopSizeChange (newSize) {
      this.pagePopSizes = newSize
      this.getCustomerTable()
    },
    handlePopCurrentChange (newPage) {
      this.currentPopPage = newPage
      this.getCustomerTable()
    },
    // 审批信息值更新
    examineValueChange (data) {
      this.examineInfo = data
    },
    getCrossArea () {
      console.log(this.isCrossArea)
      if (this.isCrossArea) {
        this.isUserSelect = true
      } else {
        this.isUserSelect = false
        this.pushStatus = ''
      }
    },
    // 获取审批人员列表
    getUserOpt () {
      GetWxSpUserList().then(res => {
        if (res.data.ErrorCode === 200) {
          this.pushOptions = res.data.Result
          // this.pushStatus = this.pushOptions[0].UserId
        }
      })
    },
    // 字段的值更新
    fieldValueChange (data) {
      console.log(data)
      if (data.index === 'CustomerId') {
        this.formInline['CustomerId'] = data.value
        this.tableList[3].disabled = false
        this.tableList[2].chosedCusName = data.name
        this.timer = new Date().getTime()
      }
      if (data.index === 'ContacterId') {
        this.formInline['ContacterId'] = data.value
      }
      if (data.type === 'product') {
        if (this.isLC) {
          this.formInline['SalesChancePirates'] = data.data
        } else {
          this.formInline['Products'] = data.data
        }
      }
    },
    // 选择文件
    selectFile () {
      document.getElementById('importInputFile').click()
    },
    /** 图片选择出发 */
    uploadFile (event) {
      let files = event.target.files
      const file = files[0]
      this.file = file
      event.target.value = ''
      let data = new FormData()
      data.append('file', file)
      axios.post('http://192.168.0.107:8081/api/File/UploadFileAsync', data, {
        headers: {
          'Content-Type': 'multipart/form-data'
        }
      }).then(res => {
        if (res.data.ErrorCode === 200) {
          this.formInline['DocumentFiles'] = [{
            'DocumentFileName': res.data.Message,
            'DocumentFilePath': res.data.Result
          }]
        } else {
          this.$message.error(res.data.Message)
        }
      }).catch(err => {
        console.log(err)
      })
    },
    // 获取自定义字段
    getField () {
      this.loading = true
      // 进行编辑操作
      if (this.action.type === 'update') {
        this.getEditData()
      // 新增操作
      } else if (this.action.type === 'save') {
        this.salesId = Lockr.get('User-Info').Id
        if (this.crmType === 'customer') {
          this.formInline['SaleOwerId'] = this.salesId
        } else if (this.crmType === 'business') {
          this.formInline['SaleOwerId'] = this.salesId
          this.formInline = {
            mapAddress: {
              province: '',
              city: ''
            },
            SalesChanceCustomerType: 1,
            SalesChanceStage: 1,
            OwerUserId: this.salesId
          }
        }
        this.getId()
      }
      if (this.crmType === 'contacts' || this.crmType === 'business') {
        this.getCustomerTable()
      }
      this.getAreaList()
      this.getIndustryList()
      this.getProjectPropertyData()
      this.getExtendProjectPropertyData()
      this.loading = false
    },
    getEditData () {
      let editRequest = this.getUpdataData()
      let params = {
        Id: this.action.id
      }
      editRequest(params)
        .then(res => {
          if (res.data.ErrorCode === 200) {
            this.editData = res.data.Result
            if (res.data.Result) {
              this.formInline = {...this.editData}
              if (this.crmType === 'customer') {
              // 客户编辑
                this.formInline['mapAddress'] = {
                  province: this.editData.ProvinceCode,
                  city: this.editData.CityCode
                }
                this.formInline['mapAddress'].type = 'map_address'
                this.salesId = this.formInline['SaleOwerId']
                this.formInline['radioInput'] = this.formInline['Industry']
                this.radioInput = this.formInline['Industry']
              } else if (this.crmType === 'contacts') {
              // 联系人编辑
                this.customerChosed = this.editData.CustomerName
                console.log(this.editData, this.editData.CustomerName)
              } else if (this.crmType === 'business') {
              // 商机编辑
                this.formInline['mapAddress'] = {
                  province: this.editData.ProvinceCode,
                  city: this.editData.CityCode
                }
                this.formInline['mapAddress'].type = 'map_address'
 
                this.formInline['SalesChanceStage'] = this.editData.SalesChanceStage && this.editData.SalesChanceStage !== '--' ? JSON.parse(this.editData.SalesChanceStage) : 1
 
                this.formInline['SalesChanceCustomerType'] = this.editData.SalesChanceCustomerType && this.editData.SalesChanceCustomerType !== '--' ? JSON.parse(this.editData.SalesChanceCustomerType) : 1
 
                this.formInline['ChanceRequestType'] = this.editData.ChanceRequestType && this.editData.ChanceRequestType !== '--' ? JSON.parse(this.editData.ChanceRequestType) : 1
                // 入值
                this.salesId = this.formInline['OwerUserId']
                this.customerChosed = this.editData.CustomerName
                if (this.formInline['ProjectProperty'] === 'LC协作') {
                  this.isLC = true
                  this.formInline['Products'] = this.editData.SalesChancePirates
                  this.formInline['LcAgency'] = this.editData.LcAgency === '' || this.editData.LcAgency === '暂无' ? 0 : (this.editData.LcAgency === '嘉禾' ? 1 : 2)
                  if (this.tableList[13].field !== 'ExtendProjectProperty') {
                    this.tableList.splice(13, 0, { field: 'ExtendProjectProperty', value: '扩展项目属性', type: 'radioList', showblock: false })
                    this.tableList.splice(14, 0, { field: 'PirateNumber', value: '盗版用量', type: 'number', showblock: false })
                    this.tableList.splice(15, 0, { field: 'LcAgency', value: '知识产权代理', type: 'select', showblock: false })
                  }
                } else {
                  this.isLC = false
                  this.formInline['Products'] = this.editData.Products
                }
                if (this.$refs['xhProduct'][0].selectInfos) {
                  this.$refs['xhProduct'][0].selectInfos(this.formInline['Products'], this.isLC)
                }
 
                // this.editData.UploadStatusName === '已提交' ||
                if (!this.editData.IsCanReport) {
                  this.isSubmit = true
                } else {
                  this.isSubmit = false
                }
                console.log(this.formInline)
              }
            }
          } else {
            this.$message.error(res.data.Message)
            this.editData = {}
          }
        })
    },
    getUpdataData () {
      if (this.action.type === 'update') {
        if (this.crmType === 'customer') {
          return GetCustomerDetail
        } else if (this.crmType === 'contacts') {
          return GetContacterDetail
        } else if (this.crmType === 'business') {
          return GetSalesChanceDetail
        } else if (this.crmType === 'product') {
        // return crmProductSave
        } else if (this.crmType === 'contract') {
        // return crmContractSave
        } else if (this.crmType === 'receivables') {
        // return crmReceivablesSave
        } else if (this.crmType === 'receivables_plan') {
        // return crmReceivablesPlanSave
        }
      }
    },
    // 销售员级联列表
    getSalesList () {
      GetDepartmentUserChildList().then(res => {
        if (res.data.ErrorCode === 200 && res.data.Result !== 0) {
          let list = res.data.Result
          let array = this.addLabel(list)
          this.salesManList = array
        } else {
          this.$message.error(res.data.Message)
          this.loading = false
        }
      })
    },
    addLabel (arr) {
      for (let k in arr) {
        if (arr[k].DepartmentAndUserChildren && arr[k].DepartmentAndUserChildren.length < 1) {
          // 当后台返回的children为空时,页面会留空白,把空白部分去掉
          arr[k].children = undefined
        } else {
          arr[k].children = arr[k].DepartmentAndUserChildren
          this.addLabel(arr[k].DepartmentAndUserChildren)
        }
      }
      return arr
    },
    getUser (val) {
      console.log(this.$refs['salesCas'][0].getCheckedNodes()[0].label, val[val.length - 1])
      this.formInline['SaleOwerId'] = val[val.length - 1]
      this.formInline['SaleName'] = this.$refs['salesCas'][0].getCheckedNodes()[0].label
      this.formInline['OwerUserId'] = val[val.length - 1]
      this.formInline['OwerUserName'] = this.$refs['salesCas'][0].getCheckedNodes()[0].label
    },
    /** 区域选择 */
    selectProvince (value) {
      console.log(value)
      this.formInline['mapAddress'].province = value
      this.formInline['ProvinceCode'] = value
    },
    selectCity (value) {
      this.formInline['mapAddress'].city = value
      this.formInline['CityCode'] = value
      console.log(this.formInline['CityCode'])
    },
    // select选择
    getSelectVal (type) {
      console.log(type)
      if (type === 'CustomerType') {
        console.log(this.formInline['CustomerType'])
        if (this.formInline['CustomerType'] === 1) {
          console.log(this.tableList)
          this.tableList.splice(5, 0, { field: 'DepartmentId', value: '所属区域', type: 'selectCheckout' })
        } else {
          if (this.tableList[5].field === 'DepartmentId') {
            this.tableList.splice(5, 1)
          }
        }
      } else if (type === 'ChancePercent') {
        // this.formInline['ChancePercent'] = this.optionsList['ChancePercent'].list[this.formInline['ChancePercent']]
        console.log(this.formInline['ChancePercent'])
      } else if (type === 'SalesChanceStage') {
        console.log(this.formInline['SalesChanceStage'])
      } else if (type === 'ChanceRequestType') {
        if (this.formInline['ChanceRequestType'] === 1) {
          if (this.tableList[13].field !== 'ExtendProjectProperty') {
            this.formInline['ProjectProperty'] = 'LC协作'
            this.tableList.splice(13, 0, { field: 'ExtendProjectProperty', value: '扩展项目属性', type: 'radioList', showblock: false })
            this.tableList.splice(14, 0, { field: 'PirateNumber', value: '盗版用量', type: 'number', showblock: false })
            this.tableList.splice(15, 0, { field: 'LcAgency', value: '知识产权代理', type: 'select', showblock: false })
            this.isLC = true
            this.$forceUpdate()
          }
        } else {
          if (this.tableList[13].field === 'ExtendProjectProperty') {
            this.tableList.splice(15, 1)
            this.tableList.splice(14, 1)
            this.tableList.splice(13, 1)
            this.isLC = false
            this.$forceUpdate()
          }
        }
        console.log(this.formInline['ChanceRequestType'])
      } else if (type === 'LcAgency') {
        if (this.formInline['LcAgency'] === 0) {
          this.formInline['LcAgency'] = '暂无'
        } else if (this.formInline['LcAgency'] === 1) {
          this.formInline['LcAgency'] = '嘉禾'
        } else if (this.formInline['LcAgency'] === 2) {
          this.formInline['LcAgency'] = '信品'
        }
        console.log(this.formInline['LcAgency'])
      }
    },
    getAreaList () {
      GetDepartmentAreaList().then(res => {
        if (res.data.Result) {
          this.optionsList['DepartmentId'].list = res.data.Result
        } else {
          this.$message.error(res.data.Message)
        }
      })
    },
    //  switch 选择
    getSwitch (type) {
      console.log(this.formInline[type])
      for (let i in this.tableList) {
        if (this.tableList[i].field === 'CustomerAddJobShcedule') {
          this.tableList[i].disabled = !this.formInline[type]
        }
      }
    },
    getCustomerTable () {
      this.popLoading = true
      let params = {
        Name: this.popSearch,
        PageIndex: this.currentPopPage,
        PageSize: this.pagePopSize
      }
      GetPersonalCustomerPageList(params).then(res => {
        if (res.data.ErrorCode === 200 && res.data.Result !== 0) {
          this.popData = res.data.Result.List || []
          this.totalPop = res.data.Result.Count
          this.popLoading = false
        } else {
          this.$message.error(res.data.Message)
          this.popLoading = false
        }
      })
        .catch(() => {
          this.popLoading = false
        })
    },
    getId () {
      if (this.crmType === 'customer') {
        GetCusomterNumber().then(res => {
          this.formInline['CustomerNumber'] = res.data.Result
        })
      } else if (this.crmType === 'contacts') {
        GetContacterNumber().then(res => {
          this.formInline['ContacterNumber'] = res.data.Result
        })
      } else if (this.crmType === 'business') {
        GetSalesChanceNumber().then(res => {
          this.formInline['ChanceNumber'] = res.data.Result
        })
      }
    },
    getSalesChanceName (data) {
      console.log('aaaaaaaaaaaa')
      let params = {
        customerId: data
      }
      GetSalesChanceName(params).then(res => {
        this.formInline['ChanceName'] = res.data.Result
        this.$forceUpdate()
      })
    },
    getProjectPropertyData () {
      GetProjectPropertyData().then(res => {
        this.optionsList['ProjectProperty'].list = res.data.Result
      })
    },
    getExtendProjectPropertyData () {
      GetExtendProjectPropertyData().then(res => {
        this.optionsList['ExtendProjectProperty'].list = res.data.Result
      })
    },
    getPropertyName () {
      console.log(this.formInline['ProjectProperty'])
      if (this.formInline['ProjectProperty'] === 'LC协作') {
        this.formInline['ChanceRequestType'] = 1
        if (this.tableList[13].field !== 'ExtendProjectProperty') {
          this.tableList.splice(13, 0, { field: 'ExtendProjectProperty', value: '扩展项目属性', type: 'radioList', showblock: false })
          this.tableList.splice(14, 0, { field: 'PirateNumber', value: '盗版用量', type: 'number', showblock: false })
          this.tableList.splice(15, 0, { field: 'LcAgency', value: '知识产权代理', type: 'select', showblock: false })
          this.isLC = true
          this.$forceUpdate()
        }
      } else {
        console.log(this.tableList[13].field)
        if (this.tableList[13].field === 'ExtendProjectProperty') {
          this.tableList.splice(15, 1)
          this.tableList.splice(14, 1)
          this.tableList.splice(13, 1)
          this.isLC = false
          this.$forceUpdate()
        }
      }
    },
    // ---inputpopover
    getIndustryList () {
      GetIndustryListChildrenData().then(res => {
        this.rightsList = res.data.Result
      })
    },
    hidenPopoverView () {
      document.querySelector('#app').click()
      this.formInline['radioInput'] = this.editData.Industry
      // this.otherInput = ''
      // this.isOtherOpt = false
    },
    getOtherOpt (val) {
      this.formInline['radioInput'] = ''
      this.isOtherOpt = true
    },
    blurOtherOpt () {
      if (!this.otherInput) {
        this.isOtherOpt = false
      }
    },
    getRadioInput (val, index) {
      console.log('yesssssssssssssssss', val, index, this.radioInput)
      // this.formInline['radioInput'] = val
    },
    setIndustry () {
      this.formInline['Industry'] = this.formInline['radioInput']
      document.querySelector('#app').click()
    },
    // 根据自定义字段获取自定义字段规则
    getcrmRulesAndModel (list) {
    },
    /**
     * 获取关联项的值 和 关联信息
     */
    getParamsValueAndRelativeInfo (params, item, list) {
      console.log(params)
      if (this.action.type === 'relative') {
        const relativeData = this.editData[item.formType]
        if (item.formType === 'receivables_plan') {
          params['value'] = ''
        } else {
          params['value'] = relativeData ? [relativeData] : []
        }
      } else {
        if (item.formType === 'receivables_plan') {
          params['value'] = item.value || ''
        } else {
          params['value'] = item.value || []
        }
      }
      if (this.action.type === 'relative' || this.action.type === 'update') {
        // 回款计划 需要合同信息
        if (item.formType === 'receivables_plan') {
          const contractItem = this.getItemRelatveInfo(item, list, 'contract')
          if (contractItem) {
            contractItem['moduleType'] = 'contract'
            params['relation'] = contractItem
          }
          // 商机合同 需要客户信息
        } else if (item.formType === 'business' || item.formType === 'contract') {
          const customerItem = this.getItemRelatveInfo(item, list, 'customer')
          if (item.formType === 'business' && customerItem) {
            customerItem['moduleType'] = 'customer'
            params['relation'] = customerItem
          } else if (item.formType === 'contract' && customerItem) {
            customerItem['moduleType'] = 'customer'
            customerItem['params'] = { checkStatus: 1 }
            params['relation'] = customerItem
          }
        }
      }
    },
    /**
     * 获取相关联item
     */
    getItemRelatveInfo (item, list, fromType) {
      let crmItem = null
      if (this.action.type === 'relative') {
        crmItem = this.editData[fromType]
      } else {
        const crmObj = list.find(listItem => {
          return listItem.formType === fromType
        })
        if (crmObj && crmObj.value && crmObj.value.length > 0) {
          crmItem = crmObj.value[0]
        }
      }
      return crmItem
    },
    /**
     * 获取关联项是否可操作
     */
    getItemDisabledFromItem (item) {
      // 相关添加
      if (this.action.type === 'relative') {
        const relativeDisInfos = {
          business: {
            customer: { customer: true },
            contacts: { customer: true }
          },
          contacts: {
            customer: { customer: true },
            business: { customer: true }
          },
          contract: {
            customer: { customer: true },
            business: { customer: true, business: true }
          },
          receivables_plan: {
            contract: { customer: true, contract: true },
            customer: { customer: true }
          },
          receivables: {
            contract: { customer: true, contract: true },
            customer: { customer: true }
          }
        }
        // 添加类型
        const crmTypeDisInfos = relativeDisInfos[this.crmType]
        if (crmTypeDisInfos) {
          // 在哪个类型下添加
          const relativeTypeDisInfos = crmTypeDisInfos[this.action.crmType]
          if (relativeTypeDisInfos) {
            // 包含的字段值
            return relativeTypeDisInfos[item.formType] || false
          }
        }
        return false
      } else if (this.action.type !== 'update') {
        // 新建
        if (this.crmType === 'contract' && item.formType === 'business') {
          return true
          // 回款下 新建 合同 和 回款计划 默认不能操作
        } else if (this.crmType === 'receivables') {
          if (item.formType === 'contract') {
            return true
          } else if (item.formType === 'receivables_plan') {
            return true
          }
        }
      }
      return false
    },
    /**
     * item 当行数据源
     */
    // 保存数据
    saveField (saveAndCreate, isDraft = false) {
      console.log(saveAndCreate)
      this.saveAndCreate = saveAndCreate
      console.log(this.formInline)
      if (this.crmType === 'business') {
        if (this.isCrossArea && this.pushStatus === '') {
          this.$message.error('请选择跨区审批人员!')
          return
        }
        if (this.formInline['ProjectProperty'] === 'LC协作' && !this.formInline['SalesChancePirates']) {
          this.$message.error('请选择产品!')
          return
        }
        if (this.formInline['ProjectProperty'] !== 'LC协作' && !this.formInline['Products']) {
          this.$message.error('请选择产品!')
          return
        }
        if (this.formInline['ProjectProperty'] === 'LC协作' && this.formInline['SalesChancePirates'].length === 0) {
          this.$message.error('请选择产品!')
          return
        }
        if (this.formInline['ProjectProperty'] !== 'LC协作' && this.formInline['Products'].length === 0) {
          this.$message.error('请选择产品!')
          return
        }
      }
      this.$refs.dialogRef.validate(valid => {
        if (valid) {
          if (this.crmType === 'customer') {
            this.$refs.userDialogRef.validate(valid => {
              if (valid) {
                this.formInline['CompanyType'] = Number(this.formInline['CompanyType'])
                this.formInline['FirmSize'] = Number(this.formInline['FirmSize'])
                let {mapAddress, radioInput, OwerUserId, OwerUserName, ...data} = this.formInline
                this.submiteParams(data)
              } else {
                return false
              }
            })
          } else if (this.crmType === 'contacts') {
            // let {customerChosed, ...data} = this.formInline
            this.submiteParams(this.formInline)
          } else if (this.crmType === 'business') {
            this.formInline['SalesChanceCustomerType'] = this.formInline['SalesChanceCustomerType'] ? JSON.parse(this.formInline['SalesChanceCustomerType']) : 1
            this.formInline['SalesChanceStage'] = this.formInline['SalesChanceStage'] ? JSON.parse(this.formInline['SalesChanceStage']) : 1
            this.formInline['PirateNumber'] = this.formInline['PirateNumber'] ? Number(this.formInline['PirateNumber']) : 0
            // 知识产权代理
            if (this.formInline['LcAgency'] === 0 || this.formInline['LcAgency'] === '暂无') {
              this.formInline['LcAgency'] = ''
            } else if (this.formInline['LcAgency'] === 1) {
              this.formInline['LcAgency'] = '嘉禾'
            } else if (this.formInline['LcAgency'] === 2) {
              this.formInline['LcAgency'] = '信品'
            }
            this.formInline['ExpectedAmount'] = this.formInline['ExpectedAmount'] ? Number(this.formInline['ExpectedAmount']) : 0
            this.formInline['ChanceRequestType'] = this.formInline['ChanceRequestType'] ? JSON.parse(this.formInline['ChanceRequestType']) : 1
            // 是否申报
            this.formInline['IsSubmitReport'] = this.isCommited
            // 是否跨区
            this.formInline['IsTransRegional'] = this.isCrossArea
            // 跨区审批人
            this.formInline['AuditUserId'] = this.pushStatus
            // 销售id
            // this.formInline['OwerUserId'] = this.formInline['SaleOwerId']
            // this.formInline['OwerUserName'] = this.formInline['SaleName']
            if (this.formInline['ProjectProperty'] === 'LC协作') {
              // 去掉多余的入参
              let {mapAddress, Products, SaleOwerId, SaleName, ...data} = this.formInline
              this.submiteParams(data)
            } else {
              // 去掉多余的入参
              let {mapAddress, SalesChancePirates, SaleOwerId, SaleName, ...data} = this.formInline
              console.log(data)
              this.submiteParams(data)
            }
          }
        } else {
          return false
        }
      })
    },
    /** 上传 */
    submiteParams (params) {
      this.loading = true
      this.isClicked = true
      console.log(params)
      if (this.saveAndCreate) {
        this.isCommited = true
        // this.$confirm('确定保存并申报吗?(申报后无法撤回)', '提示', {
        //   confirmButtonText: '确定',
        //   cancelButtonText: '取消',
        //   type: 'warning'
        // })
        //   .then(() => {
        //     this.sendQuery(params)
        //   })
        //   .catch(() => {
        //     this.loading = false
        //     this.$message({
        //       type: 'info',
        //       message: '已取消保存并申报'
        //     })
        //   })
      } else {
        this.sendQuery(params)
      }
    },
    surePush () {
 
    },
    sendQuery (params) {
      let crmRequest = this.getSubmiteRequest()
      crmRequest(params).then(res => {
        if (res.data.ErrorCode === 200) {
          this.hidenView()
          this.$message.success(
            this.action.type === 'update' ? '编辑成功' : '添加成功'
          )
          // 回到保存成功
          this.$emit('save-success', {
            type: this.crmType,
            data: res.data || {},
            saveAndCreate: this.saveAndCreate
          })
        } else {
          this.$message.error(res.data.Message)
          this.formInline['PirateNumber'] = 0
        }
        this.loading = false
        this.handleClose()
      })
        .catch(() => {
          this.loading = false
          this.handleClose()
        })
    },
    handleClose () {
      this.isCommited = false
      this.loading = false
      this.isClicked = false
      this.isSubmit = false
      this.pushStatus = ''
      this.isCrossArea = false
    },
    /** 获取上传url */
    getSubmiteRequest () {
      if (this.action.type === 'update') {
        if (this.crmType === 'leads') {
        // return crmLeadsSave
        } else if (this.crmType === 'customer') {
          return UpdateCustomer
        } else if (this.crmType === 'contacts') {
          return UpdateContacter
        } else if (this.crmType === 'business') {
          return UpdateSalesChance
        } else if (this.crmType === 'product') {
        // return crmProductSave
        } else if (this.crmType === 'contract') {
        // return crmContractSave
        } else if (this.crmType === 'receivables') {
        // return crmReceivablesSave
        } else if (this.crmType === 'receivables_plan') {
        // return crmReceivablesPlanSave
        }
      } else if (this.action.type === 'save') {
        if (this.crmType === 'leads') {
        // return crmLeadsSave
        } else if (this.crmType === 'customer') {
          return AddCustomer
        } else if (this.crmType === 'contacts') {
          return AddContacter
        } else if (this.crmType === 'business') {
          return AddSalesChance
        } else if (this.crmType === 'product') {
        // return crmProductSave
        } else if (this.crmType === 'contract') {
        // return crmContractSave
        } else if (this.crmType === 'receivables') {
        // return crmReceivablesSave
        } else if (this.crmType === 'receivables_plan') {
        // return crmReceivablesPlanSave
        }
      }
    },
    /** 拼接上传传输 */
    getSubmiteParams (array) {
      console.log(array)
      let params = {}
      for (let index = 0; index < array.length; index++) {
        const element = array[index]
        params[element.key] = element.value
        if (element.key === 'mapAddress') {
          params.address = element.value.address.join(',')
          delete params['mapAddress']
        } else if (element.key === 'CompanyType') {
          params['CompanyType'] = JSON.parse(params['CompanyType'])
        } else if (element.key === 'FirmSize') {
          params['FirmSize'] = JSON.parse(params['FirmSize'])
        }
        // if (element.key === 'product') {
        //   this.getProductParams(params, element)
        // } else if (element.key === 'map_address') {
        //   this.getCustomerAddressParams(params.entity, element)
        // } else if (element.data.fieldType === 1) {
        //   params.entity[element.key] = this.getRealParams(element) || ''
        // } else {
        //   element.data.value = this.getRealParams(element)
 
        //   params.field.push(element.data)
        // }
      }
      console.log(params)
      return params
    },
    getProductParams (params, element) {
      if (element.value) {
        params['product'] = element.value.product ? element.value.product : []
        params.entity['totalPrice'] = element.value.totalPrice
          ? element.value.totalPrice
          : 0
        params.entity['discountRate'] = element.value.discountRate
          ? element.value.discountRate
          : 0
      } else {
        params['product'] = []
        params.entity['totalPrice'] = ''
        params.entity['discountRate'] = ''
      }
    },
    // 获取客户位置参数
    getCustomerAddressParams (params, element) {
      params['address'] = element.value.address
        ? element.value.address.join(',')
        : ''
      params['detailAddress'] = element.value.detailAddress
      params['location'] = element.value.location
      params['lng'] = element.value.lng
      params['lat'] = element.value.lat
    },
    // 关联客户 联系人等数据要特殊处理
    getRealParams (element) {
      if (
        element.key === 'customer_id' ||
        element.key === 'contacts_id' ||
        element.key === 'business_id' ||
        element.key === 'leads_id' ||
        element.key === 'contract_id'
      ) {
        if (element.value && element.value.length) {
          const key = element.key.replace('_id', 'Id')
          return element.value[0][key]
        } else {
          return ''
        }
      } else if (
        element.type === 'user' ||
        element.type === 'structure'
      ) {
        return element.value
          .map(function (item, index, array) {
            return element.type === 'user' ? item.userId : item.id
          })
          .join(',')
      } else if (element.type === 'file') {
        if (element.value && element.value.length > 0) {
          return element.value[0].batchId
        }
        return ''
      } else if (element.key === 'category_id') {
        if (element.value && element.value.length > 0) {
          return element.value[element.value.length - 1]
        }
        return ''
      } else if (element.type === 'checkbox') {
        if (element.value && element.value.length > 0) {
          return element.value.join(',')
        }
        return ''
      }
 
      return element.value
    },
    hidenView () {
      this.$emit('hiden-view')
    },
    hidenRelationInput () {
      this.popSearch = ''
      document.querySelector('#app').click()
      this.$emit('close', this.$el, this.data)
    },
    // 根据类型获取标题展示名称
    getTitle () {
      if (this.crmType === 'leads') {
        return this.action.type === 'update' ? '编辑线索' : '新建线索'
      } else if (this.crmType === 'customer') {
        return this.action.type === 'update' ? '编辑客户' : '新建客户'
      } else if (this.crmType === 'contacts') {
        return this.action.type === 'update' ? '编辑联系人' : '新建联系人'
      } else if (this.crmType === 'business') {
        return this.action.type === 'update' ? '编辑商机' : '新建商机'
      } else if (this.crmType === 'product') {
        return this.action.type === 'update' ? '编辑产品' : '新建产品'
      } else if (this.crmType === 'contract') {
        return this.action.type === 'update' ? '编辑合同' : '新建合同'
      } else if (this.crmType === 'receivables') {
        return this.action.type === 'update' ? '编辑回款' : '新建回款'
      } else if (this.crmType === 'receivables_plan') {
        return this.action.type === 'update' ? '编辑回款计划' : '新建回款计划'
      }
    },
    // 获取左边padding
    getPaddingLeft (item, index) {
      if (item.showblock && item.showblock === true) {
        return '0'
      }
      return item.styleIndex % 2 === 0 ? '0' : '25px'
    },
    // 获取左边padding
    getPaddingRight (item, index) {
      if (item.showblock && item.showblock === true) {
        return '0'
      }
 
      return item.styleIndex % 2 === 0 ? '25px' : '0'
    }
  }
}
</script>
<style lang="scss" scoped>
@import '../styles/table.scss';
#importInputFile {
  display: none;
}
.crm-create-container {
  position: relative;
  height: 100%;
}
 
.crm-create-flex {
  position: relative;
  overflow-x: hidden;
  overflow-y: auto;
  flex: 1;
}
 
.crm-create-header {
  height: 40px;
  margin-bottom: 20px;
  padding: 0 10px;
  flex-shrink: 0;
  display: flex;
  .close {
    display: block;
    width: 45px;
    height: 45px;
    margin-right: -10px;
    padding: 10px;
    cursor: pointer;
  }
}
 
.crm-create-body {
  flex: 1;
  // overflow-x: hidden;
  // overflow-y: auto;
  max-height: 500px;
}
 
/** 将其改变为flex布局 */
.crm-create-box {
  display: flex;
  flex-wrap: wrap;
  padding: 0 10px;
}
 
.crm-create-item {
  flex: 0 0 45%;
  flex-shrink: 0;
  // overflow: hidden;
  padding-bottom: 30px;
}
 
// 占用一整行
.crm-create-block-item {
  flex: 0 0 100%;
  flex-shrink: 0;
  padding-bottom: 10px;
  padding-left: 25px !important;
}
 
.el-form-item /deep/ .el-form-item__label {
  line-height: 32px;
  font-size: 13px;
  color: #333333;
  position: relative;
  padding-left: 8px;
  padding-bottom: 0;
}
 
.el-form /deep/ .el-form-item {
  margin-bottom: 0px;
}
 
.el-form /deep/ .el-form-item.is-required .el-form-item__label:before {
  content: '*';
  color: #f56c6c;
  margin-right: 4px;
  position: absolute;
  left: 0;
  top: 8px;
}
 
.handle-bar {
  position: relative;
  margin: 0 auto;
  .handle-button {
    // float: right;
    margin-top: 5px;
    margin-right: 20px;
  }
}
 
.el-button + .el-button {
  margin-left: 0;
}
 
// 审核信息 里的审核类型
.examine-type {
  font-size: 12px;
  color: white;
  background-color: #fd715a;
  padding: 0 8px;
  margin-left: 5px;
  height: 16px;
  line-height: 16px;
  border-radius: 8px;
  transform: scale(0.8, 0.8);
}
 
.container{
  position: relative;
  .popover-foot{
    position: relative;
    left: 38%;
    width: 100%;
    margin-bottom: 30px;
  }
}
.content {
  position: relative;
  padding: 32px 40px;
  display: flex;
  flex-direction: column;
  margin-bottom: 40px;
  height: 355px;
  overflow: hidden;
  overflow-y: auto;
  border-bottom: 1px solid #f1f1f1;
  .content-wrap{
    width: 100%;
  }
  .otherOpt{
    margin-bottom: 15px;
    width: 100%;
  }
  p{
    margin-bottom: 36px;
    font-size: 14px;
    font-weight: 550;
    color: #333;
 
  }
  .con-group{
    margin-bottom: 28px;
  }
  .content-wrap /deep/.el-radio-group .el-radio{
    margin-right: 64px;
    margin-bottom: 12px;
  }
  .content-wrap /deep/.el-radio-group .el-radio .el-radio__label{
    font-weight: 400;
    color: #666666;
    font-size: 14px;
  }
}
.header {
  padding: 16px 30px;
  flex-shrink: 0;
  border-bottom: 1px solid #F1F1F1;
  .name {
    font-size: 13px;
    padding: 0 10px;
    color: #333;
  }
  .detail {
    font-size: 12px;
    padding: 0 10px;
    color: #aaaaaa;
    border-left: 1px solid #aaaaaa;
  }
  .close {
    position: absolute;
    width: 40px;
    height: 40px;
    top: 5px;
    right: 10px;
    padding: 10px;
  }
}
.pop-container {
  position: relative;
}
 
.pop-header {
  padding: 16px 30px;
  flex-shrink: 0;
  border-bottom: 1px solid #F1F1F1;
  margin-bottom: 13px;
  .pop-name {
    font-size: 16px;
    font-weight: 550;
    padding: 0 10px;
    color: #333;
  }
  .pop-detail {
    font-size: 12px;
    padding: 0 10px;
    color: #aaaaaa;
    border-left: 1px solid #aaaaaa;
  }
  .pop-close {
    position: absolute;
    top: 16px;
    right: 10px;
    width: 25px;
    height: 25px;
  }
}
.pop-content{
  padding: 0 30px;
  .pop-cropper-box{
    display:flex;
    flex-direction: row;
    align-items: center;
    margin-bottom: 30px;
    .pop-searchTitle{
      font-size: 14px;
      width: 124px;
      color: #333;
    }
    .pop-searchInput{
      margin-right: 20px;
    }
  }
}
.p-contianer{
  margin: 30px 0;
  .p-bar{
    margin: 5px 0 0 14px;
  }
}
.distpicker-address-wrapper{
  display: flex;
}
.distpicker-address-wrapper /deep/ label{
  margin-right: 10px;
}
.distpicker-address-wrapper /deep/ select {
  color: #333;
  height: 36px; /*no*/
  font-size: 14px; /*no*/
  border-radius: 4px;
  border: 1px solid #D9D9D9;
  padding: 2px; /*no*/
  &:disabled{
    color: #333;
    background-color: #F7FAFF;
    border-color: #D9D9D9;
    opacity: 1;
    cursor: not-allowed;
    appearance: none;
  }
}
.el-input /deep/ .el-input__inner {
  // padding: 0 8px;
  height: 36px;
  line-height: 36px;
  font-size: 14px;
}
.el-input /deep/ .el-input-group__append{
  background-color: #4D88FF;
  color: #fff;
  height: 36px;
  line-height: 36px;
}
.el-input.is-disabled /deep/ .el-input__inner{
  background-color: #F7FAFF !important;
  border-color: #D9D9D9 !important;
  color: #333 !important;
  cursor:pointer;
}
.relationInput.el-input.is-disabled /deep/ .el-input__inner{
  background-color: #fff !important;
  border-color: #D9D9D9 !important;
  color: #333 !important;
  cursor:pointer;
  &:hover{
    border-color: #4D88FF !important;
  }
}
.areaInput.el-textarea /deep/ .el-textarea__inner{
  &:hover{
    border-color: #4D88FF !important;
  }
}
.cn.el-input.is-disabled /deep/ .el-input__inner{
  cursor: not-allowed;
}
.inputPopover.el-input.is-disabled /deep/ .el-input__inner{
  background-color: #fff !important;
  border-color: #D9D9D9 !important;
  color: #333 !important;
  cursor:pointer;
}
.disInput.el-input.is-disabled /deep/ .el-input__inner{
  background-color: #F7FAFF !important;
  border-color: #D9D9D9 !important;
  color: #333 !important;
  cursor: not-allowed;
}
// .el-date-editor /deep/ .el-input__prefix{
//   right: -230px;
// }
.doubleSelect{
  display: flex;
  flex-direction: row;
  width: 100%;
  .leftSelect{
    margin-right: 10px;
  }
}
.radioList{
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  .el-radio{
    flex: 0 0 40%;
    line-height: 24px;
    .el-radio__label{
      color: #666;
      font-size: 16px;
      margin-bottom: 12px;
    }
  }
}
.pushBody{
  margin: 0 60px;
  .hintWord{
    margin-top: 10px;
  }
  .hintSelect{
    margin-top: 20px;
    .el-select{
      width: 224px;
    }
  }
}
.closePushBtn{
  margin-right: 16px;
}
.productTitle /deep/ .el-dialog__headerbtn .el-dialog__close{
  font-size: 24px;
}
</style>