deviceCheckCtrl.js 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304
  1. "use strict";
  2. angular.module('app.business')
  3. //盘点单
  4. .controller("deviceCheckCtrl", function ($scope, $http, $state, $rootScope, deviceCheckService, $filter, $stateParams, APP_CONFIG) {
  5. // 获取列表数据
  6. $scope.pageInfo = {pageNum: 1, pageSize: 10};
  7. $scope.search = {pdNum: "", starttime: "", endtime: ""};
  8. $scope.loadPdNum = function () {
  9. deviceCheckService.getCheckListNoPage().then(function (data) {
  10. $scope.pdNum = data;
  11. $scope.loadData();
  12. }, function (data) {
  13. console.log(data);
  14. });
  15. }
  16. $scope.loadData = function () {
  17. deviceCheckService.getPageInfoDevice($scope.pageInfo.pageNum, $scope.pageInfo.pageSize, $scope.search.pdNum, $scope.search.starttime, $scope.search.endtime).then(function (data) {
  18. $scope.pageInfo = data;
  19. }, function (data) {
  20. console.log(data);
  21. });
  22. }
  23. // $scope.loadData();
  24. $scope.loadPdNum();
  25. //清空
  26. $scope.clean = function () {
  27. $scope.search = {pdNum: "", starttime: "", endtime: ""};
  28. $scope.loadData();
  29. }
  30. //新增
  31. $scope.showCheck = function () {
  32. $state.go('app.basic.device.checkAdd');
  33. }
  34. // 翻页
  35. $scope.goPage = function (pageNum) {
  36. $scope.pageInfo.pageNum = pageNum;
  37. $scope.loadData();
  38. }
  39. //根据仓房ID删除数据
  40. $scope.remove = function (houseId, checkNumber) {
  41. if (confirm("确定删除该条数据?")) {
  42. deviceCheckService.remove(houseId, checkNumber).then(function (data) {
  43. $scope.loadPdNum();
  44. }, function (data) {
  45. console.log(data);
  46. });
  47. }
  48. }
  49. //修改
  50. $scope.loadDataById = function (checkNumber, type) {
  51. $state.go("app.basic.device.checkEdit", {checkNumber: checkNumber, isNotEdit: type});
  52. }
  53. // 翻页
  54. $scope.goPage = function(pageNum) {
  55. if ($scope.pageInfo.pageNum != pageNum && pageNum > 0) {
  56. $scope.pageInfo.pageNum = pageNum;
  57. $scope.loadData();
  58. }
  59. }
  60. })
  61. .controller("deviceCheckAddCtrl", function ($scope, $http, $state, $rootScope, $filter, deviceCheckService, equipmentEquipmentPoolService, $stateParams, APP_CONFIG, enumService, deviceStorageService) {
  62. // 获取存放位置
  63. $scope.equipment = function () {
  64. equipmentEquipmentPoolService.getPageInfo(null, null, null).then(function (data) {
  65. $scope.equipmentEquipmentPool = data.list;
  66. }, function (data) {
  67. console.log(data);
  68. });
  69. }
  70. $scope.equipment();
  71. /* $scope.dateTimes = function (number, type) {
  72. var date = new Date();
  73. date.setDate(date.getDate() - number);//获取number天后的日期
  74. var years = date.getFullYear();
  75. var month = date.getMonth() + 1;//获取当前月份的日期
  76. var strDate = date.getDate();
  77. if (month >= 1 && month <= 9) {
  78. month = "0" + month;
  79. }
  80. if (strDate >= 0 && strDate <= 9) {
  81. strDate = "0" + strDate;
  82. }
  83. if (type == 0) return years + month + strDate;
  84. if (type == 1) return years + "-" + month + "-" + strDate + " " + date.getHours() + ":" + date.getMinutes() + ":" + date.getSeconds();
  85. };*/
  86. $scope.pddTitleName = "新增盘点单";
  87. $scope.deviceCheck = {};
  88. $scope.reallyCount = 0;//默认实际数量
  89. $scope.reason = '无';//默认原因为空
  90. $scope.deviceCheck.depotId = -1;//仓房d
  91. $scope.deviceCheck.deviceType = "";//盘点种类
  92. // $scope.deviceCheck.checkDate = $scope.dateTimes(0, 1);
  93. var pddh;//自动生成的盘点单号-20180104003
  94. //根据盘点时间,获取当天盘点单号
  95. $scope.getCount = function () {
  96. $scope.deviceList = {};
  97. if ($scope.deviceCheck.checkNumber != undefined) {
  98. deviceStorageService.getBySbCode($scope.deviceCheck.checkNumber).then(function (data) {//data = 2;
  99. $scope.deviceList = data;
  100. }, function (data) {
  101. console.log(data);
  102. });
  103. }
  104. }
  105. $scope.changePdzl = function () {
  106. if (null == $scope.deviceCheck.deviceType || $scope.deviceCheck.deviceType == 'undefined') {
  107. $scope.deviceCheck.deviceType = "";
  108. }
  109. deviceCheckService.changePdzl($scope.deviceCheck.deviceType[0].name).then(function (data) {
  110. $scope.allSbcode = data;
  111. }, function (data) {
  112. console.log(data);
  113. });
  114. }
  115. $scope.back = function () {
  116. $state.go("app.basic.device.deviceCheckList");
  117. }
  118. var validator = $("#deviceCheck-form").validate();
  119. $scope.pd = {};
  120. $scope.check = {reallyCount: "", reason: ""};
  121. $scope.saveData = function () {
  122. if (validator.form()) {
  123. var ins = {};
  124. // ins.device_type = $scope.deviceCheck.deviceType;//盘点种类
  125. //ins.check_date = $scope.deviceCheck.checkDate;//时间
  126. // ins.check_date = $filter('date')($scope.deviceCheck.checkDate, "yyyy-MM-dd HH:mm:ss");//时间
  127. // ins.depot_id = $scope.deviceCheck.depotId;//仓房id
  128. ins.device_name = $scope.deviceCheck.deviceType[0].name;//器材名称
  129. ins.check_number = $scope.deviceCheck.checkNumber;//盘点单号
  130. ins.store_count = $scope.deviceList.sbsl;//库存数量
  131. ins.really_count = $scope.check.reallyCount;//实际库存数量
  132. ins.check_result = $scope.deviceList.checkResult;//盘点情况
  133. ins.reason = $scope.check.reason;//原因描述
  134. ins.org_id = $rootScope.userInfo.orgId;
  135. ins.check_person = $scope.deviceCheck.checkPerson;//负责人
  136. ins.model = $scope.deviceList.sbggxh; //规格型号
  137. // 提交表单
  138. $http({
  139. method: 'POST',
  140. url: APP_CONFIG.deviceUrl + '/deviceCheck/save',
  141. data: {
  142. deviceCheckJson: angular.toJson(ins),
  143. type: "add"
  144. }
  145. }).then(function successCallback(response) {
  146. if (response.data.status == "success") {
  147. alert("保存成功!");
  148. $state.go('app.basic.device.deviceCheckList');
  149. } else {
  150. alert("保存失败!");
  151. }
  152. }, function errorCallback(response) {
  153. // 请求失败执行代码
  154. });
  155. }
  156. };
  157. // 显示设备器材详情页
  158. $scope.changeDeviceType = function () {
  159. if ($scope.dSbxxsjy.ssfl === '1') { // 显示设备编辑
  160. // 显示设备 ShowQCType
  161. $scope.ShowQCType = true;
  162. // 显示器材 ShowSBType
  163. $scope.ShowSBType = false;
  164. $scope.getDeviceName('', '5476');
  165. } else if ($scope.dSbxxsjy.ssfl === '3') { // 显示器材编辑
  166. $scope.ShowQCType = false;
  167. $scope.ShowSBType = true;
  168. $scope.getDeviceName('', '5475');
  169. } else { // 默认显示设备编辑
  170. $scope.ShowQCType = true;
  171. $scope.ShowSBType = false;
  172. $scope.getDeviceName('', '5476');
  173. }
  174. };
  175. //树形下拉框获取器材设备名称
  176. $scope.getDeviceName = function (deviceName, deviceType) {
  177. enumService.getTreeListByTypeId(deviceName, deviceType).then(function (data) {
  178. $scope.deviceNameTreeData = data;
  179. }, function (data) {
  180. console.log(data);
  181. })
  182. };
  183. })
  184. .controller("deviceCheckEditCtrl", function ($scope, $http, $state, $filter, $rootScope, deviceCheckService, equipmentEquipmentPoolService, $stateParams, APP_CONFIG) {
  185. // 获取存放位置
  186. $scope.equipment = function () {
  187. equipmentEquipmentPoolService.getPageInfo(null, null, null).then(function (data) {
  188. $scope.equipmentEquipmentPool = data.list;
  189. }, function (data) {
  190. console.log(data);
  191. });
  192. }
  193. $scope.equipment();
  194. $scope.dateTimes = function (number, type) {
  195. var date = new Date();
  196. date.setDate(date.getDate() - number);//获取number天后的日期
  197. var years = date.getFullYear();
  198. var month = date.getMonth() + 1;//获取当前月份的日期
  199. var strDate = date.getDate();
  200. if (month >= 1 && month <= 9) {
  201. month = "0" + month;
  202. }
  203. if (strDate >= 0 && strDate <= 9) {
  204. strDate = "0" + strDate;
  205. }
  206. if (type == 0) return years + month + strDate;
  207. if (type == 1) return years + "-" + month + "-" + strDate + " " + date.getHours() + ":" + date.getMinutes() + ":" + date.getSeconds();
  208. };
  209. $scope.back = function () {
  210. $state.go("app.basic.device.deviceCheckList");
  211. }
  212. $scope.deviceCheck = {};
  213. $scope.deviceCheck.depotId = -1;//仓房d
  214. var pddh;//自动生成的盘点单号-20180104003
  215. //根据盘点时间,获取当天盘点单号
  216. $scope.getCount = function () {
  217. deviceCheckService.getCount($scope.deviceCheck.depotId).then(function (data) {//data = 2;
  218. pddh = $scope.deviceCheck.checkNumber = $scope.dateTimes(0, 0) + "00" + (data * 1 + 1);
  219. if ($scope.deviceCheck.depotId == null || $scope.deviceCheck.depotId == 'undefined') {
  220. $scope.deviceCheck.depotId = -1;
  221. }
  222. $scope.deviceCheck.checkNumber = $scope.deviceCheck.depotId + "-" + $scope.deviceCheck.deviceType + "-" + pddh;
  223. }, function (data) {
  224. console.log(data);
  225. });
  226. }
  227. // $scope.getCount();
  228. deviceCheckService.loadDataById($stateParams.checkNumber).then(function (data) {
  229. $scope.deviceList = data[0];
  230. if ($stateParams.isNotEdit == "1") {
  231. $scope.pddTitleName = "盘点单详情";
  232. $scope.isNotEdit = true;
  233. }
  234. else {
  235. $scope.pddTitleName = "修改盘点单";
  236. $scope.isNotEdit = false;
  237. }
  238. }, function (data) {
  239. console.log(data);
  240. });
  241. $scope.saveData = function () {
  242. var ins = {};
  243. ins.device_name = $scope.deviceList.deviceName;//器材名称
  244. ins.check_number = $scope.deviceList.checkNumber;//盘点单号
  245. ins.store_count = $scope.deviceList.storeCount;//库存数量
  246. ins.really_count = $scope.deviceList.reallyCount;//实际库存数量
  247. ins.check_result = $scope.deviceList.checkResult;//盘点情况
  248. ins.reason = $scope.deviceList.reason;//原因描述
  249. ins.org_id = $rootScope.userInfo.orgId;
  250. ins.check_person = $scope.deviceList.checkPerson;//负责人
  251. ins.model = $scope.deviceList.model; //规格型号
  252. // 提交表单
  253. $http({
  254. method: 'POST',
  255. url: APP_CONFIG.deviceUrl + '/deviceCheck/save',
  256. data: {
  257. deviceCheckJson: angular.toJson(ins),
  258. type: "edit"
  259. }
  260. }).then(function successCallback(response) {
  261. if (response.data.status == "success") {
  262. alert("保存成功!");
  263. $state.go('app.basic.device.deviceCheckList');
  264. } else {
  265. alert("保存失败!");
  266. }
  267. }, function errorCallback(response) {
  268. // 请求失败执行代码
  269. });
  270. }
  271. })