activityChooseCompanyCtrl.js 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. angular.module('push')
  2. .controller('activityChooseCompanyCtrl', function ($scope, $stateParams, ActivityService, UtilService, $timeout) {
  3. /* $scope.setStatusBar(1);*/
  4. var activityid = $stateParams.activityid;
  5. var getIntentionStatus = function () {
  6. $scope.showLoadingToast();
  7. ActivityService.getIntentionStatus(activityid).then(function (response) {
  8. // console.log(response);
  9. // result 0未选择 1已选择
  10. $scope.intentionstatus = response.result;
  11. getSelCompanyInfo();
  12. }, function () {
  13. $scope.hideLoadingToast();
  14. $scope.hideLoadingToast();
  15. })
  16. };
  17. getIntentionStatus();
  18. // 获取参与企业列表
  19. var getSelCompanyInfo = function () {
  20. ActivityService.getSelCompanyInfo(" ", activityid).then(function (response) {
  21. // issuccess 0,1 专家单向选企业 2 双方互相选择 3 专家单向选企业 4 政府删除配对
  22. $scope.companylist = response.company;
  23. $scope.hideLoadingToast();
  24. }, function () {
  25. $scope.hideLoadingToast();
  26. })
  27. };
  28. // 记录选中列表索引
  29. var indexlist = [];
  30. $scope.selectedLength = 0;
  31. // 选择企业
  32. $scope.selectOrgType = function (companyid, index) {
  33. if ($scope.intentionstatus != 0) {
  34. return;
  35. }
  36. if ($scope.companylist[index].isChecked) {
  37. var ind = indexlist.indexOf(index);
  38. indexlist.splice(ind);
  39. } else {
  40. indexlist.push(companyid);
  41. }
  42. $scope.companylist[index].isChecked = !$scope.companylist[index].isChecked;
  43. $scope.selectedLength = indexlist.length;
  44. };
  45. // 提交企业
  46. $scope.submitCompany = function () {
  47. $scope.showLoadingToast();
  48. var idlist = indexlist.join(",");
  49. // console.log(idlist);
  50. ActivityService.submitSelCompanyInfo(activityid, idlist).then(function (response) {
  51. // console.log(response);
  52. if (response.result == 1) {
  53. UtilService.showMess("提交成功!");
  54. $timeout(function () {
  55. $scope.goback();
  56. }, 1000);
  57. }
  58. $scope.hideLoadingToast();
  59. }, function () {
  60. $scope.hideLoadingToast();
  61. })
  62. };
  63. $scope.goDetail = function (companyid) {
  64. $scope.go("activityCompanyListContent", {companyid: companyid});
  65. };
  66. });