cooperateDetailCtrl.js 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227
  1. angular.module('push')
  2. .controller('cooperateDetailCtrl', function ($scope, $ionicPopup, UserService, $ionicSlideBoxDelegate, $ionicActionSheet, AccountService, $stateParams, ResourceLibraryService, CommentService, UtilService, $timeout, CommonService,ConfigService,taskModuleService) {
  3. $scope.technicalcontractid = $stateParams.list.technicalcontractid;
  4. $scope.demandreward = $stateParams.list;
  5. $scope.agree = 1;
  6. $scope.checkData = {};
  7. //获取产学研补助审核时的图片
  8. $scope.imageList1 = [];
  9. $scope.imageList2 = [];
  10. $scope.imageList3 = [];
  11. $scope.imageList4 = [];
  12. $scope.imageList5 = [];
  13. $scope.hasAuth = false;
  14. ResourceLibraryService.judgeManager(UserService.id, 10501).then(function (res) {
  15. // console.log(res);
  16. $scope.hasAuth = res.data;
  17. })
  18. AccountService.getTechnicalContractList($scope.technicalcontractid).then(function (res) {
  19. if (res.code == 3350) {
  20. $scope.picturelist = res.data;
  21. console.log($scope.picturelist)
  22. angular.forEach($scope.picturelist, function(val){
  23. if(val.remark == "经技术合同登记的产学研合作合同(技术开发、技术转让、技术咨询、技术服务)"){
  24. $scope.imageList1.push(val)
  25. }
  26. if(val.remark == "发票"){
  27. $scope.imageList2.push(val)
  28. }
  29. if(val.remark == "支付凭证(银行转账凭证)"){
  30. $scope.imageList3.push(val)
  31. }
  32. if(val.remark == "结果凭证(结题报告、进度报告等)"){
  33. $scope.imageList4.push(val)
  34. }
  35. if(val.remark == "法定代表人授权委托书"){
  36. $scope.imageList5.push(val)
  37. }
  38. })
  39. }
  40. })
  41. $scope.agreeClick = function () {
  42. $scope.agree = 1;
  43. }
  44. $scope.rollClick = function () {
  45. $scope.agree = -1;
  46. }
  47. $scope.checkDemandReward = function () {
  48. if ($scope.agree == -1) {
  49. if ($scope.checkData.refusereason == "" || $scope.checkData.refusereason == null) {
  50. $ionicPopup.alert({
  51. title: '确定',
  52. template: '请填写拒绝理由'
  53. });
  54. return;
  55. }else {
  56. submit()
  57. }
  58. }else {
  59. $ionicPopup.confirm({
  60. title: '确定',
  61. template: ' <div class="list">\n' +
  62. ' <label class="item item-input">\n' +
  63. ' <span class="input-label">拟补助金额:</span>\n' +
  64. ' <span>{{data.by3}}</span>\n' +
  65. ' </label>\n' +
  66. ' <label class="item item-input">\n' +
  67. ' <span class="input-label">核定补助金额:</span>\n' +
  68. ' <input type="text" ng-model="data.rewardmoney">\n' +
  69. ' </label>\n' +
  70. ' </div>',
  71. scope: $scope,
  72. buttons: [{
  73. text: '取消',
  74. type: 'button-default',
  75. }, {
  76. text: '确定',
  77. type: 'button-positive',
  78. onTap: function(e) {
  79. if (!$scope.data.rewardmoney) {
  80. CommonService.showMessage("请填写核定补助金额", $scope);
  81. e.preventDefault();
  82. } else {
  83. console.log($scope.data)
  84. submit()
  85. }
  86. }
  87. }]
  88. });
  89. }
  90. }
  91. function submit(){
  92. console.log($scope.checkData.refusereason)
  93. AccountService.submitDemandReward($stateParams.list.id, $scope.agree, $scope.data.rewardmoney,$scope.checkData.refusereason).then(function (res) {
  94. if (res.code == 3350) {
  95. $scope.go('cooperationSubsidyCheck');
  96. }
  97. })
  98. }
  99. //通过technicalcontractid获取TechnicalContract数据
  100. ResourceLibraryService.getTechContractByContractid($scope.technicalcontractid).then(function (res) {
  101. console.log(res)
  102. if (res.code == 3350) {
  103. $scope.data = res.data;
  104. }
  105. })
  106. //重置失败状态,失败原因没有实际作用(仅仅便于调一个接口)
  107. $scope.checkDemandRewardAgain = function (demandreward) {
  108. var by2 = $stateParams.list.by2;
  109. AccountService.submitDemandReward($stateParams.list.id, 0, "1").then(function (res) {
  110. if (res.code == 3350) {
  111. $scope.go("toDeclare", {list: $scope.data, picturelist: $scope.picturelist, by2:by2});
  112. }
  113. })
  114. }
  115. $scope.hasAuth = false;
  116. ResourceLibraryService.judgeManager(UserService.id, 10501).then(function (res) {
  117. // console.log(res);
  118. $scope.hasAuth = res.data;
  119. })
  120. //打开操作表:设置/编辑
  121. $scope.openActionSheet = function (data) {
  122. // isedit:是否可以编辑资源,isset:是否可以设置权限
  123. var buttonlist = [];
  124. buttonlist.push({text: '导出附件zip'});
  125. // buttonlist.push({text: '导出'});
  126. if($scope.demandreward.demandstatus == 1){
  127. buttonlist.push({text: '共享'});
  128. }
  129. if($scope.demandreward.demandstatus == 0){
  130. buttonlist.push({text: '修改'});
  131. }
  132. // else if($scope.demandreward.demandstatus == 8 || $scope.demandreward.demandstatus == 9){
  133. //
  134. // }else {
  135. // }
  136. $ionicActionSheet.show({
  137. buttons: buttonlist,
  138. cancelText: '取消',
  139. buttonClicked: function (index) {
  140. if (buttonlist[index].text == '导出') {
  141. //产学研补助导出功能
  142. taskModuleService.exportCooperationReport(data).then(function (res) {
  143. if (res.code == 3350) {
  144. var file = res.data;
  145. window.open(ConfigService.imgurl + file.sourceName);
  146. return;
  147. } else {
  148. $ionicPopup.alert({
  149. title: '提示',
  150. template: '导出失败!'
  151. })
  152. return;
  153. }
  154. })
  155. return true;
  156. }
  157. if (buttonlist[index].text == '共享') {
  158. taskModuleService.shareCooperationReport($scope.demandreward.id).then(function (res) {
  159. if (res.code == 3350) {
  160. $ionicPopup.alert({
  161. title: '提示',
  162. template: '共享成功!'
  163. })
  164. $scope.go('cooperationSubsidyCheck');
  165. } else {
  166. $ionicPopup.alert({
  167. title: '提示',
  168. template: '共享失败!'
  169. })
  170. return;
  171. }
  172. })
  173. return true;
  174. }
  175. if (buttonlist[index].text == '共享') {
  176. $scope.go("toDeclare", {list: $scope.data, picturelist: $scope.picturelist, by2: 'subsidy'});
  177. }
  178. if (buttonlist[index].text == '导出附件zip') {
  179. var param=[]
  180. console.log($scope.picturelist)
  181. $scope.picturelist.forEach(function (row) {
  182. param.push(ConfigService.imgurl + row.sourceName)
  183. })
  184. $scope.showLoadingToast()
  185. console.log(param)
  186. taskModuleService.usertaskzipsubsidies(param).then(function (res) {
  187. console.log(res)
  188. $scope.hideLoadingToast()
  189. var aEle = document.createElement("a");// 创建a标签
  190. var blob = new Blob([res],{type: "application/zip"});
  191. // aEle.download = item.modelName;// 设置下载文件的文件名
  192. aEle.href = URL.createObjectURL(blob);
  193. aEle.click();// 设置点击事件
  194. })
  195. }
  196. if (buttonlist[index].text == '修改') {
  197. console.log($stateParams.list)
  198. $scope.go("toDeclare", {list: JSON.stringify($stateParams.list)});
  199. }
  200. }
  201. });
  202. };
  203. $scope.bigImage = false; //初始默认大图是隐藏的
  204. $scope.hideBigImage = function () {
  205. if ($scope.app) {
  206. $scope.setStatusBar(0);
  207. }
  208. $scope.bigImage = false;
  209. }
  210. $scope.shouBigImage = function (piclist, index) { //传递一个参数(图片的URl)
  211. window.open(ConfigService.imgurl + piclist[index].sourceName);
  212. return;
  213. };
  214. });