diff --git a/src/doctor/followUp/generalFU/detail/Detail.vue b/src/doctor/followUp/generalFU/detail/Detail.vue index 2ea22de50db211f2a2bc940800f6eb584231cc74..e181e2107af2d0073265dedef78b5999b8af0627 100644 --- a/src/doctor/followUp/generalFU/detail/Detail.vue +++ b/src/doctor/followUp/generalFU/detail/Detail.vue @@ -259,10 +259,10 @@ export default { const {uploadVisitRecordImageList = []} = this.info uploadVisitRecordImageList.forEach(item => { item['imgFlag'] = '' - if (item.type == 'application/pdf') { + if (item.fileType == 'pdf') { item['imgFlag'] = 'pdf' } - if (item.type == 'image/jpeg' || item.type == 'image/png') { + if (item.fileType == 'img') { item['imgFlag'] = 'img' } }) @@ -272,10 +272,10 @@ export default { const {sceneVisitImageList = []} = this.info sceneVisitImageList.forEach(item => { item['imgFlag'] = '' - if (item.type == 'application/pdf') { + if (item.fileType == 'pdf') { item['imgFlag'] = 'pdf' } - if (item.type == 'image/jpeg' || item.type == 'image/png') { + if (item.fileType == 'img') { item['imgFlag'] = 'img' } }) diff --git a/src/doctor/followUp/generalFU/form/GeneralFUForm.vue b/src/doctor/followUp/generalFU/form/GeneralFUForm.vue index 2ece50cd5e51e2ae9aa177331f512083098db5d8..2ef074a3f97635b2c044a8bf1851b62b5bd4eb80 100644 --- a/src/doctor/followUp/generalFU/form/GeneralFUForm.vue +++ b/src/doctor/followUp/generalFU/form/GeneralFUForm.vue @@ -184,8 +184,12 @@ export default { return { store: useStore(), form: {}, + //展示用 imgList: [], imgList2: [], + //input图片值 + imgInputList1: [], + imgInputList2: [], showDate: false, rules: { nextVisitDate: [{required: true,message: '请选择'}] @@ -197,8 +201,8 @@ export default { handler() { this.form = this.setForm(this.info) if (this.info.id) { - this.imgList = this.info.uploadVisitRecordImageList || [] - this.imgList2 = this.info.sceneVisitImageList || [] + this.imgList = this.imgListInfo1 + this.imgList2 = this.imgListInfo2 } }, immediate: true @@ -231,7 +235,35 @@ export default { res = true } return res - } + }, + imgListInfo1() { + const {uploadVisitRecordImageList = []} = this.info + uploadVisitRecordImageList.forEach((item, index) => { + item['imgFlag'] = '' + item['indexF'] = index + 1 + if (item.fileType == 'pdf') { + item['imgFlag'] = 'pdf' + } + if (item.fileType == 'img') { + item['imgFlag'] = 'img' + } + }) + return uploadVisitRecordImageList + }, + imgListInfo2() { + const {sceneVisitImageList = []} = this.info + sceneVisitImageList.forEach((item, index) => { + item['imgFlag'] = '' + item['indexF'] = index + 1 + if (item.fileType == 'pdf') { + item['imgFlag'] = 'pdf' + } + if (item.fileType == 'img') { + item['imgFlag'] = 'img' + } + }) + return sceneVisitImageList + }, }, methods: { setForm(info = {}) { @@ -302,6 +334,7 @@ export default { } }) this.imgList = this.imgList.concat(newFile) + this.imgInputList1 = this.imgInputList1.concat(newFile) }, choiceImg2() { let input = document.getElementById('imgId2') @@ -320,6 +353,8 @@ export default { } }) this.imgList2 = this.imgList2.concat(newFile) + console.log(this.imgList2) + this.imgInputList2 = this.imgInputList2.concat(newFile) }, //图片预览 toPreview(index) { @@ -340,9 +375,11 @@ export default { }, delImg(index) { this.imgList = this.imgList.filter(item => item.indexF != index) + this.imgInputList1 = this.imgInputList1.filter(item => item.indexF != index) }, delImg2(index) { this.imgList2 = this.imgList2.filter(item => item.indexF != index) + this.imgInputList2 = this.imgInputList2.filter(item => item.indexF != index) }, dataConfirm({ selectedValues }) { this.form.nextVisitDate = selectedValues.join('-') @@ -354,6 +391,8 @@ export default { let par = { img1: this.imgList || [], img2: this.imgList2 || [], + imgInput1: this.imgInputList1, + imgInput2: this.imgInputList2, ...this.form, healthGuideContent: JSON.stringify(this.form.visitHealthGuideList) } diff --git a/src/doctor/followUp/generalFU/form/Index.vue b/src/doctor/followUp/generalFU/form/Index.vue index 340f1198e6ed2d644ba9d5b5e00918f0c94ca9a3..b46db88d4555e16422301d37b47c11d8e97bae80 100644 --- a/src/doctor/followUp/generalFU/form/Index.vue +++ b/src/doctor/followUp/generalFU/form/Index.vue @@ -119,32 +119,53 @@ export default { //图片上传 async upload(imgList = []) { let list = [] - let fileId = Math.random().toString(16).substring(2, 8) - let data = new FormData() - data.append('parentId', fileId) + if (imgList.length) { + let fileId = Math.random().toString(16).substring(2, 8) + let data = new FormData() + data.append('parentId', fileId) + imgList.forEach(item => { + data.append('files', item) + }) + let res = await upLoadMultifile(data) + let result = res.data || [] + result.forEach(item => { + list.push(item.id) + }) + } + return list + }, + //原图片数据处理 + baseImgHandle(imgList = []) { + let list = [] imgList.forEach(item => { - data.append('files', item) - }) - let res = await upLoadMultifile(data) - let result = res.data || [] - result.forEach(item => { list.push(item.id) }) - return list.join() + return list }, async onsubmit() { let baseInfo = await this.$refs.baseInfo.onSubmit() let generalFUForm = await this.$refs.generalFUForm.onSubmit() let commonBottom = await this.$refs.commonBottom.onSubmit() + let imgInput1List = [] + let imgInput2List = [] let uploadVisitRecord = '' let sceneVisitImage = '' - let fileId2 = Math.random().toString(16).substring(2, 8) //图片上传 + if (generalFUForm.imgInput1.length) { + imgInput1List = await this.upload(generalFUForm.imgInput1) + } + if (generalFUForm.imgInput2.length) { + imgInput2List = await this.upload(generalFUForm.imgInput2) + } if (generalFUForm.img1.length) { - uploadVisitRecord = await this.upload(generalFUForm.img1) + let img1List = this.baseImgHandle(generalFUForm.img1) + let lsit1 = [...imgInput1List, ...img1List] + uploadVisitRecord = Array.from(new Set(lsit1)).join() } if (generalFUForm.img2.length) { - sceneVisitImage = await this.upload(generalFUForm.img2) + let img2List = this.baseImgHandle(generalFUForm.img2) + let lsit2 = [...imgInput2List, ...img2List] + sceneVisitImage = Array.from(new Set(lsit2)).join() } let params = { ...baseInfo,