From 7425658e0238ac59c1021a09bb9000f1248496e3 Mon Sep 17 00:00:00 2001 From: wally <18603454788@163.com> Date: Tue, 23 May 2023 23:35:39 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=9B=B4=E6=96=B0=E6=82=A3=E8=80=85?= =?UTF-8?q?=E4=BF=A1=E6=81=AF=E5=90=ABcode,=20=E6=9F=A5=E4=B8=8B=E4=B8=AA?= =?UTF-8?q?=E8=8A=82=E7=82=B9=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- api/modules/service.ts | 9 +++ components/CodeFormItem/CodeFormItem.vue | 9 ++- components/DetailBase/DetailBase.vue | 88 ++++++++++++++++++++---- hooks/useNextNode.ts | 54 +++++++++++++++ pages/detail2/detail2.vue | 29 ++++---- store/modules/service.ts | 1 + 6 files changed, 163 insertions(+), 27 deletions(-) create mode 100644 hooks/useNextNode.ts diff --git a/api/modules/service.ts b/api/modules/service.ts index 6f558ab..dad6596 100644 --- a/api/modules/service.ts +++ b/api/modules/service.ts @@ -24,4 +24,13 @@ export const serviceApi = { // 查病历数据 getAidInfo: (firstAidId: string, codeList = []) => post('/firstAid/queryAidRecord', { param: { firstAidId, codeList } }), + + // 更新急救基本信息 + updateAidBase: param => post('/firstAid/update', { param }), + + // 更新急救code信息 + updateAidCode: param => post('/firstAid/saveAidRecord', { param }), + + // 查 下一个节点 + getNextNode: (firstAidId: string) => post('/firstAid/next', { param: { firstAidId } }), } diff --git a/components/CodeFormItem/CodeFormItem.vue b/components/CodeFormItem/CodeFormItem.vue index cc24cd0..d1f8fc9 100644 --- a/components/CodeFormItem/CodeFormItem.vue +++ b/components/CodeFormItem/CodeFormItem.vue @@ -2,9 +2,14 @@ - + - + + + diff --git a/components/DetailBase/DetailBase.vue b/components/DetailBase/DetailBase.vue index b07b354..3d27e54 100644 --- a/components/DetailBase/DetailBase.vue +++ b/components/DetailBase/DetailBase.vue @@ -7,17 +7,24 @@ + - + + - + + - + + - + diff --git a/hooks/useNextNode.ts b/hooks/useNextNode.ts new file mode 100644 index 0000000..14673f4 --- /dev/null +++ b/hooks/useNextNode.ts @@ -0,0 +1,54 @@ +import { computed, onUnmounted, ref } from 'vue' + +import { onUnload } from '@dcloudio/uni-app' +import { useServiceStore } from '@/store/modules/service' + +export interface INextNode { + countDownInSeconds: string + firstAidId: number + nextStepCode: string + nextStepName: string + nextStepType: string // 0 仅显示 1 弹窗询问是否进入下个环节 +} + +export function useNextNode() { + const serviceStore = useServiceStore() + const nextNode = ref(null) + const currentFirstAidId = computed(() => serviceStore.currentFirstAidId) + let timer: number + + async function getNextNode() { + if (!currentFirstAidId.value) { + uni.$u.alertError('没有急救id信息') + return + } + try { + nextNode.value = await uni.$u.api.getNextNode(currentFirstAidId.value) + } catch (error) { + nextNode.value = null + uni.$u.alertError(error) + } + } + + // 循环查下个节点 + function intervalGetNextCode() { + timer && clearInterval(timer) + timer = setInterval(() => { + getNextNode() + }, 1000) + } + + onUnmounted(() => { + console.log('on unmounted') + + timer && clearInterval(timer) + timer = 0 + }) + + onUnload(() => { + console.log('on unload') + timer && clearInterval(timer) + timer = 0 + }) + return { nextNode, getNextNode, intervalGetNextCode } +} diff --git a/pages/detail2/detail2.vue b/pages/detail2/detail2.vue index 8f6dd43..bbb08dd 100644 --- a/pages/detail2/detail2.vue +++ b/pages/detail2/detail2.vue @@ -39,8 +39,8 @@ - - NIHSS评分 + + {{ nextNode.nextStepName }} 00 : @@ -68,41 +68,37 @@ - - -