123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127 |
- angular.module('push')
- .controller('selectResidentNodesCtrl', function ($scope,ResourceLibraryService,$timeout,UtilService,resourceLibraryModel,UserService) {
- //加载等待页
- $scope.isloadingPageFloor=false;
- //全部企业加载失败页
- $scope.isloadingPageFailAll=false;
- //我的企业加载失败页
- $scope.isloadingPageFail=false;
- $scope.userid=1;
- $scope.keyword='';
- $scope.nodeid='';
- $scope.allResidentNodesList=[];
- var getAllResidentNodesList = function () {
- $scope.isloadingPageFloor=true;
- ResourceLibraryService.getNodeList("").then(function (response) {
- // console.log(response);
- $scope.allResidentNodesList = response.data;
- $scope.nodeid=response.data.id;
- $scope.isloadingPageFloor=false;
- $scope.isloadingPageFail=false;
- $timeout(function () {
- //默认第一个展开
- })
- }, function () {
- $scope.isloadingPageFloor=false;
- $scope.isloadingPageFail=true;
- });
- };
- getAllResidentNodesList();
- //获取我的常驻节点名称
- var getNormalNodeList = function () {
- ResourceLibraryService.getNormalNodeList().then(function (response) {
- //console.log(response);
- // 节点列表
- $scope.normalNodes = response.data;
- }, function () {
- });
- };
- getNormalNodeList();
- // 将已选择的nodeid组合
- $scope.nodeidlist = [];
- $scope.selectedSectionLength=0;
- if(UtilService.isDefined($scope.nodeidlist) && $scope.nodeidlist.length > 0){
- angular.forEach($scope.nodeidlist, function (value, ind) {
- $scope.nodeidlist.push(value.id);
- $scope.selectedSectionLength += 1;
- });
- }
- // 记录选中节点列表索引
- var indexNodelist = [];
- // 转换用到的indexNodelist为impost需要的model
- $scope.postResidentModel=
- {
- //TODO
- userid:UserService.id,
- // userid:1,
- data:[]
- };
- // 选择节点(多选)
- $scope.selectNodelId = function (nodeId,index,isCheckedAble) {
- if(isCheckedAble==0){
- if ($scope.allResidentNodesList[index].isChecked) {
- var ind = indexNodelist.indexOf(index);
- indexNodelist.splice(ind,1);
- $scope.selectedSectionLength -= 1;
- } else {
- indexNodelist.push(nodeId);
- $scope.selectedSectionLength += 1;
- }
- $scope.allResidentNodesList[index].isChecked = !$scope.allResidentNodesList[index].isChecked;
- //console.log(indexNodelist);
- }else{
- return
- }
- };
- //重新加载
- $scope.repeatLoadAll = function () {
- $scope.isloadingPageFail=false;
- getAllResidentNodesList();
- };
- // 返回选择节点页面
- $scope.gotoSourcePage=function () {
- // 不刷新页面
- resourceLibraryModel.setFlag(false);
- $scope.goback();
- };
- //提交已选择的常驻节点
- var postCheckedNodes=function () {
- //传入indexNodelist,每循环一遍就push一次
- angular.forEach(indexNodelist,function (value,key) {
- $scope.postResidentModel.data.push({
- 'node':value
- })
- });
- //console.dir($scope.postResidentModel);
- $scope.nodeCheckedList=$scope.postResidentModel;
- ResourceLibraryService.postNodeList(angular.toJson($scope.nodeCheckedList)).then(function (response) {
- // console.log('成功了');
- }, function () {
- // console.log('失败了');
- });
- };
- // 返回已选中的成员
- $scope.returnCheckedNodeList=function (isPostNone) {
- var isPostNone=$scope.selectedSectionLength;
- if(isPostNone==0){
- $timeout(function () {
- $scope.goback();
- },300);
- }else{
- // 不刷新页面
- resourceLibraryModel.setFlag(false);
- //console.log(indexNodelist);
- postCheckedNodes();
- $timeout(function () {
- $scope.goback();
- },300);
- }
- };
- });
|