techDemandCheckCtrl.js 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310
  1. angular.module('push')
  2. .controller('techDemandCheckCtrl', function ($scope, AccountService, $stateParams, UserService, $ionicPopup, dataToolsService, $ionicSlideBoxDelegate) {
  3. $scope.defaultLan = UserService.defaultLan;
  4. $scope.id = $stateParams.id;
  5. $scope.node = UserService.node;
  6. $scope.comefrom = $stateParams.comefrom;
  7. $scope.list = $stateParams.list;
  8. $scope.isBroker = false;
  9. $scope.permission1 = false;//公开
  10. $scope.permission2 = false;//技术经纪人可见
  11. $scope.permission3 = false;//高校院所专家可见
  12. $scope.permission4 = false;//私密
  13. $scope.cooperationmodelInfo = "";
  14. if ($scope.node == '330122000') {
  15. $scope.agree = 1;
  16. } else {
  17. $scope.agree = true;
  18. }
  19. $scope.checkData = {};
  20. $scope.checkShow = $stateParams.checkShow;
  21. $scope.resubmitData = {};
  22. //通过当前技术需求id获取当前的技术需求
  23. var getDemandInfo = function () {
  24. AccountService.getDemandInfo($stateParams.id).then(function (res) {
  25. if (res.code == 3350) {
  26. var data = res.data;
  27. $scope.projectname = data.projectname;
  28. $scope.capitalScale = data.capitalScale;
  29. $scope.contactor = data.contactor;
  30. $scope.tel = data.tel;
  31. $scope.photolist = data.photoList;
  32. $scope.taskintroduction = data.taskintroduction;
  33. $scope.cooperationmodelCHN = data.cooperationmodelCHN;
  34. $scope.tonglucheckstatus = data.tonglucheckstatus;
  35. $scope.refusereason = data.refusereason;
  36. $scope.node = data.node;
  37. $scope.permissionvalue = data.permissionvalue;
  38. var splitArr = [];
  39. if($scope.permissionvalue == 1 || $scope.permissionvalue == 2 || $scope.permissionvalue == 3 ||
  40. $scope.permissionvalue == 4 || $scope.permissionvalue == 5){
  41. splitArr.push($scope.permissionvalue);
  42. }else if($scope.permissionvalue != null){
  43. splitArr = $scope.permissionvalue.split(',');
  44. }else{
  45. splitArr.push(1);
  46. }
  47. for (var i = 0; i < splitArr.length; i++) {
  48. if (splitArr[i] == 1) {
  49. $scope.permission1 = true;
  50. }
  51. if (splitArr[i] == 2) {
  52. $scope.permission2 = true;
  53. }
  54. if (splitArr[i] == 3) {
  55. $scope.permission3 = true;
  56. }
  57. if (splitArr[i] == 4) {
  58. $scope.permission4 = true;
  59. }
  60. }
  61. var cooperationmodel = data.cooperationmodel;
  62. if (cooperationmodel != null && cooperationmodel != "") {
  63. dataToolsService.getCooperationmodelByCode(cooperationmodel).then(function (newRes) {
  64. if (newRes.code == 3350) {
  65. $scope.cooperationmodelInfo = newRes.data;
  66. }
  67. })
  68. }
  69. //判断创建者是不是技术经纪人
  70. dataToolsService.judgeUserBroker(data.creator).then(function (isBrokerRes) {
  71. if (isBrokerRes.code == 3350) {
  72. $scope.isBroker = isBrokerRes.data;
  73. if (isBrokerRes.data) {
  74. //当前用户是技术经纪人
  75. AccountService.getUserCheckInfo(data.creator).then(function (response) {
  76. if (response.code == 3350) {
  77. var user = response.data;
  78. $scope.contactor = user.applyname;
  79. $scope.tel = user.tel;
  80. }
  81. });
  82. }
  83. AccountService.getCompanyById(data.companyid).then(function (nameRes) {
  84. if (res.code == 3350) {
  85. $scope.companyName = nameRes.data;
  86. AccountService.getUserNameById(data.creator).then(function (userRes) {
  87. if (res.code == 3350) {
  88. $scope.userName = userRes.data;
  89. }
  90. });
  91. }
  92. });
  93. }
  94. });
  95. }
  96. });
  97. }
  98. getDemandInfo();
  99. //点击图片放大
  100. $scope.bigImage = false; //初始默认大图是隐藏的
  101. $scope.hideBigImage = function () {
  102. $scope.bigImage = false;
  103. };
  104. $scope.shouBigImage = function (index) { //传递一个参数(图片的URl)
  105. if ($scope.app) {
  106. $scope.setStatusBar(1);
  107. }
  108. $scope.bigImage = true; //显示大图
  109. $(function () {
  110. $('div.pinch-zoom').each(function () {
  111. new RTP.PinchZoom($(this), {});
  112. });
  113. });
  114. $ionicSlideBoxDelegate.update();//重绘,让图片显示出来
  115. //图片总数量
  116. setTimeout(function () {
  117. // console.log(parseInt($ionicSlideBoxDelegate.slidesCount()));
  118. // console.log(parseInt($ionicSlideBoxDelegate.currentIndex()));
  119. $ionicSlideBoxDelegate.$getByHandle('slide_detail').slide(index, 0);
  120. //获取图片
  121. var imgObj = document.getElementsByClassName('bigimage');
  122. var n;
  123. for (n = 0; n < imgObj.length; n++) {
  124. // 获取图片的原始高度和宽度
  125. var oldWid = imgObj[n].naturalWidth;
  126. var oldHei = imgObj[n].naturalHeight;
  127. var screen = document.body.offsetWidth;
  128. var screenH = window.innerHeight;
  129. // console.log(oldWid/oldHei);
  130. // console.log(screen );
  131. var rate = oldWid / oldHei;
  132. if (oldWid >= screen && oldHei >= screenH) {
  133. var tw = screen;
  134. var th = tw / rate;
  135. if (th < screenH) {
  136. imgObj[n].style.width = tw + 'px';
  137. imgObj[n].style.height = th + 'px';
  138. imgObj[n].style.marginTop = (screenH - th) / 2 + 'px';
  139. } else {
  140. imgObj[n].style.width = screenH * rate + 'px';
  141. imgObj[n].style.height = screenH + 'px';
  142. imgObj[n].style.marginLeft = (screen - screenH * rate) / 2 + 'px';
  143. }
  144. } else if (oldWid >= screen && oldHei <= screenH) {
  145. imgObj[n].style.width = screen + 'px';
  146. imgObj[n].style.height = screen / rate + 'px';
  147. imgObj[n].style.marginTop = (screenH - screen / rate) / 2 + 'px';
  148. } else if (oldWid <= screen && oldHei >= screenH) {
  149. // var hh=screenH;
  150. // var ww=screenH*rate;
  151. imgObj[n].style.width = screenH * rate + 'px';
  152. imgObj[n].style.height = screenH + 'px';
  153. imgObj[n].style.marginLeft = (screen - screenH * rate) / 2 + 'px';
  154. } else {
  155. imgObj[n].style.width = oldWid + 'px';
  156. imgObj[n].style.height = oldHei + 'px';
  157. imgObj[n].style.marginLeft = (screen - oldWid) / 2 + 'px';
  158. imgObj[n].style.marginTop = (screenH - oldHei) / 2 + 'px';
  159. }
  160. }
  161. }, 500);
  162. };
  163. $scope.agreeClick = function () {
  164. if ($scope.node == '330122000') {
  165. $scope.agree = 1;
  166. } else {
  167. $scope.agree = true;
  168. }
  169. }
  170. $scope.rollClick = function () {
  171. $scope.agree = -2;
  172. }
  173. $scope.rejectClick = function () {
  174. if ($scope.node == '330122000') {
  175. $scope.agree = -1;
  176. } else {
  177. $scope.agree = false;
  178. }
  179. }
  180. //需求审核
  181. $scope.checkDemand = function (id) {
  182. if ($scope.node != '330122000') {
  183. if ($scope.agree) {
  184. var value = 1;
  185. } else {
  186. var value = -1
  187. }
  188. }
  189. if ($scope.node == '330122000') {
  190. if ($scope.agree == 1) {
  191. var value = 1;
  192. }
  193. if ($scope.agree == -1) {
  194. var value = -1
  195. }
  196. if ($scope.agree == -2) {
  197. var value = -2
  198. }
  199. }
  200. if (value == -1 || value == -2) {
  201. if ($scope.checkData.refusereason == "" || $scope.checkData.refusereason == null) {
  202. if (value == -1) {
  203. $ionicPopup.alert({
  204. title: '确定',
  205. template: '请填写拒绝理由'
  206. });
  207. }
  208. if (value == -2) {
  209. $ionicPopup.alert({
  210. title: '确定',
  211. template: '请填写退回理由'
  212. });
  213. }
  214. return;
  215. }
  216. }
  217. AccountService.checkTechDemand(value, id, $scope.checkData.refusereason).then(function (res) {
  218. if (res.code == 3350) {
  219. $scope.go('techDemandDetail');
  220. }
  221. })
  222. }
  223. $scope.checkDemandAgain = function (list, demandId) {
  224. list.infoSectionList = [];
  225. list.infoSectionList[0] = {};
  226. list.infoSectionList[0].unitlist = [];
  227. if ($scope.projectname) {
  228. var value = {};
  229. value.tcname = "projectname";
  230. value.content = $scope.projectname;
  231. list.infoSectionList[0].unitlist.push(value);
  232. }
  233. if ($scope.capitalScale) {
  234. var value = {};
  235. value.tcname = "capitalScale";
  236. value.content = $scope.capitalScale;
  237. list.infoSectionList[0].unitlist.push(value);
  238. }
  239. if ($scope.contactor) {
  240. var value = {};
  241. value.tcname = "contactor";
  242. value.content = $scope.contactor;
  243. list.infoSectionList[0].unitlist.push(value);
  244. }
  245. if ($scope.tel) {
  246. var value = {};
  247. value.tcname = "tel";
  248. value.content = $scope.tel;
  249. list.infoSectionList[0].unitlist.push(value);
  250. list.tel = $scope.tel;
  251. }
  252. if ($scope.cooperationmodelInfo) {
  253. var value = {};
  254. value.tcname = "cooperationmodel";
  255. value.content = $scope.cooperationmodelInfo;
  256. list.infoSectionList[0].unitlist.push(value);
  257. }
  258. if ($scope.taskintroduction) {
  259. var value = {};
  260. value.tcname = "taskintroduction";
  261. value.content = $scope.taskintroduction;
  262. list.infoSectionList[0].unitlist.push(value);
  263. }
  264. if ($scope.companyName) {
  265. var value = {};
  266. value.tcname = "oid";
  267. value.content = $scope.companyName;
  268. list.infoSectionList[0].unitlist.push(value);
  269. }
  270. if ($scope.photolist) {
  271. var value = {};
  272. value = $scope.photolist;
  273. list.infoSectionList[0].unitlist.push(value);
  274. }
  275. list.baseInfoModel = {};
  276. list.baseInfoModel.oid = list.companyid;
  277. list.baseInfoModel.permission1 = $scope.permission1;
  278. list.baseInfoModel.permission2 = $scope.permission2;
  279. list.baseInfoModel.permission3 = $scope.permission3;
  280. list.baseInfoModel.permission4 = $scope.permission4;
  281. list.title = $scope.projectname;
  282. list.content = $scope.taskintroduction;
  283. list.photolist = $scope.photolist;
  284. //判断当前用户是不是技术经纪人
  285. dataToolsService.judgeUserBroker(UserService.id).then(function (res) {
  286. $scope.userIsBroker = false;
  287. if (res.code == 3350) {
  288. $scope.userIsBroker = res.data;
  289. }else{
  290. $scope.userIsBroker = false;
  291. }
  292. $scope.go('taskRelease', {data: list, userIsBroker: $scope.userIsBroker, demandId:demandId});
  293. })
  294. /*$scope.go('techDemandCheckAgain', {resubmitData: $scope.resubmitData});*/
  295. }
  296. })
  297. ;