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.
243 lines
10 KiB
243 lines
10 KiB
define(['angular', 'static/commons/commons', 'uiBootstrap', 'uiRouter', 'ngBootSwitch', 'ngFileUpload'], function (angular) {
|
|
'use strict';
|
|
|
|
var riskType = [
|
|
{code: '1', label: 'test1'},
|
|
{code: '2', label: 'test2'},
|
|
];
|
|
|
|
var app = angular.module('RiskManagement', ['ui.bootstrap', 'ui.router', 'frapontillo.bootstrap-switch', 'ngFileUpload']);
|
|
app.config(['$stateProvider', function ($stateProvider) {
|
|
$stateProvider.state('analysis_monitoring.risk_manager', {
|
|
url: '/risk/manage',
|
|
templateUrl: '/static/risk/templates/risk.html',
|
|
controller: 'RiskManageCtrl',
|
|
}).state('analysis_monitoring.risk_orders', {
|
|
url: '/risk/{record_id}/orders',
|
|
templateUrl: '/static/risk/templates/risk_orders.html',
|
|
controller: 'RiskOrderCtrl',
|
|
resolve:{
|
|
record:['$http','$stateParams', function ($http,$stateParams) {
|
|
return $http.get('/sys/risk/records/'+$stateParams.record_id).then(function (res) {
|
|
return res.data;
|
|
});
|
|
}]
|
|
}
|
|
}).state('analysis_monitoring.risk_history', {
|
|
url: '/risk/{record_id}/history',
|
|
templateUrl: '/static/risk/templates/risk_history.html',
|
|
controller: 'RecordHistoryCtrl',
|
|
resolve:{
|
|
record:['$http','$stateParams', function ($http,$stateParams) {
|
|
return $http.get('/sys/risk/records/'+$stateParams.record_id).then(function (res) {
|
|
return res.data;
|
|
});
|
|
}]
|
|
}
|
|
}).state('analysis_monitoring.risk_detail', {
|
|
url: '/risk/{record_id}/detail',
|
|
templateUrl: '/static/risk/templates/risk_detail.html',
|
|
controller: 'RecordDetailCtrl',
|
|
resolve:{
|
|
record:['$http','$stateParams', function ($http,$stateParams) {
|
|
return $http.get('/sys/risk/records/'+$stateParams.record_id).then(function (res) {
|
|
return res.data;
|
|
});
|
|
}]
|
|
}
|
|
});
|
|
}]);
|
|
app.controller('RiskManageCtrl', ['$scope', '$http', function ($scope, $http){
|
|
$scope.params = {};
|
|
$scope.pagination = {};
|
|
$scope.loadRecords = function (page) {
|
|
var params = angular.copy($scope.params);
|
|
params.page = page || $scope.pagination.page || 1;
|
|
$http.get('/sys/risk/records', {params: params}).then(function (resp) {
|
|
$scope.records = resp.data.data;
|
|
$scope.pagination = resp.data.pagination;
|
|
});
|
|
};
|
|
$scope.loadRecords(1);
|
|
}]);
|
|
|
|
app.controller('RiskOrderCtrl', ['$scope', '$http', 'record', function ($scope, $http,record) {
|
|
$scope.params = {record_id: record.id};
|
|
$scope.historyParams = {client_id:record.client_id};
|
|
$scope.pagination = {};
|
|
$scope.historyPagination = {};
|
|
$scope.record = record;
|
|
$scope.loadOrders = function (page) {
|
|
var params = angular.copy($scope.params);
|
|
params.page = page || $scope.pagination.page || 1;
|
|
$http.get('/sys/risk/orders',{params: params}).then(function (resp) {
|
|
$scope.orders = resp.data.data;
|
|
$scope.pagination = resp.data.pagination;
|
|
$scope.historyParams.c_end_time = $scope.orders.pop().create_time;
|
|
$scope.loadHistoryOrders(1);
|
|
});
|
|
};
|
|
$scope.loadOrders(1);
|
|
|
|
$scope.loadHistoryOrders = function (page) {
|
|
var historyParams = angular.copy($scope.historyParams);
|
|
historyParams.page = page || $scope.historyPagination.page || 1;
|
|
$http.get('/sys/risk/orders',{params: historyParams}).then(function (resp) {
|
|
$scope.historyOrders = resp.data.data;
|
|
$scope.historyPagination = resp.data.pagination;
|
|
});
|
|
};
|
|
}]);
|
|
|
|
app.controller('RecordHistoryCtrl', ['$scope', '$http','$uibModal', 'commonDialog','record', function ($scope, $http,$uibModal,commonDialog,record) {
|
|
$scope.record = record;
|
|
$scope.pagination = {};
|
|
$scope.params = {client_id:record.client_id,c_end_time:record.create_time};
|
|
$scope.listHistory = function (page) {
|
|
var params = angular.copy($scope.params);
|
|
params.page = page || $scope.pagination.page || 1;
|
|
$http.get('/sys/risk/records',{params:params}).then(function (res) {
|
|
$scope.histories = res.data.data;
|
|
$scope.pagination = res.data.pagination;
|
|
})
|
|
};
|
|
$scope.listHistory(1);
|
|
$scope.edit = function () {
|
|
$uibModal.open({
|
|
templateUrl: '/static/risk/templates/risk_edit.html',
|
|
controller: 'RiskRecordHandleCtrl',
|
|
resolve:{record_id:function () {
|
|
return record.id;
|
|
}}
|
|
}).result.then(function () {
|
|
commonDialog.alert({
|
|
title: 'Success',
|
|
type: 'success'
|
|
});
|
|
})
|
|
};
|
|
|
|
|
|
$scope.noop = function () {
|
|
commonDialog.confirm({
|
|
title: 'Confirm',
|
|
content: '确定放弃这次预警'
|
|
}).then(function () {
|
|
$http.put('/sys/risk/records/'+ record.id+'/noop', $scope.params).then(function () {
|
|
}).then(function (resp) {
|
|
commonDialog.alert({
|
|
title: 'Error',
|
|
content: resp.data.message,
|
|
type: 'Error'
|
|
});
|
|
})
|
|
})
|
|
}
|
|
}]);
|
|
|
|
app.controller('RecordDetailCtrl', ['$scope', '$http','$uibModal', 'commonDialog','record', function ($scope, $http,$uibModal,commonDialog,record) {
|
|
$scope.record = record;
|
|
$scope.pagination = {};
|
|
$scope.params = {record_id:record.id};
|
|
$scope.listDetail = function (page) {
|
|
var params = angular.copy($scope.params);
|
|
params.page = page || $scope.pagination.page || 1;
|
|
$http.get('/sys/risk/details',{params:params}).then(function (res) {
|
|
$scope.details = res.data.data;
|
|
$scope.pagination = res.data.pagination;
|
|
})
|
|
};
|
|
$scope.listDetail(1);
|
|
|
|
|
|
$scope.addRemark = function () {
|
|
$uibModal.open({
|
|
templateUrl: '/static/risk/templates/risk_remark.html',
|
|
controller: 'RiskDetailRemarkCtrl',
|
|
resolve:{record_id:function () {
|
|
return record.id;
|
|
}}
|
|
}).result.then(function () {
|
|
commonDialog.alert({
|
|
title: 'Success',
|
|
type: 'success'
|
|
});
|
|
})
|
|
}
|
|
|
|
$scope.dealDirectly = function () {
|
|
commonDialog.confirm({
|
|
title: 'Confirm',
|
|
content: '确定关结这次预警?'
|
|
}).then(function () {
|
|
$http.put('/sys/risk/records/'+ record.id+'/directly').then(function () {
|
|
commonDialog.alert({
|
|
title: 'Success',
|
|
type: 'Success'
|
|
});
|
|
$scope.listDetail(1);
|
|
}).then(function (resp) {
|
|
commonDialog.alert({
|
|
title: 'Error',
|
|
content: resp.data.message,
|
|
type: 'Error'
|
|
});
|
|
})
|
|
})
|
|
}
|
|
}]);
|
|
|
|
app.controller('RiskDetailRemarkCtrl', ['$scope', '$http','record_id','commonDialog', function ($scope, $http,record_id,commonDialog) {
|
|
$scope.addRemarkParams = {record_id:record_id};
|
|
$scope.addRemark = function () {
|
|
var params = angular.copy($scope.addRemarkParams);
|
|
$http.post('/sys/risk/details/remark',params).then(function (res) {
|
|
$scope.$close();
|
|
}).then(function (resp) {
|
|
commonDialog.alert({
|
|
title: 'Error',
|
|
content: resp.data.message,
|
|
type: 'Error'
|
|
});
|
|
})
|
|
}
|
|
}]);
|
|
|
|
app.controller('RiskRecordHandleCtrl', ['$scope', '$http','record_id','commonDialog', function ($scope, $http,record_id,commonDialog) {
|
|
$scope.params= {};
|
|
$scope.handle = function () {
|
|
$http.put('/sys/risk/records/'+ record_id+'/deal', $scope.params).then(function () {
|
|
$scope.$close();
|
|
}).then(function (resp) {
|
|
commonDialog.alert({
|
|
title: 'Error',
|
|
content: resp.data.message,
|
|
type: 'Error'
|
|
});
|
|
})
|
|
}
|
|
|
|
}]);
|
|
app.filter('risk_type', function () {
|
|
return function (riskStr) {
|
|
angular.forEach(riskType,function (type) {
|
|
riskStr = riskStr.replace(type.code,type.label);
|
|
})
|
|
return riskStr;
|
|
};
|
|
});
|
|
app.filter('status_type', function () {
|
|
return function (riskStr) {
|
|
var statusResult = '';
|
|
switch (riskStr){
|
|
case('0'): statusResult = '待处理';break;
|
|
case('1'): statusResult = '已处理';break;
|
|
case('2'): statusResult = '处理中';break;
|
|
default: statusResult = '';
|
|
}
|
|
return statusResult;
|
|
};
|
|
});
|
|
|
|
return app;
|
|
}); |