diff --git a/api/index.js b/api/index.js index bd550d7..678aa19 100644 --- a/api/index.js +++ b/api/index.js @@ -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 diff --git a/pages/certificate_information/add.vue b/pages/certificate_information/add.vue index c0cebf8..94553e5 100644 --- a/pages/certificate_information/add.vue +++ b/pages/certificate_information/add.vue @@ -2,12 +2,21 @@ - + + + + @@ -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) }) } }, diff --git a/pages/certificate_information/view.vue b/pages/certificate_information/view.vue index dab7046..55350b1 100644 --- a/pages/certificate_information/view.vue +++ b/pages/certificate_information/view.vue @@ -5,6 +5,7 @@ @@ -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({