zaijin 2 سال پیش
والد
کامیت
0c5d68dad4

+ 33 - 6
pages/invoiceModule/addInvoice/addInvoice.vue

@@ -132,6 +132,10 @@ export default {
     };
   },
   onLoad(options) {
+    const { invoType } = options;
+    this.form.invoType = invoType;
+  },
+  onShow() {
     uni.getStorage({
       key: 'availableOrderKey',
       success: (res) => {
@@ -139,10 +143,22 @@ export default {
         this.form.amount = total;
         this.form.orderIds = ids;
         this.form.invoType = invoType;
+      },
+      fail: (err) => {
+        uni.showModal({
+          title: '提示',
+          content: '当前页面的订单已经开票完毕,请返回可开票页面',
+          showCancel: false,
+          success: (res) => {
+            if (res.confirm) {
+              uni.redirectTo({
+                url: `/pages/invoiceModule/availableOrder/availableOrder?orderType=${this.form.invoType}`
+              });
+            }
+          }
+        });
       }
     });
-  },
-  onShow() {
     this.getInvoiceHeaderSelect();
   },
   onReady() {
@@ -242,16 +258,27 @@ export default {
             orderIds
           });
           if (code === 200) {
+            uni.removeStorage({
+              key: 'availableOrderKey',
+              success: function (res) {
+                console.log('success');
+              }
+            });
             this.$refs.uToast.show({
               title: '添加成功!',
               type: 'success',
-              duration: 1000,
-              url: '/pages/invoiceModule/invoiceSuccess/invoiceSuccess'
+              duration: 1000
+              // url: '/pages/invoiceModule/invoiceSuccess/invoiceSuccess'
             });
+            setTimeout(() => {
+              uni.redirectTo({
+                url: `/pages/invoiceModule/invoiceSuccess/invoiceSuccess`
+              });
+              uni.hideLoading();
+              this.loading = false;
+            }, 1000);
           }
         } catch (error) {
-          console.error(error);
-        } finally {
           uni.hideLoading();
           this.loading = false;
         }

+ 12 - 3
pages/invoiceModule/availableOrder/availableOrder.vue

@@ -55,7 +55,7 @@ export default {
   },
   watch: {
     currentIds(val) {
-      this.checkedAll = val.length === this.orderList.length;
+      this.checkedAll = val.length === this.orderList.length && val.length !== 0;
     }
   },
   onLoad(options) {
@@ -64,6 +64,14 @@ export default {
       this.queryParams.invoType = orderType;
     }
   },
+  onShow() {
+    // this.orderList = [];
+    // this.currentIds = [];
+    // this.currentList = [];
+    // this.$nextTick(() => {
+    //   this.$refs.paging.reload();
+    // });
+  },
   methods: {
     /**
      * @description: 分页触发
@@ -136,6 +144,7 @@ export default {
           success: () => {
             this.$u.route({
               url: '/pages/invoiceModule/addInvoice/addInvoice',
+              type: 'redirectTo',
               params: {
                 invoType: this.queryParams.invoType
               }
@@ -149,7 +158,7 @@ export default {
         });
       }
     },
-    /** 
+    /**
      * @description: 计算累加精度丢失问题
      * @param {*} arr
      * @return {*}
@@ -157,7 +166,7 @@ export default {
     countSum(arr) {
       if (!arr.length) return 0;
       arr = arr.map((v) => {
-        if (v.amount && !Number.isNaN(Number(v.amount))) return Math.round((v.amount).toFixed(2) * 100);
+        if (v.amount && !Number.isNaN(Number(v.amount))) return Math.round(v.amount.toFixed(2) * 100);
         return 0;
       });
       const result = arr.reduce((prev, curr) => {

+ 5 - 0
pages/invoiceModule/myInvoice/myInvoice.vue

@@ -73,6 +73,11 @@ export default {
   onLoad(options) {
     this.getDict();
   },
+  onShow() {
+    this.$nextTick(() => {
+      this.$refs.paging.reload();
+    })
+  },
   methods: {
     /**
      * @description: 获取字典