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