Newer
Older
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
var $lastEditRow = null;
jQuery(function () {
//document.getElementById("lstDelivery").onchange = LoadList;
LoadList();
$(".button").bind("click", function () {
var checkData = "";
var a = "";
$(".datalist tr").each(function () {
var amount = $($(this).children().get(3)).find("input").val();
if (amount < 0 || amount > 0) {
var goodsID = $($(this).children().get(3)).attr("goodsID");
var yuan = $($(this).children().get(3)).attr("DeliveryID");
var SupplierID = $($(this).children().get(3)).attr("SupplierID");
checkData += goodsID + "," + yuan + "," + amount + "," + SupplierID + "|";
}
if (amount == 0) {
var goodsID = $($(this).children().get(3)).attr("goodsID");
var yuan = $($(this).children().get(3)).attr("DeliveryID");
var SupplierID = $($(this).children().get(3)).attr("SupplierID");
checkData += goodsID + "," + yuan + "," + amount + "," + SupplierID + "|";
}
});
if (checkData == "") {
alert("不能提交空数据");
return false;
}
if (!confirm("确定要提交吗?")) {
return false;
}
var loadUrl = "AjaxPages/AjaxCheckStockInfo.ashx?rnd=" + Math.random();
$(this).attr("disabled", "true");
$.post(loadUrl, { Action: "TJ", DeliveryID: $("#lstDelivery").val(), CheckData: checkData,Nian:$("#lstNian").val(),Yue:$("#lstYue").val()
}, function (data) {
AjaxHandlerCallback(data);
}, "json");
return false;
});
});
function LoadList() {
var deliveryID = $("#lstDelivery").val();
$.ajax({
type: "POST",
url: "../AjaxPages/AjaxCheckStockInfo.ashx",
dataType: "html",
data: {
Action: "GetList",
OrderID: $("#hfOrderID").val(),
SupplierID: $("#hfSupplierID").val(), //供应商ID
CreateDate: $("#hfCreateDate").val(),
DeliveryID: deliveryID
},
success: function (data) {
$("#tblGoods").empty(); //清空原有表里HTML
$("#tblGoods").html(data);
$("#tblGoods tr:odd").addClass("odd"); //表格样式
$(".datalist tr").each(function () {
var $editTextbox = $("<input type=\"text\" class=\"editTextbox\" />");
var $theCell = $($(this).children().get(3));
$editTextbox.attr("goodsID", $theCell.attr("goodsID"));
$editTextbox.attr("yuan", $theCell.attr("yuan"));
$editTextbox.attr("acount", $theCell.attr("acount"));
if ($theCell.attr("price") != 0.00) {
$theCell.empty().append($editTextbox);
}
$theCell.bind("click", function () {
$editTextbox.select();
})
});
}
});
}
function BindSwitchRow(event) {
var $theInput = $(event.srcElement)
var $theCell = $theInput.parents("td");
var $currRow = $theCell.parents("tr");
var cellIndex = $theCell.cellIndex;
if (event.shiftKey) {
if (event.keyCode == 9) {
var $prevRow = $currRow.prev("tr");
if ($prevRow.index() >= 0) {
FocusCellInput($prevRow, cellIndex);
}
return false;
}
}
else {
if (event.keyCode == 9 || event.keyCode == 13 || event.keyCode == 40) {
//Tab或Enter直接进入下一行
var $nextRow = $currRow.next("tr");
FocusCellInput($nextRow, cellIndex);
return false;
}
else if (event.keyCode == 38) {
var $prevRow = $currRow.prev("tr");
if ($prevRow.index() >= 0) {
FocusCellInput($prevRow, cellIndex);
}
return false;
}
}
}
function FocusCellInput(theRow, cellIndex) {
$($(theRow).children().get(cellIndex)).find("input[type='text']").focus();
}
//设为行编辑状态
function SetActive(event) {
var $theInput = $(event.srcElement);
var $currRow = $theInput.parents("tr");
if ($lastEditRow != null) {
$lastEditRow.removeClass("ractive").removeClass("rover");
}
$lastEditRow = $currRow;
$lastEditRow.addClass("ractive").addClass("rover");
$theInput.select();
}
function FireInputValChanged(event) {
var $theInput = $(event.srcElement);
var $currRow = $theInput.parents("tr");
var valAmount = parseFloat($($currRow.children().get(2)).text());
var valCheckedAmount = parseFloat($($currRow.children().get(3)).text());
var valCheckAmount = parseFloat($theInput.val());
var $restAmountCell = $($currRow.children().get(5));
var valRestAmount = valAmount - valCheckedAmount - valCheckAmount;
if (valRestAmount == 0) {
$restAmountCell.text("--.--");
}
else {
$restAmountCell.text(valRestAmount.toFixed(2));
}
}
function AjaxHandlerCallback(data) {
if (data.Action == "TJ") {
alert(data.msg);
if (data.status == "success") {
window.location.reload();
}
}
}