提交 | 用户 | 时间
|
58d006
|
1 |
/** |
A |
2 |
* date: |
|
3 |
* author: neeler |
|
4 |
*/ |
|
5 |
|
|
6 |
//test data start |
|
7 |
// var data_getList = Mock.mock('/business/getItem.htm', { "item": { "td_shrq": "YYYY-MM-DD", "td_bmbh": "0601", "td_bmmc": null, "td_djrq": "20170626", "td_khmc": "巩义市贝思特贸易有限公司", "td_bz": "发上海 不开票 不带清单", "td_ywrq": "20170626", "td_zdr": "王雅", "td_tdbh": "TD-17060001", "td_tdls": "43" }, "code": 0, "list|3-50": [{"tdmx_wlbh": "D8F001","tdmx_wlmc": "8系热轧箔","tdmx_tdfl": "0000000001","tdmx_tdls": "43","tdmx_hjzt": null,"tdmx_dwmx": "吨","tdmx_fdcph": "GFC1706N80075-1","tdmx_bhse": 15372.56,"tdmx_mz": 0.764,"tdmx_pz": 0,"tdmx_jz": 0.679,"tdmx_shdw": "巩义市贝思特贸易有限公司","tdmx_fhdw": "河南眀泰","tdmx_tdlx": "欠款提货","tdmx_sl": 17,"tdmx_ggxh": "0.04*500*C","tdmx_sfzc": "0.0","tdmx_fdcph": "豫C555555", "tdmx_bz": "tdmx_bz", "tdmx_hw": "tdmx_hw"}]}) |
|
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_doUnbind = Mock.mock('/business/doUnbind.htm', {code: 0, }) |
|
11 |
// var data_doBind = Mock.mock('/business/doBind.htm', {code: 0, }) |
|
12 |
// var data_getallList = Mock.mock('/vehicle/getallList.htm', {"rowCount":0,"pagesize":0,"pages":0,"page":0,"items":null,"list":[{"note":null,"companyNo":"009","driver":"九阳神功","loadweight":15.0,"phone":"13007607721","companyName":"运输部","rownumber":1,"id|+1": 1,"state":1,"vehicleId":"豫A11111","vehicleweight":10.0}],"hint":null,"errmsg":null,"code":0}) |
|
13 |
// var data_saveItem = Mock.mock('/business/saveItem.htm', {code: 0, }) |
|
14 |
// var data_doDel = Mock.mock('/transport/yscompany/del.htm', {code: 0, errmsg: 'errmsg'}) |
|
15 |
// var data_doSave = Mock.mock('/transport/yscompany/save.htm', {code: 0, errmsg: 'errmsg'}) |
|
16 |
//test data end |
|
17 |
|
|
18 |
var SORT = [ |
|
19 |
{key: '批次号', value: 'tdmx_fdcph', visible: ko.observable(true)}, |
|
20 |
{key: '规格型号', value: 'tdmx_ggxh', visible: ko.observable(true)}, |
|
21 |
{key: '包装', value: 'tdmx_zpbz', visible: ko.observable(true)}, |
|
22 |
{key: '货位', value: 'tdmx_hwbh', visible: ko.observable(true)}, |
|
23 |
{key: '毛重', value: 'tdmx_mz', visible: ko.observable(true)}, |
|
24 |
{key: '净重', value: 'tdmx_jz', visible: ko.observable(true)} |
|
25 |
] |
|
26 |
|
|
27 |
window.I = { |
|
28 |
_lastIndex: 0, |
|
29 |
nowVehicle: null, |
|
30 |
no: $('#no').val(), |
|
31 |
vehicleKeyword: $('#vehicleKeyword'), |
|
32 |
searchVehicleBtn: $('#searchVehicleBtn'), |
|
33 |
refreshVehicleBtn: $('#refreshVehicleBtn'), |
|
34 |
tempVehicleModal: $('#tempVehicleModal'), |
|
35 |
addTempVehicle: $('#addTempVehicle'), |
|
36 |
selectAllBtn: $('#selectAllBtn'), |
|
37 |
selectNoBtn: $('#selectNoBtn'), |
|
38 |
clearSelectBtn: $('#clearSelectBtn'), |
|
39 |
piciKeyword:$('#piciKeyword'), |
|
40 |
searchpiciBtn:$('#searchpiciBtn'), |
|
41 |
SortBtn:$('#SortBtn'), |
|
42 |
clearSortBtn: $('#clearSortBtn'), |
|
43 |
ssortBtn:$('#searchSortBtn'), |
|
44 |
sxBtn:$('#sxBtn'), |
|
45 |
companyKeyword: $('#companyKeyword'), |
|
46 |
companyModal: $("#companyModal"), |
|
47 |
companyButton: $("#companyButton"), |
|
48 |
companyBindBtn: $("#companyBindBtn"), |
|
49 |
changeCompanyButton: $("#changeCompanyButton"), |
|
50 |
modal: $("#modal") |
|
51 |
|
|
52 |
} |
|
53 |
|
|
54 |
var Obj = { |
|
55 |
vehicleId: '豫A', |
|
56 |
driver: '', |
|
57 |
phone: '', |
|
58 |
IDNum: '', |
|
59 |
vehicleweight: '', |
|
60 |
loadweight: '', |
|
61 |
note: '', |
|
62 |
feature: '' |
|
63 |
} |
|
64 |
|
|
65 |
var TD = { |
|
66 |
td_bmbh: '', |
|
67 |
td_bmmc: '', |
|
68 |
td_bz: '', |
|
69 |
td_djrq: '', |
|
70 |
td_khmc: '', |
|
71 |
td_tdbh: '', |
|
72 |
td_tdls: '', |
|
73 |
td_ywrq: '', |
|
74 |
td_zdr: '', |
|
75 |
td_shrq: '', |
|
76 |
td_shsj: '', |
|
77 |
td_fpbh:'' |
|
78 |
} |
|
79 |
|
|
80 |
var ViewModel = function() { |
|
81 |
var self = this; |
|
82 |
self.o = ko.observable(ko.mapping.fromJS(Obj)); |
|
83 |
self.td = ko.observable(TD); |
|
84 |
self.vList = ko.observableArray(); |
|
85 |
self.list = ko.observableArray(); |
|
86 |
self.mxWlgs = ko.observableArray(); |
|
87 |
self.companyName = ko.observable(''); |
|
88 |
self.companyNo = ko.observable(''); |
|
89 |
|
|
90 |
self.isAdmin = ko.observable(typeof(parent.G) != 'undefined' ? parent.G.isAdmin : false); |
|
91 |
|
|
92 |
self.isSelectAll = ko.observable(false); |
|
93 |
self.allNum = ko.observable(0); |
|
94 |
self.bindNum = ko.observable(0); |
|
95 |
self.unbindNum = ko.observable(0); |
|
96 |
|
|
97 |
self.selectedNum = ko.observable(0); |
|
98 |
self.selectedMZ = ko.observable(0); |
|
99 |
self.selectedJZ = ko.observable(0); |
|
100 |
|
|
101 |
self.select = function (item) { |
|
102 |
I.nowVehicle = {}; |
|
103 |
for(attr in item) { |
|
104 |
I.nowVehicle[attr] = item[attr]; |
|
105 |
} |
|
106 |
} |
|
107 |
self.oList = ko.observableArray(SORT); |
|
108 |
self.soList = ko.observableArray(); |
|
109 |
self.addSort = function (item) { |
|
110 |
addSort(item); |
|
111 |
} |
|
112 |
self.removeSort = function (item) { |
|
113 |
removeSort(item); |
|
114 |
} |
|
115 |
} |
|
116 |
|
|
117 |
$(function () { |
|
118 |
window.vm = new ViewModel(); |
|
119 |
ko.applyBindings(vm); |
|
120 |
autoHeight(); |
|
121 |
// getVehicleList(); |
|
122 |
getCompanyList(); |
|
123 |
if (!!I.no) { |
|
124 |
getList(I.no); |
|
125 |
} |
|
126 |
pageInit(); |
|
127 |
}); |
|
128 |
function doCompanyButtonBind(){ |
|
129 |
vm.mxWlgs.removeAll(); |
|
130 |
$.each($('.mitem.info'), function (index, value) { |
|
131 |
let val = vm.list()[$(this).attr('data-indx')] |
|
132 |
vm.mxWlgs.push({tdmxTdfl:val.tdmx_tdfl, tdTdls: val.tdmx_tdls, wlgsNo: vm.companyNo()}); |
|
133 |
}); |
|
134 |
I.changeCompanyButton.prop('disabled', true); |
|
135 |
$.ajax({ |
|
136 |
url: '/business/changeWlgs.htm', |
|
137 |
type: 'post', |
|
138 |
data: JSON.stringify(vm.mxWlgs()), |
|
139 |
success: function (data, textstatus, xhr) { |
|
140 |
if (data.code >= 1) { |
|
141 |
//parent.showerrmsg(data.errmsg); |
|
142 |
swal({title: '', text: data.errmsg, type: 'error', confirmbuttontext: '确定'}); |
|
143 |
return; |
|
144 |
} |
|
145 |
if (data.code == 0) { |
|
146 |
showErrmsg('操作提示!'); |
|
147 |
getList(I.no); |
|
148 |
setTimeout( _=>{ |
|
149 |
I.changeCompanyButton.removeAttr("disabled"); |
|
150 |
},2000) |
|
151 |
} |
|
152 |
}, |
|
153 |
contentType: "application/json", |
|
154 |
dataType: "json" |
|
155 |
}); |
|
156 |
} |
|
157 |
function objToFormDate(obj) { |
|
158 |
return obj |
|
159 |
} |
|
160 |
function pageInit() { |
|
161 |
I.sxBtn.click(function (e) { |
|
162 |
getList(I.no) |
|
163 |
}) |
|
164 |
I.companyBindBtn.click(function (e) { |
|
165 |
e.preventDefault(); |
|
166 |
if ($('.vitem.info').length) { |
|
167 |
// validMessage('确定要取消配车吗?', doUnbind) |
|
168 |
I.companyModal.modal('hide',doCompanyBind()); |
|
169 |
} else { |
|
170 |
parent.showErrmsg('请选择一个公司!'); |
|
171 |
} |
|
172 |
}) |
|
173 |
I.changeCompanyButton.click(function (e) { |
|
174 |
e.preventDefault(); |
|
175 |
if ($('.mitem.info').length) { // 提交代码 |
|
176 |
doCompanyButtonBind() |
|
177 |
} else { |
|
178 |
parent.showErrmsg('请选择一个提单物资!'); |
|
179 |
} |
|
180 |
}) |
|
181 |
I.companyButton.click(function (e) { |
|
182 |
e.preventDefault(); |
|
183 |
// vm.o(ko.mapping.fromJS(Obj)); |
|
184 |
I.companyModal.modal('show'); |
|
185 |
}); |
|
186 |
I.companyModal.on('hidden.bs.modal', function (e) { |
|
187 |
clearError(); |
|
188 |
}); |
|
189 |
I.companyKeyword.keyup(function (e) { |
|
190 |
// updateVList(); |
|
191 |
getCompanyList(); |
|
192 |
}); |
|
193 |
I.searchVehicleBtn.click(function (e) { |
|
194 |
e.preventDefault(); |
|
195 |
// updateVList(); |
|
196 |
getCompanyList(); |
|
197 |
}); |
|
198 |
I.refreshVehicleBtn.click(function (e) { |
|
199 |
e.preventDefault(); |
|
200 |
getCompanyList(); |
|
201 |
}); |
|
202 |
|
|
203 |
I.selectAllBtn.click(function (e) { |
|
204 |
e.preventDefault(); |
|
205 |
/*for(var i=0;i<I._MDB.length;i++){ |
|
206 |
if(I.bindNumBtn.hasClass('btn-info')){ |
|
207 |
if (I._MDB[i].tdmx_fdcph() !== '') { |
|
208 |
if($('#piciKeyword').val()=='' || I._MDB[i].tdmx_fdcph.indexOf($('#piciKeyword').val())>0){ |
|
209 |
I._MDB[i].chooseCli=true; |
|
210 |
} |
|
211 |
} |
|
212 |
}else if(I.unbindNumBtn.hasClass('btn-info')){ |
|
213 |
if (I._MDB[i].tdmx_fdcph() == '') { |
|
214 |
if($('#piciKeyword').val()=='' || I._MDB[i].tdmx_fdcph.indexOf($('#piciKeyword').val())>0){ |
|
215 |
I._MDB[i].chooseCli=true; |
|
216 |
} |
|
217 |
} |
|
218 |
}else{ |
|
219 |
if($('#piciKeyword').val()=='' || I._MDB[i].tdmx_fdcph.indexOf($('#piciKeyword').val())>0){ |
|
220 |
I._MDB[i].chooseCli=true; |
|
221 |
} |
|
222 |
} |
|
223 |
}*/ |
|
224 |
$.each($('.mitem'), function (index, value) { |
|
225 |
// let val = vm.list()[$(this).attr('data-indx')] |
|
226 |
if (vm.list()[index].fkStatus > 0){ |
|
227 |
return; |
|
228 |
} |
|
229 |
$(this).addClass('info'); |
|
230 |
}); |
|
231 |
// $('.mitem').addClass('info'); |
|
232 |
// computedSelect(); |
|
233 |
}); |
|
234 |
I.selectNoBtn.click(function (e) { |
|
235 |
e.preventDefault(); |
|
236 |
for(var i=0;i<I._MDB.length;i++){ |
|
237 |
if(I.bindNumBtn.hasClass('btn-info')){ |
|
238 |
if (I._MDB[i].tdmx_fdcph() !== '') { |
|
239 |
if($('#piciKeyword').val()=='' || I._MDB[i].tdmx_fdcph.indexOf($('#piciKeyword').val())>0){ |
|
240 |
I._MDB[i].chooseCli=false; |
|
241 |
} |
|
242 |
} |
|
243 |
}else if(I.unbindNumBtn.hasClass('btn-info')){ |
|
244 |
if (I._MDB[i].tdmx_fdcph() == '') { |
|
245 |
if($('#piciKeyword').val()=='' || I._MDB[i].tdmx_fdcph.indexOf($('#piciKeyword').val())>0){ |
|
246 |
I._MDB[i].chooseCli=false; |
|
247 |
} |
|
248 |
} |
|
249 |
}else{ |
|
250 |
if($('#piciKeyword').val()=='' || I._MDB[i].tdmx_fdcph.indexOf($('#piciKeyword').val())>0){ |
|
251 |
I._MDB[i].chooseCli=false; |
|
252 |
} |
|
253 |
} |
|
254 |
} |
|
255 |
$('.mitem').removeClass('info'); |
|
256 |
computedSelect(); |
|
257 |
}); |
|
258 |
I.searchpiciBtn.click(function (e) { |
|
259 |
e.preventDefault(); |
|
260 |
if($('#piciKeyword').val()!=''){ |
|
261 |
vm.list.removeAll(); |
|
262 |
$.each(I._MDB, function (index, value) { |
|
263 |
if(value.tdmx_fdcph.indexOf($('#piciKeyword').val())>0){ |
|
264 |
if(I.bindNumBtn.hasClass('btn-info')){ |
|
265 |
if (value.tdmx_fdcph() !== '') { |
|
266 |
vm.list.push(value); |
|
267 |
if(value.chooseCli){ |
|
268 |
$('.mitem:last').addClass("info"); |
|
269 |
} |
|
270 |
} |
|
271 |
}else if(I.unbindNumBtn.hasClass('btn-info')){ |
|
272 |
if (value.tdmx_fdcph() == '') { |
|
273 |
vm.list.push(value); |
|
274 |
if(value.chooseCli){ |
|
275 |
$('.mitem:last').addClass("info"); |
|
276 |
} |
|
277 |
} |
|
278 |
}else{ |
|
279 |
vm.list.push(value); |
|
280 |
if(value.chooseCli){ |
|
281 |
$('.mitem:last').addClass("info"); |
|
282 |
} |
|
283 |
} |
|
284 |
} |
|
285 |
}); |
|
286 |
setMaterialTableEvent(); |
|
287 |
computedSelect(); |
|
288 |
}else{ |
|
289 |
vm.list.removeAll(); |
|
290 |
$('.mStatus').removeClass('btn-info'); |
|
291 |
I.unbindNumBtn.addClass('btn-info'); |
|
292 |
$.each(I._MDB, function (index, value) { |
|
293 |
if (value.tdmx_fdcph()== '') { |
|
294 |
vm.list.push(value); |
|
295 |
if(value.chooseCli){ |
|
296 |
$('.mitem:last').addClass("info"); |
|
297 |
} |
|
298 |
} |
|
299 |
}); |
|
300 |
setMaterialTableEvent(); |
|
301 |
computedSelect(); |
|
302 |
} |
|
303 |
|
|
304 |
}); |
|
305 |
I.clearSelectBtn.click(function (e) { |
|
306 |
e.preventDefault(); |
|
307 |
for(var i=0;i<I._MDB.length;i++){ |
|
308 |
I._MDB[i].chooseCli=false; |
|
309 |
} |
|
310 |
$('.mitem').removeClass('info'); |
|
311 |
computedSelect(); |
|
312 |
}); |
|
313 |
I.SortBtn.click(function (e) { |
|
314 |
e.preventDefault(); |
|
315 |
I.modal.modal('show'); |
|
316 |
}); |
|
317 |
I.clearSortBtn.click(function (e) { |
|
318 |
e.preventDefault(); |
|
319 |
vm.soList.removeAll(); |
|
320 |
$.each(vm.oList(), function (index, value) { |
|
321 |
value.visible(true); |
|
322 |
}); |
|
323 |
}); |
|
324 |
I.ssortBtn.click(function(e){ |
|
325 |
e.preventDefault(); |
|
326 |
vm.list.removeAll(); |
|
327 |
I._MDB.sort(SortList); |
|
328 |
$.each(I._MDB, function (index, value) { |
|
329 |
// console.log('排序后:::'+value); |
|
330 |
if(I.bindNumBtn.hasClass('btn-info')){ |
|
331 |
if (value.tdmx_fdcph() !== '') { |
|
332 |
if($('#piciKeyword').val()=='' || value.tdmx_fdcph.indexOf($('#piciKeyword').val())>0){ |
|
333 |
vm.list.push(value); |
|
334 |
if(value.chooseCli){ |
|
335 |
$('.mitem:last').addClass("info"); |
|
336 |
} |
|
337 |
} |
|
338 |
} |
|
339 |
}else if(I.unbindNumBtn.hasClass('btn-info')){ |
|
340 |
if (value.tdmx_fdcph() == '') { |
|
341 |
if($('#piciKeyword').val()=='' || value.tdmx_fdcph.indexOf($('#piciKeyword').val())>0){ |
|
342 |
vm.list.push(value); |
|
343 |
if(value.chooseCli){ |
|
344 |
$('.mitem:last').addClass("info"); |
|
345 |
} |
|
346 |
} |
|
347 |
} |
|
348 |
}else{ |
|
349 |
if($('#piciKeyword').val()=='' || value.tdmx_fdcph.indexOf($('#piciKeyword').val())>0){ |
|
350 |
vm.list.push(value); |
|
351 |
if(value.chooseCli){ |
|
352 |
$('.mitem:last').addClass("info"); |
|
353 |
} |
|
354 |
} |
|
355 |
} |
|
356 |
}); |
|
357 |
setMaterialTableEvent(); |
|
358 |
computedSelect(); |
|
359 |
}); |
|
360 |
|
|
361 |
} |
|
362 |
|
|
363 |
function getList(keyword) { |
|
364 |
$.post('/business/getBillofLadingItem.htm', { |
|
365 |
keyword: keyword |
|
366 |
}, function(data, textStatus, xhr) { |
|
367 |
vm.list.removeAll(); |
|
368 |
if (data.code >= 1) { |
|
369 |
//parent.showErrmsg(data.errmsg); |
|
370 |
swal({title:'',text:data.errmsg,type:'error',confirmButtonText:'确定'}); |
|
371 |
return; |
|
372 |
} |
|
373 |
if (data.code == 0) { |
|
374 |
I._MDB = []; |
|
375 |
data.item.td_shsj = data.item.td_shsj;//.slice(0, 19); |
|
376 |
vm.td(data.item); |
|
377 |
if (isList(data.list)) { |
|
378 |
$.each(data.list, function (index, value) { |
|
379 |
value.tdmx_fdcph = ko.observable(value.tdmx_fdcph); |
|
380 |
value.indx = index + ''; |
|
381 |
vm.list.push(value); |
|
382 |
value.chooseCli=false; |
|
383 |
I._MDB.push(value); |
|
384 |
}); |
|
385 |
} |
|
386 |
setMaterialTableEvent(); |
|
387 |
computedSelect(); |
|
388 |
updateNum(); |
|
389 |
return; |
|
390 |
} |
|
391 |
}, 'json'); |
|
392 |
} |
|
393 |
|
|
394 |
function updateNum() { |
|
395 |
var allNum = I._MDB.length; |
|
396 |
var unbindNum = 0; |
|
397 |
$.each(I._MDB, function (index, value) { |
|
398 |
value.tdmx_fdcph() === '' && unbindNum++; |
|
399 |
}); |
|
400 |
vm.allNum(allNum); |
|
401 |
vm.bindNum(allNum - unbindNum); |
|
402 |
vm.unbindNum(unbindNum); |
|
403 |
} |
|
404 |
|
|
405 |
function setMaterialTableEvent() { |
|
406 |
$('.mitem').unbind('click').click(function (e) { |
|
407 |
var index = $('.mitem').index($(this)); |
|
408 |
e.preventDefault(); |
|
409 |
if (vm.list()[index].fkStatus > 0){ |
|
410 |
return; |
|
411 |
} |
|
412 |
if (e.shiftKey) { |
|
413 |
setMaterialTrSelected(Math.min(index, I._lastIndex), Math.max(index, I._lastIndex)) |
|
414 |
} else { |
|
415 |
I._lastIndex = index; |
|
416 |
var pchcc=vm.list()[index].tdmx_fdcph; |
|
417 |
for(var mdblg=0;mdblg<I._MDB.length;mdblg++){ |
|
418 |
var pchmdb=I._MDB[mdblg].tdmx_fdcph; |
|
419 |
if(pchmdb==pchcc){ |
|
420 |
I._MDB[mdblg].chooseCli=I._MDB[mdblg].chooseCli?false:true; |
|
421 |
break; |
|
422 |
} |
|
423 |
} |
|
424 |
$(this).toggleClass('info'); |
|
425 |
} |
|
426 |
computedSelect(); |
|
427 |
}); |
|
428 |
} |
|
429 |
|
|
430 |
function setMaterialTrSelected(start, end) { |
|
431 |
$.each($('.mitem'), function (index, value) { |
|
432 |
if (index >= start && index <= end) { |
|
433 |
if (vm.list()[index].fkStatus > 0){ |
|
434 |
return; |
|
435 |
} |
|
436 |
var pchcc=vm.list()[index].tdmx_fdcph; |
|
437 |
for(var mdblg=0;mdblg<I._MDB.length;mdblg++){ |
|
438 |
var pchmdb=I._MDB[mdblg].tdmx_fdcph; |
|
439 |
if(pchmdb==pchcc){ |
|
440 |
I._MDB[mdblg].chooseCli=I._MDB[mdblg].chooseCli?false:true; |
|
441 |
break; |
|
442 |
} |
|
443 |
} |
|
444 |
$(this).addClass('info'); |
|
445 |
} |
|
446 |
}); |
|
447 |
} |
|
448 |
|
|
449 |
function computedSelect() { |
|
450 |
/* var selectedNum = 0; |
|
451 |
var selectedPZ = 0; |
|
452 |
$.each($('.bitem.info'), function (index, value) { |
|
453 |
var indx = $(this).attr('data-indx'); |
|
454 |
var obj = vm.list()[indx]; |
|
455 |
selectedNum += obj.td_wfdsl; |
|
456 |
selectedPZ += obj.td_wfdzl; |
|
457 |
}); |
|
458 |
vm.selectedNum(selectedNum); |
|
459 |
vm.selectedPZ(selectedPZ.toFixed(3));*/ |
|
460 |
} |
|
461 |
|
|
462 |
|
|
463 |
function getCompanyList() { |
|
464 |
$.post("/company/getList.htm", { |
|
465 |
searchword: I.companyKeyword.val(), |
|
466 |
page: 0, |
|
467 |
pagesize: 10, |
|
468 |
pages: 1, |
|
469 |
}, |
|
470 |
function (data, textStatus, jqXHR) { |
|
471 |
I.VDB = []; |
|
472 |
if (data.code >= 1) { |
|
473 |
swal({title:'',text:data.errmsg,type:'error',confirmButtonText:'确定'}); |
|
474 |
return; |
|
475 |
} |
|
476 |
if (data.code == 0) { |
|
477 |
vm.vList.removeAll(); |
|
478 |
if (isList(data.list)) { |
|
479 |
$.each(data.list, function (index, value) { |
|
480 |
value.indx = index + ''; |
|
481 |
value.ywdyNames =''; |
|
482 |
value.ywList.forEach(yw=> { |
|
483 |
value.ywdyNames += yw.name + "," |
|
484 |
}) |
|
485 |
value.ywdyNames = value.ywdyNames.replace(/,$/,'') |
|
486 |
vm.vList.push(value); |
|
487 |
}); |
|
488 |
} |
|
489 |
$('.vitem').click(function (e) { |
|
490 |
$('.vitem').removeClass('info'); |
|
491 |
$(this).addClass('info'); |
|
492 |
}); |
|
493 |
return; |
|
494 |
} |
|
495 |
}, |
|
496 |
"json" |
|
497 |
); |
|
498 |
} |
|
499 |
|
|
500 |
|
|
501 |
function valid(){ |
|
502 |
var isValid = false; |
|
503 |
var iF = $('#form'); |
|
504 |
iF.validate({ |
|
505 |
rules: { |
|
506 |
'vehicleId': { |
|
507 |
required: true, |
|
508 |
isPlateNumber: true |
|
509 |
}, |
|
510 |
'driver': { |
|
511 |
required: true, |
|
512 |
}, |
|
513 |
'phone': { |
|
514 |
required: true, |
|
515 |
isPhone: true |
|
516 |
}, |
|
517 |
'IDNum': { |
|
518 |
required: true, |
|
519 |
} |
|
520 |
}, |
|
521 |
messages: { |
|
522 |
'vehicleId': { |
|
523 |
required: '不能为空!', |
|
524 |
isPlateNumber: '车牌号不正确!' |
|
525 |
}, |
|
526 |
'driver': { |
|
527 |
required: '不能为空!', |
|
528 |
}, |
|
529 |
'phone': { |
|
530 |
required: '不能为空!', |
|
531 |
isPhone: '手机号不正确!' |
|
532 |
}, |
|
533 |
'IDNum': { |
|
534 |
required: '不能为空!', |
|
535 |
} |
|
536 |
}, |
|
537 |
errorPlacement: function (err, element) { |
|
538 |
var p = element.parents('.form-group').eq(0); |
|
539 |
var d = p.find('.text-error').eq(0); |
|
540 |
d.css('color', '#D9534F'); |
|
541 |
err.appendTo(d); |
|
542 |
} |
|
543 |
}) |
|
544 |
isValid = iF.valid(); |
|
545 |
return isValid; |
|
546 |
} |
|
547 |
|
|
548 |
|
|
549 |
function clearError() { |
|
550 |
$('#form input').removeClass('error'); |
|
551 |
$('#form .text-error').html(''); |
|
552 |
} |
|
553 |
|
|
554 |
function autoHeight() { |
|
555 |
$('.page-content').css('min-height', $(parent.window).height() - 117); |
|
556 |
$('.table-responsive').css('height', $(parent.window).height() - 275); |
|
557 |
$('.split').css('left', $('.table-vehicle').width() + 12); |
|
558 |
} |
|
559 |
|
|
560 |
function validMessage(message, cb, cbparams) { |
|
561 |
$("#modalContent").html(message); |
|
562 |
$("#dialog-confirm").removeClass('hide').dialog({ |
|
563 |
resizable: false, |
|
564 |
width: '320', |
|
565 |
modal: true, |
|
566 |
title: "<div class='widget-header'><h4 class='smaller'><i class='ace-icon fa fa-exclamation-triangle red'></i>确认信息</h4></div>", |
|
567 |
title_html: true, |
|
568 |
position: { my: "center", at: "center", of: window }, |
|
569 |
buttons: [ |
|
570 |
{ |
|
571 |
html: "<i class='ace-icon fa fa-trash-o bigger-110'></i> 确定", |
|
572 |
"class" : "btn btn-danger btn-minier", |
|
573 |
click: function() { |
|
574 |
$( this ).dialog( "close" ); |
|
575 |
cb(cbparams); |
|
576 |
} |
|
577 |
} |
|
578 |
, |
|
579 |
{ |
|
580 |
html: "<i class='ace-icon fa fa-times bigger-110'></i> 取消", |
|
581 |
"class" : "btn btn-minier", |
|
582 |
click: function() { |
|
583 |
$( this ).dialog( "close" ); |
|
584 |
} |
|
585 |
} |
|
586 |
] |
|
587 |
}); |
|
588 |
} |
|
589 |
|
|
590 |
|
|
591 |
function doCompanyBind() { |
|
592 |
$.each($('.vitem.info'), function (index, value) { |
|
593 |
let val = vm.vList()[$(this).attr('data-indx')] |
|
594 |
vm.companyNo(val.companyNo); |
|
595 |
vm.companyName(val.name); |
|
596 |
}); |
|
597 |
$(".vitem.info").removeClass("info"); |
|
598 |
// I.companyBindBtn.prop('disabled', true); |
|
599 |
|
|
600 |
// var arr = getSelectBiz(); |
|
601 |
// var company = ko.mapping.toJS(vm.o()); |
|
602 |
|
|
603 |
} |
|
604 |
|
|
605 |
function SortList(Obj1,Obj2){ |
|
606 |
var reval=0; |
|
607 |
$.each(vm.soList(), function (index, value) { |
|
608 |
var ASCStr=value.result(); |
|
609 |
var fieLd=value.target; |
|
610 |
if(ASCStr==null||ASCStr==''){ |
|
611 |
ASCStr="asc"; |
|
612 |
} |
|
613 |
if(fieLd==null||fieLd==''){ |
|
614 |
reval=0; |
|
615 |
} |
|
616 |
if("asc"==ASCStr){ |
|
617 |
if(!isNaN(Obj1[fieLd])){ |
|
618 |
if(Obj1[fieLd]-Obj2[fieLd]>0){ |
|
619 |
reval=1; |
|
620 |
return false; |
|
621 |
}else if(Obj1[fieLd]-Obj2[fieLd]<0){ |
|
622 |
reval=-1; |
|
623 |
return false; |
|
624 |
}else{ |
|
625 |
reval=0; |
|
626 |
} |
|
627 |
}else{ |
|
628 |
if(Obj1[fieLd]> Obj2[fieLd]){ |
|
629 |
reval=1; |
|
630 |
return false; |
|
631 |
}else if(Obj1[fieLd]< Obj2[fieLd]){ |
|
632 |
reval=-1; |
|
633 |
return false; |
|
634 |
}else{ |
|
635 |
reval=0; |
|
636 |
} |
|
637 |
} |
|
638 |
}else{ |
|
639 |
if(!isNaN(Obj1[fieLd])){ |
|
640 |
if(Obj2[fieLd]-Obj1[fieLd]>0){ |
|
641 |
reval=1; |
|
642 |
return false; |
|
643 |
}else if(Obj2[fieLd]-Obj1[fieLd]<0){ |
|
644 |
reval=-1; |
|
645 |
return false; |
|
646 |
}else{ |
|
647 |
reval=0; |
|
648 |
} |
|
649 |
}else{ |
|
650 |
if(Obj2[fieLd]> Obj1[fieLd]){ |
|
651 |
reval=1; |
|
652 |
return false; |
|
653 |
}else if(Obj2[fieLd]< Obj1[fieLd]){ |
|
654 |
reval=-1; |
|
655 |
return false; |
|
656 |
}else{ |
|
657 |
reval=0; |
|
658 |
} |
|
659 |
} |
|
660 |
|
|
661 |
} |
|
662 |
}); |
|
663 |
return reval; |
|
664 |
|
|
665 |
} |
|
666 |
function addSort(item) { |
|
667 |
item.visible(false); |
|
668 |
var obj = { |
|
669 |
key: item.key, |
|
670 |
target: item.value, |
|
671 |
result: ko.observable('asc') |
|
672 |
} |
|
673 |
vm.soList.push(obj); |
|
674 |
} |
|
675 |
|
|
676 |
function removeSort(item) { |
|
677 |
vm.soList.remove(item); |
|
678 |
$.each(vm.oList(), function (index, value) { |
|
679 |
value.key === item.key && value.visible(true); |
|
680 |
}); |
|
681 |
} |