diff --git a/.gitignore b/.gitignore index bbb6d817c8bc4d71d8ead16472f64d742ee08076..dc6e56a04b8853bdaf4b6275ab4ec52ea0982c62 100644 --- a/.gitignore +++ b/.gitignore @@ -211,4 +211,4 @@ local.properties .worksheet .gitignore -node_modules/.bin/adler32 +node_modules/* diff --git a/config/pom.json b/config/pom.json index 41f33747afa202cd46427c43352d266c792ee4c9..97e562507edeb7e3c32f1743301badac7af61027 100644 --- a/config/pom.json +++ b/config/pom.json @@ -23,9 +23,25 @@ "password": "123456a" } }, + "uatl": { + "version": "1.0.1", + "compressed": false, + "devView": true, + "validate": false, + "tmsMap" : true, + "host" : "http://120.77.8.167/wms-extra-web/", + "ticketUser": { + "phone": "11111111111", + "password": "123456a" + } + }, "pro": { "version": "1.0.1", "compressed": true, + "devView": true, + "validate": false, + "tmsMap" : true, + "host" : "http://10.20.30.137:8180/wms-extra-web/", "ticketUser": { "phone": "11111111111", "password": "plc_SUnCe)F*`WI" @@ -67,7 +83,19 @@ "password": "123456a" } }, - "lbLocal":{ + "luoLocal": { + "version": "1.0.1", + "compressed": false, + "devView": true, + "validate": false, + "tmsMap" : true, + "host" : "http://10.2.7.91:8080/", + "ticketUser": { + "phone": "11111111111", + "password": "123456a" + } + }, + "linLocal": { "version": "1.0.1", "compressed": false, "devView": true, @@ -78,5 +106,17 @@ "phone": "11111111111", "password": "123456a" } + }, + "laiLocal": { + "version": "1.0.1", + "compressed": false, + "devView": true, + "validate": false, + "tmsMap" : true, + "host" : "http://10.2.4.140:8080/", + "ticketUser": { + "phone": "11111111111", + "password": "123456a" + } } } \ No newline at end of file diff --git a/favicon.ico b/favicon.ico index b5b67c53edd8b61c476766d63a01ae1cfaaad3d8..db5e5219096e85ae17bcc953bb07aed1bd809fa9 100644 Binary files a/favicon.ico and b/favicon.ico differ diff --git a/public/css/wms.css b/public/css/wms.css index 39cb267d9eb89291cbcd300d482190f992c859fa..1b54ccab56a10b4200bb4c9e17d06e969162c02f 100644 --- a/public/css/wms.css +++ b/public/css/wms.css @@ -47,7 +47,10 @@ position: relative; top: -4px; } - +.ngdialog-header{ + font-size: 14px; + margin-bottom: 5px; +} .search-input{ width: 160px; height: 26px; @@ -119,7 +122,7 @@ .layui-table tr, td, th, select, option { text-align: center !important; - border: 1px solid #cedce2 !important; + border: 1px solid #cedce2; cursor: pointer; } @@ -595,8 +598,249 @@ table tr.checkStatus{ margin-bottom: 20px; overflow: auto; } +/*#########################*/ +.wms-icon:hover{ + cursor:pointer; + color: #de531a; +} +.wms-icon i{ + font-size: 24px; + position: relative; + top:3px; + left:-2px; +} +.wms-bd-none-main td{ + border: 1px solid #fff !important; + padding: 0 5px; +} +.wms-bd-none td{ + border: 1px solid #f0f0f0 !important; + padding: 0 5px; +} +.wms-bd-none-main tbody tr:hover{ + background-color: #fff !important; +} +.wms-layer .layui-input{ + margin: 5px 0; + height: 24px; +} +.wms-layer-heard th{ + height: 24px; +} +.wms-layer-add-tr td{ + box-sizing: border-box; + padding:0 5px; +} +.wms-layer-btn{ + margin: 5px 0 0 0; + height: 20px; +} +.trSelect{ + background-color: rgb(233,240,216) !important; +} +/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/ + +.upload_btn{ + width: 30px; +} + +/*上传样式*/ +.upload_btn input[type=file]{ + float: left; + position: relative; + right: 0; + width: 120%; + opacity: 0; + filter: alpha(opacity=0); + outline: 0; + cursor: pointer !important; + top: -23px; + left:-5px; +} + +/*.brcPrintMain .wms-bcr-print-heard{font-family: "Arial Negreta", Arial;*/ + /*font-weight: 700;font-style: normal;font-size: 28px;margin-top: 10px; position: relative;top: 23px;}*/ +.brcPrintMain table {margin-bottom:10px !important;} +.print_outbound_receipt_top .wbph1{ box-sizing: border-box;text-align: center} +.print_outbound_receipt_top .wbph2{ font-size:16px;text-align:center} +.print_outbound_receipt_top .imgB{width:145px;margin:10px 30px;float:left} +.print_outbound_receipt_top .wbph4{text-align:center;margin: 13px 0} +.wbph5{box-sizing: border-box;padding-left: 634px} +.print_outbound_receipt_top .w80{width: 80px !important;} +.print_outbound_receipt_top .w120{width: 120px !important;} +.print_outbound_receipt_top .w306{width: 306px !important;} +.print_outbound_receipt_top .w174{width: 174px !important;} + +@media print { + .print_outbound_receipt{ + margin-left: 10px; + } +} + +/*打印出库交接单*/ +.print_outbound_receipt { +} +.print_outbound_receipt_top table td { + padding: 3px 5px !important; +} + +.print_outbound_receipt .layui-table,.print_outbound_receipt .layui-table > tr,.print_outbound_receipt .layui-table th,.print_outbound_receipt .layui-table td{ + border : solid 1px black !important; +} + +.print_outbound_receipt .layui-table th{ + background-color: transparent !important; +} + +.print_outbound_receipt_title{ + width: 100%; + height: 100px; +} + +.print_outbound_receipt_title .receipt_title_left{ + width: 160px; + height: 100%; + float: left; + padding-top: 20px; + margin-left:7%; +} + +.print_outbound_receipt_title .receipt_title_center{ + width: 300px; + height: 100%; + float: left; + font-size: 24px; + text-align: center; + font-weight:bold; + line-height: 80px; +} + +.print_outbound_receipt_title .receipt_title_right{ + width: 120px; + height: 100%; + float: left; +} + +.print_outbound_receipt_top{ + width: 100%; + height: 316px; +} + +.print_outbound_receipt_top .receipt_top_title{ + width: 28%; + height: 20px; + line-height: 20px; + font-size: 16px; + margin: 0 auto; +} +.brcPrintMain table{ + margin-bottom: 10px !important; +} + +.print_outbound_receipt_top .receipt_top_bar_code{ + width: 253px; + height: 100px; + text-align: center; + margin: 0 auto; + margin-top: 10px; +} + +.print_outbound_receipt_top .receipt_top_bar_code > img{ + height: 100px; +} + +.print_outbound_receipt_top .receipt_top_table{ + margin-top: 10px; + width: 100%; + height: 110px; +} + +.print_outbound_receipt_body{ + width: 100%; + height: auto; +} + +.print_outbound_receipt_down{ + margin-top: 15px; + width: 100%; + height: 160px; + border: 1px solid black; +} + +.print_outbound_receipt_down .print_outbound_receipt_down_left{ + width: 49%; + height:100%; + float: left; + border-right: 1px solid black; +} + +.print_outbound_receipt_down .print_outbound_receipt_down_right{ + width: 50%; + height:100%; + float: left; +} + +.print_outbound_receipt_down .print_outbound_receipt_down_left > div,.print_outbound_receipt_down .print_outbound_receipt_down_right > div{ + width: 100%; + height: 40px; + color: black; +} + +.print_outbound_receipt_down .print_outbound_receipt_down_left > div:last-child,.print_outbound_receipt_down .print_outbound_receipt_down_right > div:last-child{ + border-top: 1px solid black; +} +.print_outbound_receipt_down .print_outbound_receipt_down_left > div:last-child > div:first-child,.print_outbound_receipt_down .print_outbound_receipt_down_right > div:last-child > div:first-child{ + border-right: 1px solid black; +} + +.print_outbound_receipt_down .print_outbound_receipt_down_left > div:last-child > div,.print_outbound_receipt_down .print_outbound_receipt_down_right > div:last-child > div{ + width: 49%; + height: 100%; + float: left; +} + +.print_outbound_receipt_footer{ + width: 100%; + height: 20px; + line-height: 20px; + margin-top: 10px; + margin-bottom: 10px; +} + +.print_outbound_receipt_footer > div{ + width: 25%; + float: left; +} + +/*出库确认*/ +.out_confirm_left,.out_confirm_right{ + width: 50%; + height: 350px; + float: left; +} +.out_confirm_left > div:first-child,.out_confirm_right > div:first-child{ + width: 100%; + height: 35px; +} +.out_confirm_left > div:first-child > div:first-child,.out_confirm_right > div:first-child > div:first-child{ + width: 20%; + height: 100%; + float: left; + line-height: 35px; +} +.out_confirm_left > div:first-child > div:last-child,.out_confirm_right > div:first-child > div:last-child{ + width: 70%; + height: 100%; + float: left; +} +.out_confirm_left > div:last-child,.out_confirm_right > div:last-child{ + margin-top: 10px; + width: 90%; + height: 100%; + float: left; +} \ No newline at end of file diff --git a/public/favicon.ico b/public/favicon.ico index b5b67c53edd8b61c476766d63a01ae1cfaaad3d8..db5e5219096e85ae17bcc953bb07aed1bd809fa9 100644 Binary files a/public/favicon.ico and b/public/favicon.ico differ diff --git a/public/images/junma.png b/public/images/junma.png new file mode 100644 index 0000000000000000000000000000000000000000..816b0d0058ffbd36e2e4f1f3500857fb0abbf6c8 Binary files /dev/null and b/public/images/junma.png differ diff --git a/public/images/junma12.jpg b/public/images/junma12.jpg new file mode 100644 index 0000000000000000000000000000000000000000..bbeb902e2b53037d33703fe671edb3efe83f3d95 Binary files /dev/null and b/public/images/junma12.jpg differ diff --git a/public/images/traum.png b/public/images/traum.png new file mode 100644 index 0000000000000000000000000000000000000000..73a3c069ba53eb9afbd25250caf6e62502386095 Binary files /dev/null and b/public/images/traum.png differ diff --git a/public/js/ctrl/a.ctrl.js b/public/js/ctrl/a.ctrl.js index bfe9a9708c0e5ee1d11f5ed84b6efc97b67eab20..ac952b9ff3dcfd60b7607f4546cacfa5951f679a 100644 --- a/public/js/ctrl/a.ctrl.js +++ b/public/js/ctrl/a.ctrl.js @@ -58,22 +58,44 @@ wmsCtrl.controller('asnCtrl',['$scope','dropDownService','inStorageBillService', title : '验车登记', scope : scope }) - } + }; //打印二维码 click scope.printQrClick = function(){ - scope.Tools.dialog({ - controller : 'asnCtrl.dialog', - template : 'templates/inStorageManagement/asnManagement/print-qr-code.html', - closeByDocument : false, - closeByEscape : false, - data : { - }, - width : 550, - title : '打印二维码', - scope : scope - }) - } + var indexArr = scope.Tools.getTableSelectItemIndex('.asnTable'); //获取table所选的下标 + + var asnList = scope.Tools.getDataTOIndex(indexArr,scope.asnList); + + if(asnList.length == 0){ + scope.Tools.alert('请选择一条数据'); + return; + } + + var ids = new Array(); + for(var i = 0; i < asnList.length;i++){ + ids.push(asnList[i].atId); + } + + inStorageBillService.printAsnQrCode(ids) + .then(function(result){ + if(result.success){ + scope.Tools.dialog({ + controller : 'asnCtrl.dialog', + template : 'templates/inStorageManagement/asnManagement/print-qr-code.html', + closeByDocument : false, + closeByEscape : false, + data : { + printList : result.data + }, + width : 550, + title : '打印二维码', + scope : scope + }) + }else{ + scope.Tools.alert(result.message); + } + }) + }; //打印提车交接单 scope.printCarMentionedReceiptClick = function(){ @@ -245,14 +267,37 @@ wmsCtrl.controller('asnCtrl',['$scope','dropDownService','inStorageBillService', scope.refreshClick = function(){ scope.searchClick(); } + + //导入 file change + scope.fileChange = function(e){ + scope.setUploaderParam('jminbound/importAsnByExcel','file'); + scope.uploadAll(); + } }]) .controller('asnCtrl.dialog',['$scope',function(scope){ // asn controller dialog //打印列表 scope.printListClick = function(){ - scope.Tools.print($(".dialog-body")[0].outerHTML); + if(!scope.Tools.checkPrintInstall()){ //打印插件检测 + scope.Tools.downLoadPrintPlugIn(); //提示下载打印插件 + return; + } + scope.Tools.printHTML($(".dialog-body")[0].outerHTML,750,1); + } + + //打印所有的二维码 + scope.printAllQrClick = function(){ + if(!scope.Tools.checkPrintInstall()){ //打印插件检测 + scope.Tools.downLoadPrintPlugIn(); //提示下载打印插件 + return; + } + + angular.forEach(scope.ngDialogData.printList,function(v,k){ + scope.Tools.printQr(v.barcode,null,null,v.vin,1); + }) } - scope.checkCarChange = function(item){ //验车结果 change + //验车结果 change + scope.checkCarChange = function(item){ if(item.value == scope.constant.checkCarResult.qualified){ //合格 scope.ngDialogData.checkCar.asnCheckDesc = '车辆验证合格'; }else if(item.value == scope.constant.checkCarResult.unqualified){ //不合格 diff --git a/public/js/ctrl/b.ctrl.js b/public/js/ctrl/b.ctrl.js index d50dc8d70c96cf45d36ce938c3ebaf64d6c46093..6e17db434635f0aade0fd54c6cf4bfc38bfa70c8 100644 --- a/public/js/ctrl/b.ctrl.js +++ b/public/js/ctrl/b.ctrl.js @@ -1,4 +1,519 @@ /** - * Created by houjianhui on 2017/7/19. + * Created by lihao on 2017/10/20. borrowCarRegistration */ -'use strict'; \ No newline at end of file +'use strict'; +wmsCtrl.controller('borrowCarRegistrationCtrl',['$scope','Tools','$rootScope','$http','$timeout','ngDialog','borrowCarRegistrationService',function($scope,Tools,$rootScope,$http,$timeout,ngDialog,borrowCarRegistrationService){ + + //新增 + if($rootScope.bcrAddFlag){ + $scope.addFlag = false; + var bcidsArr = []; + $('.wms_bcr_table').find('td i').each(function(i,obj) { + if ($(obj).parent().hasClass('layui-form-checked')) { + var id = $(obj).parents('td').attr('bcid'); + bcidsArr.push(id); + } + }); + borrowCarRegistrationService.queryModifyDetail(bcidsArr[0]).then(function(data){ + if(data.success){ + $scope.addObj = data.data[0]; + $rootScope.rcrAddFlag = false; + } + }); + } else { + $scope.addFlag = true; + } + + $scope.addNew = function(){ + + ngDialog.open({ + template: "templates/vehicleBorrowingManagement/layer/bcr-addNew.html", + controller: "borrowCarRegistrationCtrl", + title: $rootScope.bcrAddFlag?'编辑借用信息':'借用登记', + width:710 + }); + + //加载完页面后再渲染下页面 + $timeout(function(){ + layui.use('form',function(){ + var form = layui.form(); + form.render(); + //全选 + }) + },50); + }; + // 添加新增单 + $scope.addObj = { + bcBorrowName:'', + bcBorrowDepartment:'', + bcBorrowTel:'', + bcBorrowDate:'', + bcEstimatedReturnDate:'', + bcBorrowReason:'', + wmsBorrowCarDetailList:[] + + }; + $scope.wmsTemp = { + bdId:null, + bdCarSeries:'', + bdCarSpecname:'', + bdCarColorname:'', + num:'' + }; + + $scope.isNull = function(obj){ + for(var key in obj ){ + if(obj[key]==''){ + return true + } + } + return false + }; + + //添加车辆 + $scope.addObj.wmsBorrowCarDetailList = []; + + $scope.addCar = function(){ + + $scope.addbcrInfo = true; + + if( !$scope.isNull($scope.wmsTemp)){ + $scope.addObj.wmsBorrowCarDetailList.push($scope.wmsTemp); + //加载完页面后再渲染下页面 + $timeout(function(){ + layui.use('form',function(){ + var form = layui.form(); + form.render(); + //全选 + }) + },50); + + $scope.wmsTemp = { + bdId:null, + bdCarSeries:'', + bdCarSpecname:'', + bdCarColorname:'', + num:'' + }; + } else { + + } + }; + + //删除车辆信息 + $scope.delCar = function(){ + var indexArr = []; + $('.wmsCarInfo').find('td i').each(function(i,obj) { + if ($(obj).parent().hasClass('layui-form-checked')) { + var index = $(obj).parents('td').attr('index'); + indexArr.push(index); + } + }); + for(var i=0; i1){ + $scope.Tools.alert('编辑只能选择一条!'); + } + }; + + layui.use('form',function(){ + var form = layui.form(); + form.render(); + //全选 + form.on('checkbox(allChoose)', function (data) { + $(data.elem).parent().parent().parent().parent().parent().find('tr').toggleClass('trSelect'); + var child = $(data.elem).parents('table').find('tbody input[type="checkbox"]'); + child.each(function(index, item){ + item.checked = data.elem.checked; + if(data.elem.checked){ + $(item).parents('tr').addClass('trSelect'); + } else { + $(item).parents('tr').removeClass('trSelect'); + } + }); + form.render('checkbox'); + }); + + // 前面选择框选中 + form.on('checkbox(test)',function(data){ + if(data.elem.checked){ + $(data.elem).parents('tr').addClass('trSelect'); + } else { + $(data.elem).parents('tr').removeClass('trSelect'); + } + }); + }); + + // 显示更多条件 + $scope.moreClick = function(){ + $('.otherForm').slideToggle(500); + }; + $rootScope.bcrMainList = ''; + + + $scope.fristSelect = true; + + // 获取列表 + $scope.getList = function(){ + var params = { + pageNo:$scope.pageNo || 1, + pageSize:$scope.pageSize || 10 + }; + params = angular.extend(params,$scope.search); + borrowCarRegistrationService.borrowLine(params) + .then(function(result){ + if(result.success){ + + $rootScope.bcrMainList = result.data.wmsBorrowCarList; + + if($scope.fristSelect){ + $scope.Tools.page(document.getElementById('pages'),{ + pages : result.data.totalPage, + curr : result.data.pageNo, + count : result.data.totalRecord, + limit:result.data.pageSize + ,limits: [10,20,30,40,50] + },function(obj, first){ + $scope.fristSelect = first; //设置状态 + + if(!first){ //判断不是第一次加载 + var param = {}; + param.pageNo = obj.curr; //当前页 + param.pageSize = obj.limit; //最大页 + $scope.pageSize = obj.limit; //设置最大页 + $scope.pageNo = obj.curr; //设置当前页 + $scope.getList(param); + } + }) + } + }else{ + scope.Tools.alert(result.message); + } + }) + }; + $rootScope.bcrGetList = $scope.getList; + + + //新增保存 + $scope.addSave = function(){ + + if ($scope.isNull($scope.addObj)){ + $scope.Tools.alert('请完整填写 借车人信息 和 车辆信息 !'); + + } else { // bcBorrowDate:'', bcEstimatedReturnDate:'', + if($scope.Tools.isRange($scope.addObj.bcBorrowDate,$scope.addObj.bcEstimatedReturnDate)){ + borrowCarRegistrationService.add($scope.addObj).then(function(data){ + if(data.success){ + $scope.Tools.alert('新增保存成功'); + ngDialog.closeAll(); + $rootScope.bcrGetList(); + + $rootScope.bcDetail = ''; + + } else { + $scope.Tools.alert(data.message); + } + }) + } else { + $scope.Tools.alert('预计还车时间必须大于等于借车时间!'); + } + + } + + }; + + $scope.getList(); + + $scope.search ={}; + $scope.search.bcBorrowName = ''; + $scope.search.bcBorrowDepartment = ''; + $scope.search.borrowStartTime = ''; + $scope.search.borrowEndTime = ''; + +// 查询 + $scope.resetClick = function(){ + $scope.search.bcBorrowName = ''; + $scope.search.bcBorrowDepartment = ''; + $scope.search.borrowStartTime = ''; + $scope.search.borrowEndTime = ''; + }; +//刷新 + $scope.refreshA = function(){ + $scope.pageSize = 10; + $scope.resetClick(); + $scope.getList(); + }; + + $scope.fristSelectT = true; +// 获取信息信息 + $scope.getDetail = function(e){ + var id = angular.element(e.target).parent('tr').attr('bcid'); + borrowCarRegistrationService.findBorrowDetail(id).then(function(result){ + if(result.success){ + $rootScope.bcDetail = result.data; + } else { + $scope.Tools.alert(result.message); + } + }) + } +}]) + .controller('borrowAndReturnRecordSearchCtrl',['$scope','$rootScope','$http','$timeout','ngDialog','borrowAndReturnRecordSearchService',function($scope,$rootScope,$http,$timeout,ngDialog,borrowAndReturnRecordSearchService){ + + $scope.search ={}; + $scope.search.vin = ''; + $scope.search.isReturn = ''; + $scope.search.borrowName = ''; + $scope.search.returnName = ''; + $scope.search.returnStartTime = ''; + $scope.search.returnEndTime = ''; + + $scope.fristSelect = true; + // 获取列表 + $scope.getList = function(){ + var params = { + pageNo:$scope.pageNo || 1, + pageSize:$scope.pageSize || 10 + }; + params = angular.extend(params,$scope.search); + borrowAndReturnRecordSearchService.borrowHistoryLine(params) + .then(function(result){ + if(result.success){ + $scope.mainList = result.data.wmsBorrowCarList; + if($scope.fristSelect){ + $scope.Tools.page(document.getElementById('pages'),{ + pages : result.data.totalPage, + curr : result.data.pageNo, + count : result.data.totalRecord + },function(obj, first){ + $scope.fristSelect = first; //设置状态 + + if(!first){ //判断不是第一次加载 + var param = {}; + param.pageNo = obj.curr; //当前页 + param.pageSize = obj.limit; //最大页 + $scope.pageSize = obj.limit; //设置最大页 + $scope.pageNo = obj.curr; //设置当前页 + $scope.getList(param); + } + }) + } + }else{ + $scope.Tools.alert(result.message); + } + }) + }; + $scope.getList(); + + // 显示更多条件 + $scope.moreClick = function(){ + $('.otherForm').slideToggle(500); + }; + + //查询 + $scope.rcSearch = function(){ + + }; + + // 重置 + $scope.resetClick = function(){ + $scope.search.vin = ''; + $scope.search.isReturn = ''; + $scope.search.borrowName = ''; + $scope.search.returnName = ''; + $scope.search.returnStartTime = ''; + $scope.search.returnEndTime = ''; + }; + //刷新 + $scope.refreshA = function(){ + $scope.pageSize = 10; + $scope.resetClick(); + $scope.getList() + }; + }]) + .controller('bcrPrintCtrl',['$scope','Tools','$rootScope','$http','$timeout','ngDialog','borrowCarRegistrationService',function($scope,Tools,$rootScope,$http,$timeout,ngDialog,borrowCarRegistrationService){ + $scope.close = function(){ + ngDialog.closeAll(); + }; + + $scope.brcPrint = function(){ + Tools.printHTML($('.brcPrintMain')[0].outerHTML,790,1); + }; + + $scope.tableObj = ''; + function getTime() + { + var now = new Date(); + + var year = now.getFullYear(); //年 + var month = now.getMonth() + 1; //月 + var day = now.getDate(); //日 + + var hh = now.getHours(); //时 + var mm = now.getMinutes(); //分 + + var clock = year + "-"; + + if(month < 10) + clock += "0"; + + clock += month + "-"; + + if(day < 10) + clock += "0"; + + clock += day + " "; + + if(hh < 10) + clock += "0"; + + clock += hh + ":"; + if (mm < 10) clock += '0'; + clock += mm; + return clock; + } + + $scope.currTime = getTime(); + + // 获取打印列表 + borrowCarRegistrationService.printInfo($rootScope.currPrintID).then(function(data){ + if(data.success){ + $scope.tableObj = data.data; + } + }) + + }]); diff --git a/public/js/ctrl/i.ctrl.js b/public/js/ctrl/i.ctrl.js index a70d08c21196bd05ba4f8c1b373dc75040cfb26a..a1e8f00041bdeb564a783f4fc07009e4ac5afe19 100644 --- a/public/js/ctrl/i.ctrl.js +++ b/public/js/ctrl/i.ctrl.js @@ -19,7 +19,7 @@ wmsCtrl.controller('inStorageBillCtrl',['$scope','inStorageBillService','dropDow name:'我只是仓库1', value:'3' } - ] + ]; //品牌 var pp = [ @@ -284,7 +284,7 @@ wmsCtrl.controller('inStorageBillCtrl',['$scope','inStorageBillService','dropDow params = {}; } params.pageSize = params.pageSize ? params.pageSize : scope.constant.page.pageSize; - params.pageNo = params.pageNo ? params.pageNo : scope.constant.page.pageNo + params.pageNo = params.pageNo ? params.pageNo : scope.constant.page.pageNo; inStorageBillService.inStorageList(params) .then(function(result){ @@ -415,35 +415,19 @@ wmsCtrl.controller('inStorageBillCtrl',['$scope','inStorageBillService','dropDow }]) .controller('inputWorkCtrl',['$scope','inStorageBillService','stockUnitStrategyService','dropDownService',function(scope,inStorageBillService,stockUnitStrategyService,dropDownService){ //入库作业 - //收货质检 click + //收货质检 click - 君马 scope.receivingQualityTestingClick = function(){ - var indexArr = scope.Tools.getTableSelectItemIndex('.inputWorkTable'); //获取table所选的下标 - - var inputWorkList = scope.Tools.getDataTOIndex(indexArr,scope.inputWorkList); - - if(inputWorkList.length > 1){ - scope.Tools.alert('只能选择一条数据'); - return; - } - - //判断数据是否是未收货的数据 - for(var i = 0; i < inputWorkList.length;i++){ - if(inputWorkList[i].odStatus != scope.constant.orderStatus.wmsInboundCreate){ - scope.Tools.alert('只能选择未收货数据'); - return; - } - } - scope.Tools.dialog({ controller : 'inputWorkCtrl.dialog', template : 'templates/inStorageManagement/inputWork/receiving-quality-testing-form.html', closeByDocument : false, closeByEscape : false, data : { - quality : angular.copy(inputWorkList[0]), //质检对象 + /*quality : angular.copy(inputWorkList[0]), //质检对象*/ inspectionResults : scope.Tools.dropDown.inspectionResultsDropDown, //检验结果 dropDownDefault : { + qualityResult : scope.Tools.dropDown.inspectionResultsDropDown[0] } }, width : 600, @@ -454,33 +438,12 @@ wmsCtrl.controller('inStorageBillCtrl',['$scope','inStorageBillService','dropDow //西南库的收货质检 scope.receivingQualityTestingXnClick = function(){ - /*var indexArr = scope.Tools.getTableSelectItemIndex('.inputWorkTable'); //获取table所选的下标 - - var inputWorkList = scope.Tools.getDataTOIndex(indexArr,scope.inputWorkList); - - if(inputWorkList.length > 1){ - scope.Tools.alert('只能选择一条数据'); - return; - } - - //判断数据是否是未收货的数据 - for(var i = 0; i < inputWorkList.length;i++){ - if(inputWorkList[i].odStatus != scope.constant.orderStatus.wmsInboundCreate){ - scope.Tools.alert('只能选择未收货数据'); - return; - } - }*/ - scope.Tools.dialog({ controller : 'inputWorkCtrl.dialog', template : 'templates/inStorageManagement/inputWork/receiving-quality-testing-xn-form.html', closeByDocument : false, closeByEscape : false, data : { - /*quality : angular.copy(inputWorkList[0]), //质检对象 - inspectionResults : scope.Tools.dropDown.inspectionResultsDropDown, //检验结果*/ - dropDownDefault : { - } }, width : 600, title : '收货质检', @@ -527,7 +490,7 @@ wmsCtrl.controller('inStorageBillCtrl',['$scope','inStorageBillService','dropDow scope.Tools.alert(result.message); } }) - } + }; //更多条件默认值 scope.moreText = scope.constant.moreText.spread; @@ -608,7 +571,7 @@ wmsCtrl.controller('inStorageBillCtrl',['$scope','inStorageBillService','dropDow pageNo : scope.search.pageNo //当前页 } } - } + }; //列表 scope.fristSelect = true; //判断是否是第一次查询 @@ -768,18 +731,19 @@ wmsCtrl.controller('inStorageBillCtrl',['$scope','inStorageBillService','dropDow }]) .controller('inputWorkCtrl.dialog',['$scope','inStorageBillService',function(scope,inStorageBillService){ //入库作业 dialog - //查找收货入库单 keydown + //查找收货入库单 keydown -- 君马 scope.searchQualityKeyDown = function(e){ var keycode = window.event ? e.keyCode:e.which; if(keycode == 13){ //回车键 if(scope.ngDialogData.queryParam){ - inStorageBillService.queryByWaybillOrVin(scope.ngDialogData.queryParam) + if(scope.ngDialogData.queryParam.length != 17){ + scope.Tools.alert('请输入正确的17位vin码'); + return; + } + inStorageBillService.getInBoundInfoByVin(scope.ngDialogData.queryParam) .then(function(result){ if(result.success){ scope.ngDialogData.quality = result.data; - scope.ngDialogData.qualityResult = null; //检验结果置为空 - scope.ngDialogData.dropDownDefault.reservoirDrop = null; //库区置为空 - scope.ngDialogData.dropDownDefault.storageLocationDrop = null; //库位置为空 }else{ scope.Tools.alert(result.message); } @@ -826,58 +790,8 @@ wmsCtrl.controller('inStorageBillCtrl',['$scope','inStorageBillService','dropDow } } - //选择检验结果 - scope.inspectionResultChange = function(item){ - if(item.value == scope.constant.inspectionResults.asnOrderPass){ //合格 - var obj = { - alOdId : scope.ngDialogData.quality.odId, //订单id - alCustomerId : scope.ngDialogData.quality.odCustomerId, //货主id - alCustomerCode : scope.ngDialogData.quality.odCustomerCode, //货主code - alWaybillNo : scope.ngDialogData.quality.odWaybillNo, //单据号 - alVehicleSpecCode : scope.ngDialogData.quality.oddVehicleSpecCode, //车型 code - alVehicleSpecName : scope.ngDialogData.quality.oddVehicleSpecName, //车型 name - alVin : scope.ngDialogData.quality.oddVin //底盘号 - } - - //自动分配 - inStorageBillService.autoAssign(scope.userInfo.whCode,new Array(obj)) - .then(function(result){ - if(result.success){ - if(result.data){ - angular.forEach(result.data,function(value,key){ - //库区 - scope.ngDialogData.quality.oddWhZoneName = value.alTargetZoneName;//库区 name - scope.ngDialogData.quality.oddWhZoneCode = value.alTargetZoneCode;//库区 code - //库位 - scope.ngDialogData.quality.oddWhLocName = value.alTargetLocName;//库区 name - scope.ngDialogData.quality.oddWhLocCode = value.alTargetLocCode;//库区 code - }) - - //如果为空加载库区库位 - if(!scope.ngDialogData.quality.oddWhZoneName && !scope.ngDialogData.quality.oddWhLocName){ - scope.loadZoneLoc(); - }else{ - //设置为自动分配 - scope.ngDialogData.alType = scope.constant.distributionType.auto; - } - } - }else{ - scope.Tools.alert(result.message); - } - }) - }else{ //不合格 - //库区 - scope.ngDialogData.quality.oddWhZoneName = null;//库区 name - scope.ngDialogData.quality.oddWhZoneCode = null;//库区 code - //库位 - scope.ngDialogData.quality.oddWhLocName = null;//库区 name - scope.ngDialogData.quality.oddWhLocCode = null;//库区 code - scope.loadZoneLoc(); - } - } - //自动加载库区库位 - scope.loadZoneLoc = function(){ + /*scope.loadZoneLoc = function(){ //查询库区 inStorageBillService.reservoirList(scope.userInfo.whCode) .then(function(result){ @@ -904,10 +818,10 @@ wmsCtrl.controller('inStorageBillCtrl',['$scope','inStorageBillService','dropDow scope.Tools.alert(result.message); } }) - } + }*/ //收货确认click - scope.receivingConfirmaClick = function(){ + /* scope.receivingConfirmaClick = function(){ angular.forEach(scope.ngDialogData.qualityList,function(value,key){ value.odCheckResult = scope.ngDialogData.qualityResult[key].value; @@ -924,81 +838,32 @@ wmsCtrl.controller('inStorageBillCtrl',['$scope','inStorageBillService','dropDow scope.Tools.alert(result.message); } }) - } + }*/ //收货质检成功 scope.receivingConfirmaClick = function(){ - if(!scope.ngDialogData.qualityResult){ - scope.Tools.alert('请选择检验结果'); + + if(!scope.ngDialogData.quality || !scope.ngDialogData.quality.odId){ + scope.Tools.alert('请输入VIN码查询数据'); return; - }else{ - //赋值检验结果 - scope.ngDialogData.quality.odCheckResult = scope.ngDialogData.qualityResult.value; - if(scope.ngDialogData.alType == scope.constant.distributionType.manual){ //手动分配 - //库区 - scope.ngDialogData.quality.oddWhZoneCode = scope.ngDialogData.dropDownDefault.reservoirDrop.locZoneCode; - scope.ngDialogData.quality.oddWhZoneName = scope.ngDialogData.dropDownDefault.reservoirDrop.locZoneCode; - //库位 - scope.ngDialogData.quality.oddWhLocCode = scope.ngDialogData.dropDownDefault.storageLocationDrop.locCode; - scope.ngDialogData.quality.oddWhLocName = scope.ngDialogData.dropDownDefault.storageLocationDrop.locName; - } } - //封装参数 + var obj = { - odId : scope.ngDialogData.quality.odId, //入库主id - odCode : scope.ngDialogData.quality.odCode, //订单CODE,WMS专用 - odCustomerId : scope.ngDialogData.quality.odCustomerId, //货主id - odCustomerCode : scope.ngDialogData.quality.odCustomerCode, //货主code - odCustomerName : scope.ngDialogData.quality.odCustomerName, //货主名称 - odDispatchNo : scope.ngDialogData.quality.odDispatchNo, //调度单号 - odWaybillNo : scope.ngDialogData.quality.odWaybillNo, //运单号 - odWaybillType : scope.ngDialogData.quality.odWaybillType, //运单类型 - odStatus : scope.ngDialogData.quality.odStatus, //订单状态 - odWhId : scope.ngDialogData.quality.odWhId, //仓库id - odWhCode : scope.ngDialogData.quality.odWhCode, //仓库code - odOriginCode : scope.ngDialogData.quality.odOriginCode, - odOrigin : scope.ngDialogData.quality.odOrigin, //起始地 - odDestCode : scope.ngDialogData.quality.odDestCode, //目的地 - odDest : scope.ngDialogData.quality.odDest,//目的地 - odCheckResult : scope.ngDialogData.quality.odCheckResult, //检验结果 - odCheckDesc : scope.ngDialogData.quality.odCheckDesc, //检验描述 - odSupplierParty : scope.ngDialogData.quality.odSupplierParty, //分供方 - odSupplierCode : scope.ngDialogData.quality.odSupplierCode, //分供方code - odSupplierName : scope.ngDialogData.quality.odSupplierName, //分供方name - odSupplierPhone : scope.ngDialogData.quality.odSupplierPhone, //分供方联系人手机号 - wmsInboundOrderDetailVOList : new Array({ - oddVehicleSpecCode : scope.ngDialogData.quality.oddVehicleSpecCode, //车型code - oddVehicleSpecName : scope.ngDialogData.quality.oddVehicleSpecName, //车型名称 - oddVehicleSpecDesc : scope.ngDialogData.quality.oddVehicleSpecDesc, //车型描述 - oddVin : scope.ngDialogData.quality.oddVin, //底盘号 - oddOdId : scope.ngDialogData.quality.odId, //入库单主id - oddOdCode : scope.ngDialogData.quality.odCode //订单CODE,WMS专用 - }), - wmsInboundAllocationVOList : new Array({ - alOdId : scope.ngDialogData.quality.odId, //订单id - alCustomerCode : scope.ngDialogData.quality.odCustomerCode, //货主code - alCustomerName : scope.ngDialogData.quality.alCustomerName, //货主name - alCustomerId : scope.ngDialogData.quality.alCustomerId, //货主id - alSourceZoneCode : scope.ngDialogData.quality.oddWhZoneCode, //库区code - alSourceZoneName : scope.ngDialogData.quality.oddWhZoneName, //库区name - alSourceLocCode : scope.ngDialogData.quality.oddWhLocCode, //库位code - alSourceLocName : scope.ngDialogData.quality.oddWhLocName, //库位name - alWaybillNo : scope.ngDialogData.quality.odWaybillNo, //运单号 - alVin : scope.ngDialogData.quality.oddVin, //底盘号 - alVehicleSpecCode : scope.ngDialogData.quality.oddVehicleSpecDesc, //车型描述 - alVehicleSpecName : scope.ngDialogData.quality.oddVehicleSpecName, //车型名称 - alType : scope.ngDialogData.alType //分配类型 - }) - }; + oddVin : scope.ngDialogData.quality.oddVin, //vin + odId : scope.ngDialogData.quality.odId, //id + odCheckResult : scope.ngDialogData.dropDownDefault.qualityResult.value, //检验结果 + odCheckDesc : scope.ngDialogData.quality.odCheckDesc, //检验描述 + userId : scope.userInfo.id + } //收货质检 - inStorageBillService.receivingInspection(obj) + inStorageBillService.deliverToConfirm(obj) .then(function(result){ if(result.success){ scope.Tools.alert('收货质检成功'); //在当前页刷新 scope.list(scope.listParam()); - scope.closeThisDialog(); + scope.ngDialogData.quality = {}; }else{ scope.Tools.alert(result.message); } @@ -1022,7 +887,7 @@ wmsCtrl.controller('inStorageBillCtrl',['$scope','inStorageBillService','dropDow } //入库确认 click - scope.inputConfirmClick = function(){ + /*scope.inputConfirmClick = function(){ var obj = { alOdId : scope.ngDialogData.inputConfirm.odId //订单id @@ -1071,10 +936,10 @@ wmsCtrl.controller('inStorageBillCtrl',['$scope','inStorageBillService','dropDow }) } }) - } + }*/ //库位分配 click - scope.stockAllocationClick = function(){ + /*scope.stockAllocationClick = function(){ //查询库区 inStorageBillService.reservoirList(scope.userInfo.whCode) .then(function(result){ @@ -1118,7 +983,7 @@ wmsCtrl.controller('inStorageBillCtrl',['$scope','inStorageBillService','dropDow } }) scope.ngDialogData.allocation = true; //设置分配为true - } + }*/ //收货数据清空 click scope.receivingClearClick = function(){ diff --git a/public/js/ctrl/o.ctrl.js b/public/js/ctrl/o.ctrl.js index 8d834617eaddf1b1af01a82edab6c67b8b951930..317b3bdbf194ed7571cd6dbd72c054598beeb948 100644 --- a/public/js/ctrl/o.ctrl.js +++ b/public/js/ctrl/o.ctrl.js @@ -179,9 +179,9 @@ wmsCtrl.controller('outboundOrderCtrl', ['$scope','warehouseService','warehouseM } }]) .controller('outboundOrderCtrl.dialog',['$scope','warehouseMaintenanceService','warehouseService',function(scope,warehouseMaintenanceService,warehouseService){ //备料计划管理 dialog + scope.flag = true; //禁止多次点击 //保存备料计划 scope.savePlanClick = function(){ - scope.flag = true; //禁止多次点击 if(scope.flag){ scope.flag = false; warehouseService.createPlan(scope.ngDialogData.dropDownDefault.estimateLane.elId,scope.ngDialogData.outboundOrderList) @@ -245,6 +245,9 @@ wmsCtrl.controller('outboundOrderCtrl', ['$scope','warehouseService','warehouseM warehouseService.updateStatus(scope.keyVin) .then(function(result){ if(result.success){ + //清空输入框数据 + scope.driverVin = null; + scope.keyVin = null; }else{ scope.Tools.alert(result.message); } diff --git a/public/js/ctrl/r.ctrl.js b/public/js/ctrl/r.ctrl.js index 2824d3680edb7db4c49e89cb8d374d27ba9a9c76..50590fdfcd5bc03f5f298aa2af220207e71e034c 100644 --- a/public/js/ctrl/r.ctrl.js +++ b/public/js/ctrl/r.ctrl.js @@ -883,4 +883,364 @@ wmsCtrl.controller('reservoirCtrl',['$scope','reservoirService','dropDownService }) } } -}]) \ No newline at end of file +}]) + .controller('returnCarRegistrationCtrl',['$scope','$rootScope','$http','$timeout','ngDialog','returnCarRegistrationService',function($scope,$rootScope,$http,$timeout,ngDialog,returnCarRegistrationService){ + + //新增 + $scope.addFlag = true; + + if($rootScope.rcrAddFlag){ + + $scope.addFlag = false; //编辑标志 + + var rcidsArr = []; + $('.wms_rcr_table').find('td i').each(function(i,obj) { + if ($(obj).parent().hasClass('layui-form-checked')) { + var id = $(obj).parents('td').attr('rcid'); + rcidsArr.push(id); + } + }); + returnCarRegistrationService.queryModifyDetail(rcidsArr[0]).then(function(data){ + if(data.success){ + $scope.addObjRC = data.data[0]; + $rootScope.rcrAddFlag = false; + } + }); + } else { + $scope.addFlag = true; + } + + $scope.addNew = function(){ + ngDialog.open({ + template: "templates/vehicleBorrowingManagement/layer/rcr-addNew.html", + controller: "returnCarRegistrationCtrl", + title: $rootScope.rcrAddFlag?'编辑还车登记':'还车登记', + width:750 + }); + + //加载完页面后再渲染下页面 + $timeout(function(){ + layui.use('form',function(){ + var form = layui.form(); + form.render(); + //全选 + }) + },50); + }; + $scope.rcrAddInput = false; + // 添加新增单 + $scope.addObjRC = { + rcReturnName:'', + rcReturnDepartment:'', + rcReturnTel:'', + rcReturnDate:'', + rcBorrowNo:'', + wmsBorrowCarDetailList:[] + + }; + $scope.wmsTemp = { + bdId:null, + bdVin:'', + bdMaterialName:'', + bdCarSpecname:'', + bdCarColorname:'' + }; + + $scope.isNull = function(obj){ + for(var key in obj ){ + if(obj[key]==''){ + return true + } + } + return false + }; + + $scope.addInputFlag = false; + + $scope.cueFlag = false; + + $scope.closeCue = function(){ + $scope.cueFlag = false; + }; + + //添加车辆信息 + $scope.addCar = function(){ + + $scope.rcrAddInput = true; + + if( !$scope.isNull($scope.wmsTemp)){ + + $scope.cueFlag = false; // 提示信息 + + $scope.addObjRC.wmsBorrowCarDetailList.push($scope.wmsTemp); + //加载完页面后再渲染下页面 + $timeout(function(){ + layui.use('form',function(){ + var form = layui.form(); + form.render(); + //全选 + }) + },50); + + $scope.wmsTemp = { + bdId:null, + bdVin:'', + bdMaterialName:'', + bdCarSpecname:'', + bdCarColorname:'' + }; + } else if($scope.addInputFlag) { + $scope.cueFlag = true; + } + $scope.addInputFlag = true; //控制表格添加显示 + }; + + //删除车辆信息 + $scope.delCar = function(){ + var indexArr = []; + $('.wmsCarInfo').find('td i').each(function(i,obj) { + if ($(obj).parent().hasClass('layui-form-checked')) { + var index = $(obj).parents('td').attr('index'); + indexArr.push(index); + } + }); + for(var i=0; i1){ + $scope.Tools.alert('编辑只能选择一条!'); + } + }; + + layui.use('form',function(){ + var form = layui.form(); + form.render(); + //全选 + form.on('checkbox(allChoose)', function (data) { + $(data.elem).parent().parent().parent().parent().parent().find('tr').toggleClass('trSelect'); + var child = $(data.elem).parents('table').find('tbody input[type="checkbox"]'); + child.each(function(index, item){ + item.checked = data.elem.checked; + if(data.elem.checked){ + $(item).parents('tr').addClass('trSelect'); + } else { + $(item).parents('tr').removeClass('trSelect'); + } + }); + form.render('checkbox'); + }); + + // 前面选择框选中 + form.on('checkbox(test)',function(data){ + if(data.elem.checked){ + $(data.elem).parents('tr').addClass('trSelect'); + } else { + $(data.elem).parents('tr').removeClass('trSelect'); + } + }); + }); + + // 显示更多条件 + $scope.moreClick = function(){ + $('.otherForm').slideToggle(500); + }; + $rootScope.mainList = ''; + + + $scope.fristSelect = true; +// 获取列表 + $scope.getList = function(){ + var params = { + pageNo:$scope.pageNo || 1, + pageSize:$scope.pageSize || 10 + }; + params = angular.extend(params,$scope.search); + returnCarRegistrationService.returnLine(params) + .then(function(result){ + if(result.success){ + + $rootScope.mainList = result.data.wmsBorrowCarList; + + if($scope.fristSelect){ + $scope.Tools.page(document.getElementById('pages'),{ + pages : result.data.totalPage, + curr : result.data.pageNo, + count : result.data.totalRecord + },function(obj, first){ + $scope.fristSelect = first; //设置状态 + + if(!first){ //判断不是第一次加载 + var param = {}; + param.pageNo = obj.curr; //当前页 + param.pageSize = obj.limit; //最大页 + $scope.pageSize = obj.limit; //设置最大页 + $scope.pageNo = obj.curr; //设置当前页 + $scope.getList(param); + } + }) + } + }else{ + $scope.Tools.alert(result.message); + } + }) + }; + $scope.getList(); + + $rootScope.getList = $scope.getList; + + $scope.search ={}; + $scope.search.rcReturnName = ''; + $scope.search.rcReturnDepartment = ''; + $scope.search.returnStartTime = ''; + $scope.search.returnEndTime = ''; + +// 查询 + $scope.resetClick = function(){ + $scope.search.rcReturnName = ''; + $scope.search.rcReturnDepartment = ''; + $scope.search.returnStartTime = ''; + $scope.search.returnEndTime = ''; + + }; +//刷新 + $scope.refreshA = function(){ + $scope.pageSize = 10; + $scope.resetClick(); + $scope.getList() + }; + + + $scope.fristSelectT = true; +// 获取信息信息 + $scope.getDetail = function(e){ + var id = angular.element(e.target).parent('tr').attr('rcid'); + returnCarRegistrationService.findReturnDetail(id).then(function(result){ + if(result.success){ + $rootScope.rcDetail = result.data; + } else { + $scope.Tools.alert(result.message); + } + }) + } + }]); \ No newline at end of file diff --git a/public/js/ctrl/s.ctrl.js b/public/js/ctrl/s.ctrl.js index ec9732d38227e281770a2c2d7b16274eeb1172e7..ee1275cee4f4185ca27b597ff0c138ea02420419 100644 --- a/public/js/ctrl/s.ctrl.js +++ b/public/js/ctrl/s.ctrl.js @@ -1091,14 +1091,16 @@ wmsCtrl.controller('stockUnitCtrl',['$scope','stockUnitService','dropDownService //点击每行列表的数据 click scope.selectItemClick = function(item,e){ scope.Tools.initTableClick(e); //选中行处理 - shipmentPlanService.getShipmentPLanVehicleList(item.spId) - .then(function(result){ - if(result.success){ - scope.outboundOrderDetailList = result.data - }else{ - scope.Tools.alert(result.message); - } - }) + if(scope.userInfo.whCode.indexOf(scope.constant.warehouse.UNLCN_XN_) != -1){ //西南库才起作用 + shipmentPlanService.getShipmentPLanVehicleList(item.spId) + .then(function(result){ + if(result.success){ + scope.outboundOrderDetailList = result.data + }else{ + scope.Tools.alert(result.message); + } + }) + } } //查询 click @@ -1110,8 +1112,8 @@ wmsCtrl.controller('stockUnitCtrl',['$scope','stockUnitService','dropDownService //重置 click scope.resetClick = function(){ scope.search = {}; - scope.dropDownDefault.outboundStatus = scope.dropDownList.outboundStatus[0]; - scope.dropDownDefault.warehouse = scope.dropDownList.warehouse[0]; + scope.dropDownDefault.shipper = scope.dropDownList.shipper[0]; + scope.dropDownDefault.shipmentPlanStatus = scope.dropDownList.shipmentPlanStatus[0]; } //刷新 click @@ -1167,38 +1169,215 @@ wmsCtrl.controller('stockUnitCtrl',['$scope','stockUnitService','dropDownService }]) .controller('shipmentPlanCtrl.dialog',['$scope','shipmentPlanService',function(scope,shipmentPlanService){ //发运计划 ctrl dialog + scope.flag = true; //禁止多次点击 //保存发运计划 scope.saveShipmentPlanClick = function () { + if(scope.flag){ + scope.flag = false; + if(!scope.shipment || !scope.shipment.estimateLoadingTime){ //判断计划装车时间 + scope.Tools.alert('请选择计划装车时间'); + return; + } - if(!scope.shipment || !scope.shipment.estimateLoadingTime){ //判断计划装车时间 - scope.Tools.alert('请选择计划装车时间'); - return; + if(!scope.shipment || !scope.shipment.estimateFinishTime){ //判断预计完成时间 + scope.Tools.alert('请选择预计完成时间'); + return; + } + + var listArr = new Array(); + angular.forEach(scope.ngDialogData.Data,function (v,k) { + listArr.push({ + spId : v.spId, + estimateLoadingTime : scope.shipment.estimateLoadingTime, //计划装车时间 + estimateFinishTime : scope.shipment.estimateFinishTime //预计完成时间 + }); + }); + shipmentPlanService.createPreparationPlan(listArr) + .then(function(result){ + if(result.success){ + scope.Tools.alert('创建发运计划成功'); + scope.list(scope.listParam()); + //置空详情list + scope.$parent.outboundOrderDetailList = null; + scope.closeThisDialog(); + }else{ + scope.Tools.alert(result.message); + } + scope.flag = true; + }) + } + } + }]) + .controller('shipmentPlanRejectCtrl',['$scope','dropDownService',function(scope,dropDownService){ //发运计划驳回 ctrl + scope.moreText = scope.constant.moreText.spread; + //更多条件 + scope.moreClick = function(){ + scope.otherForm = !scope.otherForm; + if(scope.otherForm){ + scope.moreText = scope.constant.moreText.packUp; + }else{ + scope.moreText = scope.constant.moreText.spread; + } + } + + /*状态数据*/ + scope.dropDownList = { + shipmentPlanStatus : scope.Tools.dropDown.shipmentPlanStatusDropDown.concat(), //发运计划状态 + shipmentPlanType : scope.Tools.dropDown.shipmentPlanTypeDropDown.concat(), //发运类型 + shipmentRejectStatus : scope.Tools.dropDown.shipmentRejectStatusDropDown.concat() //发运驳回状态 + } + scope.dropDownList.shipmentPlanStatus.unshift(scope.constant.defaultDropDownNullData); //向前插入空值 + scope.dropDownList.shipmentPlanType.unshift(scope.constant.defaultDropDownNullData); //向前插入空值 + scope.dropDownList.shipmentRejectStatus.unshift(scope.constant.defaultDropDownNullData) //发运驳回状态 + //设置默认值 + scope.dropDownDefault = { + shipmentPlanStatus : scope.dropDownList.shipmentPlanStatus[0], //发运计划状态默认值 + shipmentPlanType : scope.dropDownList.shipmentPlanType[0], //发运类型状态默认值 + shipmentRejectStatus : scope.dropDownList.shipmentRejectStatus[0] //发运驳回状态默认值 + } + + //列表查询接口参数构造 + scope.listParam = function(){ + + if(!scope.search){ + scope.search = {}; } + scope.search.pageSize = scope.pageSize; //设置最大页 + scope.search.spSendBusinessFlag = scope.dropDownDefault.shipmentPlanStatus.value; //状态 + if(scope.otherForm){ //展开了更多 + return scope.search; + }else{ //没有展开 + return scope.search; + } + } - if(!scope.shipment || !scope.shipment.estimateFinishTime){ //判断预计完成时间 - scope.Tools.alert('请选择预计完成时间'); - return; + //列表 + scope.fristSelect = true; //判断是否是第一次查询 + scope.list = function(params){ + //设置分页参数 + if(!params){ + params = {}; } + params.pageSize = params.pageSize ? params.pageSize : scope.constant.page.pageSize; + params.pageNo = params.pageNo ? params.pageNo : scope.constant.page.pageNo; - var listArr = new Array(); - angular.forEach(scope.ngDialogData.Data,function (v,k) { - listArr.push({ - spId : v.spId, - estimateLoadingTime : scope.shipment.estimateLoadingTime, //计划装车时间 - estimateFinishTime : scope.shipment.estimateFinishTime //预计完成时间 - }); - }); - shipmentPlanService.createPreparationPlan(listArr) + /*shipmentPlanService.getShipmentPLanList(params) .then(function(result){ if(result.success){ - scope.Tools.alert('创建发运计划成功'); - scope.list(scope.listParam()); - //置空详情list - scope.$parent.outboundOrderDetailList = null; - scope.closeThisDialog(); + scope.shipmentPlanList = result.data; + scope.outboundOrderDetailList = null; //置空详情list + if(scope.fristSelect){ + scope.Tools.page(document.getElementById('page'),{ + pages : result.pageVo.totalPage, + curr : result.pageVo.pageNo, + count : result.pageVo.totalRecord + },function(obj, first){ + scope.fristSelect = first; //设置状态 + //初始化多选框 + scope.Tools.initCheckBox(); + if(!first){ //判断不是第一次加载 + var param = scope.listParam(); + param.pageNo = obj.curr; //当前页 + param.pageSize = obj.limit; //最大页 + scope.pageSize = obj.limit; //设置最大页 + scope.pageNo = obj.curr; //设置当前页 + scope.list(param); + } + }) + }else{ + //初始化多选框 + scope.Tools.initCheckBox(); + } }else{ scope.Tools.alert(result.message); } - }) + })*/ + } + + //列表 + scope.list(); + + //回车按下查询 + scope.searchListKeyDown = function(e){ + var keycode = window.event ? e.keyCode:e.which; + if(keycode == 13){ //回车键 + scope.fristSelect = true; //设置为第一次查询 + scope.list(scope.listParam()); + e.preventDefault(); + } + } + + //点击每行列表的数据 click + scope.selectItemClick = function(item,e){ + scope.Tools.initTableClick(e); //选中行处理 + /*shipmentPlanService.getShipmentPLanVehicleList(item.spId) + .then(function(result){ + if(result.success){ + scope.outboundOrderDetailList = result.data + }else{ + scope.Tools.alert(result.message); + } + })*/ + } + + //查询 click + scope.searchClick = function(){ + scope.fristSelect = true; //设置为第一次查询 + scope.list(scope.listParam()); + } + + //重置 click + scope.resetClick = function(){ + scope.search = {}; + scope.dropDownList.shipmentPlanStatus = scope.dropDownList.shipmentPlanStatus[0]; //发运计划状态 + scope.dropDownList.shipmentPlanType = scope.dropDownList.shipmentPlanType[0]; //发运计划状态 + scope.dropDownList.shipmentRejectStatus = scope.dropDownList.shipmentRejectStatus[0]; //发运计划状态 + } + + //刷新 click + scope.refreshClick = function(){ + scope.searchClick(); + } + + //任务取消 click + scope.taskCancelClick = function(){ + scope.Tools.dialog({ + controller:'shipmentPlanRejectCtrl.dialog', + template : 'templates/warehouseManagement/shipmentPlanReject/task-cancel-form.html', + closeByDocument : false, + closeByEscape : false, + data : { + }, + width : 550, + title : '任务取消', + scope : scope + }) + } + + //备料更换 click + scope.outBoundChangeClick = function(){ + scope.Tools.dialog({ + controller:'shipmentPlanRejectCtrl.dialog', + template : 'templates/warehouseManagement/shipmentPlanReject/out-bound-change-form.html', + closeByDocument : false, + closeByEscape : false, + data : { + }, + width : 350, + title : '备料更换', + scope : scope + }) + } + }]) + .controller('shipmentPlanRejectCtrl.dialog',['$scope',function(scope){ //发运计划驳回 ctrl dialog + + //保存任务取消原因 click + scope.saveTaskCancelClick = function(){ + + } + + //备料更换 保存 click + scope.saveOutBoundChangeClick = function(){ + } }]) diff --git a/public/js/ctrl/w.ctrl.js b/public/js/ctrl/w.ctrl.js index b4088a746ef94f7e258c43e75069cb89671baa1d..9e856834b7a3fe69473e36f8739cd696ed5eb924 100644 --- a/public/js/ctrl/w.ctrl.js +++ b/public/js/ctrl/w.ctrl.js @@ -210,6 +210,56 @@ wmsCtrl.controller('warehouseCtrl',['$scope','warehouseService','dropDownService }) } } + + //打印出库交接单 + scope.printOutboundReceiptClick = function(){ + var indexArr = scope.Tools.getTableSelectItemIndex('.warehouseTable'); //获取table所选的下标 + + if(indexArr.length == 0){ + scope.Tools.alert('请选择一条数据'); + return; + } + + if(indexArr.length > 1){ + scope.Tools.alert('只能选择一条数据'); + return; + } + + warehouseService.getPrintInfo(scope.warehouseList[indexArr[0]].otId) + .then(function(result){ + if(result.success){ + scope.Tools.dialog({ + controller : 'warehouseCtrl.dialog', + template : 'templates/warehouseManagement/warehouse/print-outbound-receipt.html', + closeByDocument : false, + closeByEscape : false, + data : { + receipt : result.data + }, + width : 750, + title : '打印出库交接单', + scope : scope + }) + }else{ + scope.Tools.alert(result.message); + } + }) + } + + //出库确认 + scope.outConfirmClick = function(){ + scope.Tools.dialog({ + controller : 'warehouseCtrl.dialog', + template : 'templates/warehouseManagement/warehouse/out-confirm-form.html', + closeByDocument : false, + closeByEscape : false, + data : { + }, + width : 700, + title : '出库确认', + scope : scope + }) + } }]) .controller('warehouseCtrl.dialog',['$scope','warehouseService',function(scope,warehouseService){ //出库作业管理 dialog @@ -282,6 +332,59 @@ wmsCtrl.controller('warehouseCtrl',['$scope','warehouseService','dropDownService }) } } + + //打印交接单 click + scope.printReceiptClick = function(){ + if(!scope.Tools.checkPrintInstall()){ //打印插件检测 + scope.Tools.downLoadPrintPlugIn(); //提示下载打印插件 + return; + } + scope.Tools.printHTML($(".dialog-body")[0].outerHTML,750,1); + } + + //出库确认 获取 vin 信息 + scope.searchVINListKeyDown = function(e){ + var keycode = window.event ? e.keyCode:e.which; + if(keycode == 13){ //回车键 + if(scope.orderNo){ + warehouseService.getVinList(scope.orderNo) + .then(function(result){ + if(result.success){ + scope.vinList = result.data; + }else{ + scope.Tools.alert(result.message); + } + }) + } + } + } + + //出库确认 根据vin确认数据 + scope.searchVINKeyDown = function(e){ + var keycode = window.event ? e.keyCode:e.which; + if(keycode == 13){ //回车键 + if(scope.vinList){ + var obj = { + barCode : scope.orderNo, + vin : scope.vin, + vinList : scope.vinList + }; + warehouseService.outConfirm(obj) + .then(function(result){ + if(result.success){ + scope.Tools.alert('出库确认成功'); + scope.confirmVinList = result.data; + scope.list(scope.listParam()); + }else{ + scope.Tools.alert(result.message); + } + }) + }else{ + scope.Tools.alert('请根据单据号获取vin信息'); + } + } + } + }]) .controller('warehouseMaintenanceCtrl',['$scope','warehouseMaintenanceService',function(scope,warehouseMaintenanceService){ //仓库维护 @@ -696,4 +799,10 @@ wmsCtrl.controller('warehouseCtrl',['$scope','warehouseService','dropDownService } }]) .controller('warehouseRecordCtrl.dialog',['$scope',function(scope){ //出库记录查询 ctrl dialog + + + + + + }]) \ No newline at end of file diff --git a/public/js/lib/angular-file-upload/angular-file-upload.js b/public/js/lib/angular-file-upload/angular-file-upload.js new file mode 100644 index 0000000000000000000000000000000000000000..cd70f77c4d778370e1922a89627d1761f1bad484 --- /dev/null +++ b/public/js/lib/angular-file-upload/angular-file-upload.js @@ -0,0 +1,1982 @@ +/* + angular-file-upload v2.3.4 + https://github.com/nervgh/angular-file-upload +*/ + +(function webpackUniversalModuleDefinition(root, factory) { + if(typeof exports === 'object' && typeof module === 'object') + module.exports = factory(); + else if(typeof define === 'function' && define.amd) + define([], factory); + else if(typeof exports === 'object') + exports["angular-file-upload"] = factory(); + else + root["angular-file-upload"] = factory(); +})(this, function() { +return /******/ (function(modules) { // webpackBootstrap +/******/ // The module cache +/******/ var installedModules = {}; +/******/ +/******/ // The require function +/******/ function __webpack_require__(moduleId) { +/******/ +/******/ // Check if module is in cache +/******/ if(installedModules[moduleId]) +/******/ return installedModules[moduleId].exports; +/******/ +/******/ // Create a new module (and put it into the cache) +/******/ var module = installedModules[moduleId] = { +/******/ exports: {}, +/******/ id: moduleId, +/******/ loaded: false +/******/ }; +/******/ +/******/ // Execute the module function +/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__); +/******/ +/******/ // Flag the module as loaded +/******/ module.loaded = true; +/******/ +/******/ // Return the exports of the module +/******/ return module.exports; +/******/ } +/******/ +/******/ +/******/ // expose the modules object (__webpack_modules__) +/******/ __webpack_require__.m = modules; +/******/ +/******/ // expose the module cache +/******/ __webpack_require__.c = installedModules; +/******/ +/******/ // __webpack_public_path__ +/******/ __webpack_require__.p = ""; +/******/ +/******/ // Load entry module and return exports +/******/ return __webpack_require__(0); +/******/ }) +/************************************************************************/ +/******/ ([ +/* 0 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + var _config = __webpack_require__(1); + + var _config2 = _interopRequireDefault(_config); + + var _options = __webpack_require__(2); + + var _options2 = _interopRequireDefault(_options); + + var _FileUploader = __webpack_require__(3); + + var _FileUploader2 = _interopRequireDefault(_FileUploader); + + var _FileLikeObject = __webpack_require__(4); + + var _FileLikeObject2 = _interopRequireDefault(_FileLikeObject); + + var _FileItem = __webpack_require__(5); + + var _FileItem2 = _interopRequireDefault(_FileItem); + + var _FileDirective = __webpack_require__(6); + + var _FileDirective2 = _interopRequireDefault(_FileDirective); + + var _FileSelect = __webpack_require__(7); + + var _FileSelect2 = _interopRequireDefault(_FileSelect); + + var _FileDrop = __webpack_require__(8); + + var _FileDrop2 = _interopRequireDefault(_FileDrop); + + var _FileOver = __webpack_require__(9); + + var _FileOver2 = _interopRequireDefault(_FileOver); + + var _FileSelect3 = __webpack_require__(10); + + var _FileSelect4 = _interopRequireDefault(_FileSelect3); + + var _FileDrop3 = __webpack_require__(11); + + var _FileDrop4 = _interopRequireDefault(_FileDrop3); + + var _FileOver3 = __webpack_require__(12); + + var _FileOver4 = _interopRequireDefault(_FileOver3); + + function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + + angular.module(_config2.default.name, []).value('fileUploaderOptions', _options2.default).factory('FileUploader', _FileUploader2.default).factory('FileLikeObject', _FileLikeObject2.default).factory('FileItem', _FileItem2.default).factory('FileDirective', _FileDirective2.default).factory('FileSelect', _FileSelect2.default).factory('FileDrop', _FileDrop2.default).factory('FileOver', _FileOver2.default).directive('nvFileSelect', _FileSelect4.default).directive('nvFileDrop', _FileDrop4.default).directive('nvFileOver', _FileOver4.default).run(['FileUploader', 'FileLikeObject', 'FileItem', 'FileDirective', 'FileSelect', 'FileDrop', 'FileOver', function (FileUploader, FileLikeObject, FileItem, FileDirective, FileSelect, FileDrop, FileOver) { + // only for compatibility + FileUploader.FileLikeObject = FileLikeObject; + FileUploader.FileItem = FileItem; + FileUploader.FileDirective = FileDirective; + FileUploader.FileSelect = FileSelect; + FileUploader.FileDrop = FileDrop; + FileUploader.FileOver = FileOver; + }]); + +/***/ }, +/* 1 */ +/***/ function(module, exports) { + + module.exports = { + "name": "angularFileUpload" + }; + +/***/ }, +/* 2 */ +/***/ function(module, exports) { + + 'use strict'; + + Object.defineProperty(exports, "__esModule", { + value: true + }); + exports.default = { + url: '/', + alias: 'file', + headers: {}, + queue: [], + progress: 0, + autoUpload: false, + removeAfterUpload: false, + method: 'POST', + filters: [], + formData: [], + queueLimit: Number.MAX_VALUE, + withCredentials: false, + disableMultipart: false + }; + +/***/ }, +/* 3 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + Object.defineProperty(exports, "__esModule", { + value: true + }); + exports.default = __identity; + + var _config = __webpack_require__(1); + + var _config2 = _interopRequireDefault(_config); + + function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + + function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + + var _angular = angular; + var copy = _angular.copy; + var extend = _angular.extend; + var forEach = _angular.forEach; + var isObject = _angular.isObject; + var isNumber = _angular.isNumber; + var isDefined = _angular.isDefined; + var isArray = _angular.isArray; + var element = _angular.element; + function __identity(fileUploaderOptions, $rootScope, $http, $window, $timeout, FileLikeObject, FileItem) { + var File = $window.File; + var FormData = $window.FormData; + + var FileUploader = function () { + /********************** + * PUBLIC + **********************/ + /** + * Creates an instance of FileUploader + * @param {Object} [options] + * @constructor + */ + + function FileUploader(options) { + _classCallCheck(this, FileUploader); + + var settings = copy(fileUploaderOptions); + + extend(this, settings, options, { + isUploading: false, + _nextIndex: 0, + _failFilterIndex: -1, + _directives: { select: [], drop: [], over: [] } + }); + + // add default filters + this.filters.unshift({ name: 'queueLimit', fn: this._queueLimitFilter }); + this.filters.unshift({ name: 'folder', fn: this._folderFilter }); + } + /** + * Adds items to the queue + * @param {File|HTMLInputElement|Object|FileList|Array} files + * @param {Object} [options] + * @param {Array|String} filters + */ + + + FileUploader.prototype.addToQueue = function addToQueue(files, options, filters) { + var _this = this; + + var list = this.isArrayLikeObject(files) ? files : [files]; + var arrayOfFilters = this._getFilters(filters); + var count = this.queue.length; + var addedFileItems = []; + + forEach(list, function (some /*{File|HTMLInputElement|Object}*/) { + var temp = new FileLikeObject(some); + + if (_this._isValidFile(temp, arrayOfFilters, options)) { + var fileItem = new FileItem(_this, some, options); + addedFileItems.push(fileItem); + _this.queue.push(fileItem); + _this._onAfterAddingFile(fileItem); + } else { + var filter = arrayOfFilters[_this._failFilterIndex]; + _this._onWhenAddingFileFailed(temp, filter, options); + } + }); + + if (this.queue.length !== count) { + this._onAfterAddingAll(addedFileItems); + this.progress = this._getTotalProgress(); + } + + this._render(); + if (this.autoUpload) this.uploadAll(); + }; + /** + * Remove items from the queue. Remove last: index = -1 + * @param {FileItem|Number} value + */ + + + FileUploader.prototype.removeFromQueue = function removeFromQueue(value) { + var index = this.getIndexOfItem(value); + var item = this.queue[index]; + if (item.isUploading) item.cancel(); + this.queue.splice(index, 1); + item._destroy(); + this.progress = this._getTotalProgress(); + }; + /** + * Clears the queue + */ + + + FileUploader.prototype.clearQueue = function clearQueue() { + while (this.queue.length) { + this.queue[0].remove(); + } + this.progress = 0; + }; + /** + * Uploads a item from the queue + * @param {FileItem|Number} value + */ + + + FileUploader.prototype.uploadItem = function uploadItem(value) { + var index = this.getIndexOfItem(value); + var item = this.queue[index]; + var transport = this.isHTML5 ? '_xhrTransport' : '_iframeTransport'; + + item._prepareToUploading(); + if (this.isUploading) return; + + this._onBeforeUploadItem(item); + if (item.isCancel) return; + + item.isUploading = true; + this.isUploading = true; + this[transport](item); + this._render(); + }; + /** + * Cancels uploading of item from the queue + * @param {FileItem|Number} value + */ + + + FileUploader.prototype.cancelItem = function cancelItem(value) { + var _this2 = this; + + var index = this.getIndexOfItem(value); + var item = this.queue[index]; + var prop = this.isHTML5 ? '_xhr' : '_form'; + if (!item) return; + item.isCancel = true; + if (item.isUploading) { + // It will call this._onCancelItem() & this._onCompleteItem() asynchronously + item[prop].abort(); + } else { + (function () { + var dummy = [undefined, 0, {}]; + var onNextTick = function onNextTick() { + _this2._onCancelItem.apply(_this2, [item].concat(dummy)); + _this2._onCompleteItem.apply(_this2, [item].concat(dummy)); + }; + $timeout(onNextTick); // Trigger callbacks asynchronously (setImmediate emulation) + })(); + } + }; + /** + * Uploads all not uploaded items of queue + */ + + + FileUploader.prototype.uploadAll = function uploadAll() { + var items = this.getNotUploadedItems().filter(function (item) { + return !item.isUploading; + }); + if (!items.length) return; + + forEach(items, function (item) { + return item._prepareToUploading(); + }); + items[0].upload(); + }; + /** + * Cancels all uploads + */ + + + FileUploader.prototype.cancelAll = function cancelAll() { + var items = this.getNotUploadedItems(); + forEach(items, function (item) { + return item.cancel(); + }); + }; + /** + * Returns "true" if value an instance of File + * @param {*} value + * @returns {Boolean} + * @private + */ + + + FileUploader.prototype.isFile = function isFile(value) { + return this.constructor.isFile(value); + }; + /** + * Returns "true" if value an instance of FileLikeObject + * @param {*} value + * @returns {Boolean} + * @private + */ + + + FileUploader.prototype.isFileLikeObject = function isFileLikeObject(value) { + return this.constructor.isFileLikeObject(value); + }; + /** + * Returns "true" if value is array like object + * @param {*} value + * @returns {Boolean} + */ + + + FileUploader.prototype.isArrayLikeObject = function isArrayLikeObject(value) { + return this.constructor.isArrayLikeObject(value); + }; + /** + * Returns a index of item from the queue + * @param {Item|Number} value + * @returns {Number} + */ + + + FileUploader.prototype.getIndexOfItem = function getIndexOfItem(value) { + return isNumber(value) ? value : this.queue.indexOf(value); + }; + /** + * Returns not uploaded items + * @returns {Array} + */ + + + FileUploader.prototype.getNotUploadedItems = function getNotUploadedItems() { + return this.queue.filter(function (item) { + return !item.isUploaded; + }); + }; + /** + * Returns items ready for upload + * @returns {Array} + */ + + + FileUploader.prototype.getReadyItems = function getReadyItems() { + return this.queue.filter(function (item) { + return item.isReady && !item.isUploading; + }).sort(function (item1, item2) { + return item1.index - item2.index; + }); + }; + /** + * Destroys instance of FileUploader + */ + + + FileUploader.prototype.destroy = function destroy() { + var _this3 = this; + + forEach(this._directives, function (key) { + forEach(_this3._directives[key], function (object) { + object.destroy(); + }); + }); + }; + /** + * Callback + * @param {Array} fileItems + */ + + + FileUploader.prototype.onAfterAddingAll = function onAfterAddingAll(fileItems) {}; + /** + * Callback + * @param {FileItem} fileItem + */ + + + FileUploader.prototype.onAfterAddingFile = function onAfterAddingFile(fileItem) {}; + /** + * Callback + * @param {File|Object} item + * @param {Object} filter + * @param {Object} options + */ + + + FileUploader.prototype.onWhenAddingFileFailed = function onWhenAddingFileFailed(item, filter, options) {}; + /** + * Callback + * @param {FileItem} fileItem + */ + + + FileUploader.prototype.onBeforeUploadItem = function onBeforeUploadItem(fileItem) {}; + /** + * Callback + * @param {FileItem} fileItem + * @param {Number} progress + */ + + + FileUploader.prototype.onProgressItem = function onProgressItem(fileItem, progress) {}; + /** + * Callback + * @param {Number} progress + */ + + + FileUploader.prototype.onProgressAll = function onProgressAll(progress) {}; + /** + * Callback + * @param {FileItem} item + * @param {*} response + * @param {Number} status + * @param {Object} headers + */ + + + FileUploader.prototype.onSuccessItem = function onSuccessItem(item, response, status, headers) {}; + /** + * Callback + * @param {FileItem} item + * @param {*} response + * @param {Number} status + * @param {Object} headers + */ + + + FileUploader.prototype.onErrorItem = function onErrorItem(item, response, status, headers) {}; + /** + * Callback + * @param {FileItem} item + * @param {*} response + * @param {Number} status + * @param {Object} headers + */ + + + FileUploader.prototype.onCancelItem = function onCancelItem(item, response, status, headers) {}; + /** + * Callback + * @param {FileItem} item + * @param {*} response + * @param {Number} status + * @param {Object} headers + */ + + + FileUploader.prototype.onCompleteItem = function onCompleteItem(item, response, status, headers) {}; + /** + * Callback + */ + + + FileUploader.prototype.onCompleteAll = function onCompleteAll() {}; + /********************** + * PRIVATE + **********************/ + /** + * Returns the total progress + * @param {Number} [value] + * @returns {Number} + * @private + */ + + + FileUploader.prototype._getTotalProgress = function _getTotalProgress(value) { + if (this.removeAfterUpload) return value || 0; + + var notUploaded = this.getNotUploadedItems().length; + var uploaded = notUploaded ? this.queue.length - notUploaded : this.queue.length; + var ratio = 100 / this.queue.length; + var current = (value || 0) * ratio / 100; + + return Math.round(uploaded * ratio + current); + }; + /** + * Returns array of filters + * @param {Array|String} filters + * @returns {Array} + * @private + */ + + + FileUploader.prototype._getFilters = function _getFilters(filters) { + if (!filters) return this.filters; + if (isArray(filters)) return filters; + var names = filters.match(/[^\s,]+/g); + return this.filters.filter(function (filter) { + return names.indexOf(filter.name) !== -1; + }); + }; + /** + * Updates html + * @private + */ + + + FileUploader.prototype._render = function _render() { + if (!$rootScope.$$phase) $rootScope.$apply(); + }; + /** + * Returns "true" if item is a file (not folder) + * @param {File|FileLikeObject} item + * @returns {Boolean} + * @private + */ + + + FileUploader.prototype._folderFilter = function _folderFilter(item) { + return !!(item.size || item.type); + }; + /** + * Returns "true" if the limit has not been reached + * @returns {Boolean} + * @private + */ + + + FileUploader.prototype._queueLimitFilter = function _queueLimitFilter() { + return this.queue.length < this.queueLimit; + }; + /** + * Returns "true" if file pass all filters + * @param {File|Object} file + * @param {Array} filters + * @param {Object} options + * @returns {Boolean} + * @private + */ + + + FileUploader.prototype._isValidFile = function _isValidFile(file, filters, options) { + var _this4 = this; + + this._failFilterIndex = -1; + return !filters.length ? true : filters.every(function (filter) { + _this4._failFilterIndex++; + return filter.fn.call(_this4, file, options); + }); + }; + /** + * Checks whether upload successful + * @param {Number} status + * @returns {Boolean} + * @private + */ + + + FileUploader.prototype._isSuccessCode = function _isSuccessCode(status) { + return status >= 200 && status < 300 || status === 304; + }; + /** + * Transforms the server response + * @param {*} response + * @param {Object} headers + * @returns {*} + * @private + */ + + + FileUploader.prototype._transformResponse = function _transformResponse(response, headers) { + var headersGetter = this._headersGetter(headers); + forEach($http.defaults.transformResponse, function (transformFn) { + response = transformFn(response, headersGetter); + }); + return response; + }; + /** + * Parsed response headers + * @param headers + * @returns {Object} + * @see https://github.com/angular/angular.js/blob/master/src/ng/http.js + * @private + */ + + + FileUploader.prototype._parseHeaders = function _parseHeaders(headers) { + var parsed = {}, + key, + val, + i; + + if (!headers) return parsed; + + forEach(headers.split('\n'), function (line) { + i = line.indexOf(':'); + key = line.slice(0, i).trim().toLowerCase(); + val = line.slice(i + 1).trim(); + + if (key) { + parsed[key] = parsed[key] ? parsed[key] + ', ' + val : val; + } + }); + + return parsed; + }; + /** + * Returns function that returns headers + * @param {Object} parsedHeaders + * @returns {Function} + * @private + */ + + + FileUploader.prototype._headersGetter = function _headersGetter(parsedHeaders) { + return function (name) { + if (name) { + return parsedHeaders[name.toLowerCase()] || null; + } + return parsedHeaders; + }; + }; + /** + * The XMLHttpRequest transport + * @param {FileItem} item + * @private + */ + + + FileUploader.prototype._xhrTransport = function _xhrTransport(item) { + var _this5 = this; + + var xhr = item._xhr = new XMLHttpRequest(); + var sendable; + + if (!item.disableMultipart) { + sendable = new FormData(); + forEach(item.formData, function (obj) { + forEach(obj, function (value, key) { + sendable.append(key, value); + }); + }); + + sendable.append(item.alias, item._file, item.file.name); + } else { + sendable = item._file; + } + + if (typeof item._file.size != 'number') { + throw new TypeError('The file specified is no longer valid'); + } + + xhr.upload.onprogress = function (event) { + var progress = Math.round(event.lengthComputable ? event.loaded * 100 / event.total : 0); + _this5._onProgressItem(item, progress); + }; + + xhr.onload = function () { + var headers = _this5._parseHeaders(xhr.getAllResponseHeaders()); + var response = _this5._transformResponse(xhr.response, headers); + var gist = _this5._isSuccessCode(xhr.status) ? 'Success' : 'Error'; + var method = '_on' + gist + 'Item'; + _this5[method](item, response, xhr.status, headers); + _this5._onCompleteItem(item, response, xhr.status, headers); + }; + + xhr.onerror = function () { + var headers = _this5._parseHeaders(xhr.getAllResponseHeaders()); + var response = _this5._transformResponse(xhr.response, headers); + _this5._onErrorItem(item, response, xhr.status, headers); + _this5._onCompleteItem(item, response, xhr.status, headers); + }; + + xhr.onabort = function () { + var headers = _this5._parseHeaders(xhr.getAllResponseHeaders()); + var response = _this5._transformResponse(xhr.response, headers); + _this5._onCancelItem(item, response, xhr.status, headers); + _this5._onCompleteItem(item, response, xhr.status, headers); + }; + + xhr.open(item.method, item.url, true); + + xhr.withCredentials = item.withCredentials; + + forEach(item.headers, function (value, name) { + xhr.setRequestHeader(name, value); + }); + + xhr.send(sendable); + }; + /** + * The IFrame transport + * @param {FileItem} item + * @private + */ + + + FileUploader.prototype._iframeTransport = function _iframeTransport(item) { + var _this6 = this; + + var form = element('
'); + var iframe = element('