提交 | 用户 | 时间
|
58d006
|
1 |
/** |
A |
2 |
* date: |
|
3 |
* author: neeler |
|
4 |
*/ |
|
5 |
|
|
6 |
// var data_ = Mock.mock('/biz/weightDoc/getItemDetails.htm', {"imgList":["/WeightPic/01002/2017/11/02/E001002201711020002GrossPic1.jpg","/WeightPic/01002/2017/11/02/E001002201711020002GrossPic2.jpg","/WeightPic/01002/2017/11/02/E001002201711020002GrossPic3.jpg","/WeightPic/01002/2017/11/02/E001002201711020002TarePic1.jpg","/WeightPic/01002/2017/11/02/E001002201711020002TarePic2.jpg","/WeightPic/01002/2017/11/02/E001002201711020002TarePic3.jpg"],"item":{"id":"a05f74eb-db2a-40d8-9523-cac64e7ad0bd","poundNo":"E001002201711020002","businessNo":"BO201711020002","tareWeighman":"自动称重","tare":16680.0,"taretime":"2017-11-02 07:59","grossWeighman":"自动称重","gross":85560.0,"grosstime":"2017-11-02 09:12","fubang":0.0,"fubangtime":null,"weight":68880.0,"subtra1":0.0,"subtra2":0.0,"worsebang":0.0,"cardID":"3220065529","vehicleID":"豫AE8500","whousename":"老厂2#地磅","whouseNo":"01002","tarePound":"01002","grossPound":"01002","tareFrom":"auto","lastSaveTime":"2017-11-02 09:12","note":null,"grossFrom":"auto","tares":"16680,","tareTimes":"2017-11-02 07:59:11,","grosses":"85560,","grossTimes":"2017-11-02 09:12:35,","weightStyle":"两次去皮","fromunitno":"10","tounitno":"32","fromunitname":"板带一分厂","tounitname":"河南明泰科技发展有限公司","materialguige":"1.47*1250*2500","materialname":"1系热轧板","materialno":"C1S001","balanceWeight":null,"primaryNetWeight":null,"wdstate":"正常","destroyTime":null,"destroyer":null,"batchNo":"01006_20171102075917","canfub":false,"vtexception":"0","vgexception":"0","vwexception":"0"},"code":0}) |
|
7 |
|
|
8 |
var HOSTNAME=window.location.hostname; |
|
9 |
|
|
10 |
var Obj = { |
|
11 |
id: '', |
|
12 |
poundNo: '', |
|
13 |
businessNo: '', |
|
14 |
tareWeighman: '', |
|
15 |
tare: '', |
|
16 |
taretime: '', |
|
17 |
grossWeighman: '', |
|
18 |
gross: '', |
|
19 |
grosstime: '', |
|
20 |
fubang: '', |
|
21 |
fubangtime: '', |
|
22 |
weight: '', |
|
23 |
subtra1: '', |
|
24 |
subtra2: '', |
|
25 |
worsebang: '', |
|
26 |
cardID: '', |
|
27 |
vehicleID: '', |
|
28 |
whousename: '', |
|
29 |
whouseNo: '', |
|
30 |
tarePound: '', |
|
31 |
grossPound: '', |
|
32 |
tareFrom: '', |
|
33 |
lastSaveTime: '', |
|
34 |
note: '', |
|
35 |
grossFrom: '', |
|
36 |
tares: '', |
|
37 |
tareTimes: '', |
|
38 |
grosses: '', |
|
39 |
grossTimes: '', |
|
40 |
weightStyle: '', |
|
41 |
fromunitno: '', |
|
42 |
tounitno: '', |
|
43 |
fromunitname: '', |
|
44 |
tounitname: '', |
|
45 |
materialguige: '', |
|
46 |
materialname: '', |
|
47 |
materialno: '', |
|
48 |
balanceWeight: '', |
|
49 |
primaryNetWeight: '', |
|
50 |
wdstate: '', |
|
51 |
destroyTime: '', |
|
52 |
destroyer: '', |
|
53 |
batchNo: '', |
|
54 |
} |
|
55 |
|
|
56 |
|
|
57 |
window.I = { |
|
58 |
workernamev: $('#workername').val(), |
|
59 |
poundNov: $('#poundNo').val(), |
|
60 |
printP: $('#printP') |
|
61 |
} |
|
62 |
|
|
63 |
var ViewModel = function() { |
|
64 |
var self = this; |
|
65 |
self.o = ko.observable(ko.mapping.fromJS(Obj)); |
|
66 |
self.list = ko.observableArray(); |
|
67 |
|
|
68 |
self.bussinessDetails = function() { |
|
69 |
newTab(); |
|
70 |
} |
|
71 |
} |
|
72 |
|
|
73 |
$(function () { |
|
74 |
window.vm = new ViewModel(); |
|
75 |
ko.applyBindings(vm); |
|
76 |
if (!!I.poundNov) { |
|
77 |
getItem(I.poundNov); |
|
78 |
} |
|
79 |
pageInit(); |
|
80 |
}); |
|
81 |
|
|
82 |
function pageInit() { |
|
83 |
I.printP.click(function (e) { |
|
84 |
e.preventDefault(); |
|
85 |
// var cardno = vm.o().cardno; |
|
86 |
// var gatesNo = I.gatesNo; |
|
87 |
// if (cardno != '' && gatesNo != '') { |
|
88 |
// canPrint(cardno, gatesNo); |
|
89 |
// } |
|
90 |
printTab(); |
|
91 |
}); |
|
92 |
} |
|
93 |
|
|
94 |
function printTab() { |
|
95 |
var poundNo = vm.o().poundNo; |
|
96 |
parent.closableTab.addTab({ |
|
97 |
'id': poundNo, |
|
98 |
'name': '打印磅单', |
|
99 |
'url': encodeURI('http://' + HOSTNAME + ':9088/ReportServer?reportlet=print%2Fprintdj_gbd_all.cpt£No=' + poundNo + '&pname=' + I.workernamev), |
|
100 |
'closable': true |
|
101 |
}); |
|
102 |
} |
|
103 |
|
|
104 |
function newTab(item) { |
|
105 |
parent.closableTab.addTab({ |
|
106 |
'id': new Date().getTime(), |
|
107 |
'name': '业务详情', |
|
108 |
'url': '/business/initDetalis.htm?bussinessNo=' + vm.o().businessNo, |
|
109 |
'closable': true |
|
110 |
}); |
|
111 |
} |
|
112 |
|
|
113 |
function getItem(poundNo) { |
|
114 |
$.post("/biz/weightDoc/getItemDetails.htm", {poundNo: poundNo}, |
|
115 |
function (data, textStatus, jqXHR) { |
|
116 |
if (data.code >= 1) { |
|
117 |
swal({title:'',text:data.errmsg,type:'error',confirmButtonText:'确定'}); |
|
118 |
return; |
|
119 |
} |
|
120 |
if (data.code == 0) { |
|
121 |
data.item.balanceWeight = (data.item.weight - data.item.subtra1 - data.item.subtra2 + '').weightFormat(); |
|
122 |
data.item.gross = (data.item.gross + '').weightFormat(); |
|
123 |
data.item.tare = (data.item.tare + '').weightFormat(); |
|
124 |
data.item.weight = (data.item.weight + '').weightFormat(); |
|
125 |
data.item.subtra1 = (data.item.subtra1 + '').weightFormat(); |
|
126 |
data.item.subtra2 = (data.item.subtra2 + '').weightFormat(); |
|
127 |
data.item.primaryNetWeight = (data.item.primaryNetWeight + '').weightFormat(); |
|
128 |
vm.o(data.item); |
|
129 |
if (isList(data.imgList)) { |
|
130 |
$.each(data.imgList, function (index, value) { |
|
131 |
vm.list.push({url: value}); |
|
132 |
}); |
|
133 |
colorboxInit(); |
|
134 |
} |
|
135 |
} |
|
136 |
}, |
|
137 |
"json" |
|
138 |
); |
|
139 |
} |
|
140 |
|
|
141 |
function colorboxInit() { |
|
142 |
var $overflow = ''; |
|
143 |
var colorbox_params = { |
|
144 |
rel: 'colorbox', |
|
145 |
reposition:true, |
|
146 |
scalePhotos:true, |
|
147 |
scrolling:false, |
|
148 |
previous:'<i class="ace-icon fa fa-arrow-left"></i>', |
|
149 |
next:'<i class="ace-icon fa fa-arrow-right"></i>', |
|
150 |
close:'×', |
|
151 |
current:'{current} of {total}', |
|
152 |
maxWidth:'100%', |
|
153 |
maxHeight:'100%', |
|
154 |
onOpen:function(){ |
|
155 |
$overflow = document.body.style.overflow; |
|
156 |
document.body.style.overflow = 'hidden'; |
|
157 |
}, |
|
158 |
onClosed:function(){ |
|
159 |
document.body.style.overflow = $overflow; |
|
160 |
}, |
|
161 |
onComplete:function(){ |
|
162 |
$.colorbox.resize(); |
|
163 |
} |
|
164 |
}; |
|
165 |
|
|
166 |
$('.ace-thumbnails [data-rel="colorbox"]').colorbox(colorbox_params); |
|
167 |
$("#cboxLoadingGraphic").html("<i class='ace-icon fa fa-spinner orange fa-spin'></i>");//let's add a custom loading icon |
|
168 |
$(document).one('ajaxloadstart.page', function(e) { |
|
169 |
$('#colorbox, #cboxOverlay').remove(); |
|
170 |
}); |
|
171 |
} |
|
172 |
|
|
173 |
String.prototype.weightFormat = function() { |
|
174 |
if (this + '' == 'null' || this + '' == '') return; |
|
175 |
var arr = (this + '').split('.'); |
|
176 |
var i = parseInt(arr[0].length / 3); |
|
177 |
var j = arr[0].length % 3; |
|
178 |
var a = []; |
|
179 |
var s = ''; |
|
180 |
if (!!j) { |
|
181 |
a.push(arr[0].substring(0, j)); |
|
182 |
} |
|
183 |
for (var m = 0; m < i; m++) { |
|
184 |
a.push(arr[0].substring(m * 3 + j, (m+1) * 3 + j)); |
|
185 |
} |
|
186 |
if (arr.length == 1) { |
|
187 |
return a.join(',') + '.00'; |
|
188 |
} else { |
|
189 |
if (arr[1].length > 2) { |
|
190 |
s = arr[1].substring(0, 2); |
|
191 |
} else { |
|
192 |
s = (arr[1] + '00').substring(0, 2); |
|
193 |
} |
|
194 |
return a.join(',') + '.' + s; |
|
195 |
} |
|
196 |
} |