|
|
@@ -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>
|