SendMessagesController.js 2.7 KB
"use strict";
var sendMessagesController = angular.module('sendMessagesController',[]);


sendMessagesController.controller('sendMessagesController', [
    '$rootScope',
    '$scope',
    'SendMessagesService',
    function($rootScope, $scope, SendMessagesService) {
        $scope.operationType=$rootScope.$stateParams.operationType;
        $scope.currentPage = 1;
        $scope.numPages = 1;
        $scope.pageSize = 20;
        $scope.totalRecord = 0;
        $scope.pages = [];
        $scope.operations=[];
        $scope.condition={
            operationUser:'',
            operationObject:'',
            operationContent:'',
            operationType:$scope.operationType,
            startDate:'',
            endDate:'',
            pageNow:1,
            pageSize:20
        };
        SendMessagesService.operationPager($scope.condition);
        $scope.$on('operation.list',function(){
            $scope.operations=SendMessagesService.operations.datas;
            $scope.numPages=SendMessagesService.operations.totalPage;
            $scope.totalRecord=SendMessagesService.operations.totalRecord;
            $("#messageShow").show();
            $("#basicform").hide();
        });
        //选当前页
        $scope.onSelectPage = function(page) {
            $scope.condition.pageNow=page;
            $scope.currentPage=page;
            SendMessagesService.operationPager($scope.condition);
        };
        $scope.searchOperation=function(){
            $scope.condition.pageNow=1;
            $scope.condition.startDate = $('#datepickfrom').val();
            $scope.condition.endDate   = $('#datepickto').val();
            SendMessagesService.operationPager($scope.condition);
        };
        $scope.sms={
            phone:'',
            content:''
        };
        $scope.smsFunc = function () {
            $("#messageShow").hide();
            $("#basicform").show();
        };

        $scope.onSubmitSms = function () {
            if(confirm("确认发送短信给[" + $scope.sms.phone + "]?")) {
                SendMessagesService.sendSms($scope.sms,function(res){
                    if(res){
                        SendMessagesService.operationPager($scope.condition);
                        $scope.$on('operation.list',function(){
                            $scope.operations=SendMessagesService.operations.datas;
                            $scope.numPages=SendMessagesService.operations.totalPage;
                            $scope.totalRecord=SendMessagesService.operations.totalRecord;
                            $("#messageShow").show();
                            $("#basicform").hide();
                        });
                    }
                });
            }
        };

    }]
);