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
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8" />
    <title>新增/编辑生产领料单</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <link rel="stylesheet" href="../../../layuiadmin/layui/css/layui.css" media="all">
    <link rel="stylesheet" href="../../../layuiadmin/style/admin.css" media="all">
    <script src="../../../layuiadmin/layui/layui.js"></script>
    <script src="../../../layuiadmin/Scripts/json2.js"></script>
    <script src="../../../layuiadmin/Scripts/jquery-1.4.1.js"></script>
    <script src="../../../layuiadmin/Scripts/webConfig.js"></script>
    <script src="../../../layuiadmin/PubCustom.js"></script>
    <style type="text/css">
 
        /*begin 此样式用于消除行元素中布局宽度不够的问题*/
        .layui-form-item .layui-inline {
            margin-top: 5px;
            margin-bottom: 5px;
            margin-right: 0px;
        }
        /*end*/
 
    </style>
</head>
<body>
    <div id="layout1" class="layui-fluid">
        <div class="layui-row layui-col-space15">
            <div class="layui-col-md12">
                <div class="layui-card">
                    <form id="form0" class="layui-form" lay-filter="component-form-group" action="">
                        <div class="layui-card-header">
                            <div class="layui-btn-group">
                                <button type="button" id="copy-btn" class="layui-btn layui-btn-normal layui-btn-radius" lay-submit="" lay-filter="Copy">复制</button>
                                <button type="button" id="addnew-btn" class="layui-btn layui-btn-normal layui-btn-radius" lay-submit="" lay-filter="Add">新增</button>
                                <button type="button" id="add-btn" class="layui-btn layui-btn-normal layui-btn-radius" lay-submit="" lay-filter="Saver">保存</button>
                                <button type="button" id="exit-btn" class="layui-btn layui-btn-normal layui-btn-radius" lay-submit="" lay-filter="Exit">退出</button>
                                <button type="button" id="preview-btn" class="layui-btn layui-btn-normal layui-btn-radius" lay-submit="" lay-filter="planview">预览</button>
                                <button type="button" id="print-btn" class="layui-btn layui-btn-normal layui-btn-radius" lay-submit="" lay-filter="print">打印</button>
                            </div>
                        </div>
 
                        <div class="layui-tab layui-tab-brief" lay-filter="docDemoTabBrief">
                            <ul class="layui-tab-title" lay-filter="tab-all">
                                <li lay-id="1" style="padding:1px;" class="layui-this">基本信息</li>
                                <!--<li lay-id="2" style="padding:1px;">其他信息</li>-->
                            </ul>
                            <h1 style="text-align:center;"><b>生产领料单</b></h1>
                            <div class="layui-tab-content">
                                <!--基本信息-->
                                <div class="layui-tab-item layui-show">
                                    <div class="layui-form-item">
                                        <div class="layui-inline">
                                            <label class="layui-form-label">单据号<label style="color:red"> * </label></label>
                                            <div class="layui-input-inline">
                                                <input class="layui-input" name="HBillNo" lay-verify="HBillNo" id="HBillNo" readonly="readonly" autocomplete="off">
                                                <input id="HInterID" name="HInterID" type="hidden" />
                                                <input id="HMaker" name="HMaker" type="hidden" /><!--制单人-->
                                            </div>
                                        </div>
                                        <div class="layui-inline">
                                            <label class="layui-form-label">日期<label style="color:red"> * </label></label>
                                            <div class="layui-input-inline">
                                                <input class="layui-input" name="HDate" id="HDate" autocomplete="off" model="datetime" dateFormat="yyyy-MM-dd" placeholder="yyyy-MM-dd">
                                            </div>
                                        </div>
                                        <div class="layui-inline">
                                            <label class="layui-form-label">车间<label style="color:red"> * </label></label>
                                            <div class="layui-input-inline">
                                                <input type="text" name="HDeptName" id="HDeptName" readonly class="layui-input" value="" style="float:left;width:150px;">
                                                <input type="hidden" name="HDeptID" id="HDeptID" class="layui-input" value="0" style="float:left;width:150px;">
                                                <button type="button" lay-submit="" class="layui-btn" lay-filter="Department" style="width:40px;">
                                                    <i class="layui-icon layui-icon-search layuiadmin-button-btn" style="margin-left:-9px;"></i>
                                                </button>
                                            </div>
                                        </div>
                                        <div class="layui-inline">
                                            <label class="layui-form-label">工艺单号<label style="color:red"> * </label></label>
                                            <div class="layui-input-inline">
                                                <input type="text" name="HProcExchBillNo" id="HProcExchBillNo" class="layui-input" value="" style="float:left;">
                                                <input type="hidden" name="HProcExchInterID" id="HProcExchInterID" lay-verify="HProcExchInterID" value="0">
                                                <input type="hidden" name="HProcExchEntryID" id="HProcExchEntryID" lay-verify="HProcExchEntryID" value="0">
                                            </div>
                                        </div>
                                    </div>
                                    <div class="layui-form-item">
                                        <div class="layui-inline">
                                            <label class="layui-form-label">生产订单号<label style="color:red"> * </label></label>
                                            <div class="layui-input-inline">
                                                <input class="layui-input" name="HICMOBillNo" lay-verify="HICMOBillNo" id="HICMOBillNo" readonly="readonly" autocomplete="off">
                                                <input id="HICMOInterID" name="HICMOInterID" type="hidden" value="0" />
                                                <input id="HICMOEntryID" name="HICMOEntryID" type="hidden" value="0" />
                                            </div>
                                        </div>
                                        <div class="layui-inline">
                                            <label class="layui-form-label">颜色<label style="color:red"> * </label></label>
                                            <div class="layui-input-inline">
                                                <input class="layui-input" name="HMaterName" lay-verify="HMaterName" id="HMaterName" readonly="readonly" autocomplete="off">
                                                <input id="HMaterID" name="HMaterID" type="hidden" value="0" />
                                            </div>
                                        </div>
                                        <div class="layui-inline">
                                            <label class="layui-form-label">客户<label style="color:red"> * </label></label>
                                            <div class="layui-input-inline">
                                                <input class="layui-input" name="HCusName" lay-verify="HCusName" id="HCusName" readonly="readonly" autocomplete="off">
                                                <input id="HCusID" name="HCusID" type="hidden" value="0" />
                                            </div>
                                        </div>
                                        <div class="layui-inline">
                                            <label class="layui-form-label">水冲<label style="color:red"> * </label></label>
                                            <div class="layui-input-inline">
                                                <input type="text" name="HWaterRush" id="HWaterRush" class="layui-input" value="" style="float:left;">
                                            </div>
                                        </div>
                                    </div>
                                    <div class="layui-form-item">
                                        <div class="layui-inline">
                                            <label class="layui-form-label">规格1</label>
                                            <div class="layui-input-inline">
                                                <input type="text" name="HModel" id="HModel" class="layui-input" value="" style="float:left;">
                                            </div>
                                        </div>
                                        <div class="layui-inline">
                                            <label class="layui-form-label">规格2</label>
                                            <div class="layui-input-inline">
                                                <input class="layui-input" name="HModel2" lay-verify="HModel2" id="HModel2" autocomplete="off">
                                            </div>
                                        </div>
                                        <div class="layui-inline">
                                            <label class="layui-form-label">布重<label style="color:red"> * </label></label>
                                            <div class="layui-input-inline">
                                                <input type="text" name="HWeight" id="HWeight" class="layui-input" value="" style="float:left;">
                                            </div>
                                        </div>
 
                                        <div class="layui-inline">
                                            <label class="layui-form-label">机速<label style="color:red"> * </label></label>
                                            <div class="layui-input-inline">
                                                <input type="text" name="HMachineSpeed" id="HMachineSpeed" class="layui-input" value="" style="float:left;">
                                            </div>
                                        </div>
                                    </div>
                                    <div class="layui-form-item">
                                        <div class="layui-inline">
                                            <label class="layui-form-label">打浆人<label style="color:red"> * </label></label>
                                            <div class="layui-input-inline">
                                                <input type="text" name="HMaterEmpName" id="HMaterEmpName" readonly class="layui-input" value="" style="float:left;width:150px;">
                                                <input type="hidden" name="HMaterEmpID" id="HMaterEmpID" class="layui-input" value="0" style="float:left;width:150px;">
                                                <button type="button" lay-submit="" class="layui-btn" lay-filter="btnSearchHMaterEmp" style="width:40px;">
                                                    <i class="layui-icon layui-icon-search layuiadmin-button-btn" style="margin-left:-9px;"></i>
                                                </button>
                                            </div>
                                        </div>
                                        <div class="layui-inline">
                                            <label class="layui-form-label">水比<label style="color:red"> * </label></label>
                                            <div class="layui-input-inline">
                                                <input type="text" name="HWaterRate" id="HWaterRate" class="layui-input" value="" style="float:left;">
                                            </div>
                                        </div>
                                        <div class="layui-inline">
                                            <label class="layui-form-label">水量<label style="color:red"> * </label></label>
                                            <div class="layui-input-inline">
                                                <input type="text" name="HWaterQty" id="HWaterQty" class="layui-input" value="" style="float:left;" readonly="readonly" autocomplete="off">
                                            </div>
                                        </div>
                                        <div class="layui-inline">
                                            <label class="layui-form-label">只数</label>
                                            <div class="layui-input-inline">
                                                <input type="text" name="HPieceQty" id="HPieceQty" class="layui-input" value="" style="float:left;">
                                            </div>
                                        </div>
                                    </div>
                                    <div class="layui-form-item">
                                        <div class="layui-inline">
                                            <label class="layui-form-label">备注</label>
                                            <div class="layui-input-inline">
                                                <textarea placeholder="请输入维备注" class="layui-textarea" name="HRemark" id="HRemark"></textarea>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                                <!--其他信息-->
                                <div class="layui-tab-item">
                                    <div class="layui-form-item">
                                        <div class="layui-inline">
                                            <label class="layui-form-label">领料员<label style="color:red"> * </label></label>
                                            <div class="layui-input-inline">
                                                <input type="text" name="HSecManagerName" id="HSecManagerName" readonly class="layui-input" value="" style="float:left;width:150px;">
                                                <input type="hidden" name="HSecManagerID" id="HSecManagerID" class="layui-input" value="0" style="float:left;width:150px;">
                                                <button type="button" lay-submit="" class="layui-btn" lay-filter="HSecManagerList" style="width:40px;">
                                                    <i class="layui-icon layui-icon-search layuiadmin-button-btn" style="margin-left:-9px;"></i>
                                                </button>
                                            </div>
                                        </div>
                                        <div class="layui-inline">
                                            <label class="layui-form-label">保管员<label style="color:red"> * </label></label>
                                            <div class="layui-input-inline">
                                                <input type="text" name="HKeeperName" id="HKeeperName" readonly class="layui-input" value="" style="float:left;width:150px;">
                                                <input type="hidden" name="HKeeperID" id="HKeeperID" class="layui-input" value="0" style="float:left;width:150px;">
                                                <button type="button" lay-submit="" class="layui-btn" lay-filter="HKeeperList" style="width:40px;">
                                                    <i class="layui-icon layui-icon-search layuiadmin-button-btn" style="margin-left:-9px;"></i>
                                                </button>
                                            </div>
                                        </div>
                                        <div class="layui-inline">
                                            <label class="layui-form-label">主管<label style="color:red"> * </label></label>
                                            <div class="layui-input-inline">
                                                <input type="text" name="HMangerName" id="HMangerName" readonly class="layui-input" value="" style="float:left;width:150px;">
                                                <input type="hidden" name="HManagerID" id="HManagerID" class="layui-input" value="0" style="float:left;width:150px;">
                                                <button type="button" lay-submit="" class="layui-btn" lay-filter="HManger" style="width:40px;">
                                                    <i class="layui-icon layui-icon-search layuiadmin-button-btn" style="margin-left:-9px;"></i>
                                                </button>
                                            </div>
                                        </div>
                                    </div>
                                    <div class="layui-form-item">
                                        <div class="layui-inline">
                                            <label class="layui-form-label">仓库<label style="color:red"> * </label></label>
                                            <div class="layui-input-inline">
                                                <input type="text" name="HWHName" id="HWHName" readonly class="layui-input" value="" style="float:left;width:150px;">
                                                <input type="hidden" name="HWHID" id="HWHID" class="layui-input" value="0" style="float:left;width:150px;">
                                                <button type="button" lay-submit="" class="layui-btn" lay-filter="WareHouse" style="width:40px;">
                                                    <i class="layui-icon layui-icon-search layuiadmin-button-btn" style="margin-left:-9px;"></i>
                                                </button>
                                            </div>
                                        </div>
                                        <div class="layui-inline">
                                            <label class="layui-form-label">源单类型</label>
                                            <div class="layui-input-inline">
                                                <input type="text" name="HSourceBillType" id="HSourceBillType" class="layui-input" value="" style="float:left;">
                                            </div>
                                        </div>
                                        <div class="layui-inline">
                                            <label class="layui-form-label">选单号</label>
                                            <div class="layui-input-inline">
                                                <input type="text" name="XDH" id="XDH" class="layui-input" value="" style="float:left;">
                                            </div>
                                        </div>
                                    </div>
                                    <div class="layui-form-item">
                                        <div class="layui-inline">
                                            <label class="layui-form-label">花版号</label>
                                            <div class="layui-input-inline">
                                                <input class="layui-input" name="HVerNo" lay-verify="HVerNo" id="HVerNo" autocomplete="off">
                                            </div>
                                        </div>
                                        <div class="layui-inline">
                                            <label class="layui-form-label">米数</label>
                                            <div class="layui-input-inline">
                                                <input class="layui-input" name="HLong" lay-verify="HLong" id="HLong" autocomplete="off" value="0">
                                            </div>
                                        </div>
                                        <div class="layui-inline">
                                            <label class="layui-form-label">单桶重量</label>
                                            <div class="layui-input-inline">
                                                <input type="text" name="HSingeWeight" id="HSingeWeight" class="layui-input" value="0" style="float:left;">
                                            </div>
                                        </div>
                                        <div class="layui-inline">
                                            <label class="layui-form-label">总浆重量</label>
                                            <div class="layui-input-inline">
                                                <input type="text" name="HMaterSumWeight" id="HMaterSumWeight" class="layui-input" value="0" style="float:left;">
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
 
                        <div class="layui-tab layui-tab-card" lay-filter="TabTest">
                            <ul class="layui-tab-title">
                                <li class="layui-this">明细信息</li>
                                <!--<li>汇总信息</li>-->
                            </ul>
                            <div class="layui-tab-content">
                                <div class="layui-tab-item layui-show">
                                    <table class="layui-hide" id="mainTable" lay-filter="mainTable"></table>
                                </div>
                                <div class="layui-tab-item">
                                    <table class="layui-hide" id="mainTable1" lay-filter="mainTable1"></table>
                                </div>
                            </div>
                        </div>
 
                        <script type="text/html" id="toolbarDemo">
                            <div class="layui-btn-container">
                                <button type="button" class="layui-btn layui-btn-sm" lay-event="btn-AddLine"><i class="layui-icon layui-icon-form"></i>增加一行</button>
                                <button type="button" class="layui-btn layui-btn-sm" lay-event="btn-InsertLine"><i class="layui-icon layui-icon-form"></i>插入一行</button>
                                <button type="button" class="layui-btn layui-btn-sm" lay-event="btn-CopyLine"><i class="layui-icon layui-icon-form"></i>复制一行</button>
                                <button type="button" class="layui-btn layui-btn-sm" lay-event="btn-Up"><i class="layui-icon layui-icon-form"></i>上移</button>
                                <button type="button" class="layui-btn layui-btn-sm" lay-event="btn-Under"><i class="layui-icon layui-icon-form"></i>下移</button>
                            </div>
                        </script>
                        <script type="text/html" id="xuhao">
                            {{d.LAY_TABLE_INDEX+1}}
                        </script>
                    </form>
                </div>
            </div>
        </div>
    </div>
    <script type="text/html" id="barDemo">
        <!--<a class="layui-btn layui-btn-xs" lay-event="edit">编辑</a>-->
        <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">删除</a>
    </script>
    <script>
        
 
        layui.config({
            base: '../../../layuiadmin/' //静态资源所在路径
        }).extend({
            index: 'lib/index' //主入口模块
        }).use(['index', 'form', 'laydate', 'table', 'element'], function () {
            //#region 公共变量
            var $ = layui.$
                , admin = layui.admin
                , layer = layui.layer
                , table = layui.table
                , form = layui.form
                , laydate = layui.laydate
                , element = layui.element;
 
            //#region 确认操作类型,并获取对应参数
            var params = get_UrlVars();
            if (typeof (params[params[0]]) == "undefined") {
                var OperationType = 1;//操作类型
                var closeType = 2;  //关闭类型
            } else {
                var OperationType = params[params[0]];//操作类型
                var linterid = params[params[1]];//源单id
                var HSouceBillType = params[params[2]];//源单类型
                var closeType = params[params[3]];  //关闭类型
            }
            //#endregion
 
            //查询条件
            var option = [];
            var option1 = [];
            var sWhere = "";
            var sBillType = "1204";
            //#endregion
 
 
            //#region 进入页面既加载
            //#region 初始化表单插件
            set_InitFrom();
            //#endregion
 
            //#region 初始化表格
            set_InitGrid();
            set_CountGrid();
            //#endregion
 
            //#region 判断操作类型并初始化界面
            if (OperationType == 1) {//无源新增
                set_AddFNew();
                //$('#print-btn').addClass("layui-btn-disabled").attr("disabled", true);
            }
            else if (OperationType == 2) {//复制
                set_CopyFromGrid(linterid);
                //$('#print-btn').addClass("layui-btn-disabled").attr("disabled", true);
            }
            else if (OperationType == 3) {//编辑
                set_EditFromGrid(linterid);
            }
            else {
                layer.alert("未知操作类型!", { icon: 5 });
            }
            //#endregion
            //#endregion
 
            //#region 监听:触发事件
            //#region 子表1:头工具栏按钮触发事件
            table.on('toolbar(mainTable)', function (obj) {
                var checkStatus = table.checkStatus('mainTable')
                    , data = checkStatus.data;;
                var AddRow = table.cache['mainTable'];
                var NewRow = { "HMaterID": 0, "HMaterCode": "", "HMaterName": "", "HMaterSpec": "", "HMaterRuleType":"", "HBatchNo": "", "HUnitID": 0, "HUnitCode": "", "HUnitName": "", "HDesignLife": 0, "HLeaveLife": 0, "HUseLife": 0, "HQtyMust": 0, "HRate": 0, "HQty": 0, "HPrice": 0, "HMoney": 0, "HWHID": 0, "HWHCode": "", "HWHName": "", "HSPID": 0, "HSPCode": "", "HSPName": "", "HStockOrgID": sessionStorage["OrganizationID"], "HRemark": "" };
                console.log(NewRow);
                switch (obj.event) {
                    //新增一行
                    case 'btn-AddLine': btnAddLine(NewRow);
                        break;
                    //复制一行
                    case 'btn-CopyLine': btnCopyLine(data);
                        break;
                    //指定位置下插入一行
                    case 'btn-InsertLine': btnInsertLine(NewRow)
                        break;
                    //上移
                    case 'btn-Up': btn_up();
                        break;
                    //下移
                    case 'btn-Under': btn_under();
                        break;
                }
            });
            //#endregion
 
            //#region 行内事件
            table.on('tool(mainTable)', function (obj) {
                set_GridDelete(obj);   //行内删除
                set_GridCellCheck(obj); //行内快捷键筛选
            });
            //#endregion
 
            //#region 选择弹窗触发事件
            //#region 选择车间弹窗
            form.on('submit(Department)', function () {
                //页面层-自定义
                layer.open({
                    type: 2,
                    skin: 'layui-layer-rim', //加上边框
                    title: '车间列表',
                    closeBtn: 1,
                    shift: 2,
                    area: ['80%', '80%'],
                    maxmin: true,
                    content: ['../../PublicPage/DeptInformation.html', 'yes'],
                    btn: ['确定', '取消']
                    , btn1: function (index, layero) {
 
                        //按钮【按钮一】的回调
                        var iframeWindow = window['layui-layer-iframe' + index]  //获取弹框页面
                        var checkStatus = iframeWindow.layui.table.checkStatus('mainTable');//获取table的elem:"#test"
                        if (checkStatus.data.length === 0) {
                            return layer.msg('请选择数据');
                        }
                        $("#HDeptName").val(checkStatus.data[0].HName);
                        $("#HDeptID").val(checkStatus.data[0].HItemID);
                        layer.close(layer.index); //它获取的始终是最新弹出的某个层,值是由layer内部动态递增计算的
                    }
                    , btn2: function (index, layero) {
                        //按钮【按钮二】的回调
                        //return false 开启该代码可禁止点击该按钮关闭
                    },
                    end: function () {
 
                    },
                    success: function (layero, index) {
 
                    }
                });
            });
            //#endregion
 
            //#region 选择打浆人弹窗
            form.on('submit(btnSearchHMaterEmp)', function () {
                //页面层-自定义
                layer.open({
                    type: 2,
                    skin: 'layui-layer-rim', //加上边框
                    title: '打浆人列表',
                    closeBtn: 1,
                    shift: 2,
                    area: ['80%', '80%'],
                    maxmin: true,
                    content: ['../../PublicPage/UserInformation.html', 'yes'],
                    btn: ['确定', '取消']
                    , btn1: function (index, layero) {
 
                        //按钮【按钮一】的回调
                        var iframeWindow = window['layui-layer-iframe' + index]  //获取弹框页面
                        var checkStatus = iframeWindow.layui.table.checkStatus('mainTable');//获取table的elem:"#test"
                        if (checkStatus.data.length === 0) {
                            return layer.msg('请选择数据');
                        }
                        $("#HMaterEmpName").val(checkStatus.data[0].HName);
                        $("#HMaterEmpID").val(checkStatus.data[0].HItemID);
                        layer.close(layer.index); //它获取的始终是最新弹出的某个层,值是由layer内部动态递增计算的
                    }
                    , btn2: function (index, layero) {
                        //按钮【按钮二】的回调
                        //return false 开启该代码可禁止点击该按钮关闭
                    },
                    end: function () {
 
                    },
                    success: function (layero, index) {
 
                    }
                });
            });
            //#endregion
 
            //#region 选择仓库弹窗
            form.on('submit(WareHouse)', function () {
                //页面层-自定义
                layer.open({
                    type: 2,
                    skin: 'layui-layer-rim', //加上边框
                    title: '仓库列表',
                    closeBtn: 1,
                    shift: 2,
                    area: ['80%', '80%'],
                    maxmin: true,
                    content: ['../../PublicPage/WareHouseInformation.html', 'yes'],
                    btn: ['确定', '取消']
                    , btn1: function (index, layero) {
 
                        //按钮【按钮一】的回调
                        var iframeWindow = window['layui-layer-iframe' + index]  //获取弹框页面
                        var checkStatus = iframeWindow.layui.table.checkStatus('mainTable');//获取table的elem:"#test"
                        if (checkStatus.data.length === 0) {
                            return layer.msg('请选择数据');
                        }
                        $("#HWHName").val(checkStatus.data[0].HName);
                        $("#HWHID").val(checkStatus.data[0].HItemID);
                        layer.close(layer.index); //它获取的始终是最新弹出的某个层,值是由layer内部动态递增计算的
                    }
                    , btn2: function (index, layero) {
                        //按钮【按钮二】的回调
                        //return false 开启该代码可禁止点击该按钮关闭
                    },
                    end: function () {
 
                    },
                    success: function (layero, index) {
 
                    }
                });
            });
            //#endregion
 
            //#region 选择验收员弹窗
            form.on('submit(HSecManagerList)', function () {
                //页面层-自定义
                layer.open({
                    type: 2,
                    skin: 'layui-layer-rim', //加上边框
                    title: '验收员列表',
                    closeBtn: 1,
                    shift: 2,
                    area: ['80%', '80%'],
                    maxmin: true,
                    content: ['../../PublicPage/UserInformation.html', 'yes'],
                    btn: ['确定', '取消']
                    , btn1: function (index, layero) {
 
                        //按钮【按钮一】的回调
                        var iframeWindow = window['layui-layer-iframe' + index]  //获取弹框页面
                        var checkStatus = iframeWindow.layui.table.checkStatus('mainTable');//获取table的elem:"#test"
                        if (checkStatus.data.length === 0) {
                            return layer.msg('请选择数据');
                        }
                        $("#HSecManagerName").val(checkStatus.data[0].HName);
                        $("#HSecManagerID").val(checkStatus.data[0].HItemID);
                        layer.close(layer.index); //它获取的始终是最新弹出的某个层,值是由layer内部动态递增计算的
                    }
                    , btn2: function (index, layero) {
                        //按钮【按钮二】的回调
                        //return false 开启该代码可禁止点击该按钮关闭
                    },
                    end: function () {
 
                    },
                    success: function (layero, index) {
 
                    }
                });
            });
            //#endregion
 
            //#region 选择保管员弹窗
            form.on('submit(HKeeperList)', function () {
                //页面层-自定义
                layer.open({
                    type: 2,
                    skin: 'layui-layer-rim', //加上边框
                    title: '保管员列表',
                    closeBtn: 1,
                    shift: 2,
                    area: ['80%', '80%'],
                    maxmin: true,
                    content: ['../../PublicPage/UserInformation.html', 'yes'],
                    btn: ['确定', '取消']
                    , btn1: function (index, layero) {
 
                        //按钮【按钮一】的回调
                        var iframeWindow = window['layui-layer-iframe' + index]  //获取弹框页面
                        var checkStatus = iframeWindow.layui.table.checkStatus('mainTable');//获取table的elem:"#test"
                        if (checkStatus.data.length === 0) {
                            return layer.msg('请选择数据');
                        }
                        $("#HKeeperName").val(checkStatus.data[0].HName);
                        $("#HKeeperID").val(checkStatus.data[0].HItemID);
                        layer.close(layer.index); //它获取的始终是最新弹出的某个层,值是由layer内部动态递增计算的
                    }
                    , btn2: function (index, layero) {
                        //按钮【按钮二】的回调
                        //return false 开启该代码可禁止点击该按钮关闭
                    },
                    end: function () {
 
                    },
                    success: function (layero, index) {
 
                    }
                });
            });
            //#endregion
 
            //#region 选择主管弹窗
            form.on('submit(HManger)', function () {
                //页面层-自定义
                layer.open({
                    type: 2,
                    skin: 'layui-layer-rim', //加上边框
                    title: '验收员列表',
                    closeBtn: 1,
                    shift: 2,
                    area: ['80%', '80%'],
                    maxmin: true,
                    content: ['../../PublicPage/UserInformation.html', 'yes'],
                    btn: ['确定', '取消']
                    , btn1: function (index, layero) {
 
                        //按钮【按钮一】的回调
                        var iframeWindow = window['layui-layer-iframe' + index]  //获取弹框页面
                        var checkStatus = iframeWindow.layui.table.checkStatus('mainTable');//获取table的elem:"#test"
                        if (checkStatus.data.length === 0) {
                            return layer.msg('请选择数据');
                        }
                          $("#HMangerName").val(checkStatus.data[0].HName);
                        $("#HManagerID").val(checkStatus.data[0].HItemID);
                        layer.close(layer.index); //它获取的始终是最新弹出的某个层,值是由layer内部动态递增计算的
                    }
                    , btn2: function (index, layero) {
                        //按钮【按钮二】的回调
                        //return false 开启该代码可禁止点击该按钮关闭
                    },
                    end: function () {
 
                    },
                    success: function (layero, index) {
 
                    }
                });
            });
            //#endregion 
 
            //#region 选择往来单位弹窗
            form.on('submit(HSupList)', function () {
                if ($("#HSupTypeID").val() == 0 || $("#HSupTypeID").val() == null) {
                    return layer.msg('请选择往来类型');
                }
                //页面层-自定义
                var url = '../../PublicPage/' + getSupType() + '.html';
                //alert(url);
                layer.open({
                    type: 2,
                    skin: 'layui-layer-rim', //加上边框
                    title: '往来单位列表',
                    closeBtn: 1,
                    shift: 2,
                    area: ['80%', '80%'],
                    maxmin: true,
                    content: [url, 'yes'],
                    btn: ['确定', '取消']
                    , btn1: function (index, layero) {
 
                        //按钮【按钮一】的回调
                        var iframeWindow = window['layui-layer-iframe' + index]  //获取弹框页面
                        var checkStatus = iframeWindow.layui.table.checkStatus('mainTable');//获取table的elem:"#test"
                        if (checkStatus.data.length === 0) {
                            return layer.msg('请选择数据');
                        }
                        $("#HSupName").val(checkStatus.data[0].HName);
                        $("#HSupID").val(checkStatus.data[0].HItemID);
                        layer.close(layer.index); //它获取的始终是最新弹出的某个层,值是由layer内部动态递增计算的
                    }
                    , btn2: function (index, layero) {
                        //按钮【按钮二】的回调
                        //return false 开启该代码可禁止点击该按钮关闭
                    },
                    end: function () {
 
                    },
                    success: function (layero, index) {
 
                    }
                });
            });
            //#endregion
            //#endregion
 
            //#region 下拉框事件选择触发
            form.on('select(HSupTypeID)', function (data) {
                $("#HSupID").val("");
                $("#HSupName").val("");
            });
            //#endregion
 
            //#region 表头文本框监听
            $(document).ready(function () {
                //#region 工艺单号:Enter键监听
                $("#HProcExchBillNo").on('input keydown', function (data) {
                    if (data.keyCode == 13) {
                        getMainInfoByHProcExchBillNo();
                    }
                });
                //#endregion
 
                //#region 水比变更,计算主表水量、子表重量
                $("#HWaterRate").on('input change', function (data) {
                    var HWaterRate = $("#HWaterRate").val();
                    var HWeight = $("#HWeight").val();
                    var HWaterQty = HWeight * HWaterRate;
                    $("#HWaterQty").val(HWaterQty);
 
                    for (var i = 0; i < option.data.length; i++) {
                        var HMaterRuleType = option.data[i].HMaterRuleType;
                        if (HMaterRuleType == "染料") {
                            option.data[i].HQty = option.data[i].HRate * HWeight;
                        } else if (HMaterRuleType == "助剂") {
                            option.data[i].HQty = option.data[i].HRate * HWaterQty;
                        }
                    }
                    table.render(option);
                });
                //#endregion
 
                //#region 布重变更,计算子表重量
                $("#HWeight").on('input change', function (data) {
                    var HWaterRate = $("#HWaterRate").val();
                    var HWeight = $("#HWeight").val();
                    var HWaterQty = HWeight * HWaterRate;
                    $("#HWaterQty").val(HWaterQty);
 
                    for (var i = 0; i < option.data.length; i++) {
                        var HMaterRuleType = option.data[i].HMaterRuleType;
                        if (HMaterRuleType == "染料") {
                            option.data[i].HQty = option.data[i].HRate * HWeight;
                        } else if (HMaterRuleType == "助剂") {
                            option.data[i].HQty = option.data[i].HRate * HWaterQty;
                        }
                    }
                    table.render(option);
                });
                //#endregion
            });
            //#endregion
 
            //#region 模块按钮触发事件
            //#region 复制
            form.on('submit(Copy)', function (data) {
                clear();
 
                var HInterID = $("#HInterID").val();
                OperationType = 2;
                set_CopyFromGrid(HInterID);
 
                //$('#print-btn').addClass("layui-btn-disabled").attr("disabled", true);
            });
            //#endregion
 
            //#region 新增
            form.on('submit(Add)', function (data) {
                clear();
                OperationType = 1;
                set_AddFNew();
                $("#HProcExchBillNo").prop("disabled", false);
                //$('#print-btn').addClass("layui-btn-disabled").attr("disabled", true);
            });
            //#endregion
 
            //#region 保存
            form.on('submit(Saver)', function (data) {
                var refSav = "";
                if (OperationType == 1 || OperationType==2) {
                    refSav = "Add";
                }
                if (OperationType==3) {
                    refSav = "Update";
                }
                data.field.HMaker = sessionStorage["HUserName"];//制单人
                var sMainStr = JSON.stringify(data.field);
                var sSubStr = JSON.stringify(table.cache['mainTable']);
                var sMainSub = sMainStr + ';' + sSubStr + ';' + refSav + ';' + sessionStorage["HUserName"];
 
 
                if (!AllowLoadData(sSubStr))//数据验证
                {
                    return false;
                }
                $.ajax(
                    {
                        type: "POST",
                        url: GetWEBURL() + "/Kf_MateOutBill/SaveGetMateOutBillList", //方法所在页面和方法名
                        async: true,
                        data: { "msg": sMainSub },
                        dataType: "json",
                        success: function (data) {
                            if (data.count == 1) { // 说明验证成功了,
                                layer.msg(data.Message, { time: 1 * 1000, icon: 1 }, function () {
                                    $('#add-btn').addClass("layui-btn-disabled").attr("disabled", true);
                                    /*$('#print-btn').addClass("layui-btn-disabled").attr("disabled", false);*/
                                    //var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
                                    //parent.layer.close(index); //再执行关闭
                                });
                            }
                            else {
 
                                f_alert(data.Message);
                                console.log("Reason" + sMainStr + "sub:" + JSON.stringify(layui.table.cache.mainTable));
                            }
                            layer.closeAll("loading");
                        },
                        error: function (err) {
 
                            f_alert("错误:" + err);
                            console.log("Reason" + sMainStr);
                        }
                    });
            });
            //#endregion 
 
            //#region 退出
            form.on('submit(Exit)', function (data) {
                Pub_Close(1);
            });
            //#endregion
 
            //#region 预览
            form.on("submit(planview)", function (data) {
                layer.open({
                    type: 2
                    , area: ['50%', '50%']
                    , title: '打印模版选择'
                    , shade: 0.6 //遮罩透明度
                    , maxmin: false //允许全屏最小化
                    , anim: 0 //0-6的动画形式,-1不开启
                    , content: ['../../BaseSet/SRM_OpenTmpList.html?linterid=' + linterid.toString() + '&MyMsg=' + linterid.toString() + '&Type=Kf_MateOutBillList', 'yes']
                    , resize: false
                })
            });
            //#endregion
 
            //#region 打印
            form.on("submit(print)", function (data) {
                layer.open({
                    type: 2
                    , area: ['50%', '50%']
                    , title: '打印模版选择'
                    , shade: 0.6 //遮罩透明度
                    , maxmin: false //允许全屏最小化
                    , anim: 0 //0-6的动画形式,-1不开启
                    , content: ['../../BaseSet/SRM_OpenTmpList.html?linterid=' + linterid.toString() + '&MyMsg=' + linterid.toString() + '&Type=Kf_MateOutBillList', 'yes']
                    , resize: false
                })
            });
            //#endregion
 
            //#region 关闭当前页
            form.on('submit(Cancel)', function () {
                parent.location.href = "../../../views/index.html"
                //window.close();//关闭当前页
            })
            //#endregion
 
            //#region 监听单元格编辑  单元格编辑后 变更
            table.on('edit(mainTable)', function (obj) {
                // 单元格编辑之前的值
                var oldText = $(this).prev().text();
                var value = obj.value //得到修改后的值
                    , data = obj.data //得到所在行所有键值
                    , field = obj.field; //得到字段
                //layer.msg('[ID: ' + data.id + '] ' + field + ' 字段更改为:' + value);
 
                switch (field) {
                    //case "HDesignLife":  //设计寿命
                    //    value = isNaN(value) ? 0 : value;
                    //    var HUseLife = isNaN(data.HUseLife) ? 0 : data.HUseLife;
                    //    //同步更新表格和缓存对应的值
                    //    obj.update({
                    //        HDesignLife: value,                          //设计寿命
                    //        HLeaveLife: value - HUseLife,           //剩余寿命=设计寿命-使用寿命
                    //    });
                    //    break;
                    //case "HLeaveLife":  //剩余寿命
                    //    var HDesignLife = isNaN(data.HDesignLife) ? 0 : data.HDesignLife;
                    //    var HUseLife = isNaN(data.HUseLife) ? 0 : data.HUseLife;
                    //    //同步更新表格和缓存对应的值
                    //    obj.tr.find('td[data-field=HLeaveLife] input').val(HDesignLife - HUseLife);
                    //    obj.update({
                    //        HLeaveLife: HDesignLife - HUseLife,   //剩余寿命=设计寿命-使用寿命
                    //    });
                    //    break;
                    //case "HUseLife":    //使用寿命
                    //    var HDesignLife = isNaN(data.HDesignLife) ? 0 : data.HDesignLife;
                    //    value = isNaN(value) ? 0 : value;
                    //    //同步更新表格和缓存对应的值
                    //    obj.update({
                    //        HLeaveLife: HDesignLife - value, //剩余寿命=设计寿命-使用寿命
                    //    });
                    //    break;
                    //case "HQty":        //实收数量
                    //    value = isNaN(value) ? 0 : value;
                    //    var HPrice = isNaN(data.HPrice) ? 0 : data.HPrice;
                    //    //同步更新表格和缓存对应的值
                    //    obj.update({
                    //        HMoney: value * HPrice, //金额=实收数量*单价
                    //    });
                    //    break;
                    //case "HPrice":      //单价
                    //    value = isNaN(value) ? 0 : value;
                    //    var HQty = isNaN(data.HQty) ? 0 : data.HQty;
                    //    //同步更新表格和缓存对应的值
                    //    obj.update({
                    //        HMoney: value * HQty, //金额=实收数量*单价
                    //    });
                    //    break;
                    //case "HMoney":     //金额
                    //    var HPrice = isNaN(data.HPrice) ? 0 : data.HPrice;
                    //    var HQty = isNaN(data.HQty) ? 0 : data.HQty;
                    //    //同步更新表格和缓存对应的值
                    //    obj.update({
                    //        HMoney: HPrice * HQty, //金额=实收数量*单价
                    //    });
                    //    break;
                    case "HRate":     //用量
                        var HWeight = $("#HWeight").val();
                        var HWaterQty = $("#HWaterQty").val();
                        var HRate = value;
                        var HQty = 0;
                        var HMaterRuleType = obj.data.HMaterRuleType;
                        if (HMaterRuleType == "染料") {
                            HQty = HRate * HWeight;
                        } else if (HMaterRuleType == "助剂") {
                            HQty = HRate * HWaterQty;
                        }
                        //同步更新表格和缓存对应的值
                        obj.update({
                            HQty: HQty
                        });
                        break;
                    case "HMaterRuleType":
                        var HWeight = $("#HWeight").val();
                        var HWaterQty = $("#HWaterQty").val();
                        var HRate = obj.data.HRate;
                        var HQty = 0;
                        var HMaterRuleType = value;
                        if (HMaterRuleType == "染料") {
                            HQty = HRate * HWeight;
                        } else if (HMaterRuleType == "助剂") {
                            HQty = HRate * HWaterQty;
                        }
                        //同步更新表格和缓存对应的值
                        obj.update({
                            HQty: HQty
                        });
                        break;
                    default:
                }
            });
            //#endregion
 
            //#region 监听提交
            form.verify({
                numberOrEmpty: function (value, item) {
                    // if (value != '') {
                    if (!/^\d+$/.test(value)) {
                        return '不能为空或数字或者0';
                    }
                    //}
                }
            });
            //#endregion
            //#endregion
 
            //#endregion
 
            //#region 此页面所有方法
            //#region 清空界面
            function clear() {
                $("#HDeptID").val("0");
                $("#HDeptName").val("");
                $("#HProcExchInterID").val("0");
                $("#HProcExchEntryID").val("0");
                $("#HProcExchBillNo").val("");
                $("#HICMOInterID").val("0");
                $("#HICMOEntryID").val("0");
                $("#HICMOBillNo").val("");
                $("#HMaterID").val("0");
                $("#HMaterName").val("");
                $("#HModel").val("");
                $("#HModel2").val("");
                $("#HPieceQty").val("");
                $("#HCusID").val("0");
                $("#HCusName").val("");
                $("#HWeight").val("");
                $("#HMachineSpeed").val("");
                $("#HWaterRush").val("");
                $("#HWaterQty").val("");
                $("#HWaterRate").val("");
                $("#HMaterEmpID").val("0");
                $("#HMaterEmpName").val("");
                $("#HRemark").val("");
 
                $("#HWHID").val("0");
                $("#HWHName").val("");
                $("#HSecManagerID").val("0");
                $("#HSecManagerName").val("");
                $("#HKeeperID").val("0");
                $("#HKeeperName").val("");
                $("#HManagerID").val("0");
                $("#HManagerName").val("");
                $("#HSourceBillType").val("");
                $("#XDH").val("");
 
                $("#HVerNo").val("");
                $("#HLong").val("");
                $("#HSingleWeight").val("0");
                $("#HMaterSumWeight").val("0");
            }
            //#endregion
 
            //#region 日期格式化
            function formatDate(date) {
                var d = new Date(date),
                    month = '' + (d.getMonth() + 1),
                    day = '' + d.getDate(),
                    year = d.getFullYear();
 
                if (month.length < 2) month = '0' + month;
                if (day.length < 2) day = '0' + day;
 
                return [year, month, day].join('-');
            }
            //#endregion
 
            //#region 初始化表单插件
            function set_InitFrom() {
                laydate.render({
                    elem: '#HDate'
                });
            }
            //#endregion
 
            //#region 判断往来单位类型
            function getSupType() {
                var type = $("#HSupTypeID").val();
                console.log(type)
                switch (type) {
                    case '1':
                        return "SupplierInformation";
                        break;
                    case '2':
                        return "CustomerInformation";
                        break;
                    case '3':
                        return "DeptInformation";
                        break;
                }
            }
            //#endregion
 
            //#region 获取最大单据号
            function get_MAXNum() {
                //获取最大单据号 new
                $("#HInterID").val("0");
                $("#HBillNo").val("");
                $.ajax({
                    url: GetWEBURL() + "/Web/GetMAXNum",
                    type: "GET",
                    data: { "HBillType": sBillType },
                    success: function (d) {
                        //console.log(d.data);
                        $("#HBillNo").val(d.data[0].HBillNo);
                        $("#HInterID").val(d.data[0].HInterID);
                        $("#HDate").val(Pub_Format(new Date(), "yyyy-MM-dd"));
                        linterid = $("#HInterID").val();
                    }
                });
            }
            //#endregion
 
            //#region 初始化明细表格
            function set_InitGrid() {
                columns = [
                    { type: 'checkbox', fixed: 'left' }
                    , { templet: '#xuhao', title: '序号', sort: true, fixed: 'left', event: "qwe", width: 100 }
                    , { field: 'HMaterID', title: 'HMaterID', width: 100, hide: true }
                    , { field: 'HMaterCode', title: '物料代码', edit: 'text', event: 'HMaterCode', width: 100 }
                    , { field: 'HMaterName', title: '物料名称', width: 100 }
                    , { field: 'HMaterRuleType', title: '物料公式', width: 100 }
                    , { field: 'HMaterSpec', title: '规格型号', width: 100 }
                    , { field: 'HUnitID', title: 'HUnitID', width: 100, hide: true }
                    , { field: 'HUnitCode', title: '计量单位代码', edit: 'text', event: 'HUnitCode', width: 100, hide: true }
                    , { field: 'HUnitName', title: '计量单位', width: 100 }
                    , { field: 'HQtyMust', title: '应发数量', width: 100, hide: true}
                    , { field: 'HRate', title: '用量‰', edit: 'text', width: 100 }
                    , { field: 'HQty', title: '重量', width: 100 }
                    , { field: 'HPrice', title: '单价', width: 100, hide: true}
                    , { field: 'HMoney', title: '金额', width: 100, hide: true}
                    , { field: 'HWHID', title: 'HWHID', width: 100, hide: true, hide: true }
                    , { field: 'HWHCode', title: '发料仓库代码', edit: 'text', event: 'HWHCode', width: 120, hide: true}
                    , { field: 'HWHName', title: '发料仓库名称', width: 120, hide: true}
                    , { field: 'HRemark', title: '备注', edit: 'text', width: 100 }
                    , { fixed: 'right', title: '操作', toolbar: '#barDemo' }
                ];
                option = {
                    id: 'mainTable'
                    , elem: '#mainTable'
                    , toolbar: '#toolbarDemo'
                    , page: false
                    , cellMinWidth: 120
                    , height: 500
                    , cols: [columns]
                    , limit: 500 //每页默认显示的数量
                    , done: function (res, curr, count) {
                    }
                };
            }
            //#endregion
 
            //#region 初始汇总信息
            function set_CountGrid() {
                //表头
                columns = [
                    { type: 'checkbox', fixed: 'left' }
                    , { templet: '#xuhao', title: '序号', sort: true, fixed: 'left', event: "qwe", width: 100 }
                    , { field: '物料代码', title: '物料代码', edit: 'text', event: 'HMaterCode', width: 100 }
                    , { field: '物料名称', title: '物料名称', edit: 'text', width: 100 }
                    , { field: '规格型号', title: '规格型号', edit: 'text', width: 100 }
                    , { field: '单据号', title: '单据号', edit: 'text', width: 100 }
                    , { field: '批次', title: '批次', edit: 'text', width: 100 }
                    , { field: '实收数量', title: '实收数量', edit: 'text', width: 100 }
                    , { field: 'hwhid1', title: 'HWHID', edit: 'text', width: 100, hide: true }
                    , { field: '收料仓库代码', title: '收料仓库代码', edit: 'text', event: 'HWHCode', width: 120 }
                    , { field: '收料仓库', title: '收料仓库名称', edit: 'text', width: 120 }
                    , { field: '表体备注', title: '备注', edit: 'text', width: 100 }
                ];
                option1 = {
                    id: 'mainTable1'
                    , elem: '#mainTable1'
                    , height: 500
                    , page: true
                    , limit: 500
                    , cellMinWidth: 120
                    , height: 500
                    , cols: [columns]
                    , done: function (res, curr, count) {
                    }
                };
            }
            //#endregion
 
            //#region 无源单新增
            function set_AddFNew() {
                //获取最大单据号
                get_MAXNum();
                option.data = [{ "HMaterID": 0, "HMaterCode": "", "HMaterName": "", "HMaterRuleType": "", "HMaterSpec": "", "HUnitID": 0, "HUnitCode": "", "HUnitName": "", "HQtyMust": 0, "HRate":0, "HQty": 0, "HPrice": 0, "HMoney": 0, "HWHID": 0, "HWHCode": "", "HWHName": "", "HRemark": "" }];
                table.render(option);
            }
            //#endregion
 
            //#region 复制
            function set_CopyFromGrid(linterid) {
                //根据所复制单据的内码获取单据信息,并初始化页面
                option.data = [{ "HMaterID": 0, "HMaterCode": "", "HMaterName": "", "HMaterSpec": "", "HMaterRuleType": "", "HUnitID": 0, "HUnitCode": "", "HUnitName": "", "HQtyMust": 0, "HRate": 0, "HQty": 0, "HPrice": 0, "HMoney": 0, "HWHID": 0, "HWHCode": "", "HWHName": "", "HRemark": "" }];
                set_EditForm(linterid);  //编辑获取表头
                set_EditGrid(linterid);  //编辑获取表体
                
                table.render(option);
 
                //覆盖单据内码、单据号、日期
                get_MAXNum();
 
                //清空 任务单号、工艺单号
                $("#HICMOInterID").val("0");
                $("#HICMOEntryID").val("0");
                $("#HICMOBillNo").val("");
                $("#HProcExchInterID").val("0");
                $("#HProcExchEntryID").val("0");
                $("#HProcExchBillNo").val("");
 
                $("#HProcExchBillNo").prop("disabled", false);
            }
            //#endregion
 
            //#region 编辑
            function set_EditFromGrid(linterid) {
                option.data = [{ "HMaterID": 0, "HMaterCode": "", "HMaterName": "", "HMaterSpec": "", "HMaterRuleType": "", "HUnitID": 0, "HUnitCode": "", "HUnitName": "", "HQtyMust": 0, "HRate": 0, "HQty": 0, "HPrice": 0, "HMoney": 0, "HWHID": 0, "HWHCode": "", "HWHName": "", "HRemark": "" }];
                set_EditForm(linterid);  //编辑获取表头
                set_EditGrid(linterid);  //编辑获取表体
                table.render(option);
 
                $("#HProcExchBillNo").prop("disabled", true);
                $("#HICMOBillNo").prop("disabled", true);
            }
            //#endregion
 
            //#region 编辑获取表头
            function set_EditForm(linterid){
                $.ajax({
                    url: GetWEBURL() + "Kf_MateOutBill/Kf_MateOutBillListCheckDetai",
                    async:false,
                    type: "GET",
                    data: {
                        "HID": linterid
                    },
                    success: function (result) {
 
                        if (result.code == 1) { // 说明验证成功了,
                            var data = result.data.h_v_Sc_MouldProdInHouseBillList[0];
                            form.val("component-form-group", { //formTest 即 class="layui-form" 所在元素属性 lay-filter="" 对应的值
                                
                                //, "HInnerBillNo": data.内部单据号
                                //"HWHID": data.HWHIDMain                    //仓库ID
                                //, "HWHName": data.仓库                   //仓库名称
                                //, "HSecManagerID": data.HSecManagerID    //验收员ID
                                //, "HSecManagerName": data.领料员         //验收员名称
                                //, "HKeeperID": data.HKeeperID            //保管员ID
                                //, "HKeeperName": data.保管员             //保管员名称
                                //, "HManagerID": data.HManagerID             //保管员名称
                                //, "HMangerName": data.主管             //保管员名称
                                //, "HSourceBillType": data.源单类型        //源单类型
                                //, "XDH": ""                               //选单号
                                
                                "HBillNo": data.单据号
                                , "HDate": formatDate(data.日期)
                                , "HDeptID": data.HDeptID                 //部门ID
                                , "HDeptName": data.部门                  //部门名称
                                , "HRemark": data.表头备注                    //备注
                                , "HICMOInterID": data.任务单内码
                                , "HICMOEntryID": data.任务单子内码
                                , "HICMOBillNo": data.任务单号
                                , "HProcExchInterID": data.工序流转卡内码
                                , "HProcExchEntryID": data.工序流转卡子内码
                                , "HProcExchBillNo": data.工序流转卡号
                                , "HMaterID": data.主产品内码
                                , "HMaterName": data.主产品名称
                                , "HVerNo": data.花版号
                                , "HModel": data.规格型号1
                                , "HModel2": data.规格型号2
                                , "HPieceQty": data.只数
                                , "HCusID": data.客户内码
                                , "HCusName": data.客户名称
                                , "HWeight": data.重量
                                , "HLong": data.米数
                                , "HSingleWeight": data.单桶重量
                                , "HMaterSumWeight": data.总浆重量
                                , "HMaterEmpID": data.打浆人内码
                                , "HMaterEmpName": data.打浆人名称
                                , "HMachineSpeed": data.机速
                                , "HWaterRush": data.水冲
                                , "HWaterQty": data.水量
                                , "HWaterRate": data.水比
                                , "HRemark": data.表头备注
                            });
 
                        } else {
                            layer.alert(result.msg, { icon: 5, btn: ['退出'], time: 100000, offset: 't' });
                        }
                    }, error: function () {
                        layer.alert("发生错误!", { icon: 5 });
                    }
                });
            }
            //#endregion
 
            //#region 编辑获取表体
            function set_EditGrid(linterid) {
                $("#HInterID").val(linterid);//修改时主表ID
                //编辑加载数据
                $.ajax({
                    url: GetWEBURL() + 'Kf_MateOutBill/Kf_MateOutBillListProjectDetai',
                    async:false,
                    type: "GET",
                    data: { "sqlWhere": "and hmainid=" + linterid },
                    success: function (result) {
                        if (result.count == 1) {
                            option.data = result.list[0];
                            table.render(option);
                            //option1.data = result.list[1];
                            //table.render(option1);
 
                        } else {
                            layer.alert(result.code + result.Message, { icon: 5 });
                        }
                    }, error: function () {
                        layer.close();
                        layer.alert("接口请求失败!", { icon: 5 });
                    }
                });
            }
            //#endregion
 
            //#region 在末尾增加一行
            function btnAddLine(NewRow) {
                table.cache["mainTable"].push(NewRow);
                option.data = table.cache["mainTable"];
                table.render(option);
                //rows++;
                layer.msg('增加一行按钮!')
            }
            //#endregion
 
            //#region 在指定行下插入一行
            function btnInsertLine(NewRow) {
                var checkStatus = table.checkStatus('mainTable')
                    , data = checkStatus.data;
                if (checkStatus.data.length === 1) {
                    var tables = [];                                    //存储插入一行后的表格数据
                    //获取表格的全部行
                    var rowList = table.cache['mainTable'];
                    for (var i = 0; i < rowList.length; i++) {          //遍历表格的行
                        tables.push(option.data[i]);
                        if (rowList[i].LAY_CHECKED == true) {           //获取选中行的位置
                            tables.push(NewRow);
                        }
                    }
                    option.data = tables;
                    table.render(option);
                } else {
                    layer.msg('请选择一行数据编辑!');
                }
            }
            //#endregion
 
            //#region 复制一行
            function btnCopyLine(data) {
                var copydata = JSON.stringify(data);
                if (data.length <= 0) {
                    layer.msg("请选择需要复制的一行!");
                }
                else if (data.length > 1) {
                    layer.msg("只能选择复制一行!");
                }
                else {
                    var copydata2 = copydata.substring(1, copydata.length);//去除首行字符'['
                    var copyrow = copydata2.substring(0, copydata2.length - 1);//去除末尾字符']'
                    table.cache["mainTable"].push(JSON.parse(copyrow));//将复制的行强转成json追加到表格上
                    option.data = table.cache["mainTable"];//将数据绑定到data上
                    table.render(option);//将数据渲染到表格上
                }
            }
            //#endregion
 
            //#region 上移
            function btn_up() {
                var checkStatus = table.checkStatus('mainTable')
                    , data = checkStatus.data;
                if (data.length == 1) {
                    var tables = [];
                    //获取表格的全部行
                    var rowList = table.cache['mainTable'];
                    for (var i = 0; i < rowList.length; i++) {          //遍历表格的行
                        if (rowList[i].LAY_CHECKED == true) {           //获取选中行的位置
                            //如果是第一行上移,则失败并提醒
                            if (i == 0) {
                                layer.msg("第一行数据无法上移!");
                                return;
                            }
                            tables.push(option.data[i - 1]);
                            data[0].LAY_CHECKED = true;
                            option.data[i - 1] = data[0];
                            option.data[i] = tables[0];
                            table.render(option);
                            break;
                        }
                    }                    
                } else {
                    layer.msg("请选择一行数据!");
                }
            }
            //#endregion
 
            //#region 下移
            function btn_under() {
                var checkStatus = table.checkStatus('mainTable')
                    , data = checkStatus.data;
                if (data.length == 1) {
                    var tables = [];
                    //获取表格的全部行
                    var rowList = table.cache['mainTable'];
                    for (var i = 0; i < rowList.length; i++) {          //遍历表格的行
                        if (rowList[i].LAY_CHECKED == true) {           //获取选中行的位置
                            //如果是最后一行下移,则失败并提醒
                            if (i == option.data.length-1) {
                                layer.msg("最后一行数据无法下移!");
                                return;
                            }
 
 
                            tables.push(option.data[i + 1]);
                            data[0].LAY_CHECKED = true;
                            option.data[i + 1] = data[0];
                            option.data[i] = tables[0];
                            table.render(option);
                            break;
                        }
                    }                   
                }else {
                    layer.msg("请选择一行数据!");
                }
            }
            //#endregion
 
            //#region 表格行内事件删除
            function set_GridDelete(obj) {
                var data = obj.data;
                var rowIndex = $(obj.tr).attr("data-index");
                if (obj.event === 'del') {
                    layer.confirm('真的删除行么', function (index) {
                        console.log("索引为:" + rowIndex);
                        if (rowIndex === '0') {
                            layer.msg('首行无法删除!!!');
                        } else {
                            //obj.del();
                            //layer.close(index);
                            var oldData = table.cache["mainTable"];
                            oldData.splice(obj.tr.data('index'), 1);
                            table.reload('mainTable', { data: oldData });
                            layer.close(index);
                        }
                    });
                }
            }
            //#endregion
 
            //#region 表格行内事件快捷键筛选
            function set_GridCellCheck(obj) {
                $(document).off('keydown', ".layui-table-edit").on('keydown', '.layui-table-edit', function (e) {
                    if (event.key == "F7") {
                        //模具信息  如果在模具代码列 按F7
                        if (obj.event === 'HMaterCode')  //模具信息  如果在模具代码列 按F7
                        {
                            //页面层-自定义  //F7选择模具
                            layer.open({
                                type: 2,
                                skin: 'layui-layer-rim', //加上边框
                                title: '物料列表',
                                closeBtn: 1,
                                shift: 2,
                                area: ['80%', '80%'],
                                maxmin: true,
                                content: ['../../../views/Baseset/基础资料/Gy_MaterialList.html', 'yes'],
                                btn: ['确定', '取消']
                                , btn1: function (index, layero) {
 
                                    //按钮【按钮一】的回调
                                    var iframeWindow = window['layui-layer-iframe' + index]  //获取弹框页面
                                    var checkStatus = iframeWindow.layui.table.checkStatus('mainTable');//获取table的elem:"#test"
                                    //if (checkStatus.data.length === 0) {
                                    //    return layer.msg('请选择数据');
                                    //}
                                    //console.log(obj.data);
 
 
                                    var rowIndex = $(obj.tr).attr("data-index") * 1;
                                    for (var i = 0; i < checkStatus.data.length; i++) {
                                        if (rowIndex + i >= option.data.length) {
                                            var NewRow = { "HMaterID": 0, "HMaterCode": "", "HMaterName": "", "HMaterRuleType": "", "HMaterSpec": "", "HBatchNo": "", "HUnitID": 0, "HUnitCode": "", "HUnitName": "", "HDesignLife": 0, "HLeaveLife": 0, "HUseLife": 0, "HQtyMust": 0, "HRate": 0, "HQty": 0, "HPrice": 0, "HMoney": 0, "HWHID": 0, "HWHCode": "", "HWHName": "", "HSPID": 0, "HSPCode": "", "HSPName": "", "HStockOrgID": sessionStorage["OrganizationID"], "HRemark": "" };
                                            btnAddLine(NewRow);
                                        }
 
                                        var HMaterID = checkStatus.data[i].HItemID;
                                        var resultData = getMaterialByMaterID(HMaterID);
                                        option.data[rowIndex + i].HMaterID = resultData.HMaterID;
                                        option.data[rowIndex + i].HMaterCode = resultData.HMaterNumber;
                                        option.data[rowIndex + i].HMaterName = resultData.HMaterName;
                                        option.data[rowIndex + i].HMaterRuleType = resultData.HMaterRuleType;
                                        option.data[rowIndex + i].HMaterSpec = resultData.HMaterModel;
                                        option.data[rowIndex + i].HUnitID = resultData.HUnitID;
                                        option.data[rowIndex + i].HUnitCode = resultData.HUnitNumber;
                                        option.data[rowIndex + i].HUnitName = resultData.HUnitName;
 
                                        option.data[rowIndex + i].HDesignLife = 0;
                                        option.data[rowIndex + i].HLeaveLife = 0;
                                        option.data[rowIndex + i].HMoney = 0;
 
 
                                        //根据物料的 物料公式 计算 重量
                                        var HWeight = $("#HWeight").val();
                                        var HWaterQty = $("#HWaterQty").val();
                                        if (option.data[rowIndex + i].HMaterRuleType == "染料") {
                                            option.data[rowIndex + i].HQty = option.data[rowIndex + i].HRate * HWeight;
                                        } else if (option.data[rowIndex + i].HMaterRuleType == "助剂") {
                                            option.data[rowIndex + i].HQty = option.data[rowIndex + i].HRate * HWaterQty;
                                        }
                                    }
                                    table.render(option);
                                    layer.closeAll();
                                    //layer.close(layer.index); //它获取的始终是最新弹出的某个层,值是由layer内部动态递增计算的
                                }
                                , btn2: function (index, layero) {
                                    //按钮【按钮二】的回调
                                    //return false 开启该代码可禁止点击该按钮关闭
                                },
                                end: function () {
 
                                }
                            });
                        }
                        //辅助属性信息
                        if (obj.event === 'HPropertyCode')  //辅助属性信息
                        {
                            //页面层-自定义
                            layer.open({
                                type: 2,
                                skin: 'layui-layer-rim', //加上边框
                                title: '辅助属性列表',
                                closeBtn: 1,
                                shift: 2,
                                area: ['80%', '80%'],
                                maxmin: true,
                                content: ['../../PublicPage/PropertyInformation.html', 'yes'],
                                btn: ['确定', '取消']
                                , btn1: function (index, layero) {
 
                                    //按钮【按钮一】的回调
                                    var iframeWindow = window['layui-layer-iframe' + index]  //获取弹框页面
                                    var checkStatus = iframeWindow.layui.table.checkStatus('mainTable');//获取table的elem:"#test"
                                    if (checkStatus.data.length === 0) {
                                        return layer.msg('请选择数据');
                                    }
 
                                    //同步更新表格和缓存对应的值
                                    obj.update({
                                        HPropertyID: checkStatus.data[0].HItemID,
                                        HPropertyCode: checkStatus.data[0].HNumber,
                                        HPropertyName: checkStatus.data[0].HName,
                                    });
 
                                    layer.close(layer.index); //它获取的始终是最新弹出的某个层,值是由layer内部动态递增计算的
                                }
                                , btn2: function (index, layero) {
                                    //按钮【按钮二】的回调
                                    //return false 开启该代码可禁止点击该按钮关闭
                                },
                                end: function () {
 
                                }
                            });
                        }
 
                        //计量单位代码
                        if (obj.event === 'HUnitCode')  //计量单位代码
                        {
                            //页面层-自定义
                            layer.open({
                                type: 2,
                                skin: 'layui-layer-rim', //加上边框
                                title: '计量单位列表',
                                closeBtn: 1,
                                shift: 2,
                                area: ['80%', '80%'],
                                maxmin: true,
                                content: ['../../PublicPage/UnitInformation.html', 'yes'],
                                btn: ['确定', '取消']
                                , btn1: function (index, layero) {
 
                                    //按钮【按钮一】的回调
                                    var iframeWindow = window['layui-layer-iframe' + index]  //获取弹框页面
                                    var checkStatus = iframeWindow.layui.table.checkStatus('mainTable');//获取table的elem:"#test"
                                    if (checkStatus.data.length === 0) {
                                        return layer.msg('请选择数据');
                                    }
 
                                    //同步更新表格和缓存对应的值
                                    obj.update({
                                        HUnitID: checkStatus.data[0].HItemID,
                                        HUnitCode: checkStatus.data[0].HNumber,
                                        HUnitName: checkStatus.data[0].HName,
                                    });
 
                                    layer.close(layer.index); //它获取的始终是最新弹出的某个层,值是由layer内部动态递增计算的
                                }
                                , btn2: function (index, layero) {
                                    //按钮【按钮二】的回调
                                    //return false 开启该代码可禁止点击该按钮关闭
                                },
                                end: function () {
 
                                }
                            });
                        }
                        //仓库代码
                        if (obj.event === 'HWHCode')  //仓库代码
                        {
                            //页面层-自定义
                            layer.open({
                                type: 2,
                                skin: 'layui-layer-rim', //加上边框
                                title: '仓库列表',
                                closeBtn: 1,
                                shift: 2,
                                area: ['80%', '80%'],
                                maxmin: true,
                                content: ['../../PublicPage/WareHouseInformation.html', 'yes'],
                                btn: ['确定', '取消']
                                , btn1: function (index, layero) {
 
                                    //按钮【按钮一】的回调
                                    var iframeWindow = window['layui-layer-iframe' + index]  //获取弹框页面
                                    var checkStatus = iframeWindow.layui.table.checkStatus('mainTable');//获取table的elem:"#test"
                                    if (checkStatus.data.length === 0) {
                                        return layer.msg('请选择数据');
                                    }
 
                                    //同步更新表格和缓存对应的值
                                    obj.update({
                                        HWHID: checkStatus.data[0].HItemID,
                                        HWHCode: checkStatus.data[0].HNumber,
                                        HWHName: checkStatus.data[0].HName,
                                        HSPID: "",
                                        HSPCode: "",
                                        HSPName: "",
 
                                    });
                                    ////表头仓库为空时 绑定明细行仓库信息
                                    //if ($("#HWHID").val() == '' || $("#HWHID").val() == null) {
                                    //    $("#HWHName").val(checkStatus.data[0].HName);
                                    //    $("#HWHID").val(checkStatus.data[0].HItemID);
                                    //}
                                    layer.close(layer.index); //它获取的始终是最新弹出的某个层,值是由layer内部动态递增计算的
                                }
                                , btn2: function (index, layero) {
                                    //按钮【按钮二】的回调
                                    //return false 开启该代码可禁止点击该按钮关闭
                                },
                                end: function () {
 
                                }
                            });
                        }
                        //仓位代码
                        if (obj.event === 'HSPCode')  //仓位代码
                        {
                            //页面层-自定义
                            layer.open({
                                type: 2,
                                skin: 'layui-layer-rim', //加上边框
                                title: '仓位列表',
                                closeBtn: 1,
                                shift: 2,
                                area: ['80%', '80%'],
                                maxmin: true,
                                content: ['../../PublicPage/WareLocationInformation.html', 'yes'],
                                btn: ['确定', '取消']
                                , btn1: function (index, layero) {
 
                                    //按钮【按钮一】的回调
                                    var iframeWindow = window['layui-layer-iframe' + index]  //获取弹框页面
                                    var checkStatus = iframeWindow.layui.table.checkStatus('mainTable');//获取table的elem:"#test"
                                    if (checkStatus.data.length === 0) {
                                        return layer.msg('请选择数据');
                                    }
 
                                    //同步更新表格和缓存对应的值
                                    obj.update({
                                        HSPID: checkStatus.data[0].HItemID,
                                        HSPCode: checkStatus.data[0].HNumber,
                                        HSPName: checkStatus.data[0].HName,
                                    });
 
                                    layer.close(layer.index); //它获取的始终是最新弹出的某个层,值是由layer内部动态递增计算的
                                }
                                , btn2: function (index, layero) {
                                    //按钮【按钮二】的回调
                                    //return false 开启该代码可禁止点击该按钮关闭
                                },
                                end: function () {
 
                                }
                            });
                        }
                        obj.event = "";
                        return false;
                    }
                })
            }
            //#endregion
 
            //?
            function f_alert(sMsg) {
                layer.alert(sMsg, { icon: 5 });
 
            }
 
            //#region 非空验证
            function AllowLoadData(sSubStr) {
                var Result = true;
 
                //#region 主表校验
                var ref = /^\d+(\.\d+)?$/;
                var temp = "";
 
                //if ($("#HWHID").val() == '' || $("#HWHID").val() == null) {
                //    layer.msg("仓库不能为空!", { icon: 5, btn: ['确认'], time: 2000, offset: 't', skin: 'layui-layer-lan', title: "温馨提示" });
                //    return Result = false;
                //}
                //if ($("#HSecManagerID").val() == '' || $("#HSecManagerID").val() == null) {
                //    layer.msg("领料员不能为空!", { icon: 5, btn: ['确认'], time: 2000, offset: 't', skin: 'layui-layer-lan', title: "温馨提示" });
                //    return Result = false;
                //}
                //if ($("#HKeeperID").val() == '' || $("#HKeeperID").val() == null) {
                //    layer.msg("保管员不能为空!", { icon: 5, btn: ['确认'], time: 2000, offset: 't', skin: 'layui-layer-lan', title: "温馨提示" });
                //    return Result = false;
                //}
                //if ($("#HManagerID").val() == '' || $("#HManagerID").val() == null) {
                //    layer.msg("主管不能为空!", { icon: 5, btn: ['确认'], time: 2000, offset: 't', skin: 'layui-layer-lan', title: "温馨提示" });
                //    return Result = false;
                //}
 
                if ($("#HBillNo").val() == '' || $("#HBillNo").val() == null) {
                    layer.msg("单据号不能为空!", { icon: 5, btn: ['确认'], time: 2000, offset: 't', skin: 'layui-layer-lan', title: "温馨提示" });
                    return Result = false;
                }
 
                if ($("#HDate").val() == '' || $("#HDate").val() == null) {
                    layer.msg("日期不能为空!", { icon: 5, btn: ['确认'], time: 2000, offset: 't', skin: 'layui-layer-lan', title: "温馨提示" });
                    return Result = false;
                }
 
                if ($("#HDeptID").val() == '0' || $("#HDeptID").val() == null) {
                    layer.msg("车间不能为空!", { icon: 5, btn: ['确认'], time: 2000, offset: 't', skin: 'layui-layer-lan', title: "温馨提示" });
                    return Result = false;
                }
 
                if ($("#HProcExchBillNo").val() == '' || $("#HProcExchBillNo").val() == null) {
                    layer.msg("工艺单号不能为空!", { icon: 5, btn: ['确认'], time: 2000, offset: 't', skin: 'layui-layer-lan', title: "温馨提示" });
                    return Result = false;
                }
 
                if ($("#HICMOBillNo").val() == '' || $("#HICMOBillNo").val() == null) {
                    layer.msg("生产订单号不能为空!", { icon: 5, btn: ['确认'], time: 2000, offset: 't', skin: 'layui-layer-lan', title: "温馨提示" });
                    return Result = false;
                }
 
                if ($("#HMaterID").val() == '0' || $("#HMaterID").val() == null) {
                    layer.msg("颜色不能为空!", { icon: 5, btn: ['确认'], time: 2000, offset: 't', skin: 'layui-layer-lan', title: "温馨提示" });
                    return Result = false;
                }
 
                if ($("#HCusID").val() == '0' || $("#HCusID").val() == null) {
                    layer.msg("客户不能为空!", { icon: 5, btn: ['确认'], time: 2000, offset: 't', skin: 'layui-layer-lan', title: "温馨提示" });
                    return Result = false;
                }
 
                if ($("#HMaterEmpID").val() == '0' || $("#HMaterEmpID").val() == null) {
                    layer.msg("打浆人不能为空!", { icon: 5, btn: ['确认'], time: 2000, offset: 't', skin: 'layui-layer-lan', title: "温馨提示" });
                    return Result = false;
                }
 
                temp = $("#HWeight").val() + "";
                if (temp == "") {
                    layer.msg("布重不能为空!", { icon: 5, btn: ['确认'], time: 2000, offset: 't', skin: 'layui-layer-lan', title: "温馨提示" });
                    return Result = false;
                } else if (!ref.test(temp)) {
                    layer.msg("布重:请输入非负数!", { icon: 5, btn: ['确认'], time: 2000, offset: 't', skin: 'layui-layer-lan', title: "温馨提示" });
                    return Result = false;
                }
 
                //var HProcExchBillNo = $("#HProcExchBillNo").val();
                //var resultData = getHWeightByHProcExchBillNo(HProcExchBillNo);
                //if (typeof (resultData.HWeight) == "undefined") {
                //    return Result = false;
                //} else {
                //    var HWeight = resultData.HWeight * 1;
                //    temp = temp * 1;
                //    if (temp > HWeight) {
                //        layer.msg("布重不能超出工艺单对应数量!", { icon: 5, btn: ['确认'], time: 2000, offset: 't', skin: 'layui-layer-lan', title: "温馨提示" });
                //        return Result = false;
                //    }
                //}
 
                //temp = $("#HLong").val() + "";
                //if (temp == "") {
                //    layer.msg("米数不能为空!", { icon: 5, btn: ['确认'], time: 2000, offset: 't', skin: 'layui-layer-lan', title: "温馨提示" });
                //    return Result = false;
                //} else if (!ref.test(temp)) {
                //    layer.msg("米数:请输入非负数!", { icon: 5, btn: ['确认'], time: 2000, offset: 't', skin: 'layui-layer-lan', title: "温馨提示" });
                //    return Result = false;
                //}
 
                //temp = $("#HSingleWeight").val() + "";
                //if (temp == "") {
                //    layer.msg("单桶重量不能为空!", { icon: 5, btn: ['确认'], time: 2000, offset: 't', skin: 'layui-layer-lan', title: "温馨提示" });
                //    return Result = false;
                //} else if (!ref.test(temp)) {
                //    layer.msg("单桶重量:请输入非负数!", { icon: 5, btn: ['确认'], time: 2000, offset: 't', skin: 'layui-layer-lan', title: "温馨提示" });
                //    return Result = false;
                //}
 
                //temp = $("#HMaterSumWeight").val() + "";
                //if (temp == "") {
                //    layer.msg("总浆重量不能为空!", { icon: 5, btn: ['确认'], time: 2000, offset: 't', skin: 'layui-layer-lan', title: "温馨提示" });
                //    return Result = false;
                //} else if (!ref.test(temp)) {
                //    layer.msg("总浆重量:请输入非负数!", { icon: 5, btn: ['确认'], time: 2000, offset: 't', skin: 'layui-layer-lan', title: "温馨提示" });
                //    return Result = false;
                //}
 
                temp = $("#HMachineSpeed").val() + "";
                if (temp == "") {
                    layer.msg("机速不能为空!", { icon: 5, btn: ['确认'], time: 2000, offset: 't', skin: 'layui-layer-lan', title: "温馨提示" });
                    return Result = false;
                } else if (!ref.test(temp)) {
                    layer.msg("机速:请输入非负数!", { icon: 5, btn: ['确认'], time: 2000, offset: 't', skin: 'layui-layer-lan', title: "温馨提示" });
                    return Result = false;
                }
 
                temp = $("#HWaterRush").val() + "";
                if (temp == "") {
                    layer.msg("水冲不能为空!", { icon: 5, btn: ['确认'], time: 2000, offset: 't', skin: 'layui-layer-lan', title: "温馨提示" });
                    return Result = false;
                } else if (!ref.test(temp)) {
                    layer.msg("水冲:请输入非负数!", { icon: 5, btn: ['确认'], time: 2000, offset: 't', skin: 'layui-layer-lan', title: "温馨提示" });
                    return Result = false;
                }
 
                temp = $("#HWaterQty").val() + "";
                if (temp == "") {
                    layer.msg("水量不能为空!", { icon: 5, btn: ['确认'], time: 2000, offset: 't', skin: 'layui-layer-lan', title: "温馨提示" });
                    return Result = false;
                } else if (!ref.test(temp)) {
                    layer.msg("水量:请输入非负数!", { icon: 5, btn: ['确认'], time: 2000, offset: 't', skin: 'layui-layer-lan', title: "温馨提示" });
                    return Result = false;
                }
 
                temp = $("#HWaterRate").val() + "";
                if (temp == "") {
                    layer.msg("水比不能为空!", { icon: 5, btn: ['确认'], time: 2000, offset: 't', skin: 'layui-layer-lan', title: "温馨提示" });
                    return Result = false;
                } else if (!ref.test(temp)) {
                    layer.msg("水比:请输入非负数!", { icon: 5, btn: ['确认'], time: 2000, offset: 't', skin: 'layui-layer-lan', title: "温馨提示" });
                    return Result = false;
                }
 
                
                //#endregion
 
 
 
                //#region 子表校验
                if (typeof (sSubStr) == "undefined" || sSubStr == "") {
                    layer.msg("没有物料明细记录", { icon: 5, btn: ['确认'], time: 2000, offset: 't', skin: 'layui-layer-lan', title: "温馨提示" });
                    return Result = false;
                }
                if (typeof (sSubStr) != "undefined" && typeof (sSubStr) != "") {
                    sSubStr = JSON.parse(sSubStr);
                    for (var i = 0; i < sSubStr.length; i++) {
                        if (sSubStr[i].HMaterID == "0") {
                            layer.msg("明细记录第" + (i + 1) + "行,物料信息为空!", { icon: 5, btn: ['确认'], time: 2000, offset: 't', skin: 'layui-layer-lan', title: "温馨提示" });
                            return Result = false;
                        }
                        if (sSubStr[i].HUnitID == "0") {
                            layer.msg("明细记录第" + (i + 1) + "行,计量单位为空!", { icon: 5, btn: ['确认'], time: 2000, offset: 't', skin: 'layui-layer-lan', title: "温馨提示" });
                            return Result = false;
                        }
                        //if (sSubStr[i].HWHID == "") {
                        //    layer.msg("明细记录第" + (i + 1) + "行,发料仓库为空!", { icon: 5, btn: ['确认'], time: 2000, offset: 't', skin: 'layui-layer-lan', title: "温馨提示" });
                        //    return Result = false;
                        //}
                    }
                }
                else {
                    return Result = true;
                }
                //#endregion
 
 
                //#region 子表关键字段重复检验
                var num = [];
                for (var i = 0; i < option.data.length; i++) {
                    temp = option.data[i]["HMaterID"];
                    if ($.inArray(temp, num) != -1) {
                        layer.msg("第" + (i + 1) + "行:物料重复,请重新选择!");
                        return Result = false;
                    }
                    num.push(temp);
                }
                //#endregion
 
                return Result;
            }
            //#endregion
 
            //#region 根据工艺单号获取表头信息
            function getMainInfoByHProcExchBillNo() {
                var HProcExchBillNo = $("#HProcExchBillNo").val();
                var resultData = {};
                $.ajax({
                    url: GetWEBURL() + "Kf_MateOutBill/getMainDataByHProcExchBillNo",
                    type: "GET",
                    data: {
                        "HProcExchBillNo": HProcExchBillNo
                    },
                    success: function (result) {
                        if (result.code == 1) {
                            var data = result.data.h_v_Sc_ProcessExchangeBillList[0];
                            resultData = data;
                            var HWaterRate = $("#HWaterRate").val();
 
                            form.val("component-form-group", { //formTest 即 class="layui-form" 所在元素属性 lay-filter="" 对应的值
                                "HICMOInterID": data.HICMOInterID
                                , "HICMOEntryID": data.HICMOEntryID
                                , "HICMOBillNo": data.HICMOBillNo
                                , "HProcExchInterID": data.HProcExchInterID
                                , "HMaterID": data.HMaterID
                                , "HMaterName": data.HMaterName
                                /* , "HVerNo": data.花版号*/
                                , "HModel": data.HModel
                                , "HModel2": data.HModel2
                                /*, "HPieceQty": data.只数*/
                                , "HCusID": data.HCusID
                                , "HCusName": data.HCusName
                                , "HWeight": data.HWeight
                                , "HWaterQty": data.HWeight * HWaterRate
                                //, "HLong": data.米数
                                //, "HMaterEmpID": data.打浆人内码
                                //, "HMaterEmpName": data.打浆人名称
                            });
 
                        } else {
                            layer.alert(result.msg, { icon: 5, btn: ['退出'], time: 100000, offset: 't' });
                        }
                    }, error: function () {
                        layer.alert("发生错误!", { icon: 5 });
                    }
                });
                return resultData;
            }
            //#endregion
 
            //#region 根据工艺单号获取工艺单布重
            function getHWeightByHProcExchBillNo() {
                var HProcExchBillNo = $("#HProcExchBillNo").val();
                var resultData = {};
                $.ajax({
                    url: GetWEBURL() + "Kf_MateOutBill/getMainDataByHProcExchBillNo",
                    async:false,
                    type: "GET",
                    data: {
                        "HProcExchBillNo": HProcExchBillNo
                    },
                    success: function (result) {
                        if (result.code == 1) {
                            var data = result.data.h_v_Sc_ProcessExchangeBillList[0];
                            resultData = data;
                        } else {
                            layer.alert(result.msg, { icon: 5, btn: ['退出'], time: 100000, offset: 't' });
                        }
                    }, error: function () {
                        layer.alert("发生错误!", { icon: 5 });
                    }
                });
                return resultData;
            }
            //#endregion
 
            //#region 根据物料ID获取物料详细信息
            function getMaterialByMaterID(HMaterID) {
                var resultData = {};
                $.ajax({
                    url: GetWEBURL() + "Kf_MateOutBill/getMaterialByMaterID",
                    async: false,
                    type: "GET",
                    data: {
                        "HMaterID": HMaterID
                    },
                    success: function (result) {
                        if (result.code == 1) {
                            var data = result.data;
                            resultData = data[0];
                        } else {
                            layer.alert(result.msg, { icon: 5, btn: ['退出'], time: 100000, offset: 't' });
                        }
                    }, error: function () {
                        layer.alert("发生错误!", { icon: 5 });
                    }
                });
                return resultData;
            }
            //#endregion
            //#endregion
 
 
        });
    </script>
</body>
</html>