@ -2,83 +2,108 @@
/// <reference path="systemPlugin.ts"/>
/// <reference path="systemHelpers.ts"/>
/// <reference path="systemServices.ts"/>
/// <reference path="../../configs/ts/configsUtils.ts"/>
/// <reference path="../../configs/ts/customAlert.ts"/>
/// <reference path="../../kubernetes/ts/kubernetesHelpers.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 . status = [ { id : 0 , label : " 有缺失"} , { id : 1 , label : "正常" } , { id : 2 , label : "待归档" } , { id : 3 , label : "待审核 "} ] ;
$scope . filterResult = $scope . model = SystemModel . sqlInfo ;
$scope . cityFilter = $scope . model = SystemModel . sqlInfo ;
$scope . checkboxes = {
checked : false ,
items : { }
} ;
$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 ) ;
}
counts : [ 25 , 50 , 100 ] ,
dataset : $scope.model
} ) ;
$scope . citySelect = ( x ) = > {
if ( $scope . z != 'all' ) {
$scope . statusFilter = [ ] ;
angular . forEach ( $scope . model , ( item ) = > {
if ( $scope . status [ item . sysStatus ] . label == $scope . z )
$scope . statusFilter . push ( item )
} ) ;
} else
$scope . statusFilter = $scope . model ;
if ( x != 'all' ) {
$scope . countries = classifyCountry ( SystemModel . regionalismInfo , x ) ; //获取当前市下所有区县
$scope . cityFilter = [ ] ;
angular . forEach ( $scope . statusFilter , ( item ) = > {
if ( x == item . cityName )
$scope . cityFilter . push ( item ) ;
} ) ;
} else {
$scope . countries = [ ] ;
$scope . y = 'all' ;
$scope . cityFilter = $scope . statusFilter ;
}
$scope . countryFilter = $scope . cityFilter ;
$scope . tableParams . settings ( {
dataset : $scope.cityFilter
} ) ;
}
$scope . countrySelect = ( y ) = > {
if ( y != 'all' ) {
$scope . countryFilter = [ ] ;
angular . forEach ( $scope . cityFilter , ( item ) = > {
if ( item . districtName == y )
$scope . countryFilter . push ( item ) ;
} ) ;
} else
$scope . countryFilter = $scope . cityFilter
$scope . tableParams . settings ( {
dataset : $scope.countryFilter
} ) ;
}
$scope . statusSelect = ( z ) = > {
var tmp = [ ] ;
if ( $scope . x == 'all' )
tmp = $scope . model ;
else
tmp = $scope . countryFilter ;
var result = [ ] ;
if ( z != 'all' ) {
angular . forEach ( tmp , ( item ) = > {
if ( $scope . status [ item . sysStatus ] . label == z )
result . push ( item ) ;
} ) ;
$scope . tableParams . settings ( {
dataset : result
} ) ;
} else {
$scope . tableParams . settings ( {
dataset : tmp
} ) ;
}
}
// 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 ;
} ) ;
} ) ;
$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 ) {
} , function ( values ) {
var checked = 0 , unchecked = 0 ,
total = $scope . model . length ;
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 ;
@ -90,17 +115,121 @@ module System{
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 : 100 5 ,
height : 7 00,
width : 100 0 ,
height : 6 00,
scope : $scope ,
closeByDocument : false ,
data : { type : type , item : selected } ,
className : 'ngdialog-theme-default'
} ) ;
}
}
//上传
$scope . addSql = ( selected , type ) = > {
ngDialog . open ( {
template : 'sqlAdd.html' ,
controller : 'Configs.SqlAddController' ,
width : 600 ,
height : 600 ,
scope : $scope ,
closeByDocument : false ,
data : { type : type , item : selected } ,
className : 'ngdialog-theme-default'
} ) ;
}
$scope . verifySql = ( selected , type ) = > {
ngDialog . open ( {
template : 'sqlVerification.html' ,
controller : 'Configs.sqlVerificationController' ,
width : 1000 ,
height : 600 ,
scope : $scope ,
closeByDocument : false ,
data : { type : type , item : selected } ,
className : 'ngdialog-theme-default'
} ) ;
}
$scope . moveSql = ( selected , type ) = > {
ngDialog . open ( {
template : 'sqlMove.html' ,
controller : 'Configs.sqlMoveController' ,
width : 600 ,
height : 600 ,
scope : $scope ,
closeByDocument : false ,
data : { type : type , item : selected } ,
className : 'ngdialog-theme-default'
} ) ;
}
$scope . $on ( 'onOk' , ( event , data ) = > {
Configs . create_mask ( ) ; //创建遮罩层
Kubernetes . create_locadEffect ( "正在更新文件,请稍等!" ) ; //创建数据加载效果层
var target = document . getElementById ( 'loading' )
var spinner = new Spinner ( Kubernetes . loadConfigs ( ) ) . spin ( target ) ;
$http ( {
url : "/java/console/api/filePackage/handleSqlFile" ,
method : "POST" ,
params : { type : data . type , opt : data.opt } ,
data : JSON.stringify ( {
item : data.item ,
content : data.content
} )
} ) . success ( ( data , header , config , status ) = > {
$ ( "#load" ) . remove ( ) ;
Kubernetes . removeMask ( ) ;
shareUpdate ( data ) ;
} ) . error ( ( data , header , config , status ) = > {
} ) ;
} ) ;
$scope . $on ( "replace" , ( event , data ) = > {
$http ( {
url : "/java/console/api/filePackage/handleSqlFile" ,
method : "POST" ,
params : { type : data . type , opt : data.opt } ,
data : JSON.stringify ( {
item : data.item ,
content : data.content
} )
} ) . success ( ( data , header , config , status ) = > {
shareUpdate ( data ) ;
} ) . error ( ( data , header , config , status ) = > {
Configs . customAlert ( "提示" , "脚本替换或归档失败!" , '' , null , 0 , "error" ) ;
} )
} ) ;
function shareUpdate ( data ) {
$scope . filterResult = $scope . model = SystemModel . sqlInfo = data . data ;
var result = [ ] ;
if ( $scope . x != "all" ) {
angular . forEach ( $scope . filterResult , ( item ) = > {
if ( item . cityName == $scope . x )
result . push ( item ) ;
} ) ;
$scope . filterResult = result ;
result = [ ] ;
}
if ( $scope . y != "all" ) {
angular . forEach ( $scope . filterResult , ( item ) = > {
if ( item . districtName == $scope . y )
result . push ( item ) ;
} ) ;
$scope . filterResult = result ;
result = [ ] ;
}
$scope . tableParams . settings ( {
dataset : $scope.filterResult
} ) ;
}
} ] )
}