Procházet zdrojové kódy

买家中心-发票管理-开票信息功能

yangc před 8 roky
rodič
revize
a2ddbe3b91

+ 24 - 8
src/main/webapp/resources/js/usercenter/controllers/forstore/buyer_invoice_ctrl.js

@@ -101,6 +101,14 @@ define(['app/app'], function(app) {
             // };
             //保存发票信息
             $scope.saveBill = function() {
+                $scope.bill.kind = $scope.billType
+                if (!$scope.isAdd) { //修改
+                    doSave('修改发票信息');
+                } else { // 新增
+                    doSave('添加发票');
+                }
+            };
+            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]) {
@@ -114,12 +122,13 @@ define(['app/app'], function(app) {
                         bill: $scope.bill
                     }
                 }).success(function(data){
-                    toaster.pop('success', '保存发票信息成功');
-                    $modalInstance.close(data);
+                    toaster.pop('success', message + '成功');
+                    $scope.changeBillStatusFlag = false
+                    $state.reload();
                 }).error(function(data){
-                    toaster.pop('error', '保存发票信息失败');
+                    toaster.pop('error', message + '失败');
                 });
-            };
+            }
 
 
         //设置新增栏目切换发票类型
@@ -133,10 +142,10 @@ define(['app/app'], function(app) {
                     $scope.isNormal = false;
                 }
             })
-            if ($scope.isSpecial) {
+            if (!$scope.isNormal) {
                 $scope.billType = 1205
             }
-            if ($scope.isNormal) {
+            if (!$scope.isSpecial) {
                 $scope.billType = 1206
             }
         };
@@ -148,6 +157,7 @@ define(['app/app'], function(app) {
         }
         $scope.addBill = function () {
             $scope.setType();
+            $scope.bill = {};
             $scope.changeBillStatusFlag = true;
             $scope.isAdd = true
         }
@@ -158,6 +168,7 @@ define(['app/app'], function(app) {
         $scope.modifyInvoice = function (invoice) {
             $scope.changeBillStatusFlag = true;
             $scope.isAdd = false;
+            $scope.billType = invoice.kind
             $scope.bill = invoice;
             $scope.bill.is_agree = true;
             $scope.bill.address = {};
@@ -178,7 +189,7 @@ define(['app/app'], function(app) {
         };
         //删除按钮点击
         $scope.deleteInvoice = function (invoice) {
-            $scope.tempDeleteInvoice = invoice //删除发票临时存放
+            $scope.tempDeleteId = invoice.id //删除发票临时存放
             $scope.setDeleteBox(true)
         }
         //设置提示框状态
@@ -187,7 +198,12 @@ define(['app/app'], function(app) {
         }
         //确定删除
         $scope.doDeleteInvoice = function () {
-
+            Bill.deleteById({id: $scope.tempDeleteId}, null, function (data) {
+                toaster.pop('success', '删除发票成功')
+            }, function (error) {
+                toaster.pop('error', '删除发票失败')
+            })
+            $state.reload();
         }
     }]);
 

+ 5 - 5
src/main/webapp/resources/view/usercenter/forstore/buyer_invoice.html

@@ -351,7 +351,7 @@
         <div class="ticket_record_list" ng-if="!changeBillStatusFlag">
             <div class="ticket_record_title">
                 <span class="l_title">已设置的开票信息</span>
-                <span class="add_btn" ng-click="addBill()" ng-if="isSpecial || isNormal"><i class="fa fa-plus-circle"></i>   新增发票</span>
+                <span class="add_btn" ng-click="addBill()" ng-if="!(!isSpecial && !isNormal)"><i class="fa fa-plus-circle"></i>   新增发票</span>
             </div>
             <!-- 开票资料-->
             <div class="tab" style="display: inline-block;">
@@ -395,12 +395,12 @@
                 <div class="row" ng-if="isAdd">
                     <label class="col-md-2 normal-control-label"><b class="text-inverse">*</b>发票类型:</label>
                     <div class="radio col-md-10">
-                        <label class="radio-inline" ng-click="setBillType(1206)">
-                            <label class="padding-top-5"><input type="radio" ng-model="billType" value="1206" ng-disabled="!isNormal"></label>
+                        <label class="radio-inline">
+                            <label class="padding-top-5" ng-click="setBillType(1206)"><input type="radio" ng-model="billType" value="1206" ng-disabled="!isNormal"></label>
                             <label ng-class="{'disable':!isNormal, '':isNormal}" class="padding-left-0">增值税普通发票(不可抵扣)</label>
                         </label>
-                        <label class="radio-inline" ng-click="setBillType(1205)">
-                            <label class="padding-top-5"><input type="radio" ng-model="billType" value="1205" ng-disabled="!isSpecial"></label>
+                        <label class="radio-inline">
+                            <label class="padding-top-5" ng-click="setBillType(1205)"><input type="radio" ng-model="billType" value="1205" ng-disabled="!isSpecial"></label>
                             <label ng-class="{'disable':!isSpecial, '':isSpecial}" class="padding-left-0">增值税专用发票(可抵扣) </label>
                         </label>
                     </div>