app.js 67 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755
  1. define([ 'angularAMD','toaster', 'ngTable', 'common/services', 'service/Purc','service/SupportServices', 'ui.router', 'ui.bootstrap','directive/SmartDirectives' ], function(angularAMD) {
  2. 'use strict';
  3. var app = angular.module('myApp', ['ngAnimate', 'toaster','ngTable', 'ui.router', 'common.services', 'PurcServices', 'SupportServices','ui.bootstrap','SmartDirectives']);
  4. app.init = function() {
  5. angularAMD.bootstrap(app);
  6. };
  7. app.config(['$stateProvider', '$urlRouterProvider', function($stateProvider, $urlRouterProvider) {
  8. $urlRouterProvider.otherwise('/index');
  9. $stateProvider.state('index', {
  10. url : "/index",
  11. templateUrl : "resources/tpl/index/index.html"
  12. }).state('inMakeMaterial',angularAMD.route({
  13. url : "/inMakeMaterial",
  14. templateUrl : "resources/tpl/input/inMakeMaterial.html",
  15. controllerUrl : 'app/controllers/InputCtrl'
  16. })).state('inMMOperation', {
  17. url: '/inMMOperation/:code',
  18. templateUrl: 'resources/tpl/input/inMMOperation.html'
  19. }).state('inContents',angularAMD.route({
  20. url:'/inContents',
  21. templateUrl:'resources/tpl/input/inContents.html',
  22. controllerUrl : 'app/controllers/InputCtrl'
  23. })).state('inMMWaitSubmit',{
  24. url:'/inMMWaitSubmit/:ioNocode',
  25. templateUrl:'resources/tpl/input/inMMWaitSubmit.html'
  26. }).state('inFinishWaitSubmit',{
  27. url:'/inFinishWaitSubmit/:ioNocode',
  28. templateUrl:'resources/tpl/input/inFinishWaitSubmit.html'
  29. }).state('inFinishOperation',{
  30. url:'/inFinishOperation/:code',
  31. templateUrl:'resources/tpl/input/inFinishOperation.html'
  32. }).state('inFinish',angularAMD.route({
  33. url:'/inFinish',
  34. templateUrl : 'resources/tpl/input/inFinish.html',
  35. controllerUrl : 'app/controllers/InFinishCtrl'
  36. })).state('outContents',angularAMD.route({
  37. url:'/outContents',
  38. templateUrl : 'resources/tpl/output/outContents.html',
  39. controllerUrl : 'app/controllers/OutputCtrl'
  40. })).state('outMakeMaterial',angularAMD.route({
  41. url:'/outMakeMaterial',
  42. templateUrl : 'resources/tpl/output/outMakeMaterial.html',
  43. controllerUrl : 'app/controllers/OutputCtrl'
  44. })).state('outMMOperation',angularAMD.route({
  45. url:'/outMMOperation/:code',
  46. templateUrl : 'resources/tpl/output/outMMOperation.html',
  47. controllerUrl : 'app/controllers/OutMMOperationCtrl'
  48. })).state('outMMWaitSubmit',angularAMD.route({
  49. url:'/outMMWaitSubmit/:ioNocode',
  50. templateUrl:'resources/tpl/output/outMMWaitSubmit.html',
  51. controllerUrl : 'app/controllers/OutMMwaitSubmitCtrl'
  52. })).state('outFinish',angularAMD.route({
  53. url:'/outFinish',
  54. templateUrl:'resources/tpl/output/outFinish.html',
  55. controllerUrl : 'app/controllers/OutFinishCtrl'
  56. })).state('outFinishOprCtrl',angularAMD.route({
  57. url:'/outFinishOperation/:code',
  58. templateUrl:'resources/tpl/output/outFinishOperation.html',
  59. controllerUrl : 'app/controllers/OutFinishOprCtrl'
  60. })).state('outFinWaitSubmit',angularAMD.route({
  61. url:'/outFinWaitSubmit/:ioNocode',
  62. templateUrl:'resources/tpl/output/outFinWaitSubmit.html',
  63. controllerUrl : 'app/controllers/OutFinWaitSubmitCtrl'
  64. })).state('countingContents',{
  65. url:'/countingContents',
  66. templateUrl:'resources/tpl/counting/countingContents.html'
  67. }).state('countingMM',{
  68. url:'/countingMM',
  69. templateUrl:'resources/tpl/counting/countingMM.html'
  70. }).state('countingFinish',{
  71. url:'/countingFinish',
  72. templateUrl:'resources/tpl/counting/countingFinish.html'
  73. }).state('countingMMWaitSub',{
  74. url:'/countingMMWaitSub',
  75. templateUrl:'resources/tpl/counting/countingMMWaitSub.html'
  76. }).state('countingFinWaitSub',{
  77. url:'/countingFinWaitSub',
  78. templateUrl:'resources/tpl/counting/countingFinWaitSub.html'
  79. }).state('checkContents',angularAMD.route({
  80. url:'/checkContents',
  81. templateUrl:'resources/tpl/check/checkContents.html',
  82. controllerUrl : 'app/controllers/CheckCtrl'
  83. })).state('checkMM',angularAMD.route({
  84. url:'/checkMM',
  85. templateUrl:'resources/tpl/check/checkMM.html',
  86. controllerUrl : 'app/controllers/CheckCtrl'
  87. })).state('checkBarcode',angularAMD.route({
  88. url:'/checkBarcode',
  89. templateUrl:'resources/tpl/check/checkBarcode.html',
  90. controllerUrl : 'app/controllers/CheckCtrl'
  91. })).state('checkPackage',angularAMD.route({
  92. url:'/checkPackage',
  93. templateUrl:'resources/tpl/check/checkPackage.html',
  94. controllerUrl : 'app/controllers/CheckCtrl'
  95. })).state('checkMakeFin',angularAMD.route({
  96. url:'/checkMakeFin',
  97. templateUrl:'resources/tpl/check/checkMakeFin.html',
  98. controllerUrl : 'app/controllers/CheckCtrl'
  99. })).state('checkOrderFin',angularAMD.route({
  100. url:'/checkOrderFin',
  101. templateUrl:'resources/tpl/check/checkOrderFin.html',
  102. controllerUrl : 'app/controllers/CheckCtrl'
  103. })).state('checkPO',angularAMD.route({
  104. url:'/checkPO',
  105. templateUrl:'resources/tpl/check/checkPO.html',
  106. controllerUrl : 'app/controllers/CheckCtrl'
  107. })).state('locationTransfer',angularAMD.route({
  108. url:'/locationTransfer',
  109. templateUrl:'resources/tpl/locationTransfer/locationTransfer.html',
  110. controllerUrl : 'app/controllers/LocationTransferCtrl'
  111. })).state('batchContents',{
  112. url:'/batchContents',
  113. templateUrl:'resources/tpl/batch/batchContents.html'
  114. }).state('breakingBatch',{
  115. url:'/breakingBatch',
  116. templateUrl:'resources/tpl/batch/breakingBatch.html'
  117. }).state('breakingPackage',{
  118. url:'/breakingPackage',
  119. templateUrl:'resources/tpl/batch/breakingPackage.html'
  120. }).state('combineBatch',{
  121. url:'/combineBatch',
  122. templateUrl:'resources/tpl/batch/combineBatch.html'
  123. }).state('settingContents',angularAMD.route({
  124. url:'/settingContents',
  125. templateUrl:'resources/tpl/setting/settingContents.html',
  126. controllerUrl : 'app/controllers/SettingCtrl'
  127. })).state('haveSubmitList',angularAMD.route({
  128. url:'/haveSubmitList/:pi_id/:inout/:pi_inoutno',
  129. templateUrl:'resources/tpl/input/haveSubmitList.html',
  130. controllerUrl : 'app/controllers/HaveSubmitListCtrl'
  131. }));
  132. }]);
  133. app.factory('Ring', function(){//响铃,直接调用
  134. return {
  135. success: function(){
  136. document.getElementById('successRing').play();
  137. }, error: function(){
  138. document.getElementById('errorRing').play();
  139. }
  140. }
  141. }).factory('Online',['$rootScope', function($rootScope){//在线状态,全局获取、设置
  142. var status = {online: true};
  143. return {
  144. setOnline: function(value){
  145. status.online = value;
  146. $rootScope.$broadcast('online', value);
  147. }, getOnline: function(){
  148. return status.online;
  149. }
  150. }
  151. }]);
  152. app.directive('enterAsTab', function () {
  153. return function (scope, element, attrs) {
  154. element.bind("keyup", function (event) {
  155. if(event.which === 13) {
  156. var focusable = document.getElementsByTagName('input');
  157. // Get the index of the currently focused element
  158. var currentIndex = Array.prototype.indexOf.call(focusable, event.target);
  159. // Find the next items in the list
  160. var nextIndex = currentIndex == focusable.length - 1 ? 0 : currentIndex + 1;
  161. // Focus the next element
  162. if(nextIndex >= 0 && nextIndex < focusable.length){
  163. if(focusable[nextIndex].value == 0||focusable[nextIndex].value == '')
  164. focusable[nextIndex].focus();
  165. }
  166. }
  167. });
  168. };
  169. });
  170. app.controller('AuthCtrl',['$scope', '$rootScope','$window', 'AuthenticationService','Online','BaseService','SessionService', function($scope, $rootScope,$window, AuthenticationService,Online,BaseService,SessionService) {
  171. //控制手机浏览器全屏 找到支持的方法, 使用需要全屏的 element 调用
  172. $rootScope.title = {};
  173. /* function launchFullScreen(element) {
  174. if(element.requestFullscreen) {
  175. element.requestFullscreen();
  176. } else if(element.mozRequestFullScreen) {
  177. element.mozRequestFullScreen();
  178. } else if(element.webkitRequestFullscreen) {
  179. element.webkitRequestFullscreen();
  180. } else if(element.msRequestFullscreen) {
  181. element.msRequestFullscreen();
  182. }
  183. }
  184. //启动全屏
  185. document.getElementById("full").addEventListener("click",function(){
  186. launchFullScreen(document.documentElement);
  187. });
  188. */
  189. $scope.status = {online: true};
  190. $scope.$watch('status.online', function(value){//检测用户手动切换在线状态
  191. Online.setOnline(value);
  192. });
  193. $scope.$on('online', function(data){//监听Service中的状态变化
  194. $scope.status.online = Online.getOnline();
  195. });
  196. Online.setOnline(AuthenticationService.isAuthed());
  197. $scope.userInfo = {};
  198. AuthenticationService.getAuthentication().success(function(data) {
  199. $scope.userInfo = data;
  200. if (data == null || !data.em_code){
  201. Online.setOnline(false);
  202. //$window.location.href = rootPath+'/jsps/PDAmobile/signin.html'
  203. }
  204. });
  205. $scope.logout = function() {//注销
  206. AuthenticationService.logout().success(function() {
  207. var rootPath= BaseService.getRootPath();
  208. $window.location.href = rootPath+'/jsps/PDAmobile/signin.html';
  209. });
  210. };
  211. }]);
  212. app.factory('StatusCode', function(){
  213. var statusConfig = {
  214. '101' : '已采集',
  215. '102' : '未采集',
  216. '103' : '采集中'
  217. };
  218. return {
  219. get: function(code) {
  220. return statusConfig[code];
  221. }
  222. };
  223. }).filter('status',['StatusCode', function(StatusCode){
  224. return function(data) {
  225. return StatusCode.get(data);
  226. }
  227. }]);
  228. app.controller('IndexCtrl',['$scope','$rootScope', function($scope, $rootScope){
  229. }]);
  230. app.controller('ModalInstanceCtrl',['$scope', '$modalInstance', 'items','SessionService','Print','toaster',function($scope, $modalInstance, items,SessionService,Print,toaster) {
  231. $scope.items = items;
  232. $scope.colors = [//可以选择的颜色
  233. {
  234. id: 'red',
  235. name: '红色'
  236. }
  237. ]
  238. $scope.defaultWhcode = SessionService.getCookie('defaultWhcode');
  239. $scope.ok = function(selectValue) {
  240. $modalInstance.close(selectValue.PD_WHCODE);
  241. };
  242. $scope.selectBill = function(item){
  243. $modalInstance.close(item);
  244. };
  245. $scope.cancel = function() {
  246. $modalInstance.dismiss('cancel');
  247. };
  248. $scope.confirmWhcode = function(items){//设置默认仓库
  249. $modalInstance.close(items);
  250. };
  251. $scope.search = function ($event,items){//搜索物料
  252. if($event == 13){
  253. $modalInstance.close(items);
  254. }
  255. };
  256. $scope.setStyle = function(){//设置样式
  257. $modalInstance.close($scope.items);
  258. };
  259. $scope.confirmPrint = function(items){//设置默认打印机
  260. $modalInstance.close(items);
  261. };
  262. $scope.returnBatching = function(item){//返回继续拆分
  263. $modalInstance.close(items);
  264. }
  265. $scope.print = function (){//打印
  266. if(confirm('确认打印')){
  267. Print.get({data:angular.fromJson($scope.items)},function(data){
  268. if(data.exceptionInfo){
  269. toaster.pop('error', data.exceptionInfo);
  270. }else if(data.message){
  271. toaster.pop('error', data.message);
  272. }else {
  273. toaster.pop('success', "打印成功!");
  274. }
  275. },function(res){
  276. if(res.status == 0){ //无网络错误
  277. Online.setOnline(false);//修改网络状态
  278. Ring.error();
  279. toaster.pop('error', "网络连接不可用,请稍后再试");
  280. }
  281. });
  282. }
  283. };
  284. }]);
  285. 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){
  286. $scope.grid = $rootScope.grid||[];
  287. $scope.getOnline = Online.getOnline;
  288. setTimeout( function(){
  289. try{
  290. document.getElementById("bi_barcode").focus();
  291. var labels = document.getElementsByName("required-label");
  292. /*for(var n in labels){
  293. labels[n].style.color = 'red';
  294. }*/
  295. var inputs = document.getElementsByTagName("input");
  296. for(var n in inputs){
  297. if(typeof inputs[n].getAttribute("required") === "string"){
  298. console.log('true');
  299. }
  300. if(typeof inputs[n].getAttribute("required") === "string"){
  301. inputs[n].labels[0].style.color = 'red';
  302. }
  303. }
  304. } catch(e){}
  305. }, 100);
  306. var getOrder = function(code) {//根据路径中的id号获取对应的单据
  307. var result = null;
  308. angular.forEach($rootScope.orders, function(value, key){
  309. if(value.PI_INOUTNO == code) {
  310. result = value;
  311. return result;
  312. }
  313. });
  314. return result;
  315. };
  316. $scope.changeSelection = function(item) {//table with row selection,表格选中列操作
  317. document.getElementById("bi_barcode").focus();
  318. $scope.ordercode = item.PD_ORDERCODE;
  319. $scope.bi_prodcode = item.PD_PRODCODE;
  320. $scope.bi_prodid = item.PR_ID;
  321. $scope.bi_inoutno = $scope.order.PI_INOUTNO;
  322. $scope.bi_inqty = item.PR_ZXBZS || $scope.bi_inqty;
  323. $scope.pr_fbzs = item.PD_INQTY;
  324. $scope.detno = item.PD_PDNO;
  325. $scope.pd_id = item.PD_ID;
  326. $scope.bi_prodname = item.PR_DETAIL;
  327. $scope.bi_location = item.PR_LOCATION || $scope.bi_location;
  328. $scope.pr_detail = item.PR_DETAIL+item.PR_SPEC;
  329. $scope.ifbarcodecheck = item.PR_IFBARCODECHECK;
  330. $scope.pr_id = item.PR_ID;
  331. }
  332. $scope.order = getOrder($stateParams.code);
  333. $rootScope.title.pi_inoutno =$scope.order.PI_INOUTNO +' '+$scope.order.PI_WHCODE;
  334. if($scope.order){
  335. var keepGoing = true;
  336. angular.forEach($scope.order.product, function(value, key){
  337. if( keepGoing ){
  338. if(value.PD_INQTY == 0 && $scope.order.product[key+1]){
  339. if($scope.order.product[key+1].PD_INQTY != 0){
  340. $scope.changeSelection($scope.order.product[key+1]);
  341. keepGoing = false ;
  342. }
  343. }else if(value.PD_INQTY != 0) {
  344. $scope.changeSelection($scope.order.product[key]);
  345. keepGoing = false;
  346. }
  347. }
  348. });
  349. $scope.tableParams = new ngTableParams({//未完成料号名称规格及剩余数量表格
  350. page: 1,
  351. count: 10,
  352. filter: {
  353. },
  354. sorting: {
  355. }
  356. }, {
  357. total: $scope.order.product.length,
  358. getData: function ($defer, params) {
  359. var filteredData = params.filter() ?
  360. $filter('filter')($scope.order.product, params.filter()) :
  361. data;
  362. var orderedData = params.sorting() ?
  363. $filter('orderBy')(filteredData, params.orderBy()) :
  364. data;
  365. params.total(orderedData.length); // set total for recalc pagination
  366. $defer.resolve(orderedData.slice((params.page() - 1) * params.count(), params.page() * params.count()));
  367. }
  368. });
  369. }
  370. //进入界面,表单值默认为grid中的第一行
  371. var check = function (productCode){
  372. //校验:1、物料编号存在, 2、数量不超过剩余数量,3、条码号唯一性
  373. //条码储位不允许为空
  374. var reg = /^[0-9]*[1-9][0-9]*$/; 
  375. if(!$scope.bi_barcode){
  376. //alert("请输入条码!");
  377. document.getElementById("bi_barcode").focus();
  378. return ;
  379. }/*else if(!$scope.bi_location){
  380. //alert("请输入储位!");
  381. document.getElementById("bi_location").focus();
  382. return ;
  383. }*/else if(!reg.test($scope.bi_inqty)){
  384. Ring.error();
  385. alert("数量格式不正确!");
  386. document.getElementById("bi_inqty").focus();
  387. return ;
  388. }
  389. var item = SupportUtil.contains(JSON.stringify($scope.order.product),productCode,"PD_PRODCODE");
  390. if(item){
  391. //是否条码校验
  392. if($scope.ifbarcodecheck == '1'){
  393. var pr_idlen =$scope.order.barcodeset.BS_LENPRID;
  394. //比较物料ID的前几位是否等于条码号的前几位
  395. var pr_id = new String($scope.pr_id);
  396. var bar_code = new String($scope.bi_barcode);
  397. if (SupportUtil.lapAft(pr_id,pr_idlen) != SupportUtil.lapFor(bar_code,pr_idlen)){
  398. Ring.error();
  399. $scope.bi_barcode ='';
  400. toaster.pop('error',"条码校验错误,该条码与物料不匹配");
  401. return false;
  402. }
  403. }
  404. 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 ){
  405. if($rootScope.grid){
  406. if(!(SupportUtil.contains(JSON.stringify($rootScope.grid) ,$scope.bi_barcode,"bi_barcode"))){
  407. return true;
  408. }else{
  409. Ring.error();
  410. toaster.pop('error', '条码号重复');
  411. $scope.bi_barcode ='';
  412. document.getElementById("bi_barcode").focus();
  413. return false;
  414. }
  415. }else{
  416. return true;
  417. }
  418. }else {
  419. Ring.error();
  420. $scope.bi_inqty = '';
  421. document.getElementById("bi_inqty").focus();
  422. alert("数量不能大于剩余数量或者为空");
  423. return false;
  424. }
  425. }else {
  426. alert("物料不存在");
  427. Ring.error();
  428. return false;
  429. }
  430. }
  431. $scope.message = {};
  432. $scope.scan = function(){//确认按钮事件
  433. if(check($scope.bi_prodcode)){
  434. $scope.barcodes = {};
  435. $scope.barcodes.bi_barcode = $scope.bi_barcode;
  436. $scope.barcodes.bi_prodcode = $scope.bi_prodcode ;
  437. $scope.barcodes.bi_prodid = $scope.bi_prodid ;
  438. $scope.barcodes.bi_inoutno = $scope.bi_inoutno;
  439. $scope.barcodes.bi_inqty = $scope.bi_inqty;
  440. $scope.barcodes.bi_location = $scope.bi_location;
  441. $scope.barcodes.bi_whcode = $scope.order.PI_WHCODE;
  442. $scope.barcodes.bi_prodname = $scope.bi_prodname;
  443. $scope.barcodes.bi_pdno = $scope.detno;
  444. $scope.barcodes.bi_pdid = $scope.pd_id;
  445. $scope.barcodes.bi_piid = $scope.order.PI_ID;
  446. //插入数据到待提交缓存列表中grid(barcode,prodcode,inqty,location)
  447. $scope.grid.push($scope.barcodes);
  448. $rootScope.grid = $scope.grid;
  449. $scope.pr_fbzs -= $scope.barcodes.bi_inqty;
  450. $scope.bi_barcode ='';
  451. document.getElementById("bi_barcode").focus();
  452. Ring.success();
  453. angular.forEach($scope.order.product, function(value, key){
  454. if(value.PD_ID == $scope.pd_id) {
  455. value.PD_INQTY = $scope.pr_fbzs ;
  456. $scope.tableParams.reload();
  457. if(value.PD_INQTY == 0 && $scope.order.product[key+1] ){
  458. $scope.changeSelection($scope.order.product[key+1]);
  459. }
  460. }
  461. });
  462. var keepGoing = true;
  463. angular.forEach($scope.order.product, function(value, key){
  464. if(keepGoing){
  465. if(value.PD_INQTY != 0 ){
  466. keepGoing = false ;
  467. }
  468. }
  469. });
  470. if(keepGoing){
  471. if(confirm("已完成,请提交采集")){
  472. $location.path('inMMWaitSubmit/' + $scope.order.PI_INOUTNO);
  473. }
  474. }
  475. }
  476. };
  477. $scope.enter = function (event){
  478. SupportUtil.nextFocus(event);
  479. };
  480. $scope.submitGet = function(){//提交采集操作,与后台交互
  481. if($scope.grid.length != 0){
  482. PurcOrderItem.saveBarcode({}, JSON.stringify($scope.grid),function(data) {//获取成功
  483. if(data.exceptionInfo){
  484. toaster.pop('error', '提交失败',data.exceptionInfo);
  485. Ring.error();
  486. }else{
  487. $rootScope.grid = $scope.grid ='';
  488. Ring.success();
  489. toaster.pop('success', '提交成功');
  490. }
  491. }, function(response){//获取失败处理
  492. if(response.status == 0){ //无网络错误
  493. Online.setOnline(false);//修改网络状态
  494. Ring.error();
  495. toaster.pop('error', '提交失败',"网络连接不可用,请稍后再试");
  496. }else {
  497. Ring.error();
  498. toaster.pop('error', '提交失败',response.data.exceptionInfo);
  499. }
  500. });
  501. }else {
  502. Ring.error();
  503. toaster.pop('error', '无数据');
  504. }
  505. };
  506. $scope.getList = function(argOrder){//点击
  507. if(argOrder){
  508. $location.path('inMMWaitSubmit/' + argOrder);
  509. }
  510. };
  511. $scope.returnInput = function(){//当前单据有未提交的,提示先提交。
  512. if($scope.grid.length != 0){
  513. if(confirm("返回将清空未提交数据,确认返回?")){
  514. angular.forEach($scope.order.product, function(value, key){
  515. for (var gs in $scope.grid){
  516. if (value.PD_ID == $scope.grid[gs].bi_pdid) {
  517. value.PD_INQTY = eval($scope.grid[gs].bi_inqty+"+"+value.PD_INQTY);
  518. }
  519. }
  520. });
  521. $rootScope.grid = $scope.grid ='';
  522. $location.path('inMakeMaterial');
  523. }
  524. }else{
  525. var status = '101';
  526. angular.forEach($scope.order.product, function(value, key){
  527. if(value.PD_INQTY !=0) {
  528. status = '102'
  529. }
  530. });
  531. if(status == '101'){//修改采集状态
  532. $scope.order.ENAUDITSTATUS='101';
  533. }
  534. $location.path('inMakeMaterial');
  535. }
  536. }
  537. $scope.findProdcode = function (){
  538. var modalInstance = $modal.open({
  539. templateUrl: 'prodModalContent.html',
  540. controller: 'ProdModalInstanceCtrl',
  541. resolve: {
  542. items: function () {
  543. return $scope.order.product;
  544. }
  545. }
  546. });
  547. modalInstance.result.then(function(selectedItem) {
  548. $scope.changeSelection(selectedItem);
  549. }, function() {
  550. /*$log.info('Modal dismissed at: ' + new Date());*/
  551. });
  552. }
  553. }]);
  554. app.controller('ProdModalInstanceCtrl',['$scope', '$modalInstance', 'items',function($scope, $modalInstance, items) {
  555. $scope.items = items;
  556. $scope.wh = {};
  557. $scope.selectPrCode = function(selectValue) {
  558. $modalInstance.close(selectValue);
  559. };
  560. $scope.cancel = function() {
  561. $modalInstance.dismiss('cancel');
  562. };
  563. }]);
  564. app.controller('InMMwaitSubmitCtrl',['$scope','$rootScope','$stateParams','$filter', 'ngTableParams','Online','PurcOrderItem','toaster','Ring', function($scope, $rootScope,$stateParams,$filter, ngTableParams,Online,PurcOrderItem,toaster,Ring){
  565. $scope.grid = $rootScope.grid;
  566. var getOrder = function(code) {//根据路径中的id号获取对应的单据
  567. var result = null;
  568. angular.forEach($rootScope.orders, function(value, key){
  569. if(value.PI_INOUTNO == code) {
  570. result = value;
  571. return result;
  572. }
  573. });
  574. return result;
  575. };
  576. $scope.order = getOrder($stateParams.ioNocode);
  577. if($scope.grid){
  578. $scope.tableParams = new ngTableParams({//未完成料号名称规格及剩余数量表格
  579. page: 1,
  580. count: 10,
  581. filter: {
  582. },
  583. sorting: {
  584. }
  585. }, {
  586. total: $scope.grid.length,
  587. getData: function ($defer, params) {
  588. var filteredData = params.filter() ?
  589. $filter('filter')($scope.grid, params.filter()) :
  590. data;
  591. var orderedData = params.sorting() ?
  592. $filter('orderBy')(filteredData, params.orderBy()) :
  593. data;
  594. params.total(orderedData.length); // set total for recalc pagination
  595. $defer.resolve(orderedData.slice((params.page() - 1) * params.count(), params.page() * params.count()));
  596. }
  597. });
  598. }
  599. $scope.deleteAll = function (){//全部删除
  600. if(confirm("确定删除全部?")){
  601. angular.forEach($rootScope.orders, function(value, key) {//反写剩余数
  602. if (value.PI_INOUTNO == $scope.order.PI_INOUTNO) {
  603. for (var n in value.product) {
  604. for (var gs in $scope.grid){
  605. if (value.product[n].PD_ID == $scope.grid[gs].bi_pdid) {
  606. value.product[n].PD_INQTY = eval($scope.grid[gs].bi_inqty+"+"+value.product[n].PD_INQTY);
  607. }
  608. }
  609. }
  610. }
  611. });
  612. $rootScope.grid = $scope.grid ='';
  613. $scope.tableParams.reload();
  614. toaster.pop('success', '删除成功');
  615. }
  616. }
  617. $scope.deleteWaitSubmitItem = function (s){
  618. angular.forEach($rootScope.orders, function(value, key) {
  619. if (value.PI_INOUTNO == $scope.order.PI_INOUTNO) {
  620. for (var n in value.product) {
  621. if (value.product[n].PD_ID == s.bi_pdid) {
  622. value.product[n].PD_INQTY = eval(s.bi_inqty+"+"+value.product[n].PD_INQTY);
  623. }
  624. }
  625. }
  626. });
  627. for (var n in $scope.grid){
  628. if($scope.grid[n].bi_barcode == s.bi_barcode){
  629. $scope.grid.splice(n,1);
  630. }
  631. }
  632. $rootScope.grid = $scope.grid;
  633. $scope.tableParams.reload();
  634. };
  635. $scope.submitGet = function(){//提交采集操作,与后台交互
  636. if($scope.grid.length !=0){
  637. PurcOrderItem.saveBarcode({}, JSON.stringify($scope.grid),function(data) {//获取成功
  638. if(data.exceptionInfo){
  639. toaster.pop('error', '提交失败',data.exceptionInfo);
  640. Ring.error();
  641. }else{
  642. $rootScope.grid = $scope.grid ='';
  643. Ring.success();
  644. toaster.pop('success', '提交成功');
  645. }
  646. }, function(response){//获取失败处理
  647. if(response.status == 0){ //无网络错误
  648. Online.setOnline(false);//修改网络状态
  649. Ring.error();
  650. toaster.pop('error', '提交失败',"网络连接不可用,请稍后再试");
  651. }
  652. else {
  653. Ring.error();
  654. toaster.pop('error', '提交失败',response.data.exceptionInfo);
  655. }
  656. });
  657. }else{
  658. Ring.error();
  659. toaster.pop('error', '无数据');
  660. }
  661. };
  662. }]);
  663. 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){
  664. $scope.grid = $rootScope.fisgrid||[];
  665. $scope.getOnline = Online.getOnline;
  666. setTimeout( function(){
  667. try{
  668. document.getElementById("bi_barcode").focus();
  669. } catch(e){}
  670. }, 200);
  671. var getOrder = function(code) {//根据路径中的id号获取对应的单据
  672. var result = null;
  673. angular.forEach($rootScope.fisOrders, function(value, key){
  674. if(value.PI_INOUTNO == code) {
  675. result = value;
  676. return result;
  677. }
  678. });
  679. return result;
  680. };
  681. $scope.changeSelection = function(item) {//table with row selection,表格选中列操作
  682. document.getElementById("bi_barcode").focus();
  683. $scope.ordercode = item.PD_ORDERCODE;
  684. $scope.bi_prodcode = item.PD_PRODCODE;
  685. $scope.bi_prodid = item.PR_ID;
  686. $scope.bi_prodspec = item.PD_PRODCODE+item.PR_DETAIL;
  687. $scope.bi_inoutno = $scope.order.PI_INOUTNO;
  688. $scope.bi_inqty = item.PR_ZXBZS|| $scope.bi_inqty;
  689. $scope.pr_fbzs = item.PD_INQTY;
  690. $scope.bi_location =item.PR_LOCATION;
  691. $scope.bi_prodname = item.PR_DETAIL;
  692. $scope.detno = item.PD_PDNO;
  693. $scope.pd_id = item.PD_ID;
  694. $scope.pr_id = item.PR_ID;
  695. }
  696. $scope.order = getOrder($stateParams.code);
  697. $rootScope.title = {};
  698. $rootScope.title.pi_inoutno = $scope.order.PI_INOUTNO +' '+$scope.order.PI_WHCODE;
  699. if($scope.order){
  700. $scope.tableParams = new ngTableParams({//已经采集完成的列表
  701. page: 1,
  702. count: 10,
  703. filter: {
  704. },
  705. sorting: {
  706. }
  707. }, {
  708. total: $scope.order.product.length,
  709. getData: function ($defer, params) {
  710. var filteredData = params.filter() ?
  711. $filter('filter')($scope.order.product, params.filter()) :
  712. data;
  713. var orderedData = params.sorting() ?
  714. $filter('orderBy')(filteredData, params.orderBy()) :
  715. data;
  716. params.total(orderedData.length); // set total for recalc pagination
  717. $defer.resolve(orderedData.slice((params.page() - 1) * params.count(), params.page() * params.count()));
  718. }
  719. });
  720. var keepGoing = true;
  721. angular.forEach($scope.order.product, function(value, key){
  722. if( keepGoing ){
  723. if(value.PD_INQTY == 0 && $scope.order.product[key+1].PD_INQTY != 0){
  724. $scope.changeSelection($scope.order.product[key+1]);
  725. keepGoing = false ;
  726. }else {
  727. $scope.changeSelection($scope.order.product[key]);
  728. keepGoing = false;
  729. }
  730. }
  731. });
  732. };
  733. var checkOutbox = function(defer){
  734. //包装箱号,则根据包装表packageDetail获取所有序列号和总数,
  735. //如果外包装不止一层可能存在递归,如果总数不超过剩余数则执行插入到grid。
  736. PurcOrderItem.getPackageCode({pr_fqty:$scope.pr_fbzs,pa_outboxcode:$scope.bi_outboxcode}, {},function(data){
  737. if(data.exceptionInfo){
  738. defer.reject(data.exceptionInfo);
  739. }else{
  740. defer.resolve(data.message);
  741. }
  742. },function(response){
  743. document.getElementById("bi_outboxcode").focus();
  744. Ring.error();
  745. defer.reject(response.data.exceptionInfo);
  746. });
  747. };
  748. var checkMakeSerial = function (defer){
  749. //如果有设定的归属工单,必须序列号归属于选定的工单(关联MakeSerial表判断),
  750. //5、如果该序列号已经存在库存(barcode表remain>0 ),不允许重复入库。
  751. if($scope.makeSerial){
  752. PurcOrderItem.checkMakeSerial({ms_sncode:$scope.bi_barcode,makeCode:$scope.makeSerial,whcode:$scope.order.PI_WHCODE}, {},function(data){
  753. if(data.exceptionInfo){
  754. defer.reject(data.exceptionInfo);
  755. }else
  756. defer.resolve(data.message);
  757. },function(response){
  758. document.getElementById("makeSerial").focus();
  759. Ring.error();
  760. defer.reject(response.data.exceptionInfo);
  761. });
  762. }else{
  763. defer.resolve('');
  764. }
  765. }
  766. var check = function (){
  767. //校验:1、物料编号存在, 2、数量不超过剩余数量,3、条码号唯一性
  768. //条码储位不允许为空
  769. var defer = $q.defer();
  770. var reg = /^[0-9]*[1-9][0-9]*$/; 
  771. if(!$scope.bi_barcode && !$scope.bi_outboxcode){
  772. document.getElementById("bi_barcode").focus();
  773. Ring.error();
  774. defer.reject("请输入序列号或者包装箱号!");
  775. }else if(!$scope.bi_location){
  776. document.getElementById("bi_location").focus();
  777. Ring.error();
  778. defer.reject("请输入储位!");
  779. }else if(!reg.test($scope.bi_inqty)){
  780. document.getElementById("bi_inqty").focus();
  781. Ring.error();
  782. defer.reject("数量格式不正确!");
  783. }else{
  784. var item = SupportUtil.contains(JSON.stringify($scope.order.product),$scope.bi_prodcode,"PD_PRODCODE");
  785. if(item){
  786. /*//是否条码校验
  787. if($scope.ifbarcodecheck == '1'){
  788. var pr_idlen =$scope.order.barcodeset.BS_LENPRID;
  789. //比较物料ID的前几位是否等于条码号的前几位
  790. var pr_id = new String($scope.pr_id);
  791. var bar_code = new String($scope.bi_barcode);
  792. if (SupportUtil.lap(pr_id,pr_idlen) != SupportUtil.lap(bar_code,pr_idlen)){
  793. Ring.error();
  794. $scope.bi_barcode ='';
  795. defer.reject("条码校验错误,该条码与物料不匹配")
  796. }
  797. } */
  798. 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 ){
  799. if($scope.bi_barcode){
  800. if($rootScope.fisgrid && SupportUtil.contains(JSON.stringify($rootScope.fisgrid) ,$scope.bi_barcode,"bi_barcode")){
  801. document.getElementById("bi_barcode").focus();
  802. Ring.error();
  803. defer.reject("序列号重复");
  804. }else
  805. checkMakeSerial(defer);
  806. }else{
  807. if($rootScope.fisgrid && $scope.bi_outboxcode && SupportUtil.contains(JSON.stringify($rootScope.fisgrid) ,$scope.bi_outboxcode,"bi_outboxcode")){
  808. Ring.error();
  809. defer.reject("包装箱号重复");
  810. }else{
  811. checkOutbox(defer);
  812. }
  813. }
  814. }else {
  815. Ring.error();
  816. defer.reject("数量不能大于剩余数量或者为空");
  817. }
  818. }else {
  819. defer.reject("物料不存在");
  820. Ring.error();
  821. }
  822. }
  823. return defer.promise;
  824. };
  825. $scope.scan = function(){//确认按钮事件
  826. var q = check();
  827. q.then(function(message){
  828. $scope.barcodes = {};
  829. $scope.barcodes.bi_barcode = $scope.bi_barcode;
  830. $scope.barcodes.bi_prodcode = $scope.bi_prodcode ;
  831. $scope.barcodes.bi_prodid = $scope.bi_prodid ;
  832. $scope.barcodes.bi_inoutno = $scope.bi_inoutno;
  833. $scope.barcodes.bi_inqty = $scope.bi_inqty;
  834. $scope.barcodes.bi_location = $scope.bi_location;
  835. $scope.barcodes.bi_whcode = $scope.order.PI_WHCODE;
  836. $scope.barcodes.bi_outboxcode = $scope.bi_outboxcode ;
  837. $scope.barcodes.bi_prodname = $scope.bi_prodname;
  838. $scope.barcodes.bi_pdno = $scope.detno;
  839. $scope.barcodes.bi_pdid = $scope.pd_id;
  840. $scope.barcodes.bi_piid = $scope.order.PI_ID;
  841. //插入数据到待提交缓存列表中grid(barcode,prodcode,inqty,location)
  842. $scope.grid.push($scope.barcodes);
  843. $rootScope.fisgrid = $scope.grid;
  844. $scope.pr_fbzs -= $scope.barcodes.bi_inqty;
  845. $scope.bi_barcode ='';
  846. Ring.success();
  847. angular.forEach($scope.order.product, function(value, key){
  848. if(value.PD_ID == $scope.pd_id) {
  849. value.PD_INQTY = $scope.pr_fbzs ;
  850. $scope.tableParams.reload();
  851. if(value.PD_INQTY == 0 && $scope.order.product[key+1] ){
  852. $scope.changeSelection($scope.order.product[key+1]);
  853. }
  854. }
  855. });
  856. var keepGoing = true;
  857. angular.forEach($scope.order.product, function(value, key){
  858. if(keepGoing){
  859. if(value.PD_INQTY != 0 ){
  860. keepGoing = false ;
  861. }
  862. }
  863. });
  864. if(keepGoing){
  865. if(confirm("已完成,请提交采集")){
  866. $location.path('inFinishWaitSubmit/' + $scope.order.PI_INOUTNO);
  867. }
  868. }
  869. }, function(error){
  870. Ring.error();
  871. toaster.pop('error', '错误',error);
  872. });
  873. };
  874. $scope.enter = function (event){
  875. SupportUtil.nextFocus(event);
  876. };
  877. $scope.submitGet = function(){//提交采集操作,与后台交互
  878. if($scope.grid.length >0){
  879. PurcOrderItem.saveBarcode({},JSON.stringify($scope.grid),function(data) {//获取成功
  880. if(data.exceptionInfo){
  881. toaster.pop('error', '提交失败',data.exceptionInfo);
  882. Ring.error();
  883. }else if(data.message){
  884. Ring.error();
  885. toaster.pop('error', '提交失败',data.message);
  886. }else{
  887. Ring.success();
  888. toaster.pop('success', '提交成功');
  889. $rootScope.fisgrid = $scope.grid ='';
  890. }
  891. }, function(response){//获取失败处理
  892. if(response.status == 0){ //无网络错误
  893. Online.setOnline(false);//修改网络状态
  894. Ring.error();
  895. toaster.pop('error', '提交失败',"网络连接不可用,请稍后再试");
  896. }else {
  897. Ring.error();
  898. toaster.pop('error', '提交失败',response.data.exceptionInfo);
  899. }
  900. });
  901. }else{
  902. Ring.error();
  903. toaster.pop('error', '没有需要提交的数据');
  904. }
  905. };
  906. $scope.getList = function(argOrder){//点击
  907. if(argOrder){
  908. $location.path('inFinishWaitSubmit/' + argOrder);
  909. }
  910. };
  911. $scope.returnInput = function(){//当前单据有未提交的,提示先提交。
  912. if($scope.grid.length != 0){
  913. if(confirm("返回将清空未提交数据,确认返回?")){
  914. angular.forEach($scope.order.product, function(value, key){
  915. for (var gs in $scope.grid){
  916. if (value.PD_ID == $scope.grid[gs].bi_pdid) {
  917. value.PD_INQTY = eval($scope.grid[gs].bi_inqty+"+"+value.PD_INQTY);
  918. }
  919. }
  920. });
  921. $rootScope.fisgrid = $scope.grid ='';
  922. $location.path('inFinish');
  923. }
  924. }else{
  925. var status = '101';
  926. angular.forEach($scope.order.product, function(value, key){
  927. if(value.PD_INQTY !=0) {
  928. status = '102'
  929. }
  930. });
  931. if(status == '101'){//修改采集状态
  932. $scope.order.ENAUDITSTATUS='101';
  933. }
  934. $location.path('inFinish');
  935. }
  936. }
  937. $scope.findProdcode = function (){
  938. var modalInstance = $modal.open({
  939. templateUrl: 'prodModalContent.html',
  940. controller: 'ProdModalInstanceCtrl',
  941. resolve: {
  942. items: function () {
  943. return $scope.order.product;
  944. }
  945. }
  946. });
  947. modalInstance.result.then(function(selectedItem) {
  948. $scope.changeSelection(selectedItem);
  949. });
  950. }
  951. }]);
  952. app.controller('InfinishWaitSubmitCtrl',['$scope', '$rootScope','$stateParams','$filter', 'ngTableParams','Online','PurcOrderItem','toaster','Ring', function($scope, $rootScope,$stateParams,$filter, ngTableParams,Online,PurcOrderItem,toaster,Ring){
  953. $scope.grid = $rootScope.fisgrid||[];
  954. var getOrder = function(code) {//根据路径中的id号获取对应的单据
  955. var result = null;
  956. angular.forEach($rootScope.fisOrders, function(value, key){
  957. if(value.PI_INOUTNO == code) {
  958. result = value;
  959. return result;
  960. }
  961. });
  962. return result;
  963. };
  964. $scope.order = getOrder($stateParams.ioNocode);
  965. if($scope.grid){
  966. $scope.tableParams = new ngTableParams({//未完成料号名称规格及剩余数量表格
  967. page: 1,
  968. count: 10,
  969. filter: { },
  970. sorting: { }
  971. }, {
  972. total: $scope.grid.length,
  973. getData: function ($defer, params) {
  974. var filteredData = params.filter() ?
  975. $filter('filter')($scope.grid, params.filter()) :
  976. data;
  977. var orderedData = params.sorting() ?
  978. $filter('orderBy')(filteredData, params.orderBy()) :
  979. data;
  980. params.total(orderedData.length); // set total for recalc pagination
  981. $defer.resolve(orderedData.slice((params.page() - 1) * params.count(), params.page() * params.count()));
  982. }
  983. });
  984. };
  985. $scope.deleteAll = function (){//全部删除
  986. if(confirm("确定删除全部?")){
  987. angular.forEach($rootScope.fisOrders, function(value, key) {//反写剩余数
  988. if (value.PI_INOUTNO == $scope.order.PI_INOUTNO) {
  989. for (var n in value.product) {
  990. for (var gs in $scope.grid){
  991. if (value.product[n].PD_ID == $scope.grid[gs].bi_pdid) {
  992. value.product[n].PD_INQTY = eval($scope.grid[gs].bi_inqty+"+"+value.product[n].PD_INQTY);
  993. }
  994. }
  995. }
  996. }
  997. });
  998. $rootScope.fisgrid = $scope.grid ='';
  999. $scope.tableParams.reload();
  1000. toaster.pop('success', '删除成功');
  1001. }
  1002. };
  1003. $scope.deleteWaitSubmitItem = function (s){
  1004. angular.forEach($rootScope.fisOrders, function(value, key) {
  1005. if (value.PI_INOUTNO == $scope.order.PI_INOUTNO) {
  1006. for (var n in value.product) {
  1007. if (value.product[n].PD_ID == s.bi_pdid) {
  1008. value.product[n].PD_INQTY = eval(s.bi_inqty+"+"+value.product[n].PD_INQTY);
  1009. }
  1010. }
  1011. }
  1012. });
  1013. for (var n in $scope.grid){
  1014. if($scope.grid[n].bi_barcode == s.bi_barcode){
  1015. $scope.grid.splice(n,1);
  1016. }
  1017. }
  1018. $rootScope.fisgrid = $scope.grid;
  1019. $scope.tableParams.reload();
  1020. };
  1021. $scope.submitGet = function(){//提交采集操作,与后台交互
  1022. PurcOrderItem.saveBarcode({}, JSON.stringify($scope.grid),function(data) {//获取成功
  1023. if(data.exceptionInfo){
  1024. toaster.pop('error', '提交失败',data.exceptionInfo);
  1025. Ring.error();
  1026. }else{
  1027. Ring.success();
  1028. toaster.pop('success', '提交成功');
  1029. }
  1030. }, function(response){//获取失败处理
  1031. if(response.status == 0){ //无网络错误
  1032. Online.setOnline(false);//修改网络状态
  1033. Ring.error();
  1034. toaster.pop('error', '提交失败',"网络连接不可用,请稍后再试");
  1035. }
  1036. else {
  1037. Ring.error();
  1038. toaster.pop('error', '提交失败',response.data.exceptionInfo);
  1039. }
  1040. });
  1041. };
  1042. }]);
  1043. 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){
  1044. $scope.stocking = $rootScope.stocking||'';
  1045. $scope.st_whcode = SessionService.getCookie('defaultWhcode');
  1046. $scope.find = function(event,st_code){
  1047. if(event.keyCode === 13){
  1048. $scope.search(st_code);
  1049. }
  1050. }
  1051. $scope.search = function(st_code){
  1052. if(st_code){
  1053. CountingOper.get({st_code:st_code},function(data){
  1054. if(data.exceptionInfo){
  1055. toaster.pop('error', '查询失败',data.exceptionInfo);
  1056. Ring.error();
  1057. }else if(data.target && data.totalCount > 0){
  1058. var or = new Object();
  1059. or = data.target;
  1060. $scope.stocking = data.target[0];
  1061. $rootScope.stocking = $scope.stocking;
  1062. $scope.st_whcode = $scope.stocking.ST_WHCODE;
  1063. }
  1064. },function(response){
  1065. if(response.status == 0){ //无网络错误
  1066. Online.setOnline(false);//修改网络状态
  1067. Ring.error();
  1068. toaster.pop('error', "网络连接不可用,请稍后再试");
  1069. }else{
  1070. toaster.pop('error', '查询失败',response.data.exceptionInfo);
  1071. Ring.error();
  1072. }
  1073. });
  1074. }else{
  1075. alert("请输入盘点底稿编号!");
  1076. document.getElementById("st_code").focus()
  1077. }
  1078. }
  1079. $scope.confirm = function(){
  1080. if($scope.Counting == 'makeMaterial'){
  1081. $location.path("countingMM");
  1082. }else{
  1083. $location.path("countingFinish");
  1084. }
  1085. }
  1086. }]);
  1087. 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){
  1088. $scope.stocking = $rootScope.stocking||'';
  1089. $scope.grid = $rootScope.cmGrid||[];
  1090. var check = function(){//条码号不为空;2、数量大于0;3、条码不存在于已采集列表
  1091. if(!$scope.barcodes.stb_barcode){
  1092. document.getElementById("bi_barcode").focus();
  1093. Ring.error();
  1094. alert("条码号不为空");
  1095. return false;
  1096. }else if(SupportUtil.contains(JSON.stringify($scope.grid),$scope.barcodes.stb_barcode,"stb_barcode")){
  1097. alert("条码编号重复!");
  1098. Ring.error();
  1099. document.getElementById("bi_barcode").focus();
  1100. document.getElementById("bi_barcode").select();
  1101. return false;
  1102. }else if($scope.barcodes.stb_qty <=0){
  1103. alert ("数量必须大于0");
  1104. Ring.error();
  1105. return false;
  1106. }else {
  1107. return true;
  1108. }
  1109. }
  1110. $scope.barcodes = {};
  1111. $scope.search = function($event,bi_barcode){
  1112. if($event.keyCode == 13) {//Enter事件
  1113. if(check()){
  1114. CountingOper.getBarData({bar_code:bi_barcode,bar_whcode:$scope.stocking.ST_WHCODE,st_code:$scope.stocking.ST_CODE},{},function(data){
  1115. if(data.exceptionInfo){
  1116. toaster.pop('error', '条码号错误',data.exceptionInfo);
  1117. Ring.error();
  1118. }else {
  1119. $scope.barcodes.stb_barcode = data.data.BAR_CODE;
  1120. $scope.barcodes.stb_vendcode = data.data.BAR_VENDCODE;
  1121. $scope.barcodes.stb_prodcode = data.data.BAR_PRODCODE;
  1122. $scope.barcodes.stb_barid = data.data.BAR_ID;
  1123. $scope.barcodes.stb_qty = data.data.BAR_REMAIN;
  1124. $scope.barcodes.stb_stid = $scope.stocking.ST_ID;
  1125. $scope.barcodes.stb_stcode = $scope.stocking.ST_CODE;
  1126. $scope.barcodes.pr_detail = data.data.PR_DETAIL;
  1127. }
  1128. },function(response){
  1129. if(response.status == 0){ //无网络错误
  1130. Online.setOnline(false);//修改网络状态
  1131. Ring.error();
  1132. toaster.pop('error', "网络连接不可用,请稍后再试");
  1133. }else{
  1134. toaster.pop('error', '条码号错误',response.data.exceptionInfo);
  1135. Ring.error();
  1136. }
  1137. })
  1138. }
  1139. }
  1140. }
  1141. $scope.confirm = function(){
  1142. if(check()){
  1143. $scope.show = true;
  1144. $scope.grid.push($scope.barcodes);
  1145. $scope.shows = $scope.barcodes;
  1146. $scope.barcodes ='';
  1147. document.getElementById("bi_barcode").focus();
  1148. }
  1149. $rootScope.cmGrid = $scope.grid ;
  1150. };
  1151. $scope.returnCC = function (){
  1152. if($scope.grid.length>0){
  1153. if(confirm("返回,将删除已采集未提交的数据?")){
  1154. $scope.grid = $rootScope.cfGrid = '';
  1155. $location.path("countingContents");
  1156. }
  1157. }else{
  1158. $location.path("countingContents");
  1159. }
  1160. };
  1161. $scope.submitGet = function(){//提交盘点数据
  1162. if($scope.grid.length>0){
  1163. CountingOper.saveBarcode({},JSON.stringify($scope.grid),function(data){
  1164. if(data.exceptionInfo){
  1165. toaster.pop('error', '提交失败',data.exceptionInfo);
  1166. Ring.error();
  1167. }else {
  1168. $scope.grid = $rootScope.cmGrid = '';
  1169. toaster.pop('success', '提交成功');
  1170. Ring.success();
  1171. }
  1172. },function(response){
  1173. if(response.status == 0){ //无网络错误
  1174. Online.setOnline(false);//修改网络状态
  1175. Ring.error();
  1176. toaster.pop('error', '提交失败',"网络连接不可用,请稍后再试");
  1177. }else{
  1178. toaster.pop('error', '提交失败',response.data.exceptionInfo);
  1179. Ring.error();
  1180. }
  1181. });
  1182. }else{
  1183. Ring.error();
  1184. alert("没有需要提交的数据!");
  1185. }
  1186. }
  1187. if($scope.grid){
  1188. $scope.tableParams = new ngTableParams({//盘点料号名称规格及剩余数量表格【待提交的】
  1189. page: 1,
  1190. count: 10,
  1191. filter: { },
  1192. sorting: { }
  1193. }, {
  1194. total: $scope.grid.length,
  1195. getData: function ($defer, params) {
  1196. params.total($scope.grid.length); // set total for recalc pagination
  1197. $defer.resolve($scope.grid.slice((params.page() - 1) * params.count(), params.page() * params.count()));
  1198. }
  1199. });
  1200. };
  1201. $scope.deleteAll = function(){//全部删除
  1202. if(confirm("确定删除全部?")){
  1203. $scope.grid = $rootScope.cmGrid = '';
  1204. Ring.success();
  1205. toaster.pop('success', '删除成功');
  1206. $scope.tableParams.reload();
  1207. }
  1208. }
  1209. $scope.deleteWaitSubmitItem = function(s){//单行删除
  1210. for (var n in $scope.grid){
  1211. if($scope.grid[n].stb_barcode == s.stb_barcode){
  1212. $scope.grid.splice(n,1);
  1213. }
  1214. }
  1215. $rootScope.cmGrid = $scope.grid;
  1216. $scope.tableParams.reload();
  1217. };
  1218. }]);
  1219. 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){
  1220. $scope.stocking = $rootScope.stocking||'';
  1221. $scope.grid = $rootScope.cfGrid||[];
  1222. var checkSerialSearch = function(serial_code){
  1223. if(SupportUtil.contains(JSON.stringify($scope.grid),serial_code,"stb_barcode")){
  1224. Ring.error();
  1225. alert("序列号重复!");
  1226. document.getElementById("serial_code").focus().select();
  1227. return ;
  1228. }else{
  1229. CountingOper.serialSearch({code:serial_code,whcode:$scope.stocking.ST_WHCODE,st_code:$scope.stocking.ST_CODE},{},function(data){
  1230. if(data.exceptionInfo){
  1231. toaster.pop('error', '序列号不存在',data.exceptionInfo);
  1232. Ring.error();
  1233. }else {
  1234. $scope.serialMessage = data.message;
  1235. $scope.makeCode = $scope.serialMessage.MA_CODE;
  1236. $scope.prodcode = $scope.serialMessage.stb_prodcode;
  1237. }
  1238. },function(response){
  1239. if(response.status == 0){ //无网络错误
  1240. Online.setOnline(false);//修改网络状态
  1241. Ring.error();
  1242. toaster.pop('error', "网络连接不可用,请稍后再试");
  1243. }else{
  1244. Ring.error();
  1245. toaster.pop('error', '序列号不存在',response.data.exceptionInfo);
  1246. }
  1247. });
  1248. }
  1249. }
  1250. $scope.serialSearch = function ($event,serial_code){//序列号enter事件
  1251. if($event.keyCode == 13 && serial_code){
  1252. checkSerialSearch(serial_code);
  1253. }
  1254. };
  1255. var checkOutboxSearch = function (boxcode){
  1256. if(SupportUtil.contains(JSON.stringify($scope.grid),serial_code,"stb_barcode")){
  1257. alert("包装箱号重复");
  1258. Ring.error();
  1259. return ;
  1260. }else {
  1261. CountingOper.outboxSearch({code:boxcode,whcode:$scope.stocking.ST_WHCODE,st_code:$scope.stocking.ST_CODE},{},function(data){
  1262. if(data.exceptionInfo){
  1263. toaster.pop('error', '包装箱号不存在',data.exceptionInfo);
  1264. Ring.error();
  1265. }else{
  1266. $scope.outboxMessage = data.message;
  1267. $scope.totalqty = $scope.outboxMessage.stb_qty;
  1268. $scope.prodcode = $scope.outboxMessage.stb_prodcode;}
  1269. },function(response){
  1270. if(response.status == 0){ //无网络错误
  1271. Online.setOnline(false);//修改网络状态
  1272. Ring.error();
  1273. toaster.pop('error', "网络连接不可用,请稍后再试");
  1274. }
  1275. Ring.error();
  1276. toaster.pop('error', '包装箱号不存在',response.data.exceptionInfo);
  1277. });
  1278. }
  1279. };
  1280. $scope.outboxSearch = function($event,boxcode){//包装箱号enter事件
  1281. if($event.keyCode == 13 && boxcode){
  1282. checkOutboxSearch(boxcode);
  1283. }
  1284. }
  1285. $scope.confirm = function(){
  1286. if(!$scope.serial){
  1287. alert("请选择包装箱号或者序列号");
  1288. return ;
  1289. }else if($scope.serial == 'outbox' && !$scope.boxcode){
  1290. alert("请输入包装箱号");
  1291. return;
  1292. }else if($scope.serial == 'serial' && !$scope.serial_code){
  1293. alert("请输入序列号");
  1294. return ;
  1295. }else if($scope.serial == 'serial' && $scope.serial_code ){//选择序列号执行确认
  1296. checkSerialSearch($scope.serial_code);
  1297. $scope.serialMessage.stb_stcode = $scope.stocking.ST_CODE;
  1298. $scope.serialMessage.stb_stid = $scope.stocking.ST_ID;
  1299. $scope.grid.push($scope.serialMessage);
  1300. $scope.serial_code = $scope.makeCode ='';
  1301. document.getElementById("serial_code").focus();
  1302. Ring.success();
  1303. }else if($scope.serial == 'outbox' && $scope.boxcode ){
  1304. checkOutboxSearch($scope.boxcode);
  1305. $scope.outboxMessage.stb_stcode = $scope.stocking.ST_CODE;
  1306. $scope.outboxMessage.stb_stid = $scope.stocking.ST_ID;
  1307. $scope.grid.push($scope.outboxMessage);
  1308. $scope.boxcode = $scope.totalqty ='';
  1309. document.getElementById("boxcode").focus();
  1310. Ring.success();
  1311. }
  1312. $rootScope.cfGrid = $scope.grid;
  1313. $scope.shows= $scope.grid[$scope.grid.length-1];
  1314. };
  1315. $scope.returnCC = function (){
  1316. if($scope.grid.length>0){
  1317. if(confirm("返回,将删除已采集未提交的数据?")){
  1318. $scope.grid = $rootScope.cfGrid = '';
  1319. $location.path("countingContents");
  1320. }
  1321. }else
  1322. $location.path("countingContents");
  1323. }
  1324. $scope.submitGet = function(){
  1325. if($scope.grid.length>0){
  1326. CountingOper.saveBarcode({data:JSON.stringify($scope.grid)},{},function(data){
  1327. if(data.exceptionInfo){
  1328. toaster.pop('error', '提交失败',data.exceptionInfo);
  1329. Ring.error();
  1330. }else{
  1331. $scope.grid = $rootScope.cfGrid = '';
  1332. toaster.pop('success', '提交成功');
  1333. Ring.success();
  1334. }
  1335. },function(response){
  1336. toaster.pop('error', '提交失败',response.data.exceptionInfo);
  1337. Ring.error();
  1338. });
  1339. }else{
  1340. Ring.error();
  1341. alert("没有需要提交的数据!");
  1342. }
  1343. };
  1344. if($scope.grid){
  1345. $scope.tableParams = new ngTableParams({//盘点料号名称规格及剩余数量表格【待提交的】
  1346. page: 1,
  1347. count: 10,
  1348. filter: { },
  1349. sorting: { }
  1350. }, {
  1351. total: $scope.grid.length,
  1352. getData: function ($defer, params) {
  1353. params.total($scope.grid.length); // set total for recalc pagination
  1354. $defer.resolve($scope.grid.slice((params.page() - 1) * params.count(), params.page() * params.count()));
  1355. }
  1356. });
  1357. };
  1358. $scope.deleteWaitSubmitItem = function( s){
  1359. for (var n in $scope.grid){
  1360. if($scope.grid[n].stb_barcode == s.stb_barcode){
  1361. $scope.grid.splice(n,1);
  1362. }
  1363. }
  1364. $rootScope.cfGrid = $scope.grid;
  1365. $scope.tableParams.reload();
  1366. };
  1367. $scope.deleteAll = function(){
  1368. if(confirm("确定删除全部?")){
  1369. $scope.grid = $rootScope.cfGrid = '';
  1370. Ring.success();
  1371. toaster.pop('success', '删除成功');
  1372. $scope.tableParams.reload();
  1373. }
  1374. }
  1375. }]);
  1376. 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){
  1377. $scope.batchclick = function(choose){
  1378. $location.path(choose);
  1379. };
  1380. }]);
  1381. 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){
  1382. $scope.grid = [];
  1383. $scope.btnInvalid = true;
  1384. if($scope.grid){
  1385. $scope.tableParams = new ngTableParams({//批次合并
  1386. page: 1,
  1387. count: 10,
  1388. filter: { },
  1389. sorting: { }
  1390. }, {
  1391. total: $scope.grid.length,
  1392. getData: function ($defer, params) {
  1393. params.total($scope.grid.length); // set total for recalc pagination
  1394. $defer.resolve($scope.grid.slice((params.page() - 1) * params.count(), params.page() * params.count()));
  1395. }
  1396. });
  1397. };
  1398. $scope.search = function($event,barcode,type){//根据输入的条码编号查询相关信息
  1399. if($scope.grid.length >0 && type !='breaking'){//条码拆分不需要判断是否重复
  1400. if(SupportUtil.contains(JSON.stringify($scope.grid),barcode,"bar_code")){
  1401. Ring.error();
  1402. alert("条码重复!");
  1403. return ;
  1404. }
  1405. }
  1406. if($event.keyCode == 13){
  1407. BatchOper.get({code:barcode},function(data){
  1408. if(data.exceptionInfo){
  1409. toaster.pop('error',data.exceptionInfo);
  1410. Ring.error();
  1411. document.getElementById("or_barcode").focus();
  1412. }else{
  1413. $scope.barData = data.message;
  1414. $scope.grid.push($scope.barData);
  1415. $scope.tableParams.reload();
  1416. $scope.bar_prodcode = $scope.barData.bar_prodcode
  1417. $scope.pr_detail = $scope.barData.pr_detail;
  1418. $scope.barcode.or_remain = $scope.barData.bar_remain;
  1419. Ring.success();
  1420. }
  1421. },function(response){
  1422. if(response.status == 0){ //无网络错误
  1423. Online.setOnline(false);//修改网络状态
  1424. Ring.error();
  1425. toaster.pop('error', "网络连接不可用,请稍后再试");
  1426. }else{
  1427. Ring.error();
  1428. toaster.pop('error', response.data.exceptionInfo);
  1429. document.getElementById("or_barcode").focus();
  1430. }
  1431. });
  1432. }
  1433. };
  1434. $scope.confirm = function(barcode,type){
  1435. var event = new Object();
  1436. event.keyCode = 13;
  1437. $scope.search(event,barcode,type);
  1438. }
  1439. $scope.breaking = function(){//分拆
  1440. if($scope.btnInvalid){
  1441. //分拆之前判断定,拆分数量必须小于批数量大于0
  1442. $scope.btnInvalid = false;
  1443. if( $scope.barcode.bar_remain < 0 || $scope.barcode.bar_remain >= $scope.barcode.or_remain || $scope.barcode.bar_remain == 0 || $scope.barcode.bar_remain =='0'){
  1444. Ring.error();
  1445. toaster.pop('error', '拆分数量必须在大于0,小于批数量');
  1446. document.getElementById("bar_remain").focus();
  1447. $scope.btnInvalid = true;
  1448. return ;
  1449. }
  1450. BatchOper.breakingBatch({},angular.fromJson($scope.barcode),function(data){
  1451. $scope.btnInvalid = true;
  1452. if(data.exceptionInfo){
  1453. toaster.pop('error', '拆分失败',data.exceptionInfo);
  1454. Ring.error();
  1455. }else{
  1456. Ring.success();
  1457. toaster.pop('success', '分拆成功');
  1458. modal(data.message);
  1459. }
  1460. },function(response){
  1461. $scope.btnInvalid = true;
  1462. if(response.status == 0){ //无网络错误
  1463. Online.setOnline(false);//修改网络状态
  1464. Ring.error();
  1465. toaster.pop('error', "网络连接不可用,请稍后再试");
  1466. }else{
  1467. Ring.error();
  1468. toaster.pop('error',"拆分失败",response.data.exceptionInfo);
  1469. }
  1470. });
  1471. }
  1472. },
  1473. $scope.GetTotalRemain = function () {
  1474. var sum = 0;
  1475. for (var i = 0; i < $scope.grid.length; i++) {
  1476. sum += parseFloat($scope.grid[i].bar_remain);
  1477. }
  1478. return sum;
  1479. }
  1480. $scope.combine = function(){//合并
  1481. //合并之前进行判断物料号一致、仓库一致、储位一致
  1482. if($scope.grid.length>1){
  1483. //有两条或者以上的数据才进行合并
  1484. BatchOper.combineBatch({total_remain:$scope.GetTotalRemain()},angular.fromJson($scope.grid),function(data){
  1485. if(data.exceptionInfo){
  1486. toaster.pop('error', '合并失败',data.exceptionInfo);
  1487. Ring.error();
  1488. }else{
  1489. modal(data.message);
  1490. Ring.success();
  1491. $scope.grid ='';//清空
  1492. toaster.pop('success', '合并成功');
  1493. }
  1494. },function(res){
  1495. if(response.status == 0){ //无网络错误
  1496. Online.setOnline(false);//修改网络状态
  1497. Ring.error();
  1498. toaster.pop('error', "网络连接不可用,请稍后再试");
  1499. }else{
  1500. Ring.error();
  1501. toaster.pop('error',"合并失败",response.data.exceptionInfo);
  1502. }
  1503. });
  1504. }
  1505. };
  1506. //
  1507. var modal= function(data){
  1508. var modalInstance = $modal.open({
  1509. templateUrl: 'myModalContent.html',
  1510. controller: 'ModalInstanceCtrl',
  1511. resolve: {
  1512. items: function () {
  1513. return data;
  1514. }
  1515. }
  1516. });
  1517. modalInstance.result.then(function(items) {
  1518. if(items != null){//继续分拆获取数据
  1519. $scope.confirm($scope.barcode.or_barcode,'breaking');
  1520. $scope.barcode.bar_remain='';
  1521. document.getElementById("bar_remain").focus();
  1522. }
  1523. },function() {
  1524. $scope.barcode = $scope.pr_detail = $scope.bar_prodcode = '';//清空
  1525. document.getElementById("or_barcode").focus();
  1526. });
  1527. };
  1528. }]);
  1529. 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){
  1530. $scope.grid = [];
  1531. $scope.barcode = {};
  1532. $scope.bar = {};
  1533. $scope.bar.new_qty = 0;
  1534. $scope.bar.new_packageqty = 0;
  1535. if($scope.grid){
  1536. $scope.tableParams = new ngTableParams({//批次合并
  1537. page: 1,
  1538. count: 10,
  1539. filter: { },
  1540. sorting: { }
  1541. }, {
  1542. total: $scope.grid.length,
  1543. getData: function ($defer, params) {
  1544. params.total($scope.grid.length); // set total for recalc pagination
  1545. $defer.resolve($scope.grid.slice((params.page() - 1) * params.count(), params.page() * params.count()));
  1546. }
  1547. });
  1548. };
  1549. $scope.search = function(){//根据外箱号,内箱号,或者序列号获取相关数据
  1550. if(!$scope.barcode.inner){
  1551. Ring.error();
  1552. alert("请选择拆分内箱号或者序列号!");
  1553. return ;
  1554. }
  1555. if($scope.barcode.inner == 'inner' && !$scope.barcode.innerBox){
  1556. Ring.error();
  1557. alert("请输入拆分内箱号!");
  1558. return ;
  1559. }else if($scope.barcode.inner == 'serial' && !$scope.barcode.innerSerial){
  1560. Ring.error();
  1561. alert("请输入拆分序列号!");
  1562. return ;
  1563. }
  1564. if($scope.grid.length > 0){
  1565. if($scope.barcode.or_outbox != $scope.grid[0].pa_outboxcode){
  1566. Ring.error();
  1567. alert("只能对同一外箱号进行拆分操作!");
  1568. return ;
  1569. }
  1570. if($scope.barcode.inner == 'serial' && $scope.barcode.innerSerial){
  1571. if(SupportUtil.contains(JSON.stringify($scope.grid),$scope.barcode.innerSerial,"pd_barcode")){
  1572. Ring.error();
  1573. alert("拆分序列号重复!");
  1574. return ;
  1575. }
  1576. }else if($scope.barcode.inner == 'inner' && $scope.barcode.innerBox){
  1577. if(SupportUtil.contains(JSON.stringify($scope.grid),$scope.barcode.innerBox,"pa_outboxcode")){
  1578. Ring.error();
  1579. alert("拆分箱号重复!");
  1580. return ;
  1581. }
  1582. }
  1583. }
  1584. BatchOper.searchPackageData({},angular.fromJson($scope.barcode),function(data){
  1585. if(data.exceptionInfo){
  1586. toaster.pop('error', data.exceptionInfo);
  1587. Ring.error();
  1588. }else{
  1589. $scope.grid.push(data.data);
  1590. $scope.bar.new_qty ++; //件数
  1591. $scope.bar.newOr_qty = data.data.pa_totalqty-$scope.bar.new_qty;//件数
  1592. $scope.packageqty = data.data.pd_innerqty;//箱内数量
  1593. $scope.bar.new_packageqty += $scope.packageqty; //新箱内总数
  1594. $scope.bar.newOr_packageqty = data.data.pa_packageqty-$scope.bar.new_packageqty;//原箱总数
  1595. $scope.tableParams.reload();
  1596. }
  1597. },function(response){
  1598. if(response.status == 0){ //无网络错误
  1599. Online.setOnline(false);//修改网络状态
  1600. Ring.error();
  1601. toaster.pop('error', "网络连接不可用,请稍后再试");
  1602. }else{
  1603. Ring.error();
  1604. toaster.pop('error',response.data.exceptionInfo);
  1605. }
  1606. });
  1607. };
  1608. $scope.breakingoutBox = function(){//确认拆分
  1609. BatchOper.breakingPackage({param:$scope.bar},angular.fromJson($scope.grid),function(data){
  1610. if(data.exceptionInfo){
  1611. toaster.pop('error', data.exceptionInfo);
  1612. Ring.error();
  1613. }else{
  1614. $scope.bar.new_qty = $scope.bar.new_packageqty = 0;
  1615. modal(data.message);
  1616. Ring.success();
  1617. }
  1618. toaster.pop('success',"拆分成功");
  1619. },function(response){
  1620. if(response.status == 0){ //无网络错误
  1621. Online.setOnline(false);//修改网络状态
  1622. Ring.error();
  1623. toaster.pop('error', "网络连接不可用,请稍后再试");
  1624. }else{
  1625. }
  1626. });
  1627. }
  1628. $scope.getoutbox1 = function (){//获取原始拆分 新箱号
  1629. BatchOper.getOutboxCode({pr_code:$scope.grid[0].pa_prodcode},{},function(data){
  1630. if(data.exceptionInfo){
  1631. toaster.pop('error', data.exceptionInfo);
  1632. Ring.error();
  1633. }else
  1634. $scope.bar.newOr_outbox = data.data;
  1635. },function(response){
  1636. if(response.status == 0){ //无网络错误
  1637. Online.setOnline(false);//修改网络状态
  1638. Ring.error();
  1639. toaster.pop('error', "网络连接不可用,请稍后再试");
  1640. }
  1641. });
  1642. };
  1643. $scope.getoutbox2 = function (){//获取拆分箱号
  1644. BatchOper.getOutboxCode({pr_code:$scope.grid[0].pa_prodcode},{},function(data){
  1645. if(data.exceptionInfo){
  1646. toaster.pop('error', data.exceptionInfo);
  1647. Ring.error();
  1648. }else
  1649. $scope.bar.new_outbox = data.data;
  1650. },function(response){
  1651. if(response.status == 0){ //无网络错误
  1652. Online.setOnline(false);//修改网络状态
  1653. Ring.error();
  1654. toaster.pop('error', "网络连接不可用,请稍后再试");
  1655. }
  1656. });
  1657. }
  1658. $scope.deleteB = function(item){//删除明细
  1659. angular.forEach($scope.grid, function(value,key){
  1660. if(item.pd_innerboxcode == value.pd_innerboxcode){
  1661. $scope.grid.splice(key,1);
  1662. }
  1663. });
  1664. };
  1665. var modal= function(data){
  1666. var modalInstance = $modal.open({
  1667. templateUrl: 'myModalContent.html',
  1668. controller: 'ModalInstanceCtrl',
  1669. resolve: {
  1670. items: function () {
  1671. return data;
  1672. }
  1673. }
  1674. });
  1675. };
  1676. }]);
  1677. app.controller('UploadCtrl', function($scope, $rootScope, PurcOrderItem, Online){
  1678. $scope.upLoadItems = [];
  1679. angular.forEach($rootScope.orders, function(value,key){//先去获取需要上传的Item(明细)
  1680. angular.forEach(value.orderItems, function(item, key){
  1681. if(item.replyCount) $scope.upLoadItems.push(item);
  1682. });
  1683. });
  1684. $scope.upload = function(){//一键上传操作
  1685. $scope.netError = false;
  1686. angular.forEach($scope.upLoadItems, function(item, key){
  1687. if(Online.getOnline()) {//判断是否有网
  1688. item.loading = 'fa fa-spinner fa-spin';//正在上传
  1689. //上传回复,replyCount作为回复数
  1690. PurcOrderItem.reply({orderItemId: item.id}, {delivery: new Date().getTime(), qty: item.replyCount, remark: '测试离线后上传'},
  1691. function(data){
  1692. item.loading = 'fa fa-check-square';//上传成功
  1693. item.uploadOk = true;
  1694. item.replyCount = 0;
  1695. }, function(response){//请求发生错误
  1696. item.loading = 'fa fa-exclamation-triangle text-danger';//上传失败
  1697. if(response.status == 0) {//无网络错误
  1698. Online.setOnline(false);//修改网络状态
  1699. $scope.netError = true;
  1700. } else {//其他错误
  1701. console.log(response.data);
  1702. }
  1703. });
  1704. } else {
  1705. $scope.netError = true;//断网提示
  1706. return;
  1707. }
  1708. });
  1709. };
  1710. });
  1711. return app;
  1712. });