提交 | 用户 | 时间
|
58d006
|
1 |
/** |
A |
2 |
* date: |
|
3 |
* author: neeler |
|
4 |
*/ |
|
5 |
|
|
6 |
//test data start |
|
7 |
// var data_getList = Mock.mock('/company/getList.htm', {code: 0, 'list|5-20': [{id: 'id', companyNo: 'companyNo', note: 'note', name: 'name'}], pages: 12}) |
|
8 |
// var data_doDel = Mock.mock('/company/delItem.htm', {code: 0, errmsg: 'errmsg'}) |
|
9 |
// var data_doSave = Mock.mock('/company/saveItem.htm', {code: 0, errmsg: 'errmsg'}) |
|
10 |
//test data end |
|
11 |
|
|
12 |
var HOSTNAME = window.location.hostname; |
|
13 |
|
|
14 |
window.I = { |
|
15 |
id: $('#_id').val(), |
|
16 |
bsNo: $('#_bsNo').val(), |
1c4e40
|
17 |
printBtn: $('#printBtn'), |
A |
18 |
detailModal: $("#modal"), |
58d006
|
19 |
} |
A |
20 |
|
|
21 |
var ViewModel = function() { |
|
22 |
var self = this; |
|
23 |
self.list = ko.observableArray(); |
|
24 |
self.totalMZ = ko.observable(0); |
|
25 |
self.totalJZ = ko.observable(0); |
|
26 |
self.vehicleLoadweight = ko.observable(0); |
|
27 |
self.overWeight = ko.observable(0); |
1c4e40
|
28 |
self.remark = ko.observable(''); |
58d006
|
29 |
self.isAdmin = ko.observable(typeof(parent.G) != 'undefined' ? parent.G.isAdmin : false); |
A |
30 |
self.del = function(item) { |
|
31 |
delConfirm(item); |
1c4e40
|
32 |
} |
A |
33 |
self.addRemark = function(item) { |
|
34 |
I.detailModal.modal('show'); |
58d006
|
35 |
} |
A |
36 |
} |
|
37 |
|
|
38 |
$(function () { |
|
39 |
window.vm = new ViewModel(); |
|
40 |
ko.applyBindings(vm); |
|
41 |
I.numberplates = $('#_numberplates').val(); |
|
42 |
getVehicleDetails(I.bsNo); |
|
43 |
pageInit(); |
|
44 |
autoHeight(); |
|
45 |
// getVehicleList(); |
|
46 |
}); |
|
47 |
|
|
48 |
function pageInit() { |
|
49 |
I.printBtn.click(function (e) { |
|
50 |
e.preventDefault(); |
|
51 |
newTab(I.numberplates); |
|
52 |
}); |
1c4e40
|
53 |
$("#confirmBtn").click(function (e) { |
A |
54 |
e.preventDefault(); |
|
55 |
saveRemark(); |
|
56 |
}) |
|
57 |
$("#clearSortBtn").click(function (e){ |
|
58 |
e.preventDefault(); |
|
59 |
I.detailModal.modal('hide'); |
|
60 |
}) |
|
61 |
getRemarkDetail(); |
|
62 |
} |
|
63 |
function saveRemark() { |
|
64 |
$.post("/vehicle/saveRemark.htm", {numberplates: I.numberplates, bsNo: I.bsNo, remark: vm.remark()}, |
|
65 |
function (data, textStatus, jqXHR) { |
|
66 |
if(data.code == 0) { |
|
67 |
parent.showErrmsg('保存成功!'); |
|
68 |
}else { |
|
69 |
swal({title:'',text:data.errmsg,type:'error',confirmButtonText:'确定'}); |
|
70 |
} |
|
71 |
}); |
|
72 |
} |
|
73 |
function getRemarkDetail() { |
|
74 |
$.post("/vehicle/getDetail.htm", {numberplates: I.numberplates, bsNo: I.bsNo}, |
|
75 |
function (data, textStatus, jqXHR) { |
|
76 |
if(data.code == 0) { |
|
77 |
if(data.item) vm.remark(data.item.remark); |
|
78 |
}else { |
|
79 |
swal({title:'',text:data.errmsg,type:'error',confirmButtonText:'确定'}); |
|
80 |
} |
|
81 |
}); |
58d006
|
82 |
} |
A |
83 |
|
|
84 |
function getVehicleDetails(bsNo) { |
|
85 |
vm.list.removeAll(); |
|
86 |
var mz = 0; |
|
87 |
var jz = 0; |
|
88 |
$.post("/task/getVehicleDetails.htm", {keyword: bsNo}, |
|
89 |
function (data, textStatus, jqXHR) { |
|
90 |
if (data.code >= 1) { |
|
91 |
//parent.showErrmsg(data.errmsg); |
|
92 |
swal({title:'',text:data.errmsg,type:'error',confirmButtonText:'确定'}); |
|
93 |
return; |
|
94 |
} |
|
95 |
if (data.code == 0) { |
|
96 |
if (isList(data.list)) { |
|
97 |
$.each(data.list, function (index, value) { |
|
98 |
mz += value.tdmx_mz; |
|
99 |
jz += value.tdmx_jz; |
|
100 |
vm.list.push(value); |
|
101 |
}); |
|
102 |
} |
|
103 |
vm.totalMZ(mz.toFixed(3)); |
|
104 |
vm.totalJZ(jz.toFixed(3)); |
|
105 |
} |
|
106 |
}, |
|
107 |
"json" |
|
108 |
); |
|
109 |
} |
|
110 |
|
|
111 |
function getVehicleList() { |
|
112 |
$.post("/business/getVehicleList.htm", { |
|
113 |
companyNo: |
|
114 |
vm.isAdmin() ? '' : (typeof(parent.G) != 'undefined' ? parent.G.loginCompanyNo : 'ABCDEFG'), |
|
115 |
vehicleId:'111111' |
|
116 |
}, |
|
117 |
function (data, textStatus, jqXHR) { |
|
118 |
I.VDB = []; |
|
119 |
if (data.code >= 1) { |
|
120 |
swal({title:'',text:data.errmsg,type:'error',confirmButtonText:'确定'}); |
|
121 |
return; |
|
122 |
} |
|
123 |
if (data.code == 0) { |
|
124 |
if (isList(data.list)) { |
|
125 |
$.each(data.list, function (index, value) { |
|
126 |
value.indx = index + ''; |
|
127 |
value.lastweight = ''; |
|
128 |
if ($.isNumeric(value.loadweight) && $.isNumeric(value.fdweight)) { |
|
129 |
value.lastweight = (parseFloat(value.loadweight) - parseFloat(value.fdweight)).toFixed(3); |
|
130 |
} |
|
131 |
if (value.vehicleId === I.numberplates) { |
|
132 |
vm.vehicleLoadweight(value.loadweight); |
|
133 |
} |
|
134 |
I.VDB.push(value); |
|
135 |
}); |
|
136 |
} |
|
137 |
// updateVList(); |
|
138 |
return; |
|
139 |
} |
|
140 |
}, |
|
141 |
"json" |
|
142 |
); |
|
143 |
} |
|
144 |
|
|
145 |
function newTab(vehicleId) { |
|
146 |
parent.closableTab.addTab({ |
|
147 |
'id': vehicleId, |
|
148 |
'name': '打印', |
|
149 |
// 'url': encodeURI('http://' + HOSTNAME + ':9088/ReportServer?reportlet=print%2Fprint_fd_xstd.cpt&vehicleId=' + vehicleId), |
|
150 |
'url': encodeURI('/task/Printfdxq.htm?bsNo=' + I.bsNo), |
|
151 |
'closable': true |
|
152 |
}); |
|
153 |
} |
|
154 |
|
|
155 |
function autoHeight() { |
|
156 |
$('.page-content').css('min-height', $(parent.window).height() - 159); |
1c4e40
|
157 |
$('.table-responsive').css('height', $(parent.window).height() - 239); |
58d006
|
158 |
} |
A |
159 |
|
|
160 |
function delConfirm(item) { |
|
161 |
$("#modalContent").html('确定要删除【提单编号:' + item.tdmx_tdbh+'批次号:' +item.tdmx_pch +'】吗?'); |
|
162 |
$("#dialog-confirm").removeClass('hide').dialog({ |
|
163 |
resizable: false, |
|
164 |
width: '320', |
|
165 |
modal: true, |
|
166 |
title: "<div class='widget-header'><h4 class='smaller'><i class='ace-icon fa fa-exclamation-triangle red'></i>确认信息</h4></div>", |
|
167 |
title_html: true, |
|
168 |
position: { my: "center", at: "center", of: window }, |
|
169 |
buttons: [ |
|
170 |
{ |
|
171 |
html: "<i class='ace-icon fa fa-trash-o bigger-110'></i> 确定", |
|
172 |
"class" : "btn btn-danger btn-minier", |
|
173 |
click: function() { |
|
174 |
$( this ).dialog( "close" ); |
|
175 |
doDel(item); |
|
176 |
} |
|
177 |
} |
|
178 |
, |
|
179 |
{ |
|
180 |
html: "<i class='ace-icon fa fa-times bigger-110'></i> 取消", |
|
181 |
"class" : "btn btn-minier", |
|
182 |
click: function() { |
|
183 |
$( this ).dialog( "close" ); |
|
184 |
} |
|
185 |
} |
|
186 |
] |
|
187 |
}); |
|
188 |
} |
|
189 |
|
|
190 |
function doDel(item) { |
|
191 |
if (!!I.AjaxDelItem) return; |
|
192 |
I.AjaxDelItem = true; |
|
193 |
$.post('/task/delbypch.htm', {bsno:I.bsNo,tdno: item.tdmx_tdbh,pch:item.tdmx_pch,cph:$('#_numberplates').val()}, function(data, textStatus, xhr) { |
|
194 |
I.AjaxDelItem = false; |
|
195 |
if (data.code >= 1) { |
|
196 |
//parent.showErrmsg(data.errmsg); |
|
197 |
swal({title:'',text:data.errmsg,type:'error',confirmButtonText:'确定'}); |
|
198 |
return; |
|
199 |
} |
|
200 |
if (data.code == 0) { |
|
201 |
vm.list.remove(item); |
|
202 |
// getVehicleDetails(item.tdmx_pch); |
|
203 |
parent.showErrmsg('删除成功!'); |
|
204 |
I.modal.modal('hide'); |
|
205 |
return; |
|
206 |
} |
|
207 |
}, 'json'); |
|
208 |
} |