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
var htKeyId;
var currentUserName = "";
var $classfy;
var $ztype;
var tabIndex;
initData = function () {
    htKeyId = getQueryVariable("keyid");
    if (window.sysid === '' && htKeyId != undefined && htKeyId !== "") {
        $.ajax({
            url: "/ContractToChange/InitDataByNum?sysid=" + htKeyId,
            async: false,
            cache: false,
            dataType: "json",
            success: function (data) {
                currentUserName = data.CurrentUserName;
                window.initItems = data;
                window.childrenItems = data.Children;
                $classfy = data.Classfy;
                $ztype = data.Type;
                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 !== '') {
                                $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) {
                    var $table = $('#girdtable');
                    $table.find(".body").remove();
                    $.each($data, function (index, item) {
                        var $tabelContent = createTabBodyByData($children.columns, item);
                        $table.append($tabelContent);
                    });
                    $childTable = $children.columns[0].table;
                }
            }
        });
        var $title = "";
        switch ($ztype) {
            case "1":
                $title = "主材采购";
                break;
            case "3":
                $title = "施工费/措施费";
                break;
            case "4":
                $title = "房产采购";
                break;
            case "5":
                $title = "机械设备";
                break;
            case "6":
                $title = "固定资产/周转材料";
                break;
            case "8":
                $title = "行政办公设备/行政车辆";
                break;
            case "9":
                $title = "设备维修/改装";
                break;
            case "10":
                $title = "桩机配件采购";
                break;
            case "11":
                $title = "设备部劳务班组费用";
                break;
            case "13":
                $title = "运输费用";
                break;
           
        }
        if (getQueryVariable("flowid") == "AF1BFE784475441C9C9EA95E00E3A494" || getQueryVariable("flowid") == "5BC2C6D6CEA34FEC862DA95F01127262"
            || getQueryVariable("flowid") == "D39E3EDC1FE146398DD4A95F011BABCB" || getQueryVariable("flowid") == "A018F9E8689D4E6199A7A96100ADDD9E"
            || getQueryVariable("flowid") == "582B1401697E4FC49766A96100BCFC10" || getQueryVariable("flowid") == "052EA48148144EE284ACA96100DB6D97"
            || getQueryVariable("flowid") == "AC64BE4F84BF4DC39057A96100DFA4DF" || getQueryVariable("flowid") == "A7A9F02972864A929D1BA96100E17E36"
            || getQueryVariable("flowid") == "41CFB9C5D521452B8F51A96600FA2CBA" || getQueryVariable("flowid") == "A92B7E1B9A11490398DCA96600FC69AD") {
            $("#txtTitle").html($title + "合同外变更");
            $("#oa_contractpretrial_Title").val($title + "合同外变更(" + currentUserName + ")");
        } else {
            $("#txtTitle").html($title + "合同变更");
            $("#oa_contractpretrial_Title").val($title + "合同变更(" + currentUserName + ")");
        }
        var $pcontrol = $('<input id="oa_contractpretrial_PartyBId" name="oa_contractpretrial.PartyBId" field="PartyBId" type="hidden"/>');
        $(".main").append($pcontrol);
        $("#oa_contractpretrial_PartyBId").val(initItems.PartyBId);
        reloadAuthority();
    } else {
        var $pcontrol = $('<input id="oa_contractpretrial_PartyBId" name="oa_contractpretrial.PartyBId" field="PartyBId" type="hidden"/>');
        $(".main").append($pcontrol);
        $("#oa_contractpretrial_PartyBId").val(initItems.PartyBId);
    }
    $("#oa_contractpretrial_Code").attr("readonly", "readonly");
    $("#oa_contractpretrial_Title").attr("readonly", "readonly");
    $("#oa_contractpretrial_createtime").attr("disabled", "disabled");
    $("#oa_contractpretrial_UniqueId").attr("readonly", "readonly");
    $("#oa_contractpretrial_Amount").attr("readonly", "readonly");
    $("#oa_contractpretrial_ProjectId").attr("disabled", "disabled");
}
 
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 "";
}
 
reloadAuthority = function () {
    $.each(window.authorize, function (index, obj) {
        if (obj.Status === 0)//编辑
        {
            $("[name='" + obj.Field + "']").removeAttr("disabled").addClass("edit");
        }
        if (obj.Status === 1)//只读
        {
            $("[name='" + obj.Field + "']").attr("disabled", "disabled");
        }
        if (obj.Status === 2)//隐藏
        {
            if ($("[name='" + obj.Field + "']").closest("td").length > 0) {
                var $tdindex = $("[name='" + obj.Field + "']").closest("td").index();//列索引
                $('#girdtable tr').find('td:eq("' + $tdindex + '")').hide();
            }
        }
    });
    setTimeout("initDateTime()", 500);
}
 
$(document).ready(function () {
    $(".grid").on("blur", "#oa_contractpretrialdtl_TotalPrice", function () {
        countmoney();
    });
    $(".grid").on("blur", "#oa_contractpretrialdtl_UnitPrice", function () {
        totalcompute();
    });
    $(".grid").on("blur", "#oa_contractpretrialdtl_Quantity", function () {
        totalcompute();
    });
    $(".grid").on("change", "#oa_contractpretrialdtl_TaxRate", function () {
        var $trindex = $(this).closest("tr").index();//行索引
        var $value = $(this).val();
        var $unitPrice = $('#girdtable').find('tr:eq("' + $trindex + '")').find("#oa_contractpretrialdtl_UnitPrice").val();
        var $taxPrice = (parseFloat($unitPrice) / (1 + parseFloat($value) / 100) * (parseFloat($value) / 100)).toFixed(2);
        var $nonTaxPrice = ($unitPrice - $taxPrice).toFixed(2);
        if ($nonTaxPrice > 0)
            $('#girdtable').find('tr:eq("' + $trindex + '")').find("#oa_contractpretrialdtl_NonTaxPrice").val($nonTaxPrice);
    });
});
 
//计算金额
countmoney = function () {
    var total = 0;
    $('.grid').find("table .body").each(function () {
        var price = $(this).find("#oa_contractpretrialdtl_TotalPrice").val();
        if (price > 0)
            total += parseFloat(price).toFixed(2);
    });
    $("#oa_contractpretrial_Amount").val(total);
}
totalcompute = function () {
    var total = 0;
    $('.grid').find("table .body").each(function () {
        var $price = $(this).find("#oa_contractpretrialdtl_UnitPrice").val();
        var $count = $(this).find("#oa_contractpretrialdtl_Quantity").val();
        var $value = $(this).find("select[name='oa_contractpretrialdtl.TaxRate']").val();
        if ($count > 0 && $price)
            total += parseFloat($price) * parseFloat($count);
        var $taxPrice = (parseFloat($price) / (1 + parseFloat($value) / 100) * (parseFloat($value) / 100)).toFixed(2);
        var $nonTaxPrice = ($price - $taxPrice).toFixed(2);
        if ($nonTaxPrice > 0)
            $(this).find("#oa_contractpretrialdtl_NonTaxPrice").val($nonTaxPrice);
    });
    $("#oa_contractpretrial_Amount").val(total.toFixed(2));
}
 
$(document).on("click", "input[name='oa_contractpretrialdtl.MaterialCode'],input[name='oa_contractpretrialdtl.MaterialName']", function () {
    var $supplierid = $("#oa_contractpretrial_PartyBId").val();
    if ($supplierid == undefined || $supplierid == '') {
        layer.alert("请先选择供应商");
        return;
    }
    tabIndex = $(this).closest('tr').index();
    if (initItems.Classfy == "06" || initItems.Classfy == "0501" || initItems.Classfy == "0505") {
        layer.open({
            type: 2,
            title: '资源库',
            shadeClose: true,
            shade: 0.4,
            area: ['80%', '80%'],
            content: "/Article/index?type=" + initItems.Classfy
        });
    } else {
        layer.open({
            type: 2,
            title: '资源库',
            shadeClose: true,
            shade: 0.4,
            area: ['80%', '80%'],
            content: "/FixedPrice/index?ordercode=" + initItems.ApplyCode + "&supplierid=" + $supplierid
        });
    }
});
 
setBaseInfo = function (materialCode, materialName, resourceClassificationId, resourceClassificationName, specificationModel, measurementUnit, index, measurementUnitName, resourceClassificationSupName) {
    var $row = $("table tr:eq(" + tabIndex + ")");
    $row.find("input[field='MaterialCode']").val(materialCode);
    $row.find("input[field='MaterialName']").val(materialName);
    $row.find("input[field='Unit']").val(measurementUnitName);
    layer.closeAll();
}
 
setFixedPrice = function (mCode, mName, mUnit, mPrice, mTotal, mTaxrate, mSpecification) {
    if (hasRepeat(mCode)) {
        layer.alert("明细中已存在[" + mName + "(" + mCode + ")],不能重复添加!");
        return;
    }
    var $row = $("table tr:eq(" + tabIndex + ")");
    if ($row.find("input[field='MaterialCode']").length > 0) {
        $row.find("input[field='MaterialCode']").val(mCode);
        $row.find("input[field='MaterialName']").attr("disabled", "disabled");
    }
    else if ($row.find("select[field='MaterialCode']").length > 0) {
        $row.find("select[name='oa_contractpretrialdtl.MaterialCode']").val(mCode);
        $row.find("select[name='oa_contractpretrialdtl.MaterialCode']").attr("disabled", "disabled");
        $row.find("select[name='oa_contractpretrialdtl.MaterialCode']").trigger("chosen:updated");
    } else {
        var $hidden = $('<input id="oa_contractpretrialdtl_MaterialCode" name="oa_contractpretrialdtl.MaterialCode" field="MaterialCode" type="hidden" value="' + mCode + '"/>');
        $row.append($hidden);
    }
    $row.find("input[field='MaterialName']").val(mName);
    if ($row.find("input[field='Unit']").length > 0) {
        $row.find("input[field='Unit']").val(mUnit);
    } else {
        $row.find("select[name='oa_contractpretrialdtl.Unit']").val(mUnit);
        $row.find("select[name='oa_contractpretrialdtl.Unit']").attr("disabled", "disabled");
        $row.find("select[name='oa_contractpretrialdtl.Unit']").trigger("chosen:updated");
    }
    $row.find("input[field='Unit']").attr("disabled", "disabled");
    $row.find("input[field='Quantity']").val(mTotal);
    $row.find("input[field='UnitPrice']").val(mPrice);
    $row.find("input[field='UnitPrice']").attr("maxValue", mPrice);
    $row.find("select[field='TaxRate']").val(mTaxrate);
    $row.find("select[field='TaxRate']").trigger("chosen:updated");
    $row.find("input[field='Model']").val(mSpecification);
    totalcompute();
    layer.closeAll();
}
 
hasRepeat = function (value) {
    var $array = [];
    $(".grid tbody tr").each(function () {
        if ($(this).find('#oa_contractpretrialdtl_MaterialCode').val() != undefined)
            $array.push($(this).find('#oa_contractpretrialdtl_MaterialCode').val());
    });
    if ($array.Contains(value) && value != null && value != '')
        return true;
    else return false;
}
 
hasRepeat = function (value) {
    var $array = [];
    $(".grid tbody tr").each(function () {
        if ($(this).find('#oa_contractpretrialdtl_MaterialCode').val() != undefined)
            $array.push($(this).find('#oa_contractpretrialdtl_MaterialCode').val());
    });
    if ($array.Contains(value) && value != null && value != '')
        return true;
    else return false;
}
 
Array.prototype.Contains = function (val) {
    for (var i = 0; i < this.length; i++) {
        if (this[i] == val) {
            return true;
        }
    }
    return false;
};