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