You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
aggregation-platform/plugins/system/ts/sqlManagement.ts

106 lines
3.5 KiB

/// <reference path="../../includes.ts"/>
/// <reference path="systemPlugin.ts"/>
/// <reference path="systemHelpers.ts"/>
/// <reference path="systemServices.ts"/>
module System{
export var SystemSQLManagement = controller('SystemSQLManagement', ['$scope', '$location', '$http', '$element', '$templateCache', 'NgTableParams', 'ngDialog', 'SystemModel', ($scope, $location, $http, $element, $templateCache, NgTableParams, ngDialog, SystemModel) => {
shareInit($scope);
$scope.cities = classifyCity(SystemModel.regionalismInfo);
$scope.status = [{id: 0, label: "全部"}, {id: 1, label: "待审"}, {id: 2, label: "缺失"}, {id:3, label:"正常"}];
$scope.filterResult = $scope.model = SystemModel.sqlInfo;
$scope.checkboxes = {
checked: false,
items: {}
};
$scope.tableParams = new NgTableParams({count: 25}, {
counts: [25, 50, 100],
dataset: $scope.filterResult
});
$scope.citySelect = (x) =>{
if(x != 'all'){
$scope.countries = classifyCountry(SystemModel.regionalismInfo, x);
$scope.filterResult = [];
angular.forEach($scope.model, (item) => {
if(x == item.cityName)
$scope.filterResult.push(item);
});
$scope.tableParams.settings({
dataset: $scope.filterResult
});
}else{
$scope.countries=[];
$scope.filterResult = $scope.model;
$scope.tableParams.settings({
dataset: $scope.filterResult
});
}
}
$scope.countrySelect = (y) => {
if(y != 'all'){
var result = [];
angular.forEach($scope.filterResult, (item) => {
if(item.districtName == y)
result.push(item);
});
$scope.tableParams.settings({
dataset: result
});
}else{
$scope.tableParams.settings({
dataset: $scope.filterResult
});
}
}
$scope.statusSelect = (z) => {
var result = [];
console.log(z);
}
// watch for check all checkbox
$scope.$watch(function() {
return $scope.checkboxes.checked;
}, function(value) {
angular.forEach($scope.model, function(item) {
$scope.checkboxes.items[item.id] = value;
});
});
// watch for data checkboxes
$scope.$watch(function() {
return $scope.checkboxes.items;
}, function(values) {
var checked = 0, unchecked = 0,
total = $scope.model.length;
angular.forEach($scope.model, function(item) {
checked += ($scope.checkboxes.items[item.id]) || 0;
unchecked += Number((!$scope.checkboxes.items[item.id])) || 0;
});
if ((unchecked == 0) || (checked == 0)) {
$scope.checkboxes.checked = (checked == total);
}
// grayed checkbox
angular.element($element[0].getElementsByClassName("select-all")).prop("indeterminate", (checked != 0 && unchecked != 0));
}, true);
$scope.viewSql = (selected, type) => {
ngDialog.open({
template: 'sqlView.html',
controller:'Configs.SqlViewController',
width: 1005,
height: 700,
scope: $scope,
closeByDocument : false,
data: {type: type, item: selected },
className: 'ngdialog-theme-default'
});
}
}])
}