| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808 |
- /**
- * 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('AuthCtrl', ['$scope', '$window', 'AuthenticationService', 'toaster', 'BaseService', '$modal', 'SessionService',
- function ($scope, $window, AuthenticationService, toaster, BaseService, $modal, SessionService) {
- $scope.isAuthed = AuthenticationService.isAuthed(); //AuthenticationService模块在common/下
- AuthenticationService.getAuthentication().success(function (data) {
- if (data.content) {
- $scope.userInfo = data.content;
- }
- if (data == null || !data.content) {
- $scope.isAuthed = false;
- AuthenticationService.redirectSignin();
- }
- });
- $scope.logout = function() {
- AuthenticationService.logout().success(function() {
- SessionService.removeCookie($rootScope.userInfo.userUU);
- });
- };
- // $scope.logout = function () {
- // $modal.open({
- // templateUrl: 'static/view/user/logout.html',
- // controller: 'LogOutCtrl'
- // }).result.then(function (s) {
- // if (s) {
- // AuthenticationService.logout();
- // }
- // });
- // };
- }]);
- app.controller('LogOutCtrl', ['$scope', '$modalInstance', function ($scope, $modalInstance) {
- $scope.close = function (confirm) {
- $modalInstance.close(confirm);
- };
- }]);
- /**
- * 项目列表
- */
- app.controller('ProjectListCtrl', ['$scope', '$rootScope', 'toaster', 'ngTableParams', 'BaseService', 'Project', '$modal',
- function ($scope, $rootScope, toaster, ngTableParams, BaseService, Project, $modal) {
- BaseService.scrollBackToTop();
- 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';
- if ($rootScope.active) {
- $scope.active = $rootScope.active;
- }
- $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', 'ngTableParams',
- function($scope, Project, toaster, $modalInstance, BaseService, id, $modal, $sce, ngTableParams) {
- var loadData = function() {
- // 获取项目详情
- Project.getDetailById({id :id}, {}, function(data) {
- $scope.project = data;
- $scope.code = $sce.trustAsHtml($scope.project.introduction);
- }, function() {
- toaster.pop('error', '详情加载失败');
- });
- };
- loadData();
- // 获取当前项目所有进度
- $scope.getSchedules = function() {
- Project.getSchedules({id : id}, {}, function(data) {
- $scope.schedules = data;
- }, function() {
- toaster.pop('error', '项目进度加载失败');
- });
- };
- // 获取当前项目捐款明细
- // $scope.getRecords = function() {
- // Project.getRecords({proId:id}, {}, function(data) {
- // $scope.projectRecords = data;
- // }, function() {
- // toaster.pop('error', '捐款明细加载失败');
- // });
- // };
- $scope.recordParams = new ngTableParams({
- page: 1,
- count: 5,
- sorting: {
- 'id': 'desc'
- }
- }, {
- total: 0,
- counts: [],
- getData: function ($defer, params) {
- $scope.loading = true;
- var pageParams = params.url();
- pageParams.searchFilter = { // 筛选条件
- keyword: $scope.keyword,
- // 此处area作为支付方式过滤
- area: $scope.way,
- fromDate : null !== $scope.fromDate ? $scope.fromDate.getTime(): null,
- // proId过滤
- type: id
- };
- Project.getRecordsPage.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.recordParams.page() === 1) {
- $scope.recordParams.reload();
- } else {
- $scope.recordParams.page(1);
- }
- };
- $scope.fromDate = null;
- $scope.setTime = function(type) {
- var fromDate = new Date();
- fromDate.setHours(0, 0, 0, 0);
- switch (type) {
- // 一周内
- case '7' :
- fromDate.setDate(fromDate.getDate() - 7) ;
- $scope.fromDate = fromDate;
- break;
- // 一个月内
- case '1' :
- fromDate.setMonth(fromDate.getMonth() - 1) ;
- $scope.fromDate = fromDate;
- break;
- // 三个月内
- case '3' :
- fromDate.setMonth(fromDate.getMonth() - 3) ;
- $scope.fromDate = fromDate;
- break;
- // 半年内
- case '6' :
- fromDate.setMonth(fromDate.getMonth() - 6) ;
- $scope.fromDate = fromDate;
- break;
- }
- $scope.recordParams.reload();
- };
- // 获取当前项目财务信息
- $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','财务明细加载失败');
- });
- };
- $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','操作失败');
- }
- $modalInstance.close();
- }, function(){
- });
- };
- // 重新申请
- $scope.reapply = function() {
- Project.reapply({id:id}, {}, function(data) {
- if (data.success) {
- toaster.pop('success', '重新申请成功');
- }
- if (data.error) {
- toaster.pop('error', '申请失败,请联系管理员');
- }
- $modalInstance.close();
- }, 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 = true;
- $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, invalid) {
- if (invalid == true) {
- $scope.submited = true;
- return;
- }
- 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) {
- // 默认捐助领域
- $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, invalid) {
- if (invalid) {
- $scope.submited = true;
- BaseService.scrollBackToTop();
- return;
- }
- // if (project.startTime == project.endTime) {
- // toaster.pop('info', '项目开始时间与结束时间不能相同,请修改之后再保存');
- // } else {
- 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="";
- }
- };
- // 设置active
- $scope.setActive = function(value) {
- $rootScope.active = value;
- // window.location.href = '#/';
- };
- //提交 或 保存
- $scope.saveDetail = function (project, type, invalid) {
- if (type && invalid) {
- $scope.submited = true;
- BaseService.scrollBackToTop();
- return;
- }
- 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', '发布成功');
- $rootScope.active = 'unaudited';
- BaseService.scrollBackToTop();
- 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) {
- BaseService.scrollBackToTop();
- 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(data) {
- if (data.success) {
- toaster.pop('success', data.success);
- $scope.activityParams.reload();
- }
- if (data.error) {
- toaster.pop('warning', data.error);
- }
- }, 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;
- },
- active: function() {
- return $scope.active;
- }
- }
- });
- 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', '详情加载失败');
- });
- };
- loadData();
- $scope.cancel= function() {
- $modalInstance.dismiss();
- };
- }]);
- /**
- * 活动发起
- */
- app.controller('ActivityNewCtrl', ['$scope', 'BaseService', 'toaster', 'Activity', '$http', '$upload',
- function($scope, BaseService, toaster, Activity, $http, $upload) {
- $scope.loading = true;
- $scope.activity = {
- awards:[],
- projects: []
- };
- $scope.awards = [];
- $scope.projects = [];
- $scope.tempProjects = [];
- $scope.selectedProjects = [];
- $scope.tempSelectedProjects = [];
- $scope.keyword = '';
- $scope.actImgUrl = null;
- $scope.bannerUrl = null;
- var loadSavedActivity = function() {
- Activity.getSavedActivity({}, function(data) {
- if (null !== data) {
- $scope.activity = data;
- $scope.awards = data.awards;
- $scope.selectedProjects = data.projects;
- $scope.tempSelectedProjects = angular.copy($scope.selectedProjects);
- $scope.actImgUrl = data.actImg;
- $scope.bannerUrl = data.banner;
- }
- $scope.loading = false;
- });
- };
- 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 (angular.isUndefined($scope.awards)) {
- $scope.awards = [];
- }
- if ($scope.awards.length >= 4) {
- toaster.pop('warning', '提示', '最多可添加四个奖品');
- } else {
- $scope.awards.push({
- name: '',
- amount: null,
- awardLevel: '',
- way: 1
- });
- }
- };
- // 删除某一奖品
- $scope.deletePath = [];
- $scope.deleteAward = function($index) {
- var path = $scope.awards[$index].img;
- if (!angular.isUndefined(path)) {
- $scope.deletePath.push(path);
- }
- $scope.awards.splice($index, 1);
- };
- // 获取项目列表
- var selectedIds = [];
- var getProject = function() {
- 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;
- $scope.tempProjects = angular.copy($scope.projects);
- });
- };
- getProject();
- // 搜索项目
- $scope.onSearch = function() {
- getProject();
- };
- // 选择未被选择的项目
- // $scope.checkSelected = function (project) {
- // if (project.checked) {
- // project.checked = !project.checked;
- // } else {
- // project.checked = true;
- // }
- // };
- // 添加选中
- $scope.addSelected = function() {
- // angular.forEach($scope.projects, function(project, index) {
- // if (project.checked) {
- // project.checked = false;
- // if (angular.isUndefined($scope.selectedProjects)) {
- // $scope.selectedProjects = [];
- // }
- // $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);
- // }
- // });
- var i = 0;
- for (i; i< $scope.projects.length; i++) {
- var project = $scope.projects[i];
- if (project.checked) {
- project.checked = false;
- if (angular.isUndefined($scope.selectedProjects)) {
- $scope.selectedProjects = [];
- }
- $scope.selectedProjects.push(project);
- $scope.projects.splice(i, 1);
- i = i-1;
- }
- }
- };
- // 删除选中
- $scope.deleteSelected = function() {
- // // 存在取消操作,用temp过渡
- // 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);
- // }
- // });
- var i = 0;
- for (i; i< $scope.selectedProjects.length; i++) {
- var project = $scope.selectedProjects[i];
- if (project.checked) {
- project.checked = false;
- $scope.projects.push(project);
- $scope.selectedProjects.splice(i, 1);
- i = i -1;
- }
- }
- };
- // 取消
- $scope.cancelSelected = function() {
- $scope.projects = angular.copy($scope.tempProjects);
- $scope.selectedProjects = angular.copy($scope.tempSelectedProjects);
- };
- // 保存
- $scope.saveSelected = function() {
- $scope.tempProjects = angular.copy($scope.projects);
- $scope.tempSelectedProjects = angular.copy($scope.selectedProjects);
- };
- // 清空内容
- $scope.clearActivity = function() {
- $scope.activity = {
- awards:[],
- projects: []
- };
- $scope.actImgUrl = null;
- $scope.bannerUrl = null;
- $scope.awards = [];
- $scope.selectedProjects = [];
- getProject();
- BaseService.scrollBackToTop();
- };
- // 图片上传
- $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, invalid) {
- if (invalid == true) {
- $scope.submited = true;
- BaseService.scrollBackToTop();
- return;
- }
- // if ($scope.activity.startTime === $scope.activity.endTime) {
- // toaster.pop('info', '开始时间与结束时间不能相同,请修改之后再保存');
- // } else if ($scope.activity.receiveStartTime === $scope.activity.receiveEndTime) {
- // toaster.pop('info', '兑奖开始时间与结束时间不能相同,请修改之后再保存');
- // } else {
- $scope.loading = true;
- 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', '保存成功');
- }
- if ($scope.deletePath.length > 0) {
- Activity.deletePrizeImgByBatch({path: $scope.deletePath}, {}, function (data) {
- });
- }
- $scope.loading = false;
- window.location.hash = '#/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.orgParams.page() == 1)
- $scope.orgParams.reload();
- else
- $scope.orgParams.page(1);
- }
- };
- $scope.reload = function() {
- if ($scope.orgParams.page() == 1)
- $scope.orgParams.reload();
- else
- $scope.orgParams.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.orgParams.page() == 1)
- $scope.orgParams.reload();
- else
- $scope.orgParams.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;
- });
|