人员管理(劳务人员):新增上传现场采集人脸压缩逻辑
This commit is contained in:
parent
127eac97b1
commit
a5fc697513
@ -1534,7 +1534,9 @@
|
||||
:show-file-list="false"
|
||||
:file-list="idCardUpPhotoFile"
|
||||
:disabled="titleType == 'detail'"
|
||||
:http-request="handleUpload"
|
||||
:http-request="
|
||||
(val) => handleUpload(val, 'idCardAvatar')
|
||||
"
|
||||
>
|
||||
<el-button
|
||||
size="medium"
|
||||
@ -1587,18 +1589,14 @@
|
||||
</div>
|
||||
<el-upload
|
||||
class="upload-demo"
|
||||
:action="uploadUrl"
|
||||
action="uploadUrl"
|
||||
:on-remove="(file) => handleRemove(file, 7)"
|
||||
:on-success="
|
||||
(res, file, filelist) => handleSuccess(res, 7, file)
|
||||
"
|
||||
:on-error="(file) => handleError(file, 7)"
|
||||
:on-preview="(file) => handlePreview(file, 7)"
|
||||
:before-upload="(file) => handleBeforeUpload(file, 7)"
|
||||
name="files"
|
||||
:file-list="fieldAcquisitionFile"
|
||||
:disabled="titleType == 'detail'"
|
||||
:show-file-list="false"
|
||||
:http-request="(val) => handleUpload(val, 'livesFace')"
|
||||
>
|
||||
<el-button
|
||||
size="medium"
|
||||
@ -2239,29 +2237,39 @@ export default {
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
handleUpload(params) {
|
||||
const file = params.file
|
||||
if (
|
||||
file.type != 'image/jpeg' &&
|
||||
file.type != 'image/png' &&
|
||||
file.type != 'image/jpg' &&
|
||||
file.type != 'image/bmp'
|
||||
) {
|
||||
this.$message.error(this.$t('message.companyDiagram.uploadMsg')) //只能上传图片
|
||||
return false
|
||||
}
|
||||
|
||||
handleUpload(fileData, type) {
|
||||
const file = fileData.file
|
||||
// 压缩图片
|
||||
lrz(file, { quality: 1 }).then((result) => {
|
||||
const formData = new FormData()
|
||||
formData.append('files', result.file)
|
||||
// 图片上传
|
||||
apiUploadImage(formData).then((res) => {
|
||||
if (res.code == 200 || res.status == 'SUCCESS') {
|
||||
const imgInfo = res.data[0]
|
||||
this.personForm.idCardBigPhotoUrl = imgInfo.imageUrl
|
||||
this.idCardUpPhotoFile = [
|
||||
{ name: imgInfo.filename, url: imgInfo.imageUrl }
|
||||
]
|
||||
|
||||
switch (type) {
|
||||
case 'idCardAvatar': // 身份证头像
|
||||
this.personForm.idCardBigPhotoUrl = imgInfo.imageUrl
|
||||
this.idCardUpPhotoFile = [
|
||||
{ name: imgInfo.filename, url: imgInfo.imageUrl }
|
||||
]
|
||||
break
|
||||
case 'livesFace': // 现场采集人脸
|
||||
let imgStatus = result.file.size / 1024 < 500
|
||||
if (!imgStatus) {
|
||||
this.cropperOption.img =
|
||||
this.$store.state.FILEURL + imgInfo.imageUrl
|
||||
this.cropperDialog = true
|
||||
} else {
|
||||
if (this.isSzProject == 1) {
|
||||
this.checkImgLibrary(imgInfo.imageUrl)
|
||||
} else {
|
||||
this.checkFace(imgInfo.imageUrl)
|
||||
}
|
||||
}
|
||||
break
|
||||
}
|
||||
}
|
||||
})
|
||||
})
|
||||
@ -3344,18 +3352,8 @@ export default {
|
||||
this.$message.error(this.$t('message.companyDiagram.hint8'))
|
||||
return false
|
||||
}
|
||||
} else {
|
||||
// if(type==7){
|
||||
// const isLt2M = file.size / 1024 < 500;
|
||||
// if (!isLt2M) {
|
||||
// this.$message.error('现场采集照图片大小不能超过 500kb!');
|
||||
// }
|
||||
// return isLt2M;
|
||||
// }else{
|
||||
// return true;
|
||||
// }
|
||||
return true
|
||||
}
|
||||
return true
|
||||
},
|
||||
|
||||
//删除 身份证头像 或 现场采集照片
|
||||
@ -3499,21 +3497,6 @@ export default {
|
||||
arrJoin.push(data)
|
||||
}
|
||||
this.personForm.employmentCard = arrJoin.join(',')
|
||||
} else if (type == 6) {
|
||||
this.personForm.idCardBigPhotoUrl = obj.url
|
||||
this.idCardUpPhotoFile = [obj]
|
||||
} else if (type == 7) {
|
||||
let imgStatus = file2.size / 1024 < 500
|
||||
if (!imgStatus) {
|
||||
this.cropperOption.img = this.$store.state.FILEURL + obj.url
|
||||
this.cropperDialog = true
|
||||
} else {
|
||||
if (this.isSzProject == 1) {
|
||||
this.checkImgLibrary(file.data[0].imageUrl)
|
||||
} else {
|
||||
this.checkFace(file.data[0].imageUrl)
|
||||
}
|
||||
}
|
||||
} else if (type == 8) {
|
||||
console.log(file)
|
||||
let data = {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user