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
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
var $type = 0;
var $nmoney = 0;//申请剩余报销额度
var $applycode = '';//申请单号
//获取href里面的参数
function getUrlParam(name) {
    var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)"); //构造一个含有目标参数的正则表达式对象
    var r = window.location.search.substr(1).match(reg); //匹配目标参数
    if (r != null) return unescape(r[2]); return null; //返回参数值
}
 
var listtypeoptions = [];
///绑定费用类型
var gettype = function (type) {
    switch (type) {
        case 1:
            $('#txtTitle').html('项目差旅费报销单');
            listtypeoptions.push('<option value="交通费">交通费</option>');
            listtypeoptions.push('<option value="住宿费">住宿费</option>');
            listtypeoptions.push('<option value="补贴费用">补贴费用</option>');
            break;
        case 2:
            $('#txtTitle').html('项目其他措施费报销单');
            listtypeoptions.push('<option value="项目其他措施费">项目其他措施费</option>');
            break;
        case 3:
            $('#txtTitle').html('项目汽车报销单');
            listtypeoptions.push('<option value="项目汽车费">项目汽车费</option>');
            break;
        case 4:
            $('#txtTitle').html('项目劳保费报销单');
            listtypeoptions.push('<option value="项目劳保费">项目劳保费</option>');
            break;
        case 5:
            $('#txtTitle').html('差旅费报销单');
            listtypeoptions.push('<option value="交通费">交通费</option>');
            listtypeoptions.push('<option value="住宿费">住宿费</option>');
            listtypeoptions.push('<option value="补贴费用">补贴费用</option>');
            break;
        case 6:
            $('#txtTitle').html('外部培训学习费报销单');
            listtypeoptions.push('<option value="外部培训学习费">外部培训学习费</option>');
            break;
        case 7:
            $('#txtTitle').html('例行培训学习费报销单');
            listtypeoptions.push('<option value="例行培训学习费">例行培训学习费</option>');
            break;
        case 8:
            $('#txtTitle').html('项目招待费报销单');
            listtypeoptions.push('<option value="项目招待费">项目招待费</option>');
            break;
        case 9:
            $('#txtTitle').html('汽车费报销单');
            listtypeoptions.push('<option value="汽车费">汽车费</option>');
            break;
        case 10:
            $('#txtTitle').html('招聘费报销单');
            listtypeoptions.push('<option value="招聘费">招聘费</option>');
            break;
        case 11:
            $('#txtTitle').html('办公费报销单');
            listtypeoptions.push('<option value="办公用品">办公用品</option>');
            //listtypeoptions.push('<option value="房租费用">房租费用</option>');
            listtypeoptions.push('<option value="水电费">水电费</option>');
            listtypeoptions.push('<option value="物业费">物业费</option>');
            listtypeoptions.push('<option value="办公设备维修">办公设备维修</option>');
            listtypeoptions.push('<option value="电话费">电话费</option>');
            listtypeoptions.push('<option value="会务费">会务费</option>');
            listtypeoptions.push('<option value="保险费">保险费</option>');
            listtypeoptions.push('<option value="劳保用品">劳保用品</option>');
            listtypeoptions.push('<option value="绿化">绿化</option>');
            listtypeoptions.push('<option value="垃圾清运">垃圾清运</option>');
            listtypeoptions.push('<option value="协会会费">协会会费</option>');
            listtypeoptions.push('<option value="其他">其他</option>');
            break;
        case 12:
            $('#txtTitle').html('办公物业水电费报销单');
            listtypeoptions.push('<option value="办公物业水电费">办公物业水电费</option>');
            break;
        case 13:
            $('#txtTitle').html('文化建设费报销单');
            listtypeoptions.push('<option value="文化建设费">文化建设费</option>');
            break;
        case 14:
            $('#txtTitle').html('会务费,保险费,劳保用品等其他可控管理费报销单');
            listtypeoptions.push('<option value="会务费">会务费</option>');
            listtypeoptions.push('<option value="保险费">保险费</option>');
            listtypeoptions.push('<option value="劳保用品">劳保用品</option>');
            listtypeoptions.push('<option value="绿化">绿化</option>');
            listtypeoptions.push('<option value="垃圾清运">垃圾清运</option>');
            listtypeoptions.push('<option value="协会会费">协会会费</option>');
            listtypeoptions.push('<option value="其他">其他</option>');
            break;
        case 15:
            $('#txtTitle').html('行政管理无票支出报销单');
            listtypeoptions.push('<option value="行政管理无票支出">行政管理无发票支出</option>');
            break;
        case 16:
            $('#txtTitle').html('研发费用报销单');
            listtypeoptions.push('<option value="研发费用">研发费用</option>');
            break;
        case 17:
            $('#txtTitle').html('招待费报销单');
            listtypeoptions.push('<option value="招待费">招待费</option>');
            break;
        case 18:
            $('#txtTitle').html('项目无票支出报销单');
            listtypeoptions.push('<option value="项目无票支出">项目无发票支出</option>');
            break;
        case 19:
            $('#txtTitle').html('项目辅材报销单');
            listtypeoptions.push('<option value="柴油">柴油</option>');
            listtypeoptions.push('<option value="小型工具">小型工具</option>');
            listtypeoptions.push('<option value="安全文明设施">安全文明设施</option>');
            listtypeoptions.push('<option value="办公用品">办公用品</option>');
            break;
        case 20:
            $('#txtTitle').html('市内交通费报销单');
            listtypeoptions.push('<option value="市内交通费报销">市内交通费报销</option>');
            break;
        case 21:
            $('#txtTitle').html('项目市内交通费报销单');
            listtypeoptions.push('<option value="项目市内交通费报销">项目市内交通费报销</option>');
            break;
        case 22:
            $('#txtTitle').html('项目其他间接费报销单');
            listtypeoptions.push('<option value="项目其他间接费报销">项目其他间接费报销</option>');
            break;
        case 23:
            $('#txtTitle').html('节假日福利费报销单');
            listtypeoptions.push('<option value="节假日福利费报销">节假日福利费报销</option>');
            break;
        case 24:
            $('#txtTitle').html('其他福利费报销单');
            listtypeoptions.push('<option value="其他福利费报销">其他福利费报销</option>');
            break;
        case 25:
            $('#txtTitle').html('管理人员工作餐报销单');
            listtypeoptions.push('<option value="管理人员工作餐报销">管理人员工作餐报销</option>');
            break;
        case 26:
            $('#txtTitle').html('项目福利费报销单');
            listtypeoptions.push('<option value="项目福利费报销">项目福利费报销</option>');
            break;
        case 27:
            $('#txtTitle').html('零星材料报销单');
            listtypeoptions.push('<option value="零星材料">零星材料</option>');
            break;
        case 28:
            $('#txtTitle').html('低值易耗品报销单');
            listtypeoptions.push('<option value="低值易耗品">低值易耗品</option>');
            break;
        case 29:
            $('#txtTitle').html('项目低值易耗品报销单');
            listtypeoptions.push('<option value="项目低值易耗品">项目低值易耗品</option>');
            break;
        case 30:
            $('#txtTitle').html('信息化建设报销单');
            listtypeoptions.push('<option value="信息化建设">信息化建设</option>');
            break;
        case 19041:
            $('#txtTitle').html('咨询顾问费报销单');
            listtypeoptions.push('<option value="咨询顾问费">咨询顾问费</option>');
            break;
        case 19042:
            $('#txtTitle').html('审计费报销单');
            listtypeoptions.push('<option value="审计费">审计费</option>');
            break;
        case 19043:
            $('#txtTitle').html('IPO费用差旅住宿报销单');
            listtypeoptions.push('<option value="IPO费用差旅住宿">IPO费用差旅住宿</option>');
            break;
        case 19044:
            $('#txtTitle').html('IPO费用非差旅住宿报销单');
            listtypeoptions.push('<option value="IPO费用非差旅住宿">IPO费用非差旅住宿</option>');
            break;
        case 19045:
            $('#txtTitle').html('礼品、酒报销单');
            listtypeoptions.push('<option value="礼品、酒">礼品、酒</option>');
            break;
        case 19046:
            $('#txtTitle').html('电脑、打印机维修报销单');
            listtypeoptions.push('<option value="电脑、打印机维修">电脑、打印机维修</option>');
            break;
        case 19047:
            $('#txtTitle').html('办公/职工宿舍房租、水电、物业报销单');
            listtypeoptions.push('<option value="办公/职工宿舍房租、水电、物业">办公/职工宿舍房租、水电、物业</option>');
            break;
        case 19048:
            $('#txtTitle').html('可控管理费报销单');
            listtypeoptions.push('<option value="可控管理费">可控管理费</option>');
            break;
        case 19049:
            $('#txtTitle').html('保理、承兑等金融手续费报销单');
            listtypeoptions.push('<option value="保理、承兑等金融手续费">保理、承兑等金融手续费</option>');
            break;
        case 190410:
            $('#txtTitle').html('研发其他费用报销单');
            listtypeoptions.push('<option value="研发其他费用">研发其他费用</option>');
            break;
        case 190411:
            $('#txtTitle').html('办公室装修费用报销单');
            listtypeoptions.push('<option value="办公室装修费用">办公室装修费用</option>');
            break;
        case 190412:
            $('#txtTitle').html('会务费、保险费等其他可控管理费报销单');
            listtypeoptions.push('<option value="会务费">会务费</option>');
            listtypeoptions.push('<option value="保险费">保险费</option>');
            listtypeoptions.push('<option value="其他">其他</option>');
            break;
        case 190413:
            $('#txtTitle').html('行政罚款报销单');
            listtypeoptions.push('<option value="行政罚款">行政罚款</option>');
            break;
        case 190414:
            $('#txtTitle').html('房租费用报销单');
            listtypeoptions.push('<option value="房租费用">房租费用</option>');
            break;
    }
    if ($.trim(sysid) == '') {
        $('select[name="fm_reimbursement_dtl.treeName"]').eq(0).html(listtypeoptions.join(''));
        $('select[name="fm_reimbursement_dtl.treeName"]').eq(0).trigger("chosen:updated");
    }
 
    if (listtypeoptions.length <= 1)//只有一项一下,禁用选择
    {
        $('select[name="fm_reimbursement_dtl.treeName"]').attr('disabled', 'disabled');
    }
    //// 处理部门项目部不展示,职能部展示
    var titl = $('#txtTitle').html();
    if (titl.indexOf("项目") != -1) {
        $('input[name="fm_reimbursement.dept_name"]').css('display', 'none');
    }
    $('input[name="fm_reimbursement.dept_id"]').css('display', 'none');
 
}
 
//根据申请申请单号查询剩余报销金额
var GetBaoXiaoYuMoney = function (applycode, ordercode) {
    $.ajax({
        url: "/oa/FM_reimbursement/GetYuMoney?applycode=" + applycode + "&&ordercode=" + ordercode, async: false, cache: false, dataType: "json",
        success: function (data) {
            console.log(data);
            $nmoney = parseFloat(data);
        }
    });
}
 
 
//获取默认单据号与名称
var getusername = function (type) {
    if ($.trim(sysid) == '') {
        $.ajax({
            url: "/oa/FM_reimbursement/GetLoad", async: false, cache: false, dataType: "json",
            success: function (data) {
                $('input[name="fm_reimbursement.orderCode"]').val(data.orderCode);
                $('input[name="fm_reimbursement.dept_id"]').val(data.deptid);
                $('input[name="fm_reimbursement.dept_name"]').val(data.deptname);
                switch (type) {
                    case 1:
                        $('input[name="fm_reimbursement.name"]').val('项目差旅费报销(' + data.username + ')');
                        break;
                    case 2:
                        $('input[name="fm_reimbursement.name"]').val('项目其他措施费报销(' + data.username + ')');
                        break;
                    case 3:
                        $('input[name="fm_reimbursement.name"]').val('项目汽车费报销(' + data.username + ')');
                        break;
                    case 4:
                        $('input[name="fm_reimbursement.name"]').val('项目劳保费报销(' + data.username + ')');
                        break;
                    case 5:
                        $('input[name="fm_reimbursement.name"]').val('差旅费报销(' + data.username + ')');
                        break;
                    case 6:
                        $('input[name="fm_reimbursement.name"]').val('外部培训学习费报销(' + data.username + ')');
                        break;
                    case 7:
                        $('input[name="fm_reimbursement.name"]').val('例行培训学习费报销(' + data.username + ')');
                        break;
                    case 8:
                        $('input[name="fm_reimbursement.name"]').val('项目招待费报销(' + data.username + ')');
                        break;
                    case 9:
                        $('input[name="fm_reimbursement.name"]').val('汽车费报销(' + data.username + ')');
                        break;
                    case 10:
                        $('input[name="fm_reimbursement.name"]').val('招聘费报销(' + data.username + ')');
                        break;
                    case 11:
                        $('input[name="fm_reimbursement.name"]').val('办公费报销(' + data.username + ')');
                        break;
                    case 12:
                        $('input[name="fm_reimbursement.name"]').val('办公物业水电费报销(' + data.username + ')');
                        break;
                    case 13:
                        $('input[name="fm_reimbursement.name"]').val('文化建设费报销(' + data.username + ')');
                        break;
                    case 14:
                        $('input[name="fm_reimbursement.name"]').val('会务费,保险费,劳保用品等其他可控管理费报销(' + data.username + ')');
                        break;
                    case 15:
                        $('input[name="fm_reimbursement.name"]').val('行政管理无票支出报销(' + data.username + ')');
                        break;
                    case 16:
                        $('input[name="fm_reimbursement.name"]').val('研发费用报销(' + data.username + ')');
                        break;
                    case 17:
                        $('input[name="fm_reimbursement.name"]').val('招待费报销(' + data.username + ')');
                        break;
                    case 18:
                        $('input[name="fm_reimbursement.name"]').val('项目无票支出报销(' + data.username + ')');
                        break;
                    case 19:
                        $('input[name="fm_reimbursement.name"]').val('项目辅材报销(' + data.username + ')');
                        break;
                    case 20:
                        $('input[name="fm_reimbursement.name"]').val('市内交通费报销(' + data.username + ')');
                        break;
                    case 21:
                        $('input[name="fm_reimbursement.name"]').val('项目市内交通费报销(' + data.username + ')');
                        break;
                    case 22:
                        $('input[name="fm_reimbursement.name"]').val('项目其他间接费报销(' + data.username + ')');
                        break;
                    case 23:
                        $('input[name="fm_reimbursement.name"]').val('节假日福利费报销(' + data.username + ')');
                        break;
                    case 24:
                        $('input[name="fm_reimbursement.name"]').val('其他福利费报销(' + data.username + ')');
                        break;
                    case 25:
                        $('input[name="fm_reimbursement.name"]').val('管理人员工作餐报销(' + data.username + ')');
                        break;
                    case 26:
                        $('input[name="fm_reimbursement.name"]').val('项目福利费报销(' + data.username + ')');
                        break;
                    case 27:
                        $('input[name="fm_reimbursement.name"]').val('零星材料报销(' + data.username + ')');
                        break;
                    case 28:
                        $('input[name="fm_reimbursement.name"]').val('低值易耗品报销(' + data.username + ')');
                        break;
                    case 29:
                        $('input[name="fm_reimbursement.name"]').val('项目低值易耗品报销(' + data.username + ')');
                        break;
                    case 30:
                        $('input[name="fm_reimbursement.name"]').val('信息化建设报销(' + data.username + ')');
                        break;
                    case 19041:
                        $('input[name="fm_reimbursement.name"]').val('咨询顾问费报销(' + data.username + ')');
                        break;
                    case 19042:
                        $('input[name="fm_reimbursement.name"]').val('审计费报销(' + data.username + ')');
                        break;
                    case 19043:
                        $('input[name="fm_reimbursement.name"]').val('IPO费用差旅住宿报销(' + data.username + ')');
                        break;
                    case 19044:
                        $('input[name="fm_reimbursement.name"]').val('IPO费用非差旅住宿报销(' + data.username + ')');
                        break;
                    case 19045:
                        $('input[name="fm_reimbursement.name"]').val('礼品、酒报销(' + data.username + ')');
                        break;
                    case 19046:
                        $('input[name="fm_reimbursement.name"]').val('电脑、打印机维修报销(' + data.username + ')');
                        break;
                    case 19047:
                        $('input[name="fm_reimbursement.name"]').val('办公/职工宿舍房租、水电、物业报销(' + data.username + ')');
                        break;
                    case 19048:
                        $('input[name="fm_reimbursement.name"]').val('可控管理费报销(' + data.username + ')');
                        break;
                    case 19049:
                        $('input[name="fm_reimbursement.name"]').val('保理、承兑等金融手续费报销(' + data.username + ')');
                        break;
                    case 190410:
                        $('input[name="fm_reimbursement.name"]').val('研发其他费用报销(' + data.username + ')');
                        break;
                    case 190411:
                        $('input[name="fm_reimbursement.name"]').val('办公室装修费用报销(' + data.username + ')');
                        break;
                    case 190412:
                        $('input[name="fm_reimbursement.name"]').val('会务费、保险费等其他可控管理费报销(' + data.username + ')');
                        break;
                    case 190413:
                        $('input[name="fm_reimbursement.name"]').val('行政罚款报销(' + data.username + ')');
                        break;
                    case 190414:
                        $('input[name="fm_reimbursement.name"]').val('房租费用报销(' + data.username + ')');
                        break;
                }
            }
        });
    }
}
 
var listzxw = [];//成本中心
//获取成本中心
var getcbzx = function () {
    $.ajax({
        url: "/oa/FM_reimbursement/GetCBZXW", async: false, cache: false, dataType: "json",
        success: function (data) {
            listzxw.push('<option value="" costid="" typeforcost=""></option>');
            var nobjectid = $('#fm_reimbursement_objectid').val();
            console.log(nobjectid);
            $.each(data, function (i, r) {
                var isselect = '';
                if ($.trim(sysid) == '' && ((parseInt(r.isselect) == 1 && parseInt(r.typeforcost) == 0) || ($.trim(nobjectid) != '' && parseInt(nobjectid) > 0 && parseInt(r.typeforcost) == 1 && parseInt(r.costid
                ) == parseInt(nobjectid)))) {
                    isselect = 'selected';
                }
 
                listzxw.push('<option value="' + r.costname + '" costid="' + r.costid + '" typeforcost="' + r.typeforcost + '" ' + isselect + ' >' + r.costname + '</option>');
            });
            if ($.trim(sysid) == '') {
                $('select[name="fm_reimbursement_dtl.costname"]').html(listzxw.join(''));
                $('select[name="fm_reimbursement_dtl.costname"]').trigger("chosen:updated");
            }
        }
    });
}
 
 
 
//计算总金额
var countmoney = function () {
 
    var count = 0;
    var applymoney = 0;
    $.each($('input[name="fm_reimbursement_dtl.applymoney"]'), function () {
        //实际报销金额是否显示
        var obj = $(this).parent().parent().find('input[name="fm_reimbursement_dtl.money"]').parent().css('display');
        //实际报销金额是否可编辑
        var isdisabled = $(this).parent().parent().find('input[name="fm_reimbursement_dtl.money"]').attr('disabled');
        
        if (obj == 'none' || isdisabled == 'disabled') {
            var val = $.trim($(this).val());
            val = isNaN(val) ? 0 : val;
            val = val == '' ? 0 : parseFloat(val);
            applymoney += val;
            var taxrate = parseInt($(this).parent().parent().find('select[name="fm_reimbursement_dtl.taxrate"]').val()) * 0.01;
            var tax = (val / (1 + taxrate) * taxrate).toFixed(2);;
            $(this).parent().parent().find('input[name="fm_reimbursement_dtl.tax"]').val(tax);
        }
        else {
            applymoney = initItems.applymoney;
            var val = $(this).parent().parent().find('input[name="fm_reimbursement_dtl.money"]').val();
            val = isNaN(val) ? 0 : val;
            val = val == '' ? 0 : parseFloat(val);
            count += val;
            var taxrate = parseInt($(this).parent().parent().find('select[name="fm_reimbursement_dtl.taxrate"]').val()) * 0.01;
            var tax = (val / (1 + taxrate) * taxrate).toFixed(2);;
            $(this).parent().parent().find('input[name="fm_reimbursement_dtl.tax"]').val(tax);
        }
    });
    if ($applycode != '' && ($type == 8 || $type == 17)) {
        if (applymoney > $nmoney || count > $nmoney) {
            layer.alert('报销总金额不能超出申请总金额', { icon: 5 });
            return false;
        }
    }
    if (applymoney != 0) {
        $('input[name="fm_reimbursement.applymoney"]').val(applymoney.toFixed(2));
    }
    if (count != 0) {
        $('input[name="fm_reimbursement.money"]').val(count.toFixed(2));
    }
}
 
 
 
//选择计算金额
$(document).on('change', $('input[name="fm_reimbursement_dtl.applymoney"],input[name="fm_reimbursement_dtl.money"],select[name="fm_reimbursement_dtl.taxrate"]'), function (i, r) {
    countmoney();
});
 
var thisobj = null;
 
//财务科目
var getCWinfo = function (obj) {
    thisobj = obj;
    layer.open({
        type: 2,
        title: '财务科目',
        shadeClose: true,
        shade: 0.4,
        area: ['90%', '90%'],
        content: "/Article/CWindex"
    });
}
 
//选择财务科目后触发
var setCWInfo = function (SubjectEncode, SubjectName) {
    $(thisobj).parent().parent().find('input[name="fm_reimbursement_dtl.costtype"]').val(SubjectName);
    $(thisobj).parent().parent().find('input[name="fm_reimbursement_dtl.costtypeid"]').val(SubjectEncode);
    layer.closeAll();
}
 
 
 
//删除事件回调操作
deleteMethod = function () {
    countmoney();
}
 
//添加事件回调操作
createMethod = function () {
    // chkNum();
    var ntr = $('select[name="fm_reimbursement_dtl.treeName"]').length;
    $('select[name="fm_reimbursement_dtl.treeName"]').eq(ntr - 1).html(listtypeoptions.join(''));
    $('select[name="fm_reimbursement_dtl.treeName"]').eq(ntr - 1).trigger("chosen:updated");
    if (listtypeoptions.length <= 1)//只有一项一下,禁用选择
    {
        $('select[name="fm_reimbursement_dtl.treeName"]').eq(ntr - 1).attr('disabled', 'disabled');
        $('select[name="fm_reimbursement_dtl.treeName"]').eq(ntr - 1).chosen();
    }
 
    $('select[name="fm_reimbursement_dtl.taxrate"]').eq(ntr - 1).chosen();
    var inputs = '<input type="hidden" name="fm_reimbursement_dtl.costtypeid" class="edit" field="costtypeid" value="">';
    $('input[name="fm_reimbursement_dtl.costtype"]').eq(ntr - 1).after(inputs);
    //财务科目选择后触发
    $('input[name="fm_reimbursement_dtl.costtype"]').eq(ntr - 1).bind('focus', function (i, r) {
        getCWinfo(this);
    });
    if ($type == 1 || $type == 5 || $type == 20 || $type == 21 || $type == 8 || $type == 17) {
        var costid = $('select[name="fm_reimbursement_dtl.costname"]').find('option:selected').attr('costid');
        var typeforcost = $('select[name="fm_reimbursement_dtl.costname"]').find('option:selected').attr('typeforcost');
        inputs = '<input type="hidden" name="fm_reimbursement_dtl.costid" class="edit" field="costid" value="' + costid + '">';
        inputs += '<input type="hidden" name="fm_reimbursement_dtl.typeforcost" class="edit" field="typeforcost" value="' + typeforcost + '">';
 
        $('select[name="fm_reimbursement_dtl.costname"]').after(inputs);
        $('select[name="fm_reimbursement_dtl.costname"]').eq(ntr - 1).html(listzxw.join(''));
        $('select[name="fm_reimbursement_dtl.costname"]').eq(ntr - 1).chosen();
 
        //成本中心选择后触发
        $('select[name="fm_reimbursement_dtl.costname"]').eq(ntr - 1).bind('change', function () {
            var costid = $('select[name="fm_reimbursement_dtl.costname"]').eq(ntr - 1).find('option:selected').attr('costid');
            var typeforcost = $('select[name="fm_reimbursement_dtl.costname"]').eq(ntr - 1).find('option:selected').attr('typeforcost');
            $(this).parent().parent().find('input[name="fm_reimbursement_dtl.costid"]').val(costid);
            $(this).parent().parent().find('input[name="fm_reimbursement_dtl.typeforcost"]').val(typeforcost);
        });
    }
    changeTextarea();
}
//动态添加CSS样式
function addCSS() {
    var str_style = 'td{ position:relative;}';
    if (document.all) { // document.createStyleSheet(url)
        window.style = str_style;
        document.createStyleSheet("javascript:style");
    } else { //document.createElement(style)
        var style = document.createElement('style');
        style.type = 'text/css';
        style.innerHTML = str_style;
        document.getElementsByTagName('HEAD').item(0).appendChild(style);
    }
}
//把input改为textarea
function changeTextarea() {
    //用途
    $('input[name="fm_reimbursement_dtl.costusage"]').each(function (i, input) {
        var value = $.trim($(this).val());
        var textarea = createTextarea("fm_reimbursement_dtl", "costusage");
        textarea.style.right = "0px";
        //var value = "";
        //if (childrenItems.length > i && childrenItems[i].hasOwnProperty("costusage"))
        //    value = childrenItems[i].costusage
        changeInputCell(input, textarea, value);
    })
    //业务内容
    $('input[name="fm_reimbursement_dtl.remarks"]').each(function (i, input) {
        var value = $.trim($(this).val());
        var textarea = createTextarea("fm_reimbursement_dtl", "remarks");
        textarea.style.left = "0px";
        changeInputCell(input, textarea, value);
    })
}
 
//替换表格控件元素
function changeInputCell(input, newInput, value) {
    value = value || "";
    var $input = $(input);
    var $newInput = $(newInput);
    var parent = input.parentNode;
    $newInput.val(value);
    var hasEdit = $input.hasClass("edit");
    var isDisbale = $input.prop("disabled");
    isDisbale && newInput.setAttribute("disabled", "disabled");
    newInput.innerHTML = value;
    $input.remove();
    parent.appendChild(newInput);
}
 
//创建textarea
function createTextarea(table, name) {
    var textarea = document.createElement("textarea");
    textarea.className = "tex_inp";
    textarea.id = table + "_" + name;
    textarea.name = table + "." + name;
    textarea.setAttribute("field", name);
    return textarea;
}
 
///数据加载
var initData = function () {
    //chkNum();
    addCSS();
    changeTextarea();
    var url = window.location.href;
    var type = parseInt(getUrlParam('type'));
    var ApplyCode = '';
    var orderType = 0;
    var dept_name = "", dept_id = 0;
    if ($.trim(sysid) != '' && initItems != null) {
        var sprintbtn = '<a onclick="" href="/oa/FM_reimbursement/costprint?id=' + sysid + '&flowid=' + flowid + '&taskid=' + taskid + '" target="_blank" style="font-size:12px;"><img src="~/img/ico/printer.png" />表单打印</a>';
        sprintbtn += '<a onclick="" href="/oa/FM_reimbursement/printyj?id=' + sysid + '&flowid=' + flowid + '&taskid=' + taskid + '" target="_blank" style="font-size:12px;"><img src="~/img/ico/printer.png" />审核意见打印</a>';
        $('input[name="fm_reimbursement_dtl.tax"]').each(function () {
            if ($(this).val() == "") {
                $(this).val("0");
            }
        });
        dept_id = initItems.dept_id;
        dept_name = initItems.dept_name;
        type = parseInt(initItems.type);
        ApplyCode = initItems.ApplyCode;
        orderType = parseInt(initItems.orderType);
    }
    //// 处理部门项目部不展示,职能部展示
    var titl = $('#txtTitle').html();
    if (titl.indexOf("项目") != -1) {
        $('input[name="fm_reimbursement.dept_name"]').css('display', 'none');
    }
    $('input[name="fm_reimbursement.dept_id"]').css('display', 'none');
 
    $type = type;
 
    var inputs = '<input type="hidden" id="fm_reimbursement_type" name="fm_reimbursement.type" field="type" value="' + type + '">';
    $('input[name="fm_reimbursement.orderCode"]').after(inputs);
 
    ApplyCode = ApplyCode == '' ? $.trim(getUrlParam('orderCode')) : ApplyCode;
    $('input[name="fm_reimbursement.ApplyCode"]').val(ApplyCode);
    $('input[name="fm_reimbursement.ApplyCode"]').attr('disabled', 'disabled');
    
 
    var ot = $.trim(getUrlParam('orderType'));
    if (ot != '') {
        orderType = parseInt(ot);
    }
    var lbtype = '';
    switch (orderType) {
        case 1: lbtype = '合同单号'; break;
        case 2: lbtype = '申请单号'; break;
    }
    if ($.trim(ApplyCode) == '') {
        $('input[name="fm_reimbursement.ApplyCode"]').parent().parent().remove();
    }
    else {
        $('input[name="fm_reimbursement.ApplyCode"]').parent().parent().find('label').html(lbtype);
    }
 
    inputs = '<input type="hidden" id="fm_reimbursement_orderType" name="fm_reimbursement.orderType" field="orderType" value="' + orderType + '">';
    $('input[name="fm_reimbursement.orderCode"]').after(inputs);
 
    var projectid = $.trim(getUrlParam('projectid'));
    projectid = projectid == '' ? 0 : projectid;
    projectid = parseInt(projectid);
    if (projectid > 0) {
        $('#fm_reimbursement_objectid').val(projectid);
        $('#fm_reimbursement_objectid').attr('disabled', 'disabled');
        $('#fm_reimbursement_objectid').trigger("chosen:updated");
 
    }
 
    gettype(type);
    getusername(type);
    if (type == 1 || type == 5 || type == 20 || type == 21 || type == 8 || type == 17) {
        getcbzx();
    }
    if ($.trim(sysid) != '' && initItems.Children != null && initItems.Children != undefined && initItems.Children.length > 0) {
        $.each(initItems.Children, function (i, r) {
 
            $('select[name="fm_reimbursement_dtl.treeName"]').eq(i).html(listtypeoptions.join(''));
            $('select[name="fm_reimbursement_dtl.treeName"]').eq(i).val(r.treeName);
            $('select[name="fm_reimbursement_dtl.treeName"]').eq(i).trigger("chosen:updated");
 
 
            var inputs = '<input type="hidden" name="fm_reimbursement_dtl.costtypeid" class="edit" field="costtypeid" value="' + r.costtypeid + '">';
            $('input[name="fm_reimbursement_dtl.costtype"]').eq(i).after(inputs);
 
            if (type == 1 || type == 5 || type == 20 || type == 21 || type == 8 || type == 17) {
                inputs = '<input type="hidden" name="fm_reimbursement_dtl.costid" class="edit" field="costid" value="' + r.costid + '">';
                inputs += '<input type="hidden" name="fm_reimbursement_dtl.typeforcost" class="edit" field="typeforcost" value="' + r.typeforcost + '">';
                $('select[name="fm_reimbursement_dtl.costname"]').eq(i).after(inputs);
                $('select[name="fm_reimbursement_dtl.costname"]').eq(i).html(listzxw.join(''));
                $('select[name="fm_reimbursement_dtl.costname"]').eq(i).val(r.costname);
                $('select[name="fm_reimbursement_dtl.costname"]').eq(i).trigger("chosen:updated");
            }
 
        });
    }
    $('input[name="fm_reimbursement.IsInPlan"]:eq(0)').attr("value", '1');
    $('input[name="fm_reimbursement.IsInPlan"]:eq(1)').attr("value", '2');
 
 
    if ($.trim(sysid) != '' && initItems != null) {
        var sprintbtn = '<span style="position: absolute;right:20px;"><a onclick="" href="/oa/FM_reimbursement/costprint?id=' + sysid + '&flowid=' + flowid + '&taskid=' + taskid + '" target="_blank" style="font-size:12px;margin-right: 20px;"><img src="../../img/ico/printer.png" />表单打印</a>';
        sprintbtn += '<a onclick="" href="/oa/FM_reimbursement/printyj?id=' + sysid + '&flowid=' + flowid + '&taskid=' + taskid + '" target="_blank" style="font-size:12px;"><img src="../../img/ico/printer.png" />审核意见打印</a></span>';
        $('#txtTitle').append(sprintbtn);
    }
    if (sysid == '') {
        var inputs = '<input type="hidden" name="fm_reimbursement_dtl.costtypeid" class="edit" field="costtypeid" value="">';
        $('input[name="fm_reimbursement_dtl.costtype"]').after(inputs);
        if (type == 1 || type == 5 || type == 20 || type == 21 || type == 8 || type == 17) {
            var costid = $('select[name="fm_reimbursement_dtl.costname"]').find('option:selected').attr('costid');
            var typeforcost = $('select[name="fm_reimbursement_dtl.costname"]').find('option:selected').attr('typeforcost');
            inputs = '<input type="hidden" name="fm_reimbursement_dtl.costid" class="edit" field="costid" value="' + costid + '">';
            inputs += '<input type="hidden" name="fm_reimbursement_dtl.typeforcost" class="edit" field="typeforcost" value="' + typeforcost + '">';
            $('select[name="fm_reimbursement_dtl.costname"]').after(inputs);
        }
    }
 
 
    //成本中心选择后触发
    $('select[name="fm_reimbursement_dtl.costname"]').bind('change', function () {
        var costid = $('select[name="fm_reimbursement_dtl.costname"]').find('option:selected').attr('costid');
        var typeforcost = $('select[name="fm_reimbursement_dtl.costname"]').find('option:selected').attr('typeforcost');
        $(this).parent().parent().find('input[name="fm_reimbursement_dtl.costid"]').val(costid);
        $(this).parent().parent().find('input[name="fm_reimbursement_dtl.typeforcost"]').val(typeforcost);
    });
    //财务科目选择后触发
    $('input[name="fm_reimbursement_dtl.costtype"]').bind('focus', function (i, r) {
        getCWinfo(this);
    });
    //添加更新字段
    $('input[name="fm_reimbursement.money"],input[name="fm_reimbursement.applymoney"],input[name="fm_reimbursement_dtl.money"],input[name="fm_reimbursement_dtl.applymoney"],input[name="fm_reimbursement_dtl.tax"]').addClass('edit');
 
    $applycode = sysid == '' ? $.trim(ApplyCode) : $.trim(initItems.ApplyCode);
    var sordercode = $('#fm_reimbursement_orderCode').val();
     //// edit by zyyao 2019/4/18 行政代高管和顾问 发起 招待和住宿
    if ($applycode != '' && ($type == 8 || $type == 17)) {
        GetBaoXiaoYuMoney($applycode, sordercode);
    }
    
}