From b285da3091e07094d4a4a0572da71620c1e77960 Mon Sep 17 00:00:00 2001 From: BianLzhaoMin <11485688+bianliangzhaomin123@user.noreply.gitee.com> Date: Sat, 6 Sep 2025 15:10:49 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .env.development | 4 +- src/components/ContractForm/index.vue | 50 ++++- src/components/KeyInfoForm/index.vue | 48 ++++- src/components/PersonIdCardForm/index.vue | 68 +++++- src/components/WageCardForm/index.vue | 101 +++++++-- src/pages/attendance/index.vue | 2 +- .../child-pages/addAndEditPerson.vue | 194 ++++-------------- src/pages/person-exit/data-upload/index.vue | 2 +- src/pages/person-exit/index.vue | 4 + src/services/person-entry.js | 18 ++ src/utils/http.js | 6 +- 11 files changed, 299 insertions(+), 198 deletions(-) diff --git a/.env.development b/.env.development index aaec465..13ba143 100644 --- a/.env.development +++ b/.env.development @@ -1,4 +1,4 @@ # VITE_API_BASE_URL = http://112.29.103.165:1616 # VITE_API_BASE_URL = /api -VITE_API_BASE_URL = http://192.168.0.14:1999/hd-realname/prod-api -# VITE_API_BASE_URL = http://192.168.0.234:38080 +# VITE_API_BASE_URL = http://192.168.0.14:1999/hd-realname/prod-api +VITE_API_BASE_URL = http://192.168.0.234:38080 diff --git a/src/components/ContractForm/index.vue b/src/components/ContractForm/index.vue index 2a038c9..ef07037 100644 --- a/src/components/ContractForm/index.vue +++ b/src/components/ContractForm/index.vue @@ -119,7 +119,7 @@ @delete="deletePic($event, index)" :disabled="isEditContractStatus" :deletable="!isEditContractStatus" - @afterRead="afterRead($event, index)" + @afterRead="afterRead($event, index, item.type)" :capture="['album', 'camera']" /> @@ -158,6 +158,8 @@ const contractInfoForm = ref({ wageCriterion: '', // 工资核定标准 }) // 合同表单数据 +const contractImageIdList = ref([]) // 上传文件列表 存储ID + const contractImageList = ref([ { type: 1, @@ -269,16 +271,45 @@ const onCancelContractStartDate = (e) => { // 删除图片 const deletePic = (e, index) => { contractImageList.value[index].fileList = [] + contractImageIdList.value.splice(index, 1) } // 上传图片 -const afterRead = (e, index) => { +const afterRead = (e, index, fileType) => { const type = e.file[0].type if (!type.includes('image')) { uni.$u.toast('请上传图片格式') return } - contractImageList.value[index].fileList = [e.file[0]] + const files = [ + { + name: 'file', + file: e.file[0].url, + uri: e.file[0].url, + }, + ] + uni.uploadFile({ + url: '/bmw/app/uploadFile', + files: files, + name: 'file', + isUploadFile: true, + formData: { + type: fileType, + }, + success: (res) => { + const data = JSON.parse(res.data) + if (data.code === 200) { + contractImageList.value[index].fileList.push({ isNew: true, ...e.file[0] }) + // 走上传逻辑 上传成功后把ID插入到fileList中 + contractImageIdList.value[index] = { id: data.data, fileType: fileType } + } else { + uni.$u.toast('上传失败:' + data.msg) + } + }, + fail: (err) => { + uni.$u.toast('上传失败,请重新上传') + }, + }) } const checkFormStatus = () => { @@ -338,10 +369,21 @@ const validateContractForm = async () => { uni.$u.toast('请完善合同见证中的所有信息') return reject(new Error('合同信息未完善')) } else { + let data = {} + if (contractImageIdList.value.length > 0) { + data = { + photoIds: contractImageIdList.value + .map((item) => item.id) + .join(','), + ...contractInfoForm.value, + } + } else { + data = { ...contractInfoForm.value } + } resolve({ + data, status, isValid: true, - data: contractInfoForm.value, imgList: contractImageList.value, }) } diff --git a/src/components/KeyInfoForm/index.vue b/src/components/KeyInfoForm/index.vue index 3c9f721..7d4ae72 100644 --- a/src/components/KeyInfoForm/index.vue +++ b/src/components/KeyInfoForm/index.vue @@ -157,6 +157,7 @@ import { } from '@/services/common' const keyInfoFormRef = ref(null) // 关键信息校验表单ref +const photoIds = ref('') // 上传文件列表 存储ID const keyInfoForm = ref({ proId: '', // 入场工程 postId: '', // 工种 @@ -330,22 +331,47 @@ const afterRead = (e) => { const files = [ { - file: e.file[0].file, + file: e.file[0].url, name: 'file', + uri: e.file[0].url, }, ] uni.uploadFile({ url: '/bmw/worker/faceDetection', files: files, name: 'file', + isUploadFile: true, success: (res) => { const data = JSON.parse(res.data) - // console.log(data, 'res--9996') if (data.code === 200) { - keyInfoForm.value.faceImg = [e.file[0]] + uni.uploadFile({ + url: '/bmw/app/uploadFile', + files: files, + name: 'file', + isUploadFile: true, + formData: { + type: 1, + }, + success: (res) => { + const data = JSON.parse(res.data) + if (data.code === 200) { + keyInfoForm.value.faceImg.push({ + ...e.file[0], + }) + // 走上传逻辑 上传成功后把ID插入到fileList中 + // keyInfoForm.value.photoIds = data.data + photoIds.value = data.data + } else { + uni.$u.toast('上传失败:' + data.msg) + } + }, + fail: (err) => { + uni.$u.toast('上传失败,请重新上传') + }, + }) } else { uni.$u.toast('人脸识别失败:' + data.msg) - keyInfoForm.value.faceImg = [e.file[0]] + keyInfoForm.value.faceImg = [] } }, fail: (err) => { @@ -362,10 +388,18 @@ const validateKeyInfoForm = async () => { .validate() .then((valid) => { if (valid) { - const params = { - isValid: true, - data: keyInfoForm.value, + let data = {} + if (photoIds.value) { + data = { photoIds: photoIds.value, ...keyInfoForm.value } + } else { + data = { ...keyInfoForm.value } } + + let params = { + isValid: true, + data, + } + resolve(params) } }) diff --git a/src/components/PersonIdCardForm/index.vue b/src/components/PersonIdCardForm/index.vue index c156df1..21d4ea5 100644 --- a/src/components/PersonIdCardForm/index.vue +++ b/src/components/PersonIdCardForm/index.vue @@ -143,6 +143,7 @@ { // 1人像面 2国徽面 // console.log('识别身份证(人像面)') - uni.$u.toast('功能正在开发中,敬请期待...') + // uni.$u.toast('功能正在开发中,敬请期待...') - return + // return uni.chooseImage({ count: 1, // 最多选择1张图片 @@ -354,29 +356,75 @@ const onHandleRecognizeIdCard = (type) => { sourceType: ['camera', 'album'], // 选择图片的来源 success: async (res) => { const base64 = await imgToBase64Fun(res.tempFilePaths[0]) - const param = { - imageBase64: base64.split(',')[1], + let params = { + recognitionFrontData: '', + recognitionBackData: '', + type: 1, + } + if (type === 1) { + params.recognitionFrontData = base64.split(',')[1] + } else { + params.recognitionBackData = base64.split(',')[1] } // 上传后台接口 uni.request({ - url: '/bmw/appRecognition/bankCardRecognition', + url: 'http://192.168.0.14:18975/recognition', method: 'POST', - data: param, + data: params, + isUploadFile: true, header: { // 'Content-Type': 'application/Json', Authorization: memberStore?.token, // token }, success: (res) => { - const { data: result } = res - if (result.code === 200) { + const data = JSON.parse(res.data) + console.log(data, '识别身份证结果') + + if (data.code === 20001) { uni.$u.toast('识别身份证成功') + + if (type === 1) { + const { name, gender, ethnicity, dateOfBirth, address, idNumber } = + data.data + + const match = dateOfBirth.match(/(\d+)年(\d+)月(\d+)日/) + let birthday = '' + + if (match) { + const year = match[1] + // 月和日补零处理 + const month = String(match[2]).padStart(2, '0') + const day = String(match[3]).padStart(2, '0') + birthday = `${year}-${month}-${day}` + } + + idCardModel.value.name = name + idCardModel.value.sex = gender + idCardModel.value.nation = ethnicity + idCardModel.value.birthday = birthday + idCardModel.value.address = address + idCardModel.value.idNumber = idNumber + } else { + const { issuingAuthority, validTime } = data.data + const validTimeArr = validTime.split('-') + idCardModel.value.issuingAuthority = issuingAuthority + idCardModel.value.startTime = validTimeArr[0].replace(/\./g, '-') + idCardModel.value.endTime = validTimeArr[1].replace(/\./g, '-') + } } else { - uni.$u.toast('识别身份证失败,请重新识别') + uni.$u.toast('识别失败,请重新识别') } + // const { data: result } = res + // if (result.code === 200) { + // uni.$u.toast('识别身份证成功') + // } else { + // uni.$u.toast('识别身份证失败,请重新识别') + // } }, fail: (err) => { - console.log(err, '----识别身份证失败') + // console.log(err, '----识别身份证失败') + uni.$u.toast('识别失败,请重新识别') }, }) }, diff --git a/src/components/WageCardForm/index.vue b/src/components/WageCardForm/index.vue index 9b51094..053530b 100644 --- a/src/components/WageCardForm/index.vue +++ b/src/components/WageCardForm/index.vue @@ -73,8 +73,8 @@ :name="item.name" :fileList="item.fileList" :capture="['album', 'camera']" - @delete="deletePic($event, index)" - @afterRead="afterRead($event, index)" + @delete="deletePic($event, index, item)" + @afterRead="afterRead($event, index, item.type)" /> @@ -112,6 +112,8 @@ const wageCardInfoForm = ref({ bankBranchName: '', // 银行支行名称 }) // 合同表单数据 +const deleteFileList = ref([]) // 删除的文件列表ID + const wageCardImageList = ref([ { type: 1, @@ -138,7 +140,7 @@ const wageCardImageList = ref([ title: '其它照片', }, ]) // 合同见证照片 - +const wageCardUploadIdList = ref([]) // 上传文件列表 存储ID const wageCardInfoFormRules = ref({ bankName: [ { @@ -173,19 +175,71 @@ const wageCardInfoFormRules = ref({ ], }) +const props = defineProps({ + wageCardInfo: { + type: Object, + default: () => {}, + }, + wageCardImageList: { + type: Array, + default: () => [], + }, + formType: { + type: [Number, String], // 表单类型 + default: 1, + }, +}) + // 删除图片 -const deletePic = (e, index) => { +const deletePic = (e, index, item) => { + if (props.formType == 2 && !item.isNew) { + deleteFileList.value.push(item.fileList[0].id) + } wageCardImageList.value[index].fileList = [] + wageCardUploadIdList.value.splice(index, 1) } // 上传图片 -const afterRead = (e, index) => { +const afterRead = (e, index, fileType) => { + console.log(e, '选择的文件') const type = e.file[0].type if (!type.includes('image')) { uni.$u.toast('请上传图片格式') return } - wageCardImageList.value[index].fileList = [e.file[0]] + + const files = [ + { + file: e.file[0].url, + name: 'file', + uri: e.file[0].url, + }, + ] + uni.uploadFile({ + url: '/bmw/app/uploadFile', + files: files, + name: 'file', + isUploadFile: true, + formData: { + type: fileType, + }, + success: (res) => { + const data = JSON.parse(res.data) + + console.log(data, '上传结果') + + if (data.code === 200) { + wageCardImageList.value[index].fileList.push({ isNew: true, ...e.file[0] }) + // 走上传逻辑 上传成功后把ID插入到fileList中 + wageCardUploadIdList.value[index] = { id: data.data, fileType: fileType } + } else { + uni.$u.toast('上传失败:' + data.msg) + } + }, + fail: (err) => { + uni.$u.toast('上传失败,请重新上传') + }, + }) } // 检查表单状态 @@ -232,6 +286,8 @@ const checkFormStatus = () => { // 表单校验 const validateWageCardForm = async () => { // console.log(wageCardFormRef.value, '9995') + + console.log('提交表单') return new Promise((resolve, reject) => { wageCardFormRef.value .validate() @@ -244,10 +300,26 @@ const validateWageCardForm = async () => { uni.$u.toast('请完善工资卡见证中的所有信息') return reject(new Error('工资卡信息未完善')) } else { + let data = {} + if (wageCardUploadIdList.value.length > 0) { + data = { + photoIds: wageCardUploadIdList.value + .map((item) => item.id) + .join(','), + ...wageCardInfoForm.value, + } + } else { + data = { ...wageCardInfoForm.value } + } + + if (props.formType == 2 && deleteFileList.value.length > 0) { + wageCardInfoForm.value.delIds = deleteFileList.value.join(',') + } + resolve({ + data, status, isValid: true, - data: wageCardInfoForm.value, imgList: wageCardImageList.value, }) } @@ -291,13 +363,15 @@ const onHandleRecognizeBankCard = () => { } // 上传后台接口 uni.request({ - url: import.meta.env.VITE_API_BASE_URL + '/bmw/appRecognition/bankCardRecognition', + url: '/bmw/appRecognition/bankCardRecognition', method: 'POST', data: param, + isUploadFile: true, header: { Authorization: memberStore?.token, // token }, success: (res) => { + console.log(res, '银行卡识别结果') showLoading.value = false const { data: result } = res if (result.code === 200) { @@ -329,17 +403,6 @@ defineExpose({ updateWageCardInfo, }) -const props = defineProps({ - wageCardInfo: { - type: Object, - default: () => {}, - }, - wageCardImageList: { - type: Array, - default: () => [], - }, -}) - // 增加监听 watch( props.wageCardInfo, diff --git a/src/pages/attendance/index.vue b/src/pages/attendance/index.vue index db4e502..6eaaf64 100644 --- a/src/pages/attendance/index.vue +++ b/src/pages/attendance/index.vue @@ -87,7 +87,7 @@ const onAttendanceHandle = () => { uni.chooseImage({ count: 1, // 最多选择1张图片 sizeType: ['original', 'compressed'], - sourceType: ['camera', 'album'], // 选择图片的来源 + sourceType: ['camera'], // 选择图片的来源 success: (res) => { console.log(res, '选择的文件') showLoading.value = true diff --git a/src/pages/person-entry/child-pages/addAndEditPerson.vue b/src/pages/person-entry/child-pages/addAndEditPerson.vue index 8fc77d6..48d8767 100644 --- a/src/pages/person-entry/child-pages/addAndEditPerson.vue +++ b/src/pages/person-entry/child-pages/addAndEditPerson.vue @@ -36,6 +36,7 @@ :isEditContractStatus="isEditContractStatus" /> + +