username@email.com
2025-04-27 15eb82df2d6ec539e9d4245bfe08d531e8eb6379
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
//4,房产管理
//5,机械设备管理
//6,固定资产/周转材料  
// 8,行政办公设备/车辆管理   
// 801, 行政办公设备  
//802,行政车辆   
//803, 电脑 / 打印机 / 会议系统   
//9,设备维修/改装管理   
//901,设备委外维修  
//902,设备改造  
//10桩机配件采购管理  
// 13????
//获取href里面的参数
getQueryVariable = function (parameter) {
    var query = window.location.search.substring(1);
    var vars = query.split("&");
    for (var i = 0; i < vars.length; i++) {
        var pair = vars[i].split("=");
        if (pair[0] === parameter) { return pair[1]; }
    }
    return "";
}
 
//计算总金额
var countmoney = function () {
    var count = $("#girdtable input[name='erp_procurementorder_dtl.count']").eq(dtlIndex).val();
    if (count == null || count == undefined) {
        count = 0;
    };
    var price = $("#girdtable input[name='erp_procurementorder_dtl.price']").eq(dtlIndex).val();
    if (price == null || price == undefined) {
        price = 0;
    };
    var amount = accMul(count, price).toFixed(2);
    $("#girdtable input[name='erp_procurementorder_dtl.amount']").eq(dtlIndex).val(amount.toFixed(2));
 
    var taxrate = accDiv(Number($('#girdtable .body').eq(dtlIndex).find('select[name="erp_procurementorder_dtl.taxrate"]').val()), 100);;
    var no_taxrate_amount = accSub(amount, (accMul(accDiv(amount, accAdd(1, taxrate)), taxrate)));
    $('#girdtable .body').eq(dtlIndex).find('input[name="erp_procurementorder_dtl.amount"]').val(amount.toFixed(2));
    $('#girdtable .body').eq(dtlIndex).find('input[name="erp_procurementorder_dtl.no_taxrate_amount"]').val(no_taxrate_amount.toFixed(2));
    getall();
}
 
var getall = function () {
    var allmoney = 0;
    $.each($('#girdtable .body'), function (i, r) {
        $("#girdtable input[name='erp_procurementorder_dtl.amount']").eq(i).val();
        var money = $("#girdtable input[name='erp_procurementorder_dtl.amount']").eq(i).val();
        if (money == null || money == undefined) {
            money = 0;
        }
        allmoney = accAdd(allmoney, money);
    });
    $("#erp_procurementorder_money").val(allmoney);
    $("#erp_procurementorder_moneyfont").val(Arabia_to_Chinese(allmoney));
    seltax();
}
 
var seltax = function () {
    var money = $("#erp_procurementorder_money").val();
    var taxrate = accDiv($('#erp_procurementorder_taxrate').val(), 100).toFixed(2);
    var tax = accMul(money, taxrate).toFixed(2);
    $("#erp_procurementorder_taxmoney").val(tax);
}
 
var yfchange = function () {
    var yfmoney = $("#erp_procurementorder_freight").val();
    var yftaxrate = accDiv($('#erp_procurementorder_freighttaxrate').val(), 100).toFixed(2);
    var yftax = accMul(yfmoney, yftaxrate).toFixed(2);
    $("#erp_procurementorder_freighttaxmoney").val(yftax.toFixed(2));
}
 
$(document).ready(function () {
    $("[class='form-control datetime']").each(function () {
        var dataValue = $(this).val();
        if (dataValue != '') {
            var date = new Date(parseInt(dataValue.replace("/Date(", "").replace(")/", ""), 10));
            var month = date.getMonth() + 1 < 10 ? "0" + (date.getMonth() + 1) : date.getMonth() + 1;
            var currentDate = date.getDate() < 10 ? "0" + date.getDate() : date.getDate();
            var dataStr = date.getFullYear() + "-" + month + "-" + currentDate;
            $(this).val(dataStr);
        }
    });
    var type = getQueryVariable('type');
    if (type == "12") {
        $("input[name='erp_procurementorder_dtl.materielinfo_code']").removeAttr("disabled");
        $("#erp_procurementorder_supplier_id").removeAttr("disabled");
        $("#erp_procurementorder_supplier_id").trigger("chosen:updated");
        $("#erp_procurementorder_project_id").removeAttr("disabled");
        $("#erp_procurementorder_project_id").trigger("chosen:updated");
        $("#erp_procurementorder_contractNum").parent().parent().hide();
        $("#erp_procurementorder_purchaseApplication_code").parent().parent().hide();
    }
});
//删除事件回调操作
deleteMethod = function (self) {
    countmoney();
    CheckAllMaterielinfoCode();
}
 
//添加事件回调操作
createMethod = function () {
    BindEvent();
    ISShowtaxrate();
    $("#girdtable .body").each(function (i, v) {
        if ($(v).attr("autoLoade") != "true") {
            $(v).find("input[name='erp_procurementorder_dtl.materielinfo_name'],input[name='erp_procurementorder_dtl.materielinfo_code']").removeAttr("disabled");
            debugger;
            $(v).find("[name='erp_procurementorder_dtl.taxrate']").val($("[name='erp_procurementorder_dtl.taxrate']").eq(0).val());
 
        }
    });
}
 
var dtlIndex = 0;
var materielTypes = '';
///数据加载
initData = function () {
    NumberBind();
    ISShowtaxrate();
    if (window.taskid == '') {
        debugger;
        LoadData();
        LoadPage();
        BindEvent();
        //CheckAllMaterielinfoCode();
    }
    ChangeFormTitle();
 
}
 
$(document).ready(function () {
    var type = getQueryVariable('type');
    if (type != "12") {
        $('.subtradd_js').hide();
    }
    if (window.taskid != '') {
        var dataValue = $("#erp_procurementorder_createtime").val();
        if (dataValue != '') {
        }
    } else {
        var date = new Date();
        var curDate = date.getFullYear() + "-" + (date.getMonth() + 1) + "-" + date.getDate();
        $("#erp_procurementorder_createtime").val(curDate);
    }
 
    //});
});
 
var ProcurementOrder = {};
function LoadData() {
    var relationCode = getQueryVariable('relationCode');
    var typeSource = getQueryVariable('typeSource');
    var type = getQueryVariable('type');
    $.ajax({
        url: "/ERP/Erp_procurementorder/GetPageData?flowid=" + flowid + "&taskid=" + taskid + "&relationCode=" + relationCode + "&type=" + type + "&typeSource=" + typeSource
        , async: false
        , cache: false
        , dataType: "json",
        success: function (data) {
            ProcurementOrder = data;
 
        }
    });
    $.ajax({
        url: "/ERP/Erp_procurementorder/GetMaterielTypesByType?flowType=" + type
        , async: false
        , cache: false
        , dataType: "json",
        success: function (data) {
            materielTypes = data;
        }
    });
}
 
function LoadPage() {
    $("#erp_procurementorder_orderCode").val(ProcurementOrder.orderCode);
    $("#erp_procurementorder_name").val(ProcurementOrder.name);
    $("#erp_procurementorder_contractNum").val(ProcurementOrder.contractNum);
    $("#erp_procurementorder_purchaseApplication_code").val(ProcurementOrder.purchaseApplication_code);
    $("#erp_procurementorder_supplier_id").val(ProcurementOrder.supplier_id);
    $("#erp_procurementorder_supplier_id").trigger("chosen:updated");
    $("#erp_procurementorder_project_id").val(ProcurementOrder.project_id);
    $("#erp_procurementorder_project_id").trigger("chosen:updated");
    var date = new Date(parseInt(ProcurementOrder.createtime.replace("/Date(", "").replace(")/", ""), 10));
    var month = date.getMonth() + 1 < 10 ? "0" + (date.getMonth() + 1) : date.getMonth() + 1;
    var currentDate = date.getDate() < 10 ? "0" + date.getDate() : date.getDate();
    var dataStr = date.getFullYear() + "-" + month + "-" + currentDate;
    $("#erp_procurementorder_createtime").val(dataStr);
 
    changepurchase();
    // 把type存一下
    var sprintbtn = '<input type="hidden" id="erp_procurementorder_type" name="erp_procurementorder.type"  field="type" class="form-control edit" isvalid="yes" checkexpession="NotNull"">';
    $('#erp_procurementorder_orderCode').after(sprintbtn);// 先弄个隐藏框把数据存起来
    $('#erp_procurementorder_type').val(ProcurementOrder.type);
 
    // 处理隐藏框
    var type = getQueryVariable('type');
 
    if (type == "2") {// 辅材隐藏合同单号
        $("#erp_procurementorder_contractNum").parent().parent().hide();
        $("#erp_procurementorder_supplier_id").removeAttr("disabled");
        $("#erp_procurementorder_supplier_id").trigger("chosen:updated");
 
    } else if (type == "4") {// 房产隐藏供应商,运费相关
        //$("#erp_procurementorder_supplier_id").parent().parent().hide();
        $("#erp_procurementorder_freight").parent().parent().hide();
        $("#erp_procurementorder_freighttaxrate").parent().parent().hide();
        $("#erp_procurementorder_freighttaxmoney").parent().parent().hide();
    } else if (type == "8" && type == "801" && type == "802" && type == "803") {// 行政办公车辆
 
        $("#erp_procurementorder_supplier_id").trigger("chosen:updated");
    }
 
    var typeSource = getQueryVariable('typeSource');
    if (typeSource == "purchaseApplication") {
        $("#erp_procurementorder_supplier_id").removeAttr("disabled");
        $("#erp_procurementorder_supplier_id").trigger("chosen:updated");
    }
 
    if (type == "12") {
        SetAcceptWarehouse('');
    } else {
        SetAcceptWarehouse(ProcurementOrder.project_id);
    }
}
 
function BindEvent() {
    NumberBind();
    // 物料页面
    $("input[name='erp_procurementorder_dtl.materielinfo_name'],input[name='erp_procurementorder_dtl.materielinfo_code']").unbind();
    $("input[name='erp_procurementorder_dtl.materielinfo_name'],input[name='erp_procurementorder_dtl.materielinfo_code']").bind('focus', function () {
        //dtlIndex = $(this).attr("data-id");
        dtlIndex = $(this).closest('tr').index() - 1;
        layer.open({
            type: 2,
            title: '资源库',
            shadeClose: true,
            shade: 0.4,
            area: ['90%', '90%'],
            content: "/Article/index?type=" + materielTypes
        });
    });
 
    // 采购申请
    $("#erp_procurementorder_purchaseApplication_code").change(function () {
        changepurchase();
    });
    // 供应商选择
    $("#erp_procurementorder_supplier_id").parent().click(function () {
        if ($("#erp_procurementorder_supplier_id").attr("disabled") == "disabled") {
            return false;
        }
        getcompanyinfo();
        return false;
    });
 
    //运费税
    $('[name="erp_procurementorder.freight"],[name="erp_procurementorder.freighttaxrate"]').change(function () {
        yfchange();
    });
 
    //税
    $('[name="erp_procurementorder.taxrate"]').change(function () {
        seltax();
    });
 
    //选择计算金额
    $('input[name="erp_procurementorder_dtl.price"],input[name="erp_procurementorder_dtl.count"],select[name="erp_procurementorder_dtl.taxrate"]').change(function () {
        dtlIndex = $(this).closest('tr').index() - 1;
        countmoney();
    });
}
 
var isshow = 0;
function ISShowtaxrate() {
    debugger;
    var typeSource = getQueryVariable('typeSource');
    var type = getQueryVariable('type');
    if (typeSource == "purchaseApplication") {
        if (type == "4" || type == "5" || type == "6" || type == "8" || type == "801" || type == "802" || type == "803" || type == "9" || type == "901" || type == "902" || type == "10") {
            isshow = 1;
        }
    }
 
    if (typeSource == "contractpretrial") {
        if (type == "1" || type == "10") {
            isshow = 1;
        }
    }
 
 
    var tdIndex2 = $('#girdtable .body').eq(0).find('[name="erp_procurementorder_dtl.taxrate"]').parent('td').index();
    var tdIndex3 = $('#girdtable .body').eq(0).find('[name="erp_procurementorder_dtl.no_taxrate_amount"]').parent('td').index();
    $('#girdtable tr').each(function () {
        if (tdIndex2 > -1) {
            if (isshow == 1) {
                $(this).children("td").eq(tdIndex2).show();
            } else {
                $(this).children("td").eq(tdIndex2).hide();
            }
        }
        if (tdIndex3 > -1) {
            if (isshow == 1) {
                $(this).children("td").eq(tdIndex3).show();
            } else {
                $(this).children("td").eq(tdIndex3).hide();
            }
        }
    });
}
 
function changepurchase() {
    var typeSource = getQueryVariable('typeSource');
    if (typeSource == "purchaseApplication") {
        var purchaseid = $("#erp_procurementorder_purchaseApplication_code").val();
        $.ajax({
            url: '/Erp_procurementorder/GetPurchaseapplication_dtl?purchaseid=' + purchaseid,
            type: 'Get',
            datatype: 'json',
            success: function (resp) {
                debugger;
                if (resp.length > 0) {
                    $('#girdtable .body').remove();
                    for (var j = 0; j < resp.length; j++) {
                        //var html = '<tr class="body"><td><input id="erp_procurementorder_dtl_materielinfo_code" name="erp_procurementorder_dtl.materielinfo_code" disabled="disabled" type="text" class="form-control edit" field="materielinfo_code" isvalid="yes" checkexpession="NotNull"></td><td><input id="erp_procurementorder_dtl_materielinfo_name" name="erp_procurementorder_dtl.materielinfo_name" disabled="disabled" type="text" class="form-control edit" field="materielinfo_name" isvalid="yes" checkexpession="NotNull"></td><td><input id="erp_procurementorder_dtl_Specification" name="erp_procurementorder_dtl.Specification" type="text" class="form-control edit" field="Specification" disabled="disabled" isvalid="yes" ></td><td><input id="erp_procurementorder_dtl_price" name="erp_procurementorder_dtl.price" type="text" class="form-control edit" field="price" isvalid="yes" checkexpession="Num"></td><td><input id="erp_procurementorder_dtl_count" name="erp_procurementorder_dtl.count" type="text" class="form-control edit" field="count" isvalid="yes" checkexpession="Num"></td><td><input id="erp_procurementorder_dtl_measurementUnit" name="erp_procurementorder_dtl.measurementUnit" type="text" class="form-control edit" field="measurementUnit" disabled="disabled" isvalid="yes" checkexpession="Num"></td><td><input id="erp_procurementorder_dtl_amount" name="erp_procurementorder_dtl.amount" disabled="disabled" type="text" class="form-control edit" field="amount" isvalid="yes" checkexpession="Num"></td><td><select id="erp_procurementorder_dtl_taxrate" name="erp_procurementorder_dtl.taxrate" field="taxrate" class="form-control edit chosen-select" isvalid="yes" checkexpession="NotNull" style="display: none;"><option value="0">0%</option><option value="1">1%</option><option value="3">3%</option><option value="5">5%</option><option value="6">6%</option><option value="9">9%</option><option value="10">10%</option><option value="13">13%</option><option value="16">16%</option></select></td><td><input id="erp_procurementorder_dtl_no_taxrate_amount" name="erp_procurementorder_dtl.no_taxrate_amount" type="text" class="form-control edit" field="no_taxrate_amount" isvalid="yes" checkexpession="Num"></td><td><input type="hidden" id="id" name="id" class="edit"><a title="删除" class="subtrdel_js" style="color:red;"><i class="glyphicon glyphicon-minus"></i></a></td></tr>';
                        var html = '<tr class="body"><td><input id="erp_procurementorder_dtl_materielinfo_code" name="erp_procurementorder_dtl.materielinfo_code" disabled="disabled" type="text" class="form-control edit" field="materielinfo_code" isvalid="yes" checkexpession="NotNull"></td><td><input id="erp_procurementorder_dtl_materielinfo_name" name="erp_procurementorder_dtl.materielinfo_name" disabled="disabled" type="text" class="form-control edit" field="materielinfo_name" isvalid="yes" checkexpession="NotNull"></td><td><input id="erp_procurementorder_dtl_Specification" name="erp_procurementorder_dtl.Specification" type="text" class="form-control edit" field="Specification" disabled="disabled" isvalid="yes" ></td><td><input id="erp_procurementorder_dtl_price" name="erp_procurementorder_dtl.price" type="text" class="form-control edit" field="price" isvalid="yes" checkexpession="Num"></td><td><input id="erp_procurementorder_dtl_count" name="erp_procurementorder_dtl.count" type="text" class="form-control edit" field="count" isvalid="yes" checkexpession="Num"></td><td><input id="erp_procurementorder_dtl_measurementUnit" name="erp_procurementorder_dtl.measurementUnit" type="text" class="form-control edit" field="measurementUnit" disabled="disabled" isvalid="yes" checkexpession="Num"></td><td><input id="erp_procurementorder_dtl_amount" name="erp_procurementorder_dtl.amount" disabled="disabled" type="text" class="form-control edit" field="amount" isvalid="yes" checkexpession="Num"></td><td><input type="hidden" id="id" name="id" class="edit"><a title="删除" class="subtrdel_js" style="color:red;"><i class="glyphicon glyphicon-minus"></i></a></td></tr>';
                        var setHtml = '<td><select id="erp_procurementorder_dtl_taxrate" name="erp_procurementorder_dtl.taxrate" field="taxrate" class="form-control edit chosen-select" isvalid="yes" checkexpession="NotNull" "><option value="0">0%</option><option value="1">1%</option><option value="3">3%</option><option value="5">5%</option><option value="6">6%</option><option value="9">9%</option><option value="10">10%</option><option value="13">13%</option><option value="16">16%</option></select></td><td><input id="erp_procurementorder_dtl_no_taxrate_amount" name="erp_procurementorder_dtl.no_taxrate_amount" type="text" class="form-control edit" field="no_taxrate_amount" disabled="disabled" isvalid="yes" checkexpession="Num"></td>';
                        $('#girdtable tbody').append(html);
                        debugger;
                        if (isshow == 1) {
                            $("#girdtable [name='erp_procurementorder_dtl.amount']").eq(j).parent('td').after(setHtml);
                        }
                        $("[name='erp_procurementorder_dtl.taxrate']").trigger("chosen:updated");
                        $("#girdtable [name='erp_procurementorder_dtl.materielinfo_name']").eq(j).val(resp[j].itemsname);
                        $("#girdtable [name='erp_procurementorder_dtl.materielinfo_code']").eq(j).val(resp[j].materielinfo_code);
                        $("#girdtable [name='erp_procurementorder_dtl.price']").eq(j).val(resp[j].Price);
                        $("#girdtable [name='erp_procurementorder_dtl.measurementUnit']").eq(j).val(resp[j].itemmeasuringunit);
                        $("#girdtable [name='erp_procurementorder_dtl.Specification']").eq(j).val(resp[j].Specification);
                        $("#girdtable .body").eq(j).attr("autoLoade", 'true');
                        BindEvent();
                    }
                    CheckAllMaterielinfoCode();
                };
            },
            error: function () {
 
            },
        });
    } else if (typeSource == "contractpretrial") {
        var contractpretrialCode = $("#erp_procurementorder_contractNum").val();
        $.ajax({
            url: '/Erp_procurementorder/GetContractpretrialDtlByContractpretrialCode?contractpretrialCode=' + contractpretrialCode,
            type: 'Get',
            datatype: 'json',
            success: function (resp) {
                if (resp.length > 0) {
                    $('#girdtable .body').remove();
                    for (var j = 0; j < resp.length; j++) {
                        var html = '<tr class="body"><td><input id="erp_procurementorder_dtl_materielinfo_code" name="erp_procurementorder_dtl.materielinfo_code" disabled="disabled" type="text" class="form-control edit" field="materielinfo_code" isvalid="yes" checkexpession="NotNull"></td><td><input id="erp_procurementorder_dtl_materielinfo_name" name="erp_procurementorder_dtl.materielinfo_name" disabled="disabled" type="text" class="form-control edit" field="materielinfo_name" isvalid="yes" checkexpession="NotNull"></td><td><input id="erp_procurementorder_dtl_Specification" name="erp_procurementorder_dtl.Specification" type="text" class="form-control edit" field="Specification" disabled="disabled" isvalid="yes" ></td><td><input id="erp_procurementorder_dtl_price" name="erp_procurementorder_dtl.price" type="text" class="form-control edit" field="price" isvalid="yes" checkexpession="Num"></td><td><input id="erp_procurementorder_dtl_count" name="erp_procurementorder_dtl.count" type="text" class="form-control edit" field="count" isvalid="yes" checkexpession="Num"></td><td><input id="erp_procurementorder_dtl_measurementUnit" name="erp_procurementorder_dtl.measurementUnit" type="text" class="form-control edit" field="measurementUnit" disabled="disabled" isvalid="yes" checkexpession="Num"></td><td><input id="erp_procurementorder_dtl_amount" name="erp_procurementorder_dtl.amount" disabled="disabled" type="text" class="form-control edit" field="amount" isvalid="yes" checkexpession="Num"></td><td><input type="hidden" id="id" name="id" class="edit"><a title="删除" class="subtrdel_js" style="color:red;" ><i class="glyphicon glyphicon-minus"></i></a></td></tr>';
                        var setHtml = '<td><select id="erp_procurementorder_dtl_taxrate" name="erp_procurementorder_dtl.taxrate" field="taxrate" class="form-control edit chosen-select" isvalid="yes" checkexpession="NotNull" "><option value="0">0%</option><option value="1">1%</option><option value="3">3%</option><option value="5">5%</option><option value="6">6%</option><option value="9">9%</option><option value="10">10%</option><option value="13">13%</option><option value="16">16%</option></select></td><td><input id="erp_procurementorder_dtl_no_taxrate_amount" name="erp_procurementorder_dtl.no_taxrate_amount" type="text" class="form-control edit" field="no_taxrate_amount" disabled="disabled" isvalid="yes" checkexpession="Num"></td>';
                        $('#girdtable tbody').append(html);
                        debugger;
                        if (isshow == 1) {
                            $("#girdtable [name='erp_procurementorder_dtl.amount']").eq(j).parent('td').after(setHtml);
                        }
                        //$('#girdtable tbody').append(html);
                        $("[name='erp_procurementorder_dtl.taxrate']").trigger("chosen:updated");
                        $("#girdtable [name='erp_procurementorder_dtl.materielinfo_name']").eq(j).val(resp[j].MaterialName);
                        $("#girdtable [name='erp_procurementorder_dtl.materielinfo_code']").eq(j).val(resp[j].MaterialCode);
                        $("#girdtable [name='erp_procurementorder_dtl.price']").eq(j).val(resp[j].UnitPrice);
                        $("#girdtable [name='erp_procurementorder_dtl.measurementUnit']").eq(j).val(resp[j].Unit);
                        $("#girdtable [name='erp_procurementorder_dtl.Specification']").eq(j).val(resp[j].Model);
                        $("#girdtable [name='erp_procurementorder_dtl.taxrate']").eq(j).val(resp[j].TaxRate);
                        $("#girdtable [name='erp_procurementorder_dtl.taxrate']").eq(j).attr("disabled", "disabled");
                        $("#girdtable .body").eq(j).attr("autoLoade", 'true');
                        BindEvent();
                    }
                    CheckAllMaterielinfoCode();
                };
            },
            error: function () {
 
            },
        });
    }
 
}
 
//供应商选择
var getcompanyinfo = function () {
    layer.open({
        type: 2,
        title: '供应商',
        shadeClose: true,
        shade: 0.4,
        area: ['90%', '90%'],
        content: "/oa/General/company"
    });
}
 
var setBaseInfo = function (materialNumber, materialName, resourceClassificationId, resourceClassificationName, specificationModel, measurementUnit, index, measurementUnitName, resourceClassificationSupName) {
    $("[name='erp_procurementorder_dtl.materielinfo_name']").eq(dtlIndex).val(materialName);
    $("[name='erp_procurementorder_dtl.materielinfo_code']").eq(dtlIndex).val(materialNumber);
    $("[name='erp_procurementorder_dtl.measurementUnit']").eq(dtlIndex).val(measurementUnitName);
    $("[name='erp_procurementorder_dtl.Specification']").eq(dtlIndex).val(specificationModel);
    layer.closeAll();
}
 
var setCompanyInfo = function (id, name, UserName, Phone, BankName, BankDeposit, BankAccount) {
    $("#erp_procurementorder_supplier_id").val(id);
    $("#erp_procurementorder_supplier_id").trigger("chosen:updated");
    layer.closeAll();
}
 
// 改变页面表单标题
function ChangeFormTitle() {
    var titleStr = $("#erp_procurementorder_name").val().replace(/\(\S*\)/, "");
    $("#txtTitle").text(titleStr);
    $('#girdtable').prev("h3").text(titleStr + "明细");
}
 
function CheckAllMaterielinfoCode() {
    var isAllHNT = true;
    $("input[name='erp_procurementorder_dtl.materielinfo_code']").each(function (i, v) {
        if (IsHNT($(v).val()) == false) {
            isAllHNT = false;
            return false;
        }
    });
 
    if (isAllHNT) {
        $('.subtradd_js').show();
        materielTypes = '010002';
    }
 
    var isAllGJ = true;
    $("input[name='erp_procurementorder_dtl.materielinfo_code']").each(function (i, v) {
        if (IsGJ($(v).val()) == false) {
            isAllGJ = false;
            return false;
        }
    });
 
    if (isAllGJ) {
        $('.subtradd_js').show();
        materielTypes = '010005';
    }
}
 
function IsGJ(materielinfoCode) {
    var result = false;
    $.ajax({
        url: "/ERP/Erp_procurementorder/IsGJ?materielinfo_code=" + materielinfoCode
        , async: false
        , cache: false
        , dataType: "json",
        success: function (data) {
            if (data.Result) {
                result = data.Remark == "True";
            } else {
                layer.alert("判断物料类型是否是钢筋失败");
            }
        }
    });
 
    return result;
}
 
function IsHNT(materielinfoCode) {
    var result = false;
    $.ajax({
        url: "/ERP/Erp_procurementorder/IsHNT?materielinfo_code=" + materielinfoCode
        , async: false
        , cache: false
        , dataType: "json",
        success: function (data) {
            if (data.Result) {
                result = data.Remark == "True";
            } else {
                layer.alert("判断物料类型是否是混凝土失败");
            }
        }
    });
 
    return result;
}
 
function SetAcceptWarehouse(projectId) {
    $("#erp_procurementorder_accept_warehouse_id").empty();
    $("#erp_procurementorder_accept_warehouse_id").trigger("chosen:updated");
    $.ajax({
        url: '/DropDown/WareHouseDropDown?projectId=' + projectId,
        type: 'Get',
        datatype: 'json',
        success: function (dataList) {
            if (dataList != null && dataList.length > 0) {
                $("#erp_procurementorder_accept_warehouse_id").append('<option value="">请选择</option>');
                for (var i = 0; i < dataList.length; i++) {
                    var dataItem = dataList[i];
                    $("#erp_procurementorder_accept_warehouse_id").append("<option value='" + dataItem.Value + "'>" + dataItem.Text + "</option>");
                    $("#erp_procurementorder_accept_warehouse_id").trigger("chosen:updated");
                }
            } else {
                layer.msg("该项目下没有仓库同信息", { icon: 5 });
            }
        }
    });
}
 
/** 
 * 乘法 
 * @param arg1 
 * @param arg2 
 * @returns {Number} 
 */
function accMul(arg1, arg2) {
    var num1 = Number(arg1.toString());
    var num2 = Number(arg2.toString());
    return Number((num1 * num2).toFixed(2));
    //var m = 0, s1 = arg1.toString(), s2 = arg2.toString();
    //try { m += s1.split(".")[1].length } catch (e) { }
    //try { m += s2.split(".")[1].length } catch (e) { }
    //return Number(s1.replace(".", "")) * Number(s2.replace(".", "")) / Math.pow(10, m)
}
/** 
 * 除法 
 * @param arg1 
 * @param arg2 
 * @returns {Number} 
 */
function accDiv(arg1, arg2) {
    var t1 = 0, t2 = 0, r1, r2;
    try { t1 = arg1.toString().split(".")[1].length } catch (e) { }
    try { t2 = arg2.toString().split(".")[1].length } catch (e) { }
    with (Math) {
        r1 = Number(arg1.toString().replace(".", ""))
        r2 = Number(arg2.toString().replace(".", ""))
        return (r1 / r2) * pow(10, t2 - t1);
    }
}
/** 
 * 加法 
 * @param arg1 
 * @param arg2 
 * @returns {Number} 
 */
function accAdd(arg1, arg2) {
    var r1, r2, m, c;
    try { r1 = arg1.toString().split(".")[1].length } catch (e) { r1 = 0 }
    try { r2 = arg2.toString().split(".")[1].length } catch (e) { r2 = 0 }
    c = Math.abs(r1 - r2);
    m = Math.pow(10, Math.max(r1, r2))
    if (c > 0) {
        var cm = Math.pow(10, c);
        if (r1 > r2) {
            arg1 = Number(arg1.toString().replace(".", ""));
            arg2 = Number(arg2.toString().replace(".", "")) * cm;
        }
        else {
            arg1 = Number(arg1.toString().replace(".", "")) * cm;
            arg2 = Number(arg2.toString().replace(".", ""));
        }
    }
    else {
        arg1 = Number(arg1.toString().replace(".", ""));
        arg2 = Number(arg2.toString().replace(".", ""));
    }
    return (arg1 + arg2) / m
}
/** 
 * 减法 
 * @param arg1 
 * @param arg2 
 * @returns 
 */
function accSub(arg1, arg2) {
    var r1, r2, m, n;
    try { r1 = arg1.toString().split(".")[1].length } catch (e) { r1 = 0 }
    try { r2 = arg2.toString().split(".")[1].length } catch (e) { r2 = 0 }
    m = Math.pow(10, Math.max(r1, r2));
    //last modify by deeka  
    //动态控制精度长度  
    n = (r1 >= r2) ? r1 : r2;
    return ((arg1 * m - arg2 * m) / m).toFixed(n);
}
/** 
 * 数字转换为大写 
 * @param NumStr
 * @returns 
 */
function Arabia_to_Chinese(NumStr) {
    var Num = NumStr + "";
    for (i = Num.length - 1; i >= 0; i--) {
        Num = Num.replace(",", "")//替换tomoney()中的“,”
        Num = Num.replace(" ", "")//替换tomoney()中的空格
    }
    Num = Num.replace("¥", "")//替换掉可能出现的¥字符
    if (isNaN(Num)) { //验证输入的字符是否为数字
        alert("请检查小写金额是否正确");
        return;
    }
    //字符处理完毕后开始转换,采用前后两部分分别转换
    part = String(Num).split(".");
    newchar = "";
    //小数点前进行转化
    for (i = part[0].length - 1; i >= 0; i--) {
        if (part[0].length > 10) {
            alert("位数过大,无法计算");
            return "";
        }//若数量超过拾亿单位,提示
        tmpnewchar = ""
        perchar = part[0].charAt(i);
        switch (perchar) {
            case "0": tmpnewchar = "零" + tmpnewchar; break;
            case "1": tmpnewchar = "壹" + tmpnewchar; break;
            case "2": tmpnewchar = "贰" + tmpnewchar; break;
            case "3": tmpnewchar = "叁" + tmpnewchar; break;
            case "4": tmpnewchar = "肆" + tmpnewchar; break;
            case "5": tmpnewchar = "伍" + tmpnewchar; break;
            case "6": tmpnewchar = "陆" + tmpnewchar; break;
            case "7": tmpnewchar = "柒" + tmpnewchar; break;
            case "8": tmpnewchar = "捌" + tmpnewchar; break;
            case "9": tmpnewchar = "玖" + tmpnewchar; break;
        }
        switch (part[0].length - i - 1) {
            case 0: tmpnewchar = tmpnewchar + "元"; break;
            case 1: if (perchar != 0) tmpnewchar = tmpnewchar + "拾"; break;
            case 2: if (perchar != 0) tmpnewchar = tmpnewchar + "佰"; break;
            case 3: if (perchar != 0) tmpnewchar = tmpnewchar + "仟"; break;
            case 4: tmpnewchar = tmpnewchar + "万"; break;
            case 5: if (perchar != 0) tmpnewchar = tmpnewchar + "拾"; break;
            case 6: if (perchar != 0) tmpnewchar = tmpnewchar + "佰"; break;
            case 7: if (perchar != 0) tmpnewchar = tmpnewchar + "仟"; break;
            case 8: tmpnewchar = tmpnewchar + "亿"; break;
            case 9: tmpnewchar = tmpnewchar + "拾"; break;
        }
        newchar = tmpnewchar + newchar;
    }
    //小数点之后进行转化
    if (Num.indexOf(".") != -1) {
        if (part[1].length > 2) {
            alert("小数点之后只能保留两位,系统将自动截断");
            part[1] = part[1].substr(0, 2)
        }
        for (i = 0; i < part[1].length; i++) {
            tmpnewchar = ""
            perchar = part[1].charAt(i)
            switch (perchar) {
                case "0": tmpnewchar = "零" + tmpnewchar; break;
                case "1": tmpnewchar = "壹" + tmpnewchar; break;
                case "2": tmpnewchar = "贰" + tmpnewchar; break;
                case "3": tmpnewchar = "叁" + tmpnewchar; break;
                case "4": tmpnewchar = "肆" + tmpnewchar; break;
                case "5": tmpnewchar = "伍" + tmpnewchar; break;
                case "6": tmpnewchar = "陆" + tmpnewchar; break;
                case "7": tmpnewchar = "柒" + tmpnewchar; break;
                case "8": tmpnewchar = "捌" + tmpnewchar; break;
                case "9": tmpnewchar = "玖" + tmpnewchar; break;
            }
            if (i == 0) tmpnewchar = tmpnewchar + "角";
            if (i == 1) tmpnewchar = tmpnewchar + "分";
            newchar = newchar + tmpnewchar;
        }
    }
    //替换所有无用汉字
    while (newchar.search("零零") != -1)
        newchar = newchar.replace("零零", "零");
    newchar = newchar.replace("零亿", "亿");
    newchar = newchar.replace("亿万", "亿");
    newchar = newchar.replace("零万", "万");
    newchar = newchar.replace("零元", "元");
    newchar = newchar.replace("零角", "");
    newchar = newchar.replace("零分", "");
    if (newchar.charAt(newchar.length - 1) == "元" || newchar.charAt(newchar.length - 1) == "角")
        newchar = newchar + "整"
    return newchar;
}
/** 
 * 增加千分符以及保留几位小数(四舍五入) 
 * @param NumStr
 * @returns 
 */
function Mmoney(s, n) {
    console.log(s);
    console.log(n);
    return s.toFixed(n);
    //var t = '';
    //var regPos = /^\d+(\.\d+)?$/; //非负浮点数
    //var regNeg = /^(-(([0-9]+\.[0-9]*[1-9][0-9]*)|([0-9]*[1-9][0-9]*\.[0-9]+)|([0-9]*[1-9][0-9]*)))$/; //负浮点数
    //if (s == 0 || regPos.test(s) || regNeg.test(s)) {
    //    n = n > 0 && n <= 20 ? n : 2;
    //    s = parseFloat((s + '').replace(/[^\d\.-]/g, '')).toFixed(n) + '';
    //    var l = '';
    //    if (parseFloat(s.split('.')[0]) >= 0) {
    //        l = s.split('.')[0].split('').reverse();
    //    } else {
    //        l = s.split('.')[0].split('-')[1].split('').reverse();
    //    }
    //    r = s.split('.')[1];
 
    //    for (var i = 0; i < l.length; i++) {
    //        t += l[i] + ((i + 1) % 3 == 0 && (i + 1) != l.length ? ',' : '');
    //    };
    //    t = t.split('').reverse().join('') + '.' + r;
    //    if (parseFloat(s.split('.')[0]) < 0) {
    //        t = "-" + t;
    //    };
    //}
    //return t;
}
 
NumberBind = function () {
    $("[name='erp_procurementorder_dtl.count']").addClass("countTxtBox");
    $("[name='erp_procurementorder_dtl.price']").addClass("priceTxtBox");
    $("[name='erp_procurementorder_dtl.amount']").addClass("amountTxtBox");
    NumberBoxBind();
}