提交 | 用户 | 时间
|
58d006
|
1 |
/** |
A |
2 |
* date: |
|
3 |
* author: neeler |
|
4 |
*/ |
|
5 |
|
|
6 |
//test data start |
|
7 |
// var data_getList = Mock.mock('/business/getList.htm', {code: 0, 'list|5-20': [{td_companyName: 'td_companyName', td_tdbh: 'td_tdbh', td_djrq: 'td_djrq', td_bmbh: 'td_bmbh', td_bmmc: 'td_bmmc', td_khmc: 'td_khmc', td_bz: 'td_bz', td_zdr: 'td_zdr', td_tdls: 'td_tdls', td_ywrq: 'td_ywrq', td_shdd: 'td_shdd', td_wfds: 1, td_wfdl: 1.001, td_shsj: 'td_shsj', companyName: 'companyName'}],pages: 12}) |
|
8 |
// var data_getVehicleList = Mock.mock('/business/getVehicleList.htm', {code: 0, 'list|5-30': [{vehicleId: 'vehicleId', feature: 'feature', note: 'note', fdnum: 'fdnum', fdweight: '4.551', vehicleweight: 'vehicleweight', loadweight: '51.111', driver: 'driver', phone: 'phone'}]}) |
|
9 |
// var data_validVehicle = Mock.mock('/business/validVehicle.htm', {code: 0, errmsg: '车牌号不能使用!'}) |
|
10 |
// var data_doBindByList = Mock.mock('/business/doBindByList.htm', {code: 0, }) |
|
11 |
// var data_doUnbindByList = Mock.mock('/business/doUnbindByList.htm', {code: 0, }) |
|
12 |
// var data_doDel = Mock.mock('/company/delItem.htm', {code: 0, errmsg: 'errmsg'}) |
|
13 |
// var data_doSave = Mock.mock('/company/saveItem.htm', {code: 0, errmsg: 'errmsg'}) |
|
14 |
//test data end |
|
15 |
|
|
16 |
var TYPE = [ |
|
17 |
{key: '提单编号', value: 'tdbh'}, |
|
18 |
{key: '客户名称', value: 'khmc'}, |
|
19 |
{key: '收货地点', value: 'shdd'}, |
|
20 |
{key: '制单部门', value: 'zdbm'}, |
|
21 |
{key: '制单人', value: 'zdr'}, |
|
22 |
{key: '发票编号', value: 'fpbh'} |
|
23 |
] |
|
24 |
|
|
25 |
var SORT = [ |
|
26 |
{key: '提单编号', value: 'td_tdbh', visible: ko.observable(true)}, |
|
27 |
{key: '客户名称', value: 'td_khmc', visible: ko.observable(true)}, |
|
28 |
{key: '收货地点', value: 'td_shdd', visible: ko.observable(true)}, |
|
29 |
{key: '未分单数量', value: 'td_wfdsl', visible: ko.observable(true)}, |
|
30 |
{key: '未分单重量', value: 'td_wfdzl', visible: ko.observable(true)}, |
|
31 |
{key: '制单时间', value: 'td_djrq', visible: ko.observable(true)}, |
|
32 |
{key: '制单部门', value: 'td_bmmc', visible: ko.observable(true)}, |
|
33 |
{key: '制单人', value: 'td_zdr', visible: ko.observable(true)}, |
|
34 |
// {key: '业务日期', value: 'ywrq', visible: ko.observable(true)}, |
|
35 |
{key: '提单类型', value: 'td_ztbz', visible: ko.observable(true)} |
|
36 |
] |
|
37 |
|
|
38 |
// {key: '提单编号', target: 'tdbh', result: ko.observable('cancel')}, |
|
39 |
|
|
40 |
var Obj = { |
|
41 |
vehicleId: '豫A', |
|
42 |
driver: '', |
|
43 |
phone: '', |
|
44 |
IDNum: '', |
|
45 |
vehicleweight: '', |
|
46 |
loadweight: '', |
|
47 |
note: '', |
|
48 |
feature: '' |
|
49 |
} |
|
50 |
|
|
51 |
window.I = { |
|
52 |
PZ: 30, |
|
53 |
keyword: $('#keyword'), |
|
54 |
searchBtn: $('.searchBtn'), |
|
55 |
moreSearchCondition: $('#moreSearchCondition'), |
|
56 |
searchBox: $('#searchBox'), |
|
57 |
sDate: $('#sDate'), |
|
58 |
eDate: $('#eDate'), |
|
59 |
sortBtn: $('#sortBtn'), |
|
60 |
modal: $('#modal'), |
|
61 |
clearSortBtn: $('#clearSortBtn'), |
|
62 |
vehicleBtn: $('#vehicleBtn'), |
|
63 |
vehicleModal: $('#vehicleModal'), |
|
64 |
refreshVehicleBtn: $('#refreshVehicleBtn'), |
|
65 |
vehicleKeyword: $('#vehicleKeyword'), |
|
66 |
searchVehicleBtn: $('#searchVehicleBtn'), |
|
67 |
vehicleBindBtn: $('#vehicleBindBtn'), |
|
68 |
addTempVehicle: $('#addTempVehicle'), |
|
69 |
tempVehicleModal: $('#tempVehicleModal'), |
|
70 |
tempVehicleBindBtn: $('#tempVehicleBindBtn'), |
|
71 |
unbindBtn: $('#unbindBtn'), |
|
72 |
btwcSign:$('#wcSign'), |
|
73 |
ssortBtn:$('#searchSortBtn'), |
|
74 |
closefdModel: $('#closefdModel'), |
|
75 |
fdqxclosefdBtn: $('#fdqxclosefdBtn'), |
|
76 |
fdqxopenfdBtn: $('#fdqxopenfdBtn'), |
|
77 |
fdqxclosefdmBtn: $('#fdqxclosefdmBtn') |
|
78 |
} |
|
79 |
|
|
80 |
var ViewModel = function() { |
|
81 |
var self = this; |
|
82 |
self.keyword = ko.observable(); |
|
83 |
self.o = ko.observable(ko.mapping.fromJS(Obj)); |
|
84 |
self.list = ko.observableArray(); |
|
85 |
self.tList = ko.observableArray(); |
|
86 |
self.sList = ko.observableArray(TYPE); |
|
87 |
self.oList = ko.observableArray(SORT); |
|
88 |
self.soList = ko.observableArray(); |
|
89 |
self.companyNo = ko.observable(); |
|
90 |
self.type = ko.observable(); |
|
91 |
self.isAdmin = ko.observable(typeof(parent.G) != 'undefined' ? parent.G.isAdmin : false); |
|
92 |
|
|
93 |
self.edit = function(item) { |
|
94 |
newTab(item); |
|
95 |
} |
|
96 |
self.print=function(item){ |
|
97 |
// console.log(item.td_tdbh); |
|
98 |
newPrintTab(item.td_tdbh); |
|
99 |
} |
|
100 |
self.addSort = function (item) { |
|
101 |
addSort(item); |
|
102 |
} |
|
103 |
self.removeSort = function (item) { |
|
104 |
removeSort(item); |
|
105 |
} |
|
106 |
self.selectedNum = ko.observable(0); |
|
107 |
self.selectedPZ = ko.observable(0); |
|
108 |
self.fendanChoose=function(){ |
|
109 |
if($('#wcSign').val()==1){//分单完成 |
|
110 |
$('#vehicleBtn').hide(); |
|
111 |
$('#unbindBtn').show(); |
|
112 |
$('#fdqxclosefdBtn').hide(); |
|
113 |
$('#fdqxopenfdBtn').hide(); |
|
114 |
self.selectedNum(0); |
|
115 |
self.selectedPZ(0); |
|
116 |
self.fdqxbgType(true); |
|
117 |
}else if($('#wcSign').val()==0){//未分单完成 |
|
118 |
$('#vehicleBtn').show(); |
|
119 |
$('#unbindBtn').show(); |
|
120 |
$('#fdqxclosefdBtn').show(); |
|
121 |
$('#fdqxopenfdBtn').hide(); |
|
122 |
self.selectedNum(0); |
|
123 |
self.selectedPZ(0); |
|
124 |
self.fdqxbgType(true); |
|
125 |
}else{//已关闭 |
|
126 |
$('#vehicleBtn').hide(); |
|
127 |
$('#unbindBtn').hide(); |
|
128 |
$('#fdqxclosefdBtn').hide(); |
|
129 |
$('#fdqxopenfdBtn').show(); |
|
130 |
self.selectedNum(0); |
|
131 |
self.selectedPZ(0); |
|
132 |
self.fdqxbgType(false); |
|
133 |
} |
|
134 |
doOpen(); |
|
135 |
} |
|
136 |
|
|
137 |
|
|
138 |
self.vList = ko.observableArray(); |
|
139 |
|
|
140 |
self.fdqxbgType=ko.observable(true); |
|
141 |
self.fdqxvehcileId=ko.observable(); |
|
142 |
|
|
143 |
self.fdqxdriver=ko.observable(); |
|
144 |
self.fdqxphone=ko.observable(); |
|
145 |
|
|
146 |
//厂区 |
|
147 |
self.cqVal=ko.observable(0); |
|
148 |
self.cqList=ko.observableArray(); |
|
149 |
self.cqchange=function(){ |
|
150 |
doOpen(); |
|
151 |
} |
|
152 |
self.change=function(){ |
|
153 |
doOpen(); |
|
154 |
} |
|
155 |
} |
|
156 |
|
|
157 |
$(function () { |
|
158 |
window.vm = new ViewModel(); |
|
159 |
ko.applyBindings(vm); |
|
160 |
I.sDate.val(new Date((new Date().getTime() - 30*24*3600*1000)).Format('yyyy-MM-dd')); |
|
161 |
I.eDate.val(new Date().Format('yyyy-MM-dd')); |
|
162 |
if (vm.isAdmin()) { |
|
163 |
getCompanyList(); |
|
164 |
} |
|
165 |
getVehicleList(); |
|
166 |
getcqList(); |
|
167 |
autoHeight(); |
|
168 |
// doOpen(); |
|
169 |
pageInit(); |
|
170 |
}); |
|
171 |
|
|
172 |
function pageInit() { |
|
173 |
I.unbindBtn.click(function (e) { |
|
174 |
e.preventDefault(); |
|
175 |
if ($('.bitem.info').length) { |
|
176 |
// doUnbindByList(getSelectBiz()); |
|
177 |
validMessage('确定要取消配车吗?', doUnbindByList, getSelectBiz()); |
|
178 |
} else { |
|
179 |
parent.showErrmsg('请选择一个提单!'); |
|
180 |
} |
|
181 |
}); |
|
182 |
I.tempVehicleBindBtn.click(function (e) { |
|
183 |
e.preventDefault(); |
|
184 |
if (valid()) { |
|
185 |
validVehicle(); |
|
186 |
} |
|
187 |
}); |
|
188 |
I.addTempVehicle.click(function (e) { |
|
189 |
e.preventDefault(); |
|
190 |
vm.o(ko.mapping.fromJS(Obj)); |
|
191 |
I.vehicleModal.modal('hide'); |
|
192 |
I.tempVehicleModal.modal('show'); |
|
193 |
}); |
|
194 |
I.tempVehicleModal.on('hidden.bs.modal', function (e) { |
|
195 |
clearError(); |
|
196 |
}); |
|
197 |
I.vehicleBindBtn.click(function (e) { |
|
198 |
e.preventDefault(); |
|
199 |
if ($('.vitem.info').length) { |
|
200 |
doVehicleBind(); |
|
201 |
} else { |
|
202 |
parent.showErrmsg('请选择一个车辆!'); |
|
203 |
} |
|
204 |
}); |
|
205 |
I.vehicleKeyword.keyup(function (e) { |
|
206 |
// updateVList(); |
|
207 |
getVehicleList(); |
|
208 |
}); |
|
209 |
I.searchVehicleBtn.click(function (e) { |
|
210 |
e.preventDefault(); |
|
211 |
getVehicleList(); |
|
212 |
// updateVList(); |
|
213 |
}); |
|
214 |
I.refreshVehicleBtn.click(function (e) { |
|
215 |
e.preventDefault(); |
|
216 |
getVehicleList(); |
|
217 |
}); |
|
218 |
I.vehicleBtn.click(function (e) { |
|
219 |
e.preventDefault(); |
|
220 |
if ($('.bitem.info').length) { |
|
221 |
I.vehicleModal.modal('show'); |
|
222 |
} else { |
|
223 |
parent.showErrmsg('请选择一个提单!'); |
|
224 |
} |
|
225 |
}); |
|
226 |
I.sortBtn.click(function (e) { |
|
227 |
e.preventDefault(); |
|
228 |
I.modal.modal('show'); |
|
229 |
}); |
|
230 |
I.clearSortBtn.click(function (e) { |
|
231 |
e.preventDefault(); |
|
232 |
vm.soList.removeAll(); |
|
233 |
$.each(vm.oList(), function (index, value) { |
|
234 |
value.visible(true); |
|
235 |
}); |
|
236 |
}); |
|
237 |
I.ssortBtn.click(function(e){ |
|
238 |
doOpen(); |
|
239 |
}); |
|
240 |
$('.main-table').scroll(function() { |
|
241 |
$('.th').css('top', $(this).scrollTop()); |
|
242 |
}) |
|
243 |
I.moreSearchCondition.click(function(event) { |
|
244 |
if ($(this).hasClass('active')) { |
|
245 |
I._complexSearch = false; |
|
246 |
$(this).removeClass('active'); |
|
247 |
$('i', $(this)).addClass('fa-chevron-down').removeClass('fa-chevron-up'); |
|
248 |
I.searchBox.slideUp(); |
|
249 |
} else { |
|
250 |
I._complexSearch = true; |
|
251 |
$(this).addClass('active'); |
|
252 |
$('i', $(this)).removeClass('fa-chevron-down').addClass('fa-chevron-up'); |
|
253 |
I.searchBox.slideDown(); |
|
254 |
} |
|
255 |
}); |
|
256 |
I.searchBtn.click(function(event) { |
|
257 |
doOpen(); |
|
258 |
}); |
|
259 |
// I.btwcSign.(function(event){ |
|
260 |
// if(){ |
|
261 |
// doOpen(); |
|
262 |
// } |
|
263 |
// }) |
|
264 |
I.keyword.on(ISIE ? 'keydown' : 'keyup', function (event) { |
|
265 |
if (event.keyCode == 13) { |
|
266 |
doOpen(); |
|
267 |
} |
|
268 |
}); |
|
269 |
I.fdqxclosefdBtn.click(function(event){ |
|
270 |
//判断选择了多个只能选择一个 |
|
271 |
if($('.bitem.info').length>1){ |
|
272 |
swal({title:'',text:'不能选择多个销售提单同时关闭,请选择一个销售提单!',type:'error',confirmButtonText:'确定'}); |
|
273 |
return ; |
|
274 |
} |
|
275 |
if($('.bitem.info').length<1){ |
|
276 |
swal({title:'',text:'未选择需要关闭的销售提单,请先选择一个销售提单!',type:'error',confirmButtonText:'确定'}); |
|
277 |
return ; |
|
278 |
} |
|
279 |
//弹出层显示出来 |
|
280 |
vm.fdqxvehcileId(''); |
|
281 |
vm.fdqxdriver(''); |
|
282 |
vm.fdqxphone(''); |
|
283 |
I.closefdModel.modal('show'); |
|
284 |
}); |
|
285 |
I.fdqxopenfdBtn.click(function(){ |
|
286 |
//判断选择了多个只能选择一个 |
|
287 |
if($('.bitem.info').length>1){ |
|
288 |
swal({title:'',text:'不能选择多个销售提单同时恢复,请保留一个销售提单!',type:'error',confirmButtonText:'确定'}); |
|
289 |
return ; |
|
290 |
} |
|
291 |
if($('.bitem.info').length<1){ |
|
292 |
swal({title:'',text:'未选择需要恢复的销售提单,请先选择一个销售提单!',type:'error',confirmButtonText:'确定'}); |
|
293 |
return ; |
|
294 |
} |
|
295 |
var xstdcc=''; |
|
296 |
$.each($('.bitem.info'), function (index, value) { |
|
297 |
xstdcc=vm.list()[$(this).attr('data-indx')].td_tdbh; |
|
298 |
}); |
|
299 |
//显示出来确认框 |
|
300 |
$("#modalContent").html('确定要恢复'+xstdcc+'销售提单吗?该销售提单恢复之后,您可以对该销售提单进行分单操作!'); |
|
301 |
$("#dialog-confirm").removeClass('hide').dialog({ |
|
302 |
resizable: false, |
|
303 |
width: '320', |
|
304 |
modal: true, |
|
305 |
title: "<div class='widget-header'><h4 class='smaller'><i class='ace-icon fa fa-exclamation-triangle red'></i>确认信息</h4></div>", |
|
306 |
title_html: true, |
|
307 |
position: { my: "center", at: "center", of: window }, |
|
308 |
buttons: [ |
|
309 |
{ |
|
310 |
html: "<i class='ace-icon fa fa-trash-o bigger-110'></i> 确定", |
|
311 |
"class" : "btn btn-danger btn-minier", |
|
312 |
click: function() { |
|
313 |
fdqxopenBt(); |
|
314 |
} |
|
315 |
} |
|
316 |
, |
|
317 |
{ |
|
318 |
html: "<i class='ace-icon fa fa-times bigger-110'></i> 取消", |
|
319 |
"class" : "btn btn-minier", |
|
320 |
click: function() { |
|
321 |
$( this ).dialog( "close" ); |
|
322 |
} |
|
323 |
} |
|
324 |
] |
|
325 |
}); |
|
326 |
}); |
|
327 |
//关闭分单弹出层--点击确认 |
|
328 |
I.fdqxclosefdmBtn.click(function(){ |
|
329 |
var xstdcc=''; |
|
330 |
$.each($('.bitem.info'), function (index, value) { |
|
331 |
xstdcc=vm.list()[$(this).attr('data-indx')].td_tdbh; |
|
332 |
}); |
|
333 |
$("#modalContent").html('确定要关闭'+xstdcc+'提单吗?关闭该提单之后,您将不能对该提单进行分单操作!'); |
|
334 |
$("#dialog-confirm").removeClass('hide').dialog({ |
|
335 |
resizable: false, |
|
336 |
width: '320', |
|
337 |
modal: true, |
|
338 |
title: "<div class='widget-header'><h4 class='smaller'><i class='ace-icon fa fa-exclamation-triangle red'></i>确认信息</h4></div>", |
|
339 |
title_html: true, |
|
340 |
position: { my: "center", at: "center", of: window }, |
|
341 |
buttons: [ |
|
342 |
{ |
|
343 |
html: "<i class='ace-icon fa fa-trash-o bigger-110'></i> 确定", |
|
344 |
"class" : "btn btn-danger btn-minier", |
|
345 |
click: function() { |
|
346 |
fdqxcloseBt(); |
|
347 |
} |
|
348 |
} |
|
349 |
, |
|
350 |
{ |
|
351 |
html: "<i class='ace-icon fa fa-times bigger-110'></i> 取消", |
|
352 |
"class" : "btn btn-minier", |
|
353 |
click: function() { |
|
354 |
$( this ).dialog( "close" ); |
|
355 |
} |
|
356 |
} |
|
357 |
] |
|
358 |
}); |
|
359 |
}); |
|
360 |
} |
|
361 |
|
|
362 |
function doOpen() { |
|
363 |
var k = $.trim(vm.keyword()); |
|
364 |
var sort = []; |
|
365 |
$.each(vm.soList(), function (index, value) { |
|
366 |
sort.push({ |
|
367 |
name: value.target, |
|
368 |
value: value.result() |
|
369 |
}) |
|
370 |
}); |
|
371 |
// console.log("cccc:::"+$('#wcSign').val()); |
|
372 |
getList(k, vm.companyNo(), vm.type(), $.toJSON(sort), I.sDate.val(), I.eDate.val(), 0, I.PZ, 1); |
|
373 |
} |
|
374 |
|
|
375 |
function doSearch() { |
|
376 |
doOpen(); |
|
377 |
} |
|
378 |
|
|
379 |
function getList(keyword, companyNo, type, sort, sdate, edate, page, pagesize, pages) { |
|
380 |
I._page = page; |
|
381 |
$.post('/business/getList.htm', { |
|
382 |
keyword: keyword, |
|
383 |
companyNo: vm.isAdmin() ? companyNo : (typeof(parent.G) != 'undefined' ? parent.G.loginCompanyNo : 'ABCDEFG'), |
|
384 |
type: type, |
|
385 |
sort: sort, |
|
386 |
sdate: sdate, |
|
387 |
edate: edate, |
|
388 |
wcSign:$("#wcSign").val(), |
|
389 |
page: page, |
|
390 |
pagesize: pagesize, |
|
391 |
pages: pages, |
|
392 |
cqV:vm.cqVal() |
|
393 |
}, function(data, textStatus, xhr) { |
|
394 |
vm.list.removeAll(); |
|
395 |
if (data.code >= 1) { |
|
396 |
//parent.showErrmsg(data.errmsg); |
|
397 |
swal({title:'',text:data.errmsg,type:'error',confirmButtonText:'确定'}); |
|
398 |
return; |
|
399 |
} |
|
400 |
if (data.code == 0) { |
|
401 |
if (isList(data.list)) { |
|
402 |
$.each(data.list, function(index, val) { |
|
403 |
// if($('#wcSign').val()==1){ |
|
404 |
val.indx = index + ''; |
|
405 |
val.fdqxbgType=vm.fdqxbgType(); |
|
406 |
val.td_gbsj=val.td_gbsj==null?'':val.td_gbsj; |
|
407 |
val.td_gbr=val.td_gbr==null?'':val.td_gbr; |
|
408 |
val.td_gbsl=val.td_gbsl==null?'':val.td_gbsl; |
|
409 |
val.td_gbzl=val.td_gbzl==null?'':val.td_gbzl; |
|
410 |
// if(val.td_wfdsl==0){ |
|
411 |
vm.list.push(val); |
|
412 |
// } |
|
413 |
// }else{ |
|
414 |
// val.indx = index + ''; |
|
415 |
// if(val.td_wfdsl>0){ |
|
416 |
// vm.list.push(val); |
|
417 |
// } |
|
418 |
// } |
|
419 |
}); |
|
420 |
$('.bitem').click(function (e) { |
|
421 |
$(this).toggleClass('info'); |
|
422 |
computedSelect(); |
|
423 |
}); |
|
424 |
} |
|
425 |
if (!!pages) { |
|
426 |
pages = data.pages; |
|
427 |
$('#pagdiv').unbind('page').empty(); |
|
428 |
if (pages > 1) { |
|
429 |
$('#pagdiv').bootpag({total: pages, maxVisible: 10, page: page + 1}).on('page',function(event,num){ |
|
430 |
getList(keyword, companyNo, type, sort, sdate, edate, num - 1, pagesize, 0); |
|
431 |
}); |
|
432 |
} |
|
433 |
} |
|
434 |
return; |
|
435 |
} |
|
436 |
}, 'json'); |
|
437 |
} |
|
438 |
|
|
439 |
function getCompanyList() { |
|
440 |
$.post('/company/getList.htm', null, function(data, textStatus, xhr) { |
|
441 |
vm.tList.removeAll(); |
|
442 |
if (data.code >= 1) { |
|
443 |
//parent.showErrmsg(data.errmsg); |
|
444 |
swal({title:'',text:data.errmsg,type:'error',confirmButtonText:'确定'}); |
|
445 |
return; |
|
446 |
} |
|
447 |
if (data.code == 0) { |
|
448 |
if (isList(data.list)) { |
|
449 |
$.each(data.list, function(index, val) { |
|
450 |
vm.tList.push(val); |
|
451 |
}); |
|
452 |
} |
|
453 |
} |
|
454 |
}, 'json'); |
|
455 |
} |
|
456 |
|
|
457 |
function doVehicleBind() { |
|
458 |
I.vehicleBindBtn.prop('disabled', true); |
|
459 |
var arr = getSelectBiz(); |
|
460 |
var vehicle = null; |
|
461 |
var indx = $('.vitem.info').attr('data-indx'); |
|
462 |
$.each(vm.vList(), function (index, value) { |
|
463 |
if (value.indx === indx) { |
|
464 |
vehicle = value; |
|
465 |
} |
|
466 |
}); |
|
467 |
doBindByList(arr, vehicle); |
|
468 |
} |
|
469 |
|
|
470 |
function doTempVehicleBind() { |
|
471 |
I.tempVehicleBindBtn.prop('disabled', true); |
|
472 |
var arr = getSelectBiz(); |
|
473 |
var vehicle = ko.mapping.toJS(vm.o()); |
|
474 |
doBindByList(arr, vehicle); |
|
475 |
} |
|
476 |
|
|
477 |
function validVehicle() { |
|
478 |
$.post("/business/validVehicle.htm", {vehicleId: ko.mapping.toJS(vm.o()).vehicleId.toUpperCase()}, |
|
479 |
function (data, textStatus, jqXHR) { |
|
480 |
if (data.code >= 1) { |
|
481 |
swal({title:'',text:data.errmsg,type:'error',confirmButtonText:'确定'}); |
|
482 |
return; |
|
483 |
} |
|
484 |
if (data.code == 0) { |
|
485 |
doTempVehicleBind(); |
|
486 |
return; |
|
487 |
} |
|
488 |
}, |
|
489 |
"json" |
|
490 |
); |
|
491 |
} |
|
492 |
|
|
493 |
function doBindByList(list, vehicle) { |
|
494 |
if (!!I.AjaxdoBindByList) { |
|
495 |
return; |
|
496 |
} |
|
497 |
I.AjaxdoBindByList = true; |
|
498 |
$.post("/business/doBindByList.htm", {list: $.toJSON(list), vehicle: $.toJSON(vehicle)}, |
|
499 |
function (data, textStatus, jqXHR) { |
|
500 |
I.AjaxdoBindByList = false; |
|
501 |
I.vehicleBindBtn.prop('disabled', false); |
|
502 |
I.tempVehicleBindBtn.prop('disabled', false); |
|
503 |
if (data.code >= 1) { |
|
504 |
swal({title:'',text:data.errmsg,type:'error',confirmButtonText:'确定'}); |
|
505 |
return; |
|
506 |
} |
|
507 |
if (data.code == 0) { |
|
508 |
showErrmsg('配车成功!'); |
|
509 |
I.vehicleModal.modal('hide'); |
|
510 |
I.tempVehicleModal.modal('hide'); |
|
511 |
return; |
|
512 |
} |
|
513 |
}, |
|
514 |
"json" |
|
515 |
); |
|
516 |
} |
|
517 |
|
|
518 |
function doUnbindByList(list) { |
|
519 |
if (!!I.AjaxdoUnbindByList) { |
|
520 |
return; |
|
521 |
} |
|
522 |
I.AjaxdoUnbindByList = true; |
|
523 |
I.unbindBtn.prop('disabled', true); |
|
524 |
$.post("/business/doUnbindByList.htm", {list: $.toJSON(list)}, |
|
525 |
function (data, textStatus, jqXHR) { |
|
526 |
I.AjaxdoUnbindByList = false; |
|
527 |
I.unbindBtn.prop('disabled', false); |
|
528 |
if (data.code >= 1) { |
|
529 |
swal({title:'',text:data.errmsg,type:'error',confirmButtonText:'确定'}); |
|
530 |
return; |
|
531 |
} |
|
532 |
if (data.code == 0) { |
|
533 |
showErrmsg('取消配车成功!'); |
|
534 |
return; |
|
535 |
} |
|
536 |
}, |
|
537 |
"json" |
|
538 |
); |
|
539 |
} |
|
540 |
|
|
541 |
function getSelectBiz() { |
|
542 |
var arr = []; |
|
543 |
$.each($('.bitem.info'), function (index, value) { |
|
544 |
arr.push($(this).attr('data-td_tdbh')); |
|
545 |
}); |
|
546 |
return arr; |
|
547 |
} |
|
548 |
|
|
549 |
function valid(){ |
|
550 |
var isValid = false; |
|
551 |
var iF = $('#form'); |
|
552 |
iF.validate({ |
|
553 |
rules: { |
|
554 |
'vehicleId': { |
|
555 |
required: true, |
|
556 |
isPlateNumber: true |
|
557 |
}, |
|
558 |
'driver': { |
|
559 |
required: true, |
|
560 |
}, |
|
561 |
'phone': { |
|
562 |
required: true, |
|
563 |
isPhone: true |
|
564 |
}, |
|
565 |
'IDNum': { |
|
566 |
required: true, |
|
567 |
}, |
|
568 |
}, |
|
569 |
messages: { |
|
570 |
'vehicleId': { |
|
571 |
required: '不能为空!', |
|
572 |
isPlateNumber: '车牌号不正确!' |
|
573 |
}, |
|
574 |
'driver': { |
|
575 |
required: '不能为空!', |
|
576 |
}, |
|
577 |
'phone': { |
|
578 |
required: '不能为空!', |
|
579 |
isPhone: '手机号不正确!' |
|
580 |
}, |
|
581 |
'IDNum': { |
|
582 |
required: '不能为空!', |
|
583 |
}, |
|
584 |
}, |
|
585 |
errorPlacement: function (err, element) { |
|
586 |
var p = element.parents('.form-group').eq(0); |
|
587 |
var d = p.find('.text-error').eq(0); |
|
588 |
d.css('color', '#D9534F'); |
|
589 |
err.appendTo(d); |
|
590 |
} |
|
591 |
}) |
|
592 |
isValid = iF.valid(); |
|
593 |
return isValid; |
|
594 |
} |
|
595 |
|
|
596 |
function getVehicleList() { |
|
597 |
$.post("/business/getVehicleList.htm", { |
|
598 |
companyNo: vm.isAdmin() ? '' : (typeof(parent.G) != 'undefined' ? parent.G.loginCompanyNo : 'ABCDEFG'), |
|
599 |
vehicleId:I.vehicleKeyword.val()==undefined?'':I.vehicleKeyword.val(), |
|
600 |
}, |
|
601 |
function (data, textStatus, jqXHR) { |
|
602 |
I.VDB = []; |
|
603 |
if (data.code >= 1) { |
|
604 |
swal({title:'',text:data.errmsg,type:'error',confirmButtonText:'确定'}); |
|
605 |
return; |
|
606 |
} |
|
607 |
if (data.code == 0) { |
|
608 |
if (isList(data.list)) { |
|
609 |
$.each(data.list, function (index, value) { |
|
610 |
value.indx = index + ''; |
|
611 |
value.lastweight = ''; |
|
612 |
if ($.isNumeric(value.loadweight) && $.isNumeric(value.fdweight)) { |
|
613 |
value.lastweight = (parseFloat(value.loadweight) - parseFloat(value.fdweight)).toFixed(3); |
|
614 |
} |
|
615 |
I.VDB.push(value); |
|
616 |
}); |
|
617 |
} |
|
618 |
updateVList(); |
|
619 |
return; |
|
620 |
} |
|
621 |
}, |
|
622 |
"json" |
|
623 |
); |
|
624 |
} |
|
625 |
|
|
626 |
function updateVList() { |
|
627 |
// var str = I.vehicleKeyword.val(); |
|
628 |
vm.vList.removeAll(); |
|
629 |
// if (!!str) { |
|
630 |
// var reg = new RegExp(str); |
|
631 |
// $.each(I.VDB, function (index, value) { |
|
632 |
// if (reg.test(value.vehicleId)) { |
|
633 |
// vm.vList.push(value); |
|
634 |
// } |
|
635 |
// }); |
|
636 |
// } else { |
|
637 |
if(I.VDB!=undefined&&I.VDB!=null && I.VDB.length>0){ |
|
638 |
$.each(I.VDB, function (index, value) { |
|
639 |
vm.vList.push(value); |
|
640 |
}); |
|
641 |
} |
|
642 |
|
|
643 |
// } |
|
644 |
$('.vitem').click(function (e) { |
|
645 |
$('.vitem').removeClass('info'); |
|
646 |
$(this).addClass('info'); |
|
647 |
}); |
|
648 |
} |
|
649 |
|
|
650 |
function addSort(item) { |
|
651 |
item.visible(false); |
|
652 |
var obj = { |
|
653 |
key: item.key, |
|
654 |
target: item.value, |
|
655 |
result: ko.observable('asc') |
|
656 |
} |
|
657 |
vm.soList.push(obj); |
|
658 |
} |
|
659 |
|
|
660 |
function removeSort(item) { |
|
661 |
vm.soList.remove(item); |
|
662 |
$.each(vm.oList(), function (index, value) { |
|
663 |
value.key === item.key && value.visible(true); |
|
664 |
}); |
|
665 |
} |
|
666 |
|
|
667 |
function computedSelect() { |
|
668 |
var selectedNum = 0; |
|
669 |
var selectedPZ = 0; |
|
670 |
$.each($('.bitem.info'), function (index, value) { |
|
671 |
var indx = $(this).attr('data-indx'); |
|
672 |
var obj = vm.list()[indx]; |
|
673 |
selectedNum += obj.td_wfdsl; |
|
674 |
selectedPZ += obj.td_wfdzl; |
|
675 |
}); |
|
676 |
vm.selectedNum(selectedNum); |
|
677 |
vm.selectedPZ(selectedPZ.toFixed(3)); |
|
678 |
} |
|
679 |
|
|
680 |
function validMessage(message, cb, cbparams) { |
|
681 |
$("#modalContent").html(message); |
|
682 |
$("#dialog-confirm").removeClass('hide').dialog({ |
|
683 |
resizable: false, |
|
684 |
width: '320', |
|
685 |
modal: true, |
|
686 |
title: "<div class='widget-header'><h4 class='smaller'><i class='ace-icon fa fa-exclamation-triangle red'></i>确认信息</h4></div>", |
|
687 |
title_html: true, |
|
688 |
position: { my: "center", at: "center", of: window }, |
|
689 |
buttons: [ |
|
690 |
{ |
|
691 |
html: "<i class='ace-icon fa fa-trash-o bigger-110'></i> 确定", |
|
692 |
"class" : "btn btn-danger btn-minier", |
|
693 |
click: function() { |
|
694 |
$( this ).dialog( "close" ); |
|
695 |
cb(cbparams); |
|
696 |
} |
|
697 |
} |
|
698 |
, |
|
699 |
{ |
|
700 |
html: "<i class='ace-icon fa fa-times bigger-110'></i> 取消", |
|
701 |
"class" : "btn btn-minier", |
|
702 |
click: function() { |
|
703 |
$( this ).dialog( "close" ); |
|
704 |
} |
|
705 |
} |
|
706 |
] |
|
707 |
}); |
|
708 |
} |
|
709 |
|
|
710 |
|
|
711 |
|
|
712 |
|
|
713 |
|
|
714 |
|
|
715 |
|
|
716 |
|
|
717 |
|
|
718 |
|
|
719 |
function newTab(item) { |
|
720 |
parent.closableTab.addTab({ |
|
721 |
'id': new Date().getTime(), |
|
722 |
'name': item.td_tdbh + '分单', |
|
723 |
'url': '/basic/formSplit.jsf?no=' + item.td_tdbh, |
|
724 |
'closable': true |
|
725 |
}); |
|
726 |
} |
|
727 |
|
|
728 |
function newPrintTab(tdNo) { |
|
729 |
parent.closableTab.addTab({ |
|
730 |
'id': tdNo, |
|
731 |
'name': '打印', |
|
732 |
// 'url': encodeURI('http://' + HOSTNAME + ':9088/ReportServer?reportlet=print%2Fprint_fd_xstd.cpt&vehicleId=' + vehicleId), |
|
733 |
'url': encodeURI('/task/printtdall.htm?tdNo=' + tdNo), |
|
734 |
'closable': true |
|
735 |
}); |
|
736 |
} |
|
737 |
|
|
738 |
function autoHeight() { |
|
739 |
$('.page-content').css('min-height', $(parent.window).height() - 117); |
|
740 |
$('.table-responsive').css('height', $(parent.window).height() - 260); |
|
741 |
} |
|
742 |
|
|
743 |
function clearError() { |
|
744 |
$('#form input').removeClass('error'); |
|
745 |
$('#form .text-error').html(''); |
|
746 |
} |
|
747 |
|
|
748 |
//关闭提单操作 |
|
749 |
function fdqxcloseBt(){ |
|
750 |
var tdNo=''; |
|
751 |
$.each($('.bitem.info'), function (index, value) { |
|
752 |
tdNo=vm.list()[$(this).attr('data-indx')].td_tdbh; |
|
753 |
}); |
|
754 |
$.post("/business/closexstd.htm", {vehicleId: vm.fdqxvehcileId(),driver: vm.fdqxdriver(),phone: vm.fdqxphone(),tdNo:tdNo}, |
|
755 |
function (data, textStatus, jqXHR) { |
|
756 |
I.VDB = []; |
|
757 |
if (data.code >= 1) { |
|
758 |
swal({title:'',text:data.errmsg,type:'error',confirmButtonText:'确定'}); |
|
759 |
$("#dialog-confirm").dialog( "close" ); |
|
760 |
return; |
|
761 |
} |
|
762 |
if (data.code == 0) { |
|
763 |
showErrmsg('关闭分单成功!'); |
|
764 |
I.closefdModel.modal('hide'); |
|
765 |
getList($.trim(vm.keyword()), vm.companyNo(), vm.type(), null, I.sDate.val(), I.eDate.val(), 0, I.PZ, 1); |
|
766 |
$("#dialog-confirm").dialog( "close" ); |
|
767 |
return; |
|
768 |
} |
|
769 |
}, |
|
770 |
"json" |
|
771 |
); |
|
772 |
} |
|
773 |
|
|
774 |
//打开提单操作 |
|
775 |
function fdqxopenBt(){ |
|
776 |
var tdNo=''; |
|
777 |
$.each($('.bitem.info'), function (index, value) { |
|
778 |
tdNo=vm.list()[$(this).attr('data-indx')].td_tdbh; |
|
779 |
}); |
|
780 |
$.post("/business/openxstd.htm", {tdNo:tdNo}, |
|
781 |
function (data, textStatus, jqXHR) { |
|
782 |
I.VDB = []; |
|
783 |
if (data.code >= 1) { |
|
784 |
swal({title:'',text:data.errmsg,type:'error',confirmButtonText:'确定'}); |
|
785 |
$("#dialog-confirm").dialog( "close" ); |
|
786 |
return; |
|
787 |
} |
|
788 |
if (data.code == 0) { |
|
789 |
showErrmsg('恢复分单成功!'); |
|
790 |
getList($.trim(vm.keyword()), vm.companyNo(), vm.type(), null, I.sDate.val(), I.eDate.val(), 0, I.PZ, 1); |
|
791 |
$("#dialog-confirm").dialog( "close" ); |
|
792 |
return; |
|
793 |
} |
|
794 |
}, |
|
795 |
"json" |
|
796 |
); |
|
797 |
|
|
798 |
} |
|
799 |
|
|
800 |
//获取物流公司可操作的厂区 |
|
801 |
function getcqList() { |
|
802 |
$.post('/company/getcqList.htm', null, function(data, textStatus, xhr) { |
|
803 |
vm.cqList.removeAll(); |
|
804 |
if (data.code >= 1) { |
|
805 |
//parent.showErrmsg(data.errmsg); |
|
806 |
swal({title:'',text:data.errmsg,type:'error',confirmButtonText:'确定'}); |
|
807 |
return; |
|
808 |
} |
|
809 |
if (data.code == 0) { |
|
810 |
if (isList(data.list)) { |
|
811 |
var tmp ;var ind=0; var list=[]; |
|
812 |
$.each(data.list, function(index, val) { |
|
813 |
if (val.cqval=='' ) { |
|
814 |
ind = 1; |
|
815 |
} |
|
816 |
if (val.cqval == '103' || val.name == '科技厂区') { |
|
817 |
tmp = val;return; |
|
818 |
} |
|
819 |
list.push(val); |
|
820 |
}); |
|
821 |
if (tmp){ |
|
822 |
list.splice(ind, 0, tmp) |
|
823 |
} |
|
824 |
vm.cqList.push(...list) |
|
825 |
} |
|
826 |
} |
|
827 |
}, 'json'); |
|
828 |
} |