Pārlūkot izejas kodu

add:新增发票识别功能

Tang 3 gadi atpakaļ
vecāks
revīzija
07e95a2e8c
2 mainītis faili ar 96 papildinājumiem un 19 dzēšanām
  1. 8 0
      src/newApi/invoice.js
  2. 88 19
      src/views/Marketing/order/bill/index.vue

+ 8 - 0
src/newApi/invoice.js

@@ -31,4 +31,12 @@ export default {
             method: 'get',
         })
     },
+    //发票识别
+    editvatInvoiceOCR(data) {
+        return request({
+            url: '/order/invoice/vatInvoiceOCR',
+            method: 'post',
+            data
+        })
+    },
 }

+ 88 - 19
src/views/Marketing/order/bill/index.vue

@@ -53,6 +53,7 @@
       @handleCurrentChange="handleCurrentChange"
     />
     <el-dialog
+      @closed="loadingClose"
       :visible.sync="auditStatus"
       width="460px"
       :show-close="false"
@@ -142,10 +143,13 @@
       </div>
       <span slot="footer" class="dialog-footer">
         <el-button @click="auditStatus = false">取 消</el-button>
-        <el-button @click="submitAuditForm">确 定</el-button>
+        <el-button @click="submitAuditForm" :loading="disabledBtn"
+          >确 定</el-button
+        >
       </span>
     </el-dialog>
     <el-dialog
+      @closed="loadingClose"
       :visible.sync="billSendStatus"
       width="530px"
       :show-close="false"
@@ -267,10 +271,13 @@
       </div>
       <span slot="footer" class="dialog-footer">
         <el-button @click="billSendStatus = false">取 消</el-button>
-        <el-button @click="billSendForm('billSendData')">确 定</el-button>
+        <el-button @click="billSendForm('billSendData')" :loading="disabledBtn"
+          >确 定</el-button
+        >
       </span>
     </el-dialog>
     <el-dialog
+      @closed="loadingClose"
       :visible.sync="billStatusBox"
       width="460px"
       :show-close="false"
@@ -309,7 +316,9 @@
       </div>
       <span slot="footer" class="dialog-footer">
         <el-button @click="billStatusBox = false">取 消</el-button>
-        <el-button @click="billStatusForm">确 定</el-button>
+        <el-button @click="billStatusForm" :loading="disabledBtn"
+          >确 定</el-button
+        >
       </span>
     </el-dialog>
     <el-dialog
@@ -429,6 +438,7 @@ export default {
   components: { searchBoxNew, tableList, pagination },
   data() {
     return {
+      disabledBtn: false,
       loading: false, //当前表单加载是否加载动画
       navText: {
         title: "发票申请列表",
@@ -601,7 +611,7 @@ export default {
           prop1: "realname",
           prop2: "idCard",
           hidden: true,
-          scope:"realAndIdcard"
+          scope: "realAndIdcard",
         },
         {
           label: "申请主体",
@@ -845,38 +855,71 @@ export default {
     this.search();
   },
   methods: {
+    loadingClose() {
+      this.disabledBtn = false;
+    },
+    /**
+     * 发票申请审核-提交
+     */
     submitAuditForm() {
+      this.disabledBtn = true;
       let data = JSON.parse(JSON.stringify(this.auditData));
-      this.$api.editorderInvoice(data).then((res) => {
-        this.$message.success("提交成功");
-        this.auditStatus = false;
-        this.search();
-      });
+      this.$api
+        .editorderInvoice(data)
+        .then((res) => {
+          this.$message.success("提交成功");
+          this.auditStatus = false;
+          this.search();
+        })
+        .catch(() => {
+          this.disabledBtn = false;
+        });
     },
+    /**
+     * 发票状态标记-提交
+     */
     billStatusForm() {
+      this.disabledBtn = true;
       let data = JSON.parse(JSON.stringify(this.billStatusData));
-      this.$api.editorderInvoice(data).then((res) => {
-        this.$message.success("提交成功");
-        this.billStatusBox = false;
-        this.search();
-      });
+      this.$api
+        .editorderInvoice(data)
+        .then((res) => {
+          this.$message.success("提交成功");
+          this.billStatusBox = false;
+          this.search();
+        })
+        .catch(() => {
+          this.disabledBtn = false;
+        });
     },
+    /**
+     * 上传发票-邮寄发票表单验证及提交
+     */
     billSendForm(formName) {
       var self = this;
       this.$refs[formName].validate((valid) => {
         if (valid) {
+          this.disabledBtn = true;
           let data = JSON.parse(JSON.stringify(self.billSendData));
-          self.$api.editorderInvoice(data).then((res) => {
-            self.$message.success("提交成功");
-            self.billSendStatus = false;
-            self.search();
-          });
+          self.$api
+            .editorderInvoice(data)
+            .then((res) => {
+              self.$message.success("提交成功");
+              self.billSendStatus = false;
+              self.search();
+            })
+            .catch(() => {
+              this.disabledBtn = false;
+            });
         } else {
           console.log("error submit!!");
           return false;
         }
       });
     },
+    /**
+     * 初始化搜索
+     */
     search(int) {
       //   this.loading = true;
       if (int === 1) {
@@ -972,6 +1015,9 @@ export default {
           break;
       }
     },
+    /**
+     * 上传图片
+     */
     getImgFile() {
       var self = this;
       var file = self.$refs.file.files[0];
@@ -993,6 +1039,29 @@ export default {
         .upload(file, 5)
         .then((res) => {
           self.billSendData.invoiceImg = res;
+          /**
+           * 自动识别发票Start
+           */
+          self.$modal.loading("自动识别发票中,请稍后...");
+          self.$api
+            .editvatInvoiceOCR({ imageUrl: res })
+            .then((result) => {
+              if (result.data) {
+                self.billSendData.invoiceCode = result.data.invoiceCode;
+                self.billSendData.invoiceNum = result.data.invoiceNum;
+                self.$message.success("自动识别成功");
+              } else {
+                self.$message.error(
+                  "自动识别失败,请手动输入发票代码及发票号码"
+                );
+              }
+            })
+            .finally(() => {
+              self.$modal.closeLoading();
+            });
+          /**
+           * End
+           */
           self.$refs["billSendData"].validateField("invoiceImg");
         })
         .finally(() => {