addRoleCtrl.js 1.67 KB
(function(angular) {
	function addRoleCtrl($scope, $uibModalInstance,param, systemService, $uibModal, $filter, $state) {
        $scope.selectedList = [];
        $scope.condition = {};
        $scope.dtInstance = {};

        $scope.dtOption = {
            id: 'id',
            selectingList: {
                data: $scope.selectingList,
                columns: [{
                    prop: 'name',
                    title: '角色',
                    width: 120,
                    ellipsis: false
                }]
            },
            selectedList: {
                data: $scope.selectedList,
                columns: [{
                    prop: 'name',
                    title: '角色',
                    width: 120,
                    ellipsis: false
                }]
            }
        };

        systemService.getCreatedRoleList(function (res) {
            if (res.data) {
                $scope.selectingList = res.data;
                $scope.dtOption.selectingList.data = $scope.selectingList;
            }
        })

        if(param){
            for (var i in param) {
                $scope.selectedList.push(param[i]);
            }
        }

        $scope.query = function () {
            var and = {};
            $scope.dtInstance.search(and, {
                id: $scope.condition.name,
                name: $scope.condition.name
            });
        }

        $scope.ok = function () {
            $uibModalInstance.close($scope.dtInstance.getSelectedList());
        };
        $scope.cancel = function () {
            $uibModalInstance.dismiss('cancel');
        };
	}

	angular.module('system').controller('addRoleCtrl', addRoleCtrl)
})(angular);