Przeglądaj źródła

发票需求整改

yangc 8 lat temu
rodzic
commit
b888186d18

+ 65 - 2
src/main/webapp/resources/js/usercenter/controllers/forstore/buyer_invoice_ctrl.js

@@ -64,8 +64,8 @@ define(['app/app'], function(app) {
             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.permission&&$scope.bill.permission[0]) {
-                    file = $scope.bill.permission[0];
+                if($scope.bill.billInfo&&$scope.bill.billInfo[0]) {
+                    file = $scope.bill.billInfo[0];
                 }
                 $upload.upload({
                     url: 'trade/bill/save',
@@ -83,7 +83,68 @@ define(['app/app'], function(app) {
                 });
             }
 
+            //上传发票许可证
+            $scope.onUploadPermission = function () {
+                // console.log(event.target.files[0].name);
+                $scope.bill.attachUrl = event.target.files[0].name;
+            }
 
+            //判断中文字符串的长度
+            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;
+                }
+                return realLength;
+            }
+
+            $scope.validForm = {
+                validBillHead: true,
+                validBillName: true,
+                validBankName: true
+            }
+
+            $scope.checkValidFrom = function () {
+                angular.forEach($scope.validForm, function (item) {
+                    if (!item) {
+                        return false;
+                    }
+                })
+                return true;
+            }
+        $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 () {
+            var len = getRealStringLen($scope.bill.name);
+            if (len > 20) {
+                $scope.validForm.validBillName = false;
+            } else {
+                $scope.validForm.validBillName = true;
+            }
+        }
+
+        //开户银行Check
+        $scope.checkBankName = function () {
+            var len = getRealStringLen($scope.bill.bankName);
+            if (len > 60) {
+                $scope.validForm.validBankName = false;
+            } else {
+                $scope.validForm.validBankName = true;
+            }
+        }
+            
         //设置新增栏目切换发票类型
         $scope.billType = 1206
         //设置发票类型
@@ -120,6 +181,8 @@ define(['app/app'], function(app) {
         $scope.setBillType = function (type) {
             $scope.bill = {};
             $scope.billType = type;
+            this.form.$setPristine();
+            this.form.$setUntouched();
         }
         //修改发票
         $scope.modifyInvoice = function (invoice) {

+ 49 - 47
src/main/webapp/resources/js/usercenter/controllers/forstore/buyer_no_invoice_ctrl.js

@@ -7,10 +7,10 @@ define([ 'app/app' ], function(app) {
 
         // 开票申请
         $scope.applyInvoice = function () {
-            var applyItem = []
+            var applyItem = [];
             angular.forEach($scope.orderData, function (item) {
                 if (item.checked) {
-                    applyItem.push(item)
+                    applyItem.push(item);
                 }
             })
       //      console.log(applyItem)
@@ -25,15 +25,15 @@ define([ 'app/app' ], function(app) {
                                 return applyItem;
                             },
                             invoiceData: function () {
-                                return $scope.invoices
+                                return $scope.invoices;
                             }
                         }
                     })
                 } else {
-                    toaster.pop('error','请前往开票信息页面新增发票')
+                    toaster.pop('error','请前往开票信息页面新增发票');
                 }
             } else {
-                toaster.pop('error','请勾选未开票订单')
+                toaster.pop('error','请勾选未开票订单');
             }
         };
         var initDataRule = function () {
@@ -94,7 +94,7 @@ define([ 'app/app' ], function(app) {
                         $scope.orderData = page.content;
                         //初始化选中状态
                         angular.forEach($scope.orderData, function (item) {
-                            item.checked = false
+                            item.checked = false;
                         })
                     }, function () {
                         toaster.pop('error', '获取未开票订单信息失败');
@@ -105,102 +105,102 @@ define([ 'app/app' ], function(app) {
         initTable();
 
         $scope.searchByKeyword = function () {
-            $scope.param.keyword = $scope.keyword
+            $scope.param.keyword = $scope.keyword;
             initTable();
         }
 
         //全选状态
-        $scope.isAllCheck = false
+        $scope.isAllCheck = false;
         //全选
         $scope.onAllChecked = function () {
             if (!$scope.isAllCheck) {
                 angular.forEach($scope.orderData, function (item, index) {
-                    item.checked = true
+                    item.checked = true;
                 })
             } else {
                 angular.forEach($scope.orderData, function (item, index) {
-                    item.checked = false
+                    item.checked = false;
                 })
             }
-            $scope.isAllCheck = !$scope.isAllCheck
+            $scope.isAllCheck = !$scope.isAllCheck;
         }
 
 
         //单选
         $scope.checkInvoice = function (item) {
-            var temAllCheck = true
-            item.checked = !item.checked
+            var temAllCheck = true;
+            item.checked = !item.checked;
             angular.forEach($scope.orderData, function (itemss) {
                 if (!itemss.checked) {
-                    temAllCheck = false
+                    temAllCheck = false;
                 }
             })
-            $scope.isAllCheck = temAllCheck
+            $scope.isAllCheck = temAllCheck;
         }
 
     }]);
-    app.register.controller('NoInvoiceSubmitCtrl', ['$scope','$rootScope','$modal', 'Order', 'toaster', 'submitInvoice', '$modalInstance','invoiceData','BillSubmit', function ($scope, $rootScope, $modal, Order, toaster, submitInvoice, $modalInstance, invoiceData, BillSubmit) {
+    app.register.controller('NoInvoiceSubmitCtrl', ['$scope','$rootScope','$modal', 'Order', 'toaster', 'submitInvoice', '$modalInstance','invoiceData','BillSubmit','$state', function ($scope, $rootScope, $modal, Order, toaster, submitInvoice, $modalInstance, invoiceData, BillSubmit, $state) {
         //公司列表
-        $scope.submitInvoice = []
+        $scope.submitInvoice = [];
 
         //订单数
-        $scope.orderCount = submitInvoice.length || 0
+        $scope.orderCount = submitInvoice.length || 0;
 
         //总金额
-        $scope.allPrice = 0
+        $scope.allPrice = 0;
 
         //发票信息
-        $scope.invoiceData = {}
+        $scope.invoiceData = {};
 
         // 数据处理
         $scope.dealData = function () {
-            var submitItem = submitInvoice
-            var temStoreIdArr = []
-            var tmpPriceArr = []
+            var submitItem = submitInvoice;
+            var temStoreIdArr = [];
+            var tmpPriceArr = [];
             angular.forEach(submitItem, function (item) {
-                var index = temStoreIdArr.indexOf(item.storeid)
+                var index = temStoreIdArr.indexOf(item.storeid);
                 if (index == -1) {
-                    temStoreIdArr.push(item.storeid)
-                    tmpPriceArr.push({price: item.price, storeName: item.storeName, orderid: item.orderid})
+                    temStoreIdArr.push(item.storeid);
+                    tmpPriceArr.push({price: item.price, storeName: item.storeName, orderid: item.orderid});
                 } else {
-                    tmpPriceArr[index].price += item.price
+                    tmpPriceArr[index].price += item.price;
                 }
             })
             angular.forEach(tmpPriceArr, function (item, index) {
-                $scope.submitInvoice.push(tmpPriceArr[index])
-                $scope.allPrice += tmpPriceArr[index].price
+                $scope.submitInvoice.push(tmpPriceArr[index]);
+                $scope.allPrice += tmpPriceArr[index].price;
             })
         }
-        $scope.dealData()
+        $scope.dealData();
 
-        $scope.hasSpecial = false
-        $scope.hasNormal = false
+        $scope.hasSpecial = false;
+        $scope.hasNormal = false;
 
         $scope.getInvoiceData = function (invoiceKind) {
-            var tmpInvoice = invoiceData
+            var tmpInvoice = invoiceData;
             if (!invoiceKind) {
                 if (tmpInvoice.length == 1) {
-                    $scope.invoiceData = tmpInvoice[0]
+                    $scope.invoiceData = tmpInvoice[0];
                     if (tmpInvoice[0].kind == 1205) {
-                        $scope.hasSpecial = true
+                        $scope.hasSpecial = true;
                     } else if (tmpInvoice[0].kind == 1206) {
-                        $scope.hasNormal = true
+                        $scope.hasNormal = true;
                     }
                 } else if (tmpInvoice.length > 1) {
-                    $scope.getInvoiceData(1206)
+                    $scope.getInvoiceData(1206);
                 }
             } else {
                 angular.forEach(tmpInvoice, function (item) {
                     if (item.kind == 1205) {
-                        $scope.hasSpecial = true
+                        $scope.hasSpecial = true;
                     }
 
                     if (item.kind == 1206) {
-                        $scope.hasNormal = true
+                        $scope.hasNormal = true;
                     }
 
                     if (item.kind == invoiceKind) {
-                        $scope.invoiceData = item
+                        $scope.invoiceData = item;
                     }
                 })
             }
@@ -208,25 +208,27 @@ define([ 'app/app' ], function(app) {
        //     return {}
         }
 
-        $scope.getInvoiceData()
+        $scope.getInvoiceData();
+        // console.log($scope.invoiceData);
 
         //关闭模态框
         $scope.closeModal = function () {
-            $modalInstance.dismiss()
+            $modalInstance.dismiss();
         }
 
         //提交申请
         $scope.apply = function () {
-            var orderids = ''
+            var orderids = '';
             angular.forEach($scope.submitInvoice, function (item) {
-                orderids += item.orderid + ','
+                orderids += item.orderid + ',';
             })
             orderids = orderids.substring(0, orderids.length-1)
             BillSubmit.submitBillApply(null, {orderids: orderids, invoiceid: $scope.invoiceData.id}, function (data) {
-                toaster.pop('success', '申请发票成功')
-                $scope.closeModal()
+                toaster.pop('success', '申请发票成功');
+                $scope.closeModal();
+                $state.reload();
             },function (error) {
-                toaster.pop('error', '申请发票失败')
+                toaster.pop('error', '申请发票失败');
             })
         }
 

+ 1 - 0
src/main/webapp/resources/js/vendor/controllers/forstore/vendor_invoice_ctrl.js

@@ -65,6 +65,7 @@ define([ 'app/app' ], function(app) {
                         //划分数据
                         $scope.billData = page.content;
                         //初始化选中状态和地址信息
+                        $scope.isAllCheck = false;
                         angular.forEach($scope.billData, function (item) {
                             var temAddr = item.invoiceAddress.split(',')
                             item.detailAddr = temAddr[3]

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

@@ -361,6 +361,12 @@
     .radioLabel input[type="radio"]{
         display: none;
     }
+    #bill-info .form-area .input-file-default {
+        width: 75px;
+    }
+    .ticket_record_list dl dd:last-child {
+        border-bottom: none;
+    }
 </style>
 <!--右侧主体部分-->
 <div class="user_right fr u_c_invoice">
@@ -454,9 +460,9 @@
                     <div class="form-group">
                         <label class="col-md-2 control-label"><b class="text-inverse">*</b>发票抬头:</label>
                         <div class="col-md-5">
-                            <input type="text" class="form-control" ng-model="bill.head" ng-focus="form.billHead.$touched = false" ng-blur="form.billHead.$touched = true" name="billHead" ng-maxlength="100" required="required" placeholder="请输入发票抬头">
+                            <input type="text" class="form-control" ng-model="bill.head" ng-focus="form.billHead.$touched = false" ng-blur="form.billHead.$touched = true; checkBillHead()" name="billHead" required="required" placeholder="请输入发票抬头">
                         </div>
-                        <div class="text-inverse error col-md-3" ng-show="form.billHead.$touched&&form.billHead.$invalid" ng-bind="form.billHead.$error.required?'请填写发票抬头':'请勿超过50个字'"></div>
+                        <div class="text-inverse error col-md-3" ng-show="form.billHead.$touched&&(form.billHead.$invalid || !validForm.validBillHead)" ng-bind="form.billHead.$error.required?'请填写发票抬头':'请勿超过50个字'"></div>
                     </div>
                     <div class="form-group" ng-if="billType == 1205">
                         <label class="col-md-2 control-label"><b class="text-inverse">*</b>单位地址:</label>
@@ -482,9 +488,9 @@
                     <div class="form-group"  ng-if="billType == 1205">
                         <label class="col-md-2 control-label"><b class="text-inverse">*</b>开户银行:</label>
                         <div class="col-md-5">
-                            <input type="text" class="form-control" ng-model="bill.bankName" ng-focus="form.bankName.$touched = false" ng-blur="form.bankName.$touched = true" name="bankName" required="required" ng-maxlength="60" placeholder="请输入开户银行">
+                            <input type="text" class="form-control" ng-model="bill.bankName" ng-focus="form.bankName.$touched = false" ng-blur="form.bankName.$touched = true; checkBankName()" name="bankName" required="required" placeholder="请输入开户银行">
                         </div>
-                        <div class="text-inverse error col-md-3" ng-show="form.bankName.$touched&&form.bankName.$invalid" ng-bind="form.bankName.$error.required?'请填写开户银行':'请勿超过30个字'"></div>
+                        <div class="text-inverse error col-md-3" ng-show="form.bankName.$touched&&(form.bankName.$invalid || !validForm.validBankName)" ng-bind="form.bankName.$error.required?'请填写开户银行':'请勿超过30个字'"></div>
                     </div>
                     <div class="form-group"  ng-if="billType == 1205">
                         <label class="col-md-2 control-label"><b class="text-inverse">*</b>开户银行账户:</label>
@@ -496,17 +502,17 @@
                     <div class="form-group"  ng-if="billType == 1205">
                         <label class="col-md-2 control-label"><b class="text-inverse">*</b>上传开户许可证:</label>
                         <div class="col-md-4">
-                            <input type="text" class="form-control" readonly style="background: #fff">
+                            <input type="text" name="permission" required class="form-control" ng-model="bill.attachUrl" readonly style="background: #fff">
                         </div>
-                        <div class="col-md-1"><input type="file" ng-model="bill.permission" name="permission" ng-multiple="false" accept="image/gif,image/jpeg,image/jpg,image/png,image/svg,application/pdf,*.pdf" required></div>
-                        <div class="text-inverse error col-md-3" ng-show="(bill.permission||form.permission.$touched)&&(form.permission.$invalid)">请上传开户许可证</div>
+                        <div class="col-md-1"><input class="input-file-default" type="file" ng-file-select ng-model="bill.billInfo" ng-change="onUploadPermission()" ng-multiple="false" accept="image/gif,image/jpeg,image/jpg,image/png,image/svg,application/pdf,*.pdf"></div>
+                        <div class="text-inverse error col-md-3" ng-show="(bill.attachUrl||form.permission.$touched)&&(form.permission.$invalid)">请上传开户许可证</div>
                     </div>
                     <div class="form-group">
                         <label class="col-md-2 control-label"><b class="text-inverse">*</b>收票人:</label>
                         <div class="col-md-5">
-                            <input id="mzbillname" type="text" class="form-control" ng-focus="form.billName.$touched = false" ng-blur="form.billName.$touched = true" ng-model="bill.name" name="billName" required="required" ng-maxlength="20" placeholder="请输入收票人">
+                            <input id="mzbillname" type="text" class="form-control" ng-focus="form.billName.$touched = false" ng-blur="form.billName.$touched = true; checkBillName()" ng-model="bill.name" name="billName" required="required" placeholder="请输入收票人">
                         </div>
-                        <div class="text-inverse error col-md-3" ng-show="form.billName.$touched&&(form.billName.$invalid)" ng-bind="form.billName.$error.required?'请填写收票人姓名':'请勿超过10个字'"></div>
+                        <div class="text-inverse error col-md-3" ng-show="form.billName.$touched&&(form.billName.$invalid || !validForm.validBillName)" ng-bind="form.billName.$error.required?'请填写收票人姓名':'请勿超过10个字'"></div>
                     </div>
                     <div class="form-group">
                         <label class="col-md-2 control-label"><b class="text-inverse">*</b>联系电话:</label>
@@ -561,7 +567,7 @@
                         </div>
                         <div class="form-btn">
                             <input type="button" value="取消" class="btn" ng-click="setChangeBillStatusFlag(false)">
-                            <input type="submit" value="保存" class="btn" ng-disabled="form.$invalid||(!bill.is_agree)" ng-click="saveBill()">
+                            <input type="submit" value="保存" class="btn" ng-disabled="form.$invalid||(!bill.is_agree)||(!checkValidFrom())" ng-click="saveBill()">
                         </div>
                     </div>
                 </form>

+ 1 - 1
src/main/webapp/resources/view/usercenter/modal/apply-invoice.html

@@ -202,7 +202,7 @@
             </div>
             <div class="row">
                 <div class="col-md-4">收票地址</div>
-                <div class="col-md-8" ng-bind="invoiceData.area"></div>
+                <div class="col-md-8" ng-bind="invoiceData.area + ',' + invoiceData.detailAddress"></div>
             </div>
         </div>
         <div class="deal-btn">

+ 1 - 1
src/main/webapp/resources/view/vendor/forstore/vendor-invoice.html

@@ -387,7 +387,7 @@
         <a ng-click=""><i class="fa fa-close fa-lg"></i></a>
     </div>
     <div class="content">
-        <p><i class="fa fa-exclamation-circle"></i>点击【确认】系统将通知买家发票
+        <p><i ng-click="setShowSubmitBox(false)" class="fa fa-exclamation-circle"></i>点击【确认】系统将通知买家发票
             <br/>已寄出,否则请点击【取消】</p>
         <div><a ng-click="setShowSubmitBox(false)">取消</a><a ng-click="doSubmit()">确认</a></div>
     </div>