This commit is contained in:
parent
b8ca5dfed5
commit
b285da3091
|
|
@ -1,4 +1,4 @@
|
||||||
# VITE_API_BASE_URL = http://112.29.103.165:1616
|
# VITE_API_BASE_URL = http://112.29.103.165:1616
|
||||||
# VITE_API_BASE_URL = /api
|
# 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.14:1999/hd-realname/prod-api
|
||||||
# VITE_API_BASE_URL = http://192.168.0.234:38080
|
VITE_API_BASE_URL = http://192.168.0.234:38080
|
||||||
|
|
|
||||||
|
|
@ -119,7 +119,7 @@
|
||||||
@delete="deletePic($event, index)"
|
@delete="deletePic($event, index)"
|
||||||
:disabled="isEditContractStatus"
|
:disabled="isEditContractStatus"
|
||||||
:deletable="!isEditContractStatus"
|
:deletable="!isEditContractStatus"
|
||||||
@afterRead="afterRead($event, index)"
|
@afterRead="afterRead($event, index, item.type)"
|
||||||
:capture="['album', 'camera']"
|
:capture="['album', 'camera']"
|
||||||
/>
|
/>
|
||||||
</up-form-item>
|
</up-form-item>
|
||||||
|
|
@ -158,6 +158,8 @@ const contractInfoForm = ref({
|
||||||
wageCriterion: '', // 工资核定标准
|
wageCriterion: '', // 工资核定标准
|
||||||
}) // 合同表单数据
|
}) // 合同表单数据
|
||||||
|
|
||||||
|
const contractImageIdList = ref([]) // 上传文件列表 存储ID
|
||||||
|
|
||||||
const contractImageList = ref([
|
const contractImageList = ref([
|
||||||
{
|
{
|
||||||
type: 1,
|
type: 1,
|
||||||
|
|
@ -269,16 +271,45 @@ const onCancelContractStartDate = (e) => {
|
||||||
// 删除图片
|
// 删除图片
|
||||||
const deletePic = (e, index) => {
|
const deletePic = (e, index) => {
|
||||||
contractImageList.value[index].fileList = []
|
contractImageList.value[index].fileList = []
|
||||||
|
contractImageIdList.value.splice(index, 1)
|
||||||
}
|
}
|
||||||
|
|
||||||
// 上传图片
|
// 上传图片
|
||||||
const afterRead = (e, index) => {
|
const afterRead = (e, index, fileType) => {
|
||||||
const type = e.file[0].type
|
const type = e.file[0].type
|
||||||
if (!type.includes('image')) {
|
if (!type.includes('image')) {
|
||||||
uni.$u.toast('请上传图片格式')
|
uni.$u.toast('请上传图片格式')
|
||||||
return
|
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 = () => {
|
const checkFormStatus = () => {
|
||||||
|
|
@ -338,10 +369,21 @@ const validateContractForm = async () => {
|
||||||
uni.$u.toast('请完善合同见证中的所有信息')
|
uni.$u.toast('请完善合同见证中的所有信息')
|
||||||
return reject(new Error('合同信息未完善'))
|
return reject(new Error('合同信息未完善'))
|
||||||
} else {
|
} else {
|
||||||
|
let data = {}
|
||||||
|
if (contractImageIdList.value.length > 0) {
|
||||||
|
data = {
|
||||||
|
photoIds: contractImageIdList.value
|
||||||
|
.map((item) => item.id)
|
||||||
|
.join(','),
|
||||||
|
...contractInfoForm.value,
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
data = { ...contractInfoForm.value }
|
||||||
|
}
|
||||||
resolve({
|
resolve({
|
||||||
|
data,
|
||||||
status,
|
status,
|
||||||
isValid: true,
|
isValid: true,
|
||||||
data: contractInfoForm.value,
|
|
||||||
imgList: contractImageList.value,
|
imgList: contractImageList.value,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -157,6 +157,7 @@ import {
|
||||||
} from '@/services/common'
|
} from '@/services/common'
|
||||||
|
|
||||||
const keyInfoFormRef = ref(null) // 关键信息校验表单ref
|
const keyInfoFormRef = ref(null) // 关键信息校验表单ref
|
||||||
|
const photoIds = ref('') // 上传文件列表 存储ID
|
||||||
const keyInfoForm = ref({
|
const keyInfoForm = ref({
|
||||||
proId: '', // 入场工程
|
proId: '', // 入场工程
|
||||||
postId: '', // 工种
|
postId: '', // 工种
|
||||||
|
|
@ -330,22 +331,47 @@ const afterRead = (e) => {
|
||||||
|
|
||||||
const files = [
|
const files = [
|
||||||
{
|
{
|
||||||
file: e.file[0].file,
|
file: e.file[0].url,
|
||||||
name: 'file',
|
name: 'file',
|
||||||
|
uri: e.file[0].url,
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
uni.uploadFile({
|
uni.uploadFile({
|
||||||
url: '/bmw/worker/faceDetection',
|
url: '/bmw/worker/faceDetection',
|
||||||
files: files,
|
files: files,
|
||||||
name: 'file',
|
name: 'file',
|
||||||
|
isUploadFile: true,
|
||||||
success: (res) => {
|
success: (res) => {
|
||||||
const data = JSON.parse(res.data)
|
const data = JSON.parse(res.data)
|
||||||
// console.log(data, 'res--9996')
|
|
||||||
if (data.code === 200) {
|
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 {
|
} else {
|
||||||
uni.$u.toast('人脸识别失败:' + data.msg)
|
uni.$u.toast('人脸识别失败:' + data.msg)
|
||||||
keyInfoForm.value.faceImg = [e.file[0]]
|
keyInfoForm.value.faceImg = []
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
fail: (err) => {
|
fail: (err) => {
|
||||||
|
|
@ -362,10 +388,18 @@ const validateKeyInfoForm = async () => {
|
||||||
.validate()
|
.validate()
|
||||||
.then((valid) => {
|
.then((valid) => {
|
||||||
if (valid) {
|
if (valid) {
|
||||||
const params = {
|
let data = {}
|
||||||
isValid: true,
|
if (photoIds.value) {
|
||||||
data: keyInfoForm.value,
|
data = { photoIds: photoIds.value, ...keyInfoForm.value }
|
||||||
|
} else {
|
||||||
|
data = { ...keyInfoForm.value }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let params = {
|
||||||
|
isValid: true,
|
||||||
|
data,
|
||||||
|
}
|
||||||
|
|
||||||
resolve(params)
|
resolve(params)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
|
||||||
|
|
@ -143,6 +143,7 @@
|
||||||
<up-datetime-picker
|
<up-datetime-picker
|
||||||
mode="date"
|
mode="date"
|
||||||
ref="pikerBirthdayRef"
|
ref="pikerBirthdayRef"
|
||||||
|
:minDate="0"
|
||||||
:show="showPikerBirthday"
|
:show="showPikerBirthday"
|
||||||
@cancel="onCancelBirthday"
|
@cancel="onCancelBirthday"
|
||||||
@confirm="onConfirmBirthday"
|
@confirm="onConfirmBirthday"
|
||||||
|
|
@ -155,6 +156,7 @@
|
||||||
import { ref, watch } from 'vue'
|
import { ref, watch } from 'vue'
|
||||||
import { pathToBase64 } from 'image-tools'
|
import { pathToBase64 } from 'image-tools'
|
||||||
import { useMemberStore } from '@/stores'
|
import { useMemberStore } from '@/stores'
|
||||||
|
import dayjs from 'dayjs'
|
||||||
|
|
||||||
const memberStore = useMemberStore()
|
const memberStore = useMemberStore()
|
||||||
const idCardFormRef = ref(null) // 身份证表单ref
|
const idCardFormRef = ref(null) // 身份证表单ref
|
||||||
|
|
@ -344,9 +346,9 @@ const onHandleRecognizeIdCard = (type) => {
|
||||||
// 1人像面 2国徽面
|
// 1人像面 2国徽面
|
||||||
// console.log('识别身份证(人像面)')
|
// console.log('识别身份证(人像面)')
|
||||||
|
|
||||||
uni.$u.toast('功能正在开发中,敬请期待...')
|
// uni.$u.toast('功能正在开发中,敬请期待...')
|
||||||
|
|
||||||
return
|
// return
|
||||||
|
|
||||||
uni.chooseImage({
|
uni.chooseImage({
|
||||||
count: 1, // 最多选择1张图片
|
count: 1, // 最多选择1张图片
|
||||||
|
|
@ -354,29 +356,75 @@ const onHandleRecognizeIdCard = (type) => {
|
||||||
sourceType: ['camera', 'album'], // 选择图片的来源
|
sourceType: ['camera', 'album'], // 选择图片的来源
|
||||||
success: async (res) => {
|
success: async (res) => {
|
||||||
const base64 = await imgToBase64Fun(res.tempFilePaths[0])
|
const base64 = await imgToBase64Fun(res.tempFilePaths[0])
|
||||||
const param = {
|
let params = {
|
||||||
imageBase64: base64.split(',')[1],
|
recognitionFrontData: '',
|
||||||
|
recognitionBackData: '',
|
||||||
|
type: 1,
|
||||||
|
}
|
||||||
|
if (type === 1) {
|
||||||
|
params.recognitionFrontData = base64.split(',')[1]
|
||||||
|
} else {
|
||||||
|
params.recognitionBackData = base64.split(',')[1]
|
||||||
}
|
}
|
||||||
|
|
||||||
// 上传后台接口
|
// 上传后台接口
|
||||||
uni.request({
|
uni.request({
|
||||||
url: '/bmw/appRecognition/bankCardRecognition',
|
url: 'http://192.168.0.14:18975/recognition',
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
data: param,
|
data: params,
|
||||||
|
isUploadFile: true,
|
||||||
header: {
|
header: {
|
||||||
// 'Content-Type': 'application/Json',
|
// 'Content-Type': 'application/Json',
|
||||||
Authorization: memberStore?.token, // token
|
Authorization: memberStore?.token, // token
|
||||||
},
|
},
|
||||||
success: (res) => {
|
success: (res) => {
|
||||||
const { data: result } = res
|
const data = JSON.parse(res.data)
|
||||||
if (result.code === 200) {
|
console.log(data, '识别身份证结果')
|
||||||
|
|
||||||
|
if (data.code === 20001) {
|
||||||
uni.$u.toast('识别身份证成功')
|
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 {
|
} else {
|
||||||
uni.$u.toast('识别身份证失败,请重新识别')
|
uni.$u.toast('识别失败,请重新识别')
|
||||||
}
|
}
|
||||||
|
// const { data: result } = res
|
||||||
|
// if (result.code === 200) {
|
||||||
|
// uni.$u.toast('识别身份证成功')
|
||||||
|
// } else {
|
||||||
|
// uni.$u.toast('识别身份证失败,请重新识别')
|
||||||
|
// }
|
||||||
},
|
},
|
||||||
fail: (err) => {
|
fail: (err) => {
|
||||||
console.log(err, '----识别身份证失败')
|
// console.log(err, '----识别身份证失败')
|
||||||
|
uni.$u.toast('识别失败,请重新识别')
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -73,8 +73,8 @@
|
||||||
:name="item.name"
|
:name="item.name"
|
||||||
:fileList="item.fileList"
|
:fileList="item.fileList"
|
||||||
:capture="['album', 'camera']"
|
:capture="['album', 'camera']"
|
||||||
@delete="deletePic($event, index)"
|
@delete="deletePic($event, index, item)"
|
||||||
@afterRead="afterRead($event, index)"
|
@afterRead="afterRead($event, index, item.type)"
|
||||||
/>
|
/>
|
||||||
</up-form-item>
|
</up-form-item>
|
||||||
</up-form>
|
</up-form>
|
||||||
|
|
@ -112,6 +112,8 @@ const wageCardInfoForm = ref({
|
||||||
bankBranchName: '', // 银行支行名称
|
bankBranchName: '', // 银行支行名称
|
||||||
}) // 合同表单数据
|
}) // 合同表单数据
|
||||||
|
|
||||||
|
const deleteFileList = ref([]) // 删除的文件列表ID
|
||||||
|
|
||||||
const wageCardImageList = ref([
|
const wageCardImageList = ref([
|
||||||
{
|
{
|
||||||
type: 1,
|
type: 1,
|
||||||
|
|
@ -138,7 +140,7 @@ const wageCardImageList = ref([
|
||||||
title: '其它照片',
|
title: '其它照片',
|
||||||
},
|
},
|
||||||
]) // 合同见证照片
|
]) // 合同见证照片
|
||||||
|
const wageCardUploadIdList = ref([]) // 上传文件列表 存储ID
|
||||||
const wageCardInfoFormRules = ref({
|
const wageCardInfoFormRules = ref({
|
||||||
bankName: [
|
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 = []
|
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
|
const type = e.file[0].type
|
||||||
if (!type.includes('image')) {
|
if (!type.includes('image')) {
|
||||||
uni.$u.toast('请上传图片格式')
|
uni.$u.toast('请上传图片格式')
|
||||||
return
|
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 () => {
|
const validateWageCardForm = async () => {
|
||||||
// console.log(wageCardFormRef.value, '9995')
|
// console.log(wageCardFormRef.value, '9995')
|
||||||
|
|
||||||
|
console.log('提交表单')
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
wageCardFormRef.value
|
wageCardFormRef.value
|
||||||
.validate()
|
.validate()
|
||||||
|
|
@ -244,10 +300,26 @@ const validateWageCardForm = async () => {
|
||||||
uni.$u.toast('请完善工资卡见证中的所有信息')
|
uni.$u.toast('请完善工资卡见证中的所有信息')
|
||||||
return reject(new Error('工资卡信息未完善'))
|
return reject(new Error('工资卡信息未完善'))
|
||||||
} else {
|
} 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({
|
resolve({
|
||||||
|
data,
|
||||||
status,
|
status,
|
||||||
isValid: true,
|
isValid: true,
|
||||||
data: wageCardInfoForm.value,
|
|
||||||
imgList: wageCardImageList.value,
|
imgList: wageCardImageList.value,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
@ -291,13 +363,15 @@ const onHandleRecognizeBankCard = () => {
|
||||||
}
|
}
|
||||||
// 上传后台接口
|
// 上传后台接口
|
||||||
uni.request({
|
uni.request({
|
||||||
url: import.meta.env.VITE_API_BASE_URL + '/bmw/appRecognition/bankCardRecognition',
|
url: '/bmw/appRecognition/bankCardRecognition',
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
data: param,
|
data: param,
|
||||||
|
isUploadFile: true,
|
||||||
header: {
|
header: {
|
||||||
Authorization: memberStore?.token, // token
|
Authorization: memberStore?.token, // token
|
||||||
},
|
},
|
||||||
success: (res) => {
|
success: (res) => {
|
||||||
|
console.log(res, '银行卡识别结果')
|
||||||
showLoading.value = false
|
showLoading.value = false
|
||||||
const { data: result } = res
|
const { data: result } = res
|
||||||
if (result.code === 200) {
|
if (result.code === 200) {
|
||||||
|
|
@ -329,17 +403,6 @@ defineExpose({
|
||||||
updateWageCardInfo,
|
updateWageCardInfo,
|
||||||
})
|
})
|
||||||
|
|
||||||
const props = defineProps({
|
|
||||||
wageCardInfo: {
|
|
||||||
type: Object,
|
|
||||||
default: () => {},
|
|
||||||
},
|
|
||||||
wageCardImageList: {
|
|
||||||
type: Array,
|
|
||||||
default: () => [],
|
|
||||||
},
|
|
||||||
})
|
|
||||||
|
|
||||||
// 增加监听
|
// 增加监听
|
||||||
watch(
|
watch(
|
||||||
props.wageCardInfo,
|
props.wageCardInfo,
|
||||||
|
|
|
||||||
|
|
@ -87,7 +87,7 @@ const onAttendanceHandle = () => {
|
||||||
uni.chooseImage({
|
uni.chooseImage({
|
||||||
count: 1, // 最多选择1张图片
|
count: 1, // 最多选择1张图片
|
||||||
sizeType: ['original', 'compressed'],
|
sizeType: ['original', 'compressed'],
|
||||||
sourceType: ['camera', 'album'], // 选择图片的来源
|
sourceType: ['camera'], // 选择图片的来源
|
||||||
success: (res) => {
|
success: (res) => {
|
||||||
console.log(res, '选择的文件')
|
console.log(res, '选择的文件')
|
||||||
showLoading.value = true
|
showLoading.value = true
|
||||||
|
|
|
||||||
|
|
@ -36,6 +36,7 @@
|
||||||
:isEditContractStatus="isEditContractStatus"
|
:isEditContractStatus="isEditContractStatus"
|
||||||
/>
|
/>
|
||||||
<WageCardForm
|
<WageCardForm
|
||||||
|
:formType="formType"
|
||||||
ref="personWageCardFormRef"
|
ref="personWageCardFormRef"
|
||||||
:wageCardInfo="wageCardInfo"
|
:wageCardInfo="wageCardInfo"
|
||||||
:wageCardImageList="wageCardImageList"
|
:wageCardImageList="wageCardImageList"
|
||||||
|
|
@ -57,21 +58,33 @@
|
||||||
:text="currentStep === 3 ? '提交' : '下一步'"
|
:text="currentStep === 3 ? '提交' : '下一步'"
|
||||||
/>
|
/>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
|
<up-loading-icon
|
||||||
|
:vertical="true"
|
||||||
|
duration="2000"
|
||||||
|
color="#3c9cff"
|
||||||
|
:show="showLoading"
|
||||||
|
textColor="#3c9cff"
|
||||||
|
text="数据正在提交,请稍后..."
|
||||||
|
style="position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%)"
|
||||||
|
/>
|
||||||
</view>
|
</view>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup name="addAndEditPerson">
|
<script setup name="addAndEditPerson">
|
||||||
import { useCommonStore } from '@/stores'
|
import { useCommonStore } from '@/stores'
|
||||||
|
import { pathToBase64 } from 'image-tools'
|
||||||
|
import { onLoad } from '@dcloudio/uni-app'
|
||||||
import { ref, onMounted, nextTick } from 'vue'
|
import { ref, onMounted, nextTick } from 'vue'
|
||||||
import { decryptWithSM4, encryptWithSM4, hashWithSM3AndSalt } from '@/utils/sm'
|
import { decryptWithSM4, encryptWithSM4, hashWithSM3AndSalt } from '@/utils/sm'
|
||||||
import { getPersonInfoByIdAPI, updatePersonLightStatusApi } from '@/services/person-entry'
|
import { getPersonInfoByIdAPI, updatePersonLightStatusApi } from '@/services/person-entry'
|
||||||
|
import { addPersonEntryApi, editPersonEntryApi } from '@/services/person-entry'
|
||||||
|
|
||||||
import PersonIdCardForm from '@/components/PersonIdCardForm/index.vue'
|
import PersonIdCardForm from '@/components/PersonIdCardForm/index.vue'
|
||||||
import KeyInfoForm from '@/components/KeyInfoForm/index.vue'
|
import KeyInfoForm from '@/components/KeyInfoForm/index.vue'
|
||||||
import ContractForm from '@/components/ContractForm/index.vue'
|
import ContractForm from '@/components/ContractForm/index.vue'
|
||||||
import WageCardForm from '@/components/WageCardForm/index.vue'
|
import WageCardForm from '@/components/WageCardForm/index.vue'
|
||||||
import NavBarModal from '@/components/NavBarModal/index.vue'
|
import NavBarModal from '@/components/NavBarModal/index.vue'
|
||||||
|
|
||||||
import { onLoad } from '@dcloudio/uni-app'
|
|
||||||
const { safeAreaInsets } = uni.getSystemInfoSync()
|
const { safeAreaInsets } = uni.getSystemInfoSync()
|
||||||
const commonStore = useCommonStore()
|
const commonStore = useCommonStore()
|
||||||
const navBarTitle = ref('新增人员信息')
|
const navBarTitle = ref('新增人员信息')
|
||||||
|
|
@ -87,6 +100,7 @@ const editUploadFileList = ref([]) // 编辑时已上传文件列表
|
||||||
const formType = ref(1) // 表单类型
|
const formType = ref(1) // 表单类型
|
||||||
const personId = ref('') // 人员id
|
const personId = ref('') // 人员id
|
||||||
const einStatus = ref('') // 人员状态
|
const einStatus = ref('') // 人员状态
|
||||||
|
const showLoading = ref(false) // 是否显示加载中
|
||||||
|
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
type: {
|
type: {
|
||||||
|
|
@ -186,6 +200,19 @@ const wageCardImageList = ref([
|
||||||
]) // 工资卡图片
|
]) // 工资卡图片
|
||||||
const wageCardStatus = ref('') // 工资卡状态
|
const wageCardStatus = ref('') // 工资卡状态
|
||||||
|
|
||||||
|
const imgToBase64Fun = async (path) => {
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
pathToBase64(path)
|
||||||
|
.then((base64) => {
|
||||||
|
resolve(base64)
|
||||||
|
})
|
||||||
|
.catch((error) => {
|
||||||
|
console.error(error)
|
||||||
|
reject(error)
|
||||||
|
})
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
// 下一步
|
// 下一步
|
||||||
const onHandleNext = async () => {
|
const onHandleNext = async () => {
|
||||||
try {
|
try {
|
||||||
|
|
@ -235,6 +262,7 @@ const onHandleNext = async () => {
|
||||||
}
|
}
|
||||||
if (currentStep.value === 3) {
|
if (currentStep.value === 3) {
|
||||||
const res = await personWageCardFormRef.value.validateWageCardForm()
|
const res = await personWageCardFormRef.value.validateWageCardForm()
|
||||||
|
|
||||||
if (res.isValid) {
|
if (res.isValid) {
|
||||||
stepList.value[currentStep.value].isError = false
|
stepList.value[currentStep.value].isError = false
|
||||||
|
|
||||||
|
|
@ -243,9 +271,6 @@ const onHandleNext = async () => {
|
||||||
wageCardImageList.value = imgList
|
wageCardImageList.value = imgList
|
||||||
wageCardStatus.value = status
|
wageCardStatus.value = status
|
||||||
|
|
||||||
// 提交接口 组装参数
|
|
||||||
const files = []
|
|
||||||
const fileMsg = []
|
|
||||||
const params = {
|
const params = {
|
||||||
...idCardInfo.value,
|
...idCardInfo.value,
|
||||||
...keyInfo.value,
|
...keyInfo.value,
|
||||||
|
|
@ -256,165 +281,30 @@ const onHandleNext = async () => {
|
||||||
params.einStatus = einStatus.value
|
params.einStatus = einStatus.value
|
||||||
}
|
}
|
||||||
|
|
||||||
// 处理人脸
|
|
||||||
if (keyInfo.value.faceImg) {
|
|
||||||
keyInfo.value.faceImg.forEach((e) => {
|
|
||||||
if (!e.id) {
|
|
||||||
files.push({
|
|
||||||
file: e.file,
|
|
||||||
name: 'files',
|
|
||||||
})
|
|
||||||
fileMsg.push({
|
|
||||||
type: 1,
|
|
||||||
name: 'faceImg',
|
|
||||||
})
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
// 处理合同
|
// 处理合同
|
||||||
if (contractStatus.value === 'all_filled') {
|
if (contractStatus.value === 'all_filled' && !isEditContractStatus.value) {
|
||||||
params.bmWorkerContract = contractInfo.value
|
params.bmWorkerContract = contractInfo.value
|
||||||
contractImageList.value.forEach((item) => {
|
|
||||||
item.fileList.forEach((j) => {
|
|
||||||
if (!j.id) {
|
|
||||||
files.push({
|
|
||||||
file: j.file,
|
|
||||||
name: 'files',
|
|
||||||
})
|
|
||||||
fileMsg.push({
|
|
||||||
type: item.type,
|
|
||||||
name: item.name,
|
|
||||||
})
|
|
||||||
}
|
|
||||||
})
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 处理工资卡
|
// 处理工资卡
|
||||||
if (wageCardStatus.value === 'all_filled') {
|
if (wageCardStatus.value === 'all_filled') {
|
||||||
params.bmWorkerWageCard = wageCardInfo.value
|
params.bmWorkerWageCard = wageCardInfo.value
|
||||||
let reserveFileList = []
|
|
||||||
let deleteFileList = []
|
|
||||||
wageCardImageList.value.forEach((item) => {
|
|
||||||
item.fileList.forEach((j) => {
|
|
||||||
if (!j.id) {
|
|
||||||
files.push({
|
|
||||||
file: j.file,
|
|
||||||
name: 'files',
|
|
||||||
})
|
|
||||||
fileMsg.push({
|
|
||||||
type: item.type,
|
|
||||||
name: item.name,
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
if (j.id) {
|
|
||||||
reserveFileList.push(j.id)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
if (isEditWageCardStatus && reserveFileList.length > 0) {
|
|
||||||
deleteFileList = editUploadFileList.value
|
|
||||||
.filter((item) => !reserveFileList.includes(item.id))
|
|
||||||
.map((j) => j.id)
|
|
||||||
params.bmWorkerWageCard.delIds = deleteFileList.join(',')
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
delete params.faceImg // 删除无关数据
|
delete params.faceImg // 删除无关数据
|
||||||
const requestUrl = formType.value == 2 ? '/bmw/worker/edit' : '/bmw/worker/insert'
|
|
||||||
|
|
||||||
console.log('files---***---', files)
|
showLoading.value = true
|
||||||
|
const API = formType.value == 2 ? editPersonEntryApi : addPersonEntryApi
|
||||||
|
showLoading.value = false
|
||||||
|
|
||||||
const { encryptRequest, encryptResponse, checkIntegrity } =
|
console.log('params--**----请求参数', params)
|
||||||
commonStore?.requestConfig
|
const result = await API(params)
|
||||||
|
console.log('res--**----新增或修改的结果', result)
|
||||||
if (files.length > 0) {
|
if (result.code === 200) {
|
||||||
uni.uploadFile({
|
uni.$u.toast(result.msg)
|
||||||
url: requestUrl,
|
setTimeout(() => {
|
||||||
files: files,
|
uni.navigateBack()
|
||||||
name: 'files',
|
}, 500)
|
||||||
formData: {
|
|
||||||
params: !encryptRequest
|
|
||||||
? JSON.stringify(params)
|
|
||||||
: encryptWithSM4(JSON.stringify(params)),
|
|
||||||
fileMsg: !encryptRequest
|
|
||||||
? JSON.stringify(fileMsg)
|
|
||||||
: encryptWithSM4(JSON.stringify(fileMsg)),
|
|
||||||
},
|
|
||||||
header: {
|
|
||||||
encryptRequest,
|
|
||||||
encryptResponse,
|
|
||||||
checkIntegrity,
|
|
||||||
},
|
|
||||||
success: async (res) => {
|
|
||||||
console.log('res提交结果', res)
|
|
||||||
|
|
||||||
let data = null
|
|
||||||
if (encryptResponse) {
|
|
||||||
data = JSON.parse(decryptWithSM4(res.data))
|
|
||||||
} else {
|
|
||||||
data = JSON.parse(res.data)
|
|
||||||
}
|
|
||||||
if (data.code === 200) {
|
|
||||||
uni.$u.toast(data.msg)
|
|
||||||
setTimeout(() => {
|
|
||||||
uni.navigateBack()
|
|
||||||
}, 500)
|
|
||||||
|
|
||||||
const id = formType.value == 2 ? personId.value : data.data
|
|
||||||
await updatePersonLightStatusApi(id) // 更新红绿灯状态
|
|
||||||
} else {
|
|
||||||
uni.$u.toast(data.msg)
|
|
||||||
}
|
|
||||||
},
|
|
||||||
fail: (err) => {
|
|
||||||
sendLoading.value = false
|
|
||||||
},
|
|
||||||
})
|
|
||||||
} else {
|
|
||||||
uni.uploadFile({
|
|
||||||
url: requestUrl,
|
|
||||||
formData: {
|
|
||||||
params: !encryptRequest
|
|
||||||
? JSON.stringify(params)
|
|
||||||
: encryptWithSM4(JSON.stringify(params)),
|
|
||||||
fileMsg: !encryptRequest
|
|
||||||
? JSON.stringify(fileMsg)
|
|
||||||
: encryptWithSM4(JSON.stringify(fileMsg)),
|
|
||||||
},
|
|
||||||
header: {
|
|
||||||
encryptRequest,
|
|
||||||
encryptResponse,
|
|
||||||
checkIntegrity,
|
|
||||||
},
|
|
||||||
success: async (res) => {
|
|
||||||
console.log('res提交结果', res)
|
|
||||||
|
|
||||||
let data = null
|
|
||||||
if (encryptResponse) {
|
|
||||||
data = JSON.parse(decryptWithSM4(res.data))
|
|
||||||
} else {
|
|
||||||
data = JSON.parse(res.data)
|
|
||||||
}
|
|
||||||
if (data.code === 200) {
|
|
||||||
uni.$u.toast(data.msg)
|
|
||||||
setTimeout(() => {
|
|
||||||
uni.navigateBack()
|
|
||||||
}, 500)
|
|
||||||
|
|
||||||
const id = formType.value == 2 ? personId.value : data.data
|
|
||||||
await updatePersonLightStatusApi(id) // 更新红绿灯状态
|
|
||||||
} else {
|
|
||||||
uni.$u.toast(data.msg)
|
|
||||||
}
|
|
||||||
},
|
|
||||||
fail: (err) => {
|
|
||||||
sendLoading.value = false
|
|
||||||
},
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -50,7 +50,7 @@
|
||||||
|
|
||||||
<up-upload
|
<up-upload
|
||||||
multiple
|
multiple
|
||||||
:maxCount="3"
|
:maxCount="1"
|
||||||
accept="image"
|
accept="image"
|
||||||
@delete="deletePic"
|
@delete="deletePic"
|
||||||
:fileList="fileList"
|
:fileList="fileList"
|
||||||
|
|
|
||||||
|
|
@ -190,6 +190,10 @@ const onInputLoaded = async () => {
|
||||||
|
|
||||||
// 点击打开资料上传页面
|
// 点击打开资料上传页面
|
||||||
const onPersonExitItem = (item) => {
|
const onPersonExitItem = (item) => {
|
||||||
|
if (item.einStatus == 2) {
|
||||||
|
uni.$u.toast('人员已出场')
|
||||||
|
return
|
||||||
|
}
|
||||||
const { name, id, proId, proName, subName, idNumber, workerId, teamName } = item
|
const { name, id, proId, proName, subName, idNumber, workerId, teamName } = item
|
||||||
const params = {
|
const params = {
|
||||||
name,
|
name,
|
||||||
|
|
|
||||||
|
|
@ -28,3 +28,21 @@ export const updatePersonLightStatusApi = (id) => {
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 新增人员入场接口
|
||||||
|
export const addPersonEntryApi = (data) => {
|
||||||
|
return http({
|
||||||
|
url: `/bmw/app/appWorkerInsert`,
|
||||||
|
method: 'POST',
|
||||||
|
data,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// 修改人员入场接口
|
||||||
|
export const editPersonEntryApi = (data) => {
|
||||||
|
return http({
|
||||||
|
url: `/bmw/app/appWorkerEdit`,
|
||||||
|
method: 'POST',
|
||||||
|
data,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -29,7 +29,7 @@ const httpInterceptor = {
|
||||||
console.log(options.url, '文件上传')
|
console.log(options.url, '文件上传')
|
||||||
|
|
||||||
// 2. 设置请求超时时间,默认为60s,设置为 10s
|
// 2. 设置请求超时时间,默认为60s,设置为 10s
|
||||||
options.timeout = 10000
|
options.timeout = 60000
|
||||||
|
|
||||||
// 3. 增加小程序端请求头标识
|
// 3. 增加小程序端请求头标识
|
||||||
options.header = {
|
options.header = {
|
||||||
|
|
@ -52,7 +52,7 @@ const httpInterceptor = {
|
||||||
}
|
}
|
||||||
|
|
||||||
// 2. 设置请求超时时间,默认为60s,设置为 10s
|
// 2. 设置请求超时时间,默认为60s,设置为 10s
|
||||||
options.timeout = 10000
|
options.timeout = 60000
|
||||||
|
|
||||||
// 3. 增加小程序端请求头标识
|
// 3. 增加小程序端请求头标识
|
||||||
options.header = {
|
options.header = {
|
||||||
|
|
@ -99,6 +99,8 @@ const httpInterceptor = {
|
||||||
options.url = url
|
options.url = url
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
console.log(options, 'options--**----')
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue