summaryDetailCtrl.js 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  1. "use strict";
  2. /**
  3. * controller for User Profile Example
  4. */
  5. app.controller("summaryDetailCtrl", [
  6. "$rootScope",
  7. "$scope",
  8. "$state",
  9. "$stateParams",
  10. "$timeout",
  11. "$interval",
  12. "$modal",
  13. "SweetAlert",
  14. "i18nService",
  15. "uiGridConstants",
  16. "uiGridGroupingConstants",
  17. "Restangular",
  18. "api_bpm_schedule",
  19. "api_bpm_data",
  20. "api_wechatfile",
  21. "api_configure_data",
  22. "moment",
  23. function (
  24. $rootScope,
  25. $scope,
  26. $state,
  27. $stateParams,
  28. $timeout,
  29. $interval,
  30. $modal,
  31. SweetAlert,
  32. i18nService,
  33. uiGridConstants,
  34. uiGridGroupingConstants,
  35. Restangular,
  36. api_bpm_schedule,
  37. api_bpm_data,
  38. api_wechatfile,
  39. api_configure_data,
  40. moment
  41. ) {
  42. $scope.langs = i18nService.getAllLangs();
  43. $scope.lang = "zh-cn";
  44. i18nService.setCurrentLang($scope.lang);
  45. // 获取信息
  46. $scope.consumableList = [];
  47. $scope.incidentDTO = {};
  48. $scope.workHourManagementList = [];
  49. $scope.totalMaintenancePrice = null;
  50. $scope.totalPriceConsumable = null;
  51. $scope.totalPriceWorkHourManagement = null;
  52. $scope.getInfo = function(){
  53. console.log($stateParams.incidentId);
  54. $rootScope.isMask = true;
  55. api_bpm_data.querySummaryDoc({"incidentId":$stateParams.incidentId}).then(
  56. function (data) {
  57. $rootScope.isMask = false;
  58. $scope.consumableList = data.consumableList || [];
  59. $scope.incidentDTO = data.incidentDTO || {};
  60. $scope.workHourManagementList = data.workHourManagementList || [];
  61. $scope.totalMaintenancePrice = data.totalMaintenancePrice;
  62. $scope.totalPriceConsumable = data.consumablePrice;
  63. $scope.totalPriceWorkHourManagement = data.workHourPrice;
  64. },
  65. function () {
  66. $rootScope.isMask = false;
  67. }
  68. );
  69. }
  70. $scope.getInfo();
  71. //返回列表
  72. $scope.goToList = function(){
  73. $state.go("app.incident.summary");
  74. }
  75. $scope.transferTime = function (time) {
  76. if(time){
  77. return moment(time).format('YYYY-MM-DD HH:mm');
  78. }else{
  79. return '';
  80. }
  81. }
  82. //查看事件
  83. $scope.goToIncident = function(){
  84. $state.go('app.incident.incidentDetail', {
  85. id: $scope.incidentDTO.id,
  86. });
  87. }
  88. // 撤销耗材
  89. $scope.removeHc = function(consumable){
  90. var modalInstance = $modal.open({
  91. templateUrl: "assets/views/delete.html",
  92. controller: function ($scope, $modalInstance) {
  93. $scope.title = "撤销";
  94. $scope.connect = "您确认要撤销此条耗材("+ consumable.consumableName + "【"+ consumable.consumablesNum +"】" +")的使用吗?";
  95. $scope.ok = function () {
  96. $modalInstance.close("start");
  97. };
  98. $scope.cancel = function () {
  99. $modalInstance.dismiss("cancel");
  100. };
  101. },
  102. size: "sm",
  103. });
  104. modalInstance.result.then(
  105. function (result) {
  106. if(result == 'start'){
  107. $rootScope.isMask = true;
  108. api_bpm_data.removeHc({
  109. summaryId: +$stateParams.id,
  110. remove: 'remove',
  111. consumableList: [
  112. {
  113. consumablesId: consumable.consumableId,
  114. consumablesNum: consumable.consumablesNum,
  115. }
  116. ]
  117. }).then(
  118. function (data) {
  119. $rootScope.isMask = false;
  120. $scope.getInfo();
  121. },
  122. function () {
  123. $rootScope.isMask = false;
  124. }
  125. );
  126. }
  127. },
  128. function () {}
  129. );
  130. }
  131. },
  132. ]);