Index.vue 4.13 KB
<template>
    <div>
        <van-nav-bar title='新增死亡记录' left-text='' left-arrow
                     @click-left='toBack'></van-nav-bar>
        <div class='p-4 h-overflow' ref='all'>
            <archive-common :info='info'
                            v-show='step == 1'
                            ref='baseInfo'
            ></archive-common>
            <death-record-form
                v-show='step == 2'
                ref='deathRecordForm'
            ></death-record-form>
        </div>
        <div class='bottom-small-line'></div>
        <div class='pt-2 pb-2'>
            <div class='px-5  grow flex flex-col justify-end' v-if='step == 1'>
                <van-button type='primary' block round
                            @click='toNext(2)'>下一步
                </van-button>
            </div>

            <div class='px-5  grow flex flex-col justify-end' v-if='step == 2'>
                <van-button type='primary' block round
                            @click='onsubmit'>提交
                </van-button>
            </div>
        </div>

    </div>
</template>

<script>
import { useStore } from '@/doctor/store'
import ArchiveCommon from '@/doctor/components/archiveCommon/archiveCommon'
import DeathRecordForm from '@/doctor/deathRecord/form/DeathRecordForm'
import { getChronicResidentsId } from '@/api/doctor/generalFU'
import { saveResidentsDeath } from '@/api/doctor/death'

export default {
    name: 'deathRecordIndex',
    components: { DeathRecordForm, ArchiveCommon },
    data() {
        return {
            store: useStore(),
            info: {},
            resident: {},
            step: 1
        }
    },
    computed: {
        routerDetail() {
            return this.$route.query
        },
        authInfo() {
            return this.store.authInfo
        }
    },
    created() {
        this.init()
    },
    methods: {
        async init() {
            this.info = {}
            const res = await getChronicResidentsId(this.routerDetail.residentInfoId)
            const {
                id,
                createDate,
                createDoctorId,
                createDoctorName,
                createOfficeId,
                createOfficeName,
                createUnitId,
                createUnitName,
                updated,
                ...others
            } = res.data
            this.info = {
                personId: id,
                ...others
            }
        },
        async toNext(val) {
            this.$refs.all.scrollTo(0, 0)
            if (val == 2) {
                await this.$refs.baseInfo.onSubmit()
            }
            this.step = val
        },
        async onsubmit() {
                let baseInfo = await this.$refs.baseInfo.onSubmit()
                let deathRecordForm = await this.$refs.deathRecordForm.onSubmit()
                let params = {
                    residentInfoId: this.routerDetail.residentInfoId,
                    createUnitId: this.authInfo.unitId,
                    createUnitName: this.authInfo.unitName,
                    // 录入科室
                    createOfficeId: this.authInfo.officeId,
                    createOfficeName: this.authInfo.officeName,
                    // 录入医生
                    createDoctorId: this.authInfo.relationId,
                    createDoctorName: this.authInfo.nickName,
                    residentsRecord: baseInfo,
                    ...deathRecordForm
                }
                saveResidentsDeath(params).then(res => {
                    this.store.onRefreshMark()
                    this.$router.replace({
                        path: '/doctor/patient-detail',
                        query: {
                            residentInfoId: this.routerDetail.residentInfoId
                        }
                    })
                })

        },
        toBack() {
            if (this.step != 1) {
                this.step--
                return
            }
            this.$router.back()
        }
    }
}
</script>

<style scoped lang='less'>
:deep(.van-nav-bar .van-icon) {
    color: #000000;
}

.h-overflow {
    height: calc(100vh - 110px);
    overflow-y: auto;
}
</style>