railway.js 7.35 KB
var initApp = function () {
    "use strict";
    var ref = [
        "xn.common",
        "xn.directive.top",
        "xn.service.interceptor",
        "xn.railway.filter",
        "xn.railway.service",

        "xn.page",

        "ui.bootstrap",
        "xn.directive.form",
        "xn.directive.location",
        "xn.directive.attachment",
        "xn.directive.select",
        "xn.directive.calendar",
        "xn.directive.progressbar",
        "xn.markdown",
        "xn.directive.comment",
        "xn.directive.card",
        "ngSanitize",
        "ui.sortable",
        "ng-sortable",
        "xn.directive.approval",
        "xn.kindeditor",
        "xn.directive.imgDisk",
        "xn.directive.location.foreign",
        "ngClipboard",
        "xn.directive.import",  //批量导入
        "xn.directive.positions"

    ];
    var app = angular.module("xn", ref);

    //拦截器
    app.config(["$httpProvider", function ($httpProvider) {
        $httpProvider.interceptors.push("httpInterceptor");
    }]);
    app.config(['ngClipProvider', function(ngClipProvider) {
        ngClipProvider.setPath("/railway/vendor/xn-clipboard/ZeroClipboard.swf");
    }]);
    // 全局配置 form提交验证
    app.config(["xnValidatorProvider", function (xnValidatorProvider) {
        // 全局配置
        xnValidatorProvider.config({
            blurTrig: false,
            showError: false,
            removeError: false
        });
        xnValidatorProvider.setRules({
            name: {
                required: "名称不能为空!"
            },
            room:{
                required: "厅名称不能为空!"
            },
            unitPrice:{
                required: "单价不能为空!",
                pattern:"单价只能为数字"
            },
            ticketCategoryName: {
                required: "门票类别名称不能为空!"
            },
            quantity:{
                required: "数量不能为空!",
                pattern:"数量只能为数字"
            },
            freeEntry:{
                required: "免费进场人数不能为空!",
                pattern:"人数只能为正整数"
            },
            maximumSeats:{
                required: "可坐人数不能为空!",
                pattern:"人数只能为正整数"
            },
            venueName:{
                required: "场地名称不能为空!"
            },
            venueCode:{
                required: "场地编码不能为空!"
            },
            location:{
                required: "详细地址不能为空!",
                maxlength:"详细地址不能超过200字"
            },
            shortName:{
                required: "场地简称不能为空!"
            },
            contactName:{
                required: "姓名不能为空!"
            },
            contactPhone:{
                required: "电话不能为空!"
            },
            myLoc:{
                required: "具体位置不能为空!"
            },
            zipcode:{
                required: "邮编不能为空!"
            },
            contactMail:{
                required: "邮箱不能为空!",
                pattern:"邮箱格式不正确"
            },
            orderIndex:{
                required: "排序索引不能为空!",
                pattern:"排序索引只能为数字"
            },
            age:{
                required: "年龄不能为空!",
                pattern:"年龄请输入三位数以下的正整数"
            },
            djName: {
                required: "DJ姓名不能为空!"
            },
            type: {
                required: "币种不能为空!"
            },
            promoteCode: {
                required: "促销码不能为空!"
            },
            taxRate: {
                required: "税率不能为空!"
            },
            evenName: {
                required: "活动主题不能为空!"
            },
            description:{
                maxlength:"描述不能超过500字"
            },
            unionLevelName: {
                required: "名称不能为空!"
            },
            unionLevelCode: {
                required: "代码不能为空!"
            },
            adjustmentPoint: {
                required: "调整积分不能为空!",
                pattern:"调整积分只能输入整数!"
            },
            listPrice: {
                required: "原价不能为空!",
                pattern:"价格只能输入非负数(如果是小数只能保留两位小数)!"
            },
            salePrice: {
                required: "优惠价不能为空!",
                pattern:"价格只能输入非负数(如果是小数只能保留两位小数)!"
            }
        });
    }]);
    app.value("xnConfig",xnConfig);
    app.controller("BodyController", ["$scope","$location","$filter","dialogService",
        function ($scope,$location,$filter,dialogService) {
            $scope.$on('navShow', function (e, newNavShow) {
                $scope.navShow = newNavShow;
            });
            $scope.global = {loadingInit: false};
            $scope.maxPageSize = 5;

            //日期转换函数
            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.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" || str == "et")) {
                        $("#upImportFile").val("");
                        dialogService.tip([{"message": "请上传Excel支持的文件(xls,xlsx,et等)!"}]);
                    } else {
                        $("#upImportFile").val(upImportFilename);
                    }
                };
            };

        }]);

};