增加人脸识别图像功能

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 data: params
}) })
} }
export function reqUploadImg(params) {
return request({
url: 'sys/oss/uploadImg',
method: 'post',
data: params
})
}

View File

@ -37,7 +37,7 @@
<script> <script>
import _ from 'lodash' import _ from 'lodash'
import { reqUploadFile } from '@/api/sys/upload' import { reqUploadFile, reqUploadImg } from '@/api/sys/upload'
function getBase64(file) { function getBase64(file) {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
const reader = new FileReader() const reader = new FileReader()
@ -70,7 +70,12 @@ export default {
accept: { accept: {
type: String, type: String,
default: 'image/*' // ,* default: 'image/*' // ,*
} },
//
fileSize:{
type:Number,
default:500
},
}, },
model: { model: {
prop: 'value', prop: 'value',
@ -96,8 +101,28 @@ export default {
// //
uploadFile(data) { uploadFile(data) {
const { max } = this const { max } = this
const { type } = this
const formData = new FormData() const formData = new FormData()
formData.append('file', data.file) formData.append('file', data.file)
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)
}
})
} else {
reqUploadFile(formData).then(res => { reqUploadFile(formData).then(res => {
if (res.code === 200) { if (res.code === 200) {
const file = { const file = {
@ -114,6 +139,7 @@ export default {
this.$emit('change', list) this.$emit('change', list)
} }
}) })
}
}, },
// //
handlerRemove(file) { handlerRemove(file) {

View File

@ -186,7 +186,7 @@
label="身份证正面" label="身份证正面"
:labelCol="labelCol" :labelCol="labelCol"
:wrapperCol="wrapperCol"> :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-item>
</a-form> </a-form>
</a-col> </a-col>
@ -196,7 +196,21 @@
label="身份证反面" label="身份证反面"
:labelCol="labelCol" :labelCol="labelCol"
:wrapperCol="wrapperCol"> :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-item>
</a-form> </a-form>
</a-col> </a-col>
@ -239,7 +253,8 @@
degreeData: [], degreeData: [],
typeData: [], typeData: [],
fileList: [], fileList: [],
fileList2: [] fileList2: [],
fileList3: []
} }
}, },
mounted () { mounted () {
@ -293,6 +308,13 @@
} }
if (data.idPhotoBack) { if (data.idPhotoBack) {
this.fileList2 = JSON.parse(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( this.form.setFieldsValue(
{ {
@ -350,6 +372,7 @@
values.type = values.type.join(',') values.type = values.type.join(',')
values.idPhotoFace = JSON.stringify(this.fileList) values.idPhotoFace = JSON.stringify(this.fileList)
values.idPhotoBack = JSON.stringify(this.fileList2) values.idPhotoBack = JSON.stringify(this.fileList2)
if (this.fileList3.length > 0) values.avatar = this.fileList3[0].url
personAddOrUpdate(values).then((res) => { personAddOrUpdate(values).then((res) => {
this.confirmLoading = false this.confirmLoading = false
if (res.code === 200) { if (res.code === 200) {
@ -411,6 +434,7 @@
this.form.resetFields() this.form.resetFields()
this.fileList = [] this.fileList = []
this.fileList2 = [] this.fileList2 = []
this.fileList3 = []
this.visible = false this.visible = false
} }
} }