admin.js 9.1 KB
var initApp=function(){
    "use strict";
    var ref = [
        "xn.common",
        "xn.service.interceptor",
        "xn.directive.top",
        "xn.admin.filter",
        "xn.admin.service",
        "xn.directive.loading",
        "xn.directive.attachment",
        "xn.directive.imgDisk",
        "xn.page",
        "xn.directive.calendar",
        "xn.directive.location",
        "xn.directive.card",
        "xn.directive.select",
        "xn.directive.approval",
        "xn.directive.disk",
        "ui.bootstrap",
        "xn.directive.form"

    ];

    var app =angular.module("xn", ref);
    app.config(["$httpProvider", function ($httpProvider) {
        $httpProvider.interceptors.push("httpInterceptor");
        }]);

    app.value("xnConfig", xnConfig);

    app.config(["xnValidatorProvider", function (xnValidatorProvider) {
        xnValidatorProvider.setRules({
            /*角色创建和编辑的验证*/
            roleName: {
                required: "角色名称不能为空!"
            },
            /*设置默认密码的验证*/
            passworddefault: {
                required:   "默认密码不能为空!",
                maxlength:  "密码长度不能大于14个字符!",
                pattern:    "密码强度不足,必须包含数字、字母或特殊符号中的两种,长度6-14位"
            },
            /*创建用户的验证*/
            username: {
                required: "用户姓名不能为空!"
            },
            useremail: {
                required: "邮箱不能为空!",
                pattern: "邮箱格式不正确!"
            },
            useraccount:{
                required: "账号不能为空!"
            },
            usermobilePhone: {
                pattern:    "手机号码格式不正确,需要为11位,且应该以13,15,17,18开头!"
            },
            /*企业编辑的验证*/
            tenantname:{
                required: "公司名称不能为空!"
            },
            tenantfax: {
                pattern: "传真格式不正确!"
            },
            tenantmobilePhone: {
                pattern: "电话号码格式不正确"
            },
            tenantemailSuffix: {
                maxlength: "邮箱后缀的长度过长,最多50",
                pattern:"邮箱后缀格式不正确"
            },
            postCode : {
                pattern: "邮编应为6位数字"
            },
            batchName : {
                required: "推送备注不能为空!"
            },
            messageTitle:{
                required: "消息标题不能为空!"
            },
            messageContent : {
                required: "消息内容不能为空!"
            },
            mailTitle : {
                required: "邮件标题不能为空!"
            },
            mailContent : {
                required: "邮件内容不能为空!"
            },
            groupName : {
                required: "群组名称不能为空!"
            },
            groupCode : {
                required: "群组代码不能为空!"
            },
            accountName : {
                required: "账号名称不能为空!"
            },
            wechatNumber : {
                required: "微信号不能为空!"
            },
            accountType : {
                required: "账号类型不能为空!"
            },
            appId : {
                required: "应用ID不能为空!"
            },
            appKey : {
                required: "帐号Key不能为空!"
            },
            appSecret : {
                required: "应用密钥不能为空!"
            },
            voucherCode: {
                required: "兑换码不能为空!"
            },
            processName :{
                required: "流程名称不能为空!"
            },
            processCode :{
                required: "流程代码不能为空!"
            },
            categoryName :{
                required: "类别名称不能为空!"
            },
            attributeCode :{
                pattern : "字段代码中只能包含英文字母!"
            }
        });
    }]);

    /**
     *消息明细
     */
    var messageDetailController =["$scope","$modalInstance","FoundationService", function ($scope,$modalInstance,FoundationService) {
        var id = {id: $scope.messageDetailId};
        //页面加载消息详细信息
        $scope.getMessageDetail = function () {
            FoundationService.getMessageDetail(id).success(function (data) {
                $scope.messageDetail = data.message;
            });
        };
        $scope.getMessageDetail();

        $scope.doRead = function () {
            $scope.messageReadIds = [];
            $scope.messageReadIds.push($scope.messageDetailId);
            console.log($scope.messageReadIds);
            FoundationService.doRead($scope.messageReadIds).success(function () {
            });
        };
        $scope.doRead();

        $scope.cancel = function () {
            $scope.getMessageList();
            $modalInstance.dismiss("cancel");
        };
    }];

    // 全局配置 form提交验证
    app.config(["xnValidatorProvider", function (xnValidatorProvider) {
        // 全局配置
        xnValidatorProvider.config({
            blurTrig   : false,
            showError  : false,
            removeError: false
        });

    }]);
    app.controller("BodyController",["$scope", "$location","dialogService", "toolsService", function($scope, $location,dialogService, toolsService) {

        $scope.global={loadingInit:false};
        $scope.maxPageSize=5;

        /*导航效果处理(一二级导航)*/
        var navShow=''; /*临时存储*/
        var subNavShow='';
        $scope.$on("navShow",function(event ,show){
            $scope.navShow=show;
            navShow=show;
            console.log(navShow)
        });
        /*二级导航*/
        $scope.$on("subNavShow",function(event ,show){
            $scope.subNavShow=show;
            subNavShow=show;
        });

        $scope.navMouseenter=function (number) {
            $scope.navShow=number;
            $scope.subNavShow=null;
        };
        /*移出导航*/
        $scope.cancelNav=function () {
            $scope.navShow=navShow;
            $scope.subNavShow=subNavShow;
        };
        $scope.cancelSubNav=function () {
            $scope.subNavShow=null;
        };

        $scope.upFileClick=function(){
            var upImportFileId=document.getElementById("upImportFileId");
            upImportFileId.onchange=function(){
                var upImportFile;
                var upImportFileList =upImportFileId.files;
                var upImportFilename;
                if(upImportFileList){
                    upImportFile = upImportFileList[0];
                    upImportFilename=upImportFile.name;
                }else{
                    upImportFilename =upImportFileId.value;
                }
                var str =upImportFilename.substr(upImportFilename.indexOf(".")+1);
                if(str != "xls" && str != "xlsx"){
                    $("#upImportFile").val("");
                    dialogService.tip([{"message":"请上传Excel文件!" }]);
                }else{
                    $("#upImportFile").val(upImportFilename);
                }
            };
        };

        //日期转换函数
        Date.prototype.format = function(format){
            var o = {
                "M+" : this.getMonth()+1, //month
                "d+" : this.getDate(),    //day
                "h+" : this.getHours(),   //hour
                "m+" : this.getMinutes(), //minute
                "s+" : this.getSeconds(), //second
                "q+" : Math.floor((this.getMonth()+3)/3),  //quarter
                "S" : this.getMilliseconds() //millisecond
            };
            if(/(y+)/.test(format)) format=format.replace(RegExp.$1,
                (this.getFullYear()+"").substr(4 - RegExp.$1.length));
            for(var k in o)if(new RegExp("("+ k +")").test(format))
                format = format.replace(RegExp.$1,
                    RegExp.$1.length==1 ? o[k] :
                        ("00"+ o[k]).substr((""+ o[k]).length));
            return format;
        };

        //关闭错误
        $scope.closeAlert = function (index,form) {
            form.splice(index,1);
        };

        //常用数据
        $scope.hours=[
            {key:0,value:"00"},
            {key:1,value:"01"},
            {key:2,value:"02"},
            {key:3,value:"03"},
            {key:4,value:"04"},
            {key:5,value:"05"},
            {key:6,value:"06"},
            {key:7,value:"07"},
            {key:8,value:"08"},
            {key:9,value:"09"},
            {key:10,value:"10"},
            {key:11,value:"11"},
            {key:12,value:"12"},
            {key:13,value:"13"},
            {key:14,value:"14"},
            {key:15,value:"15"},
            {key:16,value:"16"},
            {key:17,value:"17"},
            {key:18,value:"18"},
            {key:19,value:"19"},
            {key:20,value:"20"},
            {key:21,value:"21"},
            {key:22,value:"22"},
            {key:23,value:"23"}
        ];

    }]);
};