app.js 33 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830
  1. define([ 'angularAMD','toaster', 'ngTable', 'common/services', 'service/Purc','service/SupportServices', 'ui.router', 'ui.bootstrap','directive/SmartDirectives','ngTouch'], function(angularAMD) {
  2. 'use strict';
  3. var app = angular.module('myApp', ['ngAnimate', 'toaster','ngTable', 'ui.router', 'common.services', 'PurcServices', 'SupportServices','ui.bootstrap','SmartDirectives','ngTouch']);
  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('inContents',angularAMD.route({
  13. url:'/inContents',
  14. templateUrl:'resources/tpl/input/inContents.html',
  15. controllerUrl : 'app/controllers/input/InputCtrl'
  16. })).state('inMakeMaterial', angularAMD.route({
  17. url : "/inMakeMaterial",
  18. templateUrl : "resources/tpl/input/inMakeMaterial.html",
  19. controllerUrl : 'app/controllers/input/InputCtrl'
  20. })).state('inMMOperation', angularAMD.route({
  21. url: '/inMMOperation/:code',
  22. templateUrl: 'resources/tpl/input/inMMOperation.html',
  23. controllerUrl : 'app/controllers/input/InMMOperationCtrl'
  24. })).state('inMMWaitSubmit',angularAMD.route({
  25. url:'/inMMWaitSubmit/:ioNocode',
  26. templateUrl:'resources/tpl/input/inMMWaitSubmit.html',
  27. controllerUrl : 'app/controllers/input/InMMwaitSubmitCtrl'
  28. })).state('inFinish',angularAMD.route({
  29. url:'/inFinish',
  30. templateUrl : 'resources/tpl/input/inFinish.html',
  31. controllerUrl : 'app/controllers/input/InFinishCtrl'
  32. })).state('inFinishOperation',angularAMD.route({
  33. url:'/inFinishOperation/:code',
  34. templateUrl:'resources/tpl/input/inFinishOperation.html',
  35. controllerUrl : 'app/controllers/input/InFinishOprCtrl'
  36. })).state('inFinishWaitSubmit',angularAMD.route({
  37. url:'/inFinishWaitSubmit/:ioNocode',
  38. templateUrl:'resources/tpl/input/inFinishWaitSubmit.html',
  39. controllerUrl : 'app/controllers/input/InfinishWaitSubmitCtrl'
  40. })).state('inMakeMaterialCheck',angularAMD.route({
  41. url:'/inMakeMaterialCheck/:type',
  42. templateUrl : 'resources/tpl/input/inMakeMaterialCheck.html',
  43. controllerUrl : 'app/controllers/input/InMMCheckCtrl'
  44. })).state('inMMCheckOp',angularAMD.route({
  45. url:'/inMMCheckOp/:code',
  46. templateUrl : 'resources/tpl/input/inMMCheckOp.html',
  47. controllerUrl : 'app/controllers/input/InMMCheckOpCtrl'
  48. })).state('inFinishCheckOp',angularAMD.route({
  49. url:'/inFinishCheckOp/:code',
  50. templateUrl : 'resources/tpl/input/inFinishCheckOp.html',
  51. controllerUrl : 'app/controllers/input/InFinCheckOpCtrl'
  52. })).state('outContents',angularAMD.route({
  53. url:'/outContents',
  54. templateUrl : 'resources/tpl/output/outContents.html',
  55. controllerUrl : 'app/controllers/output/OutputCtrl'
  56. })).state('outMakeMaterial',angularAMD.route({
  57. url:'/outMakeMaterial',
  58. templateUrl : 'resources/tpl/output/outMakeMaterial.html',
  59. controllerUrl : 'app/controllers/output/OutputCtrl'
  60. })).state('outMMOperation',angularAMD.route({
  61. url:'/outMMOperation/:code',
  62. templateUrl : 'resources/tpl/output/outMMOperation.html',
  63. controllerUrl : 'app/controllers/output/OutMMOperationCtrl'
  64. })).state('outMMWaitSubmit',angularAMD.route({
  65. url:'/outMMWaitSubmit/:ioNocode',
  66. templateUrl:'resources/tpl/output/outMMWaitSubmit.html',
  67. controllerUrl : 'app/controllers/output/OutMMwaitSubmitCtrl'
  68. })).state('outFinish',angularAMD.route({
  69. url:'/outFinish',
  70. templateUrl:'resources/tpl/output/outFinish.html',
  71. controllerUrl : 'app/controllers/output/OutFinishCtrl'
  72. })).state('outFinishOprCtrl',angularAMD.route({
  73. url:'/outFinishOperation/:code',
  74. templateUrl:'resources/tpl/output/outFinishOperation.html',
  75. controllerUrl : 'app/controllers/output/OutFinishOprCtrl'
  76. })).state('outFinWaitSubmit',angularAMD.route({
  77. url:'/outFinWaitSubmit/:ioNocode',
  78. templateUrl:'resources/tpl/output/outFinWaitSubmit.html',
  79. controllerUrl : 'app/controllers/output/OutFinWaitSubmitCtrl'
  80. })).state('countingContents',{
  81. url:'/countingContents',
  82. templateUrl:'resources/tpl/counting/countingContents.html'
  83. }).state('countingMM',{
  84. url:'/countingMM',
  85. templateUrl:'resources/tpl/counting/countingMM.html'
  86. }).state('countingFinish',{
  87. url:'/countingFinish',
  88. templateUrl:'resources/tpl/counting/countingFinish.html'
  89. }).state('countingMMWaitSub',{
  90. url:'/countingMMWaitSub',
  91. templateUrl:'resources/tpl/counting/countingMMWaitSub.html'
  92. }).state('countingFinWaitSub',{
  93. url:'/countingFinWaitSub',
  94. templateUrl:'resources/tpl/counting/countingFinWaitSub.html'
  95. }).state('checkContents',angularAMD.route({
  96. url:'/checkContents',
  97. templateUrl:'resources/tpl/check/checkContents.html',
  98. controllerUrl : 'app/controllers/check/CheckCtrl'
  99. })).state('checkMM',angularAMD.route({
  100. url:'/checkMM',
  101. templateUrl:'resources/tpl/check/checkMM.html',
  102. controllerUrl : 'app/controllers/check/CheckCtrl'
  103. })).state('checkBarcode',angularAMD.route({
  104. url:'/checkBarcode',
  105. templateUrl:'resources/tpl/check/checkBarcode.html',
  106. controllerUrl : 'app/controllers/check/CheckCtrl'
  107. })).state('checkPackage',angularAMD.route({
  108. url:'/checkPackage',
  109. templateUrl:'resources/tpl/check/checkPackage.html',
  110. controllerUrl : 'app/controllers/check/CheckCtrl'
  111. })).state('checkMakeFin',angularAMD.route({
  112. url:'/checkMakeFin',
  113. templateUrl:'resources/tpl/check/checkMakeFin.html',
  114. controllerUrl : 'app/controllers/check/CheckCtrl'
  115. })).state('checkOrderFin',angularAMD.route({
  116. url:'/checkOrderFin',
  117. templateUrl:'resources/tpl/check/checkOrderFin.html',
  118. controllerUrl : 'app/controllers/check/CheckCtrl'
  119. })).state('checkPO',angularAMD.route({
  120. url:'/checkPO',
  121. templateUrl:'resources/tpl/check/checkPO.html',
  122. controllerUrl : 'app/controllers/check/CheckCtrl'
  123. })).state('locationTransfer',angularAMD.route({
  124. url:'/locationTransfer',
  125. templateUrl:'resources/tpl/locationTransfer/locationTransfer.html',
  126. controllerUrl : 'app/controllers/locationTransfer/LocationTransferCtrl'
  127. })).state('batchContents',angularAMD.route({
  128. url:'/batchContents',
  129. templateUrl:'resources/tpl/batch/batchContents.html',
  130. controllerUrl : 'app/controllers/batch/BreakingBatchCtrl'
  131. })).state('breakingBatch',angularAMD.route({
  132. url:'/breakingBatch/:type',
  133. templateUrl:'resources/tpl/batch/breakingBatch.html',
  134. controllerUrl : 'app/controllers/batch/BreakingBatchCtrl'
  135. })).state('breakingPackage',angularAMD.route({
  136. url:'/breakingPackage',
  137. templateUrl:'resources/tpl/batch/breakingPackage.html',
  138. controllerUrl : 'app/controllers/batch/BreakingPackageCtrl'
  139. })).state('combineBatch',angularAMD.route({
  140. url:'/combineBatch',
  141. templateUrl:'resources/tpl/batch/combineBatch.html',
  142. controllerUrl : 'app/controllers/batch/CombineBatchCtrl'
  143. })).state('settingContents',angularAMD.route({
  144. url:'/settingContents',
  145. templateUrl:'resources/tpl/setting/settingContents.html',
  146. controllerUrl : 'app/controllers/setting/SettingCtrl'
  147. })).state('haveSubmitList',angularAMD.route({
  148. url:'/haveSubmitList/:pi_id/:inout/:pi_inoutno',
  149. templateUrl:'resources/tpl/input/haveSubmitList.html',
  150. controllerUrl : 'app/controllers/input/HaveSubmitListCtrl'
  151. })).state('manageContents',angularAMD.route({
  152. url:'/manageContents',
  153. templateUrl:'resources/tpl/mes/manageContents.html',
  154. controllerUrl : 'app/controllers/mes/SMTFeedCtrl'
  155. })).state('SMTFeed',angularAMD.route({
  156. url:'/SMTFeed',
  157. templateUrl:'resources/tpl/mes/SMTFeed/SMTFeed.html',
  158. controllerUrl : 'app/controllers/mes/SMTFeedCtrl'
  159. })).state('SMTFeedContents',angularAMD.route({
  160. url:'/SMTFeedContents',
  161. templateUrl:'resources/tpl/mes/SMTFeed/SMTFeedContents.html',
  162. controllerUrl : 'app/controllers/mes/SMTFeedCtrl'
  163. })).state('SMTFeedI',angularAMD.route({
  164. url:'/SMTFeedI/:type',
  165. templateUrl:'resources/tpl/mes/SMTFeed/SMTFeedI.html',
  166. controllerUrl : 'app/controllers/mes/SMTFeedIDCtrl'
  167. })).state('SMTFeedD',angularAMD.route({
  168. url:'/SMTFeedD/:type',
  169. templateUrl:'resources/tpl/mes/SMTFeed/SMTFeedD.html',
  170. controllerUrl : 'app/controllers/mes/SMTFeedIDCtrl'
  171. })).state('SMTFeedJ',angularAMD.route({
  172. url:'/SMTFeedJ/:type',
  173. templateUrl:'resources/tpl/mes/SMTFeed/SMTFeedJC.html',
  174. controllerUrl : 'app/controllers/mes/SMTFeedIDCtrl'
  175. })).state('SMTFeedC',angularAMD.route({
  176. url:'/SMTFeedC/:type',
  177. templateUrl:'resources/tpl/mes/SMTFeed/SMTFeedJC.html',
  178. controllerUrl : 'app/controllers/mes/SMTFeedIDCtrl'
  179. })).state('SMTFeedQ',angularAMD.route({
  180. url:'/SMTFeedQ/:type',
  181. templateUrl:'resources/tpl/mes/SMTFeed/SMTFeedQuery.html',
  182. controllerUrl : 'app/controllers/mes/SMTFeedIDCtrl'
  183. })).state('SMTFeedCheck',angularAMD.route({
  184. url:'/SMTFeedCheck/:type',
  185. templateUrl:'resources/tpl/mes/SMTFeed/SMTFeedCheck.html',
  186. controllerUrl : 'app/controllers/mes/SMTFeedIDCtrl'
  187. })).state('FeederUse',angularAMD.route({
  188. url:'/FeederUse',
  189. templateUrl:'resources/tpl/mes/FeederUse.html',
  190. controllerUrl : 'app/controllers/mes/FeederUseCtrl'
  191. })).state('FeederOperate',angularAMD.route({
  192. url:'/FeederOperate/:type',
  193. templateUrl:'resources/tpl/mes/FeederOperate.html',
  194. controllerUrl : 'app/controllers/mes/FeederUseCtrl'
  195. })).state('makePrepare',angularAMD.route({
  196. url:'/makePrepare/:type',
  197. templateUrl:'resources/tpl/mes/makePrepare/makePrepare.html',
  198. controllerUrl : 'app/controllers/mes/MakePrepareCtrl'
  199. })).state('makePrepareFeeder',angularAMD.route({
  200. url:'/makePrepareFeeder/:type',
  201. templateUrl:'resources/tpl/mes/makePrepare/makePrepareList.html',
  202. controllerUrl : 'app/controllers/mes/MPrepareFeederCtrl'
  203. })).state('feederGet',angularAMD.route({
  204. url:'/feederGet/:type',
  205. templateUrl:'resources/tpl/mes/makePrepare/FeederGet.html',
  206. controllerUrl : 'app/controllers/mes/MPrepareFeederCtrl'
  207. })).state('msdContents',angularAMD.route({
  208. url:'/msdContents',
  209. templateUrl:'resources/tpl/msd/msdContents.html',
  210. controllerUrl : 'app/controllers/msd/MsdCtrl'
  211. })).state('msdinOven',angularAMD.route({
  212. url:'/inOven',
  213. templateUrl:'resources/tpl/msd/inOven.html',
  214. controllerUrl : 'app/controllers/msd/MsdCtrl'
  215. })).state('msdoutOven',angularAMD.route({
  216. url:'/outOven',
  217. templateUrl:'resources/tpl/msd/outOven.html',
  218. controllerUrl : 'app/controllers/msd/MsdCtrl'
  219. })).state('tailingBack',angularAMD.route({
  220. url:'/tailingBack',
  221. templateUrl:'resources/tpl/mes/tailingBack.html',
  222. controllerUrl : 'app/controllers/mes/TailingBackCtrl'
  223. }));
  224. }]);
  225. app.factory('Ring', function(){//响铃,直接调用
  226. return {
  227. success: function(){
  228. document.getElementById('successRing').play();
  229. }, error: function(){
  230. document.getElementById('errorRing').play();
  231. }
  232. }
  233. }).factory('Online',['$rootScope', function($rootScope){//在线状态,全局获取、设置
  234. var status = {online: true};
  235. return {
  236. setOnline: function(value){
  237. status.online = value;
  238. $rootScope.$broadcast('online', value);
  239. }, getOnline: function(){
  240. return status.online;
  241. }
  242. }
  243. }]);
  244. app.factory('StatusCode', function(){
  245. var statusConfig = {
  246. '101' : '已采集',
  247. '102' : '未采集',
  248. '103' : '采集中'
  249. };
  250. return {
  251. get: function(code) {
  252. return statusConfig[code];
  253. }
  254. };
  255. }).filter('status', ['StatusCode', function(StatusCode){
  256. return function(data) {
  257. return StatusCode.get(data);
  258. }
  259. }]);
  260. app.controller('AuthCtrl',['$scope', '$rootScope','$window', 'AuthenticationService','Online','BaseService','SessionService','$modal','$timeout','PurcOrder','$state', function($scope, $rootScope,$window, AuthenticationService,Online,BaseService,SessionService,$modal,$timeout,PurcOrder,$state) {
  261. //控制手机浏览器全屏 找到支持的方法, 使用需要全屏的 element 调用
  262. $rootScope.title = {};
  263. $scope.status = {online: true};
  264. $scope.$watch('status.online', function(value){//检测用户手动切换在线状态
  265. Online.setOnline(value);
  266. });
  267. $scope.$on('online', function(data){//监听Service中的状态变化
  268. $scope.status.online = Online.getOnline();
  269. });
  270. Online.setOnline(AuthenticationService.isAuthed());
  271. $rootScope.userInfo = {};
  272. AuthenticationService.getAuthentication().success(function(data) {
  273. $rootScope.userInfo = data;
  274. if (data == null || !data.em_code){
  275. Online.setOnline(false);
  276. }
  277. });
  278. $scope.logout = function() {//注销
  279. AuthenticationService.logout().success(function() {
  280. var rootPath= BaseService.getRootPath();
  281. $window.location.href = rootPath+'/jsps/PDAmobile/signin.html';
  282. });
  283. };
  284. $rootScope.$on('$stateChangeSuccess',function(event, toState, toParams, fromState, fromParams){
  285. // 如果用户不存在
  286. if(!$rootScope.userInfo){
  287. event.preventDefault();// 取消默认跳转行为
  288. var rootPath= BaseService.getRootPath();
  289. window.location.replace('signin.html');
  290. $state.go("login",{from:fromState.name,w:'notLogin'});//跳转到登录界面
  291. }
  292. });
  293. /*$scope.reLogin = function(){//用户点击在线时
  294. //读取cookie中的信息,提示登录
  295. var modalInstance = $modal.open({
  296. templateUrl: 'againLogin.html',
  297. controller: 'LoginCtrl',
  298. resolve: {
  299. items: function () {
  300. return $rootScope.userInfo.currentMaster;
  301. }
  302. }
  303. });
  304. modalInstance.result.then(function(result) {
  305. Online.setOnline(result);
  306. }, function() {
  307. $log.info('Modal dismissed at: ' + new Date());
  308. });
  309. };
  310. var checkOk = function(){
  311. console.log('执行$timeout回调');//发送心跳包
  312. $timeout(function(){
  313. checkOk();
  314. },1000);
  315. };
  316. $timeout(function(){
  317. checkOk();
  318. },8000);*/
  319. PurcOrder.getDescription({
  320. tablename:'configs',
  321. field:'data',
  322. condition:"code='UseLocationOrNot' and caller='BarCodeSetting'"
  323. },{},function(data){
  324. if(data.description == 'N' || data.description == 0){//不启用仓位
  325. $rootScope.UseLocation = false;
  326. }else{
  327. $rootScope.UseLocation = true;
  328. }
  329. },function(res){
  330. });
  331. }]);
  332. app.controller('LoginCtrl', ['$rootScope','$scope', '$modalInstance', 'toaster', 'AuthenticationService','BaseService','SessionService','items',function($rootScope,$scope, $modalInstance, toaster, AuthenticationService,BaseService,SessionService,items) {
  333. $scope.loading = false;
  334. $scope.user = {
  335. j_username : SessionService.getCookie('PDA_USERNAME'),
  336. j_password :'',
  337. remember_me : true,
  338. master: items.ma_name
  339. };
  340. $scope.login = function(user, _url) {
  341. if($scope.user.j_username == '' ||$scope.user.j_password == ''){
  342. alert("还有必填项没有填写!");
  343. return ;
  344. }else{
  345. $scope.loading = true;
  346. AuthenticationService.login(user).success(function(responseText, status) {
  347. if(responseText) {
  348. $scope.loading = false;
  349. toaster.pop('error', '登录失败', responseText);
  350. $modalInstance.close(false);
  351. }else if(status == 200){
  352. if(user.remember_me)
  353. SessionService.setCookie('PDA_USERNAME', user.j_username);
  354. else
  355. SessionService.removeCookie('PDA_USERNAME');
  356. //登录成功
  357. $modalInstance.close(true);
  358. AuthenticationService.getAuthentication().success(function(data) {
  359. $rootScope.userInfo = data;
  360. if (data == null || !data.em_code){
  361. Online.setOnline(false);
  362. }
  363. });
  364. }
  365. }).error(function(responseText,status) {
  366. $scope.loading = false;
  367. if(status == 0){
  368. Online.setOnline(false);//修改网络状态
  369. Ring.error();
  370. toaster.pop('error', '登录失败',"网络连接不可用,请稍后再试");
  371. }else{
  372. toaster.pop('error', '登录失败', responseText || '用户名或密码错误');
  373. }
  374. });
  375. }
  376. };
  377. }]);
  378. app.controller('IndexCtrl',['$scope','$rootScope','$state', function($scope, $rootScope,$state){
  379. }]);
  380. app.controller('ModalInstanceCtrl',['$scope', '$modalInstance', 'items','SessionService','Print','toaster','MakePrepareOper','Ring',function($scope,$modalInstance,items,SessionService,Print,toaster,MakePrepareOper,Ring) {
  381. $scope.items = items;
  382. $scope.colors = [//可以选择的颜色
  383. {
  384. id: 'red',
  385. name: '红色'
  386. }
  387. ];
  388. $scope.choose = [{id:1,name:'是'},{id:0,name:'否'}];//是否停用
  389. $scope.items.isuse = 0;//绑定,默认是否停用中的0,不停用
  390. $scope.ok = function(selectValue) {
  391. $modalInstance.close(selectValue.PD_WHCODE);
  392. };
  393. $scope.selectBill = function(item){
  394. $modalInstance.close(item);
  395. };
  396. $scope.cancel = function() {
  397. $modalInstance.dismiss('cancel');
  398. };
  399. $scope.confirmDefault = function(items){//设置默认仓库,Ip
  400. $modalInstance.close(items);
  401. };
  402. $scope.confirmBack = function(){
  403. if($scope.items.isuse == 1){
  404. if($scope.items.reason == ''){
  405. alert("请填写停用原因!");
  406. }
  407. }
  408. }
  409. $scope.search = function ($event,items){
  410. if($event == 13){
  411. $modalInstance.close(items);
  412. }
  413. };
  414. $scope.setStyle = function(){//设置样式
  415. $modalInstance.close($scope.items);
  416. };
  417. $scope.confirmPrint = function(items){//设置默认打印机
  418. $modalInstance.close(items);
  419. };
  420. $scope.returnBatching = function(item){//返回继续拆分
  421. $modalInstance.close(items);
  422. }
  423. $scope.print = function (){//打印
  424. if(confirm('确认打印')){
  425. Print.get({data:angular.fromJson($scope.items)},function(data){
  426. if(data.message){
  427. toaster.pop('error', data.message);
  428. }else {
  429. toaster.pop('success', "打印成功!");
  430. }
  431. },function(res){
  432. if(res.status == 0){ //无网络错误
  433. Online.setOnline(false);//修改网络状态
  434. Ring.error();
  435. toaster.pop('error', "网络连接不可用,请稍后再试");
  436. }else{
  437. toaster.pop('error', res.data.exceptionInfo);
  438. }
  439. });
  440. }
  441. };
  442. $scope.enterCode = function(event,code,type){
  443. if(event.keyCode == '13'){
  444. if(type == 'bar'){
  445. $scope.confirmBarcodeBack(code);
  446. }else{
  447. $scope.confirmFBarcode(code);
  448. }
  449. }
  450. };
  451. $scope.confirmFBarcode = function(code){//备料单飞达取消上料
  452. MakePrepareOper.feederBack({bar_code:code,mp_id:$scope.items.mp_id},{},function(data){
  453. toaster.pop('success', "料卷号:"+code+"取消飞达上料成功!");
  454. $modalInstance.close("料卷号:"+code+"取消飞达上料成功!");
  455. },function(res){
  456. $scope.barcode='';
  457. toaster.pop('error', res.data.exceptionInfo);
  458. });
  459. };
  460. $scope.confirmBarcodeBack = function(code){//备料单取消barcode 备料
  461. MakePrepareOper.barBack({barcode:code,mpid:$scope.items.mp_id},{},function(data){
  462. toaster.pop('success', '料卷号:'+code+'退回成功!');
  463. $modalInstance.close(data.message);
  464. },function(res){
  465. $scope.barcode = '';
  466. Ring.error();
  467. toaster.pop('error', '错误',res.data.exceptionInfo);
  468. });
  469. }
  470. }]);
  471. app.controller('ProdModalInstanceCtrl',['$scope', '$modalInstance', 'items',function($scope, $modalInstance, items) {
  472. $scope.items = items;
  473. $scope.wh = {};
  474. $scope.selectPrCode = function(selectValue) {
  475. $modalInstance.close(selectValue);
  476. };
  477. $scope.cancel = function() {
  478. $modalInstance.dismiss('cancel');
  479. };
  480. }]);
  481. 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){
  482. $scope.stocking = $rootScope.stocking||'';
  483. $scope.st_whcode = SessionService.getCookie('defaultWhcode');
  484. $scope.find = function(event,st_code){
  485. if(event.keyCode === 13){
  486. $scope.search(st_code);
  487. }
  488. }
  489. $scope.search = function(st_code){
  490. if(st_code){
  491. CountingOper.get({st_code:st_code},function(data){
  492. if(data.target && data.totalCount > 0){
  493. var or = new Object();
  494. or = data.target;
  495. $scope.stocking = data.target[0];
  496. $rootScope.stocking = $scope.stocking;
  497. $scope.st_whcode = $scope.stocking.ST_WHCODE;
  498. }
  499. },function(response){
  500. toaster.pop('error', '查询失败',response.data.exceptionInfo);
  501. Ring.error();
  502. });
  503. }else{
  504. alert("请输入盘点底稿编号!");
  505. document.getElementById("st_code").focus()
  506. }
  507. };
  508. $scope.confirm = function(){
  509. if($scope.Counting == 'makeMaterial'){
  510. $location.path("countingMM");
  511. }else if($scope.Counting == 'Finish'){
  512. $location.path("countingFinish");
  513. }else{
  514. alert("请选择判断类型!");
  515. }
  516. }
  517. }]);
  518. 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){
  519. $scope.stocking = $rootScope.stocking||'';
  520. $scope.grid = $rootScope.cmGrid||[];
  521. var check = function(){//条码号不为空;2、数量大于0;3、条码不存在于已采集列表
  522. if(!$scope.barcodes.stb_barcode){
  523. document.getElementById("bi_barcode").focus();
  524. Ring.error();
  525. alert("条码号不为空");
  526. return false;
  527. }else if(SupportUtil.contains(JSON.stringify($scope.grid),$scope.barcodes.stb_barcode,"stb_barcode")){
  528. alert("条码编号重复!");
  529. Ring.error();
  530. document.getElementById("bi_barcode").focus();
  531. document.getElementById("bi_barcode").select();
  532. return false;
  533. }else if($scope.barcodes.stb_qty <=0){
  534. alert ("数量必须大于0");
  535. Ring.error();
  536. return false;
  537. }else {
  538. return true;
  539. }
  540. }
  541. $scope.barcodes = {};
  542. $scope.search = function($event,bi_barcode){
  543. if($event.keyCode == 13) {//Enter事件
  544. if(check()){
  545. CountingOper.getBarData({bar_code:bi_barcode,bar_whcode:$scope.stocking.ST_WHCODE,st_code:$scope.stocking.ST_CODE},{},function(data){
  546. $scope.barcodes.stb_barcode = data.data.BAR_CODE;
  547. $scope.barcodes.stb_vendcode = data.data.BAR_VENDCODE;
  548. $scope.barcodes.stb_prodcode = data.data.BAR_PRODCODE;
  549. $scope.barcodes.stb_barid = data.data.BAR_ID;
  550. $scope.barcodes.stb_qty = data.data.BAR_REMAIN;
  551. $scope.barcodes.stb_stid = $scope.stocking.ST_ID;
  552. $scope.barcodes.stb_stcode = $scope.stocking.ST_CODE;
  553. $scope.barcodes.pr_detail = data.data.PR_DETAIL;
  554. },function(response){
  555. toaster.pop('error', '条码号错误',response.data.exceptionInfo);
  556. Ring.error();
  557. })
  558. }
  559. }
  560. }
  561. $scope.confirm = function(){
  562. if(check()){
  563. $scope.show = true;
  564. $scope.grid.push($scope.barcodes);
  565. $scope.shows = $scope.barcodes;
  566. $scope.barcodes ='';
  567. document.getElementById("bi_barcode").focus();
  568. }
  569. $rootScope.cmGrid = $scope.grid ;
  570. };
  571. $scope.returnCC = function (){
  572. if($scope.grid.length>0){
  573. if(confirm("返回,将删除已采集未提交的数据?")){
  574. $scope.grid = $rootScope.cfGrid = '';
  575. $location.path("countingContents");
  576. }
  577. }else{
  578. $location.path("countingContents");
  579. }
  580. };
  581. $scope.submitGet = function(){//提交盘点数据
  582. if($scope.grid.length>0){
  583. CountingOper.saveBarcode({},angular.fromJson($scope.grid),function(data){
  584. $scope.grid = $rootScope.cmGrid = '';
  585. toaster.pop('success', '提交成功');
  586. Ring.success();
  587. },function(response){
  588. toaster.pop('error', '提交失败',response.data.exceptionInfo);
  589. Ring.error();
  590. });
  591. }else{
  592. Ring.error();
  593. alert("没有需要提交的数据!");
  594. }
  595. };
  596. if($scope.grid){
  597. $scope.tableParams = new ngTableParams({//盘点料号名称规格及剩余数量表格【待提交的】
  598. page: 1,
  599. count: 10,
  600. filter: { },
  601. sorting: { }
  602. }, {
  603. total: $scope.grid.length,
  604. getData: function ($defer, params) {
  605. params.total($scope.grid.length); // set total for recalc pagination
  606. $defer.resolve($scope.grid.slice((params.page() - 1) * params.count(), params.page() * params.count()));
  607. }
  608. });
  609. };
  610. $scope.deleteAll = function(){//全部删除
  611. if(confirm("确定删除全部?")){
  612. $scope.grid = $rootScope.cmGrid = '';
  613. Ring.success();
  614. toaster.pop('success', '删除成功');
  615. $scope.tableParams.reload();
  616. }
  617. };
  618. $scope.deleteWaitSubmitItem = function(s){//单行删除
  619. for (var n in $scope.grid){
  620. if($scope.grid[n].stb_barcode == s.stb_barcode){
  621. $scope.grid.splice(n,1);
  622. }
  623. }
  624. $rootScope.cmGrid = $scope.grid;
  625. $scope.tableParams.reload();
  626. };
  627. }]);
  628. 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){
  629. $scope.stocking = $rootScope.stocking||'';
  630. $scope.grid = $rootScope.cfGrid||[];
  631. var checkSerialSearch = function(serial_code){
  632. if(SupportUtil.contains(JSON.stringify($scope.grid),serial_code,"stb_barcode")){
  633. Ring.error();
  634. alert("序列号重复!");
  635. document.getElementById("serial_code").focus().select();
  636. return ;
  637. }else{
  638. CountingOper.serialSearch({code:serial_code,whcode:$scope.stocking.ST_WHCODE,st_code:$scope.stocking.ST_CODE},{},function(data){
  639. $scope.serialMessage = data.message;
  640. $scope.makeCode = $scope.serialMessage.MA_CODE;
  641. $scope.prodcode = $scope.serialMessage.stb_prodcode;
  642. },function(response){
  643. Ring.error();
  644. toaster.pop('error', '序列号不存在',response.data.exceptionInfo);
  645. });
  646. }
  647. }
  648. $scope.serialSearch = function ($event,serial_code){//序列号enter事件
  649. if($event.keyCode == 13 && serial_code){
  650. checkSerialSearch(serial_code);
  651. }
  652. };
  653. var checkOutboxSearch = function (boxcode){
  654. if(SupportUtil.contains(JSON.stringify($scope.grid),serial_code,"stb_barcode")){
  655. alert("包装箱号重复");
  656. Ring.error();
  657. return ;
  658. }else {
  659. CountingOper.outboxSearch({code:boxcode,whcode:$scope.stocking.ST_WHCODE,st_code:$scope.stocking.ST_CODE},{},function(data){
  660. $scope.outboxMessage = data.message;
  661. $scope.totalqty = $scope.outboxMessage.stb_qty;
  662. $scope.prodcode = $scope.outboxMessage.stb_prodcode;
  663. },function(response){
  664. Ring.error();
  665. toaster.pop('error', '包装箱号不存在',response.data.exceptionInfo);
  666. });
  667. }
  668. };
  669. $scope.outboxSearch = function($event,boxcode){//包装箱号enter事件
  670. if($event.keyCode == 13 && boxcode){
  671. checkOutboxSearch(boxcode);
  672. }
  673. };
  674. $scope.confirm = function(){
  675. if(!$scope.serial){
  676. alert("请选择包装箱号或者序列号");
  677. return ;
  678. }else if($scope.serial == 'outbox' && !$scope.boxcode){
  679. alert("请输入包装箱号");
  680. return;
  681. }else if($scope.serial == 'serial' && !$scope.serial_code){
  682. alert("请输入序列号");
  683. return ;
  684. }else if($scope.serial == 'serial' && $scope.serial_code ){//选择序列号执行确认
  685. checkSerialSearch($scope.serial_code);
  686. $scope.serialMessage.stb_stcode = $scope.stocking.ST_CODE;
  687. $scope.serialMessage.stb_stid = $scope.stocking.ST_ID;
  688. $scope.grid.push($scope.serialMessage);
  689. $scope.serial_code = $scope.makeCode ='';
  690. document.getElementById("serial_code").focus();
  691. Ring.success();
  692. }else if($scope.serial == 'outbox' && $scope.boxcode ){
  693. checkOutboxSearch($scope.boxcode);
  694. $scope.outboxMessage.stb_stcode = $scope.stocking.ST_CODE;
  695. $scope.outboxMessage.stb_stid = $scope.stocking.ST_ID;
  696. $scope.grid.push($scope.outboxMessage);
  697. $scope.boxcode = $scope.totalqty ='';
  698. document.getElementById("boxcode").focus();
  699. Ring.success();
  700. }
  701. $rootScope.cfGrid = $scope.grid;
  702. $scope.shows= $scope.grid[$scope.grid.length-1];
  703. };
  704. $scope.returnCC = function (){
  705. if($scope.grid.length>0){
  706. if(confirm("返回,将删除已采集未提交的数据?")){
  707. $scope.grid = $rootScope.cfGrid = '';
  708. $location.path("countingContents");
  709. }
  710. }else{
  711. $location.path("countingContents");
  712. }
  713. }
  714. $scope.submitGet = function(){
  715. if($scope.grid.length>0){
  716. CountingOper.saveBarcode({},angular.fromJson($scope.grid),function(data){
  717. $scope.grid = $rootScope.cfGrid = '';
  718. toaster.pop('success', '提交成功');
  719. Ring.success();
  720. },function(response){
  721. toaster.pop('error', '提交失败',response.data.exceptionInfo);
  722. Ring.error();
  723. });
  724. }else{
  725. Ring.error();
  726. alert("没有需要提交的数据!");
  727. }
  728. };
  729. if($scope.grid){
  730. $scope.tableParams = new ngTableParams({//盘点料号名称规格及剩余数量表格【待提交的】
  731. page: 1,
  732. count: 10,
  733. filter: { },
  734. sorting: { }
  735. }, {
  736. total: $scope.grid.length,
  737. getData: function ($defer, params) {
  738. params.total($scope.grid.length); // set total for recalc pagination
  739. $defer.resolve($scope.grid.slice((params.page() - 1) * params.count(), params.page() * params.count()));
  740. }
  741. });
  742. };
  743. $scope.deleteWaitSubmitItem = function( s){
  744. for (var n in $scope.grid){
  745. if($scope.grid[n].stb_barcode == s.stb_barcode){
  746. $scope.grid.splice(n,1);
  747. }
  748. }
  749. $rootScope.cfGrid = $scope.grid;
  750. $scope.tableParams.reload();
  751. };
  752. $scope.deleteAll = function(){
  753. if(confirm("确定删除全部?")){
  754. $scope.grid = $rootScope.cfGrid = '';
  755. Ring.success();
  756. toaster.pop('success', '删除成功');
  757. $scope.tableParams.reload();
  758. }
  759. }
  760. }]);
  761. /**
  762. * 湿敏元件拆分
  763. */
  764. app.controller('SplitModalCtrl',['$scope', '$modalInstance', 'items','MsdOper',function($scope, $modalInstance, items,MsdOper) {
  765. $scope.items = {};
  766. $scope.items.bar_code = items.bar_code;
  767. var loadMSDLog = function(){
  768. MsdOper.loadMSDLog({code:$scope.items.bar_code}, function(data){
  769. $scope.items = data.message;
  770. }, function(response){
  771. toaster.pop('error', '获取数据失败', response.data.exceptionInfo);
  772. });
  773. };
  774. loadMSDLog();
  775. $scope.msdConfirm = function(){
  776. if($scope.items.status == "已拆封" && $scope.items.ms_resttime <= 0){//已拆封,并且无剩余寿命。不允许确认
  777. toaster.pop('error', '剩余寿命不足,请烘烤再使用!');
  778. $modalInstance.close();
  779. }else if($scope.items.status == "已拆封"){
  780. MsdOper.loadMSDLog({code: $scope.items.bar_code}, function(data){
  781. if(data.message.ms_resttime <= 0 ){
  782. toaster.pop('error', '剩余寿命不足,请烘烤再使用!');
  783. $modalInstance.close();
  784. }else{
  785. $modalInstance.close('s');
  786. }
  787. }, function(response){
  788. toaster.pop('error', '失败', response.data.exceptionInfo);
  789. });
  790. }else if($scope.items.status =='在烤箱'){//在烘烤提示是否出烤箱
  791. if(confirm("是否出烤箱?")){
  792. MsdOper.confirmOutOven({},{bar_code:$scope.items.bar_code},function(data){
  793. $scope.btnInvalid = true;
  794. toaster.pop("success","已出烘烤!");
  795. $modalInstance.close('s');
  796. },function(res){
  797. toaster.pop('error', '出烘烤失败',response.data.exceptionInfo);
  798. });
  799. }else{
  800. $modalInstance.close();
  801. }
  802. }else {
  803. $modalInstance.close('s');
  804. }
  805. }
  806. $scope.cancel = function(){
  807. $modalInstance.close();
  808. }
  809. }]);
  810. return app;
  811. });