相关方证书无法更换图片bug

liujun-2024-06-06
liujun 2024-04-08 16:28:12 +08:00
parent 1564af86d4
commit 287a51c891
3 changed files with 90 additions and 29 deletions

View File

@ -28,7 +28,7 @@ export const setUserInfo = (params) => post("/app/user/edit", params) //修改
export const getCertificateInformationList = (params) => post("/app/specialUser/list", params) //证书信息列表
export const getCertificateInformationView = (params) => post("/app/specialUser/goEdit", params) //证书信息查看
export const setCertificateInformationAdd = (params) => uploads("/app/specialUser/add", params) //证书信息添加
export const setCertificateInformationEdit = (params) => upload("/app/specialUser/edit", params) //证书信息修改
export const setCertificateInformationEdit = (params) => uploads("/app/specialUser/edit", params) //证书信息修改
export const setCertificateInformationEditPost = (params) => post("/app/specialUser/edit", params) //证书信息修改
export const getDeptTree = (params) => post("/api/department/listzTree", params) //用户信息
export const getEMPLOYMENTAPPLYMANAGEMENTID = (params) => post("/app/user/getEMPLOYMENTAPPLYMANAGEMENTID",params)//获取EMPLOYMENTAPPLYMANAGEMENTID

View File

@ -2,12 +2,21 @@
<view class="content">
<view class="card">
<u--form labelPosition="left" :model="form" :rules="rules" ref="form" labelWidth="100px">
<u-form-item label="证书图片" prop="fileList" borderBottom required>
<u-form-item label="证书正面图片" prop="fileList" borderBottom required>
<u-upload
:fileList="form.fileList"
@afterRead="fnAfterRead"
@delete="fnDeletePic"
:maxCount="2"
:maxCount="1"
previewFullImage
></u-upload>
</u-form-item>
<u-form-item label="证书反面图片" prop="fileListBack" borderBottom required>
<u-upload
:fileList="form.fileListBack"
@afterRead="fnAfterRead1"
@delete="fnDeletePic1"
:maxCount="1"
previewFullImage
></u-upload>
</u-form-item>
@ -105,6 +114,7 @@ export default {
reviewTimeValue: new Date().toString(),
form: {
fileList: [],
fileListBack: [],
NAME: '',
SEX_NAME: '',
PHONE: '',
@ -128,6 +138,12 @@ export default {
message: '请上传证书图片',
trigger: ['change']
},
fileListBack: {
type: 'array',
required: true,
message: '请上传证书图片',
trigger: ['change']
},
CER_TYPE_NAME: {
required: true,
message: '请选择证书类型',
@ -205,15 +221,22 @@ export default {
},
methods: {
async fnGetData() {
if(this.SPECIAL_USER_ID){
if (this.SPECIAL_USER_ID) {
let resData = await getCertificateInformationView({
SPECIAL_USER_ID:this.SPECIAL_USER_ID
SPECIAL_USER_ID: this.SPECIAL_USER_ID
})
this.form = {...this.form, ...resData.pd,CER_TYPE_NAME:resData.pd.typeName}
this.$set(this.form,'fileList',[{url:this.$filePath + resData.pd.FILEPATH,FILEPATH:this.$filePath + resData.pd.FILEPATH}])
let resDatares = await getDataDictionary({DICTIONARIES_ID:this.form.SPECIAL_TYPE})
this.certificateTypeColumnsOpe = [resDatares.list]
}else {
this.form = {...this.form, ...resData.pd, CER_TYPE_NAME: resData.pd.typeName}
this.$set(this.form, 'fileList', [{
url: this.$filePath + resData.pd.FILEPATH,
FILEPATH: this.$filePath + resData.pd.FILEPATH
}])
this.$set(this.form, 'fileListBack', [{
url: this.$filePath + resData.pd.FILEPATH_BACK,
FILEPATH: this.$filePath + resData.pd.FILEPATH_BACK
}])
let resDatares = await getDataDictionary({DICTIONARIES_ID: this.form.SPECIAL_TYPE})
this.certificateTypeColumnsOpe = [resDatares.list]
} else {
let resData = await getUserInfo({
CORPINFO_ID: this.userInfo.CORPINFO_ID,
})
@ -221,9 +244,9 @@ export default {
this.fnCardIdDisassembly(this.form.CARD_ID)
this.fnCardIdDisassembly(this.form.CARD_ID)
}
if (this.form.SEX_NAME == '0') {
if (this.form.SEX_NAME === '0') {
this.form.SEX_NAME = '男'
} else if (this.form.SEX_NAME == '1') {
} else if (this.form.SEX_NAME === '1') {
this.form.SEX_NAME = '女'
}
},
@ -307,20 +330,32 @@ export default {
this.form.REVIEW_TIME = uni.$u.timeFormat(event.value, 'yyyy-mm-dd')
},
fnAfterRead(event) {
var houzhui = event.file.url.replace(/.+\./,"");
console.log(houzhui);
if(houzhui=="jpg"||houzhui=="png"){
this.form.fileList.push(event.file)
}else{
uni.$u.toast('图片格式不正确请上传jpg格式图片或者png格式图片')
this.form.fileList=[]
}
var houzhui = event.file.url.replace(/.+\./, "");
console.log(houzhui);
if (houzhui == "jpg" || houzhui == "png") {
this.form.fileList.push(event.file)
} else {
uni.$u.toast('图片格式不正确请上传jpg格式图片或者png格式图片')
this.form.fileList = []
}
},
fnAfterRead1(event) {
var houzhui = event.file.url.replace(/.+\./, "");
console.log(houzhui);
if (houzhui == "jpg" || houzhui == "png") {
this.form.fileListBack.push(event.file)
} else {
uni.$u.toast('图片格式不正确请上传jpg格式图片或者png格式图片')
this.form.fileListBack = []
}
},
fnDeletePic(event) {
this.form.fileList.splice(event.index, 1)
},
fnDeletePic1(event) {
this.form.fileListBack.splice(event.index, 1)
},
async fnSubmit() {
console.info(this.$refs)
this.$refs.form.validate().then(async () => {
@ -334,22 +369,43 @@ export default {
files.push({
name: 'FILEPATH_BACK',
file: this.form.fileList[1],
uri: this.form.fileList[1].url,
file: this.form.fileListBack[0],
uri: this.form.fileListBack[0].url,
})
if (files.length !== 2){
uni.$u.toast('请上传证书正反面')
return
}
await setCertificateInformationAdd({
// filePath: this.form.fileList[0].url,
files: files,
formData: {
...this.form
}
})
}else {
if (!this.form.fileList[0].FILEPATH) {
if (!this.form.fileList[0].FILEPATH || !this.form.fileListBack[0].FILEPATH) {
uni.$u.toast('1')
let files = []
if (!this.form.fileList[0].FILEPATH){
files.push({
name: 'FILEPATH',
file: this.form.fileList[0],
uri: this.form.fileList[0].url,
})
}
if (!this.form.fileListBack[0].FILEPATH){
files.push({
name: 'FILEPATH_BACK',
file: this.form.fileListBack[0],
uri: this.form.fileListBack[0].url,
})
}
await setCertificateInformationEdit({
filePath: this.form.fileList[0].url,
name: 'file',
files: files,
formData: {
...this.form
}
@ -362,13 +418,14 @@ export default {
}
}
uni.$u.toast('保存成功')
// uni.$u.toast('')
setTimeout(()=>{
uni.navigateBack()
},2000)
}).catch((e) => {
console.info(e)
uni.$u.toast('请补全必填项')
// uni.$u.toast('')
uni.$u.toast(e)
})
}
},

View File

@ -5,6 +5,7 @@
<u-cell title="证书图片">
<template #value>
<u--image :src="info.FILEPATH" width="100upx" height="100upx" radius="10upx" @click="fnPreview"></u--image>
<u--image v-if="info.FILEPATH_BACK" :src="info.FILEPATH_BACK" width="100upx" height="100upx" radius="10upx" @click="fnPreview"></u--image>
</template>
</u-cell>
<u-cell title="姓名" :value="info.NAME"></u-cell>
@ -46,6 +47,9 @@ export default {
})
this.info = resData.pd
this.$set(this.info,'FILEPATH',this.$filePath + resData.pd.FILEPATH)
if (resData.pd.FILEPATH_BACK){
this.$set(this.info,'FILEPATH_BACK',this.$filePath + resData.pd.FILEPATH_BACK)
}
},
fnPreview() {
uni.previewImage({