|
|
@@ -48,93 +48,100 @@ define(['app/app'], function(app) {
|
|
|
$scope.bill = {};
|
|
|
$scope.bill.address = {};
|
|
|
|
|
|
- //保存发票信息
|
|
|
- $scope.saveBill = function(flag) {
|
|
|
- var dataValidFlag = $scope.checkValidFrom();
|
|
|
- if (!flag && dataValidFlag && $scope.bill.is_agree) {
|
|
|
- $scope.bill.kind = $scope.billType
|
|
|
- if (!$scope.isAdd) { //修改
|
|
|
- doSave('修改发票信息');
|
|
|
- } else { // 新增
|
|
|
- doSave('添加发票');
|
|
|
- }
|
|
|
- } else if (flag || !dataValidFlag) {
|
|
|
- toaster.pop('error', '请填写正确的发票信息');
|
|
|
- } else {
|
|
|
- toaster.pop('error', '请勾选并阅读《发票须知》');
|
|
|
- }
|
|
|
- };
|
|
|
- var doSave = function (message) {
|
|
|
- $scope.bill.area = $scope.bill.address.province + "," + $scope.bill.address.city + "," + $scope.bill.address.district;
|
|
|
- var file = null;
|
|
|
- if($scope.bill.billInfo&&$scope.bill.billInfo[0]) {
|
|
|
- file = $scope.bill.billInfo[0];
|
|
|
+ //保存发票信息
|
|
|
+ $scope.saveBill = function(flag) {
|
|
|
+ var dataValidFlag = $scope.checkValidFrom();
|
|
|
+ if (!flag && dataValidFlag && $scope.bill.is_agree) {
|
|
|
+ $scope.bill.kind = $scope.billType
|
|
|
+ if (!$scope.isAdd) { //修改
|
|
|
+ doSave('修改发票信息');
|
|
|
+ } else { // 新增
|
|
|
+ doSave('添加发票');
|
|
|
}
|
|
|
- $upload.upload({
|
|
|
- url: 'trade/bill/save',
|
|
|
- file: file,
|
|
|
- method: 'POST',
|
|
|
- data: {
|
|
|
- bill: $scope.bill
|
|
|
- }
|
|
|
- }).success(function(data){
|
|
|
- toaster.pop('success', message + '成功');
|
|
|
- $scope.changeBillStatusFlag = false
|
|
|
- $state.reload();
|
|
|
- }).error(function(data){
|
|
|
- toaster.pop('error', message + '失败');
|
|
|
- });
|
|
|
+ } else if (flag || !dataValidFlag) {
|
|
|
+ toaster.pop('error', '请填写正确的发票信息');
|
|
|
+ } else {
|
|
|
+ toaster.pop('error', '请勾选并阅读《发票须知》');
|
|
|
}
|
|
|
-
|
|
|
- $scope.isDoUpload = false;
|
|
|
- //上传发票许可证
|
|
|
- $scope.onUploadPermission = function () {
|
|
|
- $scope.isDoUpload = true;
|
|
|
- if (event.target.files[0].size < 3*1024*1024) {
|
|
|
- $scope.bill.attachUrl = event.target.files[0].name;
|
|
|
- } else {
|
|
|
- $scope.bill.attachUrl = '';
|
|
|
- }
|
|
|
+ };
|
|
|
+ var doSave = function (message) {
|
|
|
+ $scope.bill.area = $scope.bill.address.province + "," + $scope.bill.address.city + "," + $scope.bill.address.district;
|
|
|
+ var file = null;
|
|
|
+ if($scope.bill.billInfo&&$scope.bill.billInfo[0]) {
|
|
|
+ file = $scope.bill.billInfo[0];
|
|
|
}
|
|
|
-
|
|
|
- //判断中文字符串的长度
|
|
|
- var getRealStringLen = function (str) {
|
|
|
- var realLength = 0, len = str.length, charCode = -1;
|
|
|
- for (var i = 0; i < len; i++) {
|
|
|
- charCode = str.charCodeAt(i);
|
|
|
- if (charCode >= 0 && charCode <= 128) realLength += 1;
|
|
|
- else realLength += 2;
|
|
|
+ $upload.upload({
|
|
|
+ url: 'trade/bill/save',
|
|
|
+ file: file,
|
|
|
+ method: 'POST',
|
|
|
+ data: {
|
|
|
+ bill: $scope.bill
|
|
|
}
|
|
|
- return realLength;
|
|
|
- }
|
|
|
+ }).success(function(data){
|
|
|
+ toaster.pop('success', message + '成功');
|
|
|
+ $scope.changeBillStatusFlag = false
|
|
|
+ $state.reload();
|
|
|
+ }).error(function(data){
|
|
|
+ toaster.pop('error', message + '失败');
|
|
|
+ });
|
|
|
+ }
|
|
|
|
|
|
- $scope.validForm = {
|
|
|
- validBillHead: true,
|
|
|
- validBillName: true,
|
|
|
- validBankName: true,
|
|
|
- validDetailAddress: true,
|
|
|
- validCompanyAddress: true
|
|
|
+ $scope.isDoUpload = false;
|
|
|
+ //上传发票许可证
|
|
|
+ $scope.onUploadPermission = function () {
|
|
|
+ $scope.isDoUpload = true;
|
|
|
+ if (event.target.files[0].size < 3*1024*1024) {
|
|
|
+ $scope.bill.attachUrl = event.target.files[0].name;
|
|
|
+ } else {
|
|
|
+ $scope.bill.attachUrl = '';
|
|
|
}
|
|
|
+ }
|
|
|
|
|
|
- $scope.checkValidFrom = function () {
|
|
|
- var flag = true
|
|
|
- angular.forEach($scope.validForm, function (item) {
|
|
|
- if (!item) {
|
|
|
- flag = false;
|
|
|
- }
|
|
|
- })
|
|
|
- return flag;
|
|
|
+ //判断中文字符串的长度
|
|
|
+ var getRealStringLen = function (str) {
|
|
|
+ var realLength = 0, len = str.length, charCode = -1;
|
|
|
+ for (var i = 0; i < len; i++) {
|
|
|
+ charCode = str.charCodeAt(i);
|
|
|
+ if (charCode >= 0 && charCode <= 128) realLength += 1;
|
|
|
+ else realLength += 2;
|
|
|
}
|
|
|
- $scope.checkValidFrom();
|
|
|
- //发票抬头check
|
|
|
- $scope.checkBillHead = function () {
|
|
|
- var len = getRealStringLen($scope.bill.head);
|
|
|
- if (len > 100) {
|
|
|
- $scope.validForm.validBillHead = false;
|
|
|
- } else {
|
|
|
- $scope.validForm.validBillHead = true;
|
|
|
+ return realLength;
|
|
|
+ }
|
|
|
+
|
|
|
+ $scope.validForm = {
|
|
|
+ validBillHead: true,
|
|
|
+ validBillName: true,
|
|
|
+ validBankName: true,
|
|
|
+ validDetailAddress: true,
|
|
|
+ validCompanyAddress: true
|
|
|
+ }
|
|
|
+ $scope.initFlag = {
|
|
|
+ initBillHead: true,
|
|
|
+ initBillName: true,
|
|
|
+ initBankName: true,
|
|
|
+ initDetailAddress: true,
|
|
|
+ initCompanyAddress: true
|
|
|
+ }
|
|
|
+
|
|
|
+ $scope.checkValidFrom = function () {
|
|
|
+ var flag = true
|
|
|
+ angular.forEach($scope.validForm, function (item) {
|
|
|
+ if (!item) {
|
|
|
+ flag = false;
|
|
|
}
|
|
|
+ })
|
|
|
+ return flag;
|
|
|
+ }
|
|
|
+ $scope.checkValidFrom();
|
|
|
+ //发票抬头check
|
|
|
+ $scope.checkBillHead = function () {
|
|
|
+ var len = getRealStringLen($scope.bill.head);
|
|
|
+ if (len > 100) {
|
|
|
+ $scope.validForm.validBillHead = false;
|
|
|
+ } else {
|
|
|
+ $scope.validForm.validBillHead = true;
|
|
|
}
|
|
|
+ }
|
|
|
|
|
|
//收票人check
|
|
|
$scope.checkBillName = function () {
|
|
|
@@ -238,7 +245,7 @@ define(['app/app'], function(app) {
|
|
|
case 2:
|
|
|
$scope.bill.address.district = item;
|
|
|
break;
|
|
|
- }
|
|
|
+ }
|
|
|
});
|
|
|
};
|
|
|
//删除按钮点击
|