|
@@ -1,21 +1,22 @@
|
|
|
define(['app/app'], function(app) {
|
|
define(['app/app'], function(app) {
|
|
|
'use strict';
|
|
'use strict';
|
|
|
- app.register.controller('creditCardAdminCtrl', ['$scope', 'toaster', 'BaseService', 'bankInfoService', '$filter', '$modal', function($scope, toaster, BaseService, bankInfoService, $filter, $modal) {
|
|
|
|
|
|
|
+ app.register.controller('creditCardAdminCtrl', ['$scope', 'toaster', 'BaseService', 'bankInfoService', '$filter', '$modal', 'ngTableParams', '$upload', function($scope, toaster, BaseService, bankInfoService, $filter, $modal, ngTableParams, $upload) {
|
|
|
BaseService.scrollBackToTop();
|
|
BaseService.scrollBackToTop();
|
|
|
|
|
|
|
|
var hideBankFilter = $filter("hideBankFilter");
|
|
var hideBankFilter = $filter("hideBankFilter");
|
|
|
|
|
|
|
|
$scope.active = "personal";
|
|
$scope.active = "personal";
|
|
|
|
|
+ $scope.param = {};
|
|
|
|
|
|
|
|
var getState = function() {
|
|
var getState = function() {
|
|
|
- var method = "getAdminEnterAccount";
|
|
|
|
|
|
|
+ var method = "getSaleEeterpriseBank";
|
|
|
switch($scope.active) {
|
|
switch($scope.active) {
|
|
|
case "personal" :
|
|
case "personal" :
|
|
|
- method = "getAdminPersAccount"; break;
|
|
|
|
|
|
|
+ method = "getBuyPersonalBank"; break;
|
|
|
case "enterprise":
|
|
case "enterprise":
|
|
|
- method = "getAdminEnterAccount"; break;
|
|
|
|
|
|
|
+ method = "getSaleEeterpriseBank"; break;
|
|
|
default :
|
|
default :
|
|
|
- method = "getAdminEnterAccount";
|
|
|
|
|
|
|
+ method = "getSaleEeterpriseBank";
|
|
|
}
|
|
}
|
|
|
return method;
|
|
return method;
|
|
|
}
|
|
}
|
|
@@ -24,36 +25,55 @@ define(['app/app'], function(app) {
|
|
|
var method = null;
|
|
var method = null;
|
|
|
switch(kind) {
|
|
switch(kind) {
|
|
|
case "personal":
|
|
case "personal":
|
|
|
- method = "saveAdminPerAccount"; break;
|
|
|
|
|
|
|
+ method = "saveBuyPersonalBank"; break;
|
|
|
case "enterprise":
|
|
case "enterprise":
|
|
|
- method = "saveAdminEnteAccount"; break;
|
|
|
|
|
|
|
+ method = "saveBuyEnterpriseBank"; break;
|
|
|
}
|
|
}
|
|
|
return method;
|
|
return method;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
$scope.setActive = function(status) {
|
|
$scope.setActive = function(status) {
|
|
|
$scope.active = status;
|
|
$scope.active = status;
|
|
|
- loadAccount();
|
|
|
|
|
|
|
+ loadAccountData();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
$scope.kind = 0;
|
|
$scope.kind = 0;
|
|
|
-
|
|
|
|
|
- var loadAccount = function() {
|
|
|
|
|
- bankInfoService[getState()]({}, function(data) {
|
|
|
|
|
- $scope.accounts = data;
|
|
|
|
|
- angular.forEach($scope.accounts, function(account) {
|
|
|
|
|
- account.filterAccount = hideBankFilter(account.number);
|
|
|
|
|
- })
|
|
|
|
|
- }, function(response) {
|
|
|
|
|
- toaster.pop('error', '获取账户信息失败 '+ response.data);
|
|
|
|
|
- })
|
|
|
|
|
- }
|
|
|
|
|
- loadAccount();
|
|
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
|
|
+ $scope.bankInfoTableParams = new ngTableParams({
|
|
|
|
|
+ page : 1,
|
|
|
|
|
+ count : 10,
|
|
|
|
|
+ sorting : {
|
|
|
|
|
+ num : 'ASC'
|
|
|
|
|
+ }
|
|
|
|
|
+ },{
|
|
|
|
|
+ total : 0,
|
|
|
|
|
+ getData : function ($defer, params) {
|
|
|
|
|
+ var param = BaseService.parseParams(params.url());
|
|
|
|
|
+ bankInfoService[getState()](param, {}, function(data) {
|
|
|
|
|
+ $scope.accounts = data.content;
|
|
|
|
|
+ angular.forEach($scope.accounts.content, function(account) {
|
|
|
|
|
+ account.filterAccount = hideBankFilter(account.number);
|
|
|
|
|
+ })
|
|
|
|
|
+
|
|
|
|
|
+ $scope.totalElements = data.totalElements;
|
|
|
|
|
+ params.total(data.totalElements);
|
|
|
|
|
+ $defer.resolve(data.content);
|
|
|
|
|
+ }, function(response) {
|
|
|
|
|
+ toaster.pop('error', '获取账户信息失败 '+ response.data);
|
|
|
|
|
+ })
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
|
|
+ var loadAccountData = function() {
|
|
|
|
|
+ $scope.bankInfoTableParams.page(1);
|
|
|
|
|
+ $scope.bankInfoTableParams.reload();
|
|
|
|
|
+ };
|
|
|
|
|
+ loadAccountData();
|
|
|
|
|
+
|
|
|
$scope.setDefaultAccount = function(id) {
|
|
$scope.setDefaultAccount = function(id) {
|
|
|
bankInfoService.setDefaultAccount({id : id}, function() {
|
|
bankInfoService.setDefaultAccount({id : id}, function() {
|
|
|
toaster.pop('success', '设置成功');
|
|
toaster.pop('success', '设置成功');
|
|
|
- loadAccount();
|
|
|
|
|
|
|
+ loadAccountData();
|
|
|
}, function(response) {
|
|
}, function(response) {
|
|
|
toaster.pop('error', '设置默认账户失败');
|
|
toaster.pop('error', '设置默认账户失败');
|
|
|
})
|
|
})
|
|
@@ -65,7 +85,7 @@ define(['app/app'], function(app) {
|
|
|
if(isSure){
|
|
if(isSure){
|
|
|
bankInfoService.deleteBank({id: buyAccount.id}, function(data) {
|
|
bankInfoService.deleteBank({id: buyAccount.id}, function(data) {
|
|
|
toaster.pop('success', '删除成功');
|
|
toaster.pop('success', '删除成功');
|
|
|
- loadAccount();
|
|
|
|
|
|
|
+ loadAccountData();
|
|
|
}, function(response) {
|
|
}, function(response) {
|
|
|
toaster.pop('error', '删除失败');
|
|
toaster.pop('error', '删除失败');
|
|
|
})
|
|
})
|
|
@@ -94,13 +114,33 @@ define(['app/app'], function(app) {
|
|
|
toaster.pop("info", "没有设置对应的账户类型,不能保存");
|
|
toaster.pop("info", "没有设置对应的账户类型,不能保存");
|
|
|
return ;
|
|
return ;
|
|
|
}
|
|
}
|
|
|
- bankInfoService[method].call(null, account, function(data) {
|
|
|
|
|
- toaster.pop('success', '保存成功','信息已更新');
|
|
|
|
|
- $scope.kind = account.kind;
|
|
|
|
|
- loadAccount();
|
|
|
|
|
- }, function(res) {
|
|
|
|
|
- toaster.pop('error', '错误', res.data);
|
|
|
|
|
- });
|
|
|
|
|
|
|
+ account.accountType = $scope.active === 'personal' ? 'PAY_TYPE' : 'RECEIVE_TYPE';
|
|
|
|
|
+ if($scope.active === 'personal') {
|
|
|
|
|
+ bankInfoService[method].call(null, account, function(data) {
|
|
|
|
|
+ toaster.pop('success', '保存成功','信息已更新');
|
|
|
|
|
+ $scope.kind = account.kind;
|
|
|
|
|
+ loadAccountData();
|
|
|
|
|
+ }, function(res) {
|
|
|
|
|
+ toaster.pop('error', '错误', res.data);
|
|
|
|
|
+ });
|
|
|
|
|
+ } else {
|
|
|
|
|
+ $upload.upload({
|
|
|
|
|
+ url : 'trade/bankInfo/save/enterprise',
|
|
|
|
|
+ method: 'POST',
|
|
|
|
|
+ params : {type : 'sup'},
|
|
|
|
|
+ data: {
|
|
|
|
|
+ bankInfo: account
|
|
|
|
|
+ }
|
|
|
|
|
+ }).success(function(data){
|
|
|
|
|
+ if(data){
|
|
|
|
|
+ account = {};
|
|
|
|
|
+ toaster.pop('success', '保存成功');
|
|
|
|
|
+ loadAccountData();
|
|
|
|
|
+ }
|
|
|
|
|
+ }).error(function(err){
|
|
|
|
|
+ toaster.pop('error', err || "保存账户信息失败");
|
|
|
|
|
+ });
|
|
|
|
|
+ }
|
|
|
});
|
|
});
|
|
|
};
|
|
};
|
|
|
|
|
|