rationOldConfig.js
3.42 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
$(function(){
$('#record_count').keyup(rationOldConfig.calculateRecord);
/**立刻配售*/
var isSubmit = false;
$('#submit').click(function() {
rationOldConfig.calculateRecord();
var ration_count=$("#ration_count").val();//配售数量
var enableAmount=$("#enableAmount").html();//可配售数量
var enableBalance=$("#enableBalance").html();//可用余额
var record_fare=$("#record_fare").html();//配售金额
if(parseFloat(record_fare)>parseFloat(enableBalance)){
easyDialog.close({
container : 'easyDialogConfig'
});
easyDialog.open({
container : 'easyDialogBalanceWrapper'
});
return;
}
if(parseInt(ration_count)==0){
rationOldConfig.showMessage('配售数量不能为0');
$('#record_count').focus();
return;
}
if(parseInt(ration_count)>parseInt(enableAmount)){
rationOldConfig.showMessage('配售数量不能大于可配售数量');
$('#record_count').focus();
return;
}
if (isSubmit == true) {
showMessage('请勿重复提交。如需继续配售,请刷新页面后重试。');
return;
}
isSubmit = true;
$.post('/user/ration/old/qualityRecordSave', $('#configForm').serializeArray(), function(data) {
if (data.success == true) {
easyDialog.open({
container : 'easyDialogSuccessWrapper'
});
} else {
rationOldConfig.showMessage(data.data);
isSubmit = false;
}
});
});
})
/**
*
*/
var rationOldConfig = function() {
return {
formatNumberRgx : function(num) {
var parts = num.toString().split(".");
parts[0] = parts[0].replace(/\B(?=(\d{3})+(?!\d))/g, ",");
return parts.join(".");
},
/** 配售信息 */
rationConfig : function(tdid,configId) {
var configId=$("#configId").val(configId);
var otcCode=$("#"+tdid).parent().find("td:eq(1)").html();
$("#otcCode").html("<b>"+otcCode+"</b>");
var otcName=$("#"+tdid).parent().find("td:eq(2)").html();
$("#otcName").html("<b>"+otcName+"</b>");
var price=$("#"+tdid).parent().find("td:eq(5)").html();
$("#price").html(price);
var qualityAmount=$("#"+tdid).parent().find("td:eq(3)").html();
var ration_amount=$("#"+tdid).parent().find("td:eq(4)").html();
var enableAmount=parseInt(qualityAmount)-parseInt(ration_amount);
$("#enableAmount").html(enableAmount);
$("#ration_count").val(enableAmount);
rationOldConfig.calculateRecord();
easyDialog.open({
container : 'easyDialogConfig'
});
},
/**
* 关闭窗口
*/
closeWin:function(){
easyDialog.close({
container : 'easyDialogConfig'
});
$('#configForm')[0].reset();
$('#record_fare').html("");
},
/**计算配售价格*/
calculateRecord:function() {
var ration_count = $('#ration_count').val();
if (isNaN(ration_count)) {
return;
}
var enableAmount=$('#enableAmount').html();
if(parseFloat(ration_count)>parseFloat(enableAmount)){
$('#ration_count').val(enableAmount);
ration_count=enableAmount;
}
var patrn=/^([1-9]\d*|0)(\.\d*[1-9])?$/;
if (!patrn.exec(ration_count)) {
$('#ration_count').val('0');
ration_count=0;
}
var record_fare = new Number(ration_count * $('#price').html());
$('#record_fare').html(record_fare.toFixed(2));
},
/**充值*/
payButton:function(){
location.href="/user/pay/prePay";
},
/** 显示提示信息 */
showMessage:function(msg) {
$('#dialog-content').html(msg);
easyDialog.open({
container : 'easyDialogWrapper'
});
}
}
}();