app.js 105 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808
  1. /**
  2. * index
  3. *
  4. */
  5. define([ 'angularAMD', 'ui.router', 'ui-bootstrap', 'ngLocal', 'ngTable', 'file-upload', 'common/directives', 'common/services', 'toaster', 'ngSanitize', 'services/Project', 'services/Activity', 'services/Organization', 'ui-form'], function(angularAMD) {
  6. 'use strict';
  7. var app = angular.module('myApp', [ 'ui.router', 'ui.bootstrap', 'ng.local', 'ngTable', 'angularFileUpload', 'common.directives', 'common.services', 'toaster', 'ngSanitize', 'ProjectService', 'ActivityService', 'OrganizationService', 'ui.form']);
  8. app.init = function() {
  9. angularAMD.bootstrap(app);
  10. };
  11. app.config(['$httpProvider', function ($httpProvider) {
  12. // http拦截
  13. $httpProvider.interceptors.push('httpInterceptor');
  14. }]);
  15. app.factory('httpInterceptor', ['$window', '$q', '$injector', 'BaseService', function ($window, $q, $injector, BaseService) {
  16. var httpInterceptor = {
  17. 'responseError': function (response) {
  18. if (response.status == 401) {// UNAUTHORIZED
  19. window.location.href = response.data.loginUrl || 'index';
  20. return $q.reject(response);
  21. }
  22. return $q.reject(response);
  23. }
  24. }
  25. return httpInterceptor;
  26. }]);
  27. app.config(['$stateProvider', '$urlRouterProvider', function($stateProvider, $urlRouterProvider) {
  28. $urlRouterProvider.otherwise("/");
  29. $stateProvider.state("project", {
  30. url : '/',
  31. title : '项目列表',
  32. templateUrl : 'static/view/project/project_list.html',
  33. controller : 'ProjectListCtrl'
  34. }).state("launchProject1", {
  35. url : '/launchProject/baseInfo',
  36. title : '项目发起1',
  37. templateUrl : 'static/view/project/project_launch_1.html',
  38. controller : 'ProjectNewCtrl'
  39. }).state("launchProject2", {
  40. url : '/launchProject/detail/:id',
  41. title : '项目发起2',
  42. templateUrl : 'static/view/project/project_launch_2.html',
  43. controller : 'ProjectNewCtrl'
  44. }).state("launchProjectSuccess", {
  45. url : '/launchProject/success',
  46. title : '项目发起完成',
  47. templateUrl : 'static/view/project/project_launch_3.html',
  48. controller : 'ProjectNewCtrl'
  49. }).state("projectFinance", {
  50. url : '/project/finance',
  51. title : '项目财务披露',
  52. templateUrl : 'static/view/project/project_list_finance.html',
  53. controller : 'ProjectFinanceListCtrl'
  54. }).state("projectReport", {
  55. url : '/project/report',
  56. title : '项目报告',
  57. templateUrl : 'static/view/project/project_list_report.html',
  58. controller : 'ProjectReportListCtrl'
  59. }).state("projectManagement", {
  60. url : '/project/management',
  61. title : '项目结项管理',
  62. templateUrl : 'static/view/project/project_list_management.html',
  63. controller : 'ProjectManagementListCtrl'
  64. }).state("activityList", {
  65. url : '/activity',
  66. title : '活动列表',
  67. templateUrl : 'static/view/activity/activity_list.html',
  68. controller : 'ActivityListCtrl'
  69. }).state("launchActivity", {
  70. url : '/launchActivity',
  71. title : '发起活动',
  72. templateUrl : 'static/view/activity/activity_launch.html',
  73. controller : 'ActivityNewCtrl'
  74. }).state("selectInstitutionsNature", {
  75. url : '/selectInstitutionsNature',
  76. title : '机构入驻选择',
  77. templateUrl : 'static/view/user/selectInstitutionsNature.html',
  78. controller : 'SelectInstitutionsNatureCtrl'
  79. }).state("charityCertificationStep0", {
  80. url : '/charityCertificationStep0',
  81. title : '公益机构认证协议',
  82. templateUrl : 'static/view/user/charityCertification.html',
  83. controller : 'CertificationStep0Ctrl'
  84. }).state("charityCertificationStep1", {
  85. url : '/charityCertificationStep1',
  86. title : '公益机构认证第一步',
  87. templateUrl : 'static/view/user/charityCertification1.html',
  88. controller : 'CertificationStep1Ctrl'
  89. }).state("charityCertificationStep2", {
  90. url : '/charityCertificationStep2',
  91. title : '公益机构认证第二步',
  92. templateUrl : 'static/view/user/charityCertification2.html',
  93. controller : 'CertificationStep2Ctrl'
  94. }).state("charityCertificationStep3", {
  95. url : '/charityCertificationStep3',
  96. title : '公益机构认证第三步',
  97. templateUrl : 'static/view/user/charityCertification3.html',
  98. controller : 'CertificationStep3Ctrl'
  99. }).state("charityCertificationStep4", {
  100. url : '/charityCertificationStep4',
  101. title : '公益机构认证完成',
  102. templateUrl : 'static/view/user/charityCertification4.html',
  103. controller : 'CertificationStep4Ctrl'
  104. }).state("publicOfferingCertificationStep0", {
  105. url : '/publicOfferingCertificationStep0',
  106. title : '公募机构认证协议',
  107. templateUrl : 'static/view/user/publicOfferingCertification.html',
  108. controller : 'CertificationStep0Ctrl'
  109. }).state("publicOfferingCertificationStep1", {
  110. url : '/publicOfferingCertificationStep1',
  111. title : '公募机构认证第一步',
  112. templateUrl : 'static/view/user/publicOfferingCertification1.html',
  113. controller : 'CertificationStep1Ctrl'
  114. }).state("publicOfferingCertificationStep2", {
  115. url : '/publicOfferingCertificationStep2',
  116. title : '公募机构认证第二步',
  117. templateUrl : 'static/view/user/publicOfferingCertification2.html',
  118. controller : 'CertificationStep2Ctrl'
  119. }).state("publicOfferingCertificationStep3", {
  120. url : '/publicOfferingCertificationStep3',
  121. title : '公募机构认证第三步',
  122. templateUrl : 'static/view/user/publicOfferingCertification3.html',
  123. controller : 'CertificationStep3Ctrl'
  124. }).state("publicOfferingCertificationStep4", {
  125. url : '/publicOfferingCertificationStep4',
  126. title : '公募机构认证第四步',
  127. templateUrl : 'static/view/user/publicOfferingCertification4.html',
  128. controller : 'PublicCertificationStep4Ctrl'
  129. }).state("publicOfferingCertificationStep5", {
  130. url : '/publicOfferingCertificationStep5',
  131. title : '公益机构认证完成',
  132. templateUrl : 'static/view/user/publicOfferingCertification5.html',
  133. controller : 'charityCertificationStep4Ctrl'
  134. }).state("organizationList", {
  135. url : '/organization/list',
  136. title : '机构列表',
  137. templateUrl : 'static/view/user/organization_list.html',
  138. controller : 'OrgListCtrl'
  139. }).state("userList", {
  140. url : '/user/list',
  141. title : '用户列表',
  142. templateUrl : 'static/view/user/user_list.html',
  143. controller : 'UserListCtrl'
  144. });
  145. }]);
  146. // html转义
  147. var htmlEncode = function(sHtml) {
  148. return sHtml.replace(/[<>&"]/g,function(c){return {'<':'&lt;','>':'&gt;','&':'&amp;','"':'&quot;'}[c];});
  149. };
  150. var getObjectURL = function (file) {
  151. var url = null;
  152. if (window.createObjectURL != undefined) { // basic
  153. url = window.createObjectURL(file);
  154. } else if (window.URL != undefined) { // mozilla(firefox)
  155. url = window.URL.createObjectURL(file);
  156. } else if (window.webkitURL != undefined) { // webkit or chrome
  157. url = window.webkitURL.createObjectURL(file);
  158. }
  159. return url;
  160. };
  161. app.controller('AuthCtrl', ['$scope', '$window', 'AuthenticationService', 'toaster', 'BaseService', '$modal', 'SessionService',
  162. function ($scope, $window, AuthenticationService, toaster, BaseService, $modal, SessionService) {
  163. $scope.isAuthed = AuthenticationService.isAuthed(); //AuthenticationService模块在common/下
  164. AuthenticationService.getAuthentication().success(function (data) {
  165. if (data.content) {
  166. $scope.userInfo = data.content;
  167. }
  168. if (data == null || !data.content) {
  169. $scope.isAuthed = false;
  170. AuthenticationService.redirectSignin();
  171. }
  172. });
  173. $scope.logout = function() {
  174. AuthenticationService.logout().success(function() {
  175. SessionService.removeCookie($rootScope.userInfo.userUU);
  176. });
  177. };
  178. // $scope.logout = function () {
  179. // $modal.open({
  180. // templateUrl: 'static/view/user/logout.html',
  181. // controller: 'LogOutCtrl'
  182. // }).result.then(function (s) {
  183. // if (s) {
  184. // AuthenticationService.logout();
  185. // }
  186. // });
  187. // };
  188. }]);
  189. app.controller('LogOutCtrl', ['$scope', '$modalInstance', function ($scope, $modalInstance) {
  190. $scope.close = function (confirm) {
  191. $modalInstance.close(confirm);
  192. };
  193. }]);
  194. /**
  195. * 项目列表
  196. */
  197. app.controller('ProjectListCtrl', ['$scope', '$rootScope', 'toaster', 'ngTableParams', 'BaseService', 'Project', '$modal',
  198. function ($scope, $rootScope, toaster, ngTableParams, BaseService, Project, $modal) {
  199. BaseService.scrollBackToTop();
  200. var getProjectState = function (active) {
  201. var fn = 'getAudited';
  202. switch (active) {
  203. // 已审核
  204. case 'audited':
  205. fn = 'getAudited';
  206. break;
  207. // 未审核
  208. case 'unaudited':
  209. fn = 'getUnaudited';
  210. break;
  211. // 未通过
  212. case 'disagreed':
  213. fn = 'getDisagreed';
  214. break;
  215. }
  216. return fn;
  217. };
  218. $scope.active = 'audited';
  219. if ($rootScope.active) {
  220. $scope.active = $rootScope.active;
  221. }
  222. $scope.keyword = '';
  223. /**
  224. * 修改分类
  225. * @param value
  226. */
  227. $scope.setState = function (value) {
  228. if ($scope.active != value) {
  229. $scope.active = value;
  230. if ($scope.projectParams.page() == 1)
  231. $scope.projectParams.reload();
  232. else
  233. $scope.projectParams.page(1);
  234. }
  235. };
  236. /**
  237. * 修改领域
  238. * @param value
  239. */
  240. $scope.setArea = function (value) {
  241. if ($scope.selectedArea != value) {
  242. $scope.selectedArea = value;
  243. if ($scope.projectParams.page() == 1)
  244. $scope.projectParams.reload();
  245. else
  246. $scope.projectParams.page(1);
  247. }
  248. };
  249. $scope.reload = function() {
  250. if ($scope.projectParams.page() == 1)
  251. $scope.projectParams.reload();
  252. else
  253. $scope.projectParams.page(1);
  254. };
  255. $scope.projectParams = new ngTableParams({
  256. page: 1,
  257. count: 10,
  258. sorting: {
  259. 'id': 'desc'
  260. }
  261. }, {
  262. total: 0,
  263. counts: [],
  264. getData: function ($defer, params) {
  265. $scope.loading = true;
  266. var pageParams = params.url();
  267. var realActive = {};
  268. pageParams.searchFilter = { // 筛选条件
  269. keyword: $scope.keyword,
  270. area: $scope.selectedArea
  271. };
  272. Project[getProjectState($scope.active)].call(null, BaseService.parseParams(pageParams), function (page) {
  273. $scope.loading = false;
  274. if (page) {
  275. params.total(page.totalElements);
  276. $defer.resolve(page.content);
  277. // $scope.keywordXls = angular.copy($scope.keyword); // 保存当前取值的关键词 做导出时需要的字段
  278. }
  279. }, function (response) {
  280. $scope.loading = false;
  281. toaster.pop('error', '数据加载失败', response.data);
  282. });
  283. }
  284. });
  285. var getNum = function() {
  286. Project.getProjectsNum({}, {}, function(data) {
  287. $scope.auditedNum = data.auditedNum;
  288. $scope.unauditedNum = data.unauditedNum;
  289. $scope.disagreedNum = data.disagreedNum;
  290. });
  291. };
  292. getNum();
  293. $scope.onSearch = function () {
  294. if ($scope.projectParams.page() == 1)
  295. $scope.projectParams.reload();
  296. else
  297. $scope.projectParams.page(1);
  298. };
  299. // $scope.onSearch = function (keyword) {
  300. // if (!angular.isUndefined(keyword)) {
  301. // $scope.keyword = keyword;
  302. // if ($scope.projectParams.page() == 1)
  303. // $scope.projectParams.reload();
  304. // else
  305. // $scope.projectParams.page(1);
  306. // }
  307. // };
  308. // 弹出详情页模态框
  309. $scope.showDetail = function (id) {
  310. var modalInstance = $modal.open({
  311. templateUrl: 'static/view/project/project_detail.html',
  312. controller: 'ProjectDetailCtrl',
  313. size: 'lg',
  314. resolve: {
  315. id: function () {
  316. return id;
  317. }
  318. }
  319. });
  320. modalInstance.result.then(function(data){
  321. if (data.success) {
  322. toaster.pop('success', '操作成功');
  323. }
  324. $scope.projectParams.reload();
  325. }, function(){
  326. });
  327. };
  328. }]);
  329. /**
  330. * 项目详情框
  331. */
  332. app.controller('ProjectDetailCtrl', ['$scope', 'Project', 'toaster', '$modalInstance', 'BaseService', 'id', '$modal', '$sce', 'ngTableParams',
  333. function($scope, Project, toaster, $modalInstance, BaseService, id, $modal, $sce, ngTableParams) {
  334. var loadData = function() {
  335. // 获取项目详情
  336. Project.getDetailById({id :id}, {}, function(data) {
  337. $scope.project = data;
  338. $scope.code = $sce.trustAsHtml($scope.project.introduction);
  339. }, function() {
  340. toaster.pop('error', '详情加载失败');
  341. });
  342. };
  343. loadData();
  344. // 获取当前项目所有进度
  345. $scope.getSchedules = function() {
  346. Project.getSchedules({id : id}, {}, function(data) {
  347. $scope.schedules = data;
  348. }, function() {
  349. toaster.pop('error', '项目进度加载失败');
  350. });
  351. };
  352. // 获取当前项目捐款明细
  353. // $scope.getRecords = function() {
  354. // Project.getRecords({proId:id}, {}, function(data) {
  355. // $scope.projectRecords = data;
  356. // }, function() {
  357. // toaster.pop('error', '捐款明细加载失败');
  358. // });
  359. // };
  360. $scope.recordParams = new ngTableParams({
  361. page: 1,
  362. count: 5,
  363. sorting: {
  364. 'id': 'desc'
  365. }
  366. }, {
  367. total: 0,
  368. counts: [],
  369. getData: function ($defer, params) {
  370. $scope.loading = true;
  371. var pageParams = params.url();
  372. pageParams.searchFilter = { // 筛选条件
  373. keyword: $scope.keyword,
  374. // 此处area作为支付方式过滤
  375. area: $scope.way,
  376. fromDate : null !== $scope.fromDate ? $scope.fromDate.getTime(): null,
  377. // proId过滤
  378. type: id
  379. };
  380. Project.getRecordsPage.call(null, BaseService.parseParams(pageParams), function (page) {
  381. $scope.loading = false;
  382. if (page) {
  383. params.total(page.totalElements);
  384. $defer.resolve(page.content);
  385. // $scope.keywordXls = angular.copy($scope.keyword); // 保存当前取值的关键词 做导出时需要的字段
  386. }
  387. }, function (response) {
  388. $scope.loading = false;
  389. toaster.pop('error', '数据加载失败', response.data);
  390. });
  391. }
  392. });
  393. // 搜索
  394. $scope.onSearch = function() {
  395. if ($scope.recordParams.page() === 1) {
  396. $scope.recordParams.reload();
  397. } else {
  398. $scope.recordParams.page(1);
  399. }
  400. };
  401. $scope.fromDate = null;
  402. $scope.setTime = function(type) {
  403. var fromDate = new Date();
  404. fromDate.setHours(0, 0, 0, 0);
  405. switch (type) {
  406. // 一周内
  407. case '7' :
  408. fromDate.setDate(fromDate.getDate() - 7) ;
  409. $scope.fromDate = fromDate;
  410. break;
  411. // 一个月内
  412. case '1' :
  413. fromDate.setMonth(fromDate.getMonth() - 1) ;
  414. $scope.fromDate = fromDate;
  415. break;
  416. // 三个月内
  417. case '3' :
  418. fromDate.setMonth(fromDate.getMonth() - 3) ;
  419. $scope.fromDate = fromDate;
  420. break;
  421. // 半年内
  422. case '6' :
  423. fromDate.setMonth(fromDate.getMonth() - 6) ;
  424. $scope.fromDate = fromDate;
  425. break;
  426. }
  427. $scope.recordParams.reload();
  428. };
  429. // 获取当前项目财务信息
  430. $scope.getFinance = function() {
  431. Project.getFinance({id:id}, {}, function(data) {
  432. $scope.projectFinance = data.projectFinance;
  433. $scope.totalCost = data.totalCost;
  434. $scope.executeCost = data.executeCost;
  435. $scope.projectCost = data.projectCost;
  436. }, function() {
  437. toaster.pop('error','财务明细加载失败');
  438. });
  439. };
  440. $scope.cancel= function() {
  441. $modalInstance.dismiss();
  442. };
  443. $scope.deleteSchedule = function(scheduleId) {
  444. Project.deleteSchedule({id: scheduleId}, {}, function() {
  445. toaster.pop('success', '操作成功');
  446. // 重新加载
  447. $scope.getSchedules();
  448. }, function() {
  449. toaster.pop('error', '出现错误,操作失败');
  450. });
  451. };
  452. // true通过 false驳回
  453. $scope.decide = function(type) {
  454. var modalInstance = $modal.open({
  455. animation: true,
  456. templateUrl: 'static/view/project/audit_confirm.html',
  457. controller: 'AuditConfirmCtrl',
  458. resolve: {
  459. project : function() {
  460. return $scope.project;
  461. },
  462. type : function() {
  463. return type;
  464. }
  465. }
  466. });
  467. modalInstance.result.then(function(data){
  468. if (data.success) {
  469. toaster.pop('success','操作成功');
  470. }
  471. if (data.error) {
  472. toaster.pop('error','操作失败');
  473. }
  474. $modalInstance.close();
  475. }, function(){
  476. });
  477. };
  478. // 重新申请
  479. $scope.reapply = function() {
  480. Project.reapply({id:id}, {}, function(data) {
  481. if (data.success) {
  482. toaster.pop('success', '重新申请成功');
  483. }
  484. if (data.error) {
  485. toaster.pop('error', '申请失败,请联系管理员');
  486. }
  487. $modalInstance.close();
  488. }, function(response) {
  489. toaster("error", "出现错误");
  490. });
  491. }
  492. }]);
  493. /**
  494. * 审核确认框
  495. */
  496. app.controller('AuditConfirmCtrl', ['$scope', 'project', 'type', '$modalInstance', 'toaster', 'Project',
  497. function($scope, project, type, $modalInstance, toaster, Project) {
  498. $scope.result = type;
  499. $scope.project = project;
  500. $scope.ok = function (type) {
  501. if (type) {
  502. Project.agree({id: project.id}, {}, function(data) {
  503. $modalInstance.close(data);
  504. }, function() {
  505. });
  506. } else {
  507. Project.disagree({id: project.id, refuse: project.refuse}, {}, function(data) {
  508. $modalInstance.close(data);
  509. }, function() {
  510. });
  511. }
  512. };
  513. $scope.cancel = function() {
  514. $modalInstance.dismiss();
  515. };
  516. }]);
  517. /**
  518. * 机构入驻选择
  519. */
  520. app.controller('SelectInstitutionsNatureCtrl', ['$scope', 'toaster', 'Organization', '$location',
  521. function ($scope, toaster, Organization, $location) {
  522. // 获取当前账户注册机构情况
  523. Organization.getByUuid({uuid : 222222}, {}, function(data) {//10041558
  524. $scope.org = data;
  525. }, function() {
  526. toaster.pop('error', '注册情况加载失败');
  527. });
  528. //公益机构注册
  529. $scope.registerCharityCertification = function () {
  530. if (typeof $scope.org.id == 'undefined') {
  531. $location.path('charityCertificationStep0');
  532. } else {
  533. if ($scope.org.type == 2) {
  534. //之前已填写过公益机构注册信息
  535. if ($scope.org.publish != 2) {
  536. //未完成或保存为草稿
  537. $location.path('charityCertificationStep1');
  538. } else {
  539. //发布正式
  540. if ($scope.org.status == 0) {
  541. //已发布待审核 (暂时)
  542. $location.path('charityCertificationStep4');
  543. } else if ($scope.org.status == 1) {
  544. //已发布已审核
  545. $location.path('charityCertificationStep4');
  546. } else if ($scope.org.status == 2) {
  547. //已发布已驳回
  548. $location.path('charityCertificationStep1');
  549. }
  550. }
  551. } else if ($scope.org.type == 1) {
  552. //之前填写过公募机构注册信息
  553. if ($scope.org.publish != 2) {
  554. //未完成或保存为草稿
  555. //TODO 模态框判断
  556. var decideContinue = false;
  557. if (decideContinue) {
  558. //TODO 继续注册公益机构并替换掉之前的公募机构注册信息
  559. $location.path('charityCertificationStep0');
  560. } else {
  561. //TODO 继续之前的公募机构注册信息
  562. toaster.pop('info', '继续之前的公募机构注册信息');
  563. $location.path('publicOfferingCertificationStep1');
  564. }
  565. } else {
  566. //发布正式
  567. if ($scope.org.status == 0) {
  568. //已发布待审核 (暂时)
  569. $location.path('publicOfferingCertificationStep5');
  570. } else if ($scope.org.status == 1) {
  571. //已发布已审核
  572. $location.path('publicOfferingCertificationStep5');
  573. } else if ($scope.org.status == 2) {
  574. //已发布已驳回
  575. $location.path('publicOfferingCertificationStep1');
  576. }
  577. }
  578. }
  579. }
  580. }
  581. //公募机构注册
  582. $scope.registerPublicOfferingCertification = function () {
  583. if (typeof $scope.org.id == 'undefined') {
  584. $location.path('publicOfferingCertificationStep0');
  585. } else {
  586. if ($scope.org.type == 1) {
  587. //之前已填写过公募机构注册信息
  588. if ($scope.org.publish != 2) {
  589. //未完成或保存为草稿
  590. $location.path('publicOfferingCertificationStep1');
  591. } else {
  592. //发布正式
  593. if ($scope.org.status == 0) {
  594. //已发布待审核 (暂时)
  595. $location.path('publicOfferingCertificationStep5');
  596. } else if ($scope.org.status == 1) {
  597. //已发布已审核
  598. $location.path('publicOfferingCertificationStep5');
  599. } else if ($scope.org.status == 2) {
  600. //已发布已驳回
  601. $location.path('publicOfferingCertificationStep1');
  602. }
  603. }
  604. } else if ($scope.org.type == 2) {
  605. //之前填写过公益机构注册信息
  606. if ($scope.org.publish != 2) {
  607. //未完成或保存为草稿
  608. //TODO 模态框判断
  609. var decideContinue = false;
  610. if (decideContinue) {
  611. //TODO 继续注册公募机构并替换掉之前的公益机构注册信息
  612. $location.path('publicOfferingCertificationStep0');
  613. } else {
  614. //TODO 继续之前的公益机构注册信息
  615. toaster.pop('info', '继续之前的公益机构注册信息');
  616. $location.path('charityCertificationStep1');
  617. }
  618. } else {
  619. //发布正式
  620. if ($scope.org.status == 0) {
  621. //已发布待审核 (暂时)
  622. $location.path('charityCertificationStep4');
  623. } else if ($scope.org.status == 1) {
  624. //已发布已审核
  625. $location.path('charityCertificationStep4');
  626. } else if ($scope.org.status == 2) {
  627. //已发布已驳回
  628. $location.path('charityCertificationStep1');
  629. }
  630. }
  631. }
  632. }
  633. }
  634. }]);
  635. /**
  636. * 机构入驻同意协议
  637. */
  638. app.controller('CertificationStep0Ctrl', ['$scope', 'toaster', 'Organization', '$location',
  639. function ($scope, toaster, Organization, $location) {
  640. $scope.checked = true;
  641. $scope.changeChecked = function() {
  642. $scope.checked = !$scope.checked;
  643. };
  644. $scope.stepNext = function (checked, orgType) {
  645. if (checked) {
  646. if (orgType == 1) {
  647. $location.path('publicOfferingCertificationStep1');
  648. } else if (orgType == 2) {
  649. $location.path('charityCertificationStep1');
  650. }
  651. }
  652. }
  653. // 获取当前账户注册机构情况
  654. Organization.getByUuid({uuid : 222222}, {}, function(data) {//10041558
  655. if (typeof data.id == 'undefined') {
  656. return;
  657. }
  658. $scope.checked = true;
  659. }, function() {
  660. toaster.pop('error', '注册情况加载失败');
  661. });
  662. }]);
  663. /**
  664. * 机构认证第一步
  665. */
  666. app.controller('CertificationStep1Ctrl', ['$scope', '$http', '$rootScope', '$timeout', '$location', 'toaster', 'Organization',
  667. function ($scope, $http, $rootScope, $timeout, $location, toaster, Organization) {
  668. // 主要领域
  669. // $scope.areas = ['疾病援助', '扶贫/救灾', '教育/助学' , '环境/动物保护', '其他'];
  670. $scope.org = {
  671. majorArea: 1
  672. };
  673. var orgCopy;
  674. // 获取当前账户注册机构情况
  675. Organization.getByUuid({uuid : 222222}, {}, function(data) {//10041558
  676. if (typeof data.id == 'undefined') {
  677. return;
  678. }
  679. $scope.org = data;
  680. orgCopy = angular.copy($scope.org);
  681. }, function() {
  682. toaster.pop('error', '注册情况加载失败');
  683. });
  684. // 获取地址信息
  685. $http.get('static/jsondata/city.json', {
  686. "Accept": "application/json;charset=utf-8", "Accept-Charset": "charset=utf-8"
  687. }).then(function (response) {
  688. $scope.provinces = response.data;
  689. });
  690. // 设置主要领域
  691. $scope.selectMajorArea = function(index) {
  692. $scope.org.majorArea = index;
  693. };
  694. $scope.openDatePicker = function ($event, item, openParam) {
  695. $event.preventDefault();
  696. $event.stopPropagation();
  697. item[openParam] = !item[openParam];
  698. };
  699. //提交
  700. $scope.saveStep1 = function (org, orgType, invalid) {
  701. if (invalid == true) {
  702. $scope.submited = true;
  703. return;
  704. }
  705. if (orgCopy == org) {
  706. if (orgType == 1) {
  707. $location.path('publicOfferingCertificationStep2');
  708. } else if (orgType == 2) {
  709. $location.path('charityCertificationStep2');
  710. }
  711. } else {
  712. org.type = orgType;//机构类别(1:公募 2:非公募)
  713. //var file = $scope.myFiles, file = file && file.length > 0 ? file[0] : null;// 可以不传附件
  714. $http({
  715. method : 'POST',
  716. url : '/org/save',
  717. params : {
  718. jsonStr : org
  719. },
  720. }).success(function (data) {
  721. if (data.success) {
  722. toaster.pop('success', '提示', data.success);
  723. /*$timeout(function () {
  724. //提交后跳转到下一页,防止重复提交
  725. window.location.href = "#/charityCertification2;
  726. }, 500);*/
  727. if (orgType == 1) {
  728. $location.path('publicOfferingCertificationStep2');
  729. } else if (orgType == 2) {
  730. $location.path('charityCertificationStep2');
  731. }
  732. }
  733. if (data.error) {
  734. toaster.pop('error', '提示', data.error);
  735. }
  736. }).error(function (data, status) {
  737. $scope.loadingShow = false;
  738. if (status == 403) {
  739. toaster.pop('error', '操作失败', data);
  740. } else {
  741. toaster.pop('error', '操作失败', data.error);
  742. }
  743. });
  744. }
  745. };
  746. }]);
  747. /**
  748. * 机构认证第二步
  749. */
  750. app.controller('CertificationStep2Ctrl', ['$scope', '$http', '$rootScope', '$timeout', '$location', 'toaster', 'Organization',
  751. function ($scope, $http, $rootScope, $timeout, $location, toaster, Organization) {
  752. var orgCopy;
  753. // 获取当前账户注册机构情况
  754. Organization.getByUuid({uuid : 222222}, {}, function(data) {//10041558
  755. $scope.org = data;
  756. orgCopy = angular.copy($scope.org);
  757. }, function() {
  758. toaster.pop('error', '注册情况加载失败');
  759. });
  760. //提交
  761. $scope.saveStep2 = function (org, orgType) {
  762. if (orgCopy == org) {
  763. if (orgType == 1) {
  764. $location.path('publicOfferingCertificationStep3');
  765. } else if (orgType == 2) {
  766. $location.path('charityCertificationStep3');
  767. }
  768. } else {
  769. $http({
  770. method: 'POST',
  771. url: '/org/save',
  772. params: {
  773. jsonStr: org
  774. },
  775. }).success(function (data) {
  776. if (data.success) {
  777. if (orgType == 1) {
  778. $location.path('publicOfferingCertificationStep3');
  779. } else if (orgType == 2) {
  780. $location.path('charityCertificationStep3');
  781. }
  782. }
  783. if (data.error) {
  784. toaster.pop('error', '提示', data.error);
  785. }
  786. }).error(function (data, status) {
  787. $scope.loadingShow = false;
  788. if (status == 403) {
  789. toaster.pop('error', '操作失败', data);
  790. } else {
  791. toaster.pop('error', '操作失败', data.error);
  792. }
  793. });
  794. }
  795. };
  796. }]);
  797. /**
  798. * 机构认证第三步
  799. */
  800. app.controller('CertificationStep3Ctrl', ['$scope', '$http', '$rootScope', '$timeout', '$location', 'toaster', 'Organization',
  801. function ($scope, $http, $rootScope, $timeout, $location, toaster, Organization) {
  802. var orgCopy;
  803. // 获取当前账户注册机构情况
  804. Organization.getByUuid({uuid : 222222}, {}, function(data) {//10041558
  805. if (typeof data.id == 'undefined') {
  806. return;
  807. }
  808. $scope.org = data;
  809. $scope.logoUrl = $scope.org.logo;
  810. $scope.personCertificateUrl = $scope.org.personCertificate;
  811. $scope.donateCertificateUrl = $scope.org.donateCertificate;
  812. $scope.legalIdCardUrl = $scope.org.legalIdCard;
  813. orgCopy = angular.copy($scope.org);
  814. }, function() {
  815. toaster.pop('error', '注册情况加载失败');
  816. });
  817. // 获取银行信息
  818. $scope.getBankName = function (bankCard) {
  819. if (bankCard == null) {
  820. $scope.org.branchMessage = "";
  821. } else if(bankCard.toString().length < 6) {
  822. $scope.org.branchMessage = "";
  823. } else {
  824. bankCard = bankCard.toString();
  825. $.getJSON("static/jsondata/bank.json", {}, function (data) {
  826. var bankBin = 0;
  827. var isFind = false;
  828. for (var key = 10; key >= 2; key--) {
  829. bankBin = bankCard.substring(0, key);
  830. $.each(data, function (i, item) {
  831. if (item.bin == bankBin) {
  832. isFind = true;
  833. $scope.org.branchMessage = item.bankName;
  834. }
  835. });
  836. if (isFind) {
  837. break;
  838. }
  839. }
  840. if (!isFind) {
  841. $scope.org.branchMessage = "未知发卡银行";
  842. }
  843. });
  844. }
  845. }
  846. /*$scope.fileChanged = function(ele, order){
  847. if (order == 0) {
  848. $scope.logo = ele.files[0];
  849. } else if (order == 1) {
  850. $scope.personCertificate = ele.files[0];
  851. } else if (order == 2) {
  852. $scope.donateCertificate = ele.files[0];
  853. } else if (order == 3) {
  854. $scope.legalIdCard = ele.files[0];
  855. }
  856. $scope.$apply();
  857. };*/
  858. //建立一个可存取到该file的url
  859. var getObjectURL = function (file) {
  860. var url = null;
  861. if (window.createObjectURL != undefined) { // basic
  862. url = window.createObjectURL(file);
  863. } else if (window.URL != undefined) { // mozilla(firefox)
  864. url = window.URL.createObjectURL(file);
  865. } else if (window.webkitURL != undefined) { // webkit or chrome
  866. url = window.webkitURL.createObjectURL(file);
  867. }
  868. return url;
  869. };
  870. // 图片上传
  871. $scope.fileChanged = function(ele, order){
  872. if (order == 0) {
  873. $scope.logo = ele.files[0];
  874. $scope.logoUrl = getObjectURL($scope.logo);
  875. } else if (order == 1) {
  876. $scope.personCertificate = ele.files[0];
  877. $scope.personCertificateUrl = getObjectURL($scope.personCertificate);
  878. } else if (order == 2) {
  879. $scope.donateCertificate = ele.files[0];
  880. $scope.donateCertificateUrl = getObjectURL($scope.donateCertificate);
  881. } else if (order == 3) {
  882. $scope.legalIdCard = ele.files[0];
  883. $scope.legalIdCardUrl = getObjectURL($scope.legalIdCard);
  884. }
  885. $scope.$apply();
  886. };
  887. // 查看范例
  888. $scope.showImg = function (type) {
  889. var img = null;
  890. var imgUrl = null;
  891. switch (type) {
  892. case 'logo':
  893. img = $scope.org.logo;
  894. imgUrl = $scope.logoUrl;
  895. break;
  896. case 'personCertificate':
  897. img = $scope.org.personCertificate;
  898. imgUrl = $scope.personCertificateUrl;
  899. break;
  900. case 'donateCertificate':
  901. img = $scope.org.donateCertificate;
  902. imgUrl = $scope.donateCertificateUrl;
  903. break;
  904. case 'legalIdCard':
  905. img = $scope.org.legalIdCard;
  906. imgUrl = $scope.legalIdCardUrl;
  907. break;
  908. }
  909. if (img) {
  910. var src = img, box = $('#image-box');
  911. box.show();
  912. box.find('img').attr('src', src);
  913. box.find('a').click(function () {
  914. box.hide();
  915. });
  916. box.dblclick(function () {
  917. box.hide();
  918. });
  919. } else if (imgUrl != null) {
  920. var src = imgUrl, box = $('#image-box');
  921. box.show();
  922. box.find('img').attr('src', src);
  923. box.find('a').click(function () {
  924. box.hide();
  925. });
  926. box.dblclick(function () {
  927. box.hide();
  928. });
  929. }
  930. };
  931. // 删除
  932. $scope.clearFile = function (type) {
  933. switch (type) {
  934. case 'logo':
  935. $scope.logo = null;
  936. $scope.logoUrl = null;
  937. break;
  938. case 'personCertificate':
  939. $scope.personCertificate = null;
  940. $scope.personCertificateUrl = null;
  941. break;
  942. case 'donateCertificate':
  943. $scope.donateCertificate = null;
  944. $scope.donateCertificateUrl = null;
  945. break;
  946. case 'legalIdCard':
  947. $scope.legalIdCard = null;
  948. $scope.legalIdCardUrl = null;
  949. break;
  950. }
  951. // 清空input框的内容
  952. var file=document.getElementById(type);
  953. //IE,Safari,chrome
  954. if(file.outerHTML){
  955. file.outerHTML=file.outerHTML;
  956. }
  957. else{ //FF
  958. file.value="";
  959. }
  960. };
  961. //提交
  962. $scope.saveStep3 = function (org, isDraft, orgType) {
  963. if (orgCopy == org) {
  964. if (orgType == 1) {
  965. $location.path('publicOfferingCertificationStep4');
  966. } else if (orgType == 2) {
  967. $location.path('charityCertificationStep4');
  968. }
  969. } else {
  970. var url;
  971. if (isDraft) {
  972. url = '/org/save';
  973. } else {
  974. url = '/org/submit';
  975. }
  976. var data = new FormData(); //以下为像后台提交图片数据
  977. data.append('logo', $scope.logo);
  978. data.append('personCertificate', $scope.personCertificate);
  979. data.append('donateCertificate', $scope.donateCertificate);
  980. data.append('legalIdCard', $scope.legalIdCard);
  981. $http({
  982. headers: {
  983. 'Content-Type': undefined
  984. },
  985. method: 'POST',
  986. processData: false,
  987. async: false,
  988. url: url,
  989. data: data,
  990. params: {
  991. jsonStr: org
  992. },
  993. }).success(function (data) {
  994. if (data.success) {
  995. if (orgType == 1) {
  996. $location.path('publicOfferingCertificationStep4');
  997. } else if (orgType == 2) {
  998. $location.path('charityCertificationStep4');
  999. }
  1000. }
  1001. if (data.error) {
  1002. toaster.pop('error', '提示', data.error);
  1003. }
  1004. }).error(function (data, status) {
  1005. $scope.loadingShow = false;
  1006. if (status == 403) {
  1007. toaster.pop('error', '操作失败', data);
  1008. } else {
  1009. toaster.pop('error', '操作失败', data.error);
  1010. }
  1011. });
  1012. }
  1013. };
  1014. }]);
  1015. /**
  1016. * 公募机构认证第四步
  1017. */
  1018. app.controller('PublicCertificationStep4Ctrl', ['$scope', '$http', '$rootScope', '$timeout', '$location', 'toaster', 'Organization',
  1019. function ($scope, $http, $rootScope, $timeout, $location, toaster, Organization) {
  1020. var orgCopy;
  1021. // 获取当前账户注册机构情况
  1022. Organization.getByUuid({uuid : 222222}, {}, function(data) {//10041166 10041558
  1023. if (typeof data.id == 'undefined') {
  1024. return;
  1025. }
  1026. $scope.org = data;
  1027. $scope.materialUrl = $scope.org.material;
  1028. $scope.certifyUrl = $scope.org.certify;
  1029. orgCopy = angular.copy($scope.org);
  1030. }, function() {
  1031. toaster.pop('error', '注册情况加载失败');
  1032. });
  1033. /*$scope.fileChanged = function(ele, order){
  1034. if (order == 0) {
  1035. //合作商户资料
  1036. $scope.material = ele.files[0];
  1037. } else if (order == 1) {
  1038. //结算银行账号证明
  1039. $scope.certify = ele.files[0];
  1040. }
  1041. $scope.$apply();
  1042. }*/
  1043. //建立一个可存取到该file的url
  1044. var getObjectURL = function (file) {
  1045. var url = null;
  1046. if (window.createObjectURL != undefined) { // basic
  1047. url = window.createObjectURL(file);
  1048. } else if (window.URL != undefined) { // mozilla(firefox)
  1049. url = window.URL.createObjectURL(file);
  1050. } else if (window.webkitURL != undefined) { // webkit or chrome
  1051. url = window.webkitURL.createObjectURL(file);
  1052. }
  1053. return url;
  1054. };
  1055. // 图片上传
  1056. $scope.fileChanged = function(ele, order){
  1057. if (order == 0) {
  1058. $scope.material = ele.files[0];
  1059. $scope.materialUrl = getObjectURL($scope.material);
  1060. } else if (order == 1) {
  1061. $scope.certify = ele.files[0];
  1062. $scope.certifyUrl = getObjectURL($scope.certify);
  1063. }
  1064. $scope.$apply();
  1065. };
  1066. // 查看范例
  1067. $scope.showImg = function (type) {
  1068. var img = null;
  1069. var imgUrl = null;
  1070. switch (type) {
  1071. case 'material':
  1072. img = $scope.org.material;
  1073. imgUrl = $scope.materialUrl;
  1074. break;
  1075. case 'certify':
  1076. img = $scope.org.certify;
  1077. imgUrl = $scope.certifyUrl;
  1078. break;
  1079. }
  1080. if (img) {
  1081. var src = img, box = $('#image-box');
  1082. box.show();
  1083. box.find('img').attr('src', src);
  1084. box.find('a').click(function () {
  1085. box.hide();
  1086. });
  1087. box.dblclick(function () {
  1088. box.hide();
  1089. });
  1090. } else if (imgUrl != null) {
  1091. var src = imgUrl, box = $('#image-box');
  1092. box.show();
  1093. box.find('img').attr('src', src);
  1094. box.find('a').click(function () {
  1095. box.hide();
  1096. });
  1097. box.dblclick(function () {
  1098. box.hide();
  1099. });
  1100. }
  1101. };
  1102. // 删除
  1103. $scope.clearFile = function (type) {
  1104. switch (type) {
  1105. case 'material':
  1106. $scope.material = null;
  1107. $scope.materialUrl = null;
  1108. break;
  1109. case 'certify':
  1110. $scope.certify = null;
  1111. $scope.certifyUrl = null;
  1112. break;
  1113. }
  1114. // 清空input框的内容
  1115. var file=document.getElementById(type);
  1116. //IE,Safari,chrome
  1117. if(file.outerHTML){
  1118. file.outerHTML=file.outerHTML;
  1119. }
  1120. else{ //FF
  1121. file.value="";
  1122. }
  1123. };
  1124. //提交
  1125. $scope.saveStep4 = function (org, isDraft) {
  1126. if (orgCopy == org) {
  1127. $location.path('publicOfferingCertificationStep5');
  1128. } else {
  1129. var url;
  1130. if (isDraft) {
  1131. url = '/org/save';
  1132. } else {
  1133. url = '/org/submit';
  1134. }
  1135. var data = new FormData(); //以下为像后台提交图片数据
  1136. data.append('material', $scope.material);
  1137. data.append('certify', $scope.certify);
  1138. $http({
  1139. headers: {
  1140. 'Content-Type': undefined
  1141. },
  1142. method: 'POST',
  1143. processData: false,
  1144. async: false,
  1145. url: url,
  1146. data: data,
  1147. params: {
  1148. jsonStr: org
  1149. },
  1150. }).success(function (data) {
  1151. if (data.success) {
  1152. $location.path('publicOfferingCertificationStep5');
  1153. }
  1154. if (data.error) {
  1155. toaster.pop('error', '提示', data.error);
  1156. }
  1157. }).error(function (data, status) {
  1158. $scope.loadingShow = false;
  1159. if (status == 403) {
  1160. toaster.pop('error', '操作失败', data);
  1161. } else {
  1162. toaster.pop('error', '操作失败', data.error);
  1163. }
  1164. });
  1165. }
  1166. };
  1167. }]);
  1168. /**
  1169. * 新建项目
  1170. */
  1171. app.controller('ProjectNewCtrl', ['$scope', 'BaseService', 'Project', '$http', 'toaster', '$stateParams', '$rootScope',
  1172. function($scope, BaseService, Project, $http, toaster, $stateParams, $rootScope) {
  1173. // 默认捐助领域
  1174. $scope.defaultAreas = ['疾病援助', '扶贫/救灾', '教育/助学' , '环境/动物保护', '其他'];
  1175. // 默认具体分类
  1176. var defaultClassifys = ['白血病', '早产儿', '烧烫伤', '罕见病', '癌症', '唇腭裂', '因病致贫', '尘肺病', '病情危急',
  1177. '尿毒症', '渐冻症', '意外受伤', '贫困大病', '视力健康', '听障', '其他'];
  1178. $scope.populations = ['第三世界', '贫困妇女', '空巢/留守老人', '孤儿/事实孤儿', '残障', '抗战老兵', '自闭症', '弱势群体',
  1179. '走失儿童', '失独家庭', '山区孩子', '义工志愿者', '困境儿童', '贫困家庭', '少数民族', '其他'];
  1180. $scope.checked = true;
  1181. $scope.changeChecked = function() {
  1182. $scope.checked = !$scope.checked;
  1183. };
  1184. // 获取已保存的项目
  1185. var getSavedProject = function() {
  1186. // 获取地址信息
  1187. $http.get('static/jsondata/classify.json', {
  1188. "Accept": "application/json;charset=utf-8", "Accept-Charset": "charset=utf-8"
  1189. }).then(function (response) {
  1190. $scope.areas = response.data;
  1191. });
  1192. Project.getSavedProject({}, {}, function(data) {
  1193. if(angular.isObject(data)) {
  1194. $scope.project = data;
  1195. $scope.pcImgUrl = data.pcImg;
  1196. $scope.mobileImgUrl = data.mobileImg;
  1197. $scope.mobileListImgUrl = data.listImg;
  1198. $scope.logoUrl = data.logo;
  1199. }
  1200. });
  1201. if (!angular.isUndefined($stateParams.id)) {
  1202. Project.getDetailById({id : $stateParams.id}, {}, function(data) {
  1203. $scope.project = data;
  1204. $scope.pcImgUrl = data.pcImg;
  1205. $scope.mobileImgUrl = data.mobileImg;
  1206. $scope.mobileListImgUrl = data.listImg;
  1207. $scope.logoUrl = data.logo;
  1208. });
  1209. }
  1210. if (angular.isUndefined($scope.project)) {
  1211. $scope.project = {
  1212. area: $scope.defaultAreas[0],
  1213. classify: defaultClassifys[0],
  1214. population: $scope.populations[0]
  1215. };
  1216. }
  1217. };
  1218. getSavedProject();
  1219. // 日期选择
  1220. $scope.openDatePicker = function ($event, item, openParam) {
  1221. $event.preventDefault();
  1222. $event.stopPropagation();
  1223. item[openParam] = !item[openParam];
  1224. };
  1225. // 设置区域
  1226. $scope.setArea = function(area) {
  1227. $scope.project.area = area;
  1228. $scope.classifys = $scope.areas[area];
  1229. $scope.project.classify = $scope.areas[area][0];
  1230. };
  1231. // 设置具体分类
  1232. $scope.setClassify = function(classify) {
  1233. $scope.project.classify = classify;
  1234. };
  1235. // 设置受助人群
  1236. $scope.setPopulation = function(index) {
  1237. $scope.project.population = $scope.populations[index];
  1238. };
  1239. // 获取地址信息
  1240. $http.get('static/jsondata/city.json', {
  1241. "Accept": "application/json;charset=utf-8", "Accept-Charset": "charset=utf-8"
  1242. }).then(function (response) {
  1243. $scope.provinces = response.data;
  1244. });
  1245. // 保存基础信息
  1246. $scope.saveBaseInfo = function(project, invalid) {
  1247. if (invalid) {
  1248. $scope.submited = true;
  1249. BaseService.scrollBackToTop();
  1250. return;
  1251. }
  1252. // if (project.startTime == project.endTime) {
  1253. // toaster.pop('info', '项目开始时间与结束时间不能相同,请修改之后再保存');
  1254. // } else {
  1255. Project.saveBaseInfo({}, project, function(data) {
  1256. $scope.project = data;
  1257. var proId = $scope.project.id;
  1258. if(proId) {
  1259. BaseService.scrollBackToTop();
  1260. window.location.href = '#/launchProject/detail/' + proId;
  1261. }
  1262. },function(res) {
  1263. toaster.pop('error', '出现错误,操作失败');
  1264. });
  1265. // }
  1266. };
  1267. // 删除
  1268. $scope.cancel = function(type) {
  1269. switch (type) {
  1270. case 'pcImg':
  1271. $scope.pcImg = null;
  1272. break;
  1273. case 'mobileImg':
  1274. $scope.mobileImg = null;
  1275. break;
  1276. }
  1277. };
  1278. //建立一个可存取到该file的url
  1279. var getObjectURL = function (file) {
  1280. var url = null;
  1281. if (window.createObjectURL != undefined) { // basic
  1282. url = window.createObjectURL(file);
  1283. } else if (window.URL != undefined) { // mozilla(firefox)
  1284. url = window.URL.createObjectURL(file);
  1285. } else if (window.webkitURL != undefined) { // webkit or chrome
  1286. url = window.webkitURL.createObjectURL(file);
  1287. }
  1288. return url;
  1289. };
  1290. // 图片上传
  1291. $scope.fileChanged = function(ele, order){
  1292. if (order == 0) {
  1293. $scope.pcImg = ele.files[0];
  1294. $scope.pcImgUrl = getObjectURL($scope.pcImg);
  1295. } else if (order == 1) {
  1296. $scope.mobileImg = ele.files[0];
  1297. $scope.mobileImgUrl = getObjectURL($scope.mobileImg);
  1298. } if (order == 2) {
  1299. $scope.mobileListImg = ele.files[0];
  1300. $scope.mobileListImgUrl = getObjectURL($scope.mobileListImg);
  1301. } if (order == 3) {
  1302. $scope.logo = ele.files[0];
  1303. $scope.logoUrl = getObjectURL($scope.logo);
  1304. }
  1305. $scope.$apply();
  1306. };
  1307. // 查看范例
  1308. $scope.showImg = function (type) {
  1309. var img = null;
  1310. var imgUrl = null;
  1311. switch (type) {
  1312. case 'pcImg':
  1313. img = $scope.project.pcImg;
  1314. imgUrl = $scope.pcImgUrl;
  1315. break;
  1316. case 'mobileImg':
  1317. img = $scope.project.mobileImg;
  1318. imgUrl = $scope.mobileImgUrl;
  1319. break;
  1320. case 'mobileListImg':
  1321. img = $scope.project.mobileListImg;
  1322. imgUrl = $scope.mobileListImgUrl;
  1323. break;
  1324. case 'logo':
  1325. img = $scope.project.logo;
  1326. imgUrl = $scope.logoUrl;
  1327. break;
  1328. }
  1329. if (img) {
  1330. var src = img, box = $('#image-box');
  1331. box.show();
  1332. box.find('img').attr('src', src);
  1333. box.find('a').click(function () {
  1334. box.hide();
  1335. });
  1336. box.dblclick(function () {
  1337. box.hide();
  1338. });
  1339. } else if (imgUrl != null) {
  1340. var src = imgUrl, box = $('#image-box');
  1341. box.show();
  1342. box.find('img').attr('src', src);
  1343. box.find('a').click(function () {
  1344. box.hide();
  1345. });
  1346. box.dblclick(function () {
  1347. box.hide();
  1348. });
  1349. }
  1350. };
  1351. // 删除
  1352. $scope.clearFile = function (type) {
  1353. switch (type) {
  1354. case 'pcImg':
  1355. $scope.pcImg = null;
  1356. $scope.pcImgUrl = null;
  1357. break;
  1358. case 'mobileImg':
  1359. $scope.mobileImg = null;
  1360. $scope.mobileImgUrl = null;
  1361. break;
  1362. case 'mobileListImg':
  1363. $scope.mobileListImg = null;
  1364. $scope.mobileListImgUrl = null;
  1365. break;
  1366. case 'logo':
  1367. $scope.logo = null;
  1368. $scope.logoUrl = null;
  1369. break;
  1370. }
  1371. // 清空input框的内容
  1372. var file=document.getElementById(type);
  1373. //IE,Safari,chrome
  1374. if(file.outerHTML){
  1375. file.outerHTML=file.outerHTML;
  1376. }
  1377. else{ //FF
  1378. file.value="";
  1379. }
  1380. };
  1381. // 设置active
  1382. $scope.setActive = function(value) {
  1383. $rootScope.active = value;
  1384. // window.location.href = '#/';
  1385. };
  1386. //提交 或 保存
  1387. $scope.saveDetail = function (project, type, invalid) {
  1388. if (type && invalid) {
  1389. $scope.submited = true;
  1390. BaseService.scrollBackToTop();
  1391. return;
  1392. }
  1393. var data = new FormData(); //以下为像后台提交图片数据
  1394. data.append('pcImg', $scope.pcImg);
  1395. data.append('mobileImg', $scope.mobileImg);
  1396. data.append('mobileListImg', $scope.mobileListImg);
  1397. data.append('logo', $scope.logo);
  1398. data.append('jsonStr', JSON.stringify(project));
  1399. // type为true即为发布
  1400. var url;
  1401. if (type) {
  1402. url = '/project/submit';
  1403. } else {
  1404. url = '/project/save';
  1405. }
  1406. $http({
  1407. headers: {
  1408. 'Content-Type': undefined
  1409. },
  1410. method : 'POST',
  1411. processData : false,
  1412. contentType: false,
  1413. async: false,
  1414. url : url,
  1415. data: data
  1416. }).success(function (data) {
  1417. if (type) {
  1418. toaster.pop('success', '发布成功');
  1419. $rootScope.active = 'unaudited';
  1420. BaseService.scrollBackToTop();
  1421. window.location.href='#/launchProject/success';
  1422. } else {
  1423. toaster.pop('success', '保存成功');
  1424. window.location.href='#/';
  1425. }
  1426. }).error(function (data) {
  1427. $scope.loadingShow = false;
  1428. toaster.pop('error', '出现错误,操作失败');
  1429. });
  1430. };
  1431. }]);
  1432. /**
  1433. * 财务披露项目列表
  1434. */
  1435. app.controller('ProjectFinanceListCtrl', ['$scope', 'toaster', 'ngTableParams', 'BaseService', 'Project', '$modal',
  1436. function ($scope, toaster, ngTableParams, BaseService, Project, $modal) {
  1437. $scope.keyword = '';
  1438. $scope.reload = function() {
  1439. if ($scope.projectParams.page() == 1)
  1440. $scope.projectParams.reload();
  1441. else
  1442. $scope.projectParams.page(1);
  1443. };
  1444. $scope.projectParams = new ngTableParams({
  1445. page: 1,
  1446. count: 5,
  1447. sorting: {
  1448. 'id': 'desc'
  1449. }
  1450. }, {
  1451. total: 0,
  1452. counts: [5, 10, 25, 50],
  1453. getData: function ($defer, params) {
  1454. $scope.loading = true;
  1455. var pageParams = params.url();
  1456. var realActive = {};
  1457. pageParams.searchFilter = { // 筛选条件
  1458. keyword: $scope.keyword
  1459. };
  1460. Project.getNotEnd.call(null, BaseService.parseParams(pageParams), function (page) {
  1461. $scope.loading = false;
  1462. if (page) {
  1463. params.total(page.totalElements);
  1464. $defer.resolve(page.content);
  1465. // $scope.keywordXls = angular.copy($scope.keyword); // 保存当前取值的关键词 做导出时需要的字段
  1466. }
  1467. }, function (response) {
  1468. $scope.loading = false;
  1469. toaster.pop('error', '数据加载失败', response.data);
  1470. });
  1471. }
  1472. });
  1473. $scope.onSearch = function () {
  1474. if ($scope.projectParams.page() == 1)
  1475. $scope.projectParams.reload();
  1476. else
  1477. $scope.projectParams.page(1);
  1478. };
  1479. // 弹出详情页模态框
  1480. $scope.showFinance = function (id) {
  1481. var modalInstance = $modal.open({
  1482. templateUrl: 'static/view/project/project_finance.html',
  1483. controller: 'ProjectFinanceDetailCtrl',
  1484. size: 'lg',
  1485. resolve: {
  1486. id: function () {
  1487. return id;
  1488. }
  1489. }
  1490. });
  1491. modalInstance.result.then(function(data){
  1492. if (data.success) {
  1493. toaster.pop('success', '操作成功');
  1494. }
  1495. $scope.projectParams.reload();
  1496. }, function(){
  1497. });
  1498. };
  1499. }]);
  1500. /**
  1501. * 财务披露详情框
  1502. */
  1503. app.controller('ProjectFinanceDetailCtrl', ['$scope', 'Project', 'toaster', '$modalInstance', 'BaseService', 'id', '$upload', '$http',
  1504. function($scope, Project, toaster, $modalInstance, BaseService, id, $upload, $http) {
  1505. $scope.newFinance = {
  1506. amount: null,
  1507. path: null,
  1508. description: null,
  1509. type : null
  1510. };
  1511. $scope.imgUrl = null;
  1512. var loadData = function() {
  1513. // 获取项目详情
  1514. Project.getDetailById({id :id}, {}, function(data) {
  1515. $scope.project = data;
  1516. }, function() {
  1517. toaster.pop('error', '详情加载失败');
  1518. });
  1519. // 获取当前项目财务信息
  1520. Project.getFinance({id:id}, {}, function(data) {
  1521. $scope.projectFinance = data.projectFinance;
  1522. $scope.totalCost = data.totalCost;
  1523. $scope.executeCost = data.executeCost;
  1524. $scope.projectCost = data.projectCost;
  1525. }, function() {
  1526. toaster.pop('error','财务明细加载失败');
  1527. });
  1528. };
  1529. loadData();
  1530. $scope.cancel= function() {
  1531. $modalInstance.dismiss();
  1532. };
  1533. $scope.fileChanged = function(ele) {
  1534. $scope.newFinance.file = ele.files[0];
  1535. $scope.imgUrl = getObjectURL(ele.files[0]);
  1536. };
  1537. //建立一个可存取到该file的url
  1538. var getObjectURL = function (file) {
  1539. var url = null;
  1540. if (window.createObjectURL != undefined) { // basic
  1541. url = window.createObjectURL(file);
  1542. } else if (window.URL != undefined) { // mozilla(firefox)
  1543. url = window.URL.createObjectURL(file);
  1544. } else if (window.webkitURL != undefined) { // webkit or chrome
  1545. url = window.webkitURL.createObjectURL(file);
  1546. }
  1547. return url;
  1548. };
  1549. // // 查看范例
  1550. // $scope.showImg = function () {
  1551. // var imgUrl = $scope.imgUrl;
  1552. // if (imgUrl != null) {
  1553. // var src = imgUrl, box = $('#image-box');
  1554. // box.show();
  1555. // box.find('img').attr('src', src);
  1556. // box.find('a').click(function () {
  1557. // box.hide();
  1558. // });
  1559. // box.dblclick(function () {
  1560. // box.hide();
  1561. // });
  1562. // }
  1563. // };
  1564. // 删除活动图或banner
  1565. $scope.clearFile = function (type) {
  1566. $scope.newFinance.file = null;
  1567. $scope.imgUrl = null;
  1568. // 清空input框的内容
  1569. var file=document.getElementById(type);
  1570. //IE,Safari,chrome
  1571. if(file.outerHTML){
  1572. file.outerHTML=file.outerHTML;
  1573. }
  1574. else{ //FF
  1575. file.value="";
  1576. }
  1577. };
  1578. // 发布
  1579. $scope.saveFinance = function(finance) {
  1580. var data = new FormData();
  1581. data.append('json', JSON.stringify(finance));
  1582. data.append('img', finance.file);
  1583. $http({
  1584. headers: {
  1585. 'Content-Type': undefined
  1586. },
  1587. method: 'POST',
  1588. processData: false,
  1589. async: false,
  1590. url: 'project/save/finance/' + id,
  1591. data: data
  1592. }).success(function(data){
  1593. toaster.pop('success', '发布财务信息成功');
  1594. $modalInstance.close();
  1595. }).error(function(data){
  1596. toaster.pop('error', '出现错误,发布失败');
  1597. });
  1598. };
  1599. }]);
  1600. /**
  1601. * 报告填写项目列表
  1602. */
  1603. app.controller('ProjectReportListCtrl', ['$scope', 'toaster', 'ngTableParams', 'BaseService', 'Project', '$modal', '$http',
  1604. function ($scope, toaster, ngTableParams, BaseService, Project, $modal, $http) {
  1605. $scope.keyword = '';
  1606. $scope.selectedArea = '全部';
  1607. $scope.reload = function() {
  1608. if ($scope.projectParams.page() == 1)
  1609. $scope.projectParams.reload();
  1610. else
  1611. $scope.projectParams.page(1);
  1612. };
  1613. $scope.projectParams = new ngTableParams({
  1614. page: 1,
  1615. count: 5,
  1616. sorting: {
  1617. 'id': 'desc'
  1618. }
  1619. }, {
  1620. total: 0,
  1621. counts: [5, 10, 25, 50],
  1622. getData: function ($defer, params) {
  1623. $scope.loading = true;
  1624. var pageParams = params.url();
  1625. var realActive = {};
  1626. pageParams.searchFilter = { // 筛选条件
  1627. keyword: $scope.keyword,
  1628. area: $scope.selectedArea
  1629. };
  1630. Project.getNotEnd.call(null, BaseService.parseParams(pageParams), function (page) {
  1631. $scope.loading = false;
  1632. if (page) {
  1633. params.total(page.totalElements);
  1634. $defer.resolve(page.content);
  1635. // $scope.keywordXls = angular.copy($scope.keyword); // 保存当前取值的关键词 做导出时需要的字段
  1636. }
  1637. }, function (response) {
  1638. $scope.loading = false;
  1639. toaster.pop('error', '数据加载失败', response.data);
  1640. });
  1641. }
  1642. });
  1643. $scope.onSearch = function () {
  1644. if ($scope.projectParams.page() == 1)
  1645. $scope.projectParams.reload();
  1646. else
  1647. $scope.projectParams.page(1);
  1648. };
  1649. // 弹出详情页模态框
  1650. $scope.showReport = function (id) {
  1651. var modalInstance = $modal.open({
  1652. templateUrl: 'static/view/project/project_report.html',
  1653. controller: 'ProjectReportDetailCtrl',
  1654. size: 'lg',
  1655. resolve: {
  1656. id: function () {
  1657. return id;
  1658. }
  1659. }
  1660. });
  1661. modalInstance.result.then(function(data){
  1662. if (data.success) {
  1663. toaster.pop('success', '操作成功');
  1664. }
  1665. $scope.projectParams.reload();
  1666. }, function(){
  1667. });
  1668. };
  1669. }]);
  1670. /**
  1671. * 报告填写详情框
  1672. */
  1673. app.controller('ProjectReportDetailCtrl', ['$scope', 'Project', 'toaster', '$modalInstance', 'BaseService', 'id', '$http',
  1674. function($scope, Project, toaster, $modalInstance, BaseService, id, $http) {
  1675. $scope.report = {
  1676. path: null,
  1677. description: null
  1678. };
  1679. var loadData = function() {
  1680. // 获取项目详情
  1681. Project.getDetailById({id :id}, {}, function(data) {
  1682. $scope.project = data;
  1683. }, function() {
  1684. toaster.pop('error', '详情加载失败');
  1685. });
  1686. // 获取当前项目所有进度
  1687. Project.getSchedules({id : id}, {}, function(data) {
  1688. $scope.schedules = data;
  1689. }, function() {
  1690. toaster.pop('error', '项目进度加载失败');
  1691. });
  1692. };
  1693. loadData();
  1694. // 图片上传
  1695. $scope.fileChanged = function(ele){
  1696. $scope.report.file = ele.files[0];
  1697. $scope.imgUrl = getObjectURL(ele.files[0]);
  1698. $scope.$apply();
  1699. };
  1700. $scope.cancel= function() {
  1701. $modalInstance.dismiss();
  1702. };
  1703. // delete
  1704. $scope.deleteSchedule = function(scheduleId) {
  1705. Project.deleteSchedule({id: scheduleId}, {}, function() {
  1706. toaster.pop('success', '操作成功');
  1707. // 重新加载
  1708. loadData();
  1709. }, function() {
  1710. toaster.pop('error', '出现错误,操作失败');
  1711. });
  1712. };
  1713. // 发布
  1714. $scope.saveReport = function(report) {
  1715. var data = new FormData();
  1716. data.append('json', JSON.stringify(report));
  1717. data.append('img', report.file);
  1718. $http({
  1719. headers: {
  1720. 'Content-Type': undefined
  1721. },
  1722. method: 'POST',
  1723. processData: false,
  1724. async: false,
  1725. url: 'project/save/report/' + id,
  1726. data: data
  1727. }).success(function(data){
  1728. toaster.pop('success', '发布进度信息成功');
  1729. $modalInstance.close();
  1730. }).error(function(data){
  1731. toaster.pop('error', '出现错误,发布失败');
  1732. });
  1733. };
  1734. }]);
  1735. /**
  1736. * 结项管理项目列表
  1737. */
  1738. app.controller('ProjectManagementListCtrl', ['$scope', 'toaster', 'ngTableParams', 'BaseService', 'Project', '$modal',
  1739. function ($scope, toaster, ngTableParams, BaseService, Project, $modal) {
  1740. $scope.keyword = '';
  1741. $scope.selectedArea = '全部';
  1742. $scope.reload = function() {
  1743. if ($scope.projectParams.page() == 1)
  1744. $scope.projectParams.reload();
  1745. else
  1746. $scope.projectParams.page(1);
  1747. };
  1748. $scope.projectParams = new ngTableParams({
  1749. page: 1,
  1750. count: 5,
  1751. sorting: {
  1752. 'id': 'desc'
  1753. }
  1754. }, {
  1755. total: 0,
  1756. counts: [5, 10, 25, 50],
  1757. getData: function ($defer, params) {
  1758. $scope.loading = true;
  1759. var pageParams = params.url();
  1760. var realActive = {};
  1761. pageParams.searchFilter = { // 筛选条件
  1762. keyword: $scope.keyword,
  1763. area: $scope.selectedArea
  1764. };
  1765. Project.getNotEnd.call(null, BaseService.parseParams(pageParams), function (page) {
  1766. $scope.loading = false;
  1767. if (page) {
  1768. params.total(page.totalElements);
  1769. $defer.resolve(page.content);
  1770. // $scope.keywordXls = angular.copy($scope.keyword); // 保存当前取值的关键词 做导出时需要的字段
  1771. }
  1772. }, function (response) {
  1773. $scope.loading = false;
  1774. toaster.pop('error', '数据加载失败', response.data);
  1775. });
  1776. }
  1777. });
  1778. $scope.onSearch = function () {
  1779. if ($scope.projectParams.page() == 1)
  1780. $scope.projectParams.reload();
  1781. else
  1782. $scope.projectParams.page(1);
  1783. };
  1784. // 弹出详情页模态框
  1785. $scope.showManagement = function (id) {
  1786. var modalInstance = $modal.open({
  1787. templateUrl: 'static/view/project/project_management.html',
  1788. controller: 'ProjectManagementDetailCtrl',
  1789. size: 'lg',
  1790. resolve: {
  1791. id: function () {
  1792. return id;
  1793. }
  1794. }
  1795. });
  1796. modalInstance.result.then(function(data){
  1797. if (data.success) {
  1798. toaster.pop('success', '操作成功');
  1799. }
  1800. $scope.projectParams.reload();
  1801. }, function(){
  1802. });
  1803. };
  1804. }]);
  1805. /**
  1806. * 结项管理详情框
  1807. */
  1808. app.controller('ProjectManagementDetailCtrl', ['$scope', 'Project', 'toaster', '$modalInstance', 'BaseService', 'id', '$http',
  1809. function($scope, Project, toaster, $modalInstance, BaseService, id, $http) {
  1810. $scope.conclude = {
  1811. description: null
  1812. };
  1813. var loadData = function() {
  1814. // 获取项目详情
  1815. Project.getDetailById({id :id}, {}, function(data) {
  1816. $scope.project = data;
  1817. }, function() {
  1818. toaster.pop('error', '详情加载失败');
  1819. });
  1820. // 获取当前项目结项数据
  1821. $scope.getConcludeData = function() {
  1822. Project.getConcludeData({id : id}, {}, function(data) {
  1823. $scope.executeDays = data.executeDays;
  1824. $scope.updateTimes = data.updateTimes;
  1825. }, function() {
  1826. toaster.pop('error', '加载失败');
  1827. });
  1828. };
  1829. };
  1830. loadData();
  1831. $scope.cancel= function() {
  1832. $modalInstance.dismiss();
  1833. };
  1834. // 发布
  1835. $scope.saveConclude = function(conclude) {
  1836. var data = new FormData();
  1837. data.append('json', JSON.stringify(conclude));
  1838. data.append('img', conclude.file);
  1839. $http({
  1840. headers: {
  1841. 'Content-Type': undefined
  1842. },
  1843. method: 'POST',
  1844. processData: false,
  1845. async: false,
  1846. url: 'project/save/conclude/' + id,
  1847. data: data
  1848. }).success(function(data){
  1849. toaster.pop('success', '发布结项信息成功');
  1850. $modalInstance.close();
  1851. }).error(function(data){
  1852. toaster.pop('error', '出现错误,发布失败');
  1853. });
  1854. };
  1855. }]);
  1856. /**
  1857. * 活动列表
  1858. */
  1859. app.controller('ActivityListCtrl', ['$scope', '$rootScope', 'toaster', 'ngTableParams', 'BaseService', 'Activity', '$modal',
  1860. function ($scope, $rootScope, toaster, ngTableParams, BaseService, Activity, $modal) {
  1861. BaseService.scrollBackToTop();
  1862. var getActivityState = function (active) {
  1863. // 正在进行
  1864. var fn = 'getDone';
  1865. switch (active) {
  1866. // 未开始
  1867. case 'todo':
  1868. fn = 'getTodo';
  1869. break;
  1870. // 已结束
  1871. case 'end':
  1872. fn = 'getEnd';
  1873. break;
  1874. // 草稿
  1875. case 'waiting':
  1876. fn = 'getWaiting';
  1877. break;
  1878. }
  1879. return fn;
  1880. };
  1881. $scope.active = 'done';
  1882. $scope.keyword = '';
  1883. /**
  1884. * 修改分类
  1885. * @param value
  1886. */
  1887. $scope.setActive = function (value) {
  1888. if ($scope.active != value) {
  1889. $scope.active = value;
  1890. if ($scope.activityParams.page() == 1)
  1891. $scope.activityParams.reload();
  1892. else
  1893. $scope.activityParams.page(1);
  1894. }
  1895. };
  1896. $scope.reload = function() {
  1897. if ($scope.activityParams.page() == 1)
  1898. $scope.activityParams.reload();
  1899. else
  1900. $scope.activityParams.page(1);
  1901. };
  1902. $scope.activityParams = new ngTableParams({
  1903. page: 1,
  1904. count: 5,
  1905. sorting: {
  1906. 'id': 'desc'
  1907. }
  1908. }, {
  1909. total: 0,
  1910. counts: [5, 10, 25, 50],
  1911. getData: function ($defer, params) {
  1912. $scope.loading = true;
  1913. var pageParams = params.url();
  1914. var realActive = {};
  1915. pageParams.searchFilter = { // 筛选条件
  1916. keyword: $scope.keyword
  1917. };
  1918. Activity[getActivityState($scope.active)].call(null, BaseService.parseParams(pageParams), function (page) {
  1919. $scope.loading = false;
  1920. if (page) {
  1921. params.total(page.totalElements);
  1922. $defer.resolve(page.content);
  1923. // $scope.keywordXls = angular.copy($scope.keyword); // 保存当前取值的关键词 做导出时需要的字段
  1924. }
  1925. }, function (response) {
  1926. $scope.loading = false;
  1927. toaster.pop('error', '数据加载失败', response.data);
  1928. });
  1929. }
  1930. });
  1931. $scope.onSearch = function () {
  1932. if ($scope.activityParams.page() == 1)
  1933. $scope.activityParams.reload();
  1934. else
  1935. $scope.activityParams.page(1);
  1936. };
  1937. var getNum = function() {
  1938. Activity.getActivitiesNum({}, {}, function(data) {
  1939. $scope.doneNum = data.doneNum;
  1940. $scope.todoNum = data.todoNum;
  1941. $scope.endNum = data.endNum;
  1942. $scope.waitingNum = data.waitingNum;
  1943. });
  1944. };
  1945. getNum();
  1946. // 开奖
  1947. $scope.openAward = function(id) {
  1948. Activity.openAward({id: id}, {}, function(data) {
  1949. if (data.success) {
  1950. toaster.pop('success', data.success);
  1951. $scope.activityParams.reload();
  1952. }
  1953. if (data.error) {
  1954. toaster.pop('warning', data.error);
  1955. }
  1956. }, function(response) {
  1957. toaster.pop('error', '数据加载错误');
  1958. });
  1959. };
  1960. // 弹出详情页模态框
  1961. $scope.showDetail = function (id) {
  1962. var modalInstance = $modal.open({
  1963. templateUrl: 'static/view/activity/activity_detail.html',
  1964. controller: 'ActivityDetailCtrl',
  1965. size: 'lg',
  1966. resolve: {
  1967. id: function () {
  1968. return id;
  1969. },
  1970. active: function() {
  1971. return $scope.active;
  1972. }
  1973. }
  1974. });
  1975. modalInstance.result.then(function(data){
  1976. if (data.success) {
  1977. toaster.pop('success', '操作成功');
  1978. }
  1979. $scope.activityParams.reload();
  1980. }, function(){
  1981. });
  1982. };
  1983. }]);
  1984. /**
  1985. * 活动详情框
  1986. */
  1987. app.controller('ActivityDetailCtrl', ['$scope', 'Activity', 'toaster', '$modalInstance', 'BaseService', 'id', '$modal',
  1988. function($scope, Activity, toaster, $modalInstance, BaseService, id, $modal) {
  1989. var loadData = function() {
  1990. // 获取项目详情
  1991. Activity.getDetailById({id :id}, {}, function(data) {
  1992. $scope.activity = data;
  1993. }, function() {
  1994. toaster.pop('error', '详情加载失败');
  1995. });
  1996. };
  1997. loadData();
  1998. $scope.cancel= function() {
  1999. $modalInstance.dismiss();
  2000. };
  2001. }]);
  2002. /**
  2003. * 活动发起
  2004. */
  2005. app.controller('ActivityNewCtrl', ['$scope', 'BaseService', 'toaster', 'Activity', '$http', '$upload',
  2006. function($scope, BaseService, toaster, Activity, $http, $upload) {
  2007. $scope.loading = true;
  2008. $scope.activity = {
  2009. awards:[],
  2010. projects: []
  2011. };
  2012. $scope.awards = [];
  2013. $scope.projects = [];
  2014. $scope.tempProjects = [];
  2015. $scope.selectedProjects = [];
  2016. $scope.tempSelectedProjects = [];
  2017. $scope.keyword = '';
  2018. $scope.actImgUrl = null;
  2019. $scope.bannerUrl = null;
  2020. var loadSavedActivity = function() {
  2021. Activity.getSavedActivity({}, function(data) {
  2022. if (null !== data) {
  2023. $scope.activity = data;
  2024. $scope.awards = data.awards;
  2025. $scope.selectedProjects = data.projects;
  2026. $scope.tempSelectedProjects = angular.copy($scope.selectedProjects);
  2027. $scope.actImgUrl = data.actImg;
  2028. $scope.bannerUrl = data.banner;
  2029. }
  2030. $scope.loading = false;
  2031. });
  2032. };
  2033. loadSavedActivity();
  2034. // 日期选择
  2035. $scope.openDatePicker = function ($event, item, openParam) {
  2036. $event.preventDefault();
  2037. $event.stopPropagation();
  2038. item[openParam] = !item[openParam];
  2039. };
  2040. // 富文本编辑器配置
  2041. // $scope.editorConfig = {
  2042. // dialogsInBody: true,
  2043. // lang: 'zh-CN',
  2044. // toolbar:[
  2045. // ['edit',['undo','redo']],
  2046. // ['style',['bold','italic','underline','clear' ]],
  2047. // ['fontsize',['fontsize']],
  2048. // ['para',['ul','ol','paragraph']],
  2049. // ['color',['color']],
  2050. // ['remove', ['removeMedia']],
  2051. // ['insert', ['link', 'picture', 'table', 'hr']],
  2052. // ['view', ['fullscreen', 'codeview']]
  2053. // ]
  2054. // };
  2055. // 添加奖品
  2056. $scope.addAward = function() {
  2057. if (angular.isUndefined($scope.awards)) {
  2058. $scope.awards = [];
  2059. }
  2060. if ($scope.awards.length >= 4) {
  2061. toaster.pop('warning', '提示', '最多可添加四个奖品');
  2062. } else {
  2063. $scope.awards.push({
  2064. name: '',
  2065. amount: null,
  2066. awardLevel: '',
  2067. way: 1
  2068. });
  2069. }
  2070. };
  2071. // 删除某一奖品
  2072. $scope.deletePath = [];
  2073. $scope.deleteAward = function($index) {
  2074. var path = $scope.awards[$index].img;
  2075. if (!angular.isUndefined(path)) {
  2076. $scope.deletePath.push(path);
  2077. }
  2078. $scope.awards.splice($index, 1);
  2079. };
  2080. // 获取项目列表
  2081. var selectedIds = [];
  2082. var getProject = function() {
  2083. if ([] !== $scope.selectedProjects) {
  2084. angular.forEach($scope.selectedProjects, function(selectedProject) {
  2085. selectedIds.push(selectedProject.id);
  2086. });
  2087. }
  2088. Activity.getActivityRelatedProjects({keyword: $scope.keyword, selectedIds: selectedIds}, function(data) {
  2089. $scope.projects = data;
  2090. $scope.tempProjects = angular.copy($scope.projects);
  2091. });
  2092. };
  2093. getProject();
  2094. // 搜索项目
  2095. $scope.onSearch = function() {
  2096. getProject();
  2097. };
  2098. // 选择未被选择的项目
  2099. // $scope.checkSelected = function (project) {
  2100. // if (project.checked) {
  2101. // project.checked = !project.checked;
  2102. // } else {
  2103. // project.checked = true;
  2104. // }
  2105. // };
  2106. // 添加选中
  2107. $scope.addSelected = function() {
  2108. // angular.forEach($scope.projects, function(project, index) {
  2109. // if (project.checked) {
  2110. // project.checked = false;
  2111. // if (angular.isUndefined($scope.selectedProjects)) {
  2112. // $scope.selectedProjects = [];
  2113. // }
  2114. // $scope.selectedProjects.push(project);
  2115. // $scope.projects.splice(index, 1);
  2116. // }
  2117. // });
  2118. // angular.forEach($scope.projects, function(project, index) {
  2119. // if (project.checked) {
  2120. // project.checked = false;
  2121. // $scope.selectedProjects.push(project);
  2122. // $scope.projects.splice(index, 1);
  2123. // }
  2124. // });
  2125. var i = 0;
  2126. for (i; i< $scope.projects.length; i++) {
  2127. var project = $scope.projects[i];
  2128. if (project.checked) {
  2129. project.checked = false;
  2130. if (angular.isUndefined($scope.selectedProjects)) {
  2131. $scope.selectedProjects = [];
  2132. }
  2133. $scope.selectedProjects.push(project);
  2134. $scope.projects.splice(i, 1);
  2135. i = i-1;
  2136. }
  2137. }
  2138. };
  2139. // 删除选中
  2140. $scope.deleteSelected = function() {
  2141. // // 存在取消操作,用temp过渡
  2142. // angular.forEach($scope.selectedProjects, function(project, index) {
  2143. // if (project.checked) {
  2144. // project.checked = false;
  2145. // $scope.projects.push(project);
  2146. // $scope.selectedProjects.splice(index, 1);
  2147. // }
  2148. // });
  2149. // angular.forEach($scope.selectedProjects, function(project, index) {
  2150. // if (project.checked) {
  2151. // project.checked = false;
  2152. // $scope.projects.push(project);
  2153. // $scope.selectedProjects.splice(index, 1);
  2154. // }
  2155. // });
  2156. var i = 0;
  2157. for (i; i< $scope.selectedProjects.length; i++) {
  2158. var project = $scope.selectedProjects[i];
  2159. if (project.checked) {
  2160. project.checked = false;
  2161. $scope.projects.push(project);
  2162. $scope.selectedProjects.splice(i, 1);
  2163. i = i -1;
  2164. }
  2165. }
  2166. };
  2167. // 取消
  2168. $scope.cancelSelected = function() {
  2169. $scope.projects = angular.copy($scope.tempProjects);
  2170. $scope.selectedProjects = angular.copy($scope.tempSelectedProjects);
  2171. };
  2172. // 保存
  2173. $scope.saveSelected = function() {
  2174. $scope.tempProjects = angular.copy($scope.projects);
  2175. $scope.tempSelectedProjects = angular.copy($scope.selectedProjects);
  2176. };
  2177. // 清空内容
  2178. $scope.clearActivity = function() {
  2179. $scope.activity = {
  2180. awards:[],
  2181. projects: []
  2182. };
  2183. $scope.actImgUrl = null;
  2184. $scope.bannerUrl = null;
  2185. $scope.awards = [];
  2186. $scope.selectedProjects = [];
  2187. getProject();
  2188. BaseService.scrollBackToTop();
  2189. };
  2190. // 图片上传
  2191. $scope.fileChanged = function(ele, value){
  2192. if (value == 0) {
  2193. $scope.actImg = ele.files[0];
  2194. $scope.actImgUrl = getObjectURL($scope.actImg);
  2195. } else if (value == 1) {
  2196. $scope.banner = ele.files[0];
  2197. $scope.bannerUrl = getObjectURL($scope.banner);
  2198. // } else if (value == 2) {
  2199. // $scope.award1 = ele.files[0];
  2200. // } else if (value == 3) {
  2201. // $scope.award2 = ele.files[0];
  2202. // } else if (value == 4) {
  2203. // $scope.award3 = ele.files[0];
  2204. // } else if (value == 5) {
  2205. // $scope.award4 = ele.files[0];
  2206. }
  2207. $scope.$apply();
  2208. };
  2209. //建立一个可存取到该file的url
  2210. var getObjectURL = function (file) {
  2211. var url = null;
  2212. if (window.createObjectURL != undefined) { // basic
  2213. url = window.createObjectURL(file);
  2214. } else if (window.URL != undefined) { // mozilla(firefox)
  2215. url = window.URL.createObjectURL(file);
  2216. } else if (window.webkitURL != undefined) { // webkit or chrome
  2217. url = window.webkitURL.createObjectURL(file);
  2218. }
  2219. return url;
  2220. };
  2221. // 查看范例
  2222. $scope.showImg = function (type) {
  2223. var img = type;
  2224. var imgUrl = null;
  2225. switch (type) {
  2226. case 'actImg':
  2227. img = $scope.activity.actImg;
  2228. imgUrl = $scope.actImgUrl;
  2229. break;
  2230. case 'banner':
  2231. img = $scope.activity.banner;
  2232. imgUrl = $scope.bannerUrl;
  2233. break;
  2234. }
  2235. if (img) {
  2236. var src = img, box = $('#image-box');
  2237. box.show();
  2238. box.find('img').attr('src', src);
  2239. box.find('a').click(function () {
  2240. box.hide();
  2241. });
  2242. box.dblclick(function () {
  2243. box.hide();
  2244. });
  2245. } else if (imgUrl != null) {
  2246. var src = imgUrl, box = $('#image-box');
  2247. box.show();
  2248. box.find('img').attr('src', src);
  2249. box.find('a').click(function () {
  2250. box.hide();
  2251. });
  2252. box.dblclick(function () {
  2253. box.hide();
  2254. });
  2255. }
  2256. };
  2257. // 删除活动图或banner
  2258. $scope.clearFile = function (type) {
  2259. switch (type) {
  2260. case 'actImg':
  2261. $scope.actImg = null;
  2262. $scope.actImgUrl = null;
  2263. break;
  2264. case 'banner':
  2265. $scope.banner = null;
  2266. $scope.bannerUrl = null;
  2267. break;
  2268. }
  2269. // 清空input框的内容
  2270. var file=document.getElementById(type);
  2271. //IE,Safari,chrome
  2272. if(file.outerHTML){
  2273. file.outerHTML=file.outerHTML;
  2274. }
  2275. else{ //FF
  2276. file.value="";
  2277. }
  2278. };
  2279. // 删除奖品图片
  2280. $scope.deletePrizeImg = function(path, index) {
  2281. $scope.awards[index].img = null;
  2282. var type = 'award' + index;
  2283. // 清空input框的内容
  2284. var file=document.getElementById(type);
  2285. //IE,Safari,chrome
  2286. if(file.outerHTML){
  2287. file.outerHTML=file.outerHTML;
  2288. }
  2289. else{ //FF
  2290. file.value="";
  2291. }
  2292. if (!angular.isUndefined(path)) {
  2293. Activity.deletePrizeImg({path: path}, {}, function(data) {
  2294. });
  2295. }
  2296. };
  2297. $scope.uploadPrizeImg = function(award, index) {
  2298. $scope.loading = true;
  2299. var files = award.prizeImgs, file = files && files.length > 0 ? files[0] : null;
  2300. $upload.upload({
  2301. url: 'activity/upload/prizeImg',
  2302. method: 'POST',
  2303. file: file
  2304. }).success(function (data) {
  2305. $scope.awards[index].img = data.path;
  2306. $scope.loading = false;
  2307. }).error(function (data) {
  2308. $scope.loading = false;
  2309. // toaster.pop('error', '错误', data);
  2310. });
  2311. };
  2312. // 保存 或 提交
  2313. $scope.submit = function(type, invalid) {
  2314. if (invalid == true) {
  2315. $scope.submited = true;
  2316. BaseService.scrollBackToTop();
  2317. return;
  2318. }
  2319. // if ($scope.activity.startTime === $scope.activity.endTime) {
  2320. // toaster.pop('info', '开始时间与结束时间不能相同,请修改之后再保存');
  2321. // } else if ($scope.activity.receiveStartTime === $scope.activity.receiveEndTime) {
  2322. // toaster.pop('info', '兑奖开始时间与结束时间不能相同,请修改之后再保存');
  2323. // } else {
  2324. $scope.loading = true;
  2325. var projectList = [];
  2326. angular.forEach($scope.selectedProjects, function (project) {
  2327. projectList.push(project);
  2328. });
  2329. $scope.activity.projects = projectList;
  2330. $scope.activity.awards = $scope.awards;
  2331. var url;
  2332. if (type) {
  2333. url = 'activity/submit';
  2334. } else {
  2335. url = 'activity/save';
  2336. }
  2337. var data = new FormData();
  2338. data.append('actImg', $scope.actImg);
  2339. data.append('banner', $scope.banner);
  2340. // data.append('award1', $scope.award1);
  2341. // data.append('award2', $scope.award2);
  2342. // data.append('award3', $scope.award3);
  2343. // data.append('award4', $scope.award4);
  2344. data.append('jsonStr', JSON.stringify($scope.activity));
  2345. $http({
  2346. headers: {
  2347. 'Content-Type': undefined
  2348. },
  2349. method: 'POST',
  2350. processData: false,
  2351. async: false,
  2352. url: url,
  2353. data: data
  2354. }).success(function (data) {
  2355. if (type) {
  2356. toaster.pop('success', '发布成功');
  2357. } else {
  2358. toaster.pop('success', '保存成功');
  2359. }
  2360. if ($scope.deletePath.length > 0) {
  2361. Activity.deletePrizeImgByBatch({path: $scope.deletePath}, {}, function (data) {
  2362. });
  2363. }
  2364. $scope.loading = false;
  2365. window.location.hash = '#/activity';
  2366. }).error(function (data) {
  2367. $scope.loadingShow = false;
  2368. toaster.pop('error', '出现错误,操作失败');
  2369. });
  2370. // }
  2371. }
  2372. }]);
  2373. /**
  2374. * 机构列表
  2375. */
  2376. app.controller('OrgListCtrl', ['$scope', '$rootScope', 'toaster', 'ngTableParams', 'BaseService', 'Organization', '$modal',
  2377. function ($scope, $rootScope, toaster, ngTableParams, BaseService, Organization, $modal) {
  2378. var getOrgState = function (active) {
  2379. var fn = 'getAudited';
  2380. switch (active) {
  2381. // 已审核
  2382. case 'audited':
  2383. fn = 'getAudited';
  2384. break;
  2385. // 未审核
  2386. case 'unaudited':
  2387. fn = 'getUnaudited';
  2388. break;
  2389. // 未通过
  2390. case 'disagreed':
  2391. fn = 'getDisagreed';
  2392. break;
  2393. }
  2394. return fn;
  2395. };
  2396. $scope.active = 'done';
  2397. if ($rootScope.active) {
  2398. $scope.active = $rootScope.active;
  2399. }
  2400. $scope.keyword = '';
  2401. /**
  2402. * 修改分类
  2403. * @param value
  2404. */
  2405. $scope.setActive = function (value) {
  2406. if ($scope.active != value) {
  2407. $scope.active = value;
  2408. if ($scope.orgParams.page() == 1)
  2409. $scope.orgParams.reload();
  2410. else
  2411. $scope.orgParams.page(1);
  2412. }
  2413. };
  2414. $scope.reload = function() {
  2415. if ($scope.orgParams.page() == 1)
  2416. $scope.orgParams.reload();
  2417. else
  2418. $scope.orgParams.page(1);
  2419. };
  2420. $scope.orgParams = new ngTableParams({
  2421. page: 1,
  2422. count: 5,
  2423. sorting: {
  2424. 'id': 'desc'
  2425. }
  2426. }, {
  2427. total: 0,
  2428. counts: [5, 10, 25, 50],
  2429. getData: function ($defer, params) {
  2430. $scope.loading = true;
  2431. var pageParams = params.url();
  2432. var realActive = {};
  2433. pageParams.searchFilter = { // 筛选条件
  2434. keyword: $scope.keyword,
  2435. area: $scope.selectedArea,
  2436. type: $scope.selectedType
  2437. };
  2438. Organization[getOrgState($scope.active)].call(null, BaseService.parseParams(pageParams), function (page) {
  2439. $scope.loading = false;
  2440. if (page) {
  2441. params.total(page.totalElements);
  2442. $defer.resolve(page.content);
  2443. // $scope.keywordXls = angular.copy($scope.keyword); // 保存当前取值的关键词 做导出时需要的字段
  2444. }
  2445. }, function (response) {
  2446. $scope.loading = false;
  2447. toaster.pop('error', '数据加载失败', response.data);
  2448. });
  2449. }
  2450. });
  2451. $scope.onSearch = function () {
  2452. if ($scope.orgParams.page() == 1)
  2453. $scope.orgParams.reload();
  2454. else
  2455. $scope.orgParams.page(1);
  2456. };
  2457. var getNum = function() {
  2458. Organization.getOrgsNum({}, {}, function(data) {
  2459. $scope.auditedNum = data.auditedNum;
  2460. $scope.unauditedNum = data.unauditedNum;
  2461. $scope.disagreedNum = data.disagreedNum;
  2462. });
  2463. };
  2464. getNum();
  2465. // 弹出详情页模态框
  2466. $scope.showDetail = function (id) {
  2467. var modalInstance = $modal.open({
  2468. templateUrl: 'static/view/user/organization_detail.html',
  2469. controller: 'OrgDetailCtrl',
  2470. size: 'lg',
  2471. resolve: {
  2472. id: function () {
  2473. return id;
  2474. }
  2475. }
  2476. });
  2477. modalInstance.result.then(function(data){
  2478. if (data.success) {
  2479. toaster.pop('success', '操作成功');
  2480. }
  2481. $scope.orgParams.reload();
  2482. }, function(){
  2483. });
  2484. };
  2485. }]);
  2486. /**
  2487. * 机构详情框
  2488. */
  2489. app.controller('OrgDetailCtrl', ['$scope', 'Organization', 'toaster', '$modalInstance', 'BaseService', 'id', '$modal',
  2490. function($scope, Organization, toaster, $modalInstance, BaseService, id, $modal) {
  2491. var loadData = function() {
  2492. // 获取项目详情
  2493. Organization.getDetailById({id :id}, {}, function(data) {
  2494. $scope.org = data;
  2495. }, function() {
  2496. toaster.pop('error', '详情加载失败');
  2497. });
  2498. };
  2499. loadData();
  2500. $scope.cancel= function() {
  2501. $modalInstance.dismiss();
  2502. };
  2503. // true通过 false驳回
  2504. $scope.auditOrg = function(type) {
  2505. var modalInstance = $modal.open({
  2506. animation: true,
  2507. templateUrl: 'static/view/user/org_audit.html',
  2508. controller: 'OrgAuditCtrl',
  2509. resolve: {
  2510. org : function() {
  2511. return $scope.org;
  2512. },
  2513. type : function() {
  2514. return type;
  2515. }
  2516. }
  2517. });
  2518. modalInstance.result.then(function(data){
  2519. if (data.success) {
  2520. toaster.pop('success','操作成功');
  2521. }
  2522. if (data.error) {
  2523. toaster.pop('error','操作失败');
  2524. }
  2525. loadData();
  2526. }, function(){
  2527. });
  2528. };
  2529. }]);
  2530. /**
  2531. * 审核机构框
  2532. */
  2533. app.controller('OrgAuditCtrl', ['$scope', 'Organization', 'toaster', '$modalInstance', 'BaseService', 'org', 'type',
  2534. function($scope, Organization, toaster, $modalInstance, BaseService, org, type) {
  2535. $scope.org = org;
  2536. // 区别是通过还是驳回
  2537. $scope.result = type;
  2538. $scope.cancel= function() {
  2539. $modalInstance.dismiss();
  2540. };
  2541. // true通过 false驳回
  2542. $scope.ensure = function(type) {
  2543. if (type) {
  2544. Organization.agree({id: $scope.org.id}, {}, function () {
  2545. toaster.pop('success', '审核成功');
  2546. });
  2547. } else {
  2548. Organization.disagree({id: $scope.org.id, refuse: $scope.org.refuse}, {}, function () {
  2549. toaster.pop('success', '驳回成功');
  2550. });
  2551. }
  2552. };
  2553. }]);
  2554. return app;
  2555. });