|
|
@@ -356,27 +356,7 @@ define(['app/app'], function(app) {
|
|
|
|
|
|
//编辑账户
|
|
|
$scope.editAccount = function(data) {
|
|
|
- var modalInstance = $modal.open({
|
|
|
- templateUrl : 'static/view/common/bankInfoModal.html',
|
|
|
- controller : 'BankInfoCtrl',
|
|
|
- resolve : {
|
|
|
- account : function() {
|
|
|
- //深拷贝一份
|
|
|
- return angular.copy(data);
|
|
|
- }
|
|
|
- }
|
|
|
- });
|
|
|
-
|
|
|
- modalInstance.result.then(function(account) {
|
|
|
- if(data) {
|
|
|
- $scope.accounts.splice(data.num - 1, 1, account);
|
|
|
- }else {//如果是新增。
|
|
|
- loadAccountData();
|
|
|
- }
|
|
|
-
|
|
|
- }, function() {
|
|
|
-
|
|
|
- });
|
|
|
+ $scope.showAddFrame = true;
|
|
|
};
|
|
|
|
|
|
//获取数据的方法。
|
|
|
@@ -673,219 +653,215 @@ define(['app/app'], function(app) {
|
|
|
SessionService.unset("buyCenter");
|
|
|
}
|
|
|
});
|
|
|
- }]);
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- app.register.controller('BankInfoCtrl', ['$scope', '$modalInstance', 'account', 'bankInfoService', 'toaster', function($scope, $modalInstance, account, bankInfoService, toaster){
|
|
|
-
|
|
|
- /**
|
|
|
- * 目前只支持的银行
|
|
|
- * @type {string[]}
|
|
|
- */
|
|
|
- $scope.bankList = [
|
|
|
- '中国银行','中国建设银行','中国工商银行','中国农业银行','交通银行','招商银行','中国民生银行',
|
|
|
- '兴业银行','中信银行','中国光大银行','广发银行','平安银行','中国邮政储蓄银行','华夏银行','浦发银行'
|
|
|
- ];
|
|
|
-
|
|
|
- var initIndex = function () {
|
|
|
- $scope.selectIndex = -1;
|
|
|
- $scope.downIndex = 0;
|
|
|
- };
|
|
|
-
|
|
|
- $scope.getItemFocus = function() {
|
|
|
- $scope.showBankFrame = true;
|
|
|
- $scope.matchData = true;
|
|
|
- $scope.resultList = $scope.bankList;
|
|
|
- initIndex();
|
|
|
- };
|
|
|
-
|
|
|
- $scope.onItemBlur = function () {
|
|
|
- if ($scope.time){
|
|
|
- clearTimeout($scope.time);
|
|
|
- }
|
|
|
- $scope.time = setTimeout(function () {
|
|
|
- $scope.$apply(function () {
|
|
|
- $scope.showBankFrame = false;
|
|
|
- });
|
|
|
- }, 200);
|
|
|
- };
|
|
|
- $scope.onKeyUp = function () {
|
|
|
- var dom = document.getElementById("ulContent");
|
|
|
- console.log(event);
|
|
|
- if ($scope.showBankFrame){
|
|
|
- if(event.keyCode == 40) { //监听到按下键
|
|
|
- $scope.selectIndex ++;
|
|
|
- if ($scope.downIndex == 5){
|
|
|
- dom.scrollTop += 44;
|
|
|
- }
|
|
|
- if ($scope.downIndex <= 4){
|
|
|
- $scope.downIndex++;
|
|
|
- }
|
|
|
- if($scope.selectIndex >= $scope.resultList.length){
|
|
|
- $scope.selectIndex = 0;
|
|
|
- dom.scrollTop = 0;
|
|
|
- $scope.downIndex = 1;
|
|
|
- }
|
|
|
- $scope.account.bankname = $scope.resultList[$scope.selectIndex];
|
|
|
- // $scope.containsAttr($scope.logistics.companyName);
|
|
|
- } else if(event.keyCode == 38) { //监听到按上键
|
|
|
- $scope.selectIndex --;
|
|
|
- if ($scope.downIndex == 1){
|
|
|
- dom.scrollTop -= 44;
|
|
|
- }
|
|
|
- if ($scope.downIndex >= 2){
|
|
|
- $scope.downIndex--;
|
|
|
- }
|
|
|
- if($scope.selectIndex < 0){
|
|
|
- $scope.selectIndex = $scope.resultList.length - 1;
|
|
|
- dom.scrollTop = 2400;
|
|
|
- $scope.downIndex = 5;
|
|
|
- }
|
|
|
- $scope.account.bankname = $scope.resultList[$scope.selectIndex];
|
|
|
- // $scope.containsAttr($scope.logistics.companyName);
|
|
|
- } else if(event.keyCode == 13) { //确定键
|
|
|
- $scope.showBankFrame = false;
|
|
|
- }
|
|
|
- }
|
|
|
- };
|
|
|
-
|
|
|
- $scope.showList = function () {
|
|
|
- $scope.showBankFrame = !$scope.showBankFrame;
|
|
|
- $scope.matchData = true;
|
|
|
- $scope.resultList = $scope.bankList;
|
|
|
- };
|
|
|
-
|
|
|
- $scope.inputBankName = function () {
|
|
|
- $scope.showBankFrame = true;
|
|
|
- };
|
|
|
-
|
|
|
- $scope.fitBankToAccount = function (item) {
|
|
|
- $scope.account.bankname = item;
|
|
|
- $scope.showBankFrame = false;
|
|
|
- };
|
|
|
-
|
|
|
- $scope.account = account;
|
|
|
- if($scope.account) {
|
|
|
- $scope.title = "修改账户";
|
|
|
- }else {
|
|
|
- $scope.title = "新增账户";
|
|
|
- $scope.account = {};
|
|
|
- }
|
|
|
-
|
|
|
- var matchArray = function () {
|
|
|
- $scope.account.bankname = $scope.account.bankname ? $scope.account.bankname : '';
|
|
|
- $scope.resultList = $scope.bankList.filter(function (data) {
|
|
|
- if (data.indexOf($scope.account.bankname) >= 0){
|
|
|
- return data;
|
|
|
- }
|
|
|
- });
|
|
|
- if ($scope.resultList.length > 0){
|
|
|
- $scope.matchData = true;
|
|
|
- }else{
|
|
|
- $scope.matchData = false;
|
|
|
- }
|
|
|
- };
|
|
|
-
|
|
|
- /**
|
|
|
- * 验证新增账户格式
|
|
|
- * @param num
|
|
|
- */
|
|
|
- $scope.checkAccount = function (num) {
|
|
|
- var size;
|
|
|
- if (num == 1){
|
|
|
- //验证开户银行名称
|
|
|
- $scope.showBankFrame = true;
|
|
|
- matchArray();
|
|
|
- }else if(num == 2){
|
|
|
- //验证开户支行名称
|
|
|
- if($scope.account.branchname){
|
|
|
- size = $scope.account.branchname.replace(/[^\x00-\xff]/g,'**').length;
|
|
|
- if (size > 40){
|
|
|
- $scope.branchError = true;
|
|
|
- }else {
|
|
|
- $scope.branchError = false;
|
|
|
- }
|
|
|
- var telPatt = new RegExp("^[\u2E80-\u9FFF]+$");
|
|
|
- if (telPatt.test($scope.account.branchname)){
|
|
|
- $scope.branchPattError = false;
|
|
|
- }else {
|
|
|
- $scope.branchPattError = true;
|
|
|
- }
|
|
|
- }
|
|
|
- }else if(num == 3){
|
|
|
- //验证银行账号
|
|
|
- if ($scope.account.number){
|
|
|
- size = $scope.account.number.replace(/[^\x00-\xff]/g,'**').length;
|
|
|
- if (size > 30){
|
|
|
- $scope.numberError = true;
|
|
|
- }else {
|
|
|
- $scope.numberError = false;
|
|
|
- }
|
|
|
- var numPatt = new RegExp("^[0-9]+$");
|
|
|
- if (numPatt.test($scope.account.number)){
|
|
|
- $scope.numberPattError = false;
|
|
|
- }else {
|
|
|
- $scope.numberPattError = true;
|
|
|
- }
|
|
|
- validateRepeat($scope.account.number);
|
|
|
- }
|
|
|
- }else if(num == 4){
|
|
|
- //验证开户名称
|
|
|
- if ($scope.account.accountname){
|
|
|
- size = $scope.account.accountname.replace(/[^\x00-\xff]/g,'**').length;
|
|
|
- if (size > 100){
|
|
|
- $scope.nameError = true;
|
|
|
- }else {
|
|
|
- $scope.nameError = false;
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- };
|
|
|
|
|
|
- var validateRepeat = function (number) {
|
|
|
- bankInfoService.getCountByNumber({type:1061, number:number}, {}, function (data) {
|
|
|
- if (data.success){
|
|
|
- if (data.data != 0){
|
|
|
- $scope.repeatError = true;
|
|
|
- }else {
|
|
|
- $scope.repeatError = false;
|
|
|
- }
|
|
|
- }else {
|
|
|
- toaster.pop("info", data.message);
|
|
|
+ // 复制新增加部分
|
|
|
+ /**
|
|
|
+ * 目前只支持的银行
|
|
|
+ * @type {string[]}
|
|
|
+ */
|
|
|
+ $scope.bankList = [
|
|
|
+ '中国银行','中国建设银行','中国工商银行','中国农业银行','交通银行','招商银行','中国民生银行',
|
|
|
+ '兴业银行','中信银行','中国光大银行','广发银行','平安银行','中国邮政储蓄银行','华夏银行','浦发银行'
|
|
|
+ ];
|
|
|
+
|
|
|
+ var initIndex = function () {
|
|
|
+ $scope.selectIndex = -1;
|
|
|
+ $scope.downIndex = 0;
|
|
|
+ };
|
|
|
+
|
|
|
+ $scope.getItemFocus = function() {
|
|
|
+ $scope.showBankFrame = true;
|
|
|
+ $scope.matchData = true;
|
|
|
+ $scope.resultList = $scope.bankList;
|
|
|
+ initIndex();
|
|
|
+ };
|
|
|
+
|
|
|
+ $scope.onItemBlur = function () {
|
|
|
+ if ($scope.time){
|
|
|
+ clearTimeout($scope.time);
|
|
|
+ }
|
|
|
+ $scope.time = setTimeout(function () {
|
|
|
+ $scope.$apply(function () {
|
|
|
+ $scope.showBankFrame = false;
|
|
|
+ });
|
|
|
+ }, 200);
|
|
|
+ };
|
|
|
+ $scope.onKeyUp = function () {
|
|
|
+ var dom = document.getElementById("ulContent");
|
|
|
+ if ($scope.showBankFrame){
|
|
|
+ if(event.keyCode == 40) { //监听到按下键
|
|
|
+ $scope.selectIndex ++;
|
|
|
+ if ($scope.downIndex == 5){
|
|
|
+ dom.scrollTop += 44;
|
|
|
+ }
|
|
|
+ if ($scope.downIndex <= 4){
|
|
|
+ $scope.downIndex++;
|
|
|
+ }
|
|
|
+ if($scope.selectIndex >= $scope.resultList.length){
|
|
|
+ $scope.selectIndex = 0;
|
|
|
+ dom.scrollTop = 0;
|
|
|
+ $scope.downIndex = 1;
|
|
|
+ }
|
|
|
+ $scope.account.bankname = $scope.resultList[$scope.selectIndex];
|
|
|
+ // $scope.containsAttr($scope.logistics.companyName);
|
|
|
+ } else if(event.keyCode == 38) { //监听到按上键
|
|
|
+ $scope.selectIndex --;
|
|
|
+ if ($scope.downIndex == 1){
|
|
|
+ dom.scrollTop -= 44;
|
|
|
+ }
|
|
|
+ if ($scope.downIndex >= 2){
|
|
|
+ $scope.downIndex--;
|
|
|
+ }
|
|
|
+ if($scope.selectIndex < 0){
|
|
|
+ $scope.selectIndex = $scope.resultList.length - 1;
|
|
|
+ dom.scrollTop = 2400;
|
|
|
+ $scope.downIndex = 5;
|
|
|
+ }
|
|
|
+ $scope.account.bankname = $scope.resultList[$scope.selectIndex];
|
|
|
+ // $scope.containsAttr($scope.logistics.companyName);
|
|
|
+ } else if(event.keyCode == 13) { //确定键
|
|
|
+ $scope.showBankFrame = false;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ };
|
|
|
+
|
|
|
+ $scope.showList = function () {
|
|
|
+ $scope.showBankFrame = !$scope.showBankFrame;
|
|
|
+ $scope.matchData = true;
|
|
|
+ $scope.resultList = $scope.bankList;
|
|
|
+ };
|
|
|
+
|
|
|
+ $scope.inputBankName = function () {
|
|
|
+ $scope.showBankFrame = true;
|
|
|
+ };
|
|
|
+
|
|
|
+ $scope.fitBankToAccount = function (item) {
|
|
|
+ $scope.account.bankname = item;
|
|
|
+ $scope.showBankFrame = false;
|
|
|
+ };
|
|
|
+
|
|
|
+ $scope.account = {};
|
|
|
+
|
|
|
+ var matchArray = function () {
|
|
|
+ $scope.account.bankname = $scope.account.bankname ? $scope.account.bankname : '';
|
|
|
+ $scope.resultList = $scope.bankList.filter(function (data) {
|
|
|
+ if (data.indexOf($scope.account.bankname) >= 0){
|
|
|
+ return data;
|
|
|
+ }
|
|
|
+ });
|
|
|
+ if ($scope.resultList.length > 0){
|
|
|
+ $scope.matchData = true;
|
|
|
+ }else{
|
|
|
+ $scope.matchData = false;
|
|
|
+ }
|
|
|
+ };
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 验证新增账户格式
|
|
|
+ * @param num
|
|
|
+ */
|
|
|
+ $scope.checkAccount = function (num) {
|
|
|
+ var size;
|
|
|
+ if (num == 1){
|
|
|
+ //验证开户银行名称
|
|
|
+ $scope.showBankFrame = true;
|
|
|
+ matchArray();
|
|
|
+ }else if(num == 2){
|
|
|
+ //验证开户支行名称
|
|
|
+ if($scope.account.branchname){
|
|
|
+ size = $scope.account.branchname.replace(/[^\x00-\xff]/g,'**').length;
|
|
|
+ if (size > 40){
|
|
|
+ $scope.branchError = true;
|
|
|
+ }else {
|
|
|
+ $scope.branchError = false;
|
|
|
+ }
|
|
|
+ var telPatt = new RegExp("^[\u2E80-\u9FFF]+$");
|
|
|
+ if (telPatt.test($scope.account.branchname)){
|
|
|
+ $scope.branchPattError = false;
|
|
|
+ }else {
|
|
|
+ $scope.branchPattError = true;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }else if(num == 3){
|
|
|
+ //验证银行账号
|
|
|
+ if ($scope.account.number){
|
|
|
+ size = $scope.account.number.replace(/[^\x00-\xff]/g,'**').length;
|
|
|
+ if (size > 30){
|
|
|
+ $scope.numberError = true;
|
|
|
+ }else {
|
|
|
+ $scope.numberError = false;
|
|
|
+ }
|
|
|
+ var numPatt = new RegExp("^[0-9]+$");
|
|
|
+ if (numPatt.test($scope.account.number)){
|
|
|
+ $scope.numberPattError = false;
|
|
|
+ }else {
|
|
|
+ $scope.numberPattError = true;
|
|
|
+ }
|
|
|
+ validateRepeat($scope.account.number);
|
|
|
+ }
|
|
|
+ }else if(num == 4){
|
|
|
+ //验证开户名称
|
|
|
+ if ($scope.account.accountname){
|
|
|
+ size = $scope.account.accountname.replace(/[^\x00-\xff]/g,'**').length;
|
|
|
+ if (size > 100){
|
|
|
+ $scope.nameError = true;
|
|
|
+ }else {
|
|
|
+ $scope.nameError = false;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ };
|
|
|
+
|
|
|
+ var validateRepeat = function (number) {
|
|
|
+ bankInfoService.getCountByNumber({type:1061, number:number}, {}, function (data) {
|
|
|
+ if (data.success){
|
|
|
+ if (data.data != 0){
|
|
|
+ $scope.repeatError = true;
|
|
|
+ }else {
|
|
|
+ $scope.repeatError = false;
|
|
|
+ }
|
|
|
+ }else {
|
|
|
+ toaster.pop("info", data.message);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ };
|
|
|
+
|
|
|
+ $scope.confirm = function() {
|
|
|
+ var account = $scope.account;
|
|
|
+
|
|
|
+ if (!account){
|
|
|
+ toaster.pop('error', '请按要求填写正确的信息');
|
|
|
+ return ;
|
|
|
+ }
|
|
|
+ if (!account.bankname || !account.branchname || !account.number || !account.accountname){
|
|
|
+ toaster.pop('error', '请按要求填写正确的信息');
|
|
|
+ return ;
|
|
|
+ }
|
|
|
+ if (!$scope.matchData || $scope.branchError || $scope.branchPattError || $scope.numberError || $scope.numberPattError ||
|
|
|
+ $scope.nameError || $scope.repeatError){
|
|
|
+ toaster.pop('error', '请按要求填写正确的信息');
|
|
|
+ return ;
|
|
|
+ }
|
|
|
+
|
|
|
+ var method = 'saveBuyPersonalBank'; //不区分个人和企业账户
|
|
|
+ bankInfoService[method].call(null, null, $scope.account, function(data) {
|
|
|
+ if (data) {
|
|
|
+ $scope.showAddFrame = false;
|
|
|
+ $scope.account = {};
|
|
|
+ $scope.account.files = null;
|
|
|
+ toaster.pop('success', '保存成功');
|
|
|
+ loadAccountData();
|
|
|
}
|
|
|
- });
|
|
|
- };
|
|
|
-
|
|
|
- $scope.confirm = function() {
|
|
|
- var account = $scope.account;
|
|
|
-
|
|
|
- if (!account){
|
|
|
- toaster.pop('error', '请按要求填写正确的信息');
|
|
|
- return ;
|
|
|
- }
|
|
|
- if (!account.bankname || !account.branchname || !account.number || !account.accountname){
|
|
|
- toaster.pop('error', '请按要求填写正确的信息');
|
|
|
- return ;
|
|
|
- }
|
|
|
- if (!$scope.matchData || $scope.branchError || $scope.branchPattError || $scope.numberError || $scope.numberPattError ||
|
|
|
- $scope.nameError || $scope.repeatError){
|
|
|
- toaster.pop('error', '请按要求填写正确的信息');
|
|
|
- return ;
|
|
|
- }
|
|
|
-
|
|
|
- var method = 'saveBuyPersonalBank'; //不区分个人和企业账户
|
|
|
- bankInfoService[method].call(null, null, $scope.account, function(data) {
|
|
|
- toaster.pop('success', '保存成功');
|
|
|
- $modalInstance.close(data)
|
|
|
- },function (err) {
|
|
|
- toaster.pop('error', err.data || '保存信息失败');
|
|
|
- });
|
|
|
- };
|
|
|
-
|
|
|
- $scope.cancel = function() {
|
|
|
- $modalInstance.dismiss();
|
|
|
- }
|
|
|
-
|
|
|
+ },function (err) {
|
|
|
+ toaster.pop('error', err.data || '保存信息失败');
|
|
|
+ });
|
|
|
+ };
|
|
|
+
|
|
|
+ $scope.cancel = function() {
|
|
|
+ $scope.showAddFrame = false;
|
|
|
+ $scope.account = {};
|
|
|
+ $scope.account.files = null;
|
|
|
+ $scope.showBankFrame = false;
|
|
|
+ }
|
|
|
}]);
|
|
|
});
|