app.js 97 KB

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