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
var tabIndex;
var currentUserName;
initData = function () {
    if (window.taskid === '') {
        $.ajax({
            url: "/PurchaseApply/InitData",
            async: false,
            cache: false,
            dataType: "json",
            success: function (data) {
                currentUserName = data.CurrentUserName;
                var $data = data.children;
                for (var name in data) {
                    if (name !== "children") {
                        var $value = data[name];
                        if ($value != null && $value !== '') {
                            var $control = $(".main [field='" + name + "']");
                            var $controltype = $control.prop("tagName");
                            if ($controltype != null && $controltype !== '') {
 
                                var $type = $control.attr("type");
                                if ($type !== "radio" && $type !== "checkbox") {
                                    $(".main [field='" + name + "']").val($value);
                                }
                                if ($type === "radio") {
                                    $(".main [field='" + name + "'][value='" + $value + "']").attr("checked", "checked");
                                }
                                if ($type === "checkbox") {
                                    var $items = $(".main [field='" + name + "']");
                                    var $arr = $value.split(",");
                                    $.each($items, function (index, obj) {
                                        var value = $(obj).attr("value");
                                        if (contains($arr, value))
                                            $(obj).attr("checked", "checked");
                                    });
                                }
                            }
                        }
                    }
                }
                if ($data != null && $data.length > 0) {
                    renderGirdtableByData($children, $data.length);
                }
            }
        });
        var $txttitle = $("#txtTitle").text();
        $txttitle = $txttitle + "(" + currentUserName + ")";
        $("#erp_purchaseapplication_name").val($txttitle);
 
        var $classfy = getQueryVariable("type");
        if (document.getElementById("erp_purchaseapplication_Classfy") && $classfy !== '') { //js判断元素是否存在
            $("#erp_purchaseapplication_Classfy").val($classfy);
            $('#erp_purchaseapplication_Classfy').trigger("chosen:updated");
            $("#erp_purchaseapplication_Classfy").attr("disabled", true);
            var $name = $("#erp_purchaseapplication_Classfy").find("option:selected").text();
            var $type = $("#erp_purchaseapplication_Classfy").find("option:selected").val();
            if ($type == 12) {
                $("#girdtable tr").find('td:eq(0)').hide();
            }
            $('#txtTitle').html($name + "申请单");
            if (window.taskid === '') {
                $txttitle = $name + "申请单(" + currentUserName + ")";
                $("#erp_purchaseapplication_name").val($txttitle);
            }
        } else if ($classfy !== '') {
            var $control = $('<input id="erp_purchaseapplication_Classfy" name="erp_purchaseapplication.Classfy" field="Classfy" type="hidden" value="' + $classfy + '" />');
            $(".main").append($control);
            if (window.taskid === '') {
                $txttitle = $("#txtTitle").html() + "申请单(" + currentUserName + ")";;
                $("#erp_purchaseapplication_name").val($txttitle);
            }
        }
        if ($classfy == undefined || $classfy == '') {
            var $name = $("#erp_purchaseapplication_Classfy").find("option:selected").text();
            $('#txtTitle').html($name + "申请单");
            $("#erp_purchaseapplication_name").val($name + "申请单(" + currentUserName + ")");
        }
    } else {
        var name = $("#erp_purchaseapplication_Classfy").find("option:selected").text();
        if (name != "") {
            $('#txtTitle').html(name + "申请单");
        }
        var $type = $("#erp_purchaseapplication_Classfy").find("option:selected").val();
        if ($type == 12) {
            $("#girdtable tr").find('td:eq(0)').hide();
        }
        var formName = $("#erp_purchaseapplication_name").val();
        currentUserName = formName.substring(formName.indexOf("(") + 1, formName.indexOf(")"));
        $("#erp_purchaseapplication_Classfy").attr("disabled", true);
        $('#erp_purchaseapplication_Classfy').trigger("chosen:updated");
    }
    $("#erp_purchaseapplication_TotalPrice").attr("readonly", "readonly");
    $("#erp_purchaseapplication_orderCode").attr("readonly", "readonly");
    $("#erp_purchaseapplication_createtime").attr("readonly", "readonly");
    $("#erp_purchaseapplication_name").attr("readonly", "readonly");
}
 
 
//添加事件回调操作
createMethod = function () {
   
    var $type = $("#erp_purchaseapplication_Classfy").find("option:selected").val();
    if ($type == 12) {
        $("#erp_purchaseapplication_dtl_Object").parent().parent().parent().find("tr").find('td:eq(0)').hide();
    } else {
        $("#erp_purchaseapplication_dtl_Object").parent().parent().parent().find("tr").find('td:eq(0)').show();
    }
}
 
 
totalcompute = function () {
    var total = 0;
    $('.grid').find("table .body").each(function () {
        var count = $(this).find("#erp_purchaseapplication_dtl_count").val();
        var price = $(this).find("#erp_purchaseapplication_dtl_Price").val();
        if (count !== null && price !== null && count > 0 && price > 0)
            total += accMul(count,price);
        else {
            price = $(this).find("#erp_purchaseapplication_dtl_TotalPrice").val();
            if (price !== null && price > 0)
                total += accMul(1.0, price);
        }
    });
    $("#erp_purchaseapplication_TotalPrice").val(total);
}
 
$(document).ready(function () {
    $(".grid").on("blur", "#erp_purchaseapplication_dtl_count", function () {
        totalcompute();
    });
    $(".grid").on("blur", "#erp_purchaseapplication_dtl_Price", function () {
        totalcompute();
    });
    $(".grid").on("blur", "#erp_purchaseapplication_dtl_TotalPrice", function () {
        totalcompute();
    });
});
 
//$(document).on("change", "#erp_purchaseapplication_project_id", function () {
//    var $name = $("#erp_purchaseapplication_project_id").find("option:selected").text();
//    var $title = $("#txtTitle").html() + "(" + currentUserName + ")";
//    $("#erp_purchaseapplication_name").val($name + '_' + $title);
//});
 
$(document).on("change", "#erp_purchaseapplication_Classfy", function () {
    var $name = $("#erp_purchaseapplication_Classfy").find("option:selected").text();
    var $txttitle = $name + "申请单(" + currentUserName + ")";
    $("#erp_purchaseapplication_name").val($txttitle);
    $('#txtTitle').html($name + "申请单");
});
 
deleteMethod = function () {
    totalcompute();
}
 
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 "";
}