代码调试

This commit is contained in:
BianLzhaoMin 2025-08-14 18:44:55 +08:00
parent 64f549744f
commit 46165424bd
3 changed files with 425 additions and 89 deletions

View File

@ -0,0 +1,247 @@
<template>
<div>
<el-upload
action="#"
:limit="limit"
:auto-upload="false"
:multiple="multiple"
:show-file-list="true"
:on-error="handleError"
:on-exceed="handleExceed"
:file-list="fileListInner"
:on-remove="handleRemove"
:on-change="handleChange"
:before-upload="handleBeforeUpload"
>
<el-button type="text" icon="el-icon-upload"> 点击上传 </el-button>
<div slot="tip" class="el-upload__tip">
{{ uploadTip }}
</div>
</el-upload>
</div>
</template>
<script>
import { getToken } from '@/utils/auth'
export default {
props: {
//
fileList: {
type: Array,
default: () => [],
},
//
uploadFileUrl: {
type: String,
default: '',
},
//
fileType: {
type: Array,
default: ['png', 'jpg', 'jpeg'],
},
//
fileSize: {
type: Number,
default: 10,
},
//
limit: {
type: Number,
default: 1,
},
//
multiple: {
type: Boolean,
default: false,
},
//
isDetail: {
type: Boolean,
default: false,
},
//
isUploaded: {
type: Boolean,
default: false,
},
uploadTip: {
type: String,
default: '请上传文件',
},
},
data() {
return {
// addOrEditForm: {
// fileList: [],
// },
headers: {
Authorization: 'Bearer ' + getToken(),
},
dialogInnerVisible: false,
previewUrl: '',
deleteFileList: [],
}
},
methods: {
//
async handleRemove(file, fileList) {
// if (file.response && file.response.data.length > 0) {
// this.$emit('deleteFile', {
// filePath: file.response.data[0].filePath,
// isNew: true,
// })
// } else {
// if (file.isNew) {
// this.$emit('deleteFile', {
// filePath: file.filePath,
// isNew: true,
// })
// } else {
// this.$emit('deleteFile', {
// filePath: file.filePath,
// isNew: false,
// })
// }
// }
this.$emit('update:fileList', fileList)
},
//
handlePreview(file) {
this.dialogInnerVisible = true
this.previewUrl = file.url
},
//
handleSuccess(response, file, fileList) {
this.$emit('update:fileList', [])
if (response.code === 200) {
this.$emit('update:fileList', fileList)
this.$emit('uploadSuccess')
} else {
this.$modal.msgError('上传失败')
}
this.$modal.closeLoading()
},
//
handleError() {
this.$modal.msgError('上传失败')
this.$modal.closeLoading()
},
//
handleBeforeUpload(file) {
// filename
console.log(file, 'file')
const isFormat = this.fileType.some((e) => file.name.endsWith(e))
if (!isFormat) {
this.$modal.msgError(
`文件格式不正确, 请上传${this.fileType.join(
'、',
)}格式的文件!`,
)
return false
}
//
const isLt = file.size / 1024 / 1024 < this.fileSize
if (!isLt) {
this.$modal.msgError(`图片大小不能超过 ${this.fileSize} MB`)
return false
}
this.$modal.loading('图片正在上传,请稍候...')
// #
const newFileName = file.name.replace(/#/g, '@')
const newFile = new File([file], newFileName, { type: file.type })
// name
Object.defineProperty(file, 'name', {
value: newFileName,
})
return true
},
//
handleExceed(files, fileList) {
this.$modal.msgError(`上传的文件数量不能超过 ${this.limit}`)
},
//
handleChange(file, fileList) {
console.log(file, fileList, 'file, fileList')
const isFormat = this.fileType.some((e) => file.name.endsWith(e))
if (!isFormat) {
this.$modal.msgError(
`文件格式不正确, 请上传${this.fileType.join(
'、',
)}格式的文件!`,
)
this.$emit(
'update:fileList',
fileList.filter((item) => item.uid !== file.uid),
)
return false
}
//
const isLt = file.size / 1024 / 1024 < this.fileSize
if (!isLt) {
this.$modal.msgError(`图片大小不能超过 ${this.fileSize} MB`)
this.$emit(
'update:fileList',
fileList.filter((item) => item.uid !== file.uid),
)
return false
}
// // #
// const newFileName = file.name.replace(/#/g, '@')
// const newFile = new File([file], newFileName, { type: file.type })
// // name
// Object.defineProperty(file, 'name', {
// value: newFileName,
// })
this.$emit('update:fileList', fileList)
},
},
computed: {
fileListInner: {
get() {
return this.fileList
},
set(newValue) {
this.$emit('update:fileList', newValue)
},
},
},
}
</script>
<style scoped lang="scss">
::v-deep .el-upload--picture-card {
position: relative;
margin-right: 10px;
.upload-img-box {
position: absolute;
bottom: -15%;
left: 0;
width: 100%;
height: 100%;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
}
}
::v-deep .upload-img .el-upload--picture-card {
display: none;
}
</style>

View File

@ -151,7 +151,7 @@
</el-form-item> </el-form-item>
</el-col> </el-col>
<el-col :span="12"> <el-col :span="12">
<el-form-item label="人脸照片" prop="businessAddress"> <el-form-item label="人脸照片" prop="faceImg">
<UploadImgFormData <UploadImgFormData
:limit="1" :limit="1"
:file-size="10" :file-size="10"
@ -310,20 +310,14 @@
v-for="item in contractImageList" v-for="item in contractImageList"
:key="item.title" :key="item.title"
> >
<UploadImg <UploadImgFormData
:limit="30" :limit="1"
:file-size="10" :file-size="10"
:multiple="true" :multiple="true"
:is-detail="formType === 2" :is-detail="formType === 2"
:file-type="['jpg', 'png', 'jpeg']" :file-type="['jpg', 'png', 'jpeg']"
:upload-file-url="uploadFileUrl" :file-list.sync="item.fileList"
:file-list.sync=" :is-uploaded="item.fileList.length >= 1"
addOrEditForm.businessLicense
"
:is-uploaded="
addOrEditForm.businessLicense.length >=
2
"
/> />
<span> {{ item.title }} </span> <span> {{ item.title }} </span>
@ -407,12 +401,22 @@
<el-row> <el-row>
<el-col :span="24"> <el-col :span="24">
<el-form-item label="附件" prop="phone"> <el-form-item label="附件">
<!-- <el-input <UploadFileFormData
clearable :limit="3"
placeholder="请输入附件" :file-size="20"
v-model="contractInfoForm.phone" :multiple="true"
/> --> uploadTip="身份证、银行卡扫描件,承诺书、劳动合同或用工协议扫描件"
:file-list.sync="contractImageList[5].fileList"
:file-type="[
'jpg',
'png',
'jpeg',
'pdf',
'doc',
'docx',
]"
/>
</el-form-item> </el-form-item>
</el-col> </el-col>
</el-row> </el-row>
@ -437,27 +441,21 @@
</TitleTip> </TitleTip>
<el-row> <el-row>
<el-col :span="24"> <el-col :span="24">
<el-form-item label="工资卡见证照片" prop="businessLicense"> <el-form-item label="工资卡见证照片">
<div style="display: flex; gap: 10px"> <div style="display: flex; gap: 10px">
<div <div
class="contract-img-box" class="contract-img-box"
v-for="item in bankImageList" v-for="item in bankImageList"
:key="item.title" :key="item.title"
> >
<UploadImg <UploadImgFormData
:limit="30" :limit="1"
:file-size="10" :file-size="20"
:multiple="true" :multiple="true"
:is-detail="formType === 2" :is-detail="formType === 2"
:file-list.sync="item.fileList"
:file-type="['jpg', 'png', 'jpeg']" :file-type="['jpg', 'png', 'jpeg']"
:upload-file-url="uploadFileUrl" :is-uploaded="item.fileList.length >= 1"
:file-list.sync="
addOrEditForm.businessLicense
"
:is-uploaded="
addOrEditForm.businessLicense.length >=
2
"
/> />
<span> {{ item.title }} </span> <span> {{ item.title }} </span>
@ -489,11 +487,21 @@
</el-row> </el-row>
<el-row> <el-row>
<el-col :span="12"> <el-col :span="12">
<el-form-item label="附件" prop="phone"> <el-form-item label="附件">
<el-input <UploadFileFormData
clearable :limit="3"
placeholder="请输入附件" :file-size="20"
v-model="salaryCardInfoForm.phone" :multiple="true"
uploadTip="身份证、银行卡扫描件,承诺书、劳动合同或用工协议扫描件"
:file-list.sync="bankImageList[4].fileList"
:file-type="[
'jpg',
'png',
'jpeg',
'pdf',
'doc',
'docx',
]"
/> />
</el-form-item> </el-form-item>
</el-col> </el-col>
@ -512,8 +520,8 @@
</template> </template>
<script> <script>
import UploadImg from '@/components/UploadImg'
import UploadImgFormData from '@/components/UploadImgFormData' import UploadImgFormData from '@/components/UploadImgFormData'
import UploadFileFormData from '@/components/UploadFileFormData'
import { import {
addEntryPersonAPI, addEntryPersonAPI,
editEntryPersonAPI, editEntryPersonAPI,
@ -536,8 +544,8 @@ export default {
}, },
}, },
components: { components: {
UploadImg,
UploadImgFormData, UploadImgFormData,
UploadFileFormData,
}, },
data() { data() {
return { return {
@ -588,65 +596,75 @@ export default {
bankBranchName: '', // bankBranchName: '', //
}, },
addOrEditForm: {
name: '', //
idNumber: '', //
sex: '', //
birthday: '', //
nation: '', //
issuingAuthority: '', //
startTime: '', //
endTime: '', //
address: '', //
subName: '', //
legalRepresentative: '', //
phone: '', //
businessAddress: '', //
businessLicense: [], //
electronicStamp: [], //
idCard: [], //
electronicSignature: [], // /
},
contractImageList: [ contractImageList: [
{ {
title: '人员手持合同照', title: '人员手持合同照',
imgList: [], type: 1,
name: 'contract',
fileList: [],
}, },
{ {
title: '工作内容页', title: '工作内容页',
imgList: [], type: 2,
name: 'contract',
fileList: [],
}, },
{ {
title: '薪酬约定页', title: '薪酬约定页',
imgList: [], type: 3,
name: 'contract',
fileList: [],
}, },
{ {
title: '本人签名页', title: '本人签名页',
imgList: [], type: 4,
name: 'contract',
fileList: [],
}, },
{ {
title: '其他照片', title: '其他照片',
imgList: [], type: 5,
name: 'contract',
fileList: [],
},
{
title: '附件',
type: 6,
name: 'contract',
fileList: [],
}, },
], ],
bankImageList: [ bankImageList: [
{ {
title: '手持银行卡、承诺书', title: '手持银行卡、承诺书',
imgList: [], type: 1,
name: 'bank',
fileList: [],
}, },
{ {
title: '银行卡照片', title: '银行卡照片',
imgList: [], type: 2,
name: 'bank',
fileList: [],
}, },
{ {
title: '个人工资卡承诺书', title: '个人工资卡承诺书',
imgList: [], type: 3,
name: 'bank',
fileList: [],
}, },
{ {
title: '其它照片', title: '其它照片',
imgList: [], type: 4,
name: 'bank',
fileList: [],
},
{
title: '附件',
type: 5,
name: 'bank',
fileList: [],
}, },
], ],
@ -724,6 +742,13 @@ export default {
trigger: 'blur', trigger: 'blur',
}, },
], ],
faceImg: [
{
required: true,
message: '请上传人脸照片',
trigger: 'change',
},
],
}, },
// //
@ -817,6 +842,48 @@ export default {
} }
}, },
methods: { methods: {
//
checkFormStatus(fieldsList, imageFList) {
//
const imageFieldsToCheck = imageFList.slice(0, -1) //
//
let emptyFieldCount = 0
let filledFieldCount = 0
//
fieldsList.forEach((field) => {
if (!this.contractInfoForm[field]) {
emptyFieldCount++
} else {
filledFieldCount++
}
})
//
imageFieldsToCheck.forEach((item) => {
if (item.fileList.length === 0) {
emptyFieldCount++
} else {
filledFieldCount++
}
})
//
if (
emptyFieldCount ===
fieldsList.length + imageFieldsToCheck.length
) {
return 'all_empty' //
} else if (
filledFieldCount ===
fieldsList.length + imageFieldsToCheck.length
) {
return 'all_filled' //
} else {
return 'partial' //
}
},
// //
onHandleConfirmAddOrEditFun() { onHandleConfirmAddOrEditFun() {
console.log(this.idCardInfoForm.faceImg, 'idCardInfoForm.faceImg') console.log(this.idCardInfoForm.faceImg, 'idCardInfoForm.faceImg')
@ -832,27 +899,24 @@ export default {
// 2. // 2.
this.$refs.keyInfoFormRef.validate(async (valid2) => { this.$refs.keyInfoFormRef.validate(async (valid2) => {
if (valid2) { if (valid2) {
// 1. const fieldsToCheck_1 = [
// 2. 'contractCode', //
// if ( 'contractStartDate', //
// Object.values(this.contractInfoForm).every( 'contractStopDate', //
// (item) => !item, 'wageCriterion', //
// ) ]
// ) { const fieldsToCheck_2 = [
// resolve() 'bankCardCode', //
// } else { 'bankName', //
// reject(new Error('')) 'bankBranchName', //
// } ]
const status_1 = this.checkFormStatus(
// resolve() fieldsToCheck_1,
this.contractImageList,
console.log(
this.idCardInfoForm,
'idCardInfoForm 身份证信息',
) )
console.log( const status_2 = this.checkFormStatus(
this.keyInfoForm, fieldsToCheck_2,
'keyInfoForm 关键信息', this.bankImageList,
) )
console.log( console.log(
this.contractInfoForm, this.contractInfoForm,
@ -871,6 +935,30 @@ export default {
// bmWorkerWageCard: this.salaryCardInfoForm, // bmWorkerWageCard: this.salaryCardInfoForm,
} }
if (status_1 === 'all_filled') {
params.bmWorkerContract = this.contractInfoForm
}
if (status_1 === 'partial') {
this.$modal.msgError(
'请完善合同见证中的必填信息(除附件外)后再提交',
)
return reject(new Error('合同信息未完善'))
}
if (status_2 === 'all_filled') {
params.bmWorkerWageCard =
this.salaryCardInfoForm
}
if (status_2 === 'partial') {
this.$modal.msgError(
'请完善工资卡见证中的必填信息(除附件外)后再提交',
)
return reject(new Error('工资卡信息未完善'))
}
const { faceImg } = this.idCardInfoForm const { faceImg } = this.idCardInfoForm
console.log(params, 'params 组装参数') console.log(params, 'params 组装参数')

View File

@ -55,6 +55,7 @@
size="mini" size="mini"
type="danger" type="danger"
icon="el-icon-delete" icon="el-icon-delete"
v-if="data.einStatus === 2"
@click="onHandleDeletePersonEntry(data)" @click="onHandleDeletePersonEntry(data)"
> >
删除 删除
@ -157,10 +158,10 @@ export default {
// //
onHandleDeletePersonEntry(data) { onHandleDeletePersonEntry(data) {
if (data.einStatus === 1) { // if (data.einStatus === 1) {
this.$modal.msgError('该人员在场,不能删除') // this.$modal.msgError('')
return // return
} // }
this.$confirm('确定删除该人员吗?', '温馨提示', { this.$confirm('确定删除该人员吗?', '温馨提示', {
confirmButtonText: '确定', confirmButtonText: '确定',
cancelButtonText: '取消', cancelButtonText: '取消',