top.js
19.4 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
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
//公共组件
//服务接口
angular.module("xn/template/header.html",[]).run(["$templateCache", function($templateCache) {
"use strict";
$templateCache.put("headerTopInfoCenter/tpl.html",
"<div class='xn-pharos clearfix'>"
+ " <ul class='header-right clearfix' ng-init='phoneApp=false;showApp=false;showMessage=false;showTask=false;showPersonInfo=false;'>"
+" <li class='header-li' ng-class=\"!showConfig.isShowCustomer&&!showConfig.isShowYun&&!showConfig.isShowAddressBook?'header-none':''\">"
+" <span class=\"light-item\" ng-show='showConfig.isShowYun'><a class='light-txt ' href='{{xnConfig.myUrl}}pan/file.htm' target='_blank'>云盘</a></span>"
+" <span class=\"light-item\" ng-show='showConfig.isShowAddressBook'><a class='light-txt' href='{{xnConfig.myUrl}}addressBook.htm' target='_blank'>通讯录</a></span>"
+" </li>"
+" <li class='header-li'>"
+" <span class=\"light-item\" ng-show='showConfig.isShowIndex' ><a class='deep-txt' href='{{xnConfig.myUrl}}index.htm' target=\"_self\">首页</a></span>"
+" <span class=\"light-item\" ng-mouseover='showApp=true;' ng-mouseleave='showApp=false'>"
+" <a class='deep-txt orange-txt' href='{{xnConfig.myUrl}}application.htm' target=\"_self\" >应用中心</a>"
//#*常用应用下拉框*#
+" <div class='header-list app-list' ng-show='showApp==true' ng-mouseover='showApp=true;' ng-mouseleave='showApp=false'>"
+" <div class='hide-tri'></div>"
+" <ul class='header-info-ul'>"
+" <li class='header-info-li' ng-repeat='app in appList' ng-if=\"$index<8\" >"
+" <a href='{{app.url}}'>"
+" <img class ='app-img' ng-src='{{iconBaseUrl}}icon/application/{{app.applicationId}}.png'/>"
+" <span>{{app.applicationName}}</span>"
+" </a>"
+" </li>"
+" <div class=\"header-no-info\" ng-if=\"appList.length==0\"><span class='img'>暂无常用应用</span></div>"
+" <li class='header-info-li info-bottom'>"
+" <a href='{{xnConfig.myUrl}}application.htm'>"
+" <span class ='app-all-img'><i class='icon icon-app'></i></span>"
+" <span class='app-name'>全部应用</span>"
+" </a>"
+" </li>"
+" </ul>"
+" </div>"
+" </span>"
+" </li>"
+" <li class='header-li' ng-show='showConfig.isShowMessage || showConfig.isShowTask' >"
+" <span class=\"light-item\" ng-show='showConfig.isShowMessage' ng-mouseover='showMessage=true;' ng-mouseleave='showMessage=false'>"
+" <a class='deep-txt' href='{{xnConfig.myUrl}}message/index.htm'>消息<span class='number' ng-show='messagesAll.length>0'>{{messagesAll.length}}</span></a>"
//消息下拉框
+" <div class='header-list message-list' ng-show='showMessage==true' ng-mouseover='showMessage=true;' ng-mouseleave='showMessage=false'>"
+" <div class='hide-tri'></div>"
+" <ul class='header-info-ul'>"
+" <li class='header-info-li' ng-repeat='message in messages'>"
+" <a ng-click='messageDetail(message.id)'><span>{{message.messageTitle | substr:20}}</span></a>"
+" </li>"
+" <div class=\"header-no-info\" ng-if=\"messages.length==0\"><span class='img'>暂无消息</span></div>"
+" <li class='header-info-li info-bottom xn-text-center' >"
+" <a href='{{xnConfig.myUrl}}message/index.htm'>查看全部</a>"
+" </li>"
+" </ul>"
+" </div>"
+" </span>"
+" <span class=\"light-item\" ng-show='showConfig.isShowTask' ng-mouseover='showTask=true;' ng-mouseleave='showTask=false'>"
+" <a class='deep-txt ' href='{{xnConfig.myUrl}}task/futrue.htm'>任务<span class='number'ng-show='tasksAll.length>0'>{{tasksAll.length}}</span></a>"
//任务下拉框
+" <div class='header-list task-list' ng-show='showTask==true' ng-mouseover='showTask=true;' ng-mouseleave='showTask=false'>"
+" <div class='hide-tri'></div>"
+" <ul class='header-info-ul'>"
+" <li class='header-info-li' ng-repeat='task in tasks'>"
+" <a href='{{task.assignReason}}'>"
+" <span>{{task.owner.name}}{{task.assignCode | substr:40}}</span>"
+" </a>"
+" </li>"
+" <div class=\"header-no-info\" ng-if=\"tasks.length==0\"><span class='img'>暂无任务</span></div>"
+" <li class='header-info-li info-bottom xn-text-center'>"
+" <a href='{{xnConfig.myUrl}}task/futrue.htm'><span>查看全部</span></a>"
+" </li>"
+" </ul>"
+" </div>"
+" </span>"
+" </li>"
+" <li class='header-li'>"
+" <span class=\"light-item\" ng-mouseover='showPersonInfo=true;' ng-mouseleave='showPersonInfo=false'>"
+" <a class='deep-txt ' href='{{xnConfig.myUrl}}task/futrue.htm'>个人中心</a>"
+" <div class='header-list info-list' ng-show='showPersonInfo==true' ng-mouseover='showPersonInfo=true;'ng-mouseleave='showPersonInfo=false'>"
+" <div class='hide-tri'></div>"
+" <ul class='header-info-ul'>"
+" <li class='header-info-li'>"
+" <a title='个人信息' href='{{xnConfig.myUrl}}profileView'>"
+" <i class='icon icon-individual'></i><span>个人信息</span></a>"
+" </li>"
+" <li class='header-info-li '>"
+" <a title='企业信息' href='{{xnConfig.myUrl}}tenant'>"
+" <i class='icon icon-renter '></i><span>企业信息</span></a>"
+" </li>"
+" <li class='header-info-li '>"
+" <a title='个人网盘' href='{{xnConfig.myUrl}}pan/file.htm'>"
+" <i class='icon icon-onlinedisk '></i><span>个人网盘</span></a>"
+" </li>"
+" <li class='header-info-li'>"
+" <a title='修改密码' href='{{xnConfig.myUrl}}auth/change.htm'>"
+" <i class='icon icon-modifypassword '></i><span>修改密码</span></a>"
+" </li>"
+" <li class='header-info-li'>"
+" <a title='关于本系统' href='{{aboutUrl}}' target='_blank'>"
+" <i class='icon icon-aboutthissystem'></i><span>关于本系统</span></a>"
+" </li>"
+" <li class='header-info-li info-bottom'>"
+" <a title='退出' href='{{xnConfig.myUrl}}auth/logout.htm'>"
+" <i class='icon icon-quit'></i><span>退出</span></a>"
+" </li>"
+" </ul>"
+" </div>"
+" </span>"
+" </li>"
+" </ul>"
+"</div>"
);
}]);
angular.module("xn.directive.top",["xn/template/header.html"])
.value("xnConfig", [])
.filter('substr', function() {
return function(input,start) {
String.prototype.lengthB = function( ){
var b = 0, l = this.length;
if( l ){
for( var i = 0; i < l; i ++ ){
if(this.charCodeAt( i ) > 255 ){
b += 2;
}else{
b ++ ;
}
}
return b;
}else{
return 0;
}
};
if(input){
var data="";
if(start){
if(input.lengthB()>start){
data =input.substr(0, start)+"...";
}else{
data =input.substr(0, start)
}
}else{
data=input;
}
return data;
};
}
})
.directive("headerInfoCenter", ["$modal","CommonService","xnConfig",function($modal,CommonService,xnConfig) {
var config = [];
var defaultInfoConfig={
"isShowApp":true,
"isShowCustomer":true,
"isShowHelp":true,
"isShowYun":true,
"isShowAddressBook":false, /*企业通讯录*/
"isShowIndex":false, /*首页*/
"isShowMessage":false, /*消息*/
"isShowTask":false /*任务*/
};
if(xnConfig){
config = angular.extend(config, xnConfig);
};
return {
restrict: "AE",
scope: {
aboutUrl: "@",
iconBaseUrl: "@",
defaultShow:"=",
userType:"@"
},
templateUrl: "headerTopInfoCenter/tpl.html",
link: function(scope,element,atter,ngModel) {
if(config){
scope.xnConfig = config
}
/*赋值哪些显示哪些不显示*/
if(scope.defaultShow && angular.isObject(scope.defaultShow)){
scope.showConfig=angular.extend(defaultInfoConfig, scope.defaultShow);
}else {
scope.showConfig=defaultInfoConfig;
}
if(scope.userType){
switch (scope.userType)
{ case "EMPLOYEE":
case "NONE":
scope.showConfig.isShowAddressBook=true;
scope.showConfig.isShowIndex=true;
scope.showConfig.isShowMessage=true;
scope.showConfig.isShowTask=true;
break;
case "SUPPLIER":
case "MEMBER":
scope.showConfig.isShowAddressBook=false;
scope.showConfig.isShowIndex=false;
scope.showConfig.isShowMessage=false;
scope.showConfig.isShowTask=false;
break;
default:
scope.showConfig.isShowAddressBook=false;
scope.showConfig.isShowIndex=false;
scope.showConfig.isShowMessage=false;
scope.showConfig.isShowTask=false;
break;
}
}
/*获取应用列表*/
scope.getAppList=function(){
CommonService.getCommonlyAppList().success(function(data) {
scope.appList = [];
scope.appAll = data.result;
if (scope.appAll != undefined) {
if (data.result.length > 8) {
for (var i = 0; i <8; i++) {
scope.appList.push(data.result[i]);
}
} else {
scope.appList = data.result;
}
}else{
scope.appAll=[];
}
});
};
scope.getAppList();
//获取消息列表
scope.getMessageList = function () {
CommonService.getMessageList().success(function (data) {
scope.messages = [];
scope.messagesAll = data.result;
if (scope.messagesAll != undefined) {
if (data.result.length > 10) {
for (var i = 0; i < 10; i++) {
scope.messages.push(data.result[i]);
}
} else {
scope.messages = data.result;
}
}else{
scope.messagesAll=[];
}
});
};
if(scope.showConfig.isShowMessage){
scope.getMessageList();
}
/*获取任务列表*/
scope.getTaskList = function () {
CommonService.getTaskList().success(function (data) {
scope.tasks = [];
scope.tasksAll = data.result;
if (scope.tasksAll != undefined) {
if (data.result.length > 10) {
for (var i = 0; i < 10; i++) {
scope.tasks.push(data.result[i]);
}
} else {
scope.tasks = data.result;
}
}else{
scope.tasksAll=[];
}
});
};
if(scope.showConfig.isShowTask){
scope.getTaskList();
}
scope.messageDetail=function(id){
var modalInstance = $modal.open({
template:"<div class=\"modal-header\">"+
" <h3 class=\"modal-title\">{{messageDetail.messageTitle}}</h3>"+
" </div>"+
" <div class=\"modal-body clearfix\" >"+
" <div class=\"form-group col-sm-10 col-md-offset-1 clearfix\">"+
" <dd>{{messageDetail.messageContent}}</dd>"+
" </div>"+
" </div>"+
" <div class=\"modal-footer\">"+
" <a class=\"btn btn-default col-md-2 col-md-offset-1\" ng-click=\"cancel()\" ng-href=\"{{messageDetail.messageUrl}}\" target=\"_blank\""+
" ng-if=\"messageDetail.messageUrl!=undefined\">跳转</a>"+
" <button class=\"btn btn-warning\" ng-click=\"cancel()\">关闭</button>"+
" </div>",
controller:["$scope","$modalInstance","items","CommonService", function ($scope, $modalInstance,items , CommonService) {
var vm = {id:items.id};
//页面加载消息详细信息
$scope.getMessageDetail = function () {
CommonService.getMessageDetail(vm).success(function (data) {
$scope.messageDetail = data.message;
});
};
$scope.doRead = function () {
$scope.messageReadIds = [];
$scope.messageReadIds.push(vm.id);
CommonService.doRead($scope.messageReadIds).success(function () {});
};
$scope.cancel = function () {
$modalInstance.dismiss("cancel");
};
$scope.getMessageDetail();
$scope.doRead();
}] ,
resolve: {
items: function () {
return {id:id};
}
}
});
modalInstance.result.then(function () {
scope.getMessageList();
},function () {
scope.getMessageList();
});
}
}
};
}])
.factory("CommonService",["$http",function($http){
var service={};
//消息明细获取
service.getMessageDetail=function(request) {
/* var url="http://local.xiniunet.com/api/foundation.do";*/
var url=xnConfig.myUrl+"api/foundation.do";
return $http({
method : "GET",
withCredentials:true,
url : url,
params:{"method":"api.foundation.message.get","ids":[request.id]}
//data:request
});
};
//未读消息读取
service.getMessageList=function() {
var url=xnConfig.myUrl+"api/foundation.do";
return $http({
method : "POST",
withCredentials:true,
url : url,
params:{"method":"api.foundation.messages.get"}
});
};
//已读消息读取
service.getReadedMessageList=function() {
var url=xnConfig.myUrl+"api/foundation.do";
return $http({
method : "POST",
withCredentials:true,
url : url,
params:{"method":"api.foundation.readedmessage.get"}
});
};
//读消息
service.doRead=function(messageIdList) {
/* var url="http://local.xiniunet.com/api/foundation.do";*/
var url=xnConfig.myUrl+"api/foundation.do";
return $http({
method : "GET",
withCredentials:true,
url : url,
params:{"method":"api.foundation.message.read","ids":messageIdList}
});
};
//待办任务获取
service.getTaskList=function() {
var url=xnConfig.myUrl+"api/foundation.do";
return $http({
method : "POST",
withCredentials:true,
url : url,
params:{"method":"api.foundation.tasks.get"}
});
};
//获取应用列表
service.getCommonlyAppList = function () {
var url = xnConfig.myUrl+"system/api.do";
return $http({
method: "POST",
withCredentials:true,
url: url,
params: {"method": "api.platform.application.get.commonly"}
});
};
return service;
}]);