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
var $type = 0;
var $ordercode = '';
//获取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 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');
 
        var thisobj = $(this).parent().css('display');
        var thisisdisabled = $(this).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 (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 listoptions = [];
var getbaoxiaotype = function () {
    $.ajax({
        url: "/oa/Fm_reimbursement/GetBaoXiaoType", async: false, cache: false, dataType: "json",
        success: function (data) {
            listoptions = [];
            $.each(data, function (i, r) {
                var options = '<option value="' + r.Comments + '" CodeSn="' + r.CodeSn + '">' + r.Comments + '</option>';
                listoptions.push(options);
            })
 
        }
    });
 
}
 
//获取默认单据号与名称
var getusername = function () {
    if ($.trim(sysid) == '') {
        $.ajax({
            url: "/erp/Erp_purchaseorders/GetByCode?ordercode=" + $ordercode + "&&type=" + $type, async: false, cache: false, dataType: "json",
            success: function (data) {
                $('#txtTitle').html(data.bxName.split('(')[0]);
                $('input[name="fm_reimbursement.orderCode"]').val(data.bxCode);
                $('input[name="fm_reimbursement.name"]').val(data.bxName);
                $('input[name="fm_reimbursement.createtime"]').val(data.bxTime);
                $('input[name="fm_reimbursement.ApplyCode"]').val(data.orderCode);
                $('input[name="fm_reimbursement.applymoney"]').val(data.money);
                if (data.project_id > 0) {
                    $('select[name="fm_reimbursement.objectid"]').val(data.project_id);
                    $('select[name="fm_reimbursement.objectid"]').trigger("chosen:updated");
                }
                else {
                    $('select[name="fm_reimbursement.project_id"]').parent().parent().remove();
                }
                if (data.listDtl.length > 0) {
                    $.each(data.listDtl, function (i, r) {
                        if (i == 0) {
                            $('select[name="fm_reimbursement_dtl.treeName"]').eq(i).html(listoptions.join(''));
                            var tname = $('select[name="fm_reimbursement_dtl.treeName"]').eq(i).find('option[CodeSn="' + r.type + '"]').val();
                            $('select[name="fm_reimbursement_dtl.treeName"]').eq(i).val(tname);
                            $('select[name="fm_reimbursement_dtl.treeName"]').eq(i).trigger("chosen:updated");
                            $('input[name="fm_reimbursement_dtl.remarks"]').eq(i).val(r.name);
                            $('input[name="fm_reimbursement_dtl.applymoney"]').eq(i).val(r.amount);
                        }
                        else {
                            $('.subtradd_js').click();
                            $('select[name="fm_reimbursement_dtl.treeName"]').eq(i).html(listoptions.join(''));
                            var tname = $('select[name="fm_reimbursement_dtl.treeName"]').eq(i).find('option[CodeSn="' + r.type + '"]').val();
                            $('select[name="fm_reimbursement_dtl.treeName"]').eq(i).val(tname);
                            $('select[name="fm_reimbursement_dtl.treeName"]').eq(i).trigger("chosen:updated");
                            $('input[name="fm_reimbursement_dtl.remarks"]').eq(i).val(r.name);
                            $('input[name="fm_reimbursement_dtl.applymoney"]').eq(i).val(r.amount);
                        }
                    });
                    countmoney();
                }
 
            }
        });
    }
}
 
//删除事件回调操作
deleteMethod = function () {
}
 
//添加事件回调操作
createMethod = function () {
    var ntr = $('select[name="fm_reimbursement_dtl.treeName"]').length;
    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);
    });
}
 
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();
}
 
 
///数据加载
var initData = function () {
    getbaoxiaotype();
    if (sysid == '') {
        $type = getUrlParam('type');
        $ordercode = getUrlParam('orderCode');
        getusername();
    }
    else {
        $('#txtTitle').html(initItems.name.split('(')[0]);
        $type = parseInt(initItems.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);
    inputs = '<input type="hidden" id="fm_reimbursement_orderType" name="fm_reimbursement.orderType" field="orderType" value="6">';
    $('input[name="fm_reimbursement.orderCode"]').after(inputs);
    if ($.trim(sysid) != '' && initItems != null) {
        var sprintbtn = '<span style="float: right;margin-right: 50px;"><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 ($.trim(sysid) != '' && initItems.Children != null && initItems.Children != undefined && initItems.Children.length > 0) {
        $.each(initItems.Children, function (i, r) {
            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 (sysid == '') {
        var inputs = '<input type="hidden" name="fm_reimbursement_dtl.costtypeid" class="edit" field="costtypeid" value="">';
        $('input[name="fm_reimbursement_dtl.costtype"]').after(inputs);
    }
    //财务科目选择后触发
    $('input[name="fm_reimbursement_dtl.costtype"]').bind('focus', function (i, r) {
        getCWinfo(this);
    });
    $('input[name="fm_reimbursement.IsInPlan"]:eq(0)').attr("value", '1');
    $('input[name="fm_reimbursement.IsInPlan"]:eq(1)').attr("value", '2');
    $('.subtradd_js').hide();
    $('.subtrdel_js').hide();
}