增加人脸识别图像功能

This commit is contained in:
QuAoLi 2022-02-21 14:59:42 +08:00
parent 5597f5c8bf
commit 9d9a4b3487
3 changed files with 76 additions and 19 deletions

View File

@ -7,3 +7,10 @@ export function reqUploadFile(params) {
data: params
})
}
export function reqUploadImg(params) {
return request({
url: 'sys/oss/uploadImg',
method: 'post',
data: params
})
}

View File

@ -37,7 +37,7 @@
<script>
import _ from 'lodash'
import { reqUploadFile } from '@/api/sys/upload'
import { reqUploadFile, reqUploadImg } from '@/api/sys/upload'
function getBase64(file) {
return new Promise((resolve, reject) => {
const reader = new FileReader()
@ -70,7 +70,12 @@ export default {
accept: {
type: String,
default: 'image/*' // ,*
}
},
//
fileSize:{
type:Number,
default:500
},
},
model: {
prop: 'value',
@ -96,24 +101,45 @@ export default {
//
uploadFile(data) {
const { max } = this
const { type } = this
const formData = new FormData()
formData.append('file', data.file)
reqUploadFile(formData).then(res => {
if (res.code === 200) {
const file = {
uid: res.uid,
name: res.name, //
url: res.url
if (type == 'img') {
formData.append('fileSize', this.fileSize)
reqUploadImg(formData).then(res => {
if (res.code === 200) {
const file = {
uid: res.uid,
name: res.name, //
url: res.url
}
const list = [...this.value]
list.push(file)
if (list.length > max) {
this.$message.warning(`最多只能上传${max}个附件`)
return
}
this.$emit('change', list)
}
const list = [...this.value]
list.push(file)
if (list.length > max) {
this.$message.warning(`最多只能上传${max}个附件`)
return
})
} else {
reqUploadFile(formData).then(res => {
if (res.code === 200) {
const file = {
uid: res.uid,
name: res.name, //
url: res.url
}
const list = [...this.value]
list.push(file)
if (list.length > max) {
this.$message.warning(`最多只能上传${max}个附件`)
return
}
this.$emit('change', list)
}
this.$emit('change', list)
}
})
})
}
},
//
handlerRemove(file) {

View File

@ -186,7 +186,7 @@
label="身份证正面"
:labelCol="labelCol"
:wrapperCol="wrapperCol">
<db-upload v-model="fileList" max="1"></db-upload>
<db-upload v-model="fileList" max="1" type='img'></db-upload>
</a-form-item>
</a-form>
</a-col>
@ -196,7 +196,21 @@
label="身份证反面"
:labelCol="labelCol"
:wrapperCol="wrapperCol">
<db-upload v-model="fileList2" max="1"></db-upload>
<db-upload v-model="fileList2" max="1" type='img'></db-upload>
</a-form-item>
</a-form>
</a-col>
</a-row>
<a-divider orientation="left">人脸识别图像</a-divider>
<a-row :gutter="24">
<a-col :md="12" :sm="24">
<a-form :form="form">
<a-form-item
label="图像"
:labelCol="labelCol"
:wrapperCol="wrapperCol">
<db-upload v-model="fileList3" max="1" type='img' fileSize="500"></db-upload>
</a-form-item>
</a-form>
</a-col>
@ -239,7 +253,8 @@
degreeData: [],
typeData: [],
fileList: [],
fileList2: []
fileList2: [],
fileList3: []
}
},
mounted () {
@ -293,6 +308,13 @@
}
if (data.idPhotoBack) {
this.fileList2 = JSON.parse(data.idPhotoBack)
}
if (data.avatar) {
this.fileList3.push({
uid: 1,
name: 'image.jpg',
url: data.avatar
})
}
this.form.setFieldsValue(
{
@ -350,6 +372,7 @@
values.type = values.type.join(',')
values.idPhotoFace = JSON.stringify(this.fileList)
values.idPhotoBack = JSON.stringify(this.fileList2)
if (this.fileList3.length > 0) values.avatar = this.fileList3[0].url
personAddOrUpdate(values).then((res) => {
this.confirmLoading = false
if (res.code === 200) {
@ -411,6 +434,7 @@
this.form.resetFields()
this.fileList = []
this.fileList2 = []
this.fileList3 = []
this.visible = false
}
}