dialogSelect.js
1.62 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
(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);