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