customization.js
5.64 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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
var initApp = function () {
"use strict";
var ref = [
"xn.common",
//"xn.service.foundation",
"xn.directive.top",
"xn.customization.filter",
"xn.customization.service",
"xn.service.interceptor",
"xn.page",
//"xn.customization.opeItem",
//"xn.customization.demand.room",
//"xn.customization.supply.item",
//"xn.customization.supply.storeRoom",
//"xn.customization.combine",
//"xn.customization.setting",
////report
//"xn.customization.ship.report",
//"xn.customization.index",
//"xn.customization.report",
"ui.bootstrap",
"ui.sortable",
"xn.directive.loading",
"xn.directive.select",
//"xn.directive.form",
"xn.directive.location",
"xn.directive.card",
"ngCookies",
"xn.directive.attachment",
"xn.directive.import"
];
var app=angular.module("xn", ref);
app.value("xnConfig", xnConfig);
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({
// giveItemQuantity:{
// required: "赠送数量应大于零,且为正数!"
// }
// });
//}]);
app.controller("BodyController",["$scope",function($scope){
//关闭错误
$scope.closeAlert = function (index,form) {
form.splice(index,1);
};
$scope.$on('navShow', function (e, newNavShow) {
$scope.navShow = newNavShow;
});
$scope.maxPageSize=5;
$scope.isNullValue = function(value){
if(value === 0 || value === "0"){
return false;
}
if(value){
return false;
}
return true;
};
$scope.foregroundPaging = function(param){
var allList = param.allList;
var fieldList = param.fieldList;
var value = param.value;
var pageSize = param.pageSize;
var pageNumber = param.pageNumber;
if(!allList || allList.length == 0){
return {list:[],totalCount:0};
}
if(!pageSize){
pageSize = 10
}
if(!pageNumber){
pageNumber = 1;
}
var lastPageNumber = parseInt(allList.length / pageSize);
if (allList.length % pageSize != 0) {
lastPageNumber++;
}
if (pageNumber > lastPageNumber) {
pageNumber = lastPageNumber;
}
var minIndex = (pageNumber - 1) * pageSize;
var maxIndex = pageNumber * pageSize;
var list = [];
var num = 0;
var returnValue = {result:list};
if(!$scope.isNullValue(value)){
var valueLength = value.length;
for(var i=0;i<allList.length;i++){
var flag = false;
for(var k=0;k<fieldList.length;k++){
var field = fieldList[k];
var fieldValue = allList[i][field];
if (fieldValue == undefined) {
fieldValue = "";
}
var fieldLength = fieldValue.length;
for(var j=0;j<(fieldLength-valueLength+1);j++){
if(value == fieldValue.substring(j,j+valueLength)){
if(num >= minIndex && num < maxIndex){
list.push(allList[i]);
}
num++;
flag = true;
break;
}
}
if(flag){
break;
}
}
}
returnValue.totalCount = num;
} else {
if(maxIndex > allList.length){
maxIndex = allList.length;
}
for(var i=minIndex;i<maxIndex;i++){
list.push(allList[i]);
}
returnValue.totalCount = allList.length;
}
return returnValue;
}
$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);
}
};
};
}]);
};