@ -11,97 +11,65 @@ module System{
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 . cityFilter = $scope . model = SystemModel . sqlInfo ;
SystemModel . updateSqlInfo ( ) ;
$scope . model = SystemModel . sqlInfo ;
$scope . checkboxes = {
checked : false ,
items : { }
} ;
$scope . optionsFilter = {
x : "all" ,
y : "all" ,
z : "all"
}
$scope . tableParams = new NgTableParams ( { count : 25 } , {
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 . optionsFilter . x = x ;
$scope . optionsFilter . y = $scope . y = "all" ;
if ( x != "all" ) {
$scope . countries = classifyCountry ( SystemModel . regionalismInfo , x ) ; //获取当前市下所有区县
} else {
$scope . countries = [ ] ;
}
}
$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 . countrySelect = ( y ) = > {
$scope . optionsFilter . y = y ;
}
$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
} ) ;
}
$scope . optionsFilter . z = z ;
}
$scope . $watch ( ( ) = > {
return $scope . optionsFilter ;
} , ( value ) = > {
shareUpdate ( $scope . model , value ) ;
} , true ) ;
$scope . quickCheck = ( ) = > {
updateSqlStatus ( "/java/console/api/filePackage/totalVerifySqlFile" ) ;
}
$scope . quitFile = ( ) = > {
$scope . quickFile = ( ) = > {
updateSqlStatus ( "/java/console/api/filePackage/totalOnholeSqlFile" ) ;
}
$scope . help = ( ) = > {
ngDialog . open ( {
template : 'statusHelp.html' ,
width : 9 00,
height : 60 0,
width : 6 00,
height : 37 0,
closeByDocument : false ,
className : 'ngdialog-theme-default'
} ) ;
@ -116,201 +84,194 @@ module System{
} ) ;
} ) ;
// watch for data checkboxes
$scope . $watch ( function ( ) {
return $scope . checkboxes . items ;
} , function ( values ) {
$scope . checkable = false ;
for ( var index in values ) {
if ( values [ index ] == true ) {
$scope . checkable = true ;
break ;
}
}
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 ) ;
// watch for data checkboxes
$scope . $watch ( function ( ) {
return $scope . checkboxes . items ;
} , function ( values ) {
$scope . checkable = false ;
for ( var index in values ) {
if ( values [ index ] == true ) {
$scope . checkable = true ;
break ;
}
}
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 ) ;
}
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 : 1000 ,
height : 600 ,
scope : $scope ,
closeByDocument : false ,
data : { type : type , item : selected } ,
className : 'ngdialog-theme-default'
} ) ;
}
$scope . viewSql = ( selected , type ) = > {
ngDialog . open ( {
template : 'sqlView.html' ,
controller : 'Configs.SqlViewController' ,
width : 1000 ,
height : 600 ,
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 . 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 . 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 . 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 . $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" ) ;
} )
} ) ;
//替换
$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'
} ) ;
}
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 = [ ] ;
}
$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 ( ) ;
$scope . model = SystemModel . sqlInfo = data . data ;
shareUpdate ( $scope . model , $scope . optionsFilter ) ;
} ) . error ( ( data , header , config , status ) = > {
$ ( "#load" ) . remove ( ) ;
Kubernetes . removeMask ( ) ;
} ) ;
} ) ;
if ( $scope . y != "all" ) {
angular . forEach ( $scope . filterResult , ( item ) = > {
if ( item . districtName == $scope . y )
result . push ( item ) ;
} ) ;
$scope . filterResult = result ;
result = [ ] ;
}
$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 ) = > {
$scope . model = SystemModel . sqlInfo = data . data ;
shareUpdate ( $scope . model , $scope . optionsFilter ) ;
} ) . error ( ( data , header , config , status ) = > {
Configs . customAlert ( "提示" , "脚本替换或归档失败!" , '' , null , 0 , "error" ) ;
} ) ;
} ) ;
$scope . tableParams . settings ( {
dataset : $scope.filterResult
} ) ;
}
function shareUpdate ( data , value ) {
var filter = data , result = [ ] ;
if ( value . x != "all" ) {
angular . forEach ( filter , ( item ) = > {
if ( item . cityName == value . x )
result . push ( item ) ;
} ) ;
filter = result ;
result = [ ] ;
}
function updateSqlStatus ( url : string ) {
var items = [ ] ;
if ( $scope . model && $scope . model . length > 0 ) {
angular . forEach ( $scope . model , ( item ) = > {
if ( $scope . checkboxes . items [ item . id ] )
items . push ( item ) ;
if ( value . y != "all" ) {
angular . forEach ( filter , ( item ) = > {
if ( item . districtName == value . y )
result . push ( item ) ;
} ) ;
}
if ( items . length <= 0 )
return ;
filter = result ;
result = [ ] ;
}
$http ( {
url : url ,
method : 'POST' ,
data : JSON.stringify ( items )
} ) . success ( function ( data , header , config , status ) {
var result = data . data , filter ;
if ( $scope . z != 'all' ) {
result = [ ] ;
angular . forEach ( data . data , ( item ) = > {
if ( $scope . status [ item . sysStatus ] . label == $scope . z )
result . push ( item ) ;
} ) ;
}
filter = result ;
if ( value . z != "all" ) {
angular . forEach ( filter , ( item ) = > {
if ( $scope . status [ item . sysStatus ] . label == value . z )
result . push ( item ) ;
} ) ;
filter = result ;
result = [ ] ;
}
$scope . tableParams . settings ( {
dataset : filter
} ) ;
if ( $scope . x != 'all' ) {
filter = [ ] ;
var tmp = [ ] ;
angular . forEach ( result , ( item ) = > {
if ( $scope . x == item . cityName )
tmp . push ( item ) ;
} ) ;
$scope . checkboxes = {
checked : false ,
items : { }
} ;
}
filter = tmp ;
function updateSqlStatus ( url : string ) {
var items = [ ] ;
if ( $scope . model && $scope . model . length > 0 ) {
angular . forEach ( $scope . model , ( item ) = > {
if ( $scope . checkboxes . items [ item . id ] )
items . push ( item ) ;
} ) ;
}
if ( items . length <= 0 )
return ;
Configs . create_mask ( ) ; //创建遮罩层
Kubernetes . create_locadEffect ( "正在更新文件,请稍等!" ) ; //创建数据加载效果层
if ( $scope . y != 'all' ) {
filter = [ ] ;
angular . forEach ( tmp , ( item ) = > {
if ( $scope . y == item . districtName )
filter . push ( item ) ;
} ) ;
}
}
$scope . tableParams . settings ( {
dataset : filter
} ) ;
//响应成功
} ) . error ( function ( data , header , config , status ) {
//处理响应失败
} ) ;
}
$http ( {
url : url ,
method : 'POST' ,
data : JSON.stringify ( items )
} ) . success ( function ( data , header , config , status ) {
$scope . model = SystemModel . sqlInfo = data . data ;
shareUpdate ( $scope . model , $scope . optionsFilter ) ;
$ ( "#load" ) . remove ( ) ;
Kubernetes . removeMask ( ) ;
//响应成功
} ) . error ( function ( data , header , config , status ) {
//处理响应失败
$ ( "#load" ) . remove ( ) ;
Kubernetes . removeMask ( ) ;
Configs . customAlert ( "提示" , "一键审核或归档失败!" , '' , null , 0 , "error" ) ;
} ) ;
}
} ] )
}