司机,车辆 添加ocr 识别

This commit is contained in:
2024-04-07 16:57:44 +08:00
parent 8891738455
commit 867cbee6c7
5 changed files with 394 additions and 32 deletions

View File

@ -12,6 +12,46 @@
/>
</div>
<div class="addContentWrap">
<div class="itemContent">
<div class="titleType">
<img class="startImg" src="@/assets/start.png" />
<span>行驶证首页</span>
</div>
<van-uploader
v-model="vehicleLicenseFrontList"
:after-read="vehicleLicenseFrontHandler"
max-count="1"
:preview-size="54"
accept="image "
/>
</div>
<div class="itemContent">
<div class="titleType">
<img class="startImg" src="@/assets/start.png" />
<span>行驶证副页</span>
</div>
<van-uploader
v-model="vehicleLicenseBackList"
:after-read="vehicleLicenseBackHandler"
max-count="1"
:preview-size="54"
accept="image "
/>
</div>
<div class="itemContent">
<div class="titleType">
<img class="startImg" src="@/assets/start.png" />
<span>车头照</span>
</div>
<van-uploader
v-model="vehicleFrontPhotoList"
:after-read="vehicleFrontPhotoHandler"
max-count="1"
:preview-size="54"
accept="image "
/>
</div>
<cell-group label="车牌号" placeholder="请输入车牌号" v-model="carNum" />
<div class="itemContent">
<div class="titleType">
@ -78,8 +118,9 @@
</template>
<script>
// uploadImage
import {myMixins} from "@/utils/myMixins"
import {vehicleTypeList,saveVehicle,getInfoById,supplierServiceTree} from "@/api/mine"
import {vehicleTypeList,saveVehicle,getInfoById,supplierServiceTree, uploadImage, ocrHandler} from "@/api/mine"
import TwoCommonBtn from "@/components/twoBtnCommon.vue"
import CellGroup from "@/components/cellGroup.vue";
export default {
@ -100,7 +141,14 @@ export default {
serviceIds:[],//车辆服务种类,
supplierServiceList:[],
show:false,
imageUrl: require('@/assets/arr_right.png')
imageUrl: require('@/assets/arr_right.png'),
vehicleLicenseFrontList: [],
vehicleLicenseBackList: [],
vehicleFrontPhotoList: [],
vehicleLicenseFront: '', // 行驶证首页
vehicleLicenseBack: '', // 行驶证副页
vehicleFrontPhoto: '', // 车头照
vehicleLicenseInfo: {},
}
},
async mounted() {
@ -116,6 +164,66 @@ export default {
await this.getSupplierServiceTree();
},
methods:{
async vehicleLicenseFrontHandler(file) { // 上传 行驶证首页
const formData = new FormData();
formData.append("file" , file.file);
let res = await uploadImage(formData)
this.vehicleLicenseFront = res.data;
await this.vehicleOcrHandler();
},
async vehicleLicenseBackHandler(file) { // 上传 行驶证副页
const formData = new FormData();
formData.append("file" , file.file);
let res = await uploadImage(formData);
this.vehicleLicenseBack = res.data;
await this.vehicleBackOcrHandler();
},
async vehicleFrontPhotoHandler(file) { // 上传 车头照
const formData = new FormData();
formData.append("file" , file.file);
let res = await uploadImage(formData);
this.vehicleFrontPhoto = res.data;
},
async vehicleOcrHandler() { // 行驶证首页 ocr 识别
let res = await ocrHandler({
ocrType: 3,
imageUrl: this.vehicleLicenseFront,
cardSide: 'FRONT'
})
if ( res?.data?.frontInfo ) {
let frontInfo = res?.data?.frontInfo;
this.carNum = frontInfo?.plateNo;
this.vehicleLicenseInfo.licensePlateNumber = frontInfo?.plateNo;
this.vehicleLicenseInfo.vehicleType = frontInfo?.vehicleType;
this.vehicleLicenseInfo.owner = frontInfo?.owner;
this.vehicleLicenseInfo.address = frontInfo?.address;
this.vehicleLicenseInfo.useNature = frontInfo?.useCharacter;
this.vehicleLicenseInfo.model = frontInfo?.model;
this.vehicleLicenseInfo.vinCode = frontInfo?.vin;
this.vehicleLicenseInfo.engineNumber = frontInfo?.engineNo;
this.vehicleLicenseInfo.registrationDate = frontInfo?.registerDate;
this.vehicleLicenseInfo.issueDate = frontInfo?.issueDate;
this.vehicleLicenseInfo.issueAuthority = frontInfo?.seal;
}
},
async vehicleBackOcrHandler() { // 行驶证副页 ocr 识别
let res = await ocrHandler({
ocrType: 3,
imageUrl: this.vehicleLicenseBack,
cardSide: 'BACK'
})
if(res?.data?.backInfo) {
let backInfo = res?.data?.backInfo;
this.vehicleLicenseInfo.recordNumber = backInfo?.fileNo;
this.vehicleLicenseInfo.passengerCapacity = backInfo?.allowNum;
this.vehicleLicenseInfo.totalWeight = backInfo?.totalMass;
this.vehicleLicenseInfo.curbWeight = backInfo?.curbWeight;
this.vehicleLicenseInfo.permittedWeight = backInfo?.loadQuality;
this.vehicleLicenseInfo.overallDimension = backInfo?.externalSize;
this.vehicleLicenseInfo.tractionWeight = backInfo?.TotalQuasiMass;
}
console.log('this.vehicle', this.vehicleLicenseInfo)
},
loadAll(i){
// console.log(i)
this.show = !this.show
@ -145,23 +253,54 @@ export default {
let res= await getInfoById({
vehicleId:this.id
})
let result=res.data;
this.id=result.vehicleId
this.carNum=result.plateNumber
this.isJoin=result.hasPolymerization.code
this.selectedOption=result.vehicleType;
this.serviceIds=result.serviceIds
let result=res.data;
this.id=result.vehicleId
this.carNum=result.plateNumber
this.isJoin=result.hasPolymerization.code
this.selectedOption=result.vehicleType;
this.serviceIds=result.serviceIds
this.vehicleLicenseFront = result.vehicleLicenseFront;
this.vehicleLicenseBack = result.vehicleLicenseBack;
this.vehicleFrontPhoto = result.vehicleFrontPhoto;
this.vehicleLicenseInfo = result.vehicleLicenseInfo;
this.vehicleLicenseFrontList = [{ url : this.vehicleLicenseFront }];
this.vehicleLicenseBackList = [{ url : this.vehicleLicenseBack }];
this.vehicleFrontPhotoList = [{ url : this.vehicleFrontPhoto }];
},
isChange(e){
this.isJoin=e
},
async submitBtn(){
if( !this.vehicleLicenseFront ) {
this.$toast('行驶证主页照片不能为空')
return
}
if( !this.vehicleLicenseBack ) {
this.$toast('行驶证副页照片不能为空')
return
}
if( !this.vehicleLicenseBack ) {
this.$toast('车头照片不能为空')
return
}
if( !this.vehicleLicenseInfo.licensePlateNumber ) {
this.$toast('行驶证主页识别失败')
return
}
if( !this.vehicleLicenseInfo.recordNumber ) {
this.$toast('行驶证副页识别失败')
return
}
await saveVehicle({
vehicleId:this.id ? this.id : '',
plateNumber:this.carNum ? this.carNum :'',
vehicleType:this.selectedOption ? this.selectedOption : '',
hasPolymerization:this.isJoin,
serviceIds:this.serviceIds ? this.serviceIds : []
serviceIds:this.serviceIds ? this.serviceIds : [],
vehicleLicenseFront: this.vehicleLicenseFront,
vehicleLicenseBack: this.vehicleLicenseBack,
vehicleFrontPhoto: this.vehicleFrontPhoto,
vehicleLicenseInfo: this.vehicleLicenseInfo,
})
if(this.id){
this.$toast('修改成功')
@ -274,4 +413,4 @@ export default {
margin: 40px 0 30px 8px;
}
}
</style>
</style>