dialogSelect.js 1.62 KB
(function(angular) {
	function dialogSelectCtrl($scope, $uibModalInstance,config, $uibModal, $filter, $state) {
		$scope.defaultConfig = {
    		'title':"请选择", //标题
    		'searchPlaceholder':'输入搜索',//搜索框提示问题
    		'selectedList':{},      //默认选中数据
    		'selectList':[],	//可选择的列表
    		'selectColumns':{
    			'prop':null,
    			'tite':null,
    			'ellipsis':false
    		},	//条件
    		'searchProperties':['id','name']	//搜索框搜索的属性
    	}
		$scope.config = angular.extend($scope.defaultConfig,config);
        $scope.dtInstance = {};
        $scope.dtOption = {
            id: 'id',
            selectingList: {
                data: $scope.config.selectList,
                columns: [$scope.config.selectColumns]
            },
            selectedList: {
                data: $scope.config.selectedList,
                columns: [$scope.config.selectColumns]
            }
        };
        
        $scope.query = function () {
        	var condition = {};
        	if($scope.condition.searchKey){
        		for(var p in $scope.config.searchProperties){
            		condition[$scope.config.searchProperties[p]] =  $scope.condition.searchKey;
            	}
        	}
            $scope.dtInstance.search($scope.config.andCondition, condition);
        }
        
        $scope.ok = function () {
            $uibModalInstance.close($scope.dtInstance.getSelectedList());
        };
        $scope.cancel = function () {
            $uibModalInstance.dismiss('cancel');
        };
	}

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