adminnavmanagerCtrl.1.js 4.1 KB

1
  1. "use strict";app.controller("adminNavmanagerListCtrl",["$rootScope","$scope","$state","$timeout","$interval","$modal","SweetAlert","Restangular","api_configure_data","api_conversation","api_user_data",function(e,t,a,n,r,o,i,s,c,d,u){function l(e,t){for(var a={},n=null,r=0;r<e.length;r++){var o=e[r];if(o.children=[],a[o.id]=o,"undefined"==typeof o.parent||null===o.parent)n=o,t[o.id]=n;else{var i=a[o.parent.id];i.children.push(o)}}return n}function m(e){var t={},a=[];return l(e,t),angular.forEach(t,function(e){a.push(e)}),a}t.showAddservice=!1,t.showAddmenu=!1,t.showchange=!1,t.showremove=!1,u.pageEvent({userId:e.user.id,menuCode:"app.system.navmanager"}).then(function(e){if(200==e.status){var a=e.data;angular.forEach(a,function(e){"service"==e.event?t.showAddservice=!0:"menu"==e.event?t.showAddmenu=!0:"change"==e.event?t.showchange=!0:"remove"==e.event&&(t.showremove=!0)})}else i.swal({title:"系统权限错误!",text:"请刷新重试!",type:"error"})}),t.bodyHeight=Math.max(window.innerHeight-290,500);t.my_tree={},t.my_power={},t.try_async_powerload=function(e){t.getbranchs=e,t.my_power=[];c.fetchDataList("menu",{idx:0,sum:1e3}).then(function(a){if(200==a.status){for(var n=a.list,r=[],o=0;o<n.length;o++){var s={};s.id=n[o].id,n[o].parent&&0!=n[o].parent.id&&(s.parent=n[o].parent.id),angular.extend(s,n[o]),s.label=s.title,r.push(s)}angular.forEach(r,function(t,a){angular.forEach(e,function(e){t.id==e.id&&(r[a].checks=!0)})}),t.my_power=m(r),t.tree_power=angular.copy(t.my_power),t.tree_power.length>0&&(t.doing_asyncpower=!1)}else i.swal({title:"系统错误!",text:"请刷新重试!",type:"error"})})},t.try_async_powerload(),t.addData=function(){a.go("app.system.form",{formKey:"system_add_menu",service:"api_configure_data"})},t.addService=function(){a.go("app.system.form",{formKey:"system_add_service",service:"api_configure_data"})},t.choiceMenu=[],t.showHandler=function(e){t.choiceMenu=e},t.changeMenu=function(){t.choiceMenu.service?c.fetchDataById("linkConfigure",t.choiceMenu.service).then(function(e){if(200==e.status){e.data.menu={menu:e.data.menu};var t={model:e.data};a.go("app.system.form",{formKey:"system_add_service",service:"api_configure_data",model:JSON.stringify(t)})}}):c.fetchDataById("menu",t.choiceMenu.id).then(function(e){if(200==e.status)if(null!=e.data.link){e.data.type="link";var t={model:e.data};a.go("app.system.form",{formKey:"system_add_menu",service:"api_configure_data",model:JSON.stringify(t)});var t={model:e.data}}else if(e.data.service){e.data.menu={menu:e.data.menu};var t={model:e.data};a.go("app.system.form",{formKey:"system_add_service",service:"api_configure_data",model:JSON.stringify(t)})}else if(e.data.event){e.data.type="event",e.data.menu={parent:e.data.parent};var t={model:e.data};a.go("app.system.form",{formKey:"system_add_menu",service:"api_configure_data",model:JSON.stringify(t)})}else if(e.data.wechat){e.data.type="wechat",e.data.menu={parent:e.data.parent};var t={model:e.data};a.go("app.system.form",{formKey:"system_add_menu",service:"api_configure_data",model:JSON.stringify(t)})}})},t.removeData=function(){var e=o.open({templateUrl:"assets/views/delete.html",controller:["$scope","scope","$modalInstance",function(e,t,a){e.ok=function(){t.choiceMenu.children&&t.choiceMenu.children.length>0?i.swal({title:"操作异常!",text:"请先删除菜单子类",type:"error"}):a.close(t.choiceMenu)},e.cancel=function(){a.dismiss("cancel")}}],size:"sm",resolve:{scope:function(){return t}}});e.result.then(function(e){if(e){var a=[],n=[];e.service&&null!=e.service?a.push(e.service):n.push(e.id),n.length>0&&c.rmvData("menu",n).then(function(e){e.data?i.swal({title:"删除成功!",type:"success",confirmButtonColor:"#007AFF"},function(){t.try_async_powerload()}):a.length>0||i.swal({title:"操作异常!",text:"系统异常,请稍后重试,或者联系管理员!",type:"error"})}),a.length>0&&c.rmvData("linkConfigure",a).then(function(e){e.data?i.swal({title:"删除成功!",type:"success",confirmButtonColor:"#007AFF"},function(){t.try_async_powerload(),t.getbranchs=[]}):a.length>0||i.swal({title:"操作异常!",text:"系统异常,请稍后重试,或者联系管理员!",type:"error"})})}})}}]);