invoices_em7.html
69.5 KB
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
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0">
<script type="text/javascript" src="/mobile/plugin/browser/fna2/js/jquery-1.9.1.min.js"></script>
<script type="text/javascript" src="/mobilemode/browser/js/fastclick.min_wev8.js"></script>
<script type="text/javascript" src="/mobilemode/apps/fna2/js/bootstrap.min.js"></script>
<link type="text/css" rel="stylesheet" href="/mobilemode/apps/fna2/css/bootstrap.css"/>
<script>
if(!window.Promise) {
document.writeln('<script src="/cloudstore/resource/mobile/es6-promise/3.2.2/es6-promise.min.js"'+'>'+'<'+'/'+'script>');
}
</script>
<!-- 单点登录使用方式依赖loadjs加载em的jssdk文件,如果没有需要引入 -->
<script type="text/javascript" src="/cloudstore/resource/mobile/loadjs/loadjs.min.js"></script>
<!-- 单点登录工具文件 -->
<script type="text/javascript" src="/spa/coms/ssoSDK/ssoInit.js"></script>
<style type="text/css">
html,body{
height: 100%;
width: 100%;
font-family: 'Microsoft YaHei';
background-color: #f1f2f3;
overflow: auto;
position: fixed;
-webkit-overflow-scrolling: touch;
}
#container1,#container2{
width: 100%;
height: 620px;
overflow: auto;
}
#container2,#container3,#container4{
display: none;
}
.title,.invoice-footer{
text-align: center;
font-weight: bold;
}
.title{
height: 50px;
line-height: 50px;
font-size: 18px;
}
.invoice-footer{
height: 80px;
font-size: 15px;
margin-top: 10px;
}
.invoice-content{
height: 470px;
overflow-y:auto;
background-color: #fff;
background: no-repeat center #f1f1f2;
border-top: 1px solid #c5c5c5;
border-bottom: 1px solid #c5c5c5;
background-color: #fff;
background-image: url("/mobile/plugin/1/fna/images/bg.png");
background-size:50%;
background-position:50% 80%;
}
.invoice-content-detail{
height: 80px;
width: 98%;
background-color:#f1f1f1;
margin-left: 1%;
margin-bottom: 1px;
padding-top: 5px;
padding-left: 5px;
border-radius:5px;
}
.left-div{
width: 15%;
height: 70px;
float: left;
}
.center-div{
width: 45%;
float: left;
margin-left: 5px;
height: 70px;
font-size: 15px;
}
.right-div{
float: right;
text-align:center;
width: 30%;
height: 70px;
font-size: 15px;
}
.info-title{
color: #000;
}
.info-detail{
color: #919191;
overflow: hidden;
text-overflow:ellipsis;
white-space: nowrap;
}
.btn-div{
width: 33%;
float: left;
}
.btn3{
width: 34%;
}
.btn{
width: 100%;
height: 50px;
font-weight: bold;
border-radius:0;
}
.invoice-image{
height: 150px;
width: 100%;
}
.btn-div-info{
width: 50%;
float: left;
}
.invoice-info{
width: 100%;
}
#invoice-info-main,#invoice-info-main-2{
height: 100%;
width: 98%;
margin-left: 1%;
}
#invoice-info-main-3{
height: 100%;
width: 90%;
margin-left: 5%;
overflow: hidden;
text-overflow:ellipsis;
white-space: nowrap;
}
.inputdiv{
width: 70%;line-height: 50px;height:50px;font-weight: bold;float: right;text-align: right;
}
.keydiv{
overflow: hidden;
text-overflow:ellipsis;
white-space: nowrap;
width: 30%;line-height: 50px;height:50px;font-weight: bold;float: left;text-align: right;
}
.ronlydiv{
overflow: hidden;
text-overflow:ellipsis;
white-space: nowrap;
width: 70%;line-height: 50px;height:50px;font-weight: bold;float: left;text-align: right;
color: #6B6B6B;
}
.btn-div-long{
width: 100%;
}
#jymDiv1,#jymDiv2{
display: none;
}
</style>
</head>
<body>
<div id="container1">
<div class="title">请选择发票</div>
<div class="invoice-content" id="invoice-content-id">
</div>
<div class="invoice-footer">
<div class="btn-div" onclick="closeInvoice();">
<button class="btn btn-danger">关闭</button>
</div>
<div class="btn-div" id="chooseInvoice">
<button style="border-left: none;border-right: none;" class="btn btn-default" onclick="uploadimage();">选择发票</button>
<input type="file" accept="image/*" multiple="multiple" name='file_head' id="file_head" style="position:absolute;opacity:0;margin-top: -50px;height: 50px;width: 33%;">
</div>
<div class="btn-div btn3">
<button class="btn btn-primary" onclick="completeFee();">生成报销单</button>
</div>
</div>
</div>
<div id="container2">
<div class="invoice-image" onclick="showimage(1);">
<img id="invoice-image-title" style="width: 100%;height: 100%;" alt="无图片" src="">
</div>
<div class="invoice-info">
<input type="text" hidden="hidden" id="uuid-hidden-1" value="">
<input type="text" hidden="hidden" id="invoice-type" value="">
<div id="invoice-info-main">
</div>
</div>
<div class="invoice-footer">
<div class="btn-div" onclick="closeInvoiceInfo();">
<button class="btn btn-danger">关闭</button>
</div>
<div class="btn-div">
<button class="btn btn-primary" onclick="saveInfo();">保存</button>
</div>
<div class="btn-div btn3">
<button class="btn btn-danger" style="background-color: #EEB422;border:none;" onclick="deleteInvoice(1);">删除</button>
</div>
</div>
</div>
<div id="container3">
<div class="invoice-image" onclick="showimage(2);">
<img id="invoice-image-title-2" style="width: 100%;height: 100%;" alt="无图片" src="">
</div>
<div class="invoice-info">
<input type="text" hidden="hidden" id="uuid-hidden-2" value="">
<div id="invoice-info-main-2">
<input type="text" style="display: none;" id="invoiceid">
<div class='keydiv'>发票代码:</div>
<div class='inputdiv'>
<input onkeyup="this.value=this.value.replace(/[^\d]/g,'')" onafterpaste="this.value=this.value.replace(/[^\d]/g,'')"
id="fpdm" onblur="fpdmBlur();"
maxlength="12"
type="text" placeholder="请输入发票代码"
class="form-control text-input"type='text' style='height: 30px;margin-top: 10px;' value="">
</div>
<div class='keydiv'>发票号码:</div>
<div class='inputdiv'>
<input onkeyup="this.value=this.value.replace(/[^\d]/g,'')" onafterpaste="this.value=this.value.replace(/[^\d]/g,'')"
id="fphm" onblur="fphmBlur();"
maxlength="8" type="text" class="form-control text-input"
autocomplete="off" placeholder="请输入发票号码" style='height: 30px;margin-top: 10px;' value="">
</div>
<div class='keydiv'>开票日期:</div>
<div class='inputdiv'>
<input onblur="rqBlur();" id="checkDate" type="date" class="form-control text-input" autocomplete="off"
style='height: 30px;margin-top: 10px;' value="">
</div>
<div class='keydiv' id="bhsDiv1">不含税金额:</div>
<div class='inputdiv' id="bhsDiv2">
<input maxlength="9" id="je" type="text" onblur="jeBlur();" onkeyup="clearNoNum(this)" class="form-control text-input"
placeholder="请输入开具金额" autocomplete="off"
style='height: 30px;margin-top: 10px;' value="">
</div>
<div class='keydiv' id="jymDiv1">校验码后6位:</div>
<div class='inputdiv' id="jymDiv2">
<input onkeyup="this.value=this.value.replace(/[^\d]/g,'')" onafterpaste="this.value=this.value.replace(/[^\d]/g,'')"
id="jym" onblur="jymBlur();" maxlength="6" type="text" class="form-control text-input"
placeholder="请输入校验码后六位" autocomplete="off"
style='height: 30px;margin-top: 10px;' value="">
</div>
</div>
</div>
<div class="invoice-footer">
<div class="btn-div" onclick="closeInvoiceInfo();">
<button class="btn btn-danger">关闭</button>
</div>
<div class="btn-div">
<button class="btn btn-primary" onclick="onCheck_auto();">手动验票</button>
</div>
<div class="btn-div btn3">
<button class="btn btn-danger" style="background-color: #EEB422;border:none;" onclick="deleteInvoice(2);">删除</button>
</div>
</div>
</div>
<div id="container4">
<div class="invoice-image" onclick="showimage(3);">
<img id="invoice-image-title-3" style="width: 100%;height: 100%;" alt="无图片" src="">
</div>
<div class="invoice-info">
<input type="text" hidden="hidden" id="uuid-hidden-3" value="">
<div id="invoice-info-main-3">
</div>
</div>
<div class="invoice-footer">
<div class="btn-div-info" onclick="closeInvoiceInfo();">
<button class="btn btn-danger">关闭</button>
</div>
<div class="btn-div-info">
<button class="btn btn-primary" style="background-color: #EEB422;border:none;" onclick="deleteInvoice(3);">删除</button>
</div>
</div>
</div>
<div id="image-select" style="position: absolute;top: 60%;left: 5%;width: 90%;height:35%;bottom:5%;background-color: #fff;opacity:1;z-index: 10001;border-radius:10px;border: 1px solid #eeeeee;display: none;">
<div style="width: 100%;height: 33%;border-bottom: 1px solid #eeeeee;" onclick="takePicture(event,this);">
<div style="width:20%;height:100%;background: url('/mobilemode/images/mec/photograph_wev8.png') no-repeat center;float: right;"></div>
<div style="width:80%;height:100%;float: left;background: url('/mobile/plugin/1/fna/images/pz.png') no-repeat left;background-size:40px 40px;background-position: 10px;"></div>
</div>
<div style="width: 100%;height: 33%;border-bottom: 1px solid #eeeeee;" onclick="photoAlbum(event,this);">
<div style="width:20%;height:100%;background: url('/mobilemode/images/mec/photochoose_wev8.png') no-repeat center;float: right;"></div>
<div style="width:80%;height:100%;float: left;background: url('/mobile/plugin/1/fna/images/zptk.png') no-repeat left;background-size:80px 40px;background-position: 10px;"></div>
</div>
<div style="width: 100%;height: 33%;background: url('/mobile/plugin/1/fna/images/qx.png') no-repeat center;background-size:40px 40px;" onclick="cancel();"></div>
</div>
</body>
<script type="text/javascript">
var u = navigator.userAgent;
var isAndroid = u.indexOf('Android') > -1 || u.indexOf('Adr') > -1; //android终端
var isiOS = !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/); //ios终端
var isEMobile = u.indexOf('E-Mobile') > -1;
var fplx = 0;
var jyfpdm = 0;
var jyfphm = 0;
var jyjym = 0;
var jyje = 0;
var ifcheckCode = 0;
var ifExistsInterface =true;
function closeInvoice(){
//parent.callbackBack_invoiceScanning();
window.goBack();
}
var dindex = "0";
var workflowid = "";
$(function(){
if((isAndroid || isiOS) && isEMobile){
//判断当前em版本号是否存在连续拍照的方法
isExistFunPicture();
}
workflowid = window.getWfId();
dindex = window.getWfDetailName();
if(dindex == "main"){
dindex = -2;
}else{
dindex = parseInt(dindex.replace("detail_",""))-1;
}
FastClick.attach(document.body);
jQuery('input[name=file_head]').on('change', function(){
var fileLen = this.files.length;
for(var i = 0;i<fileLen;i++){
var file = this.files[i];
if(!isCanvasSupported()){
var imgFile;
var reader = new FileReader();
reader.onload=function(e) {
imgFile = e.target.result;
appendDetail(imgFile);
};
reader.readAsDataURL(file);
}else{
compress(event, i,function(base64Img){
appendDetail(base64Img);
});
}
}
$("#file_head").val("");
});
});
function isExistFunPicture(){
loading();
window.em_ssoInit().then(() => {
em.getClientInfo({
success: function (res) {
var clientVersion = res.clientVersion;
if(isiOS){
var split = clientVersion.split(".");
//格式:7.0.21
var version1=parseInt(split[1]);
var version2=parseInt(split[2]);
if(version1>0){
$("#file_head").remove();
}else if(version1==0){
if(version2>=21){
$("#file_head").remove();
}
}
}else if(isAndroid){
//格式:7.0.18.20190429
var split = clientVersion.split(".");
var version1=parseInt(split[1]);
var version2=parseInt(split[2]);
var version3=parseInt(split[3]);
if(version1>0){
$("#file_head").remove();
}else if(version1==0){
if(version2>18){
$("#file_head").remove();
}else if(version2==18){
if(version3>=20190429){
$("#file_head").remove();
}
}
}
}
loaded();
}
});
}).catch((res) => {
})
}
function isCanvasSupported() {
var elem = document.createElement('canvas');
return !!(elem.getContext && elem.getContext('2d'));
}
function compress(event, i,callback) {
if ( typeof (FileReader) === 'undefined') {
alert("当前浏览器内核不支持base64图标压缩");
} else {
try {
var file = event.currentTarget.files[i];
var reader = new FileReader();
reader.onload = function (e) {
var image = $('<img/>');
image.load(function () {
//console.log("开始压缩");
var square = 1000;
var canvas = document.createElement('canvas');
var context = canvas.getContext('2d');
var imageWidth;
var imageHeight;
if (this.width > this.height) {
imageWidth = Math.round(square * this.width / this.height);
imageHeight = square;
} else {
imageHeight = Math.round(square * this.height / this.width);
imageWidth = square;
}
context.clearRect(0, 0, imageWidth, imageHeight);
canvas.width = imageWidth;
canvas.height = imageHeight;
context.drawImage(this, 0, 0,imageWidth,imageHeight);
var data = canvas.toDataURL('image/jpeg');
callback(data);
});
image.attr('src', e.target.result);
};
reader.readAsDataURL(file);
} catch(e) {}
}
}
function uploadimage(){
if((isAndroid || isiOS) && isEMobile){
$("#image-select").show();
}
}
//拍照
function takePicture(e,params) {
cancel();
window.em_ssoInit().then(() => {
em.chooseImage({
count: 10, // 最大可选照片数,默认9
sourceType: ['camera'], // 可以指定来源是相册还是相机,默认二者都有
success: function (res) {
var localIds = res.localIds; // 返回选定照片的本地ID列表
localIds.forEach(function(localId){
em.getLocalImgData({
localId: localId,
success: function(res){
//alert("获取localId成功");
var data = res.localData;
addImg(data);
}
});
});
}
});
}).catch((res) => {
//alert("连续拍照插件异常,使用原始插件");
//var dom="<input type='file' accept='image/*' multiple='multiple' name='file_head' id='file_head' style='position:absolute;opacity:0;margin-top: -50px;height: 50px;width: 33%;'>";
//$("#chooseInvoice").append(dom);
})
}
//选照片
function photoAlbum(e,params){
cancel();
window.em_ssoInit().then(() => {
em.chooseImage({
count: 10, // 最大可选照片数,默认9
sourceType: ['album'], // 可以指定来源是相册还是相机,默认二者都有
success: function (res) {
var localIds = res.localIds; // 返回选定照片的本地ID列表
localIds.forEach(function(localId){
em.getLocalImgData({
localId: localId,
success: function(res){
var data = res.localData;
addImg(data);
}
});
});
}
});
}).catch((res) => {
//alert("连续选照片插件异常,使用原始插件");
//var dom="<input type='file' accept='image/*' multiple='multiple' name='file_head' id='file_head' style='position:absolute;opacity:0;margin-top: -50px;height: 50px;width: 33%;'>";
//$("#chooseInvoice").append(dom);
})
}
function scanQRCode(e,params){
cancel();
window.em_ssoInit().then(() => {
em.scanQRCode({
sourceType: ['qrCode'], // 可以指定来源是相册还是相机,默认二者都有
needResult:1,
success: function (res) {
alert(res.resultStr);//resultStr 为扫描到的内容
}
});
}).catch((res) => {
//alert("连续选照片插件异常,使用原始插件");
//var dom="<input type='file' accept='image/*' multiple='multiple' name='file_head' id='file_head' style='position:absolute;opacity:0;margin-top: -50px;height: 50px;width: 33%;'>";
//$("#chooseInvoice").append(dom);
})
}
function cancel(){
$("#image-select").hide();
}
function addImg(data){
var base64PicData = "data:image/jpeg;base64,"+data;
appendDetail(base64PicData);
}
var invoiceIds = "";
function completeFee(){
console.log(window.getWfId());
if(uuidArr.length == 0){
alert("未选择发票,无法生成费用");
return false;
}
var dataArray = new Array();
invoiceIds = "";
for(var i = 0;i<uuidArr.length;i++){
var uuid = uuidArr[i];
var statusid = "statusid-"+uuid;
var status = $("#"+statusid).text();
if("识别中" == status){
alert("存在识别中发票,无法生成费用");
return false;
}
if("识别失败" == status){
continue;
}
if("验票失败" == status){
continue;
}
if("验票中" == status){
alert("存在验票中发票,请验票完成之后生成费用");
return false;
}
var typeid = "typeid-"+uuid;
var invoiceNumber = $("#"+typeid).text();
if(invoiceNumber == "" || invoiceNumber == undefined){
alert("存在无发票号码的发票,请编辑保存");
return false;
}
var invoiceid = "invoiceid-"+uuid;
var id = $("#"+invoiceid).text();
var param = {
"nameValue":invoiceNumber,
"idValue":id
};
dataArray.push(param);
if(invoiceIds.length > 0){
invoiceIds += ",";
}
invoiceIds += id;
}
if(window.console){
console.log(dataArray);
}
if(invoiceIds==""){
alert("不存在识别成功的发票!");
return false;
}
loading();
try{
$.ajax({
url: '/mobile/plugin/1/fna/MultiInvoiceOCRAjax.jsp',
type: 'post',
data: {invoiceIds:invoiceIds,dindex:dindex,workflowid:workflowid,operate:"addDetail"},
dataType: 'json',
timeout: 60000,
success: function (_json) {
if(_json!=null && ""!=_json && _json.flag){
_fna_imageOCRAjax_callBack8(_json,dataArray);
}else{
alert(_json.msg);
}
},
error: function (XHR, textStatus, errorThrown) {
alert("生成报销单失败");
},
complete:function(){
loaded();
}
});
}catch(e){loaded();}
loaded();
}
function _fna_imageOCRAjax_callBack8(_json,dataArray){
try{
if (_json.error != "" && _json.error != null) {
alert("生成报销单失败");
} else {
if (_json.flag) {
var msgBuffer = _json.msgBuffer;
var indexBuffer = _json.indexBuffer;
if(msgBuffer!="" && msgBuffer!=null){
alert(msgBuffer);
}
var indexLen = indexBuffer.split(",").length;
if(indexBuffer != ""){
for(var i=0;i<indexLen;i++){
var index = indexBuffer.split(",")[i];
delete dataArray[i];
}
}
if(window.console){
console.log(dataArray);
}
var fieldIdInvoice = _json.fieldIdInvoice;
var fieldIdSubject = _json.fieldIdSubject;
var fieldIdAmount = _json.fieldIdAmount;
var fieldIdDate = _json.fieldIdDate;
var fieldIdDesc = _json.fieldIdDesc;
var fieldindex = _json.fieldindex;
var descArray = _json.desc;
for(var i = 0;i<dataArray.length;i++){
var resultJson = dataArray[i];
if(resultJson == undefined){
continue;
}
var idValue = resultJson.idValue;
var nameValue = resultJson.nameValue;
var desc = descArray[i];
var subjectId = desc.subjectId;
var subjectName = desc.subjectName;
var taxIncludedPrice = desc.taxIncludedPrice;
var billingDate = desc.billingDate;
var invoiceServiceYype = desc.invoiceServiceYype;
if(fieldindex == 0){//主表
window.parent.WfForm.changeFieldValue("field"+fieldIdInvoice, {
value: idValue,
specialobj:[
{id:idValue,name:nameValue}
]
});//发票
if(fieldIdSubject>0){
window.parent.WfForm.changeFieldValue("field"+fieldIdSubject, {
value: subjectId,
specialobj:[
{id:subjectId,name:subjectName}
]
});//科目
}
if(fieldIdAmount>0){
window.parent.WfForm.changeFieldValue("field"+fieldIdAmount, {value:taxIncludedPrice});//金额
}
if(fieldIdDate>0){
window.parent.WfForm.changeFieldValue("field"+fieldIdDate, {value:billingDate});//日期
}
if(fieldIdDesc>0){
window.parent.WfForm.changeFieldValue("field"+fieldIdDesc, {value:invoiceServiceYype});//说明
}
}else{
var detail = "detail_"+fieldindex;
var addDetailRow_paramObj = {};
addDetailRow_paramObj["field"+fieldIdInvoice] = {value : idValue, specialobj : [{id : idValue, name : nameValue}]};//发票
if(fieldIdSubject>0){
addDetailRow_paramObj["field"+fieldIdSubject] = {value : subjectId, specialobj : [{id : subjectId, name : subjectName}]};//科目
}
if(fieldIdAmount>0){
addDetailRow_paramObj["field"+fieldIdAmount] = {value : taxIncludedPrice};//金额
}
if(fieldIdDate>0){
addDetailRow_paramObj["field"+fieldIdDate] = {value : billingDate};//日期
}
if(fieldIdDesc>0){
addDetailRow_paramObj["field"+fieldIdDesc] = {value : invoiceServiceYype};//说明
}
window.parent.WfForm.addDetailRow(detail,addDetailRow_paramObj);
}
}
window.goBack();
}else{
alert("生成报销单失败");
}
}
}catch(e){}
}
function deleteInvoice(type){
var flag = confirm("确认删除此张发票?");
if(!flag){
return false;
}
var uuid = "";
if(type == "1"){
uuid = $("#uuid-hidden-1").val();
}else if(type == "2"){
uuid = $("#uuid-hidden-2").val();
}else if(type == "3"){
uuid = $("#uuid-hidden-3").val();
}
loading();
var invoiceid = "invoiceid-"+uuid;
var id = $("#"+invoiceid).text();
try{
$.ajax({
url: '/mobile/plugin/1/fna/MultiInvoiceOCRAjax.jsp',
type: 'post',
data: {id:id,operate:"deleteInvoice"},
dataType: 'json',
timeout: 60000,
success: function (_json) {
if(_json!=null && ""!=_json && _json.flag){
_fna_imageOCRAjax_callBack6(_json,uuid,id);
}else{
alert(_json.msg);
}
},
error: function (XHR, textStatus, errorThrown) {
alert("删除失败");
},
complete:function(){
loaded();
}
});
}catch(e){loaded();}
loaded();
}
function _fna_imageOCRAjax_callBack6(_json,uuid,id){
try{
if (_json.error != "" && _json.error != null) {
alert("删除失败");
} else {
if (_json.flag) {
var mainid = "mainid-"+uuid;
$("#"+mainid).remove();
deleteSameInvoice(uuid,id);
closeInvoiceInfo();
}else{
alert("删除失败");
}
}
}catch(e){}
}
Array.prototype.indexOf = function (val) {
for(var i = 0; i < this.length; i++){
if(this[i] == val){return i;}
}
return -1;
}
Array.prototype.remove = function (val) {
var index = this.indexOf(val);
if(index > -1){this.splice(index,1);}
}
var uuidArr = new Array();
function appendDetail(data){
var uuid = guid();
uuidArr.push(uuid);
var append = change_invoice_content_detail(data,"","识别中...","","",uuid);
$(".invoice-content").append(append);
var ele = document.getElementById('invoice-content-id');
ele.scrollTop = ele.scrollHeight;
$(".invoice-content").css("background-image","none");
loaded();
var srcid = "srcid-"+uuid;
var invoiceid = "invoiceid-"+uuid;
var typeid = "typeid-"+uuid;
var dateid = "dateid-"+uuid;
var sellerid = "sellerid-"+uuid;
var amtid = "amtid-"+uuid;
var statusid = "statusid-"+uuid;
try{
$.ajax({
url: '/mobile/plugin/1/fna/MultiInvoiceOCRAjax.jsp',
type: 'post',
data: {img:$("#"+srcid).attr("src"),operate:"multiCheck"},
dataType: 'json',
timeout: 60000,
success: function (_json) {
if(_json!=null && ""!=_json && _json.flag){
ifExistsInterface =_json.ifExistsInterface;
_fna_imageOCRAjax_callBack(_json,uuid,data);
}else{
alert(_json.msg);
var msg ="识别失败";
change_detail_info("0","",msg,"","",msg,uuid);
return false;
}
},
error: function (XHR, textStatus, errorThrown) {
//识别失败
var msg ="识别失败";
change_detail_info("0","",msg,"","",msg,uuid);
},
complete:function(){
}
});
}catch(e){}
}
function _fna_imageOCRAjax_callBack(_json,uuid,imgsrc){
try{
if (_json.error != "" && _json.error != null) {
var msg ="识别失败";
change_detail_info("0","",msg,"","",msg,uuid);
} else {
if (_json.flag) {
var data = _json.data;
if(data.length == 0){
var msg ="识别失败";
change_detail_info("0","",msg,"","",msg,uuid);
return;
}
var existsInvoiceSb = _json.existsInvoiceSb;
if(existsInvoiceSb!=""&&existsInvoiceSb!=undefined){
alert(existsInvoiceSb);
}
var dataLen = data.length;
for(var i = 0;i<dataLen;i++){
var newImage = "";
if(i == 0){
var invoiceType = data[i].invoiceType;
newImage = data[i].newImage;
if("10100"==invoiceType || "10101"==invoiceType || "10102"==invoiceType || "10103"==invoiceType || "10104"==invoiceType){
var invoiceId = data[i].invoiceId;
var invoiceTitle = data[i].invoiceTitle;
var invoiceInfo = data[i].invoiceInfo;
var imageID = data[i].imageID;
var total = invoiceInfo.total;
var date = invoiceInfo.date;
var description = data[i].description;
var number = data[i].number;
if(total == "" || total == undefined){
total = "0.00";
}
if(date == undefined){
date = "";
}
date = date.replace("年", "-").replace("月", "-").replace("日", "");
var exists = data[i].exists;
if(!exists){
change_detail_info(invoiceId,number,date,"",total,"验票中",uuid);
invoiceCheck(invoiceInfo,invoiceType,uuid,imageID);
}else{
change_detail_info(invoiceId,number,date,description,total,"识别成功",uuid);
}
}else{
var invoiceId = data[i].invoiceId;
var description = data[i].description;
var date = data[i].date;
var amt = data[i].amt;
var number = data[i].number;
if(amt == "" || amt == undefined){
amt = "0.00";
}
if(date == undefined){
date = "";
}
date = date.replace("年", "-").replace("月", "-").replace("日", "");
change_detail_info(invoiceId,number,date,description,amt,"识别成功",uuid);
removeSameInvoice(uuid,invoiceId);
}
if(newImage != "" && newImage != undefined){
$("#srcid-"+uuid).attr("src",newImage);
}
}else{
newImage = data[i].newImage;
var invoiceType = data[i].invoiceType;
var new_uuid = guid();
uuidArr.push(new_uuid);
var append = change_invoice_content_detail(imgsrc,"","识别中...","","",new_uuid);
$(".invoice-content").append(append);
if("10100"==invoiceType || "10101"==invoiceType || "10102"==invoiceType || "10103"==invoiceType || "10104"==invoiceType){
var invoiceId = data[i].invoiceId;
var invoiceTitle = data[i].invoiceTitle;
var invoiceInfo = data[i].invoiceInfo;
var imageID = data[i].imageID;
var total = invoiceInfo.total;
var date = invoiceInfo.date;
var description = data[i].description;
var number = data[i].number;
if(total == "" || total == undefined){
total = "0.00";
}
if(date == undefined){
date = "";
}
date = date.replace("年", "-").replace("月", "-").replace("日", "");
var exists = data[i].exists;
if(!exists){
change_detail_info(invoiceId,number,date,"",total,"验票中",new_uuid);
invoiceCheck(invoiceInfo,invoiceType,new_uuid,imageID);
}else{
change_detail_info(invoiceId,number,date,description,total,"识别成功",new_uuid);
}
}else{
var invoiceId = data[i].invoiceId;
var description = data[i].description;
var date = data[i].date;
var amt = data[i].amt;
var number = data[i].number;
if(amt == "" || amt == undefined){
amt = "0.00";
}
if(date == undefined){
date = "";
}
date = date.replace("年", "-").replace("月", "-").replace("日", "");
change_detail_info(invoiceId,number,date,description,amt,"识别成功",new_uuid);
removeSameInvoice(new_uuid,invoiceId);
}
if(newImage != "" && newImage != undefined){
$("#srcid-"+new_uuid).attr("src",newImage);
}
}
var ele = document.getElementById('invoice-content-id');
ele.scrollTop = ele.scrollHeight;
}
} else {
var msg ="识别失败";
change_detail_info("0","",msg,"","",msg,uuid);
}
}
}catch(e){alert(e);}
}
function removeSameInvoice(uuid,id){
var flag = "1";
for(var i = 0;i<uuidArr.length;i++){
var _uuid = uuidArr[i];
if(uuid == _uuid){
continue;
}
var invoiceid = "invoiceid-"+_uuid;
var _id = $("#"+invoiceid).text();
if(_id == id){
flag = "2";
}
}
if(flag == "2"){
alert("存在同一张发票");
var mainid = "mainid-"+uuid;
$("#"+mainid).remove();
uuidArr.remove(uuid);
}
}
function invoiceCheck(invoiceInfo,invoiceType,uuid,imageID){
try{
$.ajax({
url: '/mobile/plugin/1/fna/MultiInvoiceOCRAjax.jsp?invoiceType='+invoiceType+"&operate=invoiceCheck&imageID="+imageID,
type: 'post',
data: invoiceInfo,
dataType: 'json',
timeout: 60000,
success: function (_json) {
if(_json!=null && ""!=_json && _json.flag){
_fna_imageOCRAjax_callBack2(_json,uuid);
}else{
var msg ="验票失败";
change_detail_info("0",msg,msg,msg,"0.00",msg,uuid);
return false;
}
},
error: function (XHR, textStatus, errorThrown) {
//识别失败
var msg ="验票失败";
change_detail_info("0",msg,msg,msg,"0.00",msg,uuid);
},
complete:function(){
}
});
}catch(e){}
}
function closeInvoiceInfo(){
$("#container1").show();
$("#container2").hide();
$("#container3").hide();
$("#container4").hide();
}
function updateFindUUID(uuid,id,date,amt,number){
for(var i = 0;i<uuidArr.length;i++){
var _uuid = uuidArr[i];
if(uuid != _uuid){
continue;
}
var invoiceid = "invoiceid-"+_uuid;
var _id = $("#"+invoiceid).text();
if(_id == id){
var dateid = "dateid-"+_uuid;
var amtid = "amtid-"+_uuid;
var typeid = "typeid-"+_uuid;
$("#"+typeid).text(number);
$("#"+dateid).text(date);
$("#"+amtid).text("¥"+amt);
}
}
}
function deleteSameInvoice(uuid,id){
var bakArr = new Array();
bakArr.push(uuid);
for(var i = 0;i<uuidArr.length;i++){
var _uuid = uuidArr[i];
if(uuid == _uuid){
continue;
}
var invoiceid = "invoiceid-"+_uuid;
var _id = $("#"+invoiceid).text();
if(_id == id){
var mainid = "mainid-"+_uuid;
$("#"+mainid).remove();
bakArr.push(_uuid);
}
}
for(var i = 0;i<bakArr.length;i++){
uuidArr.remove(bakArr[i]);
}
if(uuidArr.length==0){
$(".invoice-content").css("background-image","url('/mobile/plugin/1/fna/images/bg.png')");
}
}
function saveInfo(){
var uuid = $("#uuid-hidden-1").val();
var type = $("#invoice-type").val();
var _data = "";
var invoiceid = "invoiceid-"+uuid;
var id = $("#"+invoiceid).text();
_data = "type="+type+"&invoiceid="+id;
if("1" == type || "2" == type || "15" == type || "16" == type){//增值税发票
var invoiceCode= $.trim($("#"+uuid+"-zzs-invoiceCode").val());
var invoiceNumber= $.trim($("#"+uuid+"-zzs-invoiceNumber").val());
var taxIncludedPrice= $.trim($("#"+uuid+"-zzs-taxIncludedPrice").val());
var priceWithoutTax= $.trim($("#"+uuid+"-zzs-priceWithoutTax").val());
var billingDate= $.trim($("#"+uuid+"-zzs-billingDate").val());
var seller= $.trim($("#"+uuid+"-zzs-seller").val());
var purchaser= $.trim($("#"+uuid+"-zzs-purchaser").val());
if(invoiceCode == "" || invoiceCode == undefined){
alert("发票代码必填");return false;
}
if(invoiceNumber == "" || invoiceNumber == undefined){
alert("发票号码必填");return false;
}
if(billingDate == "" || billingDate == undefined){
alert("日期必填");return false;
}
if(taxIncludedPrice == "" || taxIncludedPrice == undefined){
alert("金额必填");return false;
}
_data += "&invoiceCode="+invoiceCode+"&invoiceNumber="+invoiceNumber+
"&taxIncludedPrice="+taxIncludedPrice+"&priceWithoutTax="+priceWithoutTax+
"&billingDate="+billingDate+"&seller="+seller+
"&purchaser="+purchaser;
//ocr识别添加字段
var salesTaxNo= $.trim($("#"+uuid+"-zzs-salesTaxNo").val());
var purchaserTaxNo= $.trim($("#"+uuid+"-zzs-purchaserTaxNo").val());
var kind = $.trim($("#"+uuid+"-zzs-kind").val());//发票消费类型
var checkCode = "";
var category = "";//种类
var tax = "";
var taxRate = "";
var company_seal = "";//是否有公司印章
var form_type = "";//发票是第几联
var form_name = "";//发票联次
var ciphertext = "";//密码区
if("1" == type){
checkCode= $.trim($("#"+uuid+"-zzs-checkCode").val());
category= $.trim($("#"+uuid+"-zzs-category").val());
}else{
tax = $.trim($("#"+uuid+"-zzs-tax").val());;
taxRate = $.trim($("#"+uuid+"-zzs-taxRate").val());;
company_seal = $.trim($("#"+uuid+"-zzs-company_seal").val());;//是否有公司印章
form_type = $.trim($("#"+uuid+"-zzs-form_type").val());;//发票是第几联
form_name = $.trim($("#"+uuid+"-zzs-form_name").val());;//发票联次
ciphertext = $.trim($("#"+uuid+"-zzs-ciphertext").val());;//密码区
}
_data += "&salesTaxNo="+salesTaxNo+"&purchaserTaxNo="+purchaserTaxNo+"&checkCode="+checkCode+"&category="+category+
"&kind="+kind+"&tax="+tax+"&taxRate="+taxRate+"&company_seal="+company_seal+"&form_type="+form_type+
"&form_name="+form_name+"&ciphertext="+ciphertext;
}else if("12" == type){//机动车销售统一发票
var invoiceCode= $.trim($("#"+uuid+"-jdc-invoiceCode").val());
var invoiceNumber= $.trim($("#"+uuid+"-jdc-invoiceNumber").val());
var billingDate= $.trim($("#"+uuid+"-jdc-billingDate").val());
var taxIncludedPrice= $.trim($("#"+uuid+"-jdc-taxIncludedPrice").val());
var machine_code= $.trim($("#"+uuid+"-jdc-machine_code").val());
var machine_number= $.trim($("#"+uuid+"-jdc-machine_number").val());
var pretax_amount= $.trim($("#"+uuid+"-jdc-pretax_amount").val());
var seller_tax_id= $.trim($("#"+uuid+"-jdc-seller_tax_id").val());
var buyer_id= $.trim($("#"+uuid+"-jdc-buyer_id").val());
var tax_authorities= $.trim($("#"+uuid+"-jdc-tax_authorities").val());
var tax_authorities_code= $.trim($("#"+uuid+"-jdc-tax_authorities_code").val());
var car_code= $.trim($("#"+uuid+"-jdc-car_code").val());
var car_engine_code= $.trim($("#"+uuid+"-jdc-car_engine_code").val());
var car_model= $.trim($("#"+uuid+"-jdc-car_model").val());
var certificate_number= $.trim($("#"+uuid+"-jdc-certificate_number").val());
if(invoiceCode == "" || invoiceCode == undefined){
alert("发票代码必填");return false;
}
if(invoiceNumber == "" || invoiceNumber == undefined){
alert("发票号码必填");return false;
}
if(billingDate == "" || billingDate == undefined){
alert("日期必填");return false;
}
if(taxIncludedPrice == "" || taxIncludedPrice == undefined){
alert("金额必填");return false;
}
_data += "&invoiceCode="+invoiceCode+"&invoiceNumber="+invoiceNumber+
"&billingDate="+billingDate+"&taxIncludedPrice="+taxIncludedPrice+
"&machine_code="+machine_code+"&machine_number="+machine_number+
"&pretax_amount="+pretax_amount+"&seller_tax_id="+seller_tax_id+
"&buyer_id="+buyer_id+"&tax_authorities="+tax_authorities+
"&tax_authorities_code="+tax_authorities_code+"&car_code="+car_code+
"&car_engine_code="+car_engine_code+"&car_model="+car_model+
"&certificate_number="+certificate_number;
}else if("11" == type){//二手车销售统一发票
var invoiceCode= $.trim($("#"+uuid+"-esc-invoiceCode").val());
var invoiceNumber= $.trim($("#"+uuid+"-esc-invoiceNumber").val());
var billingDate= $.trim($("#"+uuid+"-esc-billingDate").val());
var taxIncludedPrice= $.trim($("#"+uuid+"-esc-taxIncludedPrice").val());
var seller_id= $.trim($("#"+uuid+"-esc-seller_id").val());
var buyer_id= $.trim($("#"+uuid+"-esc-buyer_id").val());
var company_name= $.trim($("#"+uuid+"-esc-company_name").val());
var company_tax_id= $.trim($("#"+uuid+"-esc-company_tax_id").val());
var license_plate= $.trim($("#"+uuid+"-esc-license_plate").val());
var registration_number= $.trim($("#"+uuid+"-esc-registration_number").val());
var car_code= $.trim($("#"+uuid+"-esc-car_code").val());
var car_model= $.trim($("#"+uuid+"-esc-car_model").val());
if(invoiceCode == "" || invoiceCode == undefined){
alert("发票代码必填");return false;
}
if(invoiceNumber == "" || invoiceNumber == undefined){
alert("发票号码必填");return false;
}
if(billingDate == "" || billingDate == undefined){
alert("日期必填");return false;
}
if(taxIncludedPrice == "" || taxIncludedPrice == undefined){
alert("金额必填");return false;
}
_data += "&invoiceCode="+invoiceCode+"&invoiceNumber="+invoiceNumber+
"&billingDate="+billingDate+"&taxIncludedPrice="+taxIncludedPrice+
"&seller_id="+seller_id+"&buyer_id="+buyer_id+
"&company_name="+company_name+"&company_tax_id="+company_tax_id+
"&license_plate="+license_plate+"®istration_number="+registration_number+
"&car_code="+car_code+"&car_model="+car_model;
}else if("5" == type){//定额发票
var invoiceCode= $.trim($("#"+uuid+"-de-invoiceCode").val());
var invoiceNumber= $.trim($("#"+uuid+"-de-invoiceNumber").val());
var taxIncludedPrice= $.trim($("#"+uuid+"-de-taxIncludedPrice").val());
if(invoiceCode == "" || invoiceCode == undefined){
alert("发票代码必填");return false;
}
if(invoiceNumber == "" || invoiceNumber == undefined){
alert("发票号码必填");return false;
}
if(taxIncludedPrice == "" || taxIncludedPrice == undefined){
alert("金额必填");return false;
}
_data += "&invoiceCode="+invoiceCode+"&invoiceNumber="+invoiceNumber+
"&taxIncludedPrice="+taxIncludedPrice;
//ocr增加字段
var kind= $.trim($("#"+uuid+"-de-kind").val());
_data += "&kind="+kind;
}else if("3" == type){//机打发票
var invoiceCode= $.trim($("#"+uuid+"-jdfp-invoiceCode").val());
var invoiceNumber= $.trim($("#"+uuid+"-jdfp-invoiceNumber").val());
var billingDate= $.trim($("#"+uuid+"-jdfp-billingDate").val());
var seller= $.trim($("#"+uuid+"-jdfp-seller").val());
var purchaser= $.trim($("#"+uuid+"-jdfp-purchaser").val());
var taxIncludedPrice= $.trim($("#"+uuid+"-jdfp-taxIncludedPrice").val());
var checkCode= $.trim($("#"+uuid+"-jdfp-checkCode").val());
var time= $.trim($("#"+uuid+"-jdfp-time").val());
var category= $.trim($("#"+uuid+"-jdfp-category").val());
var seller_tax_id= $.trim($("#"+uuid+"-jdfp-seller_tax_id").val());
var buyer_tax_id= $.trim($("#"+uuid+"-jdfp-buyer_tax_id").val());
if(invoiceCode == "" || invoiceCode == undefined){
alert("发票代码必填");return false;
}
if(invoiceNumber == "" || invoiceNumber == undefined){
alert("发票号码必填");return false;
}
if(billingDate == "" || billingDate == undefined){
alert("日期必填");return false;
}
if(taxIncludedPrice == "" || taxIncludedPrice == undefined){
alert("金额必填");return false;
}
_data += "&invoiceCode="+invoiceCode+"&invoiceNumber="+invoiceNumber+
"&billingDate="+billingDate+"&seller="+seller+
"&purchaser="+purchaser+"&taxIncludedPrice="+taxIncludedPrice+
"&checkCode="+checkCode+"&time="+time+
"&category="+category+"&seller_tax_id="+seller_tax_id+
"&buyer_tax_id="+buyer_tax_id;
//ocr增加字段
var kind= $.trim($("#"+uuid+"-jdfp-kind").val());
_data += "&kind="+kind;
}else if("7" == type){//出租车发票
var invoiceCode= $.trim($("#"+uuid+"-czc-invoiceCode").val());
var invoiceNumber= $.trim($("#"+uuid+"-czc-invoiceNumber").val());
var billingDate= $.trim($("#"+uuid+"-czc-billingDate").val());
var taxIncludedPrice= $.trim($("#"+uuid+"-czc-taxIncludedPrice").val());
var time_geton= $.trim($("#"+uuid+"-czc-time_geton").val());
var time_getoff= $.trim($("#"+uuid+"-czc-time_getoff").val());
var mileage= $.trim($("#"+uuid+"-czc-mileage").val());
if(invoiceCode == "" || invoiceCode == undefined){
alert("发票代码必填");return false;
}
if(invoiceNumber == "" || invoiceNumber == undefined){
alert("发票号码必填");return false;
}
if(billingDate == "" || billingDate == undefined){
alert("日期必填");return false;
}
if(taxIncludedPrice == "" || taxIncludedPrice == undefined){
alert("金额必填");return false;
}
_data += "&invoiceCode="+invoiceCode+"&invoiceNumber="+invoiceNumber+
"&billingDate="+billingDate+"&taxIncludedPrice="+taxIncludedPrice+
"&time_geton="+time_geton+"&time_getoff="+time_getoff+
"&mileage="+mileage;
//ocr增加字段
var kind= $.trim($("#"+uuid+"-czc-kind").val());
var place =$.trim($("#"+uuid+"-czc-place").val());
_data += "&kind="+kind+"&place="+place;
}else if("8" == type){//火车票
var invoiceNumber= $.trim($("#"+uuid+"-hcp-invoiceNumber").val());
var billingDate= $.trim($("#"+uuid+"-hcp-billingDate").val());
var taxIncludedPrice= $.trim($("#"+uuid+"-hcp-taxIncludedPrice").val());
var time= $.trim($("#"+uuid+"-hcp-time").val());
var name= $.trim($("#"+uuid+"-hcp-name").val());
var station_geton= $.trim($("#"+uuid+"-hcp-station_geton").val());
var station_getoff= $.trim($("#"+uuid+"-hcp-station_getoff").val());
var train_number= $.trim($("#"+uuid+"-hcp-train_number").val());
var seat= $.trim($("#"+uuid+"-hcp-seat").val());
if(invoiceNumber == "" || invoiceNumber == undefined){
alert("发票号码必填");return false;
}
if(billingDate == "" || billingDate == undefined){
alert("日期必填");return false;
}
if(taxIncludedPrice == "" || taxIncludedPrice == undefined){
alert("金额必填");return false;
}
_data += "&invoiceNumber="+invoiceNumber+"&billingDate="+billingDate+
"&taxIncludedPrice="+taxIncludedPrice+"&time="+time+
"&name="+name+"&station_geton="+station_geton+
"&station_getoff="+station_getoff+"&train_number="+train_number+
"&seat="+seat;
//ocr新增字段
var kind= $.trim($("#"+uuid+"-hcp-kind").val());
_data += "&kind="+kind;
}else if("10" == type){//客运汽车
var invoiceCode= $.trim($("#"+uuid+"-kyqc-invoiceCode").val());
var invoiceNumber= $.trim($("#"+uuid+"-kyqc-invoiceNumber").val());
var billingDate= $.trim($("#"+uuid+"-kyqc-billingDate").val());
var taxIncludedPrice= $.trim($("#"+uuid+"-kyqc-taxIncludedPrice").val());
var time= $.trim($("#"+uuid+"-kyqc-time").val());
var station_geton= $.trim($("#"+uuid+"-kyqc-station_geton").val());
var station_getoff= $.trim($("#"+uuid+"-kyqc-station_getoff").val());
var name= $.trim($("#"+uuid+"-kyqc-name").val());
if(invoiceCode == "" || invoiceCode == undefined){
alert("发票代码必填");return false;
}
if(invoiceNumber == "" || invoiceNumber == undefined){
alert("发票号码必填");return false;
}
if(billingDate == "" || billingDate == undefined){
alert("日期必填");return false;
}
if(taxIncludedPrice == "" || taxIncludedPrice == undefined){
alert("金额必填");return false;
}
_data += "&invoiceCode="+invoiceCode+"&invoiceNumber="+invoiceNumber+
"&billingDate="+billingDate+"&taxIncludedPrice="+taxIncludedPrice+
"&time="+time+"&station_geton="+station_geton+
"&station_getoff="+station_getoff+"&name="+name;
//ocr新增字段
var kind= $.trim($("#"+uuid+"-kyqc-kind").val());
_data += "&kind="+kind;
}else if("14" == type){//航空运输电子客票行程单
var invoiceNumber= $.trim($("#"+uuid+"-hk-invoiceNumber").val());
var invoiceCode= invoiceNumber;
var billingDate= $.trim($("#"+uuid+"-hk-billingDate").val());
var taxIncludedPrice= $.trim($("#"+uuid+"-hk-taxIncludedPrice").val());
var user_name= $.trim($("#"+uuid+"-hk-user_name").val());
var user_id= $.trim($("#"+uuid+"-hk-user_id").val());
var agentcode= $.trim($("#"+uuid+"-hk-agentcode").val());
var issue_by= $.trim($("#"+uuid+"-hk-issue_by").val());
var fare= $.trim($("#"+uuid+"-hk-fare").val());
var fuel_surcharge= $.trim($("#"+uuid+"-hk-fuel_surcharge").val());
var caac_development_fund= $.trim($("#"+uuid+"-hk-caac_development_fund").val());
var insurance= $.trim($("#"+uuid+"-hk-insurance").val());
// if(invoiceCode == "" || invoiceCode == undefined){
// alert("发票代码必填");return false;
// }
if(invoiceNumber == "" || invoiceNumber == undefined){
alert("电子客票号码必填");return false;
}
if(billingDate == "" || billingDate == undefined){
alert("日期必填");return false;
}
if(taxIncludedPrice == "" || taxIncludedPrice == undefined){
alert("金额必填");return false;
}
_data += "&invoiceCode="+invoiceCode+"&invoiceNumber="+invoiceNumber+
"&billingDate="+billingDate+"&taxIncludedPrice="+taxIncludedPrice+
"&user_name="+user_name+"&user_id="+user_id+
"&agentcode="+agentcode+"&issue_by="+issue_by+
"&fare="+fare+"&fuel_surcharge="+fuel_surcharge+
"&caac_development_fund="+caac_development_fund+"&insurance="+insurance;
//ocr新增字段
var check_code = $.trim($("#"+uuid+"-hk-check_code").val());
var tax = $.trim($("#"+uuid+"-hk-tax").val());
var kind= $.trim($("#"+uuid+"-hk-kind").val());
_data +="&check_code="+check_code+"&tax="+tax+"&kind="+kind;
}else if("9" == type){//过路费发票
var invoiceCode= $.trim($("#"+uuid+"-glf-invoiceCode").val());
var invoiceNumber= $.trim($("#"+uuid+"-glf-invoiceNumber").val());
var billingDate= $.trim($("#"+uuid+"-glf-billingDate").val());
var taxIncludedPrice= $.trim($("#"+uuid+"-glf-taxIncludedPrice").val());
var time= $.trim($("#"+uuid+"-glf-time").val());
var entrance= $.trim($("#"+uuid+"-glf-entrance").val());
var exit= $.trim($("#"+uuid+"-glf-exit").val());
if(invoiceCode == "" || invoiceCode == undefined){
alert("发票代码必填");return false;
}
if(invoiceNumber == "" || invoiceNumber == undefined){
alert("发票号码必填");return false;
}
if(billingDate == "" ||billingDate == undefined){
alert("日期必填");return false;
}
if(taxIncludedPrice == "" || taxIncludedPrice == undefined){
alert("金额必填");return false;
}
_data += "&invoiceCode="+invoiceCode+"&invoiceNumber="+invoiceNumber+
"&billingDate="+billingDate+"&taxIncludedPrice="+taxIncludedPrice+
"&time="+time+"&entrance="+entrance+
"&exit="+exit;
//ocr新增字段
var kind= $.trim($("#"+uuid+"-glf-kind").val());
_data += "&kind="+kind;
}else if("13" == type){//国际小票
var billingDate = $.trim($("#"+uuid+"-xp-billingDate").val());
var taxIncludedPrice = $.trim($("#"+uuid+"-xp-taxIncludedPrice").val());
var priceWithoutTax = $.trim($("#"+uuid+"-xp-priceWithoutTax").val());
var tax = $.trim($("#"+uuid+"-xp-tax").val());
var storename = $.trim($("#"+uuid+"-xp-storename").val());
var time = $.trim($("#"+uuid+"-xp-time").val());
var discount = $.trim($("#"+uuid+"-xp-discount").val());
var tips = $.trim($("#"+uuid+"-xp-tips").val());
var currency_code = $.trim($("#"+uuid+"-xp-currency_code").val());
var xftype = $.trim($("#"+uuid+"-xp-xftype").val());
if(billingDate == "" ||billingDate == undefined){
alert("日期必填");return false;
}
if(taxIncludedPrice == "" || taxIncludedPrice == undefined){
alert("总金额必填");return false;
}
if(priceWithoutTax == "" || priceWithoutTax == undefined){
alert("税前金额必填");return false;
}
if(tax == "" || tax == undefined){
alert("税费必填");return false;
}
_data += "&billingDate="+billingDate+"&taxIncludedPrice="+taxIncludedPrice+
"&priceWithoutTax="+priceWithoutTax+"&tax="+tax+
"&storename="+storename+"&time="+time+
"&discount="+discount+"&tips="+tips+
"¤cy_code="+currency_code+"&xftype="+xftype;
}
loading();
_data += "&operate=saveInvoice"
try{
$.ajax({
url: '/mobile/plugin/1/fna/MultiInvoiceOCRAjax.jsp',
type: 'get',
data: _data,
dataType: 'json',
timeout: 60000,
success: function (_json) {
if(_json!=null && ""!=_json && _json.flag){
_fna_imageOCRAjax_callBack7(_json,uuid,id);
}else{
alert(_json.msg);
}
},
error: function (XHR, textStatus, errorThrown) {
alert("保存失败");
},
complete:function(){
loaded();
}
});
}catch(e){}
}
function _fna_imageOCRAjax_callBack7(_json,uuid,id){
try{
if (_json.error != "" && _json.error != null) {
alert("保存失败");
} else {
if (_json.flag) {
var billingDate = _json.billingDate;
var taxIncludedPrice = _json.taxIncludedPrice;
var invoiceNumber = _json.invoiceNumber;
var dateid = "dateid-"+uuid;
var amtid = "amtid-"+uuid;
$("#"+dateid).text(billingDate);
$("#"+amtid).text("¥"+taxIncludedPrice);
updateFindUUID(uuid,id,billingDate,taxIncludedPrice,invoiceNumber);
closeInvoiceInfo();
}else{
alert("保存失败");
}
}
}catch(e){}
}
function _fna_imageOCRAjax_callBack2(_json,uuid){
try{
if (_json.error != "" && _json.error != null) {
var msg ="验票失败";
change_detail_info("0",msg,msg,msg,"0.00",msg,uuid);
} else {
if (_json.flag) {
var invoiceId = _json.invoiceId;
var status = _json.status;
removeSameInvoice(uuid,invoiceId);
if(status == 0){
var msg ="验票成功";
change_detail_info(invoiceId,_json.number,msg,_json.description,_json.taxIncludedPrice,msg,uuid);
}else{
var msg ="验票失败";
change_detail_info(invoiceId,"",msg,msg,_json.taxIncludedPrice,msg,uuid);
}
}else{
var msg ="验票失败";
change_detail_info("0",msg,msg,msg,"0.00",msg,uuid);
}
}
}catch(e){}
}
function getSameIDUUid(uuid){
var sameUUID = new Array();
for(var i = 0;i<uuidArr.length;i++){
var _uuid = uuidArr[i];
if(uuid == _uuid){
continue;
}
var invoiceid = "invoiceid-"+_uuid;
var _id = $("#"+invoiceid).text();
if(_id == id){
sameUUID.push(_uuid);
}
}
return sameUUID;
}
function change_detail_info(invoiceId,invoiceType,date,seller,amt,status,uuid){
var srcid = "srcid-"+uuid;
var invoiceid = "invoiceid-"+uuid;
var typeid = "typeid-"+uuid;
var dateid = "dateid-"+uuid;
var sellerid = "sellerid-"+uuid;
var amtid = "amtid-"+uuid;
var statusid = "statusid-"+uuid;
$("#"+invoiceid).text(invoiceId);
$("#"+typeid).text(invoiceType);
$("#"+amtid).text("¥"+parseFloat(amt).toFixed(2));
if("验票失败" != status && "验票成功" != status){
$("#"+dateid).text(date);
$("#"+sellerid).text(seller);
}
if("验票成功" == status){
$("#"+sellerid).text(seller);
}
if("识别失败" == status){
$("#"+amtid).text("");
}
if("验票中" == status){
$("#"+statusid).removeClass("label-info").addClass("label-primary");
}else if("验票成功" == status){
$("#"+statusid).removeClass("label-info").addClass("label-success");
}else if("验票失败" == status){
$("#"+statusid).removeClass("label-primary").addClass("label-warning");
}else if("识别成功" == status){
$("#"+statusid).removeClass("label-info").addClass("label-success");
}else if("识别失败" == status){
$("#"+statusid).removeClass("label-info").addClass("label-danger");
}
$("#"+statusid).text(status);
}
function showInvoiceDetail(uuid){
$("#image-select").hide();
var invoiceId = $("#invoiceid-"+uuid).text();
if(invoiceId == 0 || invoiceId == "" || invoiceId==undefined){
return false;
}
loading();
try{
$.ajax({
url: '/mobile/plugin/1/fna/MultiInvoiceOCRAjax.jsp',
type: 'post',
data: {invoiceId:invoiceId,uuid:uuid,operate:"invoiceShow"},
dataType: 'json',
timeout: 60000,
success: function (_json) {
if(_json!=null && ""!=_json && _json.flag){
_fna_imageOCRAjax_callBack3(_json,uuid,invoiceId);
}else{
alert("查询发票信息失败");
}
},
error: function (XHR, textStatus, errorThrown) {
alert("查询发票信息失败");
},
complete:function(){
loaded();
}
});
}catch(e){}
}
function _fna_imageOCRAjax_callBack3(_json,uuid,invoiceId){
try{
if (_json.error != "" && _json.error != null) {
alert("查询发票信息失败");
} else {
if (_json.flag) {
var type= _json.type;
if(type == "1" || type == "2" || type=="15" || type=="16" || type=="12"){
if(_json.authenticity == 1){//真
$("#container1").hide();
$("#container4").show();
$("#uuid-hidden-3").val(uuid);
var imgsrc = $("#srcid-"+uuid).attr("src");
$("#invoice-image-title-3").attr("src",imgsrc);
$("#invoice-info-main-3").empty();
for (var val in _json) {
var key = val;
if(key == "flag" ||key == "type" || key == "authenticity"){
continue;
}
var info = _json[val];
$("#invoice-info-main-3").append(appendRonlyInfo(key,info));
}
}else{
var exists = _json.exists;
if(exists){
$("#container1").hide();
$("#container3").show();
$("#uuid-hidden-2").val(uuid);
var invoiceCode = _json.invoiceCode;
var invoiceNumber = _json.invoiceNumber;
var billingDate = _json.billingDate;
var priceWithoutTax = _json.priceWithoutTax;
var checkcode = _json.checkcode;
var imgsrc = $("#srcid-"+uuid).attr("src");
$("#invoice-image-title-2").attr("src",imgsrc);
if(checkcode.length == 20){
checkcode = checkcode.substring(14);
}
blurs(type, invoiceNumber, invoiceCode, checkcode, billingDate, priceWithoutTax,invoiceId);
}else{
$("#container1").hide();
$("#container2").show();
$("#uuid-hidden-1").val(uuid);
$("#invoice-type").val(type);
var imgsrc = $("#srcid-"+uuid).attr("src");
$("#invoice-image-title").attr("src",imgsrc);
$("#invoice-info-main").empty();
for (var val in _json) {
var key = val;
if(key == "flag" ||key == "type" || key=="authenticity" || key=="exists"){
continue;
}
var info = _json[val];
$("#invoice-info-main").append(appendInfo(key,info));
}
}
}
}else{
$("#container1").hide();
$("#container2").show();
$("#uuid-hidden-1").val(uuid);
$("#invoice-type").val(type);
var imgsrc = $("#srcid-"+uuid).attr("src");
$("#invoice-image-title").attr("src",imgsrc);
$("#invoice-info-main").empty();
for (var val in _json) {
var key = val;
if(key == "flag" ||key == "type"){
continue;
}
var info = _json[val];
$("#invoice-info-main").append(appendInfo(key,info));
}
}
}else{
alert("查询发票信息失败");
}
}
}catch(e){}
}
function blurs(_invoiceType,_invoiceNumber,_invoicecode,_checkCode,_billingDate,_priceWithoutTax,invoiceid){
if(_invoiceType == "1" || _invoiceType == "15" || _invoiceType == "16"){
$("#fphm").val(_invoiceNumber);
$("#fphm").blur();
$("#fpdm").val(_invoicecode);
$("#fpdm").blur();
$("#checkDate").val(_billingDate.replace("年", "-").replace("月", "-").replace("日", ""));
$("#jym").val(_checkCode);
$("#jym").blur();
$("#invoiceid").val(invoiceid);
}else{
$("#fphm").val(_invoiceNumber);
$("#fphm").blur();
$("#fpdm").val(_invoicecode);
$("#fpdm").blur();
$("#checkDate").val(_billingDate);
$("#je").val(_priceWithoutTax);
$("#je").blur();
$("#invoiceid").val(invoiceid);
}
}
function appendInfo(key,info){
var inputtype = "text";
if(key == "日期:"){
inputtype = "date";
}
if(key=="发票号码:"||key=="发票代码:" || key=="金额:"|| key=="日期:"){
key += "<span style='color:red;'>*</span>";
}
var append = "<div class='keydiv'>"+key+"</div>"+
"<div class='inputdiv'>";
append +=info;
append +="</div>";
return append;
}
function appendRonlyInfo(key,info){
var append = "<div class='keydiv'>"+key+"</div>"+
"<div class='ronlydiv'>"+info+"</div>";
return append;
}
function change_invoice_content_detail(imgsrc,invoiceType,date,seller,amt,uuid){
loading();
var amt_str = "";
if(amt&&amt!=""){
amt_str = "¥"+parseFloat(amt).toFixed(2);
}
var srcid = "srcid-"+uuid;
var invoiceid = "invoiceid-"+uuid;
var typeid = "typeid-"+uuid;
var dateid = "dateid-"+uuid;
var sellerid = "sellerid-"+uuid;
var amtid = "amtid-"+uuid;
var statusid = "statusid-"+uuid;
var mainid = "mainid-"+uuid;
var append = "<div class='invoice-content-detail' id='"+mainid+"' onclick=\"showInvoiceDetail('"+uuid+"');\">"+
"<div class='left-div' ><img width='100%;' height='100%;' id="+srcid+" alt='' src='"+imgsrc+"'></div>"+
"<div class='center-div'>"+
"<div class='info-title' style='display:none;' id="+invoiceid+"></div>"+
"<div class='info-title' id="+typeid+">"+
invoiceType+
"</div>"+
"<div class='info-detail' id="+dateid+">"+
date+
"</div>"+
"<div class='info-detail' id="+sellerid+">"+
seller+
"</div>"+
"</div>"+
"<div class='right-div'>"+
"<div id="+amtid+">"+amt_str+"</div>"+
"<div><h4><span id="+statusid+" class='label label-info'>识别中</span></h4></div>"+
"</div>"+
"</div>";
loaded();
return append;
}
function S4() {
return (((1+Math.random())*0x10000)|0).toString(16).substring(1);
}
function guid() {
return (S4()+S4()+"-"+S4()+"-"+S4()+"-"+S4()+"-"+S4()+S4()+S4());
}
function fphmBlur(){
var fphm = $("#fphm").val().trim();
if (fphm.length == 8){
displayFont(3);
}else{
displayFont(4);
}
}
function rqBlur(){
var checkDate = $("#checkDate").val().trim();
if (checkDate.length == 0){
displayFont(13);
}else{
displayFont(14);
}
}
function jeBlur(){
var je = $("#je").val().trim();
if (je.length == 0){
displayFont(9);
}else{
displayFont(10);
}
}
function jymBlur(){
var jym = $("#jym").val().trim();
if (jym.length == 6){
displayFont(7);
}else{
displayFont(8);
}
}
function getResult(){
var result = "";
var fpdm = $("#fpdm").val();
var fphm = $("#fphm").val();
var jym = $("#jym").val();
var je = $("#je").val();
var checkDate = $("#checkDate").val().replace("-","").replace("-","");
if(fplx == 1){
result = "01,04,"+fpdm+","+fphm+",0.00,"+checkDate+",00000000000"+jym+",0000,";
}else if(fplx == 2){
result = "01,01,"+fpdm+","+fphm+","+je+","+checkDate+","+"000000000000000,0000,";
}
return result;
}
function onCheck_auto(){
//alert(fplx+"---"+jyfpdm+"---"+jyfphm+"---"+jyje+"---"+checkDate);
var checkDate = $("#checkDate").val();
if(fplx == 1){
if(jyfpdm == 0 || jyfphm == 0 || jyjym == 0 || checkDate == ""){
alert("请检查所填信息是否正确");
return false;
}
}else if(fplx == 2 || fplx==12){
if(jyfpdm == 0 || jyfphm == 0 || jyje == 0 || checkDate == ""){
alert("请检查所填信息是否正确");
return false;
}
}else{
alert("请检查所填信息是否正确");
return false;
}
var result = getResult();
autoCheck(result,fplx);
}
function autoCheck(result,fplx){
loading();
var invoiceid = $("#invoiceid").val();
try{
$.ajax({
url: '/mobile/plugin/1/fna/MultiInvoiceOCRAjax.jsp',
type: 'post',
data: {result:result,type:"0",operate:"authenticityCheck",invoiceid:invoiceid},
dataType: 'json',
timeout: 60000,
success: function (_json) {
if(_json!=null && ""!=_json && _json.flag){
_fna_imageOCRAjax_callBack4(_json,fplx);
}else{
alert(_json.msg);
}
},
error: function (XHR, textStatus, errorThrown) {
alert("验票失败");
},
complete:function(){
loaded();
}
});
}catch(e){}
}
function _fna_imageOCRAjax_callBack4(_json,fplx){
try{
if (_json.error != "" && _json.error != null) {
alert("验票失败");
} else {
if (_json.flag) {
$("#container3").hide();
$("#container4").show();
$("#invoice-info-main-3").empty();
if(fplx == 1){
$("#invoice-info-main-3").append(appendRonlyInfo("发票类型:","增值税普通发票"));
}else if(fplx == 2){
$("#invoice-info-main-3").append(appendRonlyInfo("发票类型:","增值税专用发票"));
}
for (var val in _json) {
var key = val;
if(key == "flag" || key == "id" || key == "amt"|| key == "number"|| key == "date"){
continue;
}
var info = _json[val];
$("#invoice-info-main-3").append(appendRonlyInfo(key,info));
}
var uuid = $("#uuid-hidden-2").val();
var statusid = "statusid-"+uuid;
$("#"+statusid).removeClass("label-warning").addClass("label-success");
$("#"+statusid).text("验票成功");
var imgsrc = $("#srcid-"+uuid).attr("src");
$("#invoice-image-title-3").attr("src",imgsrc);
var sellerid = "sellerid-"+uuid;
if(fplx == 1){
$("#"+sellerid).text("增值税普通发票");
}else if(fplx == 2){
$("#"+sellerid).text("增值税专用发票");
}
var typeid = "typeid-"+uuid;
$("#"+typeid).text(_json.number);
var amtid = "amtid-"+uuid;
$("#"+amtid).text("¥"+_json.amt);
var invoiceid = "invoiceid-"+uuid;
$("#"+invoiceid).text(_json.id);
var dateid = "dateid-"+uuid;
$("#"+dateid).text(_json.date);
$("#uuid-hidden-3").val(uuid);
}else{
alert(_json.msg);
}
}
}catch(e){}
}
function clearNoNum(obj){
obj.value = obj.value.replace(/[^\d.]/g,""); //清除“数字”和“.”以外的字符
obj.value = obj.value.replace(/\.{2,}/g,"."); //只保留第一个. 清除多余的
obj.value = obj.value.replace(".","$#$").replace(/\./g,"").replace("$#$",".");
obj.value = obj.value.replace(/^(\-)*(\d+)\.(\d\d).*$/,'$1$2.$3');//只能输入两个小数
if(obj.value.indexOf(".")< 0 && obj.value !=""){//以上已经过滤,此处控制的是如果没有小数点,首位不能为类似于 01、02的金额
obj.value= parseFloat(obj.value);
}
}
function fpdmBlur(){
var fpdm = $("#fpdm").val().trim();
if (fpdm.length == 10 || fpdm.length == 12) {
var invoiceType = 0;
if(fpdm.length == 10){
var eight = fpdm.substring(7,8);
if("1" == eight || "2" == eight || "5" == eight || "7" == eight){
invoiceType = 1;
}else if("3" == eight || "6" == eight){
invoiceType = 2;
}
}else if(fpdm.length == 12){
var first = fpdm.substring(0,1);
var eight = fpdm.substring(7,8);
var elevenTwelve = fpdm.substring(10,11) + fpdm.substring(11,12);
if("0" == first && ("04" == elevenTwelve || "05" == elevenTwelve || "06" == elevenTwelve || "07" == elevenTwelve
|| "11" == elevenTwelve || "12" == elevenTwelve)){
invoiceType = 2;
}
if("1" == first && "2" == eight){
invoiceType = 3;
}
if("0" == first && "17" == elevenTwelve){
invoiceType = 4;
}
}
if(invoiceType == 1){
fplx = 2;
displayFont(2);
displayFont(6);
}else if(invoiceType == 2){
fplx = 1;
displayFont(2);
displayFont(5);
}else{
fplx = 0;
displayFont(1);
}
}else if(invoiceType == 3){
fplx = 12;
displayFont(2);
displayFont(6);
}else{
fplx = 0;
displayFont(1);
}
}
function displayFont(type){
if(type == 1){
jyfpdm = 0;
}else if(type == 2){
jyfpdm = 1;
}else if(type == 3){
jyfphm = 1;
}else if(type == 4){
jyfphm = 0;
}else if(type == 5){
$("#jymDiv1").show();
$("#jymDiv2").show();
$("#bhsDiv1").hide();
$("#bhsDiv2").hide();
}else if(type == 6){
$("#jymDiv1").hide();
$("#jymDiv2").hide();
$("#bhsDiv1").show();
$("#bhsDiv2").show();
}else if(type == 7){
jyjym = 1;
}else if(type == 8){
jyjym = 0;
}else if(type == 9){
jyje = 0;
}else if(type == 10){
jyje = 1;
}
}
function downCallback(){
$(".invoice-content").empty();
$(".invoice-content").css("background-image","url('/mobile/plugin/1/fna/images/bg.png')");
uuidArr.splice(0,uuidArr.length);
invoiceIds = "";
}
function showimage(type){
var image_bg = document.createElement("div");
image_bg.id = "image_bg";
image_bg.style.position = "absolute";
image_bg.style.top = "0px";
image_bg.style.left = "0px";
image_bg.style.width = "100%";
image_bg.style.height = "100%";
image_bg.style.backgroundColor = "#fff";
image_bg.style.zIndex = 10001;
image_bg.style.backgroundSize = "100%";
var src = "";
if(type=="1"){
src = $("#invoice-image-title").attr("src");
}else if(type=="2"){
src = $("#invoice-image-title-2").attr("src");
}else if(type=="3"){
src = $("#invoice-image-title-3").attr("src");
}
image_bg.style.backgroundImage="url("+src+")";
image_bg.style.backgroundRepeat="no-repeat";
image_bg.style.backgroundPosition="center";
document.body.appendChild(image_bg);
//关闭按钮
var close_div = document.createElement("div");
close_div.style.position = "absolute";
close_div.style.top = "0px";
close_div.style.right = "0px";
close_div.style.width = "50px";
close_div.style.height = "50px";
close_div.style.textAlign = "center";
close_div.style.backgroundImage="url(/fna/invoice/image/close_fna_invoice.png)";
close_div.style.backgroundRepeat="no-repeat";
close_div.style.backgroundPosition="center";
close_div.style.backgroundSize="80% 80%";
close_div.style.zIndex = 10002;
close_div.style.color = "red";
close_div.onclick=closeImage;
image_bg.appendChild(close_div);
}
function closeImage(){
var image_bg = document.getElementById("image_bg");
if (image_bg != null)
image_bg.parentNode.removeChild(image_bg);
}
function loading() {
var mask_bg = document.createElement("div");
mask_bg.id = "mask_bg";
mask_bg.style.position = "absolute";
mask_bg.style.top = "0px";
mask_bg.style.left = "0px";
mask_bg.style.width = "100%";
mask_bg.style.height = "100%";
mask_bg.style.backgroundColor = "#fff";
mask_bg.style.opacity = 0.8;
mask_bg.style.zIndex = 10001;
mask_bg.style.backgroundImage="url(/mobile/plugin/1/fna/images/loading_large_wev8.gif)";
mask_bg.style.backgroundRepeat="no-repeat";
mask_bg.style.backgroundPosition="center";
document.body.appendChild(mask_bg);
var mask_msg = document.createElement("div");
mask_msg.style.position = "absolute";
mask_msg.style.top = "35%";
mask_msg.style.left = "20%";
mask_msg.style.textAlign = "center";
mask_msg.style.fontSize = "1.1em";
mask_msg.style.fontWeight = "bold";
mask_msg.style.padding = "0.5em 3em 0.5em 3em";
mask_msg.style.zIndex = 10002;
mask_msg.style.color = "#fff";
mask_bg.appendChild(mask_msg);
}
function loaded() {
var mask_bg = document.getElementById("mask_bg");
if (mask_bg != null)
mask_bg.parentNode.removeChild(mask_bg);
}
</script>
</html>