index.tsx
3.0 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
import React, { memo, useEffect, useState } from 'react'
import type { FC, ReactNode } from 'react'
import { Image } from 'antd'
import { EyeOutlined } from '@ant-design/icons'
import { useAppDispatch, useAppSelector, shallowEqualApp } from '@/store'
import { fetchPrescriptionDetailAction } from '@/store/modules/order'
import { ViewPrescriptionWrapper } from '../style'
import type { PrescriptionDetailType } from '@/types'
import GHandler from '@/utils/methods'
interface IProps {
children?: ReactNode
id: string | number
}
const ViewPrescription: FC<IProps> = memo((props) => {
const dispatch = useAppDispatch()
const [PrescriptionDetail, setPrescriptionDetail] = useState<PrescriptionDetailType>()
useEffect(() => {
dispatch(fetchPrescriptionDetailAction({ id: props.id }))
}, [props.id])
const { PrescriptionDetailDetail } = useAppSelector(
(state) => ({
PrescriptionDetailDetail: state.order.PrescriptionDetailData
}),
shallowEqualApp
)
useEffect(() => {
setPrescriptionDetail(PrescriptionDetailDetail)
}, [PrescriptionDetailDetail])
return (
<ViewPrescriptionWrapper>
<div className="title">问诊病情:</div>
<div className="content">{PrescriptionDetail?.prescriptionForm || '暂无问诊病情'}</div>
<div className="title">处方药:</div>
<div className="listbox">
{Array.isArray(PrescriptionDetail?.drugList) && PrescriptionDetail?.drugList?.length ? (
PrescriptionDetail?.drugList?.map((_, index) => (
<div className="itemo">
<div className="flexJ black" key={index}>
<div>{_.name || '药物名称'}</div>
<div>¥{_.amount || 0}</div>
</div>
<div className="flexJ gray">
<div>{_.des || '描述'}</div>
<div>x{_.num || 0}</div>
</div>
</div>
))
) : (
<div className="title">暂无处方药</div>
)}
</div>
<div className="title">处方单证明:</div>
{Array.isArray(PrescriptionDetail?.prescriptionFile) && PrescriptionDetail?.prescriptionFile.length ? (
PrescriptionDetail.prescriptionFile.map((_) => (
<Image
width={120}
height={120}
preview={{
mask: <EyeOutlined />
}}
src={GHandler.downFile(_)}
className="marbot"
/>
))
) : typeof PrescriptionDetail?.prescriptionFile === 'string' && PrescriptionDetail.prescriptionFile.length ? (
PrescriptionDetail.prescriptionFile.split(',').map((_) => (
<Image
width={120}
height={120}
preview={{
mask: <EyeOutlined />
}}
src={GHandler.downFile(_)}
className="marbot"
/>
))
) : (
<div className="title">暂无处方单证明</div>
)}
<div className="black">总金额:¥{PrescriptionDetail?.award || 0}</div>
</ViewPrescriptionWrapper>
)
})
export default ViewPrescription