home.js
3.72 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
var initApp = function () {
"use strict";
var ref = [
"xn.common",
"xn.directive.top",
"xn.service.interceptor",
"xn.home.filter",
"xn.home.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"
];
var app = angular.module("xn", ref);
//拦截器
app.config(["$httpProvider", function ($httpProvider) {
$httpProvider.interceptors.push("httpInterceptor");
}]);
// 全局配置 form提交验证
app.config(["xnValidatorProvider", function (xnValidatorProvider) {
// 全局配置
xnValidatorProvider.config({
blurTrig: false,
showError: false,
removeError: false
});
xnValidatorProvider.setRules({
});
}]);
app.value("xnConfig",xnConfig);
app.controller("BodyController", ["$scope","$location","dialogService",
function ($scope,$location,dialogService) {
$scope.$on('navShow', function (e, newNavShow) {
$scope.navShow = newNavShow;
});
$scope.$on('subnavShow', function (e, newNavShow) {
$scope.subnavShow = 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);
}
};
};
}]);
};