topicMessage.js 1.76 KB
/**
 * Created by cjl on 2018/4/23.
 */
(function () {
    "user strict";

    var topicMessageController = function($scope,$modal,$http,$interval,dialogService,railwayService){
        $scope.settingShow = 9;
        $scope.topic = {
            title : "",
            content :""
        }

        $scope.doSave = function(){
            if (!$scope.topic.title) {
                dialogService.tip([{"message":"消息标题不能为空!" }]);
                return;
            }
            if (!$scope.topic.content) {
                dialogService.tip([{"message":"消息内容不能为空!" }]);
                return;
            }

            var dialogDefaults = {
                size: "sm"
            };
            var dialogOptions = {
                closeButtonText: "取消",
                actionButtonText: "确定",
                headerText: "消息推送?",
                bodyText: "确定推送该条消息到app?",
                callback: function () {
                    railwayService.addTopicMessage($scope.topic).success(function(data){
                        if (data.errors == null || data.errors.length > 0){
                            dialogService.tip(data.errors);
                        }
                        else {
                            dialogService.tip([{message:"消息推送成功!"}],"/admin/topicMessage/index.htm",1000);
                            //清空数据
                        }
                    })
                }
            };
            dialogService.confirm(dialogDefaults, dialogOptions);
        };
    }

    angular.module("xn.page", ["xn.directive.form"])
        .controller("TopicMessageController",["$scope","$modal","$http","$interval","dialogService","RailwayService",topicMessageController])
})();