|
|
import React, { memo, useEffect, useState, useRef, ElementRef } from 'react'
|
|
|
import type { FC, ReactNode } from 'react'
|
|
|
import { Tabs, Avatar, Space, Divider, Button, Modal, Pagination, Carousel, Empty } from 'antd'
|
|
|
import { Tabs, Avatar, Space, Divider, Button, Modal, Pagination, Carousel, Empty, message } from 'antd'
|
|
|
import type { TabsProps } from 'antd'
|
|
|
import { ConsultationOrderWrapper, ConsultationOrderItemWrapper } from './styled'
|
|
|
import { useAppDispatch, useAppSelector, shallowEqualApp } from '@/store'
|
...
|
...
|
@@ -11,13 +11,18 @@ import SendPrescription from '../../com/SendPrescription' |
|
|
import ViewPrescription from '../../com/ViewPrescription'
|
|
|
import ViewSymptom from '../../com/ViewSymptom'
|
|
|
import GHandler from '@/utils/methods'
|
|
|
import mAvatar from '@/assets/img/mAvatar.png'
|
|
|
|
|
|
interface IProps {
|
|
|
children?: ReactNode
|
|
|
orderList?: ConsultationOrderListItemType[]
|
|
|
}
|
|
|
|
|
|
const url = 'https://p1.ssl.qhmsg.com/dr/270_500_/t010c2d50907f0a7b9c.png'
|
|
|
const url = mAvatar
|
|
|
|
|
|
message.config({
|
|
|
top: 1400
|
|
|
})
|
|
|
|
|
|
const ShowOrderComHandler: FC<IProps> = (props) => {
|
|
|
const { orderList } = props
|
...
|
...
|
@@ -25,26 +30,58 @@ const ShowOrderComHandler: FC<IProps> = (props) => { |
|
|
const [confirmLoading, setConfirmLoading] = useState(false)
|
|
|
const [modalTitle, setModalTitle] = useState<string>(' ')
|
|
|
const [modalFlag, setModalFlag] = useState<number>(0)
|
|
|
const [orderId, setOrderId] = useState<string | number>('')
|
|
|
|
|
|
const SendPrescriptionRef = useRef<SendPrescriptionPropsType | null>(null)
|
|
|
|
|
|
const showModalHandler = (flag: number) => {
|
|
|
console.log(flag, '按钮状态')
|
|
|
const [messageApi, contextHolder] = message.useMessage()
|
|
|
|
|
|
const warning = (content: string) => messageApi.open({ type: 'warning', content: content })
|
|
|
|
|
|
const success = (content: string) => messageApi.open({ type: 'success', content: content })
|
|
|
|
|
|
const showModalHandler = (flag: number, orderId: string | number) => {
|
|
|
setOrderId(orderId)
|
|
|
|
|
|
setModalFlag(flag)
|
|
|
|
|
|
setModalTitle({ 1: '查看症状', 2: '发送处方单', 3: '查看处方单' }[flag] as string)
|
|
|
|
|
|
setOpenHandler(true)
|
|
|
}
|
|
|
|
|
|
const closeSendPrescriptionHandler = () => {
|
|
|
setTimeout(() => {
|
|
|
setOpenHandler(false)
|
|
|
|
|
|
setConfirmLoading(false)
|
|
|
}, 1300)
|
|
|
}
|
|
|
|
|
|
const handleOk = async () => {
|
|
|
if (modalFlag === 2) {
|
|
|
setConfirmLoading(true)
|
|
|
|
|
|
const instance = SendPrescriptionRef.current
|
|
|
|
|
|
await updateSend_prescription_form({
|
|
|
const ret = await updateSend_prescription_form({
|
|
|
...instance?.Send_prescription_formData,
|
|
|
drugList: JSON.stringify(instance?.Send_prescription_formData.drugList),
|
|
|
id: orderId,
|
|
|
prescriptionFile: instance?.fileList.map((_: any) => _.response.message).join()
|
|
|
})
|
|
|
|
|
|
if ([200].includes(ret.code)) {
|
|
|
success('发送成功')
|
|
|
|
|
|
closeSendPrescriptionHandler()
|
|
|
}
|
|
|
|
|
|
if ([500, 401, 403].includes(ret.code)) {
|
|
|
warning(ret.message)
|
|
|
|
|
|
closeSendPrescriptionHandler()
|
|
|
}
|
|
|
|
|
|
typeof instance?.setSend_prescription_formTypeData === 'function' &&
|
|
|
instance?.setSend_prescription_formTypeData({
|
|
|
drugList: [{ amount: '', des: '', name: '', num: '' }],
|
...
|
...
|
@@ -54,15 +91,8 @@ const ShowOrderComHandler: FC<IProps> = (props) => { |
|
|
|
|
|
typeof instance?.setFileList === 'function' && instance.setFileList([])
|
|
|
|
|
|
console.log(SendPrescriptionRef.current, 'SendPrescription 子组件实例')
|
|
|
// console.log(SendPrescriptionRef.current, 'SendPrescription 子组件实例')
|
|
|
|
|
|
setConfirmLoading(true)
|
|
|
|
|
|
setTimeout(() => {
|
|
|
setOpenHandler(false)
|
|
|
|
|
|
setConfirmLoading(false)
|
|
|
}, 2000)
|
|
|
return
|
|
|
}
|
|
|
|
...
|
...
|
@@ -72,23 +102,22 @@ const ShowOrderComHandler: FC<IProps> = (props) => { |
|
|
}
|
|
|
|
|
|
const handleCancel = () => {
|
|
|
console.log('Clicked cancel button')
|
|
|
|
|
|
setOpenHandler(false)
|
|
|
}
|
|
|
|
|
|
return (
|
|
|
<ConsultationOrderItemWrapper>
|
|
|
{contextHolder}
|
|
|
<Modal title={modalTitle} open={open} onOk={handleOk} cancelText="关闭" okText="确认" confirmLoading={confirmLoading} onCancel={handleCancel}>
|
|
|
{{ 1: <ViewSymptom id={1} />, 2: <SendPrescription ref={SendPrescriptionRef} />, 3: <ViewPrescription id={1} /> }[modalFlag]}
|
|
|
{{ 1: <ViewSymptom id={orderId} />, 2: <SendPrescription ref={SendPrescriptionRef} id={orderId} />, 3: <ViewPrescription id={orderId} /> }[modalFlag]}
|
|
|
</Modal>
|
|
|
{orderList?.length ? (
|
|
|
orderList.map((_, index) => (
|
|
|
<div className="orderItem " key={index}>
|
|
|
<div className="topinfo flexJ">
|
|
|
<div className=" flexA">
|
|
|
<Avatar size="large" src={<img src={_.user?.avatar || url} alt="avatar" />} />
|
|
|
<div className="username">{_.user?.nickname || '暂无用户名'}</div>
|
|
|
<Avatar size="large" src={<img src={GHandler.downFile(_.user?.avatar) || url} alt="avatar" />} />
|
|
|
<div className="username">{_.user?.nickName || '暂无用户名'}</div>
|
|
|
<div className="statetag flexC">{GHandler.optObjectValue('consultationWay', _.consultationWay || 10)}</div>
|
|
|
<div className="time">{_.time}</div>
|
|
|
</div>
|
...
|
...
|
@@ -96,12 +125,12 @@ const ShowOrderComHandler: FC<IProps> = (props) => { |
|
|
</div>
|
|
|
<div className="contenttext">
|
|
|
<span>就诊宠物:</span>
|
|
|
{GHandler.optObjectValue('petType', _?.petType || 30)}/{_?.age || '年龄未知'}/{GHandler.optObjectValue('petSex', _?.petSex || 1)}/
|
|
|
{GHandler.optObjectValue('symptom', _?.symptom as string)}/{_?.weight || '体重未知'}
|
|
|
{_?.petName}/{_?.petClass}/{_?.age || '年龄未知'}/{GHandler.optObjectValue('petSex', _?.petSex || 1)}/
|
|
|
{GHandler.optObjectValue('isSterilization', _?.isSterilization || 0)}/{_?.weight ? _?.weight + 'kg' : '体重未知'}
|
|
|
</div>
|
|
|
<div className="contenttext">
|
|
|
<span>病情描述:</span>
|
|
|
{_.prescriptionForm || '暂无病情描述'}
|
|
|
{_.supplement || '暂无病情描述'}
|
|
|
</div>
|
|
|
<Divider />
|
|
|
<div className="flexJ">
|
...
|
...
|
@@ -111,15 +140,32 @@ const ShowOrderComHandler: FC<IProps> = (props) => { |
|
|
</div>
|
|
|
<div className="flexA">
|
|
|
<Space wrap>
|
|
|
<Button type="primary" shape="round" onClick={() => showModalHandler(1)}>
|
|
|
<Button type="primary" shape="round" onClick={() => showModalHandler(1, _.id)}>
|
|
|
查看症状
|
|
|
</Button>
|
|
|
<Button type="primary" shape="round" onClick={() => showModalHandler(2)}>
|
|
|
发送处方单
|
|
|
</Button>
|
|
|
<Button type="primary" shape="round" onClick={() => showModalHandler(3)}>
|
|
|
查看处方单
|
|
|
</Button>
|
|
|
{[30, '30'].includes(_.orderState as string | number) ? (
|
|
|
<Button type="primary" shape="round" onClick={() => showModalHandler(2, _.id)}>
|
|
|
发送处方单
|
|
|
</Button>
|
|
|
) : (
|
|
|
''
|
|
|
)}
|
|
|
|
|
|
{[20, '20'].includes(_.orderState as string | number) ? (
|
|
|
<Button type="primary" shape="round" onClick={() => warning('请到app内进行接诊')}>
|
|
|
接诊
|
|
|
</Button>
|
|
|
) : (
|
|
|
''
|
|
|
)}
|
|
|
|
|
|
{[30, '30', 40, '40'].includes(_.orderState as string | number) ? (
|
|
|
<Button type="primary" shape="round" onClick={() => showModalHandler(3, _.id)}>
|
|
|
查看处方单
|
|
|
</Button>
|
|
|
) : (
|
|
|
''
|
|
|
)}
|
|
|
</Space>
|
|
|
</div>
|
|
|
</div>
|
...
|
...
|
@@ -139,14 +185,17 @@ const ConsultationOrder: FC<IProps> = memo(() => { |
|
|
|
|
|
const [pageNo, setPageNo] = useState<number>(1)
|
|
|
|
|
|
const [orderTotal, setOrderTotal] = useState<number>(0)
|
|
|
|
|
|
useEffect(() => {
|
|
|
// return
|
|
|
dispatch(fetchOrderDataAction({ pageNo: pageNo }))
|
|
|
}, [])
|
|
|
|
|
|
const { ConsultationOrder } = useAppSelector(
|
|
|
const { ConsultationOrder, ConsultationOrderTotal } = useAppSelector(
|
|
|
(state) => ({
|
|
|
ConsultationOrder: state.order.ConsultationOrderList
|
|
|
ConsultationOrder: state.order.ConsultationOrderList,
|
|
|
ConsultationOrderTotal: state.order.total
|
|
|
}),
|
|
|
shallowEqualApp
|
|
|
)
|
...
|
...
|
@@ -156,6 +205,7 @@ const ConsultationOrder: FC<IProps> = memo(() => { |
|
|
if (!ConsultationOrder.length) return
|
|
|
// console.log(ConsultationOrder, '问诊订单列表数据')
|
|
|
setCOrderList(ConsultationOrder)
|
|
|
setOrderTotal(ConsultationOrderTotal)
|
|
|
}, [ConsultationOrder])
|
|
|
|
|
|
const [COrderList, setCOrderList] = useState<ConsultationOrderListItemType[]>([])
|
...
|
...
|
@@ -168,7 +218,13 @@ const ConsultationOrder: FC<IProps> = memo(() => { |
|
|
{ key: '50', label: '已取消', children: ShowOrderComHandler({ orderList: COrderList }) }
|
|
|
]
|
|
|
|
|
|
const onChange = (key: string) => dispatch(fetchOrderDataAction({ pageNo: 1, orderState: key }))
|
|
|
const onChange = (key: string) => {
|
|
|
setCOrderList([])
|
|
|
|
|
|
setOrderTotal(0)
|
|
|
|
|
|
dispatch(fetchOrderDataAction({ pageNo: 1, orderState: key }))
|
|
|
}
|
|
|
|
|
|
const changeOrderListHandler = (e: number) => dispatch(fetchOrderDataAction({ pageNo: e }))
|
|
|
|
...
|
...
|
@@ -177,7 +233,7 @@ const ConsultationOrder: FC<IProps> = memo(() => { |
|
|
<div className="title">问诊订单</div>
|
|
|
<Tabs defaultActiveKey="0" items={items} onChange={onChange} />;
|
|
|
<div className="paginationBox flexD">
|
|
|
<Pagination defaultCurrent={1} total={50} onChange={(e) => changeOrderListHandler(e)} />
|
|
|
<Pagination defaultCurrent={1} total={orderTotal} onChange={(e) => changeOrderListHandler(e)} />
|
|
|
</div>
|
|
|
</ConsultationOrderWrapper>
|
|
|
)
|
...
|
...
|
|