xubo 1 年間 前
コミット
caf53a3b19
3 ファイル変更41 行追加8 行削除
  1. BIN
      dist/.DS_Store
  2. 39 6
      src/App.vue
  3. 2 2
      vite.config.js

BIN
dist/.DS_Store


+ 39 - 6
src/App.vue

@@ -1,18 +1,43 @@
 <template>
-  <div>
-    <input type="file" @change="onFileChange" />
+  <div class="form-container">
+    <div>
+      <input type="file" @change="onFileChange"/>
+    </div>
+    <div>
+      <select v-model="selectedType">
+        <option disabled selected>---请选择---</option>
+        <option value="TrainTicket">火车票</option>
+        <option value="TaxiInvoice">出租车发票</option>
+        <option value="QuotaInvoice">定额发票</option>
+        <option value="Invoice">增值税发票</option>
+      </select>
+      金额: <label id="far"></label>   票号:<label id="ticket_number"></label>
+    </div>
     <button @click="uploadFile">Upload</button>
-    <button @click="recognizeOcr">发票识别</button>
+    <!--    <button @click="recognizeOcr">发票识别</button>-->
   </div>
 </template>
 
+<style>
+.form-container {
+  display: flex;
+  flex-direction: column;
+}
+
+.form-container div {
+  margin-bottom: 10px;
+}
+</style>
+
 <script>
 
 import axios from 'axios';
+
 export default {
   data() {
     return {
       selectedFile: null,
+      selectedType: null
     };
   },
   methods: {
@@ -22,6 +47,7 @@ export default {
     uploadFile() {
       const formData = new FormData();
       formData.append('file', this.selectedFile, this.selectedFile.name);
+      formData.append('type', this.selectedType);
 
       axios.post('/api/upload', formData, {
         headers: {
@@ -30,14 +56,21 @@ export default {
       })
           .then(response => {
             console.log(response);
+            // Parse the response object
+            const farValue = response.data.far;
+            const ticketValue = response.data.ticket_number;
+
+            // Render the values on the page
+            document.getElementById('far').textContent = farValue;
+            document.getElementById('ticket_number').textContent = ticketValue;
           })
           .catch(error => {
             console.error(error);
           });
     },
-    recognizeOcr() {
-
-    }
+    // recognizeOcr() {
+    //
+    // }
   }
 };
 </script>

+ 2 - 2
vite.config.js

@@ -12,10 +12,10 @@ export default defineConfig({
     cors: true,
     proxy: {
       '/api': {
-        target: 'https://dev.maxwebx.cn',    // 接口域名,接口服务器地止
+        target: 'http://127.0.0.1:8000',    // 接口域名,接口服务器地止
         changeOrigin: true,
         secure: false,
-        rewrite: (path) => path.replace(/^\/api/, '')
+        // rewrite: (path) => path.replace(/^\/api/, '')
       },
     }
   },