Browse Source

feat:详情提交

main
wally 2 years ago
parent
commit
ee62a91267
  1. 18
      components/CodeFormItem/CodeFormItem.vue
  2. 191
      components/DetailAidRecord/DetailAidRecord.vue
  3. 26
      config/code.ts
  4. 4
      uni.scss

18
components/CodeFormItem/CodeFormItem.vue

@ -10,24 +10,20 @@
<uni-data-select :value="value" :modelValue="value" :localdata="config.range" @change="$emit('on-change', $event)" <uni-data-select :value="value" :modelValue="value" :localdata="config.range" @change="$emit('on-change', $event)"
v-else-if="config.type === 'select'"></uni-data-select> v-else-if="config.type === 'select'"></uni-data-select>
<view v-else-if="config.type === 'text'" class="flex-1 flex justify-end uni-secondary-color u-font-sm" style="height: 35px;"
@click="$emit('on-click', config.text)">
{{ value }}
<uni-icons type="forward" v-if="config.rightArrow" size="16" />
</view>
</view> </view>
</template> </template>
<script lang="ts" setup> <script lang="ts" setup>
import { CODE_DICT } from '@/config/code' import { CODE_DICT } from '@/config/code'
import type { IConfig } from '@/config/code'
import { computed } from 'vue' import { computed } from 'vue'
interface IConfig {
text: string
type: string
default: string
range?: { value: string, text: string }[]
showType?: {
type: string
code: string
value: string
}
}
interface IProps { interface IProps {
code: string code: string
value: string value: string

191
components/DetailAidRecord/DetailAidRecord.vue

@ -1,159 +1,57 @@
<template> <template>
<view class=""> <view class="">
<uni-section type="line" title="患者急救记录" titleFontSize="16px"> </uni-section> <uni-section type="line" title="患者急救记录" titleFontSize="16px"> </uni-section>
<uni-forms :modelValue="baseInfo" :label-width="160" class="white uni-radius-lg uni-pa-10"> <uni-forms :modelValue="codeAidForm" :label-width="160" class="white uni-radius-lg uni-pa-10">
<uni-forms-item label="身高" name="patientName"> <uni-forms-item :name="key" v-for="(item, key) in codeAidForm" :key="key">
<uni-easyinput type="digit" v-model="baseInfo.patientName" placeholder="请输入姓名" @change="onBaseChange('patientName', $event)" /> <template v-slot:label>
<view class="full-height flex" style="width: 135px">
<!-- @ts-ignore -->
{{ CODE_DICT[key]?.text }} <text v-if="CODE_DICT[key].description"
class="uni-secondary-color">{{ CODE_DICT[key].description }}</text>
</view>
</template>
<!-- {{ key }} -->
<CodeFormItem :code="key" :value="item" @on-change="onChange(key, $event)" />
</uni-forms-item> </uni-forms-item>
<uni-forms-item name="patientGender" label="性别">
<uni-data-checkbox v-model="baseInfo.patientGender" :localdata="GENDER_LIST"
@change="onBaseChange('patientGender', $event.detail.value)" />
</uni-forms-item>
<uni-forms-item label="民族" name="patientNation">
<uni-data-select :localdata="nationList" v-model="baseInfo.patientNation" :clear="false"
@change="onBaseChange('patientNation', $event)" />
</uni-forms-item>
<uni-forms-item label="身份证号" name="patientIdCardNo">
<uni-easyinput type="idcard" v-model="baseInfo.patientIdCardNo" placeholder="请输入身份证号"
@change="onBaseChange('patientIdCardNo', $event)" />
</uni-forms-item>
<template v-for="(item, key) in codeForm" :key="key">
<uni-forms-item :name="key" :label="CODE_DICT[key].text" v-if="computeShow(key)">
<CodeFormItem :code="key" :value="item" :show="computeShow(key)" @on-change="onChange(key, $event)" />
</uni-forms-item>
</template>
</uni-forms> </uni-forms>
<uni-section type="line" title="疑似诊断" titleFontSize="16px"> </uni-section> <uni-section type="line" title="疑似诊断" titleFontSize="16px"> </uni-section>
<uni-data-checkbox mode="list" v-model="baseInfo.firstAidZlType" :localdata="FIRST_AID_ZL_TYPE" class="white uni-radius-lg uni-pa-6" <!-- <uni-data-checkbox mode="list" v-model="baseInfo.firstAidZlType" :localdata="FIRST_AID_ZL_TYPE" class="white uni-radius-lg uni-pa-6"
@change="onBaseChange('firstAidZlType', $event.detail.value)"> @change="onBaseChange('firstAidZlType', $event.detail.value)">
</uni-data-checkbox> </uni-data-checkbox> -->
</view> </view>
</template> </template>
<script lang="ts" setup> <script lang="ts" setup>
import { reactive, ref, computed, inject } from 'vue'; import { reactive, computed, inject } from 'vue';
import type { Ref } from 'vue' import type { Ref } from 'vue'
import { useUserStore } from '@/store/modules/user' import { GET_GENDER_TEXT_BY_CODE } from '@/config/service'
import { GENDER_LIST, FIRST_AID_ZL_TYPE } from '@/config/service'
import { CODE_DICT } from '@/config/code';
import { useServiceStore } from '@/store/modules/service'; import { useServiceStore } from '@/store/modules/service';
import { CODE_DICT } from '@/config/code';
const firstAidId = inject<Ref<string>>('firstAidId') const firstAidId = inject<Ref<string>>('firstAidId')
const userStore = useUserStore()
const serviceStore = useServiceStore() const serviceStore = useServiceStore()
const baseInfo = reactive({ const codeAidForm = reactive({
patientName: '张三', 'RYPG-HEIGHT': '',
patientGender: 0, 'RYPG-WEIGHT': '',
patientNation: '汉族', 'RYPG-GENDER': '',
patientIdCardNo: '142222188901120112', 'RYPG-BMI': '',
firstAidZlType: 0 'RYPG-SYSTOLIC-PRESSURE': '',
}) 'RYPG-DIASTOLIC-PRESSURE': '',
'RYPG-PULSE': '',
const codeForm = reactive({ 'RYPG-MRS': '',
'JBXX-SFXHCZ': '已知', 'RYPG-NIHSS': '',
'JBXX-FBSJ': '', 'RYPG-BLOOD-REPORT-TIME': '',
'JBXX-ZHZC-TIME': '', 'RYPG-BLOOD-SUGAR': '',
'JBXX-SFYNCZ': '是', 'RYPG-CT-LK-TIME': ''
'JBXX-DDJZ-TIME': '',
'JBXX-TZCZYS-TIME': '',
'JBXX-CZYSDC-TIME': '',
'JBXX-LYFS': ''
}) })
const nationList = ref([])
const token = computed(() => userStore.token)
const currentPatient = computed(() => serviceStore.currentPatient) const currentPatient = computed(() => serviceStore.currentPatient)
//
async function onSubmit() {
const param = { ...baseInfo, }
try {
const { firstAidId, firstAidStatus } = await uni.$u.api.createAid(param)
uni.$u.toast('创建成功')
uni.$u.openPage('detail2', false, `firstAidId=${firstAidId}&firstAidStatus=${firstAidStatus}`)
} catch (error) {
uni.$u.alertError(error)
}
}
//
function onScan() {
uni.chooseImage({
count: 1,
sizeType: ['original', 'compressed'],
sourceType: ['album', 'camera'],
success(res) {
upload(res.tempFilePaths[0])
}
});
}
//
function upload(tempPath: string) {
const host = uni.getStorageSync(uni.$u.LOCAL_KEY.HOST)
if (!host) {
uni.showModal({ title: '提示', content: '请先配置服务器地址' })
return
}
uni.uploadFile({
url: `${host}/sys/ocr/idcardInfo`, //
filePath: tempPath,
name: 'file',
header: { Authorization: `Bearer ${token.value}` },
success: (uploadFileRes) => {
if (!uploadFileRes?.data) {
uni.$u.toast('请求失败')
return
}
const { msg, code, data } = JSON.parse(uploadFileRes.data) as any
if (code === 200) {
const { name, sex, idCardNo, nation } = data
baseInfo.patientName = name || ''
baseInfo.patientGender = sex || ''
baseInfo.patientNation = nation || ''
baseInfo.patientIdCardNo = idCardNo || ''
// handleScan(url)
} else if (code === 401) {
uni.$u.api.login().then(upload(tempPath))
} else {
uni.$u.toast(msg)
}
}
});
}
/**
* 基础信息更新
* @param {string} type 字段名
* @param {string} event 值信息
*/
async function onBaseChange(type: string, event: string) {
console.log(firstAidId?.value);
if (!firstAidId?.value) {
uni.$u.alertError('缺少急救id参数')
return
}
const param = { [type]: event, firstAidId: firstAidId?.value }
try {
await uni.$u.api.updateAidBase(param)
uni.$u.toast('更新成功')
} catch (error) {
uni.$u.alertError(error)
}
}
// code form item change // code form item change
async function onChange(code: string, value: string) { async function onChange(code: string, value: string) {
codeForm[code] = value // codeForm[code] = value
try { try {
if (!firstAidId?.value) { if (!firstAidId?.value) {
uni.$u.alertError('缺少急救id参数') uni.$u.alertError('缺少急救id参数')
@ -167,40 +65,21 @@ async function onChange(code: string, value: string) {
} }
} }
// code form
function computeShow(code: string) {
const { showType } = CODE_DICT[code]
if (!showType) return true
return (showType.type === 'value' && codeForm[showType.code] === showType.value)
}
//
async function getNationList() {
try {
const data = await uni.$u.api.getNationList()
nationList.value = data.map((item: string) => ({ value: item, text: item }))
} catch (error) {
uni.$u.alertError(error)
}
}
function init() { function init() {
//
getNationList()
// store // store
if (!currentPatient.value) return if (!currentPatient.value) return
for (const key in baseInfo) {
baseInfo[key] = currentPatient.value[key]
}
// code // code
const { recordValDict } = currentPatient.value const { recordValDict, patientGender } = currentPatient.value
if (!recordValDict) return if (!recordValDict) return
for (const key in codeForm) { for (const key in codeAidForm) {
if (!recordValDict[key]) continue if (!recordValDict[key]) continue
codeForm[key] = recordValDict[key][0]?.answer[0] || '' codeAidForm[key] = recordValDict[key][0]?.answer[0] || ''
} }
codeAidForm['RYPG-GENDER'] = GET_GENDER_TEXT_BY_CODE[patientGender]
} }

26
config/code.ts

@ -1,3 +1,17 @@
export interface IConfig {
text: string
description?: string
rightArrow?: boolean
type: string
default: string
range?: { value: string; text: string }[]
showType?: {
type: string
code: string
value: string
}
}
// 患者基本信息 // 患者基本信息
export const BASE_CODE_DICT = { export const BASE_CODE_DICT = {
'JBXX-SFXHCZ': { 'JBXX-SFXHCZ': {
@ -82,12 +96,8 @@ export const AID_RECORD_DICT = {
inputType: 'digit', inputType: 'digit',
default: '', default: '',
}, },
'RYPG-WEIGHT': { 'RYPG-WEIGHT': { text: '体重', description: '(kg)', type: 'text', default: '' },
text: '体重', 'RYPG-GENDER': { text: '性别', description: '', type: 'text', default: '' },
description: '(kg)',
type: 'text',
default: '',
},
'RYPG-BMI': { 'RYPG-BMI': {
text: 'BMI', text: 'BMI',
description: '', description: '',
@ -142,7 +152,7 @@ export const AID_RECORD_DICT = {
inputType: 'digit', inputType: 'digit',
default: '', default: '',
}, },
'RYPG-CT-JCWB-TIME': { 'RYPG-CT-LK-TIME': {
text: 'CT完成时间', text: 'CT完成时间',
type: 'datetime', type: 'datetime',
default: '', default: '',
@ -151,4 +161,4 @@ export const AID_RECORD_DICT = {
} }
// all, you know? // all, you know?
export const CODE_DICT = { ...BASE_CODE_DICT } export const CODE_DICT: { [key: string]: IConfig } = { ...BASE_CODE_DICT, ...AID_RECORD_DICT }

4
uni.scss

@ -155,3 +155,7 @@ $u-type-success: #1bb299;
padding: 20px; padding: 20px;
background-color: #fff; background-color: #fff;
} }
.uni-forms-item.is-direction-left {
align-items: center;
}

Loading…
Cancel
Save