Main.js 21.5 KB
Newer Older
R
roo00 已提交
1
MWF.xApplication.Attendance = MWF.xApplication.Attendance || {};
F
fancy 已提交
2
MWF.require("MWF.widget.O2Identity", null, false);
R
roo00 已提交
3 4 5 6 7 8 9 10 11 12 13 14
//MWF.xDesktop.requireApp("Attendance", "Actions.RestActions", null, false);
MWF.xDesktop.requireApp("Attendance", "Common", null, false);
MWF.xDesktop.requireApp("Template", "MDomItem", null, false);
MWF.xApplication.Attendance.options = {
	multitask: false,
	executable: true
};
MWF.xApplication.Attendance.Main = new Class({
	Extends: MWF.xApplication.Common.Main,
	Implements: [Options, Events],

	options: {
F
fancy 已提交
15
		"curNaviId": null,
R
roo00 已提交
16 17 18 19 20 21 22 23 24
		"style": "default",
		"name": "Attendance",
		"icon": "icon.png",
		"width": "1400",
		"height": "700",
		"isResize": true,
		"isMax": true,
		"title": MWF.xApplication.Attendance.LP.title
	},
F
fancy 已提交
25
	onQueryLoad: function () {
R
roo00 已提交
26 27
		this.lp = MWF.xApplication.Attendance.LP;
	},
F
fancy 已提交
28
	loadApplication: function (callback) {
R
roo00 已提交
29 30 31 32 33 34 35 36
		if (!this.options.isRefresh) {
			this.maxSize(function () {
				this.loadLayout();
			}.bind(this));
		} else {
			this.loadLayout();
		}
	},
F
fancy 已提交
37 38
	loadLayout: function () {
		this.manageUnits = [];
R
roo00 已提交
39
		this.manageTopUnits = [];
F
fancy 已提交
40
		this.enableType = "";
R
roo00 已提交
41 42 43 44 45 46 47 48

		this.restActions = MWF.Actions.get("x_attendance_assemble_control");
		this.personActions = MWF.Actions.get("x_organization_assemble_personal");
		this.orgActions = MWF.Actions.get("x_organization_assemble_express");

		this.createNode();
		this.loadApplicationContent();
	},
F
fancy 已提交
49 50
	isAdmin: function () {
		return this.isTopUnitManager() || MWF.AC.isAttendanceManager() || MWF.AC.isAdministrator()
R
roo00 已提交
51
	},
F
fancy 已提交
52
	isUnitManager: function () {
R
roo00 已提交
53 54
		return this.manageUnits.length > 0;
	},
F
fancy 已提交
55
	isTopUnitManager: function () {
R
roo00 已提交
56 57
		return this.manageTopUnits.length > 0;
	},
F
fancy 已提交
58
	getNameFlag: function (name) {
R
roo00 已提交
59
		var t = typeOf(name);
F
fancy 已提交
60
		if (t === "array") {
R
roo00 已提交
61
			var v = [];
F
fancy 已提交
62 63
			name.each(function (id) {
				v.push((typeOf(id) === "object") ? (id.distinguishedName || id.id || id.unique || id.name) : id);
R
roo00 已提交
64 65
			});
			return v;
F
fancy 已提交
66 67
		} else {
			return [(t === "object") ? (name.distinguishedName || name.id || name.unique || name.name) : name];
R
roo00 已提交
68 69
		}
	},
F
fancy 已提交
70 71
	loadController: function (callback) {
		this.restActions.listPermission(function (json) {
R
roo00 已提交
72
			json.data = json.data || [];
F
fancy 已提交
73 74 75 76 77
			json.data.each(function (item) {
				if (item.adminLevel == "COMPANY" && item.adminName == layout.desktop.session.user.distinguishedName) {
					this.manageTopUnits.push(item.unitName)
				} else if (item.adminLevel == "DEPT" && item.adminName == layout.desktop.session.user.distinguishedName) {
					this.manageUnits.push(item.unitName)
R
roo00 已提交
78 79
				}
			}.bind(this));
F
fancy 已提交
80
			if (callback) callback(json);
R
roo00 已提交
81 82
		}.bind(this));
	},
F
fancy 已提交
83 84 85 86 87 88 89 90 91 92 93 94
	loadEnableType: function (callback) {
		var action = o2.Actions.load("x_attendance_assemble_control");
		action.AttendanceSettingAction.enableType(//平台封装好的方法
			function (json) { //服务调用成功的回调函数, json为服务传回的数据
				if (json.data && json.data.value) {
					debugger;
					this.enableType = json.data.value;
				}
				if (callback) callback(json);
			}.bind(this));
	},
	createNode: function () {
R
roo00 已提交
95 96
		this.content.setStyle("overflow", "hidden");
		this.node = new Element("div", {
F
fancy 已提交
97
			"styles": { "width": "100%", "height": "100%", "overflow": "hidden" }
R
roo00 已提交
98 99
		}).inject(this.content);
	},
F
fancy 已提交
100 101 102 103 104
	loadApplicationContent: function () {
		this.loadController(function () {
			this.loadEnableType(function () {
				this.loaNavi();
			}.bind(this));
R
roo00 已提交
105 106 107
		}.bind(this));
		//this.loadApplicationLayout();
	},
F
fancy 已提交
108
	loaNavi: function (callback) {
R
roo00 已提交
109 110 111 112
		this.naviNode = new Element("div.naviNode", {
			"styles": this.css.naviNode
		}).inject(this.node);

F
fancy 已提交
113 114
		var curNavi = { "id": "" };
		if (this.status) {
R
roo00 已提交
115 116
			curNavi.id = this.status.id
		}
F
fancy 已提交
117
		if (this.options.curNaviId) {
R
roo00 已提交
118 119
			curNavi.id = this.options.curNaviId;
		}
F
fancy 已提交
120
		this.navi = new MWF.xApplication.Attendance.Navi(this, this.naviNode, curNavi);
R
roo00 已提交
121
	},
F
fancy 已提交
122 123 124
	clearContent: function () {
		if (this.explorerContent) {
			if (this.explorer && this.explorer.destroy) {
R
roo00 已提交
125 126 127 128 129 130
				this.explorer.destroy();
			}
			this.explorerContent.destroy();
			this.explorerContent = null;
		}
	},
F
fancy 已提交
131 132
	openMyIndex: function () {
		MWF.xDesktop.requireApp("Attendance", "MyIndex", function () {
R
roo00 已提交
133 134 135 136
			this.clearContent();
			this.explorerContent = new Element("div", {
				"styles": this.css.rightContentNode
			}).inject(this.node);
F
fancy 已提交
137
			this.explorer = new MWF.xApplication.Attendance.MyIndex(this.explorerContent, this, this.restActions, { "isAdmin": this.isAdmin() });
R
roo00 已提交
138 139 140
			this.explorer.load();
		}.bind(this));
	},
F
fancy 已提交
141 142
	openMyDetail: function () {
		MWF.xDesktop.requireApp("Attendance", "MyDetail", function () {
R
roo00 已提交
143 144 145 146
			this.clearContent();
			this.explorerContent = new Element("div", {
				"styles": this.css.rightContentNode
			}).inject(this.node);
F
fancy 已提交
147
			this.explorer = new MWF.xApplication.Attendance.MyDetail(this.explorerContent, this, this.restActions, { "isAdmin": this.isAdmin() });
R
roo00 已提交
148 149 150
			this.explorer.load();
		}.bind(this));
	},
F
fancy 已提交
151 152
	openUnitIndex: function () {
		MWF.xDesktop.requireApp("Attendance", "UnitIndex", function () {
R
roo00 已提交
153 154 155 156
			this.clearContent();
			this.explorerContent = new Element("div", {
				"styles": this.css.rightContentNode
			}).inject(this.node);
F
fancy 已提交
157
			this.explorer = new MWF.xApplication.Attendance.UnitIndex(this.explorerContent, this, this.restActions, { "isAdmin": this.isAdmin() });
R
roo00 已提交
158 159 160
			this.explorer.load();
		}.bind(this));
	},
F
fancy 已提交
161 162 163 164 165 166 167 168 169 170
	openUnitDingdingIndex: function () {
		MWF.xDesktop.requireApp("Attendance", "UnitDingdingIndex", function () {
			this.clearContent();
			this.explorerContent = new Element("div", {
				"styles": this.css.rightContentNode
			}).inject(this.node);
			this.explorer = new MWF.xApplication.Attendance.UnitDingdingIndex(this.explorerContent, this, this.restActions, { "isAdmin": this.isAdmin() });
			this.explorer.load();
		}.bind(this));
	},
171 172 173 174 175 176 177 178 179 180
	openUnitQywxIndex: function () {
		MWF.xDesktop.requireApp("Attendance", "UnitQywxIndex", function () {
			this.clearContent();
			this.explorerContent = new Element("div", {
				"styles": this.css.rightContentNode
			}).inject(this.node);
			this.explorer = new MWF.xApplication.Attendance.UnitQywxIndex(this.explorerContent, this, this.restActions, { "isAdmin": this.isAdmin() });
			this.explorer.load();
		}.bind(this));
	},
F
fancy 已提交
181 182
	openUnitDetail: function () {
		MWF.xDesktop.requireApp("Attendance", "UnitDetail", function () {
R
roo00 已提交
183 184 185 186
			this.clearContent();
			this.explorerContent = new Element("div", {
				"styles": this.css.rightContentNode
			}).inject(this.node);
F
fancy 已提交
187
			this.explorer = new MWF.xApplication.Attendance.UnitDetail(this.explorerContent, this, this.restActions, { "isAdmin": this.isAdmin() });
R
roo00 已提交
188 189 190
			this.explorer.load();
		}.bind(this));
	},
191
	
F
fancy 已提交
192 193
	openDingdingUnitDetail: function () {
		MWF.xDesktop.requireApp("Attendance", "UnitDingdingDetail", function () {
R
roo00 已提交
194 195 196 197
			this.clearContent();
			this.explorerContent = new Element("div", {
				"styles": this.css.rightContentNode
			}).inject(this.node);
F
fancy 已提交
198
			this.explorer = new MWF.xApplication.Attendance.UnitDingdingDetail(this.explorerContent, this, this.restActions, { "isAdmin": this.isAdmin() });
R
roo00 已提交
199 200 201
			this.explorer.load();
		}.bind(this));
	},
202 203 204 205 206 207 208 209 210 211
	openQywxUnitDetail: function () {
		MWF.xDesktop.requireApp("Attendance", "UnitQywxDetail", function () {
			this.clearContent();
			this.explorerContent = new Element("div", {
				"styles": this.css.rightContentNode
			}).inject(this.node);
			this.explorer = new MWF.xApplication.Attendance.UnitQywxDetail(this.explorerContent, this, this.restActions, { "isAdmin": this.isAdmin() });
			this.explorer.load();
		}.bind(this));
	},
F
fancy 已提交
212 213
	openPeopleDetail: function () {
		MWF.xDesktop.requireApp("Attendance", "PeopleDetail", function () {
R
roo00 已提交
214 215 216 217
			this.clearContent();
			this.explorerContent = new Element("div", {
				"styles": this.css.rightContentNode
			}).inject(this.node);
F
fancy 已提交
218
			this.explorer = new MWF.xApplication.Attendance.PeopleDetail(this.explorerContent, this, this.restActions, { "isAdmin": this.isAdmin() });
R
roo00 已提交
219 220 221
			this.explorer.load();
		}.bind(this));
	},
F
fancy 已提交
222 223
	openDingdingPeopleDetail: function () {
		MWF.xDesktop.requireApp("Attendance", "PeopleDingdingDetail", function () {
R
roo00 已提交
224 225 226 227
			this.clearContent();
			this.explorerContent = new Element("div", {
				"styles": this.css.rightContentNode
			}).inject(this.node);
F
fancy 已提交
228
			this.explorer = new MWF.xApplication.Attendance.PeopleDingdingDetail(this.explorerContent, this, this.restActions, { "isAdmin": this.isAdmin() });
R
roo00 已提交
229 230 231
			this.explorer.load();
		}.bind(this));
	},
232 233 234 235 236 237 238 239 240 241
	openQywxPeopleDetail: function () {
		MWF.xDesktop.requireApp("Attendance", "PeopleQywxDetail", function () {
			this.clearContent();
			this.explorerContent = new Element("div", {
				"styles": this.css.rightContentNode
			}).inject(this.node);
			this.explorer = new MWF.xApplication.Attendance.PeopleQywxDetail(this.explorerContent, this, this.restActions, { "isAdmin": this.isAdmin() });
			this.explorer.load();
		}.bind(this));
	},
F
fancy 已提交
242 243
	openTopUnitDetail: function () {
		MWF.xDesktop.requireApp("Attendance", "TopUnitDetail", function () {
R
roo00 已提交
244 245 246 247
			this.clearContent();
			this.explorerContent = new Element("div", {
				"styles": this.css.rightContentNode
			}).inject(this.node);
F
fancy 已提交
248
			this.explorer = new MWF.xApplication.Attendance.TopUnitDetail(this.explorerContent, this, this.restActions, { "isAdmin": this.isAdmin() });
R
roo00 已提交
249 250 251
			this.explorer.load();
		}.bind(this));
	},
F
fancy 已提交
252 253
	openSelfHoliday: function () {
		MWF.xDesktop.requireApp("Attendance", "SelfHoliday", function () {
R
roo00 已提交
254 255 256 257
			this.clearContent();
			this.explorerContent = new Element("div", {
				"styles": this.css.rightContentNode
			}).inject(this.node);
F
fancy 已提交
258
			this.explorer = new MWF.xApplication.Attendance.SelfHoliday(this.explorerContent, this, this.restActions, { "isAdmin": this.isAdmin() });
R
roo00 已提交
259 260 261
			this.explorer.load();
		}.bind(this));
	},
F
fancy 已提交
262 263
	openMyAppealDeal: function () {
		MWF.xDesktop.requireApp("Attendance", "MyAppeal", function () {
R
roo00 已提交
264 265 266 267
			this.clearContent();
			this.explorerContent = new Element("div", {
				"styles": this.css.rightContentNode
			}).inject(this.node);
F
fancy 已提交
268
			this.explorer = new MWF.xApplication.Attendance.MyAppeal(this.explorerContent, this, this.restActions, { "isAdmin": this.isAdmin() });
R
roo00 已提交
269 270 271
			this.explorer.load();
		}.bind(this));
	},
F
fancy 已提交
272 273
	openAppealDeal: function () {
		MWF.xDesktop.requireApp("Attendance", "AppealExplorer", function () {
R
roo00 已提交
274 275 276 277
			this.clearContent();
			this.explorerContent = new Element("div", {
				"styles": this.css.rightContentNode
			}).inject(this.node);
F
fancy 已提交
278
			this.explorer = new MWF.xApplication.Attendance.AppealExplorer(this.explorerContent, this, this.restActions, { "isAdmin": this.isAdmin() });
R
roo00 已提交
279 280 281
			this.explorer.load();
		}.bind(this));
	},
F
fancy 已提交
282 283
	openImporting: function () {
		MWF.xDesktop.requireApp("Attendance", "ImportExplorer", function () {
R
roo00 已提交
284 285 286 287
			this.clearContent();
			this.explorerContent = new Element("div", {
				"styles": this.css.rightContentNode
			}).inject(this.node);
F
fancy 已提交
288
			this.explorer = new MWF.xApplication.Attendance.ImportExplorer(this.explorerContent, this, this.restActions, { "isAdmin": this.isAdmin() });
R
roo00 已提交
289 290 291
			this.explorer.load();
		}.bind(this));
	},
F
fancy 已提交
292 293
	openImportedInvalidInfor: function () {
		MWF.xDesktop.requireApp("Attendance", "InvalidInfor", function () {
R
roo00 已提交
294 295 296 297
			this.clearContent();
			this.explorerContent = new Element("div", {
				"styles": this.css.rightContentNode
			}).inject(this.node);
F
fancy 已提交
298
			this.explorer = new MWF.xApplication.Attendance.InvalidInfor(this.explorerContent, this, this.restActions, { "isAdmin": this.isAdmin() });
R
roo00 已提交
299 300 301
			this.explorer.load();
		}.bind(this));
	},
F
fancy 已提交
302 303
	openAbnormalExport: function () {
		MWF.xDesktop.requireApp("Attendance", "AbnormalExport", function () {
R
roo00 已提交
304 305 306 307
			this.clearContent();
			this.explorerContent = new Element("div", {
				"styles": this.css.rightContentNode
			}).inject(this.node);
F
fancy 已提交
308
			this.explorer = new MWF.xApplication.Attendance.AbnormalExport(this.explorerContent, this, this.restActions, { "isAdmin": this.isAdmin() });
R
roo00 已提交
309 310 311
			this.explorer.load();
		}.bind(this));
	},
F
fancy 已提交
312 313
	openScheduleSetting: function () {
		MWF.xDesktop.requireApp("Attendance", "ScheduleExplorer", function () {
R
roo00 已提交
314 315 316 317
			this.clearContent();
			this.explorerContent = new Element("div", {
				"styles": this.css.rightContentNode
			}).inject(this.node);
F
fancy 已提交
318
			this.explorer = new MWF.xApplication.Attendance.ScheduleExplorer(this.explorerContent, this, this.restActions, { "isAdmin": this.isAdmin() });
R
roo00 已提交
319 320 321
			this.explorer.load();
		}.bind(this));
	},
F
fancy 已提交
322 323
	openPermissionSetting: function () {
		MWF.xDesktop.requireApp("Attendance", "PermissionExplorer", function () {
R
roo00 已提交
324 325 326 327
			this.clearContent();
			this.explorerContent = new Element("div", {
				"styles": this.css.rightContentNode
			}).inject(this.node);
F
fancy 已提交
328
			this.explorer = new MWF.xApplication.Attendance.PermissionExplorer(this.explorerContent, this, this.restActions, { "isAdmin": this.isAdmin() });
R
roo00 已提交
329 330 331
			this.explorer.load();
		}.bind(this));
	},
F
fancy 已提交
332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354
	openHolidaySetting: function () {
		MWF.xDesktop.requireApp("Attendance", "HolidayExplorer", function () {
			this.clearContent();
			this.explorerContent = new Element("div", {
				"styles": this.css.rightContentNode
			}).inject(this.node);
			this.explorer = new MWF.xApplication.Attendance.HolidayExplorer(this.explorerContent, this, this.restActions, { "isAdmin": this.isAdmin() });
			this.explorer.load();
		}.bind(this));
	},
	openStaticsCycleExplorer: function () {
		MWF.xDesktop.requireApp("Attendance", "StatisticsCycle", function () {
			this.clearContent();
			this.explorerContent = new Element("div", {
				"styles": this.css.rightContentNode
			}).inject(this.node);
			this.explorer = new MWF.xApplication.Attendance.StatisticsCycle(this.explorerContent, this, this.restActions, { "isAdmin": this.isAdmin() });
			this.explorer.load();
		}.bind(this));
	},
	openAppSetting: function () {
		MWF.xDesktop.requireApp("Attendance", "AppSetting", function () {
			var setting = new MWF.xApplication.Attendance.AppSetting(this, this.restActions);
R
roo00 已提交
355 356 357
			setting.edit();
		}.bind(this));
	},
L
luojing 已提交
358 359 360 361 362 363
	openWeekendSetting : function(){
		MWF.xDesktop.requireApp("Attendance", "WeekendSetting", function(){
			var setting = new MWF.xApplication.Attendance.WeekendSetting(this,this.restActions);
			setting.edit();
		}.bind(this));
	},
F
fancy 已提交
364 365
	openAddressSetting: function () {
		MWF.xDesktop.requireApp("Attendance", "AddressExplorer", function () {
R
roo00 已提交
366 367 368 369
			this.clearContent();
			this.explorerContent = new Element("div", {
				"styles": this.css.rightContentNode
			}).inject(this.node);
F
fancy 已提交
370
			this.explorer = new MWF.xApplication.Attendance.AddressExplorer(this.explorerContent, this, this.restActions, { "isAdmin": this.isAdmin() });
R
roo00 已提交
371 372 373
			this.explorer.load();
		}.bind(this));
	},
F
fancy 已提交
374 375
	openPersonSetting: function () {
		MWF.xDesktop.requireApp("Attendance", "PersonSetting", function () {
R
roo00 已提交
376 377 378 379
			this.clearContent();
			this.explorerContent = new Element("div", {
				"styles": this.css.rightContentNode
			}).inject(this.node);
F
fancy 已提交
380
			this.explorer = new MWF.xApplication.Attendance.PersonSetting(this.explorerContent, this, this.restActions, { "isAdmin": this.isAdmin() });
R
roo00 已提交
381 382 383
			this.explorer.load();
		}.bind(this));
	},
F
fancy 已提交
384 385
	recordStatus: function () {
		return this.navi && this.navi.currentItem ? this.navi.currentItem.retrieve("data") : {};
R
roo00 已提交
386 387 388 389 390 391 392
	}
});



MWF.xApplication.Attendance.Navi = new Class({
	Implements: [Options, Events],
F
fancy 已提交
393 394
	options: {
		"id": ""
R
roo00 已提交
395
	},
F
fancy 已提交
396
	initialize: function (app, node, options) {
R
roo00 已提交
397 398 399 400 401 402 403 404 405 406 407
		this.setOptions(options);
		this.app = app;
		this.node = $(node);
		this.css = this.app.css;
		this.currentMenu = null;
		this.currentItem = null;
		this.menus = {};
		this.items = {};
		this.elements = [];
		this.load();
	},
F
fancy 已提交
408 409 410
	load: function () {
		this.scrollNode = new Element("div.naviScrollNode", { "styles": this.css.naviScrollNode }).inject(this.node);
		this.areaNode = new Element("div.naviAreaNode", { "styles": this.css.naviAreaNode }).inject(this.scrollNode);
R
roo00 已提交
411 412 413

		this.setNodeScroll();

F
fancy 已提交
414 415 416 417 418 419 420 421 422 423
		var naviUrl = this.app.path + "navi.json";
		MWF.getJSON(naviUrl, function (json) {
			json.each(function (navi) {
				if (navi.access && navi.access == "admin") {
					if (this.app.isAdmin()) this.createNaviNode(navi);
				} else if (navi.access && navi.access == "admin_dept") {
					if (this.app.isUnitManager() || this.app.isAdmin()) this.createNaviNode(navi);
				} else if (navi.access && navi.access == "dingding") { //启用钉钉考勤同步后
					debugger;
					if ((this.app.isUnitManager() || this.app.isAdmin()) && (this.app.enableType == "dingding")) this.createNaviNode(navi);
424 425 426
				} else if (navi.access && navi.access == "qywx") { // 启用企业微信考勤同步后
					debugger;
					if ((this.app.isUnitManager() || this.app.isAdmin()) && (this.app.enableType == "qywx")) this.createNaviNode(navi);
F
fancy 已提交
427
				} else {
R
roo00 已提交
428 429 430
					this.createNaviNode(navi);
				}
			}.bind(this));
F
fancy 已提交
431
			if (this.options.id == "") this.elements[0].click();
R
roo00 已提交
432 433 434 435 436 437

			this.setContentSize();

			this.app.addEvent("resize", this.setContentSize.bind(this));
		}.bind(this));
	},
F
fancy 已提交
438 439
	setNodeScroll: function () {
		MWF.require("MWF.widget.DragScroll", function () {
R
roo00 已提交
440 441
			new MWF.widget.DragScroll(this.scrollNode);
		}.bind(this));
F
fancy 已提交
442 443
		MWF.require("MWF.widget.ScrollBar", function () {
			new MWF.widget.ScrollBar(this.scrollNode, { "indent": false });
R
roo00 已提交
444 445
		}.bind(this));
	},
F
fancy 已提交
446 447
	createNaviNode: function (data) {
		if (data.type == "sep") {
R
roo00 已提交
448
			var flag = true;
F
fancy 已提交
449 450 451 452
			if (data.access == "admin") {
				if (!this.app.isAdmin()) flag = false;
			} else if (data.access && data.access == "admin_dept") {
				if (!this.app.isUnitManager() && !this.app.isAdmin()) flag = false;
R
roo00 已提交
453
			}
F
fancy 已提交
454
			if (flag) {
R
roo00 已提交
455 456
				new Element("div", { "styles": this.css.viewNaviSepartorNode }).inject(this.areaNode);
			}
F
fancy 已提交
457
		} else if (data.sub && data.sub.length > 0) {
R
roo00 已提交
458
			this.createNaviMenuNode(data);
F
fancy 已提交
459
		} else {
R
roo00 已提交
460 461 462 463
			this.menus[data.id] = {};
			this.createNaviItemNode(data, data.id);
		}
	},
F
fancy 已提交
464 465 466 467 468
	createNaviMenuNode: function (data) {
		if (data.access == "admin") {
			if (!this.app.isAdmin()) return;
		} else if (data.access == "admin_dept") {
			if (!this.app.isUnitManager() && !this.app.isAdmin()) return;
R
roo00 已提交
469 470 471 472 473 474 475 476
		}
		var _self = this;
		var menuNode = new Element("div", {
			"styles": this.css.naviMenuNode
		});
		menuNode.store("data", data);
		menuNode.store("type", "menu");

F
fancy 已提交
477
		var textNode = new Element("div", {
R
roo00 已提交
478 479 480 481 482 483 484 485 486 487 488
			"styles": this.css.naviMenuTextNode,
			"text": data.title
		});
		textNode.inject(menuNode);
		menuNode.inject(this.areaNode);

		this.menus[data.id] = {};
		this.menus[data.id].node = menuNode;
		this.elements.push(menuNode);

		menuNode.addEvents({
F
fancy 已提交
489 490 491 492 493
			"mouseover": function () { if (_self.currentMenu != this) this.setStyles(_self.app.css.naviMenuNode_over); },
			"mouseout": function () { if (_self.currentMenu != this) this.setStyles(_self.app.css.naviMenuNode); },
			"mousedown": function () { if (_self.currentMenu != this) this.setStyles(_self.app.css.naviMenuNode_down); },
			"mouseup": function () { if (_self.currentMenu != this) this.setStyles(_self.app.css.naviMenuNode_over); },
			"click": function () {
R
roo00 已提交
494 495 496 497 498
				//if (_self.currentNavi!=this) _self.doAction.apply(_self, [this]);
				_self.clickMenu.apply(_self, [this]);
			}
		});

F
fancy 已提交
499 500
		data.sub.each(function (d) {
			this.createNaviItemNode(d, data.id, menuNode)
R
roo00 已提交
501 502
		}.bind(this))
	},
F
fancy 已提交
503
	clickMenu: function (naviNode) {
R
roo00 已提交
504 505 506 507
		var navi = naviNode.retrieve("data");
		var action = navi.action;

		this.closeCurrentMenu();
F
fancy 已提交
508 509 510
		if (this.menus[navi.id].itemNodes) {
			this.menus[navi.id].itemNodes.each(function (itemNode) {
				itemNode.setStyle("display", "block");
R
roo00 已提交
511 512 513 514 515
			})
		}

		var type = naviNode.retrieve("type");
		if (!navi.target || navi.target != "_blank") {
F
fancy 已提交
516
			naviNode.setStyles(this.css.naviMenuNode_current);
R
roo00 已提交
517 518 519
			this.currentMenu = naviNode;
		}
	},
F
fancy 已提交
520 521
	closeCurrentMenu: function () {
		if (this.currentMenu) {
R
roo00 已提交
522 523 524 525 526 527
			var data = this.currentMenu.retrieve("data");
			if (this.menus[data.id].itemNodes) {
				this.menus[data.id].itemNodes.each(function (itemNode) {
					itemNode.setStyle("display", "none");
				})
			}
F
fancy 已提交
528
			this.currentMenu.setStyles(this.css.naviMenuNode);
R
roo00 已提交
529 530
		}
	},
F
fancy 已提交
531
	createNaviItemNode: function (data, menuId) {
R
roo00 已提交
532

F
fancy 已提交
533 534 535 536
		if (data.access == "admin") {
			if (!this.app.isAdmin()) return;
		} else if (data.access && data.access == "admin_dept") {
			if (!this.app.isUnitManager() && !this.app.isAdmin()) return;
R
roo00 已提交
537 538 539 540 541 542 543 544 545
		}

		var _self = this;

		var items = this.menus[menuId].itemNodes = this.menus[menuId].itemNodes || [];

		var itemNode = new Element("div", {
			"styles": this.css.naviItemNode
		});
F
fancy 已提交
546
		itemNode.setStyle("display", "block");
R
roo00 已提交
547 548 549 550 551

		items.push(itemNode);
		itemNode.store("data", data);
		itemNode.store("type", "item");

F
fancy 已提交
552
		var textNode = new Element("div", {
R
roo00 已提交
553 554 555 556 557 558 559 560 561 562 563
			"styles": this.css.naviItemTextNode,
			"text": data.title
		});
		textNode.inject(itemNode);

		itemNode.inject(this.areaNode);

		this.elements.push(itemNode);
		this.items[data.id] = itemNode;

		itemNode.addEvents({
F
fancy 已提交
564 565 566 567 568
			"mouseover": function () { if (_self.currentItem != this) this.setStyles(_self.app.css.naviItemNode_over); },
			"mouseout": function () { if (_self.currentItem != this) this.setStyles(_self.app.css.naviItemNode); },
			"mousedown": function () { if (_self.currentItem != this) this.setStyles(_self.app.css.naviItemNode_down); },
			"mouseup": function () { if (_self.currentItem != this) this.setStyles(_self.app.css.naviItemNode_over); },
			"click": function () {
R
roo00 已提交
569 570 571 572
				_self.clickItem.apply(_self, [this]);
			}
		});

F
fancy 已提交
573
		if (data.id == this.options.id) {
R
roo00 已提交
574 575 576
			itemNode.click();
		}
	},
F
fancy 已提交
577
	clickItem: function (naviNode) {
R
roo00 已提交
578 579 580 581 582 583 584 585 586 587 588 589 590 591
		var navi = naviNode.retrieve("data");
		var action = navi.action;

		var type = naviNode.retrieve("type");
		if (!navi.target || navi.target != "_blank") {
			if (this.currentItem) this.currentItem.setStyles(this.css.naviItemNode);
			naviNode.setStyles(this.css.naviItemNode_current);
			this.currentItem = naviNode;
		}

		if (navi.action && this.app[navi.action]) {
			this.app[navi.action].call(this.app, navi);
		}
	},
F
fancy 已提交
592
	setContentSize: function () {
R
roo00 已提交
593
		var size = this.app.content.getSize();
F
fancy 已提交
594
		this.scrollNode.setStyle("height", size.y - 5);
R
roo00 已提交
595 596 597 598 599 600 601 602 603
	}
	//loadCalendar: function () {
	//	var calendarArea = new Element("div#calendarArea",{
	//		"styles" : this.css.calendarArea
	//	}).inject(this.node)
	//	this.calendar = new MWF.xApplication.Attendance.Calendar( calendarArea, this.app, this.actions )
	//	this.calendar.load();
	//}
});