1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105 |
- app.controller('powerCtrl', ["$rootScope", "$scope", "$state", "$timeout", "$interval", "SweetAlert", "$modal", "Restangular", "api_user_data", "api_configure_data", "api_conversation", function($rootScope, $scope, $state, $timeout, $interval, SweetAlert, $modal, Restangular, api_user_data, api_configure_data, api_conversation) {
- var loginUser = $rootScope.user;
- $scope.xinzeng=false;
- $scope.shanchu=false;
- $scope.bianji=false;
- $scope.fenpeiquanxian=false;
- // $scope.role={};
- // $scope.role.flag=1;
- for(var i=0;i<loginUser.menu.length;i++){
- if(loginUser.menu[i].link=="quanxianguanli_xinzeng"){
- $scope.xinzeng=true
- }
- if(loginUser.menu[i].link=="quanxianguanli_shanchu"){
- $scope.shanchu=true
- }
- if(loginUser.menu[i].link=="quanxianguanli_bianji"){
- $scope.bianji=true
- }
- if(loginUser.menu[i].link=="quanxianguanli_fenpeiquanxian"){
- $scope.fenpeiquanxian=true
- }
- }
- //user tree
- var apple_selected, tree, treedata_avm, treedata_geography;
- var i = 0;
- $scope.bodyHeight = Math.max((window.innerHeight - 290), 500);
- $(window).resize(function() {
- $scope.bodyHeight = Math.max((window.innerHeight - 290), 500);
- });
- $rootScope.isMask = false;
- //角色仪表权限
- function dashboardaborad(branch) {
- $scope.dashboard_tree = angular.copy($scope.dashboard_data);
- angular.forEach($scope.dashboard_tree, function(index, i) {
- if (branch.dashboard && branch.dashboard.length > 0) {
- angular.forEach(branch.dashboard, function(item) {
- if (index.id == item.id) {
- $scope.dashboard_tree[i].checks = true;
- }
- })
- }
- })
- }
- // 责任部门
- $scope.hospitalAndDutyDept = {};
- $scope.dutyDeptList = [];
- $scope.branchObj = {};
- $scope.getDutyDeptList = function(roleObj) {
- api_user_data.fetchDataList('branch', { "idx": 0, "sum": 1000 }).then(function(res) {
- if (res.status == 200) {
- api_user_data.fetchDataList('dutyDepartment', { "idx": 0, "sum": 1000 }).then(function(response) {
- if (response.status == 200) {
- // 院区数据处理
- $scope.branchObj = angular.copy(res.list).find(v=>v.children.length>0);
- $scope.branchObj.children.sort((a,b)=>a.id-b.id);
- // 清空
- response.list.forEach(v=>{
- v.flag = false
- });
- $scope.dutyDeptList = response.list;
- $scope.branchObj.flag = false;
- $scope.branchObj.children.forEach(v=>{
- v.flag = false;
- })
- // 回显数据
- if(roleObj){
- roleObj.dutyDepts.forEach(v=>{
- $scope.dutyDeptList.forEach(vv=>{
- if(v.id == vv.id){
- vv.flag = true;
- }
- })
- })
- roleObj.branchs.forEach(v=>{
- if(v.id == $scope.branchObj.id){
- $scope.branchObj.flag = true;
- }
- $scope.branchObj.children.forEach(vv=>{
- if(v.id == vv.id){
- vv.flag = true;
- }
- })
- })
- }
- // 处理责任科室数据
- $scope.hospitalAndDutyDept = {};
- $scope.dutyDeptList.forEach(v=>{
- if($scope.hospitalAndDutyDept[v.branch]){
- $scope.hospitalAndDutyDept[v.branch].push(v);
- }else{
- $scope.hospitalAndDutyDept[v.branch] = [v];
- }
- })
- console.log($scope.branchObj,$scope.hospitalAndDutyDept)
- } else {
- SweetAlert.swal({
- title: "系统错误!",
- text: "请刷新重试!",
- type: "error"
- });
- }
- });
- } else {
- SweetAlert.swal({
- title: "系统错误!",
- text: "请刷新重试!",
- type: "error"
- });
- }
- });
- };
- //角色树
- $scope.my_tree = {};
- $scope.my_power = {};
- $scope.try_async_load = function() {
- $scope.my_data = [];
- $scope.doing_async = true;
- api_user_data.fetchDataList('role', { "idx": 0, "sum": 1000 }).then(function(response) {
- if (response.status == 200) {
- var data = response.list;
- var objects = [];
- for (var i = 0; i < data.length; i++) {
- var object = {};
- object.id = data[i].id;
- if (data[i].parent && data[i].parent.id != 0) {
- object.parent = data[i].parent.id;
- }
- angular.extend(object, data[i]);
- object.label = object.role;
- if (loginUser.id == 1) {
- objects.push(object);
- } else {
- if (object.rolecode != "system_menus") {
- objects.push(object);
- }
- }
- }
- $scope.my_data = convertParentToChildList(objects);
- $scope.tree_data = angular.copy($scope.my_data);
- if ($scope.my_data.length > 0) {
- $scope.doing_async = false;
- }
- } else {
- SweetAlert.swal({
- title: "系统错误!",
- text: "请刷新重试!",
- type: "error"
- });
- }
- });
- };
- function convertListToTree(data, treeMap) {
- var idToNodeMap = {}; //Keeps track of nodes using id as key, for fast lookup
- var root = null; //Initially set our loop to null
- //loop over data
- for (var i = 0; i < data.length; i++) {
- var datum = data[i];
- //each node will have children, so let's give it a "children" poperty
- datum.children = [];
- //add an entry for this node to the map so that any future children can
- //lookup the parent
- idToNodeMap[datum.id] = datum;
- //Does this node have a parent?
- // console.log("datum="+JSON.stringify(datum))
- if (typeof datum.parent === "undefined" || datum.parent === null) {
- //Doesn't look like it, so this node is the root of the tree
- root = datum;
- treeMap[datum.id] = root;
- } else {
- //This node has a parent, so let's look it up using the id
- parentNode = idToNodeMap[datum.parent.id];
- //We don't need this property, so let's delete it.
- // delete datum.parent;
- //Let's add the current node as a child of the parent node.
- parentNode.children.push(datum);
- }
- }
- return root;
- }
- function convertParentToChildList(data) {
- var treeMap = {};
- var list = [];
- convertListToTree(data, treeMap);
- angular.forEach(treeMap, function(item) {
- list.push(item);
- });
- return list;
- }
- $scope.try_async_load();
- $scope.getDutyDeptList();
- //end power
- //普通用户菜单权限
- $scope.try_async_powerload = function(items) {
- if (items) {
- $scope.getbranchs = items.menu;
- }
- // $scope.my_power = [];
- var objects = [];
- var selected = [];
- api_user_data.roleMenu(items.id).then(function(response) {
- console.log(response);
- // api_configure_data.fetchDataList('menu', { "idx": 0, "sum": 1000 }).then(function(response) {
- if (response.status == 200) {
- // //旧的树
- // var data = response.data;
- // var objects = [];
- // for (var i = 0; i < data.length; i++) {
- // var object = {};
- // object.id = data[i].id;
- // if (data[i].parent && data[i].parent.id != 0) {
- // object.parent = data[i].parent.id;
- // }
- // angular.extend(object, data[i]);
- // object.label = object.title;
- // objects.push(object);
- // }
- // selected = angular.copy($scope.tile);
- // $scope.my_power = angular.copy($scope.tree_power);
- // if (data.length > 0) {
- // angular.forEach(selected, function(index, i) {
- // angular.forEach(objects, function(item) {
- // if (index.id == item.id) {
- // selected[i].checks = true;
- // }
- // })
- // })
- // $scope.my_power = convertParentToChildList(selected);
- // } else {
- // $scope.my_power = convertParentToChildList($scope.tile);
- // }
- // if ($scope.my_power.length > 0) {
- // $scope.doing_asyncpower = false;
- // }
- // 新的树
- $scope.allPower_select=[];
- var data=response.data;
- for(var i=0;i<$scope.allPower.length;i++){
- $scope.allPower[i].biaoshi=false
- }
- $scope.allPower_select=$scope.allPower;
- for(var i=0;i<$scope.allPower_select.length;i++){
- for(var j=0;j<data.length;j++){
- if($scope.allPower_select[i].id==data[j].id){
- $scope.allPower_select[i].biaoshi=true
- }
- }
- }
- var objects = [];
- for (var i = 0; i < $scope.allPower_select.length; i++) {
- var object = {};
- object.id = $scope.allPower_select[i].id;
- if ($scope.allPower_select[i].parent && $scope.allPower_select[i].parent.id != 0) {
- object.parent = $scope.allPower_select[i].parent.id;
- }
- angular.extend(object, $scope.allPower_select[i]);
- object.label = object.title;
- objects.push(object);
- }
- $scope.tile = objects;
- $scope.my_power = convertParentToChildList(objects);
- $scope.tree_power = angular.copy($scope.my_power);
- if ($scope.my_data.length > 0) {
- $scope.doing_asyncpower = false;
- }
- } else {
- SweetAlert.swal({
- title: "系统错误!",
- text: "请刷新重试!",
- type: "error"
- });
- }
- });
- };
- $scope.dianjiceshi=function(){
- console.log($scope.my_power);
- console.log($scope.allPower_select);
- }
- //普通用户底菜单权限
- $scope.allPower=[];
- $scope.my_power = [];
- $scope.tile = [];
- $scope.try_async_powerloadlow = function() {
- var objects = [];
- api_user_data.pageMenuByCode("system_menus").then(function(response) {
- if (response.status == 200) {
- var data = response.data;
- $scope.allPower= response.data;
- var objects = [];
- for (var i = 0; i < data.length; i++) {
- data[i]["biaoshi"]=false;
- var object = {};
- object.id = data[i].id;
- if (data[i].parent && data[i].parent.id != 0) {
- object.parent = data[i].parent.id;
- }
- angular.extend(object, data[i]);
- object.label = object.title;
- objects.push(object);
- }
- $scope.tile = objects;
- $scope.my_power = convertParentToChildList(objects);
- $scope.tree_power = angular.copy($scope.my_power);
- if ($scope.my_data.length > 0) {
- $scope.doing_asyncpower = false;
- }
- console.log($scope.my_power)
- } else {
- SweetAlert.swal({
- title: "系统错误!",
- text: "请刷新重试!",
- type: "error"
- });
- }
- });
- };
- // $scope.jry_AllPower=[];
- // $scope.getJry_AllPower=function(){
- // api_user_data.pageMenuByCode("system_menus").then(function(res) {
- // console.log(res.data);
- // $scope.jry_AllPower=res.data
- // })
- // }
- // $scope.getJry_AllPower()
- //管理员 底菜单
- $scope.try_async_powerloadadmin = function() {
- var objects = [];
- // api_conversation.pageMenuByCode("system_menus").then(function(response) {
- api_user_data.getMenu({}).then(function(response) {
- if (response.status == 200) {
- var data = response.data;
- var objects = [];
- for (var i = 0; i < data.length; i++) {
- var object = {};
- object.id = data[i].id;
- if (data[i].parent && data[i].parent.id != 0) {
- object.parent = data[i].parent.id;
- }
- angular.extend(object, data[i]);
- object.label = object.title;
- objects.push(object);
- }
- $scope.tile = objects;
- $scope.my_power = convertParentToChildList(objects);
- $scope.tree_power = angular.copy($scope.my_power);
- if ($scope.tree_power.length > 0) {
- $scope.doing_asyncpower = false;
- }
- } else {
- SweetAlert.swal({
- title: "系统错误!",
- text: "请刷新重试!",
- type: "error"
- });
- }
- });
- };
- //点击角色
- $scope.role = {};
- // $scope.role.flag=1;
- $scope.chaoguan=true;//超级管理员禁止修改判断
- $scope.flagSwitch=true;
- $scope.change = true;
- $scope.my_tree_handler = function(branch) {
- console.log(branch);
- if(branch.flag==0){
- $scope.flagSwitch=true
- }else{
- $scope.flagSwitch=false
- }
- if(branch.label=="超级管理员"){
- $scope.chaoguan=false
- }else{
- $scope.chaoguan=true
- }
- $scope.role = branch;
- for (var i = 0; i < $scope.roledetail.length; i++) {
- if ($scope.role.model == $scope.roledetail[i].name) {
- $scope.role.model = { 'id': $scope.roledetail[i].id, 'name': $scope.roledetail[i].name }
- }
- }
- $scope.formlist = branch.dashboard;
- dashboardaborad($scope.role);
- $scope.try_async_powerload(branch);
- $scope.compareDutydept(branch);
- $scope.change = false;
- }
- $scope.compareDutydept = function(roleObj){
- // $scope.dutyDeptList.forEach(v=>{
- // v.flag = false;
- // })
- // dutyDepts.forEach(v=>{
- // $scope.dutyDeptList.forEach(vv=>{
- // if(v.id == vv.id){
- // vv.flag = true;
- // }
- // })
- // })
- $scope.getDutyDeptList(roleObj);
- }
- // if (loginUser.id == 1) {
- // $scope.try_async_powerloadadmin();
- // } else {
- $scope.try_async_powerloadlow();
- // }
- // $scope.try_async_powerloadadmin();
- // console.log(loginUser);
- //start remove
- $scope.getbranchs = {};
- $scope.formbranch = function(branchData) {
- $scope.getbranchs = branchData;
- }
- //change right
- $scope.selectAllBiaoshi=true;
- // 全选/反选
- $scope.allSelect=function(){
- if($scope.selectAllBiaoshi){
- for(var i=0;i<$scope.my_power.length;i++){
- $scope.my_power[i].biaoshi=true;
- if($scope.my_power[i].children){
- for(var j=0;j<$scope.my_power[i].children.length;j++){
- $scope.my_power[i].children[j].biaoshi=true
- if($scope.my_power[i].children[j].children){
- for(var k=0;k<$scope.my_power[i].children[j].children.length;k++){
- $scope.my_power[i].children[j].children[k].biaoshi=true
- if($scope.my_power[i].children[j].children[k].children){
- for(var l=0;l<$scope.my_power[i].children[j].children[k].children.length;l++){
- $scope.my_power[i].children[j].children[k].children[l].biaoshi=true
- }
- }
- }
- }
- }
- }
- }
- $scope.selectAllBiaoshi=false;
- }else{
- for(var i=0;i<$scope.my_power.length;i++){
- $scope.my_power[i].biaoshi=false;
- if($scope.my_power[i].children){
- for(var j=0;j<$scope.my_power[i].children.length;j++){
- $scope.my_power[i].children[j].biaoshi=false
- if($scope.my_power[i].children[j].children){
- for(var k=0;k<$scope.my_power[i].children[j].children.length;k++){
- $scope.my_power[i].children[j].children[k].biaoshi=false
- if($scope.my_power[i].children[j].children[k].children){
- for(var l=0;l<$scope.my_power[i].children[j].children[k].children.length;l++){
- $scope.my_power[i].children[j].children[k].children[l].biaoshi=false
- }
- }
- }
- }
- }
- }
- }
- $scope.selectAllBiaoshi=true;
- }
- }
- // 点击选项
- $scope.changeCheckBox1=function(data){
- console.log($scope.my_power);
- for(var i=0;i<$scope.my_power.length;i++){
- if(data.id === $scope.my_power[i].id){
- if(!$scope.my_power[i].biaoshi){
- if($scope.my_power[i].children){
- for(var j=0;j<$scope.my_power[i].children.length;j++){
- $scope.my_power[i].children[j].biaoshi=false
- if($scope.my_power[i].children[j].children){
- for(var k=0;k<$scope.my_power[i].children[j].children.length;k++){
- $scope.my_power[i].children[j].children[k].biaoshi=false
- if($scope.my_power[i].children[j].children[k].children){
- for(var l=0;l<$scope.my_power[i].children[j].children[k].children.length;l++){
- $scope.my_power[i].children[j].children[k].children[l].biaoshi=false
- }
- }
- }
- }
- }
- }
- }else{
- if($scope.my_power[i].children){
- for(var j=0;j<$scope.my_power[i].children.length;j++){
- $scope.my_power[i].children[j].biaoshi=true
- if($scope.my_power[i].children[j].children){
- for(var k=0;k<$scope.my_power[i].children[j].children.length;k++){
- $scope.my_power[i].children[j].children[k].biaoshi=true
- if($scope.my_power[i].children[j].children[k].children){
- for(var l=0;l<$scope.my_power[i].children[j].children[k].children.length;l++){
- $scope.my_power[i].children[j].children[k].children[l].biaoshi=true
- }
- }
- }
- }
- }
- }
- }
- }
- }
- }
- $scope.changeCheckBox2=function(){
- for(var i=0;i<$scope.my_power.length;i++){
- if($scope.my_power[i].children){
- for(var j=0;j<$scope.my_power[i].children.length;j++){
- if(!$scope.my_power[i].children[j].biaoshi){
- if($scope.my_power[i].children[j].children){
- for(var k=0;k<$scope.my_power[i].children[j].children.length;k++){
- $scope.my_power[i].children[j].children[k].biaoshi=false
- if($scope.my_power[i].children[j].children[k].children){
- for(var l=0;l<$scope.my_power[i].children[j].children[k].children.length;l++){
- $scope.my_power[i].children[j].children[k].children[l].biaoshi=false
- }
- }
- }
- }
- }else{
- $scope.my_power[i].biaoshi=true
- }
- }
- }
- }
- }
- $scope.changeCheckBox3=function(){
- for(var i=0;i<$scope.my_power.length;i++){
- if($scope.my_power[i].children){
- for(var j=0;j<$scope.my_power[i].children.length;j++){
- if($scope.my_power[i].children[j].children){
- for(var k=0;k<$scope.my_power[i].children[j].children.length;k++){
- if(!$scope.my_power[i].children[j].children[k].biaoshi){
- for(var l=0;l<$scope.my_power[i].children[j].children[k].children.length;l++){
- $scope.my_power[i].children[j].children[k].children[l].biaoshi=false
- }
- }else{
- $scope.my_power[i].biaoshi=true;
- $scope.my_power[i].children[j].biaoshi=true;
- }
- }
- }
- }
- }
- }
- }
- $scope.changeCheckBox4=function(){
- for(var i=0;i<$scope.my_power.length;i++){
- if($scope.my_power[i].children){
- for(var j=0;j<$scope.my_power[i].children.length;j++){
- if($scope.my_power[i].children[j].children){
- for(var k=0;k<$scope.my_power[i].children[j].children.length;k++){
- if($scope.my_power[i].children[j].children[k].children){
- for(var l=0;l<$scope.my_power[i].children[j].children[k].children.length;l++){
- if($scope.my_power[i].children[j].children[k].children[l].biaoshi){
- $scope.my_power[i].biaoshi=true;
- $scope.my_power[i].children[j].biaoshi=true;
- $scope.my_power[i].children[j].children[k].biaoshi=true;
- }
- }
- }
- }
- }
- }
- }
- }
- }
- //修改权限
- $scope.changeData = function() {
- if($scope.role.id){
- var menu = [];
- $rootScope.isMask = true;
- // 旧的树
- // angular.forEach($scope.getbranchs, function(it) {
- // menu.push({ "id": it.id });
- // })
- // 新的树
- for(var i=0;i<$scope.my_power.length;i++){
- if($scope.my_power[i].biaoshi){
- menu.push({ "id": $scope.my_power[i].id });
- }
- if($scope.my_power[i].children){
- for(var j=0;j<$scope.my_power[i].children.length;j++){
- if($scope.my_power[i].children[j].biaoshi){
- menu.push({ "id": $scope.my_power[i].children[j].id });
- }
- if($scope.my_power[i].children[j].children){
- for(var k=0;k<$scope.my_power[i].children[j].children.length;k++){
- if($scope.my_power[i].children[j].children[k].biaoshi){
- menu.push({ "id": $scope.my_power[i].children[j].children[k].id });
- }
- if($scope.my_power[i].children[j].children[k].children){
- for(var l=0;l<$scope.my_power[i].children[j].children[k].children.length;l++){
- if($scope.my_power[i].children[j].children[k].children[l].biaoshi){
- menu.push({ "id": $scope.my_power[i].children[j].children[k].children[l].id });
- }
- }
- }
- }
- }
- }
- }
- }
- var branch = { 'menu': menu };
- // 院区和责任科室
- var dutyDepts = $scope.dutyDeptList.filter(v=>v.flag).map(v=>({id:v.id}));
- var branchs = [];
- if($scope.branchObj.flag){
- branchs.push($scope.branchObj);
- }
- var branchs_lin = $scope.branchObj.children.filter(v=>v.flag);
- branchs = branchs.concat(branchs_lin);
- angular.extend(branch, { 'id': $scope.role.id, dutyDepts:dutyDepts,branchs:branchs, 'role': $scope.role.role,'flag':$scope.role.flag, 'rolecode': $scope.role.rolecode, 'roletype': $scope.role.roletype,'remark': $scope.role.remark })
- // var modelData = {role: branch};
- api_user_data.addData('role', { 'role': branch }).then(function(response) {
- if (response && response.status == 200) {
- $scope.role={};
- SweetAlert.swal({
- title: "提交成功!",
- type: "success",
- confirmButtonColor: "#007AFF"
- }, function() {
- $rootScope.isMask = false;
- $scope.try_async_load();
- $scope.getDutyDeptList();
- });
- } else {
- SweetAlert.swal({
- title: "系统错误",
- text: "系统错误,请稍后重试!",
- type: "error",
- confirmButtonColor: "#DD6B55"
- }, function() {
- $rootScope.isMask = false;
- });
- }
- })
- }else{
- SweetAlert.swal({
- title: "操作失败",
- text: "请选择需要修改的角色!",
- type: "error",
- })
- }
-
- // $state.go('app.system.form',{formKey:'system_add_menu', service:'api_configure_data', model : JSON.stringify(modelData)});
- }
- //新增角色
- // $scope.addData = function() {
- // $state.go('app.system.form', { formKey: 'system_add_menu', service: 'api_configure_data' });
- // }
- //change menu
- // $scope.choiceMenu = [];
- // $scope.showHandler = function(branch) {
- // $scope.choiceMenu = branch;
- // }
- // $scope.changeMenu = function() {
- // // if ($scope.choiceMenu && $scope.choiceMenu != null) {
- // // }
- // api_configure_data.fetchDataById('menu', $scope.choiceMenu.id).then(function(response) {
- // if (response.status == 200) {
- // if (response.data.link != null) {
- // response.data.type = "link";
- // } else if (response.data.service) {
- // response.data.type = "service";
- // } else if (response.data.event) {
- // response.data.type = "event";
- // }
- // response.data['menu'] = { parent: response.data.parent };
- // var modelData = { model: response.data }
- // $state.go('app.system.form', { formKey: 'system_add_menu', service: 'api_configure_data', model: JSON.stringify(modelData) });
- // }
- // })
- // }
- //remove menu
- $scope.removeData = function() {
- var modalInstance = $modal.open({
- templateUrl: 'assets/views/delete.html',
- controller: function($scope, scope, $modalInstance) {
- $scope.rmvList = [];
- angular.forEach(scope.getbranchs, function(item) {
- $scope.rmvList.push(item.id);
- })
- $scope.ok = function() {
- $modalInstance.close($scope.rmvList);
- };
- $scope.cancel = function() {
- $modalInstance.dismiss('cancel');
- };
- },
- size: 'sm',
- resolve: {
- scope: function() {
- return $scope;
- }
- }
- });
- modalInstance.result.then(function(selectedItem) {
- if (selectedItem) {
- if (selectedItem.length > 0) {
- api_configure_data.rmvData('menu', selectedItem).then(function(response) {
- if (response.data) {
- SweetAlert.swal({
- title: "删除成功!",
- type: "success",
- confirmButtonColor: "#007AFF"
- }, function() {
- if (loginUser.id == 1) {
- $scope.try_async_powerloadadmin();
- } else {
- $scope.try_async_powerload();
- }
- });
- } else {
- SweetAlert.swal({
- title: "操作异常!",
- text: "系统异常,请稍后重试,或者联系管理员!",
- type: "error"
- });
- }
- })
- }
- }
- })
- }
- //add role
- $scope.addRole = function() {
- var modalInstance = $modal.open({
- templateUrl: 'assets/views/system/tpl/addpower.html',
- controller: function($scope, scope, $modalInstance, api_user_data) {
- $scope.role={
- "role":"",
- "remark":"",
- "flag":0
- }
- $scope.addSwitch=true;
- $scope.addSwitchChange=function(data){
- console.log(data);
- if(data==true){
- $scope.role.flag=0
- }else{
- $scope.role.flag=1
- }
- }
- $scope.roledetail = [{ 'id': 1, 'name': '事件流程' }, { 'id': 2, 'name': '问题流程' }, { 'id': 3, 'name': '变更流程' }, { 'id': 4, 'name': '发布流程' }, { 'id': 5, 'name': '知识库模块' }, { 'id': 6, 'name': '资产模块' }, { 'id': 7, 'name': '系统管理模块' }]
- $scope.cancel = function() {
- $modalInstance.dismiss('cancel');
- };
- $scope.ok = function(role) {
- if(role.role&&role.remark){
- if (role.role) {
- var roledisable = false;
- for (var i = 0; i < scope.my_data.length; i++) {
- if (scope.my_data[i].role == role.role) {
- roledisable = true;
- break;
- }
- }
- if (!roledisable) {
- angular.extend(role, { 'roletype': '0' });
- if (role.model) {
- role.model = role.model.name;
- }
- var fildata = { loginUser: loginUser, role };
- $modalInstance.close(fildata);
- } else {
- SweetAlert.swal({
- title: "新增失败!",
- text: "该角色已存在",
- type: "error"
- })
- }
- } else {
- SweetAlert.swal({
- title: "新增失败!",
- text: "请填写角色名",
- type: "error"
- })
- }
- }else{
- SweetAlert.swal({
- title: "新增失败!",
- text: "请填写必填项",
- type: "error"
- })
- }
- }
- },
- resolve: {
- scope: function() {
- return $scope;
- }
- }
- });
- modalInstance.result.then(function(selectedItem) {
- if (selectedItem) {
- api_user_data.addData('role', selectedItem).then(function(response) {
- if (response) {
- if (response.status == 200) {
- SweetAlert.swal({
- title: "新增成功!",
- type: "success"
- }, function() {
- $scope.try_async_load();
- $scope.getDutyDeptList();
- })
- } else {
- SweetAlert.swal({
- title: "新增失败!",
- type: "error"
- })
- }
- // $modalInstance.close();
- }
- })
- }
- })
- }
- // $scope.addRole = function(role) {
- // // $scope.roledetail = [{ 'id': 1, 'name': '事件流程' }, { 'id': 2, 'name': '问题流程' }, { 'id': 3, 'name': '变更流程' }]
- // angular.extend(role, { 'roletype': '0' });
- // if (role.model) {
- // role.model = role.model.name;
- // }
- // var fildata = { loginUser: loginUser, role };
- // // var fildata = { loginUser: loginUser, 'role': { 'id': $scope.role.id, 'role': $scope.role.role, 'roletype': $scope.role.roletype, 'model': model, 'remark': $scope.role.remark } };
- // api_user_data.addData('role', fildata).then(function(response) {
- // if (response) {
- // if (response.status == 200) {
- // SweetAlert.swal({
- // title: "新增成功!",
- // type: "success"
- // }, function() {
- // $scope.try_async_load();
- // // $scope.refreshData('expand-right', defaultFilterData);
- // })
- // } else {
- // SweetAlert.swal({
- // title: "新增失败!",
- // type: "error"
- // })
- // }
- // // $modalInstance.close();
- // }
- // })
- // }
- //角色详情
- $scope.roledetail = [{ 'id': 1, 'name': '事件流程' }, { 'id': 2, 'name': '问题流程' }, { 'id': 3, 'name': '变更流程' }]
- //change role
- $scope.changeIfEnableEdit=function(data){
- console.log(data);
- if(data){
- $scope.role.flag=0;
- $scope.flagSwitch=true
- }else{
- $scope.role.flag=1;
- $scope.flagSwitch=false
- }
- }
- $scope.changerole = function(role) {
- if($scope.role.id){
- if($scope.role.role&&$scope.role.remark){
- var model = "";
- if ($scope.role.model) {
- model = $scope.role.model.name
- }
- var dutyDepts = $scope.dutyDeptList.filter(v=>v.flag).map(v=>({id:v.id}));
- var branchs = [];
- if($scope.branchObj.flag){
- branchs.push($scope.branchObj);
- }
- var branchs_lin = $scope.branchObj.children.filter(v=>v.flag);
- branchs = branchs.concat(branchs_lin);
- var fildata = { loginUser: loginUser, 'role': { 'id': $scope.role.id,dutyDepts:dutyDepts,branchs:branchs,'menu':$scope.role.menu,'flag':$scope.role.flag, 'role': $scope.role.role, 'roletype': $scope.role.roletype, 'model': model, 'remark': $scope.role.remark } };
- api_user_data.addData('role', fildata).then(function(response) {
- if (response) {
- if (response.status == 200) {
- $scope.role={};
- SweetAlert.swal({
- title: "修改成功!",
- type: "success"
- }, function() {
- $scope.try_async_load();
- $scope.getDutyDeptList();
- // $scope.refreshData('expand-right', defaultFilterData);
- })
- } else {
- SweetAlert.swal({
- title: "修改失败!",
- type: "error"
- })
- }
- // $modalInstance.close();
- }
- })
- }else{
- SweetAlert.swal({
- title: "修改失败!",
- text:"请填写必填项",
- type: "error"
- })
- }
- }else{
- SweetAlert.swal({
- title: "操作失败!",
- text:"请选择需要修改的角色",
- type: "error"
- })
- }
-
- }
- // })
- // }
- //change role
- $scope.changeRole = function() {
- var modalInstance = $modal.open({
- templateUrl: 'assets/views/system/tpl/addpower.html',
- controller: function($scope, scope, $modalInstance, api_user_data) {
- $scope.role = scope.role;
- $scope.cancel = function() {
- $modalInstance.dismiss('cancel');
- };
- $scope.ok = function(item) {
- var fildata = { loginUser: loginUser, 'role': { 'id': item.id, 'role': item.role, 'roletype': item.roletype } };
- $modalInstance.close(fildata);
- }
- },
- resolve: {
- scope: function() {
- return $scope;
- }
- }
- });
- modalInstance.result.then(function(selectedItem) {
- if (selectedItem) {
- api_user_data.addData('role', selectedItem).then(function(response) {
- if (response) {
- if (response.status == 200) {
- SweetAlert.swal({
- title: "修改成功!",
- type: "success"
- }, function() {
- $scope.try_async_load();
- $scope.getDutyDeptList();
- // $scope.refreshData('expand-right', defaultFilterData);
- })
- } else {
- SweetAlert.swal({
- title: "修改失败!",
- type: "error"
- })
- }
- // $modalInstance.close();
- }
- })
- }
- })
- }
- //remove role
- $scope.removeRole = function() {
- if ($scope.role && $scope.role.roletype == 0) {
- var modalInstance = $modal.open({
- templateUrl: 'assets/views/delete.html',
- controller: function($scope, scope, $modalInstance) {
- var rmvList = [];
- // angular.forEach(scope.getbranchs, function(item) {
- // $scope.rmvList.push(item.id);
- // })
- rmvList.push(scope.role.id);
- $scope.ok = function() {
- $modalInstance.close(rmvList);
- };
- $scope.cancel = function() {
- $modalInstance.dismiss('cancel');
- };
- $scope.title = '角色删除';
- $scope.connect = '是否删除该角色'
- },
- size: 'sm',
- resolve: {
- scope: function() {
- return $scope;
- }
- }
- });
- modalInstance.result.then(function(selectedItem) {
- if (selectedItem) {
- if (selectedItem.length > 0) {
- api_user_data.rmvData('role', selectedItem).then(function(response) {
- if (response.data) {
- $scope.role={};
- SweetAlert.swal({
- title: "删除成功!",
- type: "success",
- confirmButtonColor: "#007AFF"
- }, function() {
- $scope.try_async_load();
- $scope.getDutyDeptList();
- });
- } else {
- SweetAlert.swal({
- title: "操作异常!",
- text: "系统异常,请稍后重试,或者联系管理员!",
- type: "error"
- });
- }
- })
- }
- }
- })
- } else {
- SweetAlert.swal({
- title: "操作错误!",
- text: "该角色不能删除!",
- type: "error"
- });
- }
- }
- //仪表盘
- //查看仪表盘权限
- $scope.doing_asyncdash = true;
- $scope.dashboard_tree = [];
- // $scope.try_async_dashboard = function() {
- // api_user_data.fetchDataList("dashboard", { "idx": 0, "sum": 1000 }).then(function(response) {
- // if (response.status == 200) {
- // var data = response.list;
- // var objects = [];
- // for (var i = 0; i < data.length; i++) {
- // var object = {};
- // object.id = data[i].id;
- // object.label = data[i].name;
- // objects.push(object);
- // }
- // $scope.dashboard_tree = objects;
- // $scope.dashboard_data = angular.copy($scope.dashboard_tree);
- // if ($scope.dashboard_data.length > 0) {
- // $scope.doing_asyncdash = false;
- // }
- // } else {
- // SweetAlert.swal({
- // title: "系统错误!",
- // text: "请刷新重试!",
- // type: "error"
- // });
- // }
- // });
- // }
- // $scope.try_async_dashboard();
- $scope.formlist = {};
- $scope.formdashboard = function(branchData) {
- // $scope.formlist = {};
- $scope.formlist = branchData;
- }
- //修改仪表盘权限
- // var dashboard = [];
- $scope.changeDashboard = function() {
- var firldata = {};
- var dashboard = [];
- $rootScope.isMask = true;
- angular.forEach($scope.formlist, function(item) {
- dashboard.push({ 'id': item.id, 'name': item.label });
- })
- firldata = { 'dashboard': dashboard, 'id': $scope.role.id, 'role': $scope.role.role, 'rolecode': $scope.role.rolecode, 'roletype': $scope.role.roletype, 'menu': $scope.role.menu }
- api_user_data.addData('role', { 'role': firldata }).then(function(response) {
- if (response && response.status == 200) {
- $scope.getDutyDeptList();
- $scope.try_async_load();
- SweetAlert.swal({
- title: "提交成功!",
- type: "success",
- confirmButtonColor: "#007AFF"
- }, function() {
- $rootScope.isMask = false;
- // $scope.formlist = {}
- });
- } else {
- SweetAlert.swal({
- title: "系统错误",
- text: "系统错误,请稍后重试!",
- type: "error",
- confirmButtonColor: "#DD6B55"
- }, function() {
- $rootScope.isMask = false;
- });
- }
- })
- }
- }]);
|