| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755 |
- define([ 'angularAMD','toaster', 'ngTable', 'common/services', 'service/Purc','service/SupportServices', 'ui.router', 'ui.bootstrap','directive/SmartDirectives' ], function(angularAMD) {
- 'use strict';
- var app = angular.module('myApp', ['ngAnimate', 'toaster','ngTable', 'ui.router', 'common.services', 'PurcServices', 'SupportServices','ui.bootstrap','SmartDirectives']);
- app.init = function() {
- angularAMD.bootstrap(app);
- };
- app.config(['$stateProvider', '$urlRouterProvider', function($stateProvider, $urlRouterProvider) {
- $urlRouterProvider.otherwise('/index');
- $stateProvider.state('index', {
- url : "/index",
- templateUrl : "resources/tpl/index/index.html"
- }).state('inMakeMaterial',angularAMD.route({
- url : "/inMakeMaterial",
- templateUrl : "resources/tpl/input/inMakeMaterial.html",
- controllerUrl : 'app/controllers/InputCtrl'
- })).state('inMMOperation', {
- url: '/inMMOperation/:code',
- templateUrl: 'resources/tpl/input/inMMOperation.html'
- }).state('inContents',angularAMD.route({
- url:'/inContents',
- templateUrl:'resources/tpl/input/inContents.html',
- controllerUrl : 'app/controllers/InputCtrl'
- })).state('inMMWaitSubmit',{
- url:'/inMMWaitSubmit/:ioNocode',
- templateUrl:'resources/tpl/input/inMMWaitSubmit.html'
- }).state('inFinishWaitSubmit',{
- url:'/inFinishWaitSubmit/:ioNocode',
- templateUrl:'resources/tpl/input/inFinishWaitSubmit.html'
- }).state('inFinishOperation',{
- url:'/inFinishOperation/:code',
- templateUrl:'resources/tpl/input/inFinishOperation.html'
- }).state('inFinish',angularAMD.route({
- url:'/inFinish',
- templateUrl : 'resources/tpl/input/inFinish.html',
- controllerUrl : 'app/controllers/InFinishCtrl'
- })).state('outContents',angularAMD.route({
- url:'/outContents',
- templateUrl : 'resources/tpl/output/outContents.html',
- controllerUrl : 'app/controllers/OutputCtrl'
- })).state('outMakeMaterial',angularAMD.route({
- url:'/outMakeMaterial',
- templateUrl : 'resources/tpl/output/outMakeMaterial.html',
- controllerUrl : 'app/controllers/OutputCtrl'
- })).state('outMMOperation',angularAMD.route({
- url:'/outMMOperation/:code',
- templateUrl : 'resources/tpl/output/outMMOperation.html',
- controllerUrl : 'app/controllers/OutMMOperationCtrl'
- })).state('outMMWaitSubmit',angularAMD.route({
- url:'/outMMWaitSubmit/:ioNocode',
- templateUrl:'resources/tpl/output/outMMWaitSubmit.html',
- controllerUrl : 'app/controllers/OutMMwaitSubmitCtrl'
- })).state('outFinish',angularAMD.route({
- url:'/outFinish',
- templateUrl:'resources/tpl/output/outFinish.html',
- controllerUrl : 'app/controllers/OutFinishCtrl'
- })).state('outFinishOprCtrl',angularAMD.route({
- url:'/outFinishOperation/:code',
- templateUrl:'resources/tpl/output/outFinishOperation.html',
- controllerUrl : 'app/controllers/OutFinishOprCtrl'
- })).state('outFinWaitSubmit',angularAMD.route({
- url:'/outFinWaitSubmit/:ioNocode',
- templateUrl:'resources/tpl/output/outFinWaitSubmit.html',
- controllerUrl : 'app/controllers/OutFinWaitSubmitCtrl'
- })).state('countingContents',{
- url:'/countingContents',
- templateUrl:'resources/tpl/counting/countingContents.html'
- }).state('countingMM',{
- url:'/countingMM',
- templateUrl:'resources/tpl/counting/countingMM.html'
- }).state('countingFinish',{
- url:'/countingFinish',
- templateUrl:'resources/tpl/counting/countingFinish.html'
- }).state('countingMMWaitSub',{
- url:'/countingMMWaitSub',
- templateUrl:'resources/tpl/counting/countingMMWaitSub.html'
- }).state('countingFinWaitSub',{
- url:'/countingFinWaitSub',
- templateUrl:'resources/tpl/counting/countingFinWaitSub.html'
- }).state('checkContents',angularAMD.route({
- url:'/checkContents',
- templateUrl:'resources/tpl/check/checkContents.html',
- controllerUrl : 'app/controllers/CheckCtrl'
- })).state('checkMM',angularAMD.route({
- url:'/checkMM',
- templateUrl:'resources/tpl/check/checkMM.html',
- controllerUrl : 'app/controllers/CheckCtrl'
- })).state('checkBarcode',angularAMD.route({
- url:'/checkBarcode',
- templateUrl:'resources/tpl/check/checkBarcode.html',
- controllerUrl : 'app/controllers/CheckCtrl'
- })).state('checkPackage',angularAMD.route({
- url:'/checkPackage',
- templateUrl:'resources/tpl/check/checkPackage.html',
- controllerUrl : 'app/controllers/CheckCtrl'
- })).state('checkMakeFin',angularAMD.route({
- url:'/checkMakeFin',
- templateUrl:'resources/tpl/check/checkMakeFin.html',
- controllerUrl : 'app/controllers/CheckCtrl'
- })).state('checkOrderFin',angularAMD.route({
- url:'/checkOrderFin',
- templateUrl:'resources/tpl/check/checkOrderFin.html',
- controllerUrl : 'app/controllers/CheckCtrl'
- })).state('checkPO',angularAMD.route({
- url:'/checkPO',
- templateUrl:'resources/tpl/check/checkPO.html',
- controllerUrl : 'app/controllers/CheckCtrl'
- })).state('locationTransfer',angularAMD.route({
- url:'/locationTransfer',
- templateUrl:'resources/tpl/locationTransfer/locationTransfer.html',
- controllerUrl : 'app/controllers/LocationTransferCtrl'
- })).state('batchContents',{
- url:'/batchContents',
- templateUrl:'resources/tpl/batch/batchContents.html'
- }).state('breakingBatch',{
- url:'/breakingBatch',
- templateUrl:'resources/tpl/batch/breakingBatch.html'
- }).state('breakingPackage',{
- url:'/breakingPackage',
- templateUrl:'resources/tpl/batch/breakingPackage.html'
- }).state('combineBatch',{
- url:'/combineBatch',
- templateUrl:'resources/tpl/batch/combineBatch.html'
- }).state('settingContents',angularAMD.route({
- url:'/settingContents',
- templateUrl:'resources/tpl/setting/settingContents.html',
- controllerUrl : 'app/controllers/SettingCtrl'
- })).state('haveSubmitList',angularAMD.route({
- url:'/haveSubmitList/:pi_id/:inout/:pi_inoutno',
- templateUrl:'resources/tpl/input/haveSubmitList.html',
- controllerUrl : 'app/controllers/HaveSubmitListCtrl'
- }));
- }]);
- app.factory('Ring', function(){//响铃,直接调用
- return {
- success: function(){
- document.getElementById('successRing').play();
- }, error: function(){
- document.getElementById('errorRing').play();
- }
- }
- }).factory('Online',['$rootScope', function($rootScope){//在线状态,全局获取、设置
- var status = {online: true};
- return {
- setOnline: function(value){
- status.online = value;
- $rootScope.$broadcast('online', value);
- }, getOnline: function(){
- return status.online;
- }
- }
- }]);
-
- app.directive('enterAsTab', function () {
- return function (scope, element, attrs) {
- element.bind("keyup", function (event) {
- if(event.which === 13) {
- var focusable = document.getElementsByTagName('input');
- // Get the index of the currently focused element
- var currentIndex = Array.prototype.indexOf.call(focusable, event.target);
- // Find the next items in the list
- var nextIndex = currentIndex == focusable.length - 1 ? 0 : currentIndex + 1;
- // Focus the next element
- if(nextIndex >= 0 && nextIndex < focusable.length){
- if(focusable[nextIndex].value == 0||focusable[nextIndex].value == '')
- focusable[nextIndex].focus();
- }
- }
- });
- };
- });
-
- app.controller('AuthCtrl',['$scope', '$rootScope','$window', 'AuthenticationService','Online','BaseService','SessionService', function($scope, $rootScope,$window, AuthenticationService,Online,BaseService,SessionService) {
- //控制手机浏览器全屏 找到支持的方法, 使用需要全屏的 element 调用
- $rootScope.title = {};
- /* function launchFullScreen(element) {
- if(element.requestFullscreen) {
- element.requestFullscreen();
- } else if(element.mozRequestFullScreen) {
- element.mozRequestFullScreen();
- } else if(element.webkitRequestFullscreen) {
- element.webkitRequestFullscreen();
- } else if(element.msRequestFullscreen) {
- element.msRequestFullscreen();
- }
- }
- //启动全屏
- document.getElementById("full").addEventListener("click",function(){
- launchFullScreen(document.documentElement);
- });
- */
- $scope.status = {online: true};
- $scope.$watch('status.online', function(value){//检测用户手动切换在线状态
- Online.setOnline(value);
- });
- $scope.$on('online', function(data){//监听Service中的状态变化
- $scope.status.online = Online.getOnline();
- });
-
- Online.setOnline(AuthenticationService.isAuthed());
- $scope.userInfo = {};
- AuthenticationService.getAuthentication().success(function(data) {
- $scope.userInfo = data;
- if (data == null || !data.em_code){
- Online.setOnline(false);
- //$window.location.href = rootPath+'/jsps/PDAmobile/signin.html'
- }
- });
- $scope.logout = function() {//注销
- AuthenticationService.logout().success(function() {
- var rootPath= BaseService.getRootPath();
- $window.location.href = rootPath+'/jsps/PDAmobile/signin.html';
- });
- };
- }]);
- app.factory('StatusCode', function(){
- var statusConfig = {
- '101' : '已采集',
- '102' : '未采集',
- '103' : '采集中'
- };
- return {
- get: function(code) {
- return statusConfig[code];
- }
- };
- }).filter('status',['StatusCode', function(StatusCode){
- return function(data) {
- return StatusCode.get(data);
- }
- }]);
- app.controller('IndexCtrl',['$scope','$rootScope', function($scope, $rootScope){
- }]);
- app.controller('ModalInstanceCtrl',['$scope', '$modalInstance', 'items','SessionService','Print','toaster',function($scope, $modalInstance, items,SessionService,Print,toaster) {
- $scope.items = items;
- $scope.colors = [//可以选择的颜色
- {
- id: 'red',
- name: '红色'
- }
- ]
- $scope.defaultWhcode = SessionService.getCookie('defaultWhcode');
- $scope.ok = function(selectValue) {
- $modalInstance.close(selectValue.PD_WHCODE);
- };
- $scope.selectBill = function(item){
- $modalInstance.close(item);
- };
- $scope.cancel = function() {
- $modalInstance.dismiss('cancel');
- };
- $scope.confirmWhcode = function(items){//设置默认仓库
- $modalInstance.close(items);
- };
- $scope.search = function ($event,items){//搜索物料
- if($event == 13){
- $modalInstance.close(items);
- }
- };
- $scope.setStyle = function(){//设置样式
- $modalInstance.close($scope.items);
- };
- $scope.confirmPrint = function(items){//设置默认打印机
- $modalInstance.close(items);
- };
- $scope.returnBatching = function(item){//返回继续拆分
- $modalInstance.close(items);
- }
- $scope.print = function (){//打印
- if(confirm('确认打印')){
- Print.get({data:angular.fromJson($scope.items)},function(data){
- if(data.exceptionInfo){
- toaster.pop('error', data.exceptionInfo);
- }else if(data.message){
- toaster.pop('error', data.message);
- }else {
- toaster.pop('success', "打印成功!");
- }
- },function(res){
- if(res.status == 0){ //无网络错误
- Online.setOnline(false);//修改网络状态
- Ring.error();
- toaster.pop('error', "网络连接不可用,请稍后再试");
- }
- });
- }
- };
- }]);
- app.controller('InMMOperationCtrl',['$scope','$http','$modal', '$stateParams', '$rootScope','$filter','$location', 'ngTableParams','toaster', 'Ring', 'PurcOrderItem','SupportUtil', 'Online', function($scope, $http,$modal, $stateParams, $rootScope,$filter,$location, ngTableParams,toaster, Ring, PurcOrderItem,SupportUtil, Online){
- $scope.grid = $rootScope.grid||[];
- $scope.getOnline = Online.getOnline;
- setTimeout( function(){
- try{
- document.getElementById("bi_barcode").focus();
- var labels = document.getElementsByName("required-label");
- /*for(var n in labels){
- labels[n].style.color = 'red';
- }*/
- var inputs = document.getElementsByTagName("input");
- for(var n in inputs){
- if(typeof inputs[n].getAttribute("required") === "string"){
- console.log('true');
- }
- if(typeof inputs[n].getAttribute("required") === "string"){
- inputs[n].labels[0].style.color = 'red';
- }
- }
- } catch(e){}
- }, 100);
- var getOrder = function(code) {//根据路径中的id号获取对应的单据
- var result = null;
- angular.forEach($rootScope.orders, function(value, key){
- if(value.PI_INOUTNO == code) {
- result = value;
- return result;
- }
- });
- return result;
- };
- $scope.changeSelection = function(item) {//table with row selection,表格选中列操作
- document.getElementById("bi_barcode").focus();
- $scope.ordercode = item.PD_ORDERCODE;
- $scope.bi_prodcode = item.PD_PRODCODE;
- $scope.bi_prodid = item.PR_ID;
- $scope.bi_inoutno = $scope.order.PI_INOUTNO;
- $scope.bi_inqty = item.PR_ZXBZS || $scope.bi_inqty;
- $scope.pr_fbzs = item.PD_INQTY;
- $scope.detno = item.PD_PDNO;
- $scope.pd_id = item.PD_ID;
- $scope.bi_prodname = item.PR_DETAIL;
- $scope.bi_location = item.PR_LOCATION || $scope.bi_location;
- $scope.pr_detail = item.PR_DETAIL+item.PR_SPEC;
- $scope.ifbarcodecheck = item.PR_IFBARCODECHECK;
- $scope.pr_id = item.PR_ID;
- }
- $scope.order = getOrder($stateParams.code);
- $rootScope.title.pi_inoutno =$scope.order.PI_INOUTNO +' '+$scope.order.PI_WHCODE;
- if($scope.order){
- var keepGoing = true;
- angular.forEach($scope.order.product, function(value, key){
- if( keepGoing ){
- if(value.PD_INQTY == 0 && $scope.order.product[key+1]){
- if($scope.order.product[key+1].PD_INQTY != 0){
- $scope.changeSelection($scope.order.product[key+1]);
- keepGoing = false ;
- }
- }else if(value.PD_INQTY != 0) {
- $scope.changeSelection($scope.order.product[key]);
- keepGoing = false;
- }
- }
- });
- $scope.tableParams = new ngTableParams({//未完成料号名称规格及剩余数量表格
- page: 1,
- count: 10,
- filter: {
- },
- sorting: {
- }
- }, {
- total: $scope.order.product.length,
- getData: function ($defer, params) {
- var filteredData = params.filter() ?
- $filter('filter')($scope.order.product, params.filter()) :
- data;
- var orderedData = params.sorting() ?
- $filter('orderBy')(filteredData, params.orderBy()) :
- data;
- params.total(orderedData.length); // set total for recalc pagination
- $defer.resolve(orderedData.slice((params.page() - 1) * params.count(), params.page() * params.count()));
- }
- });
- }
- //进入界面,表单值默认为grid中的第一行
- var check = function (productCode){
- //校验:1、物料编号存在, 2、数量不超过剩余数量,3、条码号唯一性
- //条码储位不允许为空
- var reg = /^[0-9]*[1-9][0-9]*$/;
- if(!$scope.bi_barcode){
- //alert("请输入条码!");
- document.getElementById("bi_barcode").focus();
- return ;
- }/*else if(!$scope.bi_location){
- //alert("请输入储位!");
- document.getElementById("bi_location").focus();
- return ;
- }*/else if(!reg.test($scope.bi_inqty)){
- Ring.error();
- alert("数量格式不正确!");
- document.getElementById("bi_inqty").focus();
- return ;
- }
- var item = SupportUtil.contains(JSON.stringify($scope.order.product),productCode,"PD_PRODCODE");
- if(item){
- //是否条码校验
- if($scope.ifbarcodecheck == '1'){
- var pr_idlen =$scope.order.barcodeset.BS_LENPRID;
- //比较物料ID的前几位是否等于条码号的前几位
- var pr_id = new String($scope.pr_id);
- var bar_code = new String($scope.bi_barcode);
- if (SupportUtil.lapAft(pr_id,pr_idlen) != SupportUtil.lapFor(bar_code,pr_idlen)){
- Ring.error();
- $scope.bi_barcode ='';
- toaster.pop('error',"条码校验错误,该条码与物料不匹配");
- return false;
- }
- }
- if($scope.bi_inqty !=0 && $scope.bi_inqty >0 && ($scope.bi_inqty < $scope.pr_fbzs || $scope.bi_inqty == $scope.pr_fbzs) && $scope.pr_fbzs > -1 ){
- if($rootScope.grid){
- if(!(SupportUtil.contains(JSON.stringify($rootScope.grid) ,$scope.bi_barcode,"bi_barcode"))){
- return true;
- }else{
- Ring.error();
- toaster.pop('error', '条码号重复');
- $scope.bi_barcode ='';
- document.getElementById("bi_barcode").focus();
- return false;
- }
- }else{
- return true;
- }
- }else {
- Ring.error();
- $scope.bi_inqty = '';
- document.getElementById("bi_inqty").focus();
- alert("数量不能大于剩余数量或者为空");
- return false;
- }
- }else {
- alert("物料不存在");
- Ring.error();
- return false;
- }
- }
- $scope.message = {};
- $scope.scan = function(){//确认按钮事件
- if(check($scope.bi_prodcode)){
- $scope.barcodes = {};
- $scope.barcodes.bi_barcode = $scope.bi_barcode;
- $scope.barcodes.bi_prodcode = $scope.bi_prodcode ;
- $scope.barcodes.bi_prodid = $scope.bi_prodid ;
- $scope.barcodes.bi_inoutno = $scope.bi_inoutno;
- $scope.barcodes.bi_inqty = $scope.bi_inqty;
- $scope.barcodes.bi_location = $scope.bi_location;
- $scope.barcodes.bi_whcode = $scope.order.PI_WHCODE;
- $scope.barcodes.bi_prodname = $scope.bi_prodname;
- $scope.barcodes.bi_pdno = $scope.detno;
- $scope.barcodes.bi_pdid = $scope.pd_id;
- $scope.barcodes.bi_piid = $scope.order.PI_ID;
- //插入数据到待提交缓存列表中grid(barcode,prodcode,inqty,location)
- $scope.grid.push($scope.barcodes);
- $rootScope.grid = $scope.grid;
- $scope.pr_fbzs -= $scope.barcodes.bi_inqty;
- $scope.bi_barcode ='';
- document.getElementById("bi_barcode").focus();
- Ring.success();
- angular.forEach($scope.order.product, function(value, key){
- if(value.PD_ID == $scope.pd_id) {
- value.PD_INQTY = $scope.pr_fbzs ;
- $scope.tableParams.reload();
- if(value.PD_INQTY == 0 && $scope.order.product[key+1] ){
- $scope.changeSelection($scope.order.product[key+1]);
- }
- }
- });
-
- var keepGoing = true;
- angular.forEach($scope.order.product, function(value, key){
- if(keepGoing){
- if(value.PD_INQTY != 0 ){
- keepGoing = false ;
- }
- }
- });
- if(keepGoing){
- if(confirm("已完成,请提交采集")){
- $location.path('inMMWaitSubmit/' + $scope.order.PI_INOUTNO);
- }
- }
- }
- };
- $scope.enter = function (event){
- SupportUtil.nextFocus(event);
- };
- $scope.submitGet = function(){//提交采集操作,与后台交互
- if($scope.grid.length != 0){
- PurcOrderItem.saveBarcode({}, JSON.stringify($scope.grid),function(data) {//获取成功
- if(data.exceptionInfo){
- toaster.pop('error', '提交失败',data.exceptionInfo);
- Ring.error();
- }else{
- $rootScope.grid = $scope.grid ='';
- Ring.success();
- toaster.pop('success', '提交成功');
- }
- }, function(response){//获取失败处理
- if(response.status == 0){ //无网络错误
- Online.setOnline(false);//修改网络状态
- Ring.error();
- toaster.pop('error', '提交失败',"网络连接不可用,请稍后再试");
- }else {
- Ring.error();
- toaster.pop('error', '提交失败',response.data.exceptionInfo);
- }
- });
- }else {
- Ring.error();
- toaster.pop('error', '无数据');
- }
- };
-
- $scope.getList = function(argOrder){//点击
- if(argOrder){
- $location.path('inMMWaitSubmit/' + argOrder);
- }
- };
-
- $scope.returnInput = function(){//当前单据有未提交的,提示先提交。
- if($scope.grid.length != 0){
- if(confirm("返回将清空未提交数据,确认返回?")){
- angular.forEach($scope.order.product, function(value, key){
- for (var gs in $scope.grid){
- if (value.PD_ID == $scope.grid[gs].bi_pdid) {
- value.PD_INQTY = eval($scope.grid[gs].bi_inqty+"+"+value.PD_INQTY);
- }
- }
- });
- $rootScope.grid = $scope.grid ='';
- $location.path('inMakeMaterial');
- }
- }else{
- var status = '101';
- angular.forEach($scope.order.product, function(value, key){
- if(value.PD_INQTY !=0) {
- status = '102'
- }
- });
- if(status == '101'){//修改采集状态
- $scope.order.ENAUDITSTATUS='101';
- }
- $location.path('inMakeMaterial');
- }
- }
-
- $scope.findProdcode = function (){
- var modalInstance = $modal.open({
- templateUrl: 'prodModalContent.html',
- controller: 'ProdModalInstanceCtrl',
- resolve: {
- items: function () {
- return $scope.order.product;
- }
- }
- });
- modalInstance.result.then(function(selectedItem) {
- $scope.changeSelection(selectedItem);
- }, function() {
- /*$log.info('Modal dismissed at: ' + new Date());*/
- });
- }
- }]);
-
- app.controller('ProdModalInstanceCtrl',['$scope', '$modalInstance', 'items',function($scope, $modalInstance, items) {
- $scope.items = items;
- $scope.wh = {};
- $scope.selectPrCode = function(selectValue) {
- $modalInstance.close(selectValue);
- };
- $scope.cancel = function() {
- $modalInstance.dismiss('cancel');
- };
- }]);
- app.controller('InMMwaitSubmitCtrl',['$scope','$rootScope','$stateParams','$filter', 'ngTableParams','Online','PurcOrderItem','toaster','Ring', function($scope, $rootScope,$stateParams,$filter, ngTableParams,Online,PurcOrderItem,toaster,Ring){
- $scope.grid = $rootScope.grid;
- var getOrder = function(code) {//根据路径中的id号获取对应的单据
- var result = null;
- angular.forEach($rootScope.orders, function(value, key){
- if(value.PI_INOUTNO == code) {
- result = value;
- return result;
- }
- });
- return result;
- };
- $scope.order = getOrder($stateParams.ioNocode);
- if($scope.grid){
- $scope.tableParams = new ngTableParams({//未完成料号名称规格及剩余数量表格
- page: 1,
- count: 10,
- filter: {
- },
- sorting: {
- }
- }, {
- total: $scope.grid.length,
- getData: function ($defer, params) {
- var filteredData = params.filter() ?
- $filter('filter')($scope.grid, params.filter()) :
- data;
- var orderedData = params.sorting() ?
- $filter('orderBy')(filteredData, params.orderBy()) :
- data;
- params.total(orderedData.length); // set total for recalc pagination
- $defer.resolve(orderedData.slice((params.page() - 1) * params.count(), params.page() * params.count()));
- }
- });
- }
- $scope.deleteAll = function (){//全部删除
- if(confirm("确定删除全部?")){
- angular.forEach($rootScope.orders, function(value, key) {//反写剩余数
- if (value.PI_INOUTNO == $scope.order.PI_INOUTNO) {
- for (var n in value.product) {
- for (var gs in $scope.grid){
- if (value.product[n].PD_ID == $scope.grid[gs].bi_pdid) {
- value.product[n].PD_INQTY = eval($scope.grid[gs].bi_inqty+"+"+value.product[n].PD_INQTY);
- }
- }
- }
- }
- });
- $rootScope.grid = $scope.grid ='';
- $scope.tableParams.reload();
- toaster.pop('success', '删除成功');
- }
- }
- $scope.deleteWaitSubmitItem = function (s){
- angular.forEach($rootScope.orders, function(value, key) {
- if (value.PI_INOUTNO == $scope.order.PI_INOUTNO) {
- for (var n in value.product) {
- if (value.product[n].PD_ID == s.bi_pdid) {
- value.product[n].PD_INQTY = eval(s.bi_inqty+"+"+value.product[n].PD_INQTY);
- }
- }
- }
- });
- for (var n in $scope.grid){
- if($scope.grid[n].bi_barcode == s.bi_barcode){
- $scope.grid.splice(n,1);
- }
- }
- $rootScope.grid = $scope.grid;
- $scope.tableParams.reload();
- };
-
- $scope.submitGet = function(){//提交采集操作,与后台交互
- if($scope.grid.length !=0){
- PurcOrderItem.saveBarcode({}, JSON.stringify($scope.grid),function(data) {//获取成功
- if(data.exceptionInfo){
- toaster.pop('error', '提交失败',data.exceptionInfo);
- Ring.error();
- }else{
- $rootScope.grid = $scope.grid ='';
- Ring.success();
- toaster.pop('success', '提交成功');
- }
- }, function(response){//获取失败处理
- if(response.status == 0){ //无网络错误
- Online.setOnline(false);//修改网络状态
- Ring.error();
- toaster.pop('error', '提交失败',"网络连接不可用,请稍后再试");
- }
- else {
- Ring.error();
- toaster.pop('error', '提交失败',response.data.exceptionInfo);
- }
- });
- }else{
- Ring.error();
- toaster.pop('error', '无数据');
- }
- };
- }]);
- app.controller('InFinishOprCtrl',['$scope', '$http', '$stateParams', '$rootScope','$filter','$location','$modal', 'ngTableParams','toaster', 'Ring', 'PurcOrderItem','SupportUtil', 'Online','$q', function($scope, $http, $stateParams, $rootScope,$filter,$location,$modal, ngTableParams,toaster, Ring, PurcOrderItem,SupportUtil, Online,$q){
- $scope.grid = $rootScope.fisgrid||[];
- $scope.getOnline = Online.getOnline;
- setTimeout( function(){
- try{
- document.getElementById("bi_barcode").focus();
- } catch(e){}
- }, 200);
-
- var getOrder = function(code) {//根据路径中的id号获取对应的单据
- var result = null;
- angular.forEach($rootScope.fisOrders, function(value, key){
- if(value.PI_INOUTNO == code) {
- result = value;
- return result;
- }
- });
- return result;
- };
- $scope.changeSelection = function(item) {//table with row selection,表格选中列操作
- document.getElementById("bi_barcode").focus();
- $scope.ordercode = item.PD_ORDERCODE;
- $scope.bi_prodcode = item.PD_PRODCODE;
- $scope.bi_prodid = item.PR_ID;
- $scope.bi_prodspec = item.PD_PRODCODE+item.PR_DETAIL;
- $scope.bi_inoutno = $scope.order.PI_INOUTNO;
- $scope.bi_inqty = item.PR_ZXBZS|| $scope.bi_inqty;
- $scope.pr_fbzs = item.PD_INQTY;
- $scope.bi_location =item.PR_LOCATION;
- $scope.bi_prodname = item.PR_DETAIL;
- $scope.detno = item.PD_PDNO;
- $scope.pd_id = item.PD_ID;
- $scope.pr_id = item.PR_ID;
- }
- $scope.order = getOrder($stateParams.code);
- $rootScope.title = {};
- $rootScope.title.pi_inoutno = $scope.order.PI_INOUTNO +' '+$scope.order.PI_WHCODE;
- if($scope.order){
- $scope.tableParams = new ngTableParams({//已经采集完成的列表
- page: 1,
- count: 10,
- filter: {
- },
- sorting: {
- }
- }, {
- total: $scope.order.product.length,
- getData: function ($defer, params) {
- var filteredData = params.filter() ?
- $filter('filter')($scope.order.product, params.filter()) :
- data;
- var orderedData = params.sorting() ?
- $filter('orderBy')(filteredData, params.orderBy()) :
- data;
- params.total(orderedData.length); // set total for recalc pagination
- $defer.resolve(orderedData.slice((params.page() - 1) * params.count(), params.page() * params.count()));
- }
- });
- var keepGoing = true;
- angular.forEach($scope.order.product, function(value, key){
- if( keepGoing ){
- if(value.PD_INQTY == 0 && $scope.order.product[key+1].PD_INQTY != 0){
- $scope.changeSelection($scope.order.product[key+1]);
- keepGoing = false ;
- }else {
- $scope.changeSelection($scope.order.product[key]);
- keepGoing = false;
- }
- }
- });
- };
-
- var checkOutbox = function(defer){
- //包装箱号,则根据包装表packageDetail获取所有序列号和总数,
- //如果外包装不止一层可能存在递归,如果总数不超过剩余数则执行插入到grid。
- PurcOrderItem.getPackageCode({pr_fqty:$scope.pr_fbzs,pa_outboxcode:$scope.bi_outboxcode}, {},function(data){
- if(data.exceptionInfo){
- defer.reject(data.exceptionInfo);
- }else{
- defer.resolve(data.message);
- }
- },function(response){
- document.getElementById("bi_outboxcode").focus();
- Ring.error();
- defer.reject(response.data.exceptionInfo);
- });
- };
- var checkMakeSerial = function (defer){
- //如果有设定的归属工单,必须序列号归属于选定的工单(关联MakeSerial表判断),
- //5、如果该序列号已经存在库存(barcode表remain>0 ),不允许重复入库。
- if($scope.makeSerial){
- PurcOrderItem.checkMakeSerial({ms_sncode:$scope.bi_barcode,makeCode:$scope.makeSerial,whcode:$scope.order.PI_WHCODE}, {},function(data){
- if(data.exceptionInfo){
- defer.reject(data.exceptionInfo);
- }else
- defer.resolve(data.message);
- },function(response){
- document.getElementById("makeSerial").focus();
- Ring.error();
- defer.reject(response.data.exceptionInfo);
- });
- }else{
- defer.resolve('');
- }
- }
- var check = function (){
- //校验:1、物料编号存在, 2、数量不超过剩余数量,3、条码号唯一性
- //条码储位不允许为空
- var defer = $q.defer();
- var reg = /^[0-9]*[1-9][0-9]*$/;
- if(!$scope.bi_barcode && !$scope.bi_outboxcode){
- document.getElementById("bi_barcode").focus();
- Ring.error();
- defer.reject("请输入序列号或者包装箱号!");
- }else if(!$scope.bi_location){
- document.getElementById("bi_location").focus();
- Ring.error();
- defer.reject("请输入储位!");
- }else if(!reg.test($scope.bi_inqty)){
- document.getElementById("bi_inqty").focus();
- Ring.error();
- defer.reject("数量格式不正确!");
- }else{
- var item = SupportUtil.contains(JSON.stringify($scope.order.product),$scope.bi_prodcode,"PD_PRODCODE");
- if(item){
- /*//是否条码校验
- if($scope.ifbarcodecheck == '1'){
- var pr_idlen =$scope.order.barcodeset.BS_LENPRID;
- //比较物料ID的前几位是否等于条码号的前几位
- var pr_id = new String($scope.pr_id);
- var bar_code = new String($scope.bi_barcode);
- if (SupportUtil.lap(pr_id,pr_idlen) != SupportUtil.lap(bar_code,pr_idlen)){
- Ring.error();
- $scope.bi_barcode ='';
- defer.reject("条码校验错误,该条码与物料不匹配")
- }
- } */
- if($scope.bi_inqty !=0 && $scope.bi_inqty >0 && ($scope.bi_inqty < $scope.pr_fbzs || $scope.bi_inqty == $scope.pr_fbzs) && $scope.pr_fbzs > -1 ){
- if($scope.bi_barcode){
- if($rootScope.fisgrid && SupportUtil.contains(JSON.stringify($rootScope.fisgrid) ,$scope.bi_barcode,"bi_barcode")){
- document.getElementById("bi_barcode").focus();
- Ring.error();
- defer.reject("序列号重复");
- }else
- checkMakeSerial(defer);
- }else{
- if($rootScope.fisgrid && $scope.bi_outboxcode && SupportUtil.contains(JSON.stringify($rootScope.fisgrid) ,$scope.bi_outboxcode,"bi_outboxcode")){
- Ring.error();
- defer.reject("包装箱号重复");
- }else{
- checkOutbox(defer);
- }
- }
- }else {
- Ring.error();
- defer.reject("数量不能大于剩余数量或者为空");
- }
- }else {
- defer.reject("物料不存在");
- Ring.error();
- }
- }
- return defer.promise;
- };
- $scope.scan = function(){//确认按钮事件
- var q = check();
- q.then(function(message){
- $scope.barcodes = {};
- $scope.barcodes.bi_barcode = $scope.bi_barcode;
- $scope.barcodes.bi_prodcode = $scope.bi_prodcode ;
- $scope.barcodes.bi_prodid = $scope.bi_prodid ;
- $scope.barcodes.bi_inoutno = $scope.bi_inoutno;
- $scope.barcodes.bi_inqty = $scope.bi_inqty;
- $scope.barcodes.bi_location = $scope.bi_location;
- $scope.barcodes.bi_whcode = $scope.order.PI_WHCODE;
- $scope.barcodes.bi_outboxcode = $scope.bi_outboxcode ;
- $scope.barcodes.bi_prodname = $scope.bi_prodname;
- $scope.barcodes.bi_pdno = $scope.detno;
- $scope.barcodes.bi_pdid = $scope.pd_id;
- $scope.barcodes.bi_piid = $scope.order.PI_ID;
- //插入数据到待提交缓存列表中grid(barcode,prodcode,inqty,location)
- $scope.grid.push($scope.barcodes);
- $rootScope.fisgrid = $scope.grid;
- $scope.pr_fbzs -= $scope.barcodes.bi_inqty;
- $scope.bi_barcode ='';
- Ring.success();
- angular.forEach($scope.order.product, function(value, key){
- if(value.PD_ID == $scope.pd_id) {
- value.PD_INQTY = $scope.pr_fbzs ;
- $scope.tableParams.reload();
- if(value.PD_INQTY == 0 && $scope.order.product[key+1] ){
- $scope.changeSelection($scope.order.product[key+1]);
- }
- }
- });
- var keepGoing = true;
- angular.forEach($scope.order.product, function(value, key){
- if(keepGoing){
- if(value.PD_INQTY != 0 ){
- keepGoing = false ;
- }
- }
- });
- if(keepGoing){
- if(confirm("已完成,请提交采集")){
- $location.path('inFinishWaitSubmit/' + $scope.order.PI_INOUTNO);
- }
- }
- }, function(error){
- Ring.error();
- toaster.pop('error', '错误',error);
- });
- };
- $scope.enter = function (event){
- SupportUtil.nextFocus(event);
- };
- $scope.submitGet = function(){//提交采集操作,与后台交互
- if($scope.grid.length >0){
- PurcOrderItem.saveBarcode({},JSON.stringify($scope.grid),function(data) {//获取成功
- if(data.exceptionInfo){
- toaster.pop('error', '提交失败',data.exceptionInfo);
- Ring.error();
- }else if(data.message){
- Ring.error();
- toaster.pop('error', '提交失败',data.message);
- }else{
- Ring.success();
- toaster.pop('success', '提交成功');
- $rootScope.fisgrid = $scope.grid ='';
- }
- }, function(response){//获取失败处理
- if(response.status == 0){ //无网络错误
- Online.setOnline(false);//修改网络状态
- Ring.error();
- toaster.pop('error', '提交失败',"网络连接不可用,请稍后再试");
- }else {
- Ring.error();
- toaster.pop('error', '提交失败',response.data.exceptionInfo);
- }
- });
- }else{
- Ring.error();
- toaster.pop('error', '没有需要提交的数据');
- }
- };
-
- $scope.getList = function(argOrder){//点击
- if(argOrder){
- $location.path('inFinishWaitSubmit/' + argOrder);
- }
- };
-
- $scope.returnInput = function(){//当前单据有未提交的,提示先提交。
- if($scope.grid.length != 0){
- if(confirm("返回将清空未提交数据,确认返回?")){
- angular.forEach($scope.order.product, function(value, key){
- for (var gs in $scope.grid){
- if (value.PD_ID == $scope.grid[gs].bi_pdid) {
- value.PD_INQTY = eval($scope.grid[gs].bi_inqty+"+"+value.PD_INQTY);
- }
- }
- });
- $rootScope.fisgrid = $scope.grid ='';
- $location.path('inFinish');
- }
- }else{
- var status = '101';
- angular.forEach($scope.order.product, function(value, key){
- if(value.PD_INQTY !=0) {
- status = '102'
- }
- });
- if(status == '101'){//修改采集状态
- $scope.order.ENAUDITSTATUS='101';
- }
- $location.path('inFinish');
- }
-
- }
- $scope.findProdcode = function (){
- var modalInstance = $modal.open({
- templateUrl: 'prodModalContent.html',
- controller: 'ProdModalInstanceCtrl',
- resolve: {
- items: function () {
- return $scope.order.product;
- }
- }
- });
- modalInstance.result.then(function(selectedItem) {
- $scope.changeSelection(selectedItem);
- });
- }
- }]);
-
- app.controller('InfinishWaitSubmitCtrl',['$scope', '$rootScope','$stateParams','$filter', 'ngTableParams','Online','PurcOrderItem','toaster','Ring', function($scope, $rootScope,$stateParams,$filter, ngTableParams,Online,PurcOrderItem,toaster,Ring){
- $scope.grid = $rootScope.fisgrid||[];
- var getOrder = function(code) {//根据路径中的id号获取对应的单据
- var result = null;
- angular.forEach($rootScope.fisOrders, function(value, key){
- if(value.PI_INOUTNO == code) {
- result = value;
- return result;
- }
- });
- return result;
- };
- $scope.order = getOrder($stateParams.ioNocode);
- if($scope.grid){
- $scope.tableParams = new ngTableParams({//未完成料号名称规格及剩余数量表格
- page: 1,
- count: 10,
- filter: { },
- sorting: { }
- }, {
- total: $scope.grid.length,
- getData: function ($defer, params) {
- var filteredData = params.filter() ?
- $filter('filter')($scope.grid, params.filter()) :
- data;
- var orderedData = params.sorting() ?
- $filter('orderBy')(filteredData, params.orderBy()) :
- data;
- params.total(orderedData.length); // set total for recalc pagination
- $defer.resolve(orderedData.slice((params.page() - 1) * params.count(), params.page() * params.count()));
- }
- });
- };
- $scope.deleteAll = function (){//全部删除
- if(confirm("确定删除全部?")){
- angular.forEach($rootScope.fisOrders, function(value, key) {//反写剩余数
- if (value.PI_INOUTNO == $scope.order.PI_INOUTNO) {
- for (var n in value.product) {
- for (var gs in $scope.grid){
- if (value.product[n].PD_ID == $scope.grid[gs].bi_pdid) {
- value.product[n].PD_INQTY = eval($scope.grid[gs].bi_inqty+"+"+value.product[n].PD_INQTY);
- }
- }
- }
- }
- });
- $rootScope.fisgrid = $scope.grid ='';
- $scope.tableParams.reload();
- toaster.pop('success', '删除成功');
- }
- };
- $scope.deleteWaitSubmitItem = function (s){
- angular.forEach($rootScope.fisOrders, function(value, key) {
- if (value.PI_INOUTNO == $scope.order.PI_INOUTNO) {
- for (var n in value.product) {
- if (value.product[n].PD_ID == s.bi_pdid) {
- value.product[n].PD_INQTY = eval(s.bi_inqty+"+"+value.product[n].PD_INQTY);
- }
- }
- }
- });
- for (var n in $scope.grid){
- if($scope.grid[n].bi_barcode == s.bi_barcode){
- $scope.grid.splice(n,1);
- }
- }
- $rootScope.fisgrid = $scope.grid;
- $scope.tableParams.reload();
- };
-
- $scope.submitGet = function(){//提交采集操作,与后台交互
- PurcOrderItem.saveBarcode({}, JSON.stringify($scope.grid),function(data) {//获取成功
- if(data.exceptionInfo){
- toaster.pop('error', '提交失败',data.exceptionInfo);
- Ring.error();
- }else{
- Ring.success();
- toaster.pop('success', '提交成功');
- }
- }, function(response){//获取失败处理
- if(response.status == 0){ //无网络错误
- Online.setOnline(false);//修改网络状态
- Ring.error();
- toaster.pop('error', '提交失败',"网络连接不可用,请稍后再试");
- }
- else {
- Ring.error();
- toaster.pop('error', '提交失败',response.data.exceptionInfo);
- }
- });
- };
- }]);
-
- app.controller('CountingCtrl',['$scope', '$http', '$stateParams', '$rootScope','$filter','$location', 'ngTableParams','toaster', 'Ring', 'SupportUtil','CountingOper', 'Online','SessionService',function($scope, $http, $stateParams, $rootScope,$filter,$location, ngTableParams,toaster, Ring, SupportUtil,CountingOper, Online,SessionService){
- $scope.stocking = $rootScope.stocking||'';
- $scope.st_whcode = SessionService.getCookie('defaultWhcode');
- $scope.find = function(event,st_code){
- if(event.keyCode === 13){
- $scope.search(st_code);
- }
- }
- $scope.search = function(st_code){
- if(st_code){
- CountingOper.get({st_code:st_code},function(data){
- if(data.exceptionInfo){
- toaster.pop('error', '查询失败',data.exceptionInfo);
- Ring.error();
- }else if(data.target && data.totalCount > 0){
- var or = new Object();
- or = data.target;
- $scope.stocking = data.target[0];
- $rootScope.stocking = $scope.stocking;
- $scope.st_whcode = $scope.stocking.ST_WHCODE;
- }
- },function(response){
- if(response.status == 0){ //无网络错误
- Online.setOnline(false);//修改网络状态
- Ring.error();
- toaster.pop('error', "网络连接不可用,请稍后再试");
- }else{
- toaster.pop('error', '查询失败',response.data.exceptionInfo);
- Ring.error();
- }
- });
- }else{
- alert("请输入盘点底稿编号!");
- document.getElementById("st_code").focus()
- }
- }
-
- $scope.confirm = function(){
- if($scope.Counting == 'makeMaterial'){
- $location.path("countingMM");
- }else{
- $location.path("countingFinish");
- }
- }
- }]);
- app.controller('CountingMMCtrl',['$scope', '$http', '$stateParams', '$rootScope','$filter','$location', 'ngTableParams','toaster', 'Ring', 'SupportUtil','CountingOper', 'Online',function($scope, $http, $stateParams, $rootScope,$filter,$location, ngTableParams,toaster, Ring, SupportUtil,CountingOper, Online){
- $scope.stocking = $rootScope.stocking||'';
- $scope.grid = $rootScope.cmGrid||[];
- var check = function(){//条码号不为空;2、数量大于0;3、条码不存在于已采集列表
- if(!$scope.barcodes.stb_barcode){
- document.getElementById("bi_barcode").focus();
- Ring.error();
- alert("条码号不为空");
- return false;
- }else if(SupportUtil.contains(JSON.stringify($scope.grid),$scope.barcodes.stb_barcode,"stb_barcode")){
- alert("条码编号重复!");
- Ring.error();
- document.getElementById("bi_barcode").focus();
- document.getElementById("bi_barcode").select();
- return false;
- }else if($scope.barcodes.stb_qty <=0){
- alert ("数量必须大于0");
- Ring.error();
- return false;
- }else {
- return true;
- }
- }
- $scope.barcodes = {};
- $scope.search = function($event,bi_barcode){
- if($event.keyCode == 13) {//Enter事件
- if(check()){
- CountingOper.getBarData({bar_code:bi_barcode,bar_whcode:$scope.stocking.ST_WHCODE,st_code:$scope.stocking.ST_CODE},{},function(data){
- if(data.exceptionInfo){
- toaster.pop('error', '条码号错误',data.exceptionInfo);
- Ring.error();
- }else {
- $scope.barcodes.stb_barcode = data.data.BAR_CODE;
- $scope.barcodes.stb_vendcode = data.data.BAR_VENDCODE;
- $scope.barcodes.stb_prodcode = data.data.BAR_PRODCODE;
- $scope.barcodes.stb_barid = data.data.BAR_ID;
- $scope.barcodes.stb_qty = data.data.BAR_REMAIN;
- $scope.barcodes.stb_stid = $scope.stocking.ST_ID;
- $scope.barcodes.stb_stcode = $scope.stocking.ST_CODE;
- $scope.barcodes.pr_detail = data.data.PR_DETAIL;
- }
- },function(response){
- if(response.status == 0){ //无网络错误
- Online.setOnline(false);//修改网络状态
- Ring.error();
- toaster.pop('error', "网络连接不可用,请稍后再试");
- }else{
- toaster.pop('error', '条码号错误',response.data.exceptionInfo);
- Ring.error();
- }
- })
- }
- }
- }
- $scope.confirm = function(){
- if(check()){
- $scope.show = true;
- $scope.grid.push($scope.barcodes);
- $scope.shows = $scope.barcodes;
- $scope.barcodes ='';
- document.getElementById("bi_barcode").focus();
- }
- $rootScope.cmGrid = $scope.grid ;
- };
- $scope.returnCC = function (){
- if($scope.grid.length>0){
- if(confirm("返回,将删除已采集未提交的数据?")){
- $scope.grid = $rootScope.cfGrid = '';
- $location.path("countingContents");
- }
- }else{
- $location.path("countingContents");
- }
- };
- $scope.submitGet = function(){//提交盘点数据
- if($scope.grid.length>0){
- CountingOper.saveBarcode({},JSON.stringify($scope.grid),function(data){
- if(data.exceptionInfo){
- toaster.pop('error', '提交失败',data.exceptionInfo);
- Ring.error();
- }else {
- $scope.grid = $rootScope.cmGrid = '';
- toaster.pop('success', '提交成功');
- Ring.success();
- }
- },function(response){
- if(response.status == 0){ //无网络错误
- Online.setOnline(false);//修改网络状态
- Ring.error();
- toaster.pop('error', '提交失败',"网络连接不可用,请稍后再试");
- }else{
- toaster.pop('error', '提交失败',response.data.exceptionInfo);
- Ring.error();
- }
- });
- }else{
- Ring.error();
- alert("没有需要提交的数据!");
- }
- }
-
- if($scope.grid){
- $scope.tableParams = new ngTableParams({//盘点料号名称规格及剩余数量表格【待提交的】
- page: 1,
- count: 10,
- filter: { },
- sorting: { }
- }, {
- total: $scope.grid.length,
- getData: function ($defer, params) {
- params.total($scope.grid.length); // set total for recalc pagination
- $defer.resolve($scope.grid.slice((params.page() - 1) * params.count(), params.page() * params.count()));
- }
- });
- };
-
- $scope.deleteAll = function(){//全部删除
- if(confirm("确定删除全部?")){
- $scope.grid = $rootScope.cmGrid = '';
- Ring.success();
- toaster.pop('success', '删除成功');
- $scope.tableParams.reload();
- }
- }
-
- $scope.deleteWaitSubmitItem = function(s){//单行删除
- for (var n in $scope.grid){
- if($scope.grid[n].stb_barcode == s.stb_barcode){
- $scope.grid.splice(n,1);
- }
- }
- $rootScope.cmGrid = $scope.grid;
- $scope.tableParams.reload();
- };
- }]);
-
- app.controller('CountingFinishCtrl',['$scope', '$http', '$stateParams', '$rootScope','$filter','$location', 'ngTableParams','toaster', 'Ring', 'SupportUtil','CountingOper', 'Online',function($scope, $http, $stateParams, $rootScope,$filter,$location, ngTableParams,toaster, Ring, SupportUtil,CountingOper, Online){
- $scope.stocking = $rootScope.stocking||'';
- $scope.grid = $rootScope.cfGrid||[];
- var checkSerialSearch = function(serial_code){
- if(SupportUtil.contains(JSON.stringify($scope.grid),serial_code,"stb_barcode")){
- Ring.error();
- alert("序列号重复!");
- document.getElementById("serial_code").focus().select();
- return ;
- }else{
- CountingOper.serialSearch({code:serial_code,whcode:$scope.stocking.ST_WHCODE,st_code:$scope.stocking.ST_CODE},{},function(data){
- if(data.exceptionInfo){
- toaster.pop('error', '序列号不存在',data.exceptionInfo);
- Ring.error();
- }else {
- $scope.serialMessage = data.message;
- $scope.makeCode = $scope.serialMessage.MA_CODE;
- $scope.prodcode = $scope.serialMessage.stb_prodcode;
- }
- },function(response){
- if(response.status == 0){ //无网络错误
- Online.setOnline(false);//修改网络状态
- Ring.error();
- toaster.pop('error', "网络连接不可用,请稍后再试");
- }else{
- Ring.error();
- toaster.pop('error', '序列号不存在',response.data.exceptionInfo);
- }
- });
- }
- }
- $scope.serialSearch = function ($event,serial_code){//序列号enter事件
- if($event.keyCode == 13 && serial_code){
- checkSerialSearch(serial_code);
- }
- };
-
- var checkOutboxSearch = function (boxcode){
- if(SupportUtil.contains(JSON.stringify($scope.grid),serial_code,"stb_barcode")){
- alert("包装箱号重复");
- Ring.error();
- return ;
- }else {
- CountingOper.outboxSearch({code:boxcode,whcode:$scope.stocking.ST_WHCODE,st_code:$scope.stocking.ST_CODE},{},function(data){
- if(data.exceptionInfo){
- toaster.pop('error', '包装箱号不存在',data.exceptionInfo);
- Ring.error();
- }else{
- $scope.outboxMessage = data.message;
- $scope.totalqty = $scope.outboxMessage.stb_qty;
- $scope.prodcode = $scope.outboxMessage.stb_prodcode;}
- },function(response){
- if(response.status == 0){ //无网络错误
- Online.setOnline(false);//修改网络状态
- Ring.error();
- toaster.pop('error', "网络连接不可用,请稍后再试");
- }
- Ring.error();
- toaster.pop('error', '包装箱号不存在',response.data.exceptionInfo);
- });
- }
- };
- $scope.outboxSearch = function($event,boxcode){//包装箱号enter事件
- if($event.keyCode == 13 && boxcode){
- checkOutboxSearch(boxcode);
- }
- }
-
- $scope.confirm = function(){
- if(!$scope.serial){
- alert("请选择包装箱号或者序列号");
- return ;
- }else if($scope.serial == 'outbox' && !$scope.boxcode){
- alert("请输入包装箱号");
- return;
- }else if($scope.serial == 'serial' && !$scope.serial_code){
- alert("请输入序列号");
- return ;
- }else if($scope.serial == 'serial' && $scope.serial_code ){//选择序列号执行确认
- checkSerialSearch($scope.serial_code);
- $scope.serialMessage.stb_stcode = $scope.stocking.ST_CODE;
- $scope.serialMessage.stb_stid = $scope.stocking.ST_ID;
- $scope.grid.push($scope.serialMessage);
- $scope.serial_code = $scope.makeCode ='';
- document.getElementById("serial_code").focus();
- Ring.success();
- }else if($scope.serial == 'outbox' && $scope.boxcode ){
- checkOutboxSearch($scope.boxcode);
- $scope.outboxMessage.stb_stcode = $scope.stocking.ST_CODE;
- $scope.outboxMessage.stb_stid = $scope.stocking.ST_ID;
- $scope.grid.push($scope.outboxMessage);
- $scope.boxcode = $scope.totalqty ='';
- document.getElementById("boxcode").focus();
- Ring.success();
- }
- $rootScope.cfGrid = $scope.grid;
- $scope.shows= $scope.grid[$scope.grid.length-1];
- };
-
- $scope.returnCC = function (){
- if($scope.grid.length>0){
- if(confirm("返回,将删除已采集未提交的数据?")){
- $scope.grid = $rootScope.cfGrid = '';
- $location.path("countingContents");
- }
- }else
- $location.path("countingContents");
- }
-
- $scope.submitGet = function(){
- if($scope.grid.length>0){
- CountingOper.saveBarcode({data:JSON.stringify($scope.grid)},{},function(data){
- if(data.exceptionInfo){
- toaster.pop('error', '提交失败',data.exceptionInfo);
- Ring.error();
- }else{
- $scope.grid = $rootScope.cfGrid = '';
- toaster.pop('success', '提交成功');
- Ring.success();
- }
- },function(response){
-
- toaster.pop('error', '提交失败',response.data.exceptionInfo);
- Ring.error();
- });
- }else{
- Ring.error();
- alert("没有需要提交的数据!");
- }
- };
-
- if($scope.grid){
- $scope.tableParams = new ngTableParams({//盘点料号名称规格及剩余数量表格【待提交的】
- page: 1,
- count: 10,
- filter: { },
- sorting: { }
- }, {
- total: $scope.grid.length,
- getData: function ($defer, params) {
- params.total($scope.grid.length); // set total for recalc pagination
- $defer.resolve($scope.grid.slice((params.page() - 1) * params.count(), params.page() * params.count()));
- }
- });
- };
-
- $scope.deleteWaitSubmitItem = function( s){
- for (var n in $scope.grid){
- if($scope.grid[n].stb_barcode == s.stb_barcode){
- $scope.grid.splice(n,1);
- }
- }
- $rootScope.cfGrid = $scope.grid;
- $scope.tableParams.reload();
- };
- $scope.deleteAll = function(){
- if(confirm("确定删除全部?")){
- $scope.grid = $rootScope.cfGrid = '';
- Ring.success();
- toaster.pop('success', '删除成功');
- $scope.tableParams.reload();
- }
- }
-
- }]);
-
- app.controller('BatchCtrl',['$scope', '$http', '$stateParams', '$rootScope','$filter','$location', 'BatchOper','ngTableParams','toaster', 'Ring', 'SupportUtil', 'Online','SessionService',function($scope, $http, $stateParams, $rootScope,$filter,$location, BatchOper,ngTableParams,toaster, Ring, SupportUtil, Online,SessionService){
- $scope.batchclick = function(choose){
- $location.path(choose);
- };
- }]);
- app.controller('BreakingBatchCtrl',['$scope', '$http', '$stateParams', '$rootScope','$filter','$location', 'BatchOper','ngTableParams','toaster', 'Ring', 'SupportUtil', 'Online','$modal',function($scope, $http, $stateParams, $rootScope,$filter,$location, BatchOper,ngTableParams,toaster, Ring, SupportUtil, Online,$modal){
- $scope.grid = [];
- $scope.btnInvalid = true;
- if($scope.grid){
- $scope.tableParams = new ngTableParams({//批次合并
- page: 1,
- count: 10,
- filter: { },
- sorting: { }
- }, {
- total: $scope.grid.length,
- getData: function ($defer, params) {
- params.total($scope.grid.length); // set total for recalc pagination
- $defer.resolve($scope.grid.slice((params.page() - 1) * params.count(), params.page() * params.count()));
- }
- });
- };
- $scope.search = function($event,barcode,type){//根据输入的条码编号查询相关信息
- if($scope.grid.length >0 && type !='breaking'){//条码拆分不需要判断是否重复
- if(SupportUtil.contains(JSON.stringify($scope.grid),barcode,"bar_code")){
- Ring.error();
- alert("条码重复!");
- return ;
- }
- }
- if($event.keyCode == 13){
- BatchOper.get({code:barcode},function(data){
- if(data.exceptionInfo){
- toaster.pop('error',data.exceptionInfo);
- Ring.error();
- document.getElementById("or_barcode").focus();
- }else{
- $scope.barData = data.message;
- $scope.grid.push($scope.barData);
- $scope.tableParams.reload();
- $scope.bar_prodcode = $scope.barData.bar_prodcode
- $scope.pr_detail = $scope.barData.pr_detail;
- $scope.barcode.or_remain = $scope.barData.bar_remain;
- Ring.success();
- }
- },function(response){
- if(response.status == 0){ //无网络错误
- Online.setOnline(false);//修改网络状态
- Ring.error();
- toaster.pop('error', "网络连接不可用,请稍后再试");
- }else{
- Ring.error();
- toaster.pop('error', response.data.exceptionInfo);
- document.getElementById("or_barcode").focus();
- }
- });
- }
- };
-
- $scope.confirm = function(barcode,type){
- var event = new Object();
- event.keyCode = 13;
- $scope.search(event,barcode,type);
- }
- $scope.breaking = function(){//分拆
- if($scope.btnInvalid){
- //分拆之前判断定,拆分数量必须小于批数量大于0
- $scope.btnInvalid = false;
- if( $scope.barcode.bar_remain < 0 || $scope.barcode.bar_remain >= $scope.barcode.or_remain || $scope.barcode.bar_remain == 0 || $scope.barcode.bar_remain =='0'){
- Ring.error();
- toaster.pop('error', '拆分数量必须在大于0,小于批数量');
- document.getElementById("bar_remain").focus();
- $scope.btnInvalid = true;
- return ;
- }
- BatchOper.breakingBatch({},angular.fromJson($scope.barcode),function(data){
- $scope.btnInvalid = true;
- if(data.exceptionInfo){
- toaster.pop('error', '拆分失败',data.exceptionInfo);
- Ring.error();
- }else{
- Ring.success();
- toaster.pop('success', '分拆成功');
- modal(data.message);
- }
- },function(response){
- $scope.btnInvalid = true;
- if(response.status == 0){ //无网络错误
- Online.setOnline(false);//修改网络状态
- Ring.error();
- toaster.pop('error', "网络连接不可用,请稍后再试");
- }else{
- Ring.error();
- toaster.pop('error',"拆分失败",response.data.exceptionInfo);
- }
- });
- }
- },
- $scope.GetTotalRemain = function () {
- var sum = 0;
- for (var i = 0; i < $scope.grid.length; i++) {
- sum += parseFloat($scope.grid[i].bar_remain);
- }
- return sum;
- }
- $scope.combine = function(){//合并
- //合并之前进行判断物料号一致、仓库一致、储位一致
- if($scope.grid.length>1){
- //有两条或者以上的数据才进行合并
- BatchOper.combineBatch({total_remain:$scope.GetTotalRemain()},angular.fromJson($scope.grid),function(data){
- if(data.exceptionInfo){
- toaster.pop('error', '合并失败',data.exceptionInfo);
- Ring.error();
- }else{
- modal(data.message);
- Ring.success();
- $scope.grid ='';//清空
- toaster.pop('success', '合并成功');
- }
- },function(res){
- if(response.status == 0){ //无网络错误
- Online.setOnline(false);//修改网络状态
- Ring.error();
- toaster.pop('error', "网络连接不可用,请稍后再试");
- }else{
- Ring.error();
- toaster.pop('error',"合并失败",response.data.exceptionInfo);
- }
- });
- }
- };
- //
- var modal= function(data){
- var modalInstance = $modal.open({
- templateUrl: 'myModalContent.html',
- controller: 'ModalInstanceCtrl',
- resolve: {
- items: function () {
- return data;
- }
- }
- });
- modalInstance.result.then(function(items) {
- if(items != null){//继续分拆获取数据
- $scope.confirm($scope.barcode.or_barcode,'breaking');
- $scope.barcode.bar_remain='';
- document.getElementById("bar_remain").focus();
- }
- },function() {
- $scope.barcode = $scope.pr_detail = $scope.bar_prodcode = '';//清空
- document.getElementById("or_barcode").focus();
- });
- };
-
- }]);
-
- app.controller('BreakingPackageCtrl',['$scope', '$http', '$stateParams', '$rootScope','$filter','$location', 'BatchOper','ngTableParams','toaster', 'Ring', 'SupportUtil', 'Online','$modal',function($scope, $http, $stateParams, $rootScope,$filter,$location, BatchOper,ngTableParams,toaster, Ring, SupportUtil, Online,$modal){
- $scope.grid = [];
- $scope.barcode = {};
- $scope.bar = {};
- $scope.bar.new_qty = 0;
- $scope.bar.new_packageqty = 0;
- if($scope.grid){
- $scope.tableParams = new ngTableParams({//批次合并
- page: 1,
- count: 10,
- filter: { },
- sorting: { }
- }, {
- total: $scope.grid.length,
- getData: function ($defer, params) {
- params.total($scope.grid.length); // set total for recalc pagination
- $defer.resolve($scope.grid.slice((params.page() - 1) * params.count(), params.page() * params.count()));
- }
- });
- };
-
- $scope.search = function(){//根据外箱号,内箱号,或者序列号获取相关数据
- if(!$scope.barcode.inner){
- Ring.error();
- alert("请选择拆分内箱号或者序列号!");
- return ;
- }
- if($scope.barcode.inner == 'inner' && !$scope.barcode.innerBox){
- Ring.error();
- alert("请输入拆分内箱号!");
- return ;
- }else if($scope.barcode.inner == 'serial' && !$scope.barcode.innerSerial){
- Ring.error();
- alert("请输入拆分序列号!");
- return ;
- }
- if($scope.grid.length > 0){
- if($scope.barcode.or_outbox != $scope.grid[0].pa_outboxcode){
- Ring.error();
- alert("只能对同一外箱号进行拆分操作!");
- return ;
- }
- if($scope.barcode.inner == 'serial' && $scope.barcode.innerSerial){
- if(SupportUtil.contains(JSON.stringify($scope.grid),$scope.barcode.innerSerial,"pd_barcode")){
- Ring.error();
- alert("拆分序列号重复!");
- return ;
- }
- }else if($scope.barcode.inner == 'inner' && $scope.barcode.innerBox){
- if(SupportUtil.contains(JSON.stringify($scope.grid),$scope.barcode.innerBox,"pa_outboxcode")){
- Ring.error();
- alert("拆分箱号重复!");
- return ;
- }
- }
- }
- BatchOper.searchPackageData({},angular.fromJson($scope.barcode),function(data){
- if(data.exceptionInfo){
- toaster.pop('error', data.exceptionInfo);
- Ring.error();
- }else{
- $scope.grid.push(data.data);
- $scope.bar.new_qty ++; //件数
- $scope.bar.newOr_qty = data.data.pa_totalqty-$scope.bar.new_qty;//件数
- $scope.packageqty = data.data.pd_innerqty;//箱内数量
- $scope.bar.new_packageqty += $scope.packageqty; //新箱内总数
- $scope.bar.newOr_packageqty = data.data.pa_packageqty-$scope.bar.new_packageqty;//原箱总数
- $scope.tableParams.reload();
- }
- },function(response){
- if(response.status == 0){ //无网络错误
- Online.setOnline(false);//修改网络状态
- Ring.error();
- toaster.pop('error', "网络连接不可用,请稍后再试");
- }else{
- Ring.error();
- toaster.pop('error',response.data.exceptionInfo);
- }
- });
- };
- $scope.breakingoutBox = function(){//确认拆分
- BatchOper.breakingPackage({param:$scope.bar},angular.fromJson($scope.grid),function(data){
- if(data.exceptionInfo){
- toaster.pop('error', data.exceptionInfo);
- Ring.error();
- }else{
- $scope.bar.new_qty = $scope.bar.new_packageqty = 0;
- modal(data.message);
- Ring.success();
- }
- toaster.pop('success',"拆分成功");
- },function(response){
- if(response.status == 0){ //无网络错误
- Online.setOnline(false);//修改网络状态
- Ring.error();
- toaster.pop('error', "网络连接不可用,请稍后再试");
- }else{
-
- }
- });
- }
-
- $scope.getoutbox1 = function (){//获取原始拆分 新箱号
- BatchOper.getOutboxCode({pr_code:$scope.grid[0].pa_prodcode},{},function(data){
- if(data.exceptionInfo){
- toaster.pop('error', data.exceptionInfo);
- Ring.error();
- }else
- $scope.bar.newOr_outbox = data.data;
- },function(response){
- if(response.status == 0){ //无网络错误
- Online.setOnline(false);//修改网络状态
- Ring.error();
- toaster.pop('error', "网络连接不可用,请稍后再试");
- }
- });
- };
- $scope.getoutbox2 = function (){//获取拆分箱号
- BatchOper.getOutboxCode({pr_code:$scope.grid[0].pa_prodcode},{},function(data){
- if(data.exceptionInfo){
- toaster.pop('error', data.exceptionInfo);
- Ring.error();
- }else
- $scope.bar.new_outbox = data.data;
- },function(response){
- if(response.status == 0){ //无网络错误
- Online.setOnline(false);//修改网络状态
- Ring.error();
- toaster.pop('error', "网络连接不可用,请稍后再试");
- }
- });
- }
- $scope.deleteB = function(item){//删除明细
- angular.forEach($scope.grid, function(value,key){
- if(item.pd_innerboxcode == value.pd_innerboxcode){
- $scope.grid.splice(key,1);
- }
- });
- };
- var modal= function(data){
- var modalInstance = $modal.open({
- templateUrl: 'myModalContent.html',
- controller: 'ModalInstanceCtrl',
- resolve: {
- items: function () {
- return data;
- }
- }
- });
- };
- }]);
-
- app.controller('UploadCtrl', function($scope, $rootScope, PurcOrderItem, Online){
- $scope.upLoadItems = [];
- angular.forEach($rootScope.orders, function(value,key){//先去获取需要上传的Item(明细)
- angular.forEach(value.orderItems, function(item, key){
- if(item.replyCount) $scope.upLoadItems.push(item);
- });
- });
-
- $scope.upload = function(){//一键上传操作
- $scope.netError = false;
- angular.forEach($scope.upLoadItems, function(item, key){
- if(Online.getOnline()) {//判断是否有网
- item.loading = 'fa fa-spinner fa-spin';//正在上传
- //上传回复,replyCount作为回复数
- PurcOrderItem.reply({orderItemId: item.id}, {delivery: new Date().getTime(), qty: item.replyCount, remark: '测试离线后上传'},
- function(data){
- item.loading = 'fa fa-check-square';//上传成功
- item.uploadOk = true;
- item.replyCount = 0;
- }, function(response){//请求发生错误
- item.loading = 'fa fa-exclamation-triangle text-danger';//上传失败
- if(response.status == 0) {//无网络错误
- Online.setOnline(false);//修改网络状态
- $scope.netError = true;
- } else {//其他错误
- console.log(response.data);
- }
- });
- } else {
- $scope.netError = true;//断网提示
- return;
- }
- });
- };
- });
- return app;
- });
|