position.js
3.98 KB
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
/**
* 持仓列表
*/
var Position = function($) {
return {
init : function() {
var pickType = $(':radio[name="pickType"]:checked').val();
Position.initPickNum(pickType)
$('input[type=radio][name=pickType]').change(function() {
Position.initPickNum(this.value)
});
/** 普通提货 */
$('#btnNormalPick').click(function() {
var pickType = $(':radio[name="pickType"]:checked').val();
if (pickType == null) {
$.alert('请选择提货方式');
return;
}
Position.pick();
});
/** 封装提货 */
$('#btnPackPick').click(function() {
var packageId = $('#hidPackageId').val();
var pickType = $(':radio[name="pickType"]:checked').val();
if (pickType == null) {
$.alert('请选择提货方式');
return;
}
if (packageId == '') {
$.alert('请选择包装方式');
return;
}
Position.pick();
});
/** 网点提货 */
$('#btnWarehousePick').click(function() {
Position.pick(3);
});
//选择封装方式
$("#positionGiftMethod").find("li").each(function() {
var li = this;
$(li).click(function() {
$(li).addClass("selected").siblings().removeClass("selected");
$('#hidPackageId').val($(li).val());
});
});
$('.pickPacks').change(function() {
$(this).parent().next().find('span').text($(this).find('option:selected').val());
});
},
initPickNum:function(pickType){
var occurAmounts = $('#pickTable').find('input[name="occurAmount"]');
if(pickType==6){
for (var i = 0; i < occurAmounts.length; i++) {
var enableAmount = $(occurAmounts[i]).next('span').text();
$(occurAmounts[i]).val(parseInt(enableAmount))
$(occurAmounts[i]).attr("disabled",'disabled')
}
$("#aaetip1").css('display','block')
$("#aaetip2").css('display','block')
$("#btnNormalPick").val("确认提货")
}else{
for (var i = 0; i < occurAmounts.length; i++) {
//$(occurAmounts[i]).val('')
//$(occurAmounts[i]).removeAttr("disabled")
}
$("#aaetip1").css('display','none')
$("#aaetip2").css('display','none')
$("#btnNormalPick").val("下一步")
}
},
/** 确认提货 */
pick : function(pickType) {
var submitUrl;
var picks = new Array();
var occurAmounts = $('#pickTable').find('input[name="occurAmount"]');
var pickPacks = $('.pickPacks');
for (var i = 0; i < occurAmounts.length; i++) {
var occurAmount = $(occurAmounts[i]).val();
var rows = $('#pickTable').find('tr');
var tds = $(rows[i + 1]).find('td');
var pick = {};
var enableAmount = $(occurAmounts[i]).next('span').text();
var usefulAmount = $(occurAmounts[i]).next('span').next('span').text();
var pickPack = $(pickPacks.get(i)).find('option:selected');
if (occurAmount == '') {
continue;
}
if (isNaN(occurAmount)) {
$.alert('藏品[' + $(tds[0]).text() + ']提货数量应为数字');
return;
}
if (occurAmount.indexOf('.') > 0) {
$.alert('藏品[' + $(tds[0]).text() + ']提货数量应为整数');
return;
}
if (parseInt(occurAmount) <= 0) {
$.alert('藏品[' + $(tds[0]).text() + ']提货数量应大于0');
return;
}
if (parseInt(occurAmount) > parseInt(enableAmount)) {
$.alert('藏品[' + $(tds[0]).text() + ']提货数量不能大于可提数量');
return;
}
//网点自提
if (pickType == 3 && parseInt(occurAmount) > parseInt(usefulAmount)) {
$.alert('藏品[' + $(tds[0]).text() + ']提货数量不能大于库存总量');
return;
}
pick.otcCode = $(tds[0]).text();
pick.otcName = $(tds[1]).text();
pick.enableAmount = $(tds[2]).text();
pick.occurAmount = occurAmount;
pick.packType = pickPack.text();
pick.packFee = pickPack.val();
picks.push(pick);
}
if (picks.length == 0) {
$.alert('请输入提货数量');
return;
}
picks = JSON.stringify(picks);
$('#hidApplys').val(picks);
$('#pickForm').submit();
}
}
}(jQuery);
$(function() {
Position.init();
});