salesRecord.js
10.5 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
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
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
/**
* 买卖记录页面
*/
var SalesRecord = function(){
var _withdraw_no;
var _his_entrust;
return {
tabChange : function(tab,content,selecedClass){
var $tab = $(tab);
$tab.find("a").eq(0).addClass(selecedClass);
$tab.find("a").on("click", function(){
var index= $(this).index();
$(this).addClass(selecedClass).siblings().removeClass(selecedClass);
$(content).children("div").eq(index).show().siblings().hide();
if(index == 0){
SalesRecord.queryEntrust();
}else if(index == 1){
SalesRecord.queryTransaction();
}else if(index == 2){
SalesRecord.queryWithdraw();
}
});
},
SelectChange : function(selectedId,tab1,tab2){
var selectVue=$("#"+selectedId).find("option:selected").val();
var $tab1=$("#"+tab1);
var $tab2=$("#"+tab2);
if(selectedId == "dealToday"){
SalesRecord.queryTransaction();
}
if(selectVue=="0"){
$tab1.show();
$tab2.hide();
}else{
$tab2.show();
$tab1.hide();
}
},
/**
* 用户当日委托查询
*/
queryEntrust : function(){
$.getJSON('/ec/entrust', function(data){
if(data != null && data.length > 0){
var text = new Array();
text.push("<tr><th>序号</th>");
text.push("<th>订单号</th>");
text.push("<th>订单日期</th>");
text.push("<th>订单时间</th>");
text.push("<th>订单状态</th>");
text.push("<th>藏品代码</th>");
text.push("<th>藏品名称</th>");
text.push("<th>下单价格</th>");
text.push("<th>下单数量</th>");
text.push("<th>成交价格</th>");
text.push("<th>成交数量</th>");
text.push("<th>交易属性</th></tr>");
for (var i = 0; i < data.length; i++) {
var entrust = data[i];
text.push("<tr><td>"+(i+1)+"</td>");
text.push("<td>"+entrust.entrust_no+"</td>");
text.push("<td>"+entrust.entrust_date+"</td>");
text.push("<td>"+entrust.entrust_time+"</td>");
text.push("<td>"+entrust.entrust_status+"</td>");
text.push("<td>"+entrust.otc_code+"</td>");
text.push("<td>"+entrust.otc_name+"</td>");
text.push("<td>"+Number(entrust.entrust_price).toMoney(2,'',',')+"</td>");
text.push("<td>"+entrust.entrust_amount+"</td>");
text.push("<td>"+Number(entrust.business_price).toMoney(2,'',',')+"</td>");
text.push("<td>"+entrust.business_amount+"</td>");
text.push("<td>"+entrust.otc_prop+"</td></tr>");
}
$("#entrust_info").html(text.join(''));
}
});
},
/**
* 用户当日成交查询
*/
queryTransaction : function(){
var select = $("#dealToday").val();
if(select == "0"){
$.getJSON('/ec/entrust/transaction', function(data){
if(data != null && data.length > 0){
var text = new Array();
text.push("<tr><th>序号</th>");
text.push("<th>成交时间</th>");
text.push("<th>藏品代码</th>");
text.push("<th>藏品名称</th>");
text.push("<th>成交价格</th>");
text.push("<th>成交数量</th>");
text.push("<th>成交编号</th>");
text.push("<th>成交金额</th>");
text.push("<th>成交状态</th>");
text.push("<th>交易属性</th></tr>");
for (var i = 0; i < data.length; i++) {
var transaction = data[i];
text.push("<tr><td>"+(i+1)+"</td>");
text.push("<td>"+transaction.business_time+"</td>");
text.push("<td>"+transaction.otc_code+"</td>");
text.push("<td>"+transaction.otc_name+"</td>");
text.push("<td>"+Number(transaction.business_price).toMoney(3,'',',')+"</td>");
text.push("<td>"+transaction.business_amount+"</td>");
text.push("<td>"+transaction.business_no+"</td>");
text.push("<td>"+transaction.business_balance+"</td>");
text.push("<td>"+transaction.real_status+"</td>");
text.push("<td>"+transaction.otc_prop+"</td></tr>");
}
$("#dealTodayTab1").html(text.join(''));
}
});
}else{
$.getJSON("/ec/entrust/transaction/total", function(data){
if(data != null && data.length > 0){
var text = new Array();
text.push("<tr><th>序号</th>");
text.push("<th>藏品代码</th>");
text.push("<th>藏品名称</th>");
text.push("<th>成交价格</th>");
text.push("<th>成交数量</th>");
text.push("<th>交易属性</th></tr>");
for (var i = 0; i < data.length; i++) {
var transaction = data[i];
text.push("<tr><td>"+(i+1)+"</td>");
text.push("<td>"+transaction.otc_code+"</td>");
text.push("<td>"+transaction.otc_name+"</td>");
text.push("<td>"+Number(transaction.average_price).toMoney(3,'',',')+"</td>");
text.push("<td>"+transaction.otc_prop+"</td></tr>");
}
$("#dealTodayTab2").html(text.join(''));
}
});
}
},
/**
* 撤单查询
*/
queryWithdraw : function(){
$.getJSON('/user/ec/reversibility', function(data){
if(data != null && data.length > 0){
var text = new Array();
text.push("<thead><tr><th>订单号</th>");
text.push("<th>订单日期</th>");
text.push("<th>订单时间</th>");
text.push("<th>订单状态</th>");
text.push("<th>藏品代码</th>");
text.push("<th>藏品名称</th>");
text.push("<th>下单价格</th>");
text.push("<th>下单数量</th>");
text.push("<th>成交价格</th>");
text.push("<th>成交数量</th>");
text.push("<th>交易属性</th>");
text.push("<th>操作</th></tr></thead>");
text.push("<tbody>");
for (var i = 0; i < data.length; i++) {
var entrust = data[i];
text.push("<tr><td>"+entrust.entrust_no+"</td>");
text.push("<td>"+entrust.entrust_date+"</td>");
text.push("<td>"+entrust.entrust_time+"</td>");
text.push("<td>"+entrust.entrust_status+"</td>");
text.push("<td>"+entrust.otc_code+"</td>");
text.push("<td>"+entrust.otc_name+"</td>");
text.push("<td>"+Number(entrust.entrust_price).toMoney(3,'',',')+"</td>");
text.push("<td>"+entrust.entrust_amount+"</td>");
text.push("<td>"+Number(entrust.business_price).toMoney(3,'',',')+"</td>");
text.push("<td>"+entrust.business_amount+"</td>");
text.push("<td>"+entrust.otc_prop+"</td>");
text.push("<td><a onclick='SalesRecord.withdrawDialog("+entrust.entrust_no+")'>撤单</a></td></tr>");
}
text.push("</tbody>");
$("#withdraw").html(text.join(''));
}
});
},
withdrawDialog : function(entrustNo){
$("#deleteRecord_text").html("委托编号="+entrustNo);
_withdraw_no = entrustNo;
easyDialog.open({
container : "deleteRecord_popup"
});
},
/**
* 撤单
*/
withdraw : function(){
easyDialog.close();
var entrustNo = _withdraw_no;
$.post("/user/withdraw", {entrustNo : entrustNo}, function(data){
if(data.resultCode == "0"){
$("#entrust_result").html("操作成功");
}else{
$("#entrust_result").html("操作失败");
}
easyDialog.open({
container : 'ensure'
});
SalesRecord.queryWithdraw();
}, "json");
},
/**
* 历史订单
*/
queryHisEntrust : function(){
$("#pageToolbar").Paging({pagesize: "${params.rows }", count: "${params._total}",
toolbar:true, current: Number("${params.page}"), callback:function(page, size, count) {
$.getJSON("/user/ec/transaction/his", {start_date : $("#start_date_DH").val(),
end_date : $("#end_date_DH").val(), page : page, rows : size}, function(data){
_his_entrust = data;
if(data != null && data.length > 0){
var text = new Array();
text.push("<tr><th> </th>");
text.push("<th>订单日期</th>");
text.push("<th>订单状态</th>");
text.push("<th>订单号</th>");
text.push("<th>藏品代码</th>");
text.push("<th>藏品名称</th>");
text.push("<th>下单价格</th>");
text.push("<th>下单数量</th>");
text.push("<th>成交价格</th>");
text.push("<th>成交数量</th>");
text.push("<th>交易属性</th></tr>");
for (var i = 0; i < data.length; i++) {
var entrust = data[i];
text.push("<tr><td>"+(i+1)+"</td>");
text.push("<td>"+entrust.entrust_date+"</td>");
text.push("<td>"+entrust.entrust_status+"</td>");
text.push("<td>"+entrust.entrust_no+"</td>");
text.push("<td>"+entrust.otc_code+"</td>");
text.push("<td>"+entrust.otc_name+"</td>");
text.push("<td>"+entrust.entrust_price+"</td>");
text.push("<td>"+entrust.entrust_amount+"</td>");
text.push("<td>"+entrust.business_price+"</td>");
text.push("<td>"+entrust.business_amount+"</td>");
text.push("<td>"+entrust.otc_prop+"</td></tr>");
}
$("#his_entrust").html(text.join(''));
}
});
}});
}
}
}();
$(function(){
var offset_left=$(".tab-slide").offset().left; //表格距离左边框距离
var offset_top=$(".tab-slide").offset().top;
SalesRecord.tabChange("#tab","#tabContent" ,"tab-seletced");
$("#start_date_DH").datepicker({
showOtherMonths: true,
dateFormat: "yy-mm-dd",
maxDate:-1,
defaultDate: -1
}).datepicker('widget').wrap('<div class="ll-skin-latoja"/>');
$("#end_date_DH").datepicker({
showOtherMonths: true,
dateFormat: "yy-mm-dd",
maxDate:-1,
defaultDate: -1
}).datepicker('widget');
$("#start_date_DR").datepicker({
showOtherMonths: true,
dateFormat: "yy-mm-dd",
maxDate:-1,
defaultDate: -1
}).datepicker('widget');
$("#end_date_DR").datepicker({
showOtherMonths: true,
dateFormat: "yy-mm-dd",
maxDate:-1,
defaultDate: -1
}).datepicker('widget');
$("#start_date_DS").datepicker({
showOtherMonths: true,
dateFormat: "yy-mm-dd",
maxDate:-1,
defaultDate: -1
}).datepicker('widget');
$("#end_date_DS").datepicker({
showOtherMonths: true,
dateFormat: "yy-mm-dd",
maxDate:-1,
defaultDate: -1
}).datepicker('widget');
/*
* 撤单table最后一列固定
*/
$("#table th:last-child,#table tr>td:last-child").width("60");
//固定最后一列位置
$("#table th:last-child,tr>td:last-child").css("left", offset_left+ $("#div_abroad").width() - $("#table td:last-child").width())
$("#table th:last-child").css("top", offset_top+45)
$("#table tr>td:last-child").each(function(index,item){
$(this).css("top", offset_top+77+index*30)
})
//补充一列
$td = $("<td style='width:" + $("#table th:last-child").width().toString() + "px'></td>");
$("#table tbody>tr>td:last-child").before($td);
SalesRecord.queryEntrust();
});