| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605 |
- /**
- * index
- *
- */
- 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) {
- 'use strict';
- var app = angular.module('myApp', [ 'ui.router', 'ui.bootstrap', 'ng.local', 'ngTable', 'angularFileUpload', 'common.directives', 'common.services', 'toaster', 'ngSanitize', 'ProjectService', 'ActivityService', 'OrganizationService', 'ui.form']);
- app.init = function() {
- angularAMD.bootstrap(app);
- };
- app.config(['$httpProvider', function ($httpProvider) {
- // http拦截
- $httpProvider.interceptors.push('httpInterceptor');
- }]);
- app.factory('httpInterceptor', ['$window', '$q', '$injector', 'BaseService', function ($window, $q, $injector, BaseService) {
- var httpInterceptor = {
- 'responseError': function (response) {
- if (response.status == 401) {// UNAUTHORIZED
- window.location.href = response.data.loginUrl || 'index';
- return $q.reject(response);
- }
- return $q.reject(response);
- }
- }
- return httpInterceptor;
- }]);
- app.config(['$stateProvider', '$urlRouterProvider', function($stateProvider, $urlRouterProvider) {
- $urlRouterProvider.otherwise("/");
- $stateProvider.state("project", {
- url : '/',
- title : '项目列表',
- templateUrl : 'static/view/project/project_list.html',
- controller : 'ProjectListCtrl'
- }).state("launchProject1", {
- url : '/launchProject/baseInfo',
- title : '项目发起1',
- templateUrl : 'static/view/project/project_launch_1.html',
- controller : 'ProjectNewCtrl'
- }).state("launchProject2", {
- url : '/launchProject/detail/:id',
- title : '项目发起2',
- templateUrl : 'static/view/project/project_launch_2.html',
- controller : 'ProjectNewCtrl'
- }).state("launchProjectSuccess", {
- url : '/launchProject/success',
- title : '项目发起完成',
- templateUrl : 'static/view/project/project_launch_3.html',
- controller : 'ProjectNewCtrl'
- }).state("projectFinance", {
- url : '/project/finance',
- title : '项目财务披露',
- templateUrl : 'static/view/project/project_list_finance.html',
- controller : 'ProjectFinanceListCtrl'
- }).state("projectReport", {
- url : '/project/report',
- title : '项目报告',
- templateUrl : 'static/view/project/project_list_report.html',
- controller : 'ProjectReportListCtrl'
- }).state("projectManagement", {
- url : '/project/management',
- title : '项目结项管理',
- templateUrl : 'static/view/project/project_list_management.html',
- controller : 'ProjectManagementListCtrl'
- }).state("activityList", {
- url : '/activity',
- title : '活动列表',
- templateUrl : 'static/view/activity/activity_list.html',
- controller : 'ActivityListCtrl'
- }).state("launchActivity", {
- url : '/launchActivity',
- title : '发起活动',
- templateUrl : 'static/view/activity/activity_launch.html',
- controller : 'ActivityNewCtrl'
- }).state("selectInstitutionsNature", {
- url : '/selectInstitutionsNature',
- title : '机构入驻选择',
- templateUrl : 'static/view/user/selectInstitutionsNature.html',
- controller : 'SelectInstitutionsNatureCtrl'
- }).state("charityCertificationStep0", {
- url : '/charityCertificationStep0',
- title : '公益机构认证协议',
- templateUrl : 'static/view/user/charityCertification.html',
- controller : 'CertificationStep0Ctrl'
- }).state("charityCertificationStep1", {
- url : '/charityCertificationStep1',
- title : '公益机构认证第一步',
- templateUrl : 'static/view/user/charityCertification1.html',
- controller : 'CertificationStep1Ctrl'
- }).state("charityCertificationStep2", {
- url : '/charityCertificationStep2',
- title : '公益机构认证第二步',
- templateUrl : 'static/view/user/charityCertification2.html',
- controller : 'CertificationStep2Ctrl'
- }).state("charityCertificationStep3", {
- url : '/charityCertificationStep3',
- title : '公益机构认证第三步',
- templateUrl : 'static/view/user/charityCertification3.html',
- controller : 'CertificationStep3Ctrl'
- }).state("charityCertificationStep4", {
- url : '/charityCertificationStep4',
- title : '公益机构认证完成',
- templateUrl : 'static/view/user/charityCertification4.html',
- controller : 'CertificationStep4Ctrl'
- }).state("publicOfferingCertificationStep0", {
- url : '/publicOfferingCertificationStep0',
- title : '公募机构认证协议',
- templateUrl : 'static/view/user/publicOfferingCertification.html',
- controller : 'CertificationStep0Ctrl'
- }).state("publicOfferingCertificationStep1", {
- url : '/publicOfferingCertificationStep1',
- title : '公募机构认证第一步',
- templateUrl : 'static/view/user/publicOfferingCertification1.html',
- controller : 'CertificationStep1Ctrl'
- }).state("publicOfferingCertificationStep2", {
- url : '/publicOfferingCertificationStep2',
- title : '公募机构认证第二步',
- templateUrl : 'static/view/user/publicOfferingCertification2.html',
- controller : 'CertificationStep2Ctrl'
- }).state("publicOfferingCertificationStep3", {
- url : '/publicOfferingCertificationStep3',
- title : '公募机构认证第三步',
- templateUrl : 'static/view/user/publicOfferingCertification3.html',
- controller : 'CertificationStep3Ctrl'
- }).state("publicOfferingCertificationStep4", {
- url : '/publicOfferingCertificationStep4',
- title : '公募机构认证第四步',
- templateUrl : 'static/view/user/publicOfferingCertification4.html',
- controller : 'PublicCertificationStep4Ctrl'
- }).state("publicOfferingCertificationStep5", {
- url : '/publicOfferingCertificationStep5',
- title : '公益机构认证完成',
- templateUrl : 'static/view/user/publicOfferingCertification5.html',
- controller : 'charityCertificationStep4Ctrl'
- }).state("organizationList", {
- url : '/organization/list',
- title : '机构列表',
- templateUrl : 'static/view/user/organization_list.html',
- controller : 'OrgListCtrl'
- }).state("userList", {
- url : '/user/list',
- title : '用户列表',
- templateUrl : 'static/view/user/user_list.html',
- controller : 'UserListCtrl'
- });
- }]);
- // html转义
- var htmlEncode = function(sHtml) {
- return sHtml.replace(/[<>&"]/g,function(c){return {'<':'<','>':'>','&':'&','"':'"'}[c];});
- };
- var getObjectURL = function (file) {
- var url = null;
- if (window.createObjectURL != undefined) { // basic
- url = window.createObjectURL(file);
- } else if (window.URL != undefined) { // mozilla(firefox)
- url = window.URL.createObjectURL(file);
- } else if (window.webkitURL != undefined) { // webkit or chrome
- url = window.webkitURL.createObjectURL(file);
- }
- return url;
- };
- /**
- * 项目列表
- */
- app.controller('ProjectListCtrl', ['$scope', '$rootScope', 'toaster', 'ngTableParams', 'BaseService', 'Project', '$modal',
- function ($scope, $rootScope, toaster, ngTableParams, BaseService, Project, $modal) {
- var getProjectState = function (active) {
- var fn = 'getAudited';
- switch (active) {
- // 已审核
- case 'audited':
- fn = 'getAudited';
- break;
- // 未审核
- case 'unaudited':
- fn = 'getUnaudited';
- break;
- // 未通过
- case 'disagreed':
- fn = 'getDisagreed';
- break;
- }
- return fn;
- };
- $scope.active = 'audited';
- $scope.keyword = '';
- /**
- * 修改分类
- * @param value
- */
- $scope.setState = function (value) {
- if ($scope.active != value) {
- $scope.active = value;
- if ($scope.projectParams.page() == 1)
- $scope.projectParams.reload();
- else
- $scope.projectParams.page(1);
- }
- };
- /**
- * 修改领域
- * @param value
- */
- $scope.setArea = function (value) {
- if ($scope.selectedArea != value) {
- $scope.selectedArea = value;
- if ($scope.projectParams.page() == 1)
- $scope.projectParams.reload();
- else
- $scope.projectParams.page(1);
- }
- };
- $scope.reload = function() {
- if ($scope.projectParams.page() == 1)
- $scope.projectParams.reload();
- else
- $scope.projectParams.page(1);
- };
- $scope.projectParams = new ngTableParams({
- page: 1,
- count: 10,
- sorting: {
- 'id': 'desc'
- }
- }, {
- total: 0,
- counts: [],
- getData: function ($defer, params) {
- $scope.loading = true;
- var pageParams = params.url();
- var realActive = {};
- pageParams.searchFilter = { // 筛选条件
- keyword: $scope.keyword,
- area: $scope.selectedArea
- };
- Project[getProjectState($scope.active)].call(null, BaseService.parseParams(pageParams), function (page) {
- $scope.loading = false;
- if (page) {
- params.total(page.totalElements);
- $defer.resolve(page.content);
- // $scope.keywordXls = angular.copy($scope.keyword); // 保存当前取值的关键词 做导出时需要的字段
- }
- }, function (response) {
- $scope.loading = false;
- toaster.pop('error', '数据加载失败', response.data);
- });
- }
- });
- var getNum = function() {
- Project.getProjectsNum({}, {}, function(data) {
- $scope.auditedNum = data.auditedNum;
- $scope.unauditedNum = data.unauditedNum;
- $scope.disagreedNum = data.disagreedNum;
- });
- };
- getNum();
- $scope.onSearch = function () {
- if ($scope.projectParams.page() == 1)
- $scope.projectParams.reload();
- else
- $scope.projectParams.page(1);
- };
- // $scope.onSearch = function (keyword) {
- // if (!angular.isUndefined(keyword)) {
- // $scope.keyword = keyword;
- // if ($scope.projectParams.page() == 1)
- // $scope.projectParams.reload();
- // else
- // $scope.projectParams.page(1);
- // }
- // };
- // 弹出详情页模态框
- $scope.showDetail = function (id) {
- var modalInstance = $modal.open({
- templateUrl: 'static/view/project/project_detail.html',
- controller: 'ProjectDetailCtrl',
- size: 'lg',
- resolve: {
- id: function () {
- return id;
- }
- }
- });
- modalInstance.result.then(function(data){
- if (data.success) {
- toaster.pop('success', '操作成功');
- }
- $scope.projectParams.reload();
- }, function(){
- });
- };
- }]);
- /**
- * 项目详情框
- */
- app.controller('ProjectDetailCtrl', ['$scope', 'Project', 'toaster', '$modalInstance', 'BaseService', 'id', '$modal', '$sce',
- function($scope, Project, toaster, $modalInstance, BaseService, id, $modal, $sce) {
- var loadData = function() {
- // 获取项目详情
- Project.getDetailById({id :id}, {}, function(data) {
- $scope.project = data;
- $scope.code = $sce.trustAsHtml($scope.project.introduction);
- }, function() {
- toaster.pop('error', '详情加载失败');
- });
- };
- // 获取当前项目所有进度
- $scope.getSchedules = function() {
- Project.getSchedules({id : id}, {}, function(data) {
- $scope.schedules = data;
- }, function() {
- toaster.pop('error', '项目进度加载失败');
- });
- };
- // 获取当前项目捐款明细
- $scope.getRecords = function() {
- Project.getRecords({id:id}, {}, function(data) {
- $scope.projectRecords = data;
- }, function() {
- toaster.pop('error', '捐款明细加载失败');
- });
- };
- // 获取当前项目财务信息
- $scope.getFinance = function() {
- Project.getFinance({id:id}, {}, function(data) {
- $scope.projectFinance = data.projectFinance;
- $scope.totalCost = data.totalCost;
- $scope.executeCost = data.executeCost;
- $scope.projectCost = data.projectCost;
- }, function() {
- toaster.pop('error','财务明细加载失败');
- });
- };
- loadData();
- $scope.cancel= function() {
- $modalInstance.dismiss();
- };
- $scope.deleteSchedule = function(scheduleId) {
- Project.deleteSchedule({id: scheduleId}, {}, function() {
- toaster.pop('success', '操作成功');
- // 重新加载
- $scope.getSchedules();
- }, function() {
- toaster.pop('error', '出现错误,操作失败');
- });
- };
- // true通过 false驳回
- $scope.decide = function(type) {
- var modalInstance = $modal.open({
- animation: true,
- templateUrl: 'static/view/project/audit_confirm.html',
- controller: 'AuditConfirmCtrl',
- resolve: {
- project : function() {
- return $scope.project;
- },
- type : function() {
- return type;
- }
- }
- });
- modalInstance.result.then(function(data){
- if (data.success) {
- toaster.pop('success','操作成功');
- }
- if (data.error) {
- toaster.pop('error','操作失败');
- }
- loadData();
- }, function(){
- });
- };
- // 重新申请
- $scope.reapply = function() {
- Project.reapply({id:id}, {}, function(data) {
- if (data.success) {
- toaster.pop('success', '重新申请成功');
- }
- if (data.error) {
- toaster.pop('error', '申请失败,请联系管理员');
- }
- loadData();
- }, function(response) {
- toaster("error", "出现错误");
- });
- }
- }]);
- /**
- * 审核确认框
- */
- app.controller('AuditConfirmCtrl', ['$scope', 'project', 'type', '$modalInstance', 'toaster', 'Project',
- function($scope, project, type, $modalInstance, toaster, Project) {
- $scope.result = type;
- $scope.project = project;
- $scope.ok = function (type) {
- if (type) {
- Project.agree({id: project.id}, {}, function(data) {
- $modalInstance.close(data);
- }, function() {
- });
- } else {
- Project.disagree({id: project.id, refuse: project.refuse}, {}, function(data) {
- $modalInstance.close(data);
- }, function() {
- });
- }
- };
- $scope.cancel = function() {
- $modalInstance.dismiss();
- };
- }]);
- /**
- * 机构入驻选择
- */
- app.controller('SelectInstitutionsNatureCtrl', ['$scope', 'toaster', 'Organization', '$location',
- function ($scope, toaster, Organization, $location) {
- // 获取当前账户注册机构情况
- Organization.getByUuid({uuid : 222222}, {}, function(data) {//10041558
- $scope.org = data;
- }, function() {
- toaster.pop('error', '注册情况加载失败');
- });
- //公益机构注册
- $scope.registerCharityCertification = function () {
- if (typeof $scope.org.id == 'undefined') {
- $location.path('charityCertificationStep0');
- } else {
- if ($scope.org.type == 2) {
- //之前已填写过公益机构注册信息
- if ($scope.org.publish != 2) {
- //未完成或保存为草稿
- $location.path('charityCertificationStep1');
- } else {
- //发布正式
- if ($scope.org.status == 0) {
- //已发布待审核 (暂时)
- $location.path('charityCertificationStep4');
- } else if ($scope.org.status == 1) {
- //已发布已审核
- $location.path('charityCertificationStep4');
- } else if ($scope.org.status == 2) {
- //已发布已驳回
- $location.path('charityCertificationStep1');
- }
- }
- } else if ($scope.org.type == 1) {
- //之前填写过公募机构注册信息
- if ($scope.org.publish != 2) {
- //未完成或保存为草稿
- //TODO 模态框判断
- var decideContinue = false;
- if (decideContinue) {
- //TODO 继续注册公益机构并替换掉之前的公募机构注册信息
- $location.path('charityCertificationStep0');
- } else {
- //TODO 继续之前的公募机构注册信息
- toaster.pop('info', '继续之前的公募机构注册信息');
- $location.path('publicOfferingCertificationStep1');
- }
- } else {
- //发布正式
- if ($scope.org.status == 0) {
- //已发布待审核 (暂时)
- $location.path('publicOfferingCertificationStep5');
- } else if ($scope.org.status == 1) {
- //已发布已审核
- $location.path('publicOfferingCertificationStep5');
- } else if ($scope.org.status == 2) {
- //已发布已驳回
- $location.path('publicOfferingCertificationStep1');
- }
- }
- }
- }
- }
- //公募机构注册
- $scope.registerPublicOfferingCertification = function () {
- if (typeof $scope.org.id == 'undefined') {
- $location.path('publicOfferingCertificationStep0');
- } else {
- if ($scope.org.type == 1) {
- //之前已填写过公募机构注册信息
- if ($scope.org.publish != 2) {
- //未完成或保存为草稿
- $location.path('publicOfferingCertificationStep1');
- } else {
- //发布正式
- if ($scope.org.status == 0) {
- //已发布待审核 (暂时)
- $location.path('publicOfferingCertificationStep5');
- } else if ($scope.org.status == 1) {
- //已发布已审核
- $location.path('publicOfferingCertificationStep5');
- } else if ($scope.org.status == 2) {
- //已发布已驳回
- $location.path('publicOfferingCertificationStep1');
- }
- }
- } else if ($scope.org.type == 2) {
- //之前填写过公益机构注册信息
- if ($scope.org.publish != 2) {
- //未完成或保存为草稿
- //TODO 模态框判断
- var decideContinue = false;
- if (decideContinue) {
- //TODO 继续注册公募机构并替换掉之前的公益机构注册信息
- $location.path('publicOfferingCertificationStep0');
- } else {
- //TODO 继续之前的公益机构注册信息
- toaster.pop('info', '继续之前的公益机构注册信息');
- $location.path('charityCertificationStep1');
- }
- } else {
- //发布正式
- if ($scope.org.status == 0) {
- //已发布待审核 (暂时)
- $location.path('charityCertificationStep4');
- } else if ($scope.org.status == 1) {
- //已发布已审核
- $location.path('charityCertificationStep4');
- } else if ($scope.org.status == 2) {
- //已发布已驳回
- $location.path('charityCertificationStep1');
- }
- }
- }
- }
- }
- }]);
- /**
- * 机构入驻同意协议
- */
- app.controller('CertificationStep0Ctrl', ['$scope', 'toaster', 'Organization', '$location',
- function ($scope, toaster, Organization, $location) {
- $scope.checked = false;
- $scope.changeChecked = function() {
- $scope.checked = !$scope.checked;
- };
- $scope.stepNext = function (checked, orgType) {
- if (checked) {
- if (orgType == 1) {
- $location.path('publicOfferingCertificationStep1');
- } else if (orgType == 2) {
- $location.path('charityCertificationStep1');
- }
- }
- }
- // 获取当前账户注册机构情况
- Organization.getByUuid({uuid : 222222}, {}, function(data) {//10041558
- if (typeof data.id == 'undefined') {
- return;
- }
- $scope.checked = true;
- }, function() {
- toaster.pop('error', '注册情况加载失败');
- });
- }]);
- /**
- * 机构认证第一步
- */
- app.controller('CertificationStep1Ctrl', ['$scope', '$http', '$rootScope', '$timeout', '$location', 'toaster', 'Organization',
- function ($scope, $http, $rootScope, $timeout, $location, toaster, Organization) {
- // 主要领域
- // $scope.areas = ['疾病援助', '扶贫/救灾', '教育/助学' , '环境/动物保护', '其他'];
- $scope.org = {
- majorArea: 1
- };
- var orgCopy;
- // 获取当前账户注册机构情况
- Organization.getByUuid({uuid : 222222}, {}, function(data) {//10041558
- if (typeof data.id == 'undefined') {
- return;
- }
- $scope.org = data;
- orgCopy = angular.copy($scope.org);
- }, function() {
- toaster.pop('error', '注册情况加载失败');
- });
- // 获取地址信息
- $http.get('static/jsondata/city.json', {
- "Accept": "application/json;charset=utf-8", "Accept-Charset": "charset=utf-8"
- }).then(function (response) {
- $scope.provinces = response.data;
- });
- // 设置主要领域
- $scope.selectMajorArea = function(index) {
- $scope.org.majorArea = index;
- };
- $scope.openDatePicker = function ($event, item, openParam) {
- $event.preventDefault();
- $event.stopPropagation();
- item[openParam] = !item[openParam];
- };
- //提交
- $scope.saveStep1 = function (org, orgType) {
- if (orgCopy == org) {
- if (orgType == 1) {
- $location.path('publicOfferingCertificationStep2');
- } else if (orgType == 2) {
- $location.path('charityCertificationStep2');
- }
- } else {
- org.type = orgType;//机构类别(1:公募 2:非公募)
- //var file = $scope.myFiles, file = file && file.length > 0 ? file[0] : null;// 可以不传附件
- $http({
- method : 'POST',
- url : '/org/save',
- params : {
- jsonStr : org
- },
- }).success(function (data) {
- if (data.success) {
- toaster.pop('success', '提示', data.success);
- /*$timeout(function () {
- //提交后跳转到下一页,防止重复提交
- window.location.href = "#/charityCertification2;
- }, 500);*/
- if (orgType == 1) {
- $location.path('publicOfferingCertificationStep2');
- } else if (orgType == 2) {
- $location.path('charityCertificationStep2');
- }
- }
- if (data.error) {
- toaster.pop('error', '提示', data.error);
- }
- }).error(function (data, status) {
- $scope.loadingShow = false;
- if (status == 403) {
- toaster.pop('error', '操作失败', data);
- } else {
- toaster.pop('error', '操作失败', data.error);
- }
- });
- }
- };
- }]);
- /**
- * 机构认证第二步
- */
- app.controller('CertificationStep2Ctrl', ['$scope', '$http', '$rootScope', '$timeout', '$location', 'toaster', 'Organization',
- function ($scope, $http, $rootScope, $timeout, $location, toaster, Organization) {
- var orgCopy;
- // 获取当前账户注册机构情况
- Organization.getByUuid({uuid : 222222}, {}, function(data) {//10041558
- $scope.org = data;
- orgCopy = angular.copy($scope.org);
- }, function() {
- toaster.pop('error', '注册情况加载失败');
- });
- //提交
- $scope.saveStep2 = function (org, orgType) {
- if (orgCopy == org) {
- if (orgType == 1) {
- $location.path('publicOfferingCertificationStep3');
- } else if (orgType == 2) {
- $location.path('charityCertificationStep3');
- }
- } else {
- $http({
- method: 'POST',
- url: '/org/save',
- params: {
- jsonStr: org
- },
- }).success(function (data) {
- if (data.success) {
- if (orgType == 1) {
- $location.path('publicOfferingCertificationStep3');
- } else if (orgType == 2) {
- $location.path('charityCertificationStep3');
- }
- }
- if (data.error) {
- toaster.pop('error', '提示', data.error);
- }
- }).error(function (data, status) {
- $scope.loadingShow = false;
- if (status == 403) {
- toaster.pop('error', '操作失败', data);
- } else {
- toaster.pop('error', '操作失败', data.error);
- }
- });
- }
- };
- }]);
- /**
- * 机构认证第三步
- */
- app.controller('CertificationStep3Ctrl', ['$scope', '$http', '$rootScope', '$timeout', '$location', 'toaster', 'Organization',
- function ($scope, $http, $rootScope, $timeout, $location, toaster, Organization) {
- var orgCopy;
- // 获取当前账户注册机构情况
- Organization.getByUuid({uuid : 222222}, {}, function(data) {//10041558
- if (typeof data.id == 'undefined') {
- return;
- }
- $scope.org = data;
- $scope.logoUrl = $scope.org.logo;
- $scope.personCertificateUrl = $scope.org.personCertificate;
- $scope.donateCertificateUrl = $scope.org.donateCertificate;
- $scope.legalIdCardUrl = $scope.org.legalIdCard;
- orgCopy = angular.copy($scope.org);
- }, function() {
- toaster.pop('error', '注册情况加载失败');
- });
- // 获取银行信息
- $scope.getBankName = function (bankCard) {
- if (bankCard == null) {
- $scope.org.branchMessage = "";
- } else if(bankCard.toString().length < 6) {
- $scope.org.branchMessage = "";
- } else {
- bankCard = bankCard.toString();
- $.getJSON("static/jsondata/bank.json", {}, function (data) {
- var bankBin = 0;
- var isFind = false;
- for (var key = 10; key >= 2; key--) {
- bankBin = bankCard.substring(0, key);
- $.each(data, function (i, item) {
- if (item.bin == bankBin) {
- isFind = true;
- $scope.org.branchMessage = item.bankName;
- }
- });
- if (isFind) {
- break;
- }
- }
- if (!isFind) {
- $scope.org.branchMessage = "未知发卡银行";
- }
- });
- }
- }
- /*$scope.fileChanged = function(ele, order){
- if (order == 0) {
- $scope.logo = ele.files[0];
- } else if (order == 1) {
- $scope.personCertificate = ele.files[0];
- } else if (order == 2) {
- $scope.donateCertificate = ele.files[0];
- } else if (order == 3) {
- $scope.legalIdCard = ele.files[0];
- }
- $scope.$apply();
- };*/
- //建立一个可存取到该file的url
- var getObjectURL = function (file) {
- var url = null;
- if (window.createObjectURL != undefined) { // basic
- url = window.createObjectURL(file);
- } else if (window.URL != undefined) { // mozilla(firefox)
- url = window.URL.createObjectURL(file);
- } else if (window.webkitURL != undefined) { // webkit or chrome
- url = window.webkitURL.createObjectURL(file);
- }
- return url;
- };
- // 图片上传
- $scope.fileChanged = function(ele, order){
- if (order == 0) {
- $scope.logo = ele.files[0];
- $scope.logoUrl = getObjectURL($scope.logo);
- } else if (order == 1) {
- $scope.personCertificate = ele.files[0];
- $scope.personCertificateUrl = getObjectURL($scope.personCertificate);
- } else if (order == 2) {
- $scope.donateCertificate = ele.files[0];
- $scope.donateCertificateUrl = getObjectURL($scope.donateCertificate);
- } else if (order == 3) {
- $scope.legalIdCard = ele.files[0];
- $scope.legalIdCardUrl = getObjectURL($scope.legalIdCard);
- }
- $scope.$apply();
- };
- // 查看范例
- $scope.showImg = function (type) {
- var img = null;
- var imgUrl = null;
- switch (type) {
- case 'logo':
- img = $scope.org.logo;
- imgUrl = $scope.logoUrl;
- break;
- case 'personCertificate':
- img = $scope.org.personCertificate;
- imgUrl = $scope.personCertificateUrl;
- break;
- case 'donateCertificate':
- img = $scope.org.donateCertificate;
- imgUrl = $scope.donateCertificateUrl;
- break;
- case 'legalIdCard':
- img = $scope.org.legalIdCard;
- imgUrl = $scope.legalIdCardUrl;
- break;
- }
- if (img) {
- var src = img, box = $('#image-box');
- box.show();
- box.find('img').attr('src', src);
- box.find('a').click(function () {
- box.hide();
- });
- box.dblclick(function () {
- box.hide();
- });
- } else if (imgUrl != null) {
- var src = imgUrl, box = $('#image-box');
- box.show();
- box.find('img').attr('src', src);
- box.find('a').click(function () {
- box.hide();
- });
- box.dblclick(function () {
- box.hide();
- });
- }
- };
- // 删除
- $scope.clearFile = function (type) {
- switch (type) {
- case 'logo':
- $scope.logo = null;
- $scope.logoUrl = null;
- break;
- case 'personCertificate':
- $scope.personCertificate = null;
- $scope.personCertificateUrl = null;
- break;
- case 'donateCertificate':
- $scope.donateCertificate = null;
- $scope.donateCertificateUrl = null;
- break;
- case 'legalIdCard':
- $scope.legalIdCard = null;
- $scope.legalIdCardUrl = null;
- break;
- }
- // 清空input框的内容
- var file=document.getElementById(type);
- //IE,Safari,chrome
- if(file.outerHTML){
- file.outerHTML=file.outerHTML;
- }
- else{ //FF
- file.value="";
- }
- };
- //提交
- $scope.saveStep3 = function (org, isDraft, orgType) {
- if (orgCopy == org) {
- if (orgType == 1) {
- $location.path('publicOfferingCertificationStep4');
- } else if (orgType == 2) {
- $location.path('charityCertificationStep4');
- }
- } else {
- var url;
- if (isDraft) {
- url = '/org/save';
- } else {
- url = '/org/submit';
- }
- var data = new FormData(); //以下为像后台提交图片数据
- data.append('logo', $scope.logo);
- data.append('personCertificate', $scope.personCertificate);
- data.append('donateCertificate', $scope.donateCertificate);
- data.append('legalIdCard', $scope.legalIdCard);
- $http({
- headers: {
- 'Content-Type': undefined
- },
- method: 'POST',
- processData: false,
- async: false,
- url: url,
- data: data,
- params: {
- jsonStr: org
- },
- }).success(function (data) {
- if (data.success) {
- if (orgType == 1) {
- $location.path('publicOfferingCertificationStep4');
- } else if (orgType == 2) {
- $location.path('charityCertificationStep4');
- }
- }
- if (data.error) {
- toaster.pop('error', '提示', data.error);
- }
- }).error(function (data, status) {
- $scope.loadingShow = false;
- if (status == 403) {
- toaster.pop('error', '操作失败', data);
- } else {
- toaster.pop('error', '操作失败', data.error);
- }
- });
- }
- };
- }]);
- /**
- * 公募机构认证第四步
- */
- app.controller('PublicCertificationStep4Ctrl', ['$scope', '$http', '$rootScope', '$timeout', '$location', 'toaster', 'Organization',
- function ($scope, $http, $rootScope, $timeout, $location, toaster, Organization) {
- var orgCopy;
- // 获取当前账户注册机构情况
- Organization.getByUuid({uuid : 222222}, {}, function(data) {//10041166 10041558
- if (typeof data.id == 'undefined') {
- return;
- }
- $scope.org = data;
- $scope.materialUrl = $scope.org.material;
- $scope.certifyUrl = $scope.org.certify;
- orgCopy = angular.copy($scope.org);
- }, function() {
- toaster.pop('error', '注册情况加载失败');
- });
- /*$scope.fileChanged = function(ele, order){
- if (order == 0) {
- //合作商户资料
- $scope.material = ele.files[0];
- } else if (order == 1) {
- //结算银行账号证明
- $scope.certify = ele.files[0];
- }
- $scope.$apply();
- }*/
- //建立一个可存取到该file的url
- var getObjectURL = function (file) {
- var url = null;
- if (window.createObjectURL != undefined) { // basic
- url = window.createObjectURL(file);
- } else if (window.URL != undefined) { // mozilla(firefox)
- url = window.URL.createObjectURL(file);
- } else if (window.webkitURL != undefined) { // webkit or chrome
- url = window.webkitURL.createObjectURL(file);
- }
- return url;
- };
- // 图片上传
- $scope.fileChanged = function(ele, order){
- if (order == 0) {
- $scope.material = ele.files[0];
- $scope.materialUrl = getObjectURL($scope.material);
- } else if (order == 1) {
- $scope.certify = ele.files[0];
- $scope.certifyUrl = getObjectURL($scope.certify);
- }
- $scope.$apply();
- };
- // 查看范例
- $scope.showImg = function (type) {
- var img = null;
- var imgUrl = null;
- switch (type) {
- case 'material':
- img = $scope.org.material;
- imgUrl = $scope.materialUrl;
- break;
- case 'certify':
- img = $scope.org.certify;
- imgUrl = $scope.certifyUrl;
- break;
- }
- if (img) {
- var src = img, box = $('#image-box');
- box.show();
- box.find('img').attr('src', src);
- box.find('a').click(function () {
- box.hide();
- });
- box.dblclick(function () {
- box.hide();
- });
- } else if (imgUrl != null) {
- var src = imgUrl, box = $('#image-box');
- box.show();
- box.find('img').attr('src', src);
- box.find('a').click(function () {
- box.hide();
- });
- box.dblclick(function () {
- box.hide();
- });
- }
- };
- // 删除
- $scope.clearFile = function (type) {
- switch (type) {
- case 'material':
- $scope.material = null;
- $scope.materialUrl = null;
- break;
- case 'certify':
- $scope.certify = null;
- $scope.certifyUrl = null;
- break;
- }
- // 清空input框的内容
- var file=document.getElementById(type);
- //IE,Safari,chrome
- if(file.outerHTML){
- file.outerHTML=file.outerHTML;
- }
- else{ //FF
- file.value="";
- }
- };
- //提交
- $scope.saveStep4 = function (org, isDraft) {
- if (orgCopy == org) {
- $location.path('publicOfferingCertificationStep5');
- } else {
- var url;
- if (isDraft) {
- url = '/org/save';
- } else {
- url = '/org/submit';
- }
- var data = new FormData(); //以下为像后台提交图片数据
- data.append('material', $scope.material);
- data.append('certify', $scope.certify);
- $http({
- headers: {
- 'Content-Type': undefined
- },
- method: 'POST',
- processData: false,
- async: false,
- url: url,
- data: data,
- params: {
- jsonStr: org
- },
- }).success(function (data) {
- if (data.success) {
- $location.path('publicOfferingCertificationStep5');
- }
- if (data.error) {
- toaster.pop('error', '提示', data.error);
- }
- }).error(function (data, status) {
- $scope.loadingShow = false;
- if (status == 403) {
- toaster.pop('error', '操作失败', data);
- } else {
- toaster.pop('error', '操作失败', data.error);
- }
- });
- }
- };
- }]);
- /**
- * 新建项目
- */
- app.controller('ProjectNewCtrl', ['$scope', 'BaseService', 'Project', '$http', 'toaster', '$stateParams', '$rootScope',
- function($scope, BaseService, Project, $http, toaster, $stateParams, $rootScope) {
- if ($rootScope.active) {
- $rootScope.active = 'done';
- }
- // 默认捐助领域
- $scope.defaultAreas = ['疾病援助', '扶贫/救灾', '教育/助学' , '环境/动物保护', '其他'];
- // 默认具体分类
- var defaultClassifys = ['白血病', '早产儿', '烧烫伤', '罕见病', '癌症', '唇腭裂', '因病致贫', '尘肺病', '病情危急',
- '尿毒症', '渐冻症', '意外受伤', '贫困大病', '视力健康', '听障', '其他'];
- $scope.populations = ['第三世界', '贫困妇女', '空巢/留守老人', '孤儿/事实孤儿', '残障', '抗战老兵', '自闭症', '弱势群体',
- '走失儿童', '失独家庭', '山区孩子', '义工志愿者', '困境儿童', '贫困家庭', '少数民族', '其他'];
- $scope.checked = true;
- $scope.changeChecked = function() {
- $scope.checked = !$scope.checked;
- };
- // 获取已保存的项目
- var getSavedProject = function() {
- // 获取地址信息
- $http.get('static/jsondata/classify.json', {
- "Accept": "application/json;charset=utf-8", "Accept-Charset": "charset=utf-8"
- }).then(function (response) {
- $scope.areas = response.data;
- });
- Project.getSavedProject({}, {}, function(data) {
- if(angular.isObject(data)) {
- $scope.project = data;
- $scope.pcImgUrl = data.pcImg;
- $scope.mobileImgUrl = data.mobileImg;
- $scope.mobileListImgUrl = data.listImg;
- $scope.logoUrl = data.logo;
- }
- });
- if (!angular.isUndefined($stateParams.id)) {
- Project.getDetailById({id : $stateParams.id}, {}, function(data) {
- $scope.project = data;
- $scope.pcImgUrl = data.pcImg;
- $scope.mobileImgUrl = data.mobileImg;
- $scope.mobileListImgUrl = data.listImg;
- $scope.logoUrl = data.logo;
- });
- }
- if (angular.isUndefined($scope.project)) {
- $scope.project = {
- area: $scope.defaultAreas[0],
- classify: defaultClassifys[0],
- population: $scope.populations[0]
- };
- }
- };
- getSavedProject();
- // 日期选择
- $scope.openDatePicker = function ($event, item, openParam) {
- $event.preventDefault();
- $event.stopPropagation();
- item[openParam] = !item[openParam];
- };
- // 设置区域
- $scope.setArea = function(area) {
- $scope.project.area = area;
- $scope.classifys = $scope.areas[area];
- $scope.project.classify = $scope.areas[area][0];
- };
- // 设置具体分类
- $scope.setClassify = function(classify) {
- $scope.project.classify = classify;
- };
- // 设置受助人群
- $scope.setPopulation = function(index) {
- $scope.project.population = $scope.populations[index];
- };
- // 获取地址信息
- $http.get('static/jsondata/city.json', {
- "Accept": "application/json;charset=utf-8", "Accept-Charset": "charset=utf-8"
- }).then(function (response) {
- $scope.provinces = response.data;
- });
- // 保存基础信息
- $scope.saveBaseInfo = function(project) {
- Project.saveBaseInfo({}, project, function(data) {
- $scope.project = data;
- var proId = $scope.project.id;
- if(proId) {
- BaseService.scrollBackToTop();
- window.location.href = '#/launchProject/detail/' + proId;
- }
- },function(res) {
- toaster.pop('error', '出现错误,操作失败');
- });
- };
- // 删除
- $scope.cancel = function(type) {
- switch (type) {
- case 'pcImg':
- $scope.pcImg = null;
- break;
- case 'mobileImg':
- $scope.mobileImg = null;
- break;
- }
- };
- //建立一个可存取到该file的url
- var getObjectURL = function (file) {
- var url = null;
- if (window.createObjectURL != undefined) { // basic
- url = window.createObjectURL(file);
- } else if (window.URL != undefined) { // mozilla(firefox)
- url = window.URL.createObjectURL(file);
- } else if (window.webkitURL != undefined) { // webkit or chrome
- url = window.webkitURL.createObjectURL(file);
- }
- return url;
- };
- // 图片上传
- $scope.fileChanged = function(ele, order){
- if (order == 0) {
- $scope.pcImg = ele.files[0];
- $scope.pcImgUrl = getObjectURL($scope.pcImg);
- } else if (order == 1) {
- $scope.mobileImg = ele.files[0];
- $scope.mobileImgUrl = getObjectURL($scope.mobileImg);
- } if (order == 2) {
- $scope.mobileListImg = ele.files[0];
- $scope.mobileListImgUrl = getObjectURL($scope.mobileListImg);
- } if (order == 3) {
- $scope.logo = ele.files[0];
- $scope.logoUrl = getObjectURL($scope.logo);
- }
- $scope.$apply();
- };
- // 查看范例
- $scope.showImg = function (type) {
- var img = null;
- var imgUrl = null;
- switch (type) {
- case 'pcImg':
- img = $scope.project.pcImg;
- imgUrl = $scope.pcImgUrl;
- break;
- case 'mobileImg':
- img = $scope.project.mobileImg;
- imgUrl = $scope.mobileImgUrl;
- break;
- case 'mobileListImg':
- img = $scope.project.mobileListImg;
- imgUrl = $scope.mobileListImgUrl;
- break;
- case 'logo':
- img = $scope.project.logo;
- imgUrl = $scope.logoUrl;
- break;
- }
- if (img) {
- var src = img, box = $('#image-box');
- box.show();
- box.find('img').attr('src', src);
- box.find('a').click(function () {
- box.hide();
- });
- box.dblclick(function () {
- box.hide();
- });
- } else if (imgUrl != null) {
- var src = imgUrl, box = $('#image-box');
- box.show();
- box.find('img').attr('src', src);
- box.find('a').click(function () {
- box.hide();
- });
- box.dblclick(function () {
- box.hide();
- });
- }
- };
- // 删除
- $scope.clearFile = function (type) {
- switch (type) {
- case 'pcImg':
- $scope.pcImg = null;
- $scope.pcImgUrl = null;
- break;
- case 'mobileImg':
- $scope.mobileImg = null;
- $scope.mobileImgUrl = null;
- break;
- case 'mobileListImg':
- $scope.mobileListImg = null;
- $scope.mobileListImgUrl = null;
- break;
- case 'logo':
- $scope.logo = null;
- $scope.logoUrl = null;
- break;
- }
- // 清空input框的内容
- var file=document.getElementById(type);
- //IE,Safari,chrome
- if(file.outerHTML){
- file.outerHTML=file.outerHTML;
- }
- else{ //FF
- file.value="";
- }
- };
- //提交 或 保存
- $scope.saveDetail = function (project, type) {
- var data = new FormData(); //以下为像后台提交图片数据
- data.append('pcImg', $scope.pcImg);
- data.append('mobileImg', $scope.mobileImg);
- data.append('mobileListImg', $scope.mobileListImg);
- data.append('logo', $scope.logo);
- data.append('jsonStr', JSON.stringify(project));
- // type为true即为发布
- var url;
- if (type) {
- url = '/project/submit';
- } else {
- url = '/project/save';
- }
- $http({
- headers: {
- 'Content-Type': undefined
- },
- method : 'POST',
- processData : false,
- contentType: false,
- async: false,
- url : url,
- data: data
- }).success(function (data) {
- if (type) {
- toaster.pop('success', '发布成功');
- BaseService.scrollBackToTop();
- $rootScope.active = 'todo';
- window.location.href='#/launchProject/success';
- } else {
- toaster.pop('success', '保存成功');
- window.location.href='#/';
- }
- }).error(function (data) {
- $scope.loadingShow = false;
- toaster.pop('error', '出现错误,操作失败');
- });
- };
- }]);
- /**
- * 财务披露项目列表
- */
- app.controller('ProjectFinanceListCtrl', ['$scope', 'toaster', 'ngTableParams', 'BaseService', 'Project', '$modal',
- function ($scope, toaster, ngTableParams, BaseService, Project, $modal) {
- $scope.keyword = '';
- $scope.reload = function() {
- if ($scope.projectParams.page() == 1)
- $scope.projectParams.reload();
- else
- $scope.projectParams.page(1);
- };
- $scope.projectParams = new ngTableParams({
- page: 1,
- count: 5,
- sorting: {
- 'id': 'desc'
- }
- }, {
- total: 0,
- counts: [5, 10, 25, 50],
- getData: function ($defer, params) {
- $scope.loading = true;
- var pageParams = params.url();
- var realActive = {};
- pageParams.searchFilter = { // 筛选条件
- keyword: $scope.keyword
- };
- Project.getNotEnd.call(null, BaseService.parseParams(pageParams), function (page) {
- $scope.loading = false;
- if (page) {
- params.total(page.totalElements);
- $defer.resolve(page.content);
- // $scope.keywordXls = angular.copy($scope.keyword); // 保存当前取值的关键词 做导出时需要的字段
- }
- }, function (response) {
- $scope.loading = false;
- toaster.pop('error', '数据加载失败', response.data);
- });
- }
- });
- $scope.onSearch = function () {
- if ($scope.projectParams.page() == 1)
- $scope.projectParams.reload();
- else
- $scope.projectParams.page(1);
- };
- // 弹出详情页模态框
- $scope.showFinance = function (id) {
- var modalInstance = $modal.open({
- templateUrl: 'static/view/project/project_finance.html',
- controller: 'ProjectFinanceDetailCtrl',
- size: 'lg',
- resolve: {
- id: function () {
- return id;
- }
- }
- });
- modalInstance.result.then(function(data){
- if (data.success) {
- toaster.pop('success', '操作成功');
- }
- $scope.projectParams.reload();
- }, function(){
- });
- };
- }]);
- /**
- * 财务披露详情框
- */
- app.controller('ProjectFinanceDetailCtrl', ['$scope', 'Project', 'toaster', '$modalInstance', 'BaseService', 'id', '$upload', '$http',
- function($scope, Project, toaster, $modalInstance, BaseService, id, $upload, $http) {
- $scope.newFinance = {
- amount: null,
- path: null,
- description: null,
- type : null
- };
- $scope.imgUrl = null;
- var loadData = function() {
- // 获取项目详情
- Project.getDetailById({id :id}, {}, function(data) {
- $scope.project = data;
- }, function() {
- toaster.pop('error', '详情加载失败');
- });
- // 获取当前项目财务信息
- Project.getFinance({id:id}, {}, function(data) {
- $scope.projectFinance = data.projectFinance;
- $scope.totalCost = data.totalCost;
- $scope.executeCost = data.executeCost;
- $scope.projectCost = data.projectCost;
- }, function() {
- toaster.pop('error','财务明细加载失败');
- });
- };
- loadData();
- $scope.cancel= function() {
- $modalInstance.dismiss();
- };
- $scope.fileChanged = function(ele) {
- $scope.newFinance.file = ele.files[0];
- $scope.imgUrl = getObjectURL(ele.files[0]);
- };
- //建立一个可存取到该file的url
- var getObjectURL = function (file) {
- var url = null;
- if (window.createObjectURL != undefined) { // basic
- url = window.createObjectURL(file);
- } else if (window.URL != undefined) { // mozilla(firefox)
- url = window.URL.createObjectURL(file);
- } else if (window.webkitURL != undefined) { // webkit or chrome
- url = window.webkitURL.createObjectURL(file);
- }
- return url;
- };
- // // 查看范例
- // $scope.showImg = function () {
- // var imgUrl = $scope.imgUrl;
- // if (imgUrl != null) {
- // var src = imgUrl, box = $('#image-box');
- // box.show();
- // box.find('img').attr('src', src);
- // box.find('a').click(function () {
- // box.hide();
- // });
- // box.dblclick(function () {
- // box.hide();
- // });
- // }
- // };
- // 删除活动图或banner
- $scope.clearFile = function (type) {
- $scope.newFinance.file = null;
- $scope.imgUrl = null;
- // 清空input框的内容
- var file=document.getElementById(type);
- //IE,Safari,chrome
- if(file.outerHTML){
- file.outerHTML=file.outerHTML;
- }
- else{ //FF
- file.value="";
- }
- };
- // 发布
- $scope.saveFinance = function(finance) {
- var data = new FormData();
- data.append('json', JSON.stringify(finance));
- data.append('img', finance.file);
- $http({
- headers: {
- 'Content-Type': undefined
- },
- method: 'POST',
- processData: false,
- async: false,
- url: 'project/save/finance/' + id,
- data: data
- }).success(function(data){
- toaster.pop('success', '发布财务信息成功');
- $modalInstance.close();
- }).error(function(data){
- toaster.pop('error', '出现错误,发布失败');
- });
- };
- }]);
- /**
- * 报告填写项目列表
- */
- app.controller('ProjectReportListCtrl', ['$scope', 'toaster', 'ngTableParams', 'BaseService', 'Project', '$modal', '$http',
- function ($scope, toaster, ngTableParams, BaseService, Project, $modal, $http) {
- $scope.keyword = '';
- $scope.selectedArea = '全部';
- $scope.reload = function() {
- if ($scope.projectParams.page() == 1)
- $scope.projectParams.reload();
- else
- $scope.projectParams.page(1);
- };
- $scope.projectParams = new ngTableParams({
- page: 1,
- count: 5,
- sorting: {
- 'id': 'desc'
- }
- }, {
- total: 0,
- counts: [5, 10, 25, 50],
- getData: function ($defer, params) {
- $scope.loading = true;
- var pageParams = params.url();
- var realActive = {};
- pageParams.searchFilter = { // 筛选条件
- keyword: $scope.keyword,
- area: $scope.selectedArea
- };
- Project.getNotEnd.call(null, BaseService.parseParams(pageParams), function (page) {
- $scope.loading = false;
- if (page) {
- params.total(page.totalElements);
- $defer.resolve(page.content);
- // $scope.keywordXls = angular.copy($scope.keyword); // 保存当前取值的关键词 做导出时需要的字段
- }
- }, function (response) {
- $scope.loading = false;
- toaster.pop('error', '数据加载失败', response.data);
- });
- }
- });
- $scope.onSearch = function () {
- if ($scope.projectParams.page() == 1)
- $scope.projectParams.reload();
- else
- $scope.projectParams.page(1);
- };
- // 弹出详情页模态框
- $scope.showReport = function (id) {
- var modalInstance = $modal.open({
- templateUrl: 'static/view/project/project_report.html',
- controller: 'ProjectReportDetailCtrl',
- size: 'lg',
- resolve: {
- id: function () {
- return id;
- }
- }
- });
- modalInstance.result.then(function(data){
- if (data.success) {
- toaster.pop('success', '操作成功');
- }
- $scope.projectParams.reload();
- }, function(){
- });
- };
- }]);
- /**
- * 报告填写详情框
- */
- app.controller('ProjectReportDetailCtrl', ['$scope', 'Project', 'toaster', '$modalInstance', 'BaseService', 'id', '$http',
- function($scope, Project, toaster, $modalInstance, BaseService, id, $http) {
- $scope.report = {
- path: null,
- description: null
- };
- var loadData = function() {
- // 获取项目详情
- Project.getDetailById({id :id}, {}, function(data) {
- $scope.project = data;
- }, function() {
- toaster.pop('error', '详情加载失败');
- });
- // 获取当前项目所有进度
- Project.getSchedules({id : id}, {}, function(data) {
- $scope.schedules = data;
- }, function() {
- toaster.pop('error', '项目进度加载失败');
- });
- };
- loadData();
- // 图片上传
- $scope.fileChanged = function(ele){
- $scope.report.file = ele.files[0];
- $scope.imgUrl = getObjectURL(ele.files[0]);
- $scope.$apply();
- };
- $scope.cancel= function() {
- $modalInstance.dismiss();
- };
- // delete
- $scope.deleteSchedule = function(scheduleId) {
- Project.deleteSchedule({id: scheduleId}, {}, function() {
- toaster.pop('success', '操作成功');
- // 重新加载
- loadData();
- }, function() {
- toaster.pop('error', '出现错误,操作失败');
- });
- };
- // 发布
- $scope.saveReport = function(report) {
- var data = new FormData();
- data.append('json', JSON.stringify(report));
- data.append('img', report.file);
- $http({
- headers: {
- 'Content-Type': undefined
- },
- method: 'POST',
- processData: false,
- async: false,
- url: 'project/save/report/' + id,
- data: data
- }).success(function(data){
- toaster.pop('success', '发布进度信息成功');
- $modalInstance.close();
- }).error(function(data){
- toaster.pop('error', '出现错误,发布失败');
- });
- };
- }]);
- /**
- * 结项管理项目列表
- */
- app.controller('ProjectManagementListCtrl', ['$scope', 'toaster', 'ngTableParams', 'BaseService', 'Project', '$modal',
- function ($scope, toaster, ngTableParams, BaseService, Project, $modal) {
- $scope.keyword = '';
- $scope.selectedArea = '全部';
- $scope.reload = function() {
- if ($scope.projectParams.page() == 1)
- $scope.projectParams.reload();
- else
- $scope.projectParams.page(1);
- };
- $scope.projectParams = new ngTableParams({
- page: 1,
- count: 5,
- sorting: {
- 'id': 'desc'
- }
- }, {
- total: 0,
- counts: [5, 10, 25, 50],
- getData: function ($defer, params) {
- $scope.loading = true;
- var pageParams = params.url();
- var realActive = {};
- pageParams.searchFilter = { // 筛选条件
- keyword: $scope.keyword,
- area: $scope.selectedArea
- };
- Project.getNotEnd.call(null, BaseService.parseParams(pageParams), function (page) {
- $scope.loading = false;
- if (page) {
- params.total(page.totalElements);
- $defer.resolve(page.content);
- // $scope.keywordXls = angular.copy($scope.keyword); // 保存当前取值的关键词 做导出时需要的字段
- }
- }, function (response) {
- $scope.loading = false;
- toaster.pop('error', '数据加载失败', response.data);
- });
- }
- });
- $scope.onSearch = function () {
- if ($scope.projectParams.page() == 1)
- $scope.projectParams.reload();
- else
- $scope.projectParams.page(1);
- };
- // 弹出详情页模态框
- $scope.showManagement = function (id) {
- var modalInstance = $modal.open({
- templateUrl: 'static/view/project/project_management.html',
- controller: 'ProjectManagementDetailCtrl',
- size: 'lg',
- resolve: {
- id: function () {
- return id;
- }
- }
- });
- modalInstance.result.then(function(data){
- if (data.success) {
- toaster.pop('success', '操作成功');
- }
- $scope.projectParams.reload();
- }, function(){
- });
- };
- }]);
- /**
- * 结项管理详情框
- */
- app.controller('ProjectManagementDetailCtrl', ['$scope', 'Project', 'toaster', '$modalInstance', 'BaseService', 'id', '$http',
- function($scope, Project, toaster, $modalInstance, BaseService, id, $http) {
- $scope.conclude = {
- description: null
- };
- var loadData = function() {
- // 获取项目详情
- Project.getDetailById({id :id}, {}, function(data) {
- $scope.project = data;
- }, function() {
- toaster.pop('error', '详情加载失败');
- });
- // 获取当前项目结项数据
- $scope.getConcludeData = function() {
- Project.getConcludeData({id : id}, {}, function(data) {
- $scope.executeDays = data.executeDays;
- $scope.updateTimes = data.updateTimes;
- }, function() {
- toaster.pop('error', '加载失败');
- });
- };
- };
- loadData();
- $scope.cancel= function() {
- $modalInstance.dismiss();
- };
- // 发布
- $scope.saveConclude = function(conclude) {
- var data = new FormData();
- data.append('json', JSON.stringify(conclude));
- data.append('img', conclude.file);
- $http({
- headers: {
- 'Content-Type': undefined
- },
- method: 'POST',
- processData: false,
- async: false,
- url: 'project/save/conclude/' + id,
- data: data
- }).success(function(data){
- toaster.pop('success', '发布结项信息成功');
- $modalInstance.close();
- }).error(function(data){
- toaster.pop('error', '出现错误,发布失败');
- });
- };
- }]);
- /**
- * 活动列表
- */
- app.controller('ActivityListCtrl', ['$scope', '$rootScope', 'toaster', 'ngTableParams', 'BaseService', 'Activity', '$modal',
- function ($scope, $rootScope, toaster, ngTableParams, BaseService, Activity, $modal) {
- var getActivityState = function (active) {
- // 正在进行
- var fn = 'getDone';
- switch (active) {
- // 未开始
- case 'todo':
- fn = 'getTodo';
- break;
- // 已结束
- case 'end':
- fn = 'getEnd';
- break;
- // 草稿
- case 'waiting':
- fn = 'getWaiting';
- break;
- }
- return fn;
- };
- $scope.active = 'done';
- $scope.keyword = '';
- /**
- * 修改分类
- * @param value
- */
- $scope.setActive = function (value) {
- if ($scope.active != value) {
- $scope.active = value;
- if ($scope.activityParams.page() == 1)
- $scope.activityParams.reload();
- else
- $scope.activityParams.page(1);
- }
- };
- $scope.reload = function() {
- if ($scope.activityParams.page() == 1)
- $scope.activityParams.reload();
- else
- $scope.activityParams.page(1);
- };
- $scope.activityParams = new ngTableParams({
- page: 1,
- count: 5,
- sorting: {
- 'id': 'desc'
- }
- }, {
- total: 0,
- counts: [5, 10, 25, 50],
- getData: function ($defer, params) {
- $scope.loading = true;
- var pageParams = params.url();
- var realActive = {};
- pageParams.searchFilter = { // 筛选条件
- keyword: $scope.keyword
- };
- Activity[getActivityState($scope.active)].call(null, BaseService.parseParams(pageParams), function (page) {
- $scope.loading = false;
- if (page) {
- params.total(page.totalElements);
- $defer.resolve(page.content);
- // $scope.keywordXls = angular.copy($scope.keyword); // 保存当前取值的关键词 做导出时需要的字段
- }
- }, function (response) {
- $scope.loading = false;
- toaster.pop('error', '数据加载失败', response.data);
- });
- }
- });
- $scope.onSearch = function () {
- if ($scope.activityParams.page() == 1)
- $scope.activityParams.reload();
- else
- $scope.activityParams.page(1);
- };
- var getNum = function() {
- Activity.getActivitiesNum({}, {}, function(data) {
- $scope.doneNum = data.doneNum;
- $scope.todoNum = data.todoNum;
- $scope.endNum = data.endNum;
- $scope.waitingNum = data.waitingNum;
- });
- };
- getNum();
- // 开奖
- $scope.openAward = function(id) {
- Activity.openAward({id: id}, {}, function() {
- toaster.pop('success', '开奖成功');
- $scope.activityParams.reload();
- }, function(response) {
- toaster.pop('error', '数据加载错误');
- });
- };
- // 弹出详情页模态框
- $scope.showDetail = function (id) {
- var modalInstance = $modal.open({
- templateUrl: 'static/view/activity/activity_detail.html',
- controller: 'ActivityDetailCtrl',
- size: 'lg',
- resolve: {
- id: function () {
- return id;
- }
- }
- });
- modalInstance.result.then(function(data){
- if (data.success) {
- toaster.pop('success', '操作成功');
- }
- $scope.activityParams.reload();
- }, function(){
- });
- };
- }]);
- /**
- * 活动详情框
- */
- app.controller('ActivityDetailCtrl', ['$scope', 'Activity', 'toaster', '$modalInstance', 'BaseService', 'id', '$modal',
- function($scope, Activity, toaster, $modalInstance, BaseService, id, $modal) {
- var loadData = function() {
- // 获取项目详情
- Activity.getDetailById({id :id}, {}, function(data) {
- $scope.activity = data;
- }, function() {
- toaster.pop('error', '详情加载失败');
- });
- Activity.getRelatedProject({id:id}, {}, function(data) {
- $scope.relatedProjects = data;
- });
- };
- loadData();
- $scope.cancel= function() {
- $modalInstance.dismiss();
- };
- }]);
- /**
- * 活动发起
- */
- app.controller('ActivityNewCtrl', ['$scope', 'BaseService', 'toaster', 'Activity', '$http', '$upload',
- function($scope, BaseService, toaster, Activity, $http, $upload) {
- $scope.activity = {
- awards:[],
- projects: []
- };
- $scope.awards = [];
- $scope.projects = [];
- $scope.tempProjects = [];
- $scope.selectedProjects = [];
- $scope.tempSelectedProjects = [];
- $scope.keyword = '';
- var loadSavedActivity = function() {
- Activity.getSavedActivity({}, function(data) {
- if (null !== data) {
- $scope.activity = data;
- $scope.awards = data.awards;
- $scope.selectedProjects = data.projects;
- }
- });
- };
- loadSavedActivity();
- // 日期选择
- $scope.openDatePicker = function ($event, item, openParam) {
- $event.preventDefault();
- $event.stopPropagation();
- item[openParam] = !item[openParam];
- };
- // 富文本编辑器配置
- // $scope.editorConfig = {
- // dialogsInBody: true,
- // lang: 'zh-CN',
- // toolbar:[
- // ['edit',['undo','redo']],
- // ['style',['bold','italic','underline','clear' ]],
- // ['fontsize',['fontsize']],
- // ['para',['ul','ol','paragraph']],
- // ['color',['color']],
- // ['remove', ['removeMedia']],
- // ['insert', ['link', 'picture', 'table', 'hr']],
- // ['view', ['fullscreen', 'codeview']]
- // ]
- // };
- // 添加奖品
- $scope.addAward = function() {
- if ($scope.awards.length >= 4) {
- toaster.pop('warning', '提示', '最多可添加四个奖品');
- } else {
- $scope.awards.push({
- name: '',
- amount: null,
- awardLevel: '',
- way: 1
- });
- }
- };
- // 删除某一奖品
- $scope.deleteAward = function($index) {
- var path = $scope.awards[$index].img;
- if (!angular.isUndefined(path)) {
- Activity.deletePrizeImg({path: path}, {}, function(data) {
- });
- }
- $scope.awards.splice($index, 1);
- };
- // 获取项目列表
- var getProject = function() {
- var selectedIds = [];
- if ([] !== $scope.selectedProjects) {
- angular.forEach($scope.selectedProjects, function(selectedProject) {
- selectedIds.push(selectedProject.id);
- });
- }
- Activity.getActivityRelatedProjects({keyword: $scope.keyword, selectedIds: selectedIds}, {}, function(data) {
- $scope.projects = data;
- });
- };
- getProject();
- // 搜索项目
- $scope.onSearch = function() {
- getProject();
- };
- // 选择未被选择的项目
- // $scope.checkSelected = function (project) {
- // if (project.checked) {
- // project.checked = !project.checked;
- // } else {
- // project.checked = true;
- // }
- // };
- // 添加选中
- $scope.addSelected = function() {
- $scope.tempSelectedProjects = angular.copy($scope.selectedProjects);
- $scope.tempProjects = angular.copy($scope.projects);
- angular.forEach($scope.projects, function(project, index) {
- if (project.checked) {
- project.checked = false;
- $scope.selectedProjects.push(project);
- $scope.projects.splice(index, 1);
- }
- });
- angular.forEach($scope.projects, function(project, index) {
- if (project.checked) {
- project.checked = false;
- $scope.selectedProjects.push(project);
- $scope.projects.splice(index, 1);
- }
- });
- };
- // 删除选中
- $scope.deleteSelected = function() {
- $scope.tempSelectedProjects = angular.copy($scope.selectedProjects);
- $scope.tempProjects = angular.copy($scope.projects);
- // 存在取消操作,用temp过渡
- // 因为会splice,所以相邻的被选中需要遍历两次
- angular.forEach($scope.selectedProjects, function(project, index) {
- if (project.checked) {
- project.checked = false;
- $scope.projects.push(project);
- $scope.selectedProjects.splice(index, 1);
- }
- });
- angular.forEach($scope.selectedProjects, function(project, index) {
- if (project.checked) {
- project.checked = false;
- $scope.projects.push(project);
- $scope.selectedProjects.splice(index, 1);
- }
- });
- };
- // 取消
- $scope.cancelSelected = function() {
- $scope.projects = angular.copy($scope.tempProjects);
- $scope.selectedProjects = angular.copy($scope.tempSelectedProjects);
- };
- // 刷新
- $scope.refresh = function() {
- window.location.reload();
- };
- // 图片上传
- $scope.fileChanged = function(ele, value){
- if (value == 0) {
- $scope.actImg = ele.files[0];
- $scope.actImgUrl = getObjectURL($scope.actImg);
- } else if (value == 1) {
- $scope.banner = ele.files[0];
- $scope.bannerUrl = getObjectURL($scope.banner);
- // } else if (value == 2) {
- // $scope.award1 = ele.files[0];
- // } else if (value == 3) {
- // $scope.award2 = ele.files[0];
- // } else if (value == 4) {
- // $scope.award3 = ele.files[0];
- // } else if (value == 5) {
- // $scope.award4 = ele.files[0];
- }
- $scope.$apply();
- };
- //建立一个可存取到该file的url
- var getObjectURL = function (file) {
- var url = null;
- if (window.createObjectURL != undefined) { // basic
- url = window.createObjectURL(file);
- } else if (window.URL != undefined) { // mozilla(firefox)
- url = window.URL.createObjectURL(file);
- } else if (window.webkitURL != undefined) { // webkit or chrome
- url = window.webkitURL.createObjectURL(file);
- }
- return url;
- };
- // 查看范例
- $scope.showImg = function (type) {
- var img = type;
- var imgUrl = null;
- switch (type) {
- case 'actImg':
- img = $scope.activity.actImg;
- imgUrl = $scope.actImgUrl;
- break;
- case 'banner':
- img = $scope.activity.banner;
- imgUrl = $scope.bannerUrl;
- break;
- }
- if (img) {
- var src = img, box = $('#image-box');
- box.show();
- box.find('img').attr('src', src);
- box.find('a').click(function () {
- box.hide();
- });
- box.dblclick(function () {
- box.hide();
- });
- } else if (imgUrl != null) {
- var src = imgUrl, box = $('#image-box');
- box.show();
- box.find('img').attr('src', src);
- box.find('a').click(function () {
- box.hide();
- });
- box.dblclick(function () {
- box.hide();
- });
- }
- };
- // 删除活动图或banner
- $scope.clearFile = function (type) {
- switch (type) {
- case 'actImg':
- $scope.actImg = null;
- $scope.actImgUrl = null;
- break;
- case 'banner':
- $scope.banner = null;
- $scope.bannerUrl = null;
- break;
- }
- // 清空input框的内容
- var file=document.getElementById(type);
- //IE,Safari,chrome
- if(file.outerHTML){
- file.outerHTML=file.outerHTML;
- }
- else{ //FF
- file.value="";
- }
- };
- // 删除奖品图片
- $scope.deletePrizeImg = function(path, index) {
- $scope.awards[index].img = null;
- var type = 'award' + index;
- // 清空input框的内容
- var file=document.getElementById(type);
- //IE,Safari,chrome
- if(file.outerHTML){
- file.outerHTML=file.outerHTML;
- }
- else{ //FF
- file.value="";
- }
- if (!angular.isUndefined(path)) {
- Activity.deletePrizeImg({path: path}, {}, function(data) {
- });
- }
- };
- $scope.uploadPrizeImg = function(award, index) {
- $scope.loading = true;
- var files = award.prizeImgs, file = files && files.length > 0 ? files[0] : null;
- $upload.upload({
- url: 'activity/upload/prizeImg',
- method: 'POST',
- file: file
- }).success(function (data) {
- $scope.awards[index].img = data.path;
- $scope.loading = false;
- }).error(function (data) {
- $scope.loading = false;
- // toaster.pop('error', '错误', data);
- });
- };
- // 保存 或 提交
- $scope.submit = function(type) {
- var projectList = [];
- angular.forEach($scope.selectedProjects, function(project) {
- projectList.push(project);
- });
- $scope.activity.projects = projectList;
- $scope.activity.awards = $scope.awards;
- var url;
- if (type) {
- url = 'activity/submit';
- } else {
- url = 'activity/save';
- }
- var data = new FormData();
- data.append('actImg', $scope.actImg);
- data.append('banner', $scope.banner);
- // data.append('award1', $scope.award1);
- // data.append('award2', $scope.award2);
- // data.append('award3', $scope.award3);
- // data.append('award4', $scope.award4);
- data.append('jsonStr', JSON.stringify($scope.activity));
- $http({
- headers: {
- 'Content-Type': undefined
- },
- method : 'POST',
- processData : false,
- async: false,
- url : url,
- data: data
- }).success(function (data) {
- if (type) {
- toaster.pop('success', '发布成功');
- } else {
- toaster.pop('success', '保存成功');
- }
- window.location.href='#/activity';
- }).error(function (data) {
- $scope.loadingShow = false;
- toaster.pop('error', '出现错误,操作失败');
- });
- }
- }]);
- /**
- * 机构列表
- */
- app.controller('OrgListCtrl', ['$scope', '$rootScope', 'toaster', 'ngTableParams', 'BaseService', 'Organization', '$modal',
- function ($scope, $rootScope, toaster, ngTableParams, BaseService, Organization, $modal) {
- var getOrgState = function (active) {
- var fn = 'getAudited';
- switch (active) {
- // 已审核
- case 'audited':
- fn = 'getAudited';
- break;
- // 未审核
- case 'unaudited':
- fn = 'getUnaudited';
- break;
- // 未通过
- case 'disagreed':
- fn = 'getDisagreed';
- break;
- }
- return fn;
- };
- $scope.active = 'done';
- if ($rootScope.active) {
- $scope.active = $rootScope.active;
- }
- $scope.keyword = '';
- /**
- * 修改分类
- * @param value
- */
- $scope.setActive = function (value) {
- if ($scope.active != value) {
- $scope.active = value;
- if ($scope.activityParams.page() == 1)
- $scope.activityParams.reload();
- else
- $scope.activityParams.page(1);
- }
- };
- $scope.reload = function() {
- if ($scope.activityParams.page() == 1)
- $scope.activityParams.reload();
- else
- $scope.activityParams.page(1);
- };
- $scope.orgParams = new ngTableParams({
- page: 1,
- count: 5,
- sorting: {
- 'id': 'desc'
- }
- }, {
- total: 0,
- counts: [5, 10, 25, 50],
- getData: function ($defer, params) {
- $scope.loading = true;
- var pageParams = params.url();
- var realActive = {};
- pageParams.searchFilter = { // 筛选条件
- keyword: $scope.keyword,
- area: $scope.selectedArea,
- type: $scope.selectedType
- };
- Organization[getOrgState($scope.active)].call(null, BaseService.parseParams(pageParams), function (page) {
- $scope.loading = false;
- if (page) {
- params.total(page.totalElements);
- $defer.resolve(page.content);
- // $scope.keywordXls = angular.copy($scope.keyword); // 保存当前取值的关键词 做导出时需要的字段
- }
- }, function (response) {
- $scope.loading = false;
- toaster.pop('error', '数据加载失败', response.data);
- });
- }
- });
- $scope.onSearch = function () {
- if ($scope.activityParams.page() == 1)
- $scope.activityParams.reload();
- else
- $scope.activityParams.page(1);
- };
- var getNum = function() {
- Organization.getOrgsNum({}, {}, function(data) {
- $scope.auditedNum = data.auditedNum;
- $scope.unauditedNum = data.unauditedNum;
- $scope.disagreedNum = data.disagreedNum;
- });
- };
- getNum();
- // 弹出详情页模态框
- $scope.showDetail = function (id) {
- var modalInstance = $modal.open({
- templateUrl: 'static/view/user/organization_detail.html',
- controller: 'OrgDetailCtrl',
- size: 'lg',
- resolve: {
- id: function () {
- return id;
- }
- }
- });
- modalInstance.result.then(function(data){
- if (data.success) {
- toaster.pop('success', '操作成功');
- }
- $scope.orgParams.reload();
- }, function(){
- });
- };
- }]);
- /**
- * 机构详情框
- */
- app.controller('OrgDetailCtrl', ['$scope', 'Organization', 'toaster', '$modalInstance', 'BaseService', 'id', '$modal',
- function($scope, Organization, toaster, $modalInstance, BaseService, id, $modal) {
- var loadData = function() {
- // 获取项目详情
- Organization.getDetailById({id :id}, {}, function(data) {
- $scope.org = data;
- }, function() {
- toaster.pop('error', '详情加载失败');
- });
- };
- loadData();
- $scope.cancel= function() {
- $modalInstance.dismiss();
- };
- // true通过 false驳回
- $scope.auditOrg = function(type) {
- var modalInstance = $modal.open({
- animation: true,
- templateUrl: 'static/view/user/org_audit.html',
- controller: 'OrgAuditCtrl',
- resolve: {
- org : function() {
- return $scope.org;
- },
- type : function() {
- return type;
- }
- }
- });
- modalInstance.result.then(function(data){
- if (data.success) {
- toaster.pop('success','操作成功');
- }
- if (data.error) {
- toaster.pop('error','操作失败');
- }
- loadData();
- }, function(){
- });
- };
- }]);
- /**
- * 审核机构框
- */
- app.controller('OrgAuditCtrl', ['$scope', 'Organization', 'toaster', '$modalInstance', 'BaseService', 'org', 'type',
- function($scope, Organization, toaster, $modalInstance, BaseService, org, type) {
- $scope.org = org;
- // 区别是通过还是驳回
- $scope.result = type;
- $scope.cancel= function() {
- $modalInstance.dismiss();
- };
- // true通过 false驳回
- $scope.ensure = function(type) {
- if (type) {
- Organization.agree({id: $scope.org.id}, {}, function () {
- toaster.pop('success', '审核成功');
- });
- } else {
- Organization.disagree({id: $scope.org.id, refuse: $scope.org.refuse}, {}, function () {
- toaster.pop('success', '驳回成功');
- });
- }
- };
- }]);
- return app;
- });
|