numberManageCtrl.js 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186
  1. "use strict";
  2. angular.module('app.numbermanage').controller("numberManageCtrl", function(APP_CONFIG, $scope,$rootScope, $http, $state, $filter,
  3. numberMangaeService, sheetService, StorehouseService, warehouseService, enumService,
  4. kcswService, archiveService,$stateParams) {
  5. $scope.searchCondition = {houseId : "", warehouseId : "", pz : ""};
  6. $scope.getBasicData = function() {
  7. //按照单位获取单位下的仓房信息
  8. var depotId = $rootScope.orgInfo.orgId;
  9. warehouseService.getStorehouse(depotId, $scope.searchCondition.houseId,"0").then(function(data){
  10. $scope.warehouseList = data.wareList; //下拉列表数据
  11. $scope.warehouseObj = data.wares; //查询数据列表货位信息转换
  12. },function (data) {
  13. console.log(data);
  14. });
  15. };
  16. /* 分页信息 */
  17. $scope.pageInfo = {pageNum : 1, pageSize : 10};
  18. $scope.isArchiveHouse = 0;
  19. $scope.loadDataSelect = function() {
  20. /* 先拿到库存实物表的数据 */
  21. var serchCh = null;
  22. var serchHwh = null;
  23. var serchPz = null;
  24. //归档用
  25. if($stateParams.dataState == "archive"){
  26. $scope.isArchive = true;
  27. //查询归档仓房下拉
  28. archiveService.getArchiveDataList().then(function (data) {
  29. if($scope.isArchiveHouse == 0){
  30. $scope.store_tank_list = data;
  31. }
  32. $scope.isArchiveHouse++;
  33. //如果不是下拉的则可能是点查看则按照这种方式跳转
  34. if($scope.searchCondition.houseId == undefined || $scope.searchCondition.houseId == ""){
  35. $scope.searchCondition.houseId = $rootScope.archiveState.storehouseId;
  36. $scope.searchCondition.createTime = $rootScope.archiveState.createTime;
  37. $scope.getBasicData();
  38. }else{
  39. $scope.searchCondition.createTime = $scope.store_tank_list[$scope.searchCondition.houseId].createTime;
  40. }
  41. if($scope.searchCondition.createTime == "" || $scope.searchCondition.createTime == undefined){
  42. $scope.pageInfo.pageNum = 0;
  43. $scope.pageInfo.pageSize = 0;
  44. $scope.searchCondition.houseId = '000';
  45. }
  46. if (undefined != $scope.searchCondition) {
  47. if (undefined != $scope.searchCondition.houseId) {
  48. serchCh = $scope.searchCondition.houseId;
  49. }
  50. if (undefined != $scope.searchCondition.warehouseId) {
  51. serchHwh = $scope.searchCondition.warehouseId;
  52. }
  53. if (undefined != $scope.searchCondition.pz) {
  54. serchPz = $scope.searchCondition.pz;
  55. }
  56. if (undefined != $scope.searchCondition.pz) {
  57. serchPz = $scope.searchCondition.pz;
  58. }
  59. if (undefined != $scope.searchCondition.createTime) {
  60. var createTime = $scope.searchCondition.createTime;
  61. }
  62. $scope.kcswStr = {ch: serchCh, hwh: serchHwh, pz: serchPz, unitid: $rootScope.orgInfo.orgId, modifydate: createTime};
  63. } else {
  64. $scope.kcswStr = {ch: null, hwh: null, pz: null, unitid: $rootScope.orgInfo.orgId};
  65. }
  66. $scope.searchCondition.createTime = $filter('date')($scope.searchCondition.createTime, "yyyy-MM-dd HH:mm:ss");
  67. //原来代码
  68. kcswService.getPageInfo($scope.pageInfo.pageNum, $scope.pageInfo.pageSize, $scope.kcswStr, "ch").then(function (data) {
  69. $scope.pageInfo = data;
  70. }, function (data) {
  71. console.log(data);
  72. });
  73. }, function (data) {
  74. console.log(data);
  75. });
  76. }else {
  77. if (undefined != $scope.searchCondition) {
  78. if (undefined != $scope.searchCondition.houseId) {
  79. serchCh = $scope.searchCondition.houseId;
  80. }
  81. if (undefined != $scope.searchCondition.warehouseId) {
  82. serchHwh = $scope.searchCondition.warehouseId;
  83. }
  84. if (undefined != $scope.searchCondition.pz) {
  85. serchPz = $scope.searchCondition.pz;
  86. }
  87. $scope.kcswStr = {ch: serchCh, hwh: serchHwh, pz: serchPz, unitid: $rootScope.orgInfo.orgId};
  88. } else {
  89. $scope.kcswStr = {ch: null, hwh: null, pz: null, unitid: $rootScope.orgInfo.orgId};
  90. }
  91. kcswService.getPageInfo($scope.pageInfo.pageNum, $scope.pageInfo.pageSize, $scope.kcswStr, "ch").then(function (data) {
  92. $scope.pageInfo = data;
  93. }, function (data) {
  94. console.log(data);
  95. });
  96. }
  97. kcswService.getCountKczl($rootScope.orgInfo.orgId).then(function(data){
  98. $scope.lskczl = data.lskczl;
  99. if ($scope.lskczl != "0") {
  100. $scope.lskczl = parseFloat($scope.lskczl)/1000;
  101. $scope.lskczl = Number($scope.lskczl.toString().match(/^\d+(?:\.\d{0,3})?/));
  102. }
  103. $scope.yzkczl = data.yzkczl;
  104. if ($scope.yzkczl != "0") {
  105. $scope.yzkczl = parseFloat($scope.yzkczl)/1000;
  106. $scope.yzkczl = Number($scope.yzkczl.toString().match(/^\d+(?:\.\d{0,3})?/));
  107. }
  108. },function(data){
  109. console.log(data);
  110. });
  111. //加载打印数据
  112. kcswService.getPageInfo(null, null, $scope.kcswStr, null).then(function (data) {
  113. $scope.pageInfoprint = data;
  114. }, function (data) {
  115. console.log(data);
  116. });
  117. }
  118. $scope.getBasicData();
  119. $scope.loadDataSelect();
  120. $scope.searchCondition = {};
  121. //清空
  122. $scope.clearConditions = function() {
  123. $scope.searchCondition = {};
  124. $scope.loadData();
  125. };
  126. // 分页相关方法.
  127. $scope.go_pages = function(type, pageNum, pigeSize, pages) {
  128. var pageNumC = pageNum;
  129. if (type == 'previousPage') {
  130. if (pageNum <= 1) {
  131. return;
  132. }
  133. pageNumC = pageNum - 1
  134. } else if (type == 'nextPage') {
  135. if (pageNum >= pages) {
  136. return;
  137. }
  138. pageNumC = pageNum + 1
  139. } else if (type == 'firstPage') {
  140. if (pageNum == 1) {
  141. return;
  142. }
  143. pageNumC = 1;
  144. } else if (type == 'lastPage') {
  145. if (pageNum == pages) {
  146. return;
  147. }
  148. pageNumC = pages;
  149. }
  150. $scope.loadData = function() {
  151. kcswService.getPageInfo(pageNumC, pigeSize,$scope.kcswStr, "ch").then(function(data){
  152. $scope.pageInfo = data;
  153. },function(data){
  154. //console.log(data);
  155. });
  156. };
  157. $scope.loadData();
  158. };
  159. // 改变页码.
  160. $scope.change_pageSize = function(pigeSizeChange) {
  161. $scope.loadData = function() {
  162. kcswService.getPageInfo(1, pigeSizeChange,$scope.kcswStr).then(function(data){
  163. $scope.pageInfo = data;
  164. },function(data){
  165. //console.log(data);
  166. });
  167. };
  168. $scope.loadData();
  169. }
  170. //打印
  171. $scope.print = function() {
  172. $("#kcprint").printArea();
  173. }
  174. });