(function () {
|
'use strict';
|
angular
|
.module('core.controller',[])
|
.controller("BodyCtrl",BodyCtrl)
|
;
|
|
function BodyCtrl($scope, $state, $document, $timeout, $rootScope, Utils,$window, CurdHelper) {
|
|
$scope.includes = includes;
|
|
$rootScope.screen = {
|
width: $document.innerWidth(),
|
height:$document.innerHeight()
|
};
|
|
$scope.btns = [];
|
|
$rootScope.setStyle = setStyle;
|
|
$scope.init = init;
|
$scope.isSpread = true;
|
$rootScope.divSpread = false;
|
|
function _closeList() {
|
$rootScope.divSpread = false;
|
}
|
|
$scope.closeList = function (event) {
|
event.stopPropagation();
|
_closeList();
|
};
|
|
|
$scope.toggle = function toggle(event) {
|
event.stopImmediatePropagation();
|
if ($rootScope.divSpread) { _closeList(); } else { $rootScope.divSpread = true; }
|
};
|
|
$scope.auth = [];
|
|
function init() {
|
|
$scope.btns = [{
|
name: "库位预览",
|
img: "btnCrane.png",
|
href: "task.preview-place",
|
includes: "task.preview-place",
|
icon: "glyphicon glyphicon-th-large",
|
hasPermission:true,
|
p: { tag: null }
|
},
|
{
|
name: "输送机",
|
img: "btnCuttingMachines.png",
|
href: "task.conveyor-monitor",
|
includes: "task.conveyor-monitor",
|
icon: "glyphicon glyphicon-road",
|
hasPermission: true,
|
p: { tag: null }
|
},
|
{
|
name: "堆垛机",
|
img: "btnCrane.png",
|
href: "task.stacker-monitor",
|
includes: "task.stacker-monitor",
|
icon: "glyphicon glyphicon-sound-dolby",
|
hasPermission: true,
|
p: { tag: null }
|
}];
|
|
CurdHelper.query("./Auth/GetAuth", function (data) {
|
|
if (Utils.isBlank(data.Message)) {
|
$scope.auth = data.Result;
|
for (var i = 0; i < $scope.btns.length; i++) {
|
for (var j = 0; j < $scope.auth.length; j++) {
|
if ($scope.btns[i].href == $scope.auth[j].ContentCode) {
|
$scope.btns[i].hasPermission = true;
|
|
break;
|
|
}
|
}
|
}
|
resize();
|
|
}
|
});
|
|
}
|
|
function resize() {
|
if ($window.innerWidth < 1900 && $scope.auth.length>7) {
|
$scope.isSpread = false;
|
}
|
//$timeout(resize, 100);
|
}
|
|
function setStyle(style) {
|
|
if (!Utils.isBlank(style.background)) {
|
style.background = "url(./modules/core/images/" + style.background + ") no-repeat";
|
}
|
return style;
|
}
|
|
function includes(btn)
|
{
|
return $state.includes(btn.includes, btn.p);
|
}
|
|
}
|
})();
|