司机,车辆 添加ocr 识别
This commit is contained in:
@ -11,7 +11,76 @@
|
||||
@click-left="h5GoBack"
|
||||
/>
|
||||
</div>
|
||||
<cell-group label="司机姓名" placeholder="请输入司机姓名" v-model="driverName" :disabled="supplierType ==1 ? true:false"/>
|
||||
<div class="itemContent">
|
||||
<div class="titleType">
|
||||
<img class="startImg" src="@/assets/start.png" />
|
||||
<span>身份证正面</span>
|
||||
</div>
|
||||
<van-uploader
|
||||
v-model="identityCardFrontList"
|
||||
:after-read="identityCardFrontHandler"
|
||||
max-count="1"
|
||||
:preview-size="54"
|
||||
accept="image "
|
||||
/>
|
||||
</div>
|
||||
<div class="lineBot"></div>
|
||||
<div class="itemContent">
|
||||
<div class="titleType">
|
||||
<img class="startImg" src="@/assets/start.png" />
|
||||
<span>身份证反面</span>
|
||||
</div>
|
||||
<van-uploader
|
||||
v-model="identityCardContraryList"
|
||||
:after-read="identityCardBackHandler"
|
||||
max-count="1"
|
||||
:preview-size="54"
|
||||
accept="image "
|
||||
/>
|
||||
</div>
|
||||
<div class="lineBot"></div>
|
||||
<div class="itemContent">
|
||||
<div class="titleType">
|
||||
<img class="startImg" src="@/assets/start.png" />
|
||||
<span>驾驶证主页</span>
|
||||
</div>
|
||||
<van-uploader
|
||||
v-model="drivingLicenceFrontList"
|
||||
:after-read="drivingLicenceFrontHandler"
|
||||
max-count="1"
|
||||
:preview-size="54"
|
||||
accept="image "
|
||||
/>
|
||||
</div>
|
||||
<div class="lineBot"></div>
|
||||
<div class="itemContent">
|
||||
<div class="titleType">
|
||||
<img class="startImg" src="@/assets/start.png" />
|
||||
<span>驾驶证副页</span>
|
||||
</div>
|
||||
<van-uploader
|
||||
v-model="drivingLicenceContraryList"
|
||||
:after-read="drivingLicenceContraryHandler"
|
||||
max-count="1"
|
||||
:preview-size="54"
|
||||
accept="image "
|
||||
/>
|
||||
</div>
|
||||
<div class="lineBot"></div>
|
||||
<div class="itemContent">
|
||||
<div class="titleType">
|
||||
<span>头像</span>
|
||||
</div>
|
||||
<van-uploader
|
||||
v-model="iconList"
|
||||
:after-read="iconListHandler"
|
||||
max-count="1"
|
||||
:preview-size="54"
|
||||
accept="image "
|
||||
/>
|
||||
</div>
|
||||
<div class="lineBot"></div>
|
||||
<cell-group label="司机姓名" placeholder="请输入司机姓名" v-model="driverName" aria-readonly="true" :disabled="supplierType ==1 ? true:false"/>
|
||||
<cell-group label="手机号码" v-model="driverPhone" placeholder="请输入手机号" />
|
||||
<cell-group label="身份证号" v-model="identityCardNumber" placeholder="请输入身份证号" />
|
||||
<div class="itemContent">
|
||||
@ -63,7 +132,7 @@
|
||||
|
||||
<script>
|
||||
import {myMixins} from "@/utils/myMixins"
|
||||
import {saveDriver} from "@/api/mine"
|
||||
import {saveDriver, uploadImage, ocrHandler} from "@/api/mine"
|
||||
import TwoCommonBtn from "@/components/twoBtnCommon.vue"
|
||||
import CellGroup from "@/components/cellGroup.vue"
|
||||
export default {
|
||||
@ -80,7 +149,19 @@ export default {
|
||||
activeIcon: require('@/assets/check.png'),
|
||||
inactiveIcon: require('@/assets/uncheck.png'),
|
||||
supplierType:'',
|
||||
createTime:''
|
||||
createTime:'',
|
||||
identityCardFront: '', // 身份证正面
|
||||
identityCardFrontList: [], // 身份证正面 列表
|
||||
identityCardContrary: '', // 身份证反面
|
||||
identityCardContraryList: [], // 身份证反面 列表
|
||||
drivingLicenceFront: '', // 驾驶证正面
|
||||
drivingLicenceFrontList: [], // 驾驶证正面 列表
|
||||
drivingLicenceContrary: '', // 驾驶证反面
|
||||
drivingLicenceContraryList: [], // 驾驶证反面 列表
|
||||
icon: '',
|
||||
iconList: [],
|
||||
driverInfo: {},
|
||||
drivingLicenceName: '',
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
@ -92,6 +173,20 @@ export default {
|
||||
this.states = this.$route.params?.states;
|
||||
this.supplierType=this.$route.params?.supplierType;
|
||||
this.createTime=this.$route.params?.createTime;
|
||||
this.driverInfo.drivingBeginDate = this.$route.params?.drivingBeginDate;
|
||||
this.drivingLicenceContrary = this.$route.params?.drivingLicenceContrary;
|
||||
this.drivingLicenceFront = this.$route.params?.drivingLicenceFront;
|
||||
this.driverInfo.drivingLicenceValidityDate = this.$route.params?.drivingLicenceValidityDate;
|
||||
this.icon = this.$route.params?.icon;
|
||||
this.identityCardContrary = this.$route.params?.identityCardContrary;
|
||||
this.identityCardFront = this.$route.params?.identityCardFront;
|
||||
this.driverInfo.lssueDate = this.$route.params?.lssueDate;
|
||||
this.drivingLicenceName = this.$route.params?.drivingLicenceName;
|
||||
this.identityCardFrontList = [{ url : this.identityCardFront }];
|
||||
this.identityCardContraryList = [{ url : this.identityCardContrary }];
|
||||
this.drivingLicenceFrontList = [{ url : this.drivingLicenceFront }];
|
||||
this.drivingLicenceContraryList = [{ url : this.drivingLicenceContrary }];
|
||||
this.iconList = [{ url : this.icon }];
|
||||
const selectElement = document.getElementById('mySelect');
|
||||
selectElement.addEventListener('change', function() {
|
||||
const selectedValue = selectElement.value;
|
||||
@ -103,25 +198,122 @@ export default {
|
||||
isUse(e){
|
||||
this.states=e
|
||||
},
|
||||
async submitBtn(){
|
||||
await saveDriver({
|
||||
driverId:this.id ? this.id : '',
|
||||
driverName:this.driverName ,
|
||||
driverPhone:this.driverPhone,
|
||||
identityCardNumber:this.identityCardNumber,
|
||||
drivingModel:this.drivingModel,
|
||||
states:Number(this.states),
|
||||
createTime:this.createTime || ''
|
||||
})
|
||||
if(this.id){
|
||||
this.$toast('修改成功')
|
||||
}else{
|
||||
this.$toast('添加成功')
|
||||
async identityCardFrontHandler(file) { // 上传身份证正面照片
|
||||
const formData = new FormData();
|
||||
formData.append("file" , file.file);
|
||||
let res = await uploadImage(formData)
|
||||
this.identityCardFront = res.data;
|
||||
await this.idCardOcrHandler();
|
||||
},
|
||||
async identityCardBackHandler(file) { // 上传身份证反面照片
|
||||
const formData = new FormData();
|
||||
formData.append("file" , file.file);
|
||||
let res = await uploadImage(formData)
|
||||
this.identityCardContrary = res.data;
|
||||
},
|
||||
async drivingLicenceFrontHandler(file) { // 上传驾驶证主页
|
||||
const formData = new FormData();
|
||||
formData.append("file" , file.file);
|
||||
let res = await uploadImage(formData)
|
||||
this.drivingLicenceFront = res.data;
|
||||
await this.drivingLicenceOcrHandler();
|
||||
},
|
||||
async drivingLicenceContraryHandler(file) { // 上传驾驶证副页
|
||||
const formData = new FormData();
|
||||
formData.append("file" , file.file);
|
||||
let res = await uploadImage(formData)
|
||||
this.drivingLicenceContrary = res.data;
|
||||
},
|
||||
async iconListHandler(file) { // 上传头像
|
||||
const formData = new FormData();
|
||||
formData.append("file" , file.file);
|
||||
let res = await uploadImage(formData)
|
||||
this.icon = res.data;
|
||||
},
|
||||
async idCardOcrHandler() { // 身份证正面 ocr识别
|
||||
let res = await ocrHandler({
|
||||
ocrType: 1,
|
||||
imageUrl: this.identityCardFront,
|
||||
cardSide: 'FRONT'
|
||||
})
|
||||
this.driverName = res?.data?.name;
|
||||
this.identityCardNumber = res?.data?.idNum;
|
||||
if( this.drivingLicenceName && this.driverName != this.drivingLicenceName ) {
|
||||
this.$toast('身份证信息与驾驶证信息不匹配')
|
||||
}
|
||||
},
|
||||
async drivingLicenceOcrHandler() { // 驾驶证正面 ocr识别
|
||||
let res = await ocrHandler({
|
||||
ocrType: 2,
|
||||
imageUrl: this.drivingLicenceFront,
|
||||
cardSide: 'FRONT'
|
||||
});
|
||||
if( res?.data ) {
|
||||
this.driverInfo.drivingBeginDate = res?.data?.dateOfFirstIssue;
|
||||
this.driverInfo.lssueDate = res?.data?.dateOfFirstIssue ? (res?.data?.dateOfFirstIssue + ' 00:00:00') : '';
|
||||
this.driverInfo.drivingLicenceValidityDate = res?.data?.endDate;
|
||||
this.drivingModel = res.data?.class_;
|
||||
this.drivingLicenceName = res.data?.name
|
||||
if( this.driverName && this.drivingLicenceName != this.driverName ) {
|
||||
this.$toast('身份证信息与驾驶证信息不匹配')
|
||||
}
|
||||
}
|
||||
},
|
||||
async submitBtn(){
|
||||
if(!this.identityCardFront) {
|
||||
this.$toast('身份证正面照未上传')
|
||||
return
|
||||
}
|
||||
if(!this.identityCardContrary) {
|
||||
this.$toast('身份证反面照未上传')
|
||||
return
|
||||
}
|
||||
if(!this.drivingLicenceFront) {
|
||||
this.$toast('驾驶证首页未上传')
|
||||
return
|
||||
}
|
||||
if(!this.drivingLicenceContrary) {
|
||||
this.$toast('驾驶证副页未上传')
|
||||
return
|
||||
}
|
||||
if( this.drivingLicenceName != this.driverName ) {
|
||||
this.$toast('身份证信息与驾驶证信息不匹配')
|
||||
return
|
||||
}
|
||||
if( this.driverInfo.drivingLicenceValidityDate ) {
|
||||
if( new Date(this.driverInfo.drivingLicenceValidityDate).getTime() < new Date().getTime() ) {
|
||||
this.$toast('驾驶证已过期')
|
||||
return
|
||||
}
|
||||
} else {
|
||||
this.$toast('驾驶证信息识别错误,请重新上传')
|
||||
return
|
||||
}
|
||||
await saveDriver({
|
||||
driverId:this.id ? this.id : '',
|
||||
driverName:this.driverName ,
|
||||
driverPhone:this.driverPhone,
|
||||
identityCardNumber:this.identityCardNumber,
|
||||
drivingModel:this.drivingModel,
|
||||
states:Number(this.states),
|
||||
createTime:this.createTime || '',
|
||||
identityCardFront: this.identityCardFront,
|
||||
identityCardContrary: this.identityCardContrary,
|
||||
drivingLicenceFront: this.drivingLicenceFront,
|
||||
drivingLicenceContrary: this.drivingLicenceContrary,
|
||||
icon: this.icon,
|
||||
drivingLicenceName: this.drivingLicenceName,
|
||||
...this.driverInfo
|
||||
})
|
||||
if(this.id){
|
||||
this.$toast('修改成功')
|
||||
}else{
|
||||
this.$toast('添加成功')
|
||||
}
|
||||
setTimeout(()=>{
|
||||
this.$router.back();
|
||||
},2000)
|
||||
},
|
||||
},
|
||||
},
|
||||
components:{
|
||||
TwoCommonBtn,
|
||||
@ -137,6 +329,8 @@ export default {
|
||||
@include wh(100%,100%);
|
||||
box-sizing: border-box;
|
||||
padding-left: 16px;
|
||||
padding-bottom: 100px;
|
||||
overflow-y: auto;
|
||||
}
|
||||
.mySelect{
|
||||
@include fontWeightSize(bold,13px);
|
||||
|
Reference in New Issue
Block a user