From d56bbee80ec36d57a52a41160e65adffdfda0e92 Mon Sep 17 00:00:00 2001
From: gengchunlei <1807398631@qq.com>
Date: Fri, 6 Sep 2024 10:51:36 +0800
Subject: [PATCH] =?UTF-8?q?=20=E6=85=A2=E7=BB=BC=20=E5=8C=BB=E7=94=9F?=
 =?UTF-8?q?=E7=AB=AF=20=E9=9A=8F=E8=AE=BF=E8=A1=A8=E5=8D=95=E6=8E=A5?=
 =?UTF-8?q?=E5=8F=A3=E5=AF=B9=E6=8E=A5?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 src/api/doctor/generalFU.js                   | 28 +++++-
 src/doctor/Doctor.vue                         |  2 +-
 .../followUp/generalFU/detail/Detail.vue      |  3 +-
 .../followUp/generalFU/form/BaseInfo.vue      |  8 +-
 .../followUp/generalFU/form/GeneralFUForm.vue | 24 ++---
 src/doctor/followUp/generalFU/form/Index.vue  | 89 ++++++++++++++++---
 vue.config.js                                 |  6 +-
 7 files changed, 129 insertions(+), 31 deletions(-)

diff --git a/src/api/doctor/generalFU.js b/src/api/doctor/generalFU.js
index b926604..d85373a 100644
--- a/src/api/doctor/generalFU.js
+++ b/src/api/doctor/generalFU.js
@@ -1,4 +1,4 @@
-import {fetchBase} from '@/api/doctor/doctorFetch'
+import { fetchBase } from '@/api/doctor/doctorFetch'
 
 //获取登录信息
 export function getAuthInfo() {
@@ -7,7 +7,11 @@ export function getAuthInfo() {
 
 //查询居民信息
 export function getChronicResidentsId(residentInfoId) {
-    return fetchBase({ url: `/chronic-admin/v1/chronic-residents-record/resident-info`,body:{"residentInfoId":residentInfoId},loading: true})
+    return fetchBase({
+        url: `/chronic-admin/v1/chronic-residents-record/resident-info`,
+        body: { 'residentInfoId': residentInfoId },
+        loading: true
+    })
 }
 
 // 主键查询
@@ -38,4 +42,24 @@ export function getOfficeList(unitId) {
 // 根据科室id查询医生
 export function getOfficeDoctor(unitId, officeId) {
     return fetchBase({ url: `/tumour-admin/v1/sys-user/org-office-doctors/${unitId}/${officeId}` })
+}
+
+// 新增通用随访
+export function addCurrency(params) {
+    return fetchBase({ url: `/chronic-admin/v1/chronic-visit-currency/save`, body: params, loading: true })
+}
+
+//修改通用随访
+export function updateCurrency(params) {
+    return fetchBase({ url: `/chronic-admin/v1/chronic-visit-currency/update`, body: params, loading: true })
+}
+
+//图片上传
+export function upLoadMultifile(params) {
+    return fetchBase({
+        url: `/chronic-admin/v1/pictures-info/multifile`,
+        body: params,
+        loading: false,
+        contentType: 'file'
+    })
 }
\ No newline at end of file
diff --git a/src/doctor/Doctor.vue b/src/doctor/Doctor.vue
index 002277f..d8f8a02 100644
--- a/src/doctor/Doctor.vue
+++ b/src/doctor/Doctor.vue
@@ -46,7 +46,7 @@ export default {
             let token = getQueryVariable('token')
             if (!token) {
                 // token = sessionStorage.getItem('token')
-                token = '842c7b77-9f98-43b7-bfe4-909d22472904'
+                token = '4a3719ad-a7d8-47ae-accc-3e332ac2117b'
             }
             if (token) {
              sessionStorage.setItem('token', token)
diff --git a/src/doctor/followUp/generalFU/detail/Detail.vue b/src/doctor/followUp/generalFU/detail/Detail.vue
index 0a0f08b..ee9f477 100644
--- a/src/doctor/followUp/generalFU/detail/Detail.vue
+++ b/src/doctor/followUp/generalFU/detail/Detail.vue
@@ -135,6 +135,7 @@
 
 <script>
 import { fetchCurrencyById } from '@/api/doctor/generalFU'
+import { showToast } from 'vant'
 
 export default {
     name: 'Detail',
@@ -205,7 +206,7 @@ export default {
     methods: {
         async load() {
             if (!this.routerDetail.relationId) {
-                this.$message.info('未获取到信息')
+                showToast('未获取到信息');
                 return
             }
             let par = {
diff --git a/src/doctor/followUp/generalFU/form/BaseInfo.vue b/src/doctor/followUp/generalFU/form/BaseInfo.vue
index aee568c..067faac 100644
--- a/src/doctor/followUp/generalFU/form/BaseInfo.vue
+++ b/src/doctor/followUp/generalFU/form/BaseInfo.vue
@@ -453,6 +453,7 @@ import dayjs from 'dayjs'
 const defaultForm = (info = {}) => {
     const form = {
         id: undefined,
+        personId: undefined,
         residentInfoId: undefined,
         // 年龄
         currentAge: undefined,
@@ -666,6 +667,7 @@ export default {
             return new Promise((resolve, reject) => {
                 this.$refs.form.validate().then(() => {
                     const {
+                        personId,
                         visitSituation,
                         lossReason,
                         deathReason,
@@ -685,8 +687,12 @@ export default {
                         visitWay,
                         isHealthGuide,
                         screenTime,
+                        residentInfoId: this.form.residentInfoId,
                         urgentInsContent: content,
-                        residentsRecord: {...others},
+                        residentsRecord: {
+                            ...others,
+                            id: this.form.personId,
+                        },
                     }
                     resolve(
                         fetchDataHandle(par, {
diff --git a/src/doctor/followUp/generalFU/form/GeneralFUForm.vue b/src/doctor/followUp/generalFU/form/GeneralFUForm.vue
index ae9beba..2ece50c 100644
--- a/src/doctor/followUp/generalFU/form/GeneralFUForm.vue
+++ b/src/doctor/followUp/generalFU/form/GeneralFUForm.vue
@@ -64,7 +64,7 @@
                             <div>
                                 <doc-icon type='doc-remove' class='remove' @click='delImg(item.indexF)'></doc-icon>
                             </div>
-                            <img :src='item.src' class='ml-2' style='width: 95px;height: 95px;'
+                            <img :src='item.trueDownloadUrl' class='ml-2' style='width: 95px;height: 95px;'
                                  @click='toPreview(index)'>
                         </div>
                     </div>
@@ -112,7 +112,7 @@
                                 <div>
                                     <doc-icon type='doc-remove' class='remove' @click='delImg2(item.indexF)'></doc-icon>
                                 </div>
-                                <img :src='item.src' class='ml-2' style='width: 95px;height: 95px;'
+                                <img :src='item.trueDownloadUrl' class='ml-2' style='width: 95px;height: 95px;'
                                      @click='toPreview(index)'>
                             </div>
                         </div>
@@ -187,9 +187,6 @@ export default {
             imgList: [],
             imgList2: [],
             showDate: false,
-            showOne: false,
-            showTwo: false,
-            showThree: false,
             rules: {
                 nextVisitDate: [{required: true,message: '请选择'}]
             }
@@ -199,6 +196,10 @@ export default {
         'info': {
             handler() {
                 this.form = this.setForm(this.info)
+                if (this.info.id) {
+                    this.imgList = this.info.uploadVisitRecordImageList || []
+                    this.imgList2 = this.info.sceneVisitImageList || []
+                }
             },
             immediate: true
         },
@@ -291,7 +292,7 @@ export default {
             let maxIndexF =  Math.max(...this.imgList.map(item => item.indexF));
             newFile.forEach((item, index) => {
                 item['indexF'] = maxIndexF+ index + 1
-                item['src'] = window.URL.createObjectURL(item)
+                item['trueDownloadUrl'] = window.URL.createObjectURL(item)
                 item['imgFlag'] = ''
                 if (item.type == 'application/pdf') {
                     item['imgFlag'] = 'pdf'
@@ -309,7 +310,7 @@ export default {
             let maxIndexF =  Math.max(...this.imgList2.map(item => item.indexF));
             newFile.forEach((item, index) => {
                 item['indexF'] = maxIndexF+ index + 1
-                item['src'] = window.URL.createObjectURL(item)
+                item['trueDownloadUrl'] = window.URL.createObjectURL(item)
                 item['imgFlag'] = ''
                 if (item.type == 'application/pdf') {
                     item['imgFlag'] = 'pdf'
@@ -324,7 +325,7 @@ export default {
         toPreview(index) {
             // let list = []
             // this.imgList.forEach(item => {
-            //     list.push(item.src)
+            //     list.push(item.trueDownloadUrl)
             // })
             // showImagePreview({
             //     images: list,
@@ -335,7 +336,7 @@ export default {
         },
         //pdf预览
         toPdf(item) {
-            // window.open(item.src)
+            // window.open(item.trueDownloadUrl)
         },
         delImg(index) {
             this.imgList = this.imgList.filter(item => item.indexF != index)
@@ -351,9 +352,10 @@ export default {
             return new Promise((resolve, reject) => {
                 this.$refs.form.validate().then(() => {
                     let par = {
-                        img1: this.imgList,
-                        img2: this.imgList2,
+                        img1: this.imgList || [],
+                        img2: this.imgList2 || [],
                        ...this.form,
+                        healthGuideContent: JSON.stringify(this.form.visitHealthGuideList)
                     }
                     resolve(par)
                 }).catch((e) => {
diff --git a/src/doctor/followUp/generalFU/form/Index.vue b/src/doctor/followUp/generalFU/form/Index.vue
index 10999dc..39e6380 100644
--- a/src/doctor/followUp/generalFU/form/Index.vue
+++ b/src/doctor/followUp/generalFU/form/Index.vue
@@ -4,7 +4,8 @@
         <div class='p-4 h-overflow'>
             <base-info :info='info' v-show='step == 1' ref='baseInfo'
                        @changeVisitSituation='changeVisitSituation'></base-info>
-            <general-f-u-form :info='info' :first-form='firstForm' v-show='step == 2' ref='generalFUForm'></general-f-u-form>
+            <general-f-u-form :info='info' :first-form='firstForm' v-show='step == 2'
+                              ref='generalFUForm'></general-f-u-form>
             <common-bottom :info='info' v-show='step == 3' ref='commonBottom'></common-bottom>
         </div>
         <div class='pt-2 pb-2'>
@@ -37,7 +38,13 @@
 
 <script>
 import BaseInfo from '@/doctor/followUp/generalFU/form/BaseInfo'
-import { fetchCurrencyById, getChronicResidentsId } from '@/api/doctor/generalFU'
+import {
+    addCurrency,
+    fetchCurrencyById,
+    getChronicResidentsId,
+    updateCurrency,
+    upLoadMultifile
+} from '@/api/doctor/generalFU'
 import GeneralFUForm from '@/doctor/followUp/generalFU/form/GeneralFUForm'
 import CommonBottom from '@/doctor/followUp/generalFU/form/CommonBottom'
 
@@ -51,7 +58,7 @@ export default {
             visitSituation: 1,
             step: 1,
             //第一步提交的表单
-            firstForm: {},
+            firstForm: {}
         }
     },
     created() {
@@ -66,8 +73,20 @@ export default {
         async init() {
             this.info = {}
             const res = await getChronicResidentsId(this.routerDetail.residentInfoId)
-            const { id, ...others } = res.data
+            const {
+                id,
+                createDate,
+                createDoctorId,
+                createDoctorName,
+                createOfficeId,
+                createOfficeName,
+                createUnitId,
+                createUnitName,
+                updated,
+                ...others
+            } = res.data
             this.info = {
+                personId: id,
                 ...others
             }
             this.info.diseaseType = this.routerDetail.diseaseType
@@ -79,23 +98,69 @@ export default {
                 }
             }
         },
-       async toNext(val) {
+        async toNext(val) {
             if (val == 2) {
                 this.firstForm = await this.$refs.baseInfo.onSubmit()
             }
-           if (val == 3) {
+            if (val == 3) {
                 await this.$refs.generalFUForm.onSubmit()
-           }
+            }
             this.step = val
         },
         changeVisitSituation(val) {
             this.visitSituation = val
         },
-       async onsubmit() {
-        let baseInfo = await this.$refs.baseInfo.onSubmit()
-        let generalFUForm =  await this.$refs.generalFUForm.onSubmit()
-        let commonBottom = await this.$refs.commonBottom.onSubmit()
-       },
+        //图片上传
+        async upload(imgList = []) {
+            let list = []
+            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.join()
+        },
+        async onsubmit() {
+            debugger
+            let baseInfo = await this.$refs.baseInfo.onSubmit()
+            let generalFUForm = await this.$refs.generalFUForm.onSubmit()
+            let commonBottom = await this.$refs.commonBottom.onSubmit()
+            let uploadVisitRecord = ''
+            let sceneVisitImage = ''
+            let fileId2 = Math.random().toString(16).substring(2, 8)
+            //图片上传
+            if (generalFUForm.img1.length) {
+                uploadVisitRecord = await this.upload(generalFUForm.img1)
+            }
+            if (generalFUForm.img2.length) {
+                sceneVisitImage = await this.upload(generalFUForm.img2)
+            }
+            let params = {
+                ...baseInfo,
+                ...generalFUForm,
+                ...commonBottom,
+                uploadVisitRecord,
+                sceneVisitImage
+            }
+            if (this.info.id) {
+                params.visitRecordId = this.info.visitRecordId
+            }
+            if (params.visitSituation == 2) {
+                params.visitWay = 14
+            }
+            let fun = this.info.id ? updateCurrency : addCurrency
+            fun(params, true).then(({ code }) => {
+                if (code == 'SUCCESS') {
+                    this.$router.back()
+                }
+            })
+        },
         toBack() {
             if (this.visitSituation == 1) {
                 if (this.step != 1) {
diff --git a/vue.config.js b/vue.config.js
index 7ecf9df..231a8f7 100644
--- a/vue.config.js
+++ b/vue.config.js
@@ -30,11 +30,11 @@ module.exports = defineConfig({
                 }
             },
             '/chronic-admin': {
-                target: 'https://beta-tumour.zmnyjk.com',
-                // target: 'http://192.168.1.26:8900',
+                // target: 'https://beta-tumour.zmnyjk.com',
+                target: 'http://192.168.1.26:8900',
                 changOrigin: true,
                 pathRewrite: {
-                    '^/chronic-admin': '/chronic-admin'
+                    '^/chronic-admin': '/'
                 }
             },
             '/chronic-resident': {
-- 
2.18.0