作者 韩昌

gaibug

@@ -15,6 +15,7 @@ @@ -15,6 +15,7 @@
15 "antd": "^5.9.3", 15 "antd": "^5.9.3",
16 "axios": "^1.4.0", 16 "axios": "^1.4.0",
17 "craco-less": "^3.0.1", 17 "craco-less": "^3.0.1",
  18 + "events": "^3.3.0",
18 "normalize.css": "^8.0.1", 19 "normalize.css": "^8.0.1",
19 "react": "^18.2.0", 20 "react": "^18.2.0",
20 "react-dom": "^18.2.0", 21 "react-dom": "^18.2.0",
1 -import React, { Suspense } from 'react'  
2 -import { useRoutes } from 'react-router-dom' 1 +import React, { Suspense, useEffect } from 'react'
  2 +import { useRoutes, useNavigate } from 'react-router-dom'
3 import routes from './router' 3 import routes from './router'
4 import { useAppSelector, useAppDispatch, shallowEqualApp } from './store' 4 import { useAppSelector, useAppDispatch, shallowEqualApp } from './store'
5 import { changeMessage } from './store/modules/counter' 5 import { changeMessage } from './store/modules/counter'
  6 +import EventBus from '@/utils/events'
6 7
7 function App() { 8 function App() {
8 const { counter } = useAppSelector((state) => state, shallowEqualApp) 9 const { counter } = useAppSelector((state) => state, shallowEqualApp)
  10 + const navigate = useNavigate()
9 const dispatch = useAppDispatch() 11 const dispatch = useAppDispatch()
  12 +
  13 + useEffect(() => {
  14 + EventBus.on('notLogin', function () {
  15 + navigate('/login')
  16 + })
  17 + }, [])
  18 +
10 function changeMessageHandler() { 19 function changeMessageHandler() {
11 dispatch(changeMessage('hahah')) 20 dispatch(changeMessage('hahah'))
12 } 21 }
@@ -9,8 +9,8 @@ export const getMessageLogin = (params: any) => hyrequest.get({ url: '/pet/login @@ -9,8 +9,8 @@ export const getMessageLogin = (params: any) => hyrequest.get({ url: '/pet/login
9 9
10 // 问诊及处方 10 // 问诊及处方
11 export const getConsultation_information_list = (params: PageListParamsType) => hyrequest.get({ url: '/veterinary/consultation_information_list', params }) // 问诊订单列表 11 export const getConsultation_information_list = (params: PageListParamsType) => hyrequest.get({ url: '/veterinary/consultation_information_list', params }) // 问诊订单列表
12 -export const updateSend_prescription_form = (params: any) => hyrequest.post({ url: '/veterinary/send_prescription_form', params }) // 发送处方单  
13 -export const getPrescription_detail = (params: { id: string | number }) => hyrequest.get({ url: '/veterinary/prescription_detail', params }) // 处方单详情 12 +export const updateSend_prescription_form = (params: any) => hyrequest.post({ url: '/veterinary/send_prescription_form', data: params }) // 发送处方单
  13 +export const getPrescription_detail = (params: { id: string | number }) => hyrequest.get({ url: '/veterinary/prescription_detail_information', params }) // 处方单详情
14 export const getConsultation_information_detail = (params: { id: string | number }) => hyrequest.get({ url: '/veterinary/consultation_information_detail', params }) // 问诊订单详情 14 export const getConsultation_information_detail = (params: { id: string | number }) => hyrequest.get({ url: '/veterinary/consultation_information_detail', params }) // 问诊订单详情
15 15
16 // 我的 16 // 我的
1 -body, textarea, select, input, button { 1 +body,
  2 +textarea,
  3 +select,
  4 +input,
  5 +button {
2 // font-size: 12px; 6 // font-size: 12px;
3 // color: #333; 7 // color: #333;
4 // font-family: Arial, Helvetica, sans-serif; 8 // font-family: Arial, Helvetica, sans-serif;
@@ -60,10 +64,8 @@ body, textarea, select, input, button { @@ -60,10 +64,8 @@ body, textarea, select, input, button {
60 // } 64 // }
61 65
62 .ant-message .ant-message-notice-content { 66 .ant-message .ant-message-notice-content {
63 - // position: fixed;  
64 - // left: 50%;  
65 - // transform: translateX(-50%);  
66 - // bottom: 60px;  
67 - // background-color: rgba(0, 0, 0, .7);  
68 - // color: #fff; 67 + position: fixed;
  68 + left: 50%;
  69 + transform: translateX(-50%);
  70 + bottom: -150px;
69 } 71 }
@@ -3,6 +3,7 @@ import type { FC, ReactNode } from 'react' @@ -3,6 +3,7 @@ import type { FC, ReactNode } from 'react'
3 import { useNavigate } from 'react-router-dom' 3 import { useNavigate } from 'react-router-dom'
4 import { useAppDispatch, useAppSelector, shallowEqualApp } from '@/store' 4 import { useAppDispatch, useAppSelector, shallowEqualApp } from '@/store'
5 import { fetchUserinfoAction } from '@/store/modules/order' 5 import { fetchUserinfoAction } from '@/store/modules/order'
  6 +import GHandler from '@/utils/methods'
6 import { AppHeaderWrapper } from './styled' 7 import { AppHeaderWrapper } from './styled'
7 import type { UserInfoType } from '@/types' 8 import type { UserInfoType } from '@/types'
8 9
@@ -44,8 +45,12 @@ const AppHeader: FC<IProps> = memo(() => { @@ -44,8 +45,12 @@ const AppHeader: FC<IProps> = memo(() => {
44 <div className="flexJ box"> 45 <div className="flexJ box">
45 <div className="title flexA">宠物问诊</div> 46 <div className="title flexA">宠物问诊</div>
46 <div className="flexA"> 47 <div className="flexA">
47 - <img className="avatar" src={UserInfo?.avatar || 'https://tupian.qqw21.com/article/UploadPic/2020-4/20204421535275855.jpg'} alt="" />  
48 - <div className="username">{UserInfo?.nickname || '未设置昵称'}</div> 48 + <img
  49 + className="avatar"
  50 + src={GHandler.downFile(UserInfo?.avatar) || 'https://tupian.qqw21.com/article/UploadPic/2020-4/20204421535275855.jpg'}
  51 + alt=""
  52 + />
  53 + <div className="username">{UserInfo?.realname || '未设置昵称'}</div>
49 {token && ( 54 {token && (
50 <div className="loginout" onClick={loginOutHandler}> 55 <div className="loginout" onClick={loginOutHandler}>
51 退出登录 56 退出登录
1 -// const BASE_URL = 'http://codercba.com:9002/'  
2 -// const BASE_URL = 'http://192.168.10.63:8080/jeecg-boot'  
3 -const BASE_URL = 'http://127.0.0.1:4523/m1/3332971-0-default/jeecg-boot' // mock 1 +// const BASE_URL = 'http://114.115.178.175:8799/jeecg-boot' // 测试
  2 +// const BASE_URL = 'http://192.168.10.63:8080/jeecg-boot' // 本地
  3 +// const BASE_URL = 'http://127.0.0.1:4523/m1/3332971-0-default/jeecg-boot' // mock
  4 +const BASE_URL = 'https://pet.apple02.brofirst.cn/jeecg-boot'
  5 +
4 6
5 export const TIME_OUT = 10000; 7 export const TIME_OUT = 10000;
6 export { BASE_URL } 8 export { BASE_URL }
@@ -10,7 +10,7 @@ const hyrequest = new HYRequest({ @@ -10,7 +10,7 @@ const hyrequest = new HYRequest({
10 requestSuccessFn(config) { 10 requestSuccessFn(config) {
11 const token = LStore.get('token') 11 const token = LStore.get('token')
12 if (token && config.headers) { 12 if (token && config.headers) {
13 - config.headers['Content-Type'] = 'multipart/form-data;' 13 + // config.headers['Content-Type'] = 'multipart/form-data;'
14 config.headers.token = token 14 config.headers.token = token
15 config.headers['X-Access-Token'] = token 15 config.headers['X-Access-Token'] = token
16 } 16 }
1 import axios from "axios" 1 import axios from "axios"
2 import type { AxiosInstance, AxiosRequestConfig, AxiosResponse } from 'axios' 2 import type { AxiosInstance, AxiosRequestConfig, AxiosResponse } from 'axios'
3 import type { HYRequestConfig } from './types' 3 import type { HYRequestConfig } from './types'
  4 +import EventBus from '@/utils/events'
4 // import router from "../../router" 5 // import router from "../../router"
5 6
6 /** 7 /**
@@ -32,7 +33,7 @@ class HYRequest { @@ -32,7 +33,7 @@ class HYRequest {
32 return res.data 33 return res.data
33 }, err => { 34 }, err => {
34 if (err.response.data.code === 401) { 35 if (err.response.data.code === 401) {
35 - // router.push('/login') 36 + EventBus.emit('notLogin', err.response.data.message)
36 } 37 }
37 console.log('全局相应失败的拦截', err.response.data) 38 console.log('全局相应失败的拦截', err.response.data)
38 return err 39 return err
@@ -8,7 +8,8 @@ export const fetchOrderDataAction = createAsyncThunk<void, PageListParamsType>( @@ -8,7 +8,8 @@ export const fetchOrderDataAction = createAsyncThunk<void, PageListParamsType>(
8 'fetchdata', (payload, { dispatch }) => { 8 'fetchdata', (payload, { dispatch }) => {
9 getConsultation_information_list(payload).then(({ result }: { result: PageListType<ConsultationOrderListItemType[]> }) => { 9 getConsultation_information_list(payload).then(({ result }: { result: PageListType<ConsultationOrderListItemType[]> }) => {
10 console.log(result, '问诊订单列表') 10 console.log(result, '问诊订单列表')
11 - dispatch(changeConsultationOrderAction(result.records)) 11 + dispatch(changeConsultationOrderAction(result?.records))
  12 + dispatch(changeConsultationOrderNumAction(result?.total))
12 }) 13 })
13 } 14 }
14 ) 15 )
@@ -44,12 +45,16 @@ const orderSlice = createSlice({ @@ -44,12 +45,16 @@ const orderSlice = createSlice({
44 ConsultationOrderList: [], 45 ConsultationOrderList: [],
45 ConsultationOrderDetailData: {}, 46 ConsultationOrderDetailData: {},
46 PrescriptionDetailData: {}, 47 PrescriptionDetailData: {},
47 - UserInfo: {} 48 + UserInfo: {},
  49 + total: 0
48 }, 50 },
49 reducers: { 51 reducers: {
50 changeConsultationOrderAction(state, { payload }) { 52 changeConsultationOrderAction(state, { payload }) {
51 state.ConsultationOrderList = payload 53 state.ConsultationOrderList = payload
52 }, 54 },
  55 + changeConsultationOrderNumAction(state, { payload }) {
  56 + state.total = payload
  57 + },
53 changeConsultationOrderDetailAction(state, { payload }) { 58 changeConsultationOrderDetailAction(state, { payload }) {
54 state.ConsultationOrderDetailData = payload 59 state.ConsultationOrderDetailData = payload
55 }, 60 },
@@ -64,4 +69,4 @@ const orderSlice = createSlice({ @@ -64,4 +69,4 @@ const orderSlice = createSlice({
64 69
65 export default orderSlice.reducer 70 export default orderSlice.reducer
66 71
67 -export const { changeConsultationOrderAction, changeConsultationOrderDetailAction, changePrescriptionDetailAction, changeUserInfoAction } = orderSlice.actions 72 +export const { changeConsultationOrderAction, changeConsultationOrderNumAction, changeConsultationOrderDetailAction, changePrescriptionDetailAction, changeUserInfoAction } = orderSlice.actions
@@ -55,7 +55,7 @@ export interface ConsultationOrderRecordsType { @@ -55,7 +55,7 @@ export interface ConsultationOrderRecordsType {
55 /** 55 /**
56 * 实际收入 56 * 实际收入
57 */ 57 */
58 - effect_award?: number; 58 + effectAward?: number;
59 /** 59 /**
60 * 喂养方式1=配方粮2=配方粮+零食3=只吃人食物4=自制犬猫粮 60 * 喂养方式1=配方粮2=配方粮+零食3=只吃人食物4=自制犬猫粮
61 */ 61 */
@@ -195,7 +195,7 @@ export interface ConsultationOrderListItemType { @@ -195,7 +195,7 @@ export interface ConsultationOrderListItemType {
195 /** 195 /**
196 * 实际收入 196 * 实际收入
197 */ 197 */
198 - effect_award?: number; 198 + effectAward?: number;
199 /** 199 /**
200 * 喂养方式1=配方粮2=配方粮+零食3=只吃人食物4=自制犬猫粮 200 * 喂养方式1=配方粮2=配方粮+零食3=只吃人食物4=自制犬猫粮
201 */ 201 */
@@ -346,7 +346,7 @@ export interface ConsultationOrderDetailType { @@ -346,7 +346,7 @@ export interface ConsultationOrderDetailType {
346 /** 346 /**
347 * 实际收入 347 * 实际收入
348 */ 348 */
349 - effect_award?: number; 349 + effectAward?: number;
350 /** 350 /**
351 * 喂养方式1=配方粮2=配方粮+零食3=只吃人食物4=自制犬猫粮 351 * 喂养方式1=配方粮2=配方粮+零食3=只吃人食物4=自制犬猫粮
352 */ 352 */
@@ -358,7 +358,7 @@ export interface ConsultationOrderDetailType { @@ -358,7 +358,7 @@ export interface ConsultationOrderDetailType {
358 /** 358 /**
359 * 症状图片 359 * 症状图片
360 */ 360 */
361 - image?: string[]; 361 + image?: string;
362 /** 362 /**
363 * 宠物免疫情况1=已免疫2=未免疫3=免疫不全4=免疫不详 363 * 宠物免疫情况1=已免疫2=未免疫3=免疫不全4=免疫不详
364 */ 364 */
@@ -621,7 +621,8 @@ export interface User { @@ -621,7 +621,8 @@ export interface User {
621 /** 621 /**
622 * 昵称 622 * 昵称
623 */ 623 */
624 - nickname: string; 624 + nickname?: string;
  625 + nickName?: string
625 [property: string]: any; 626 [property: string]: any;
626 } 627 }
627 628
  1 +import { EventEmitter } from 'events'
  2 +
  3 +const eventBus = new EventEmitter()
  4 +
  5 +export default eventBus
@@ -15,9 +15,9 @@ const GlobalData: ObjectString = { @@ -15,9 +15,9 @@ const GlobalData: ObjectString = {
15 'MessageType': { 1: '系统通知', 2: '用户反馈', 'err': '状态码错误' }, 15 'MessageType': { 1: '系统通知', 2: '用户反馈', 'err': '状态码错误' },
16 'consultationWay': { 10: '快速问诊', 21: '专家图文语音问诊', 22: '专家视频问诊', 23: '专家电话问诊', 'err': '状态码错误' }, 16 'consultationWay': { 10: '快速问诊', 21: '专家图文语音问诊', 22: '专家视频问诊', 23: '专家电话问诊', 'err': '状态码错误' },
17 'isReply': { 0: '否', 1: '是', 'err': '状态码错误' }, // 17 'isReply': { 0: '否', 1: '是', 'err': '状态码错误' }, //
18 - 'orderState': { 20: '待问诊', 30: '问诊中', 40: '问诊结束', 50: '已取消', 'err': '状态码错误' }, 18 + 'orderState': { 10: '待接诊', 20: '待问诊', 30: '问诊中', 40: '问诊结束', 50: '已取消', 'err': '状态码错误' },
19 'state': { 0: '待发货', 1: '已发货', 2: '已完成', 3: '已退货', 'err': '状态码错误' }, 19 'state': { 0: '待发货', 1: '已发货', 2: '已完成', 3: '已退货', 'err': '状态码错误' },
20 - 'isSterilization': { 0: '否', 1: '是', 'err': '状态码错误' }, // 是否绝育 20 + 'isSterilization': { 0: '未绝育', 1: '已绝育', 'err': '状态码错误' }, // 是否绝育
21 'petSex': { 0: '母', 1: '公', 'err': '状态码错误' }, 21 'petSex': { 0: '母', 1: '公', 'err': '状态码错误' },
22 'immuneStatus': { 1: '已免疫', 2: '未免疫', 3: '免疫不全', 4: '免疫不详', 'err': '状态码错误' }, 22 'immuneStatus': { 1: '已免疫', 2: '未免疫', 3: '免疫不全', 4: '免疫不详', 'err': '状态码错误' },
23 'feedType': { 1: '配方粮', 2: '配方粮+零食', 3: '只吃人食物', 4: '自制犬猫粮', 'err': '状态码错误' }, 23 'feedType': { 1: '配方粮', 2: '配方粮+零食', 3: '只吃人食物', 4: '自制犬猫粮', 'err': '状态码错误' },
@@ -35,12 +35,12 @@ export default { @@ -35,12 +35,12 @@ export default {
35 optObjectValue(object: string, key: string | number, err: number | string = 'err') { 35 optObjectValue(object: string, key: string | number, err: number | string = 'err') {
36 return GlobalData[object][key] || GlobalData[object][err] 36 return GlobalData[object][key] || GlobalData[object][err]
37 }, 37 },
38 - downFile(fileName: string) { 38 + downFile(fileName?: string) {
39 if (fileName == '' || fileName == undefined) return '' 39 if (fileName == '' || fileName == undefined) return ''
40 40
41 if (fileName.indexOf(BASE_URL) > -1 || fileName.indexOf('http://') > -1 || fileName.indexOf('https://') > -1) return fileName 41 if (fileName.indexOf(BASE_URL) > -1 || fileName.indexOf('http://') > -1 || fileName.indexOf('https://') > -1) return fileName
42 42
43 - return BASE_URL + '/v1/public/downLoadPic?fileName=' + fileName 43 + return BASE_URL + fileName
44 }, 44 },
45 formatStr(str: string, val: string) { 45 formatStr(str: string, val: string) {
46 if (str == null || str == undefined) return val || '' 46 if (str == null || str == undefined) return val || ''
1 -import React, { memo, useState, forwardRef, useImperativeHandle } from 'react' 1 +import React, { memo, useState, forwardRef, useImperativeHandle, useEffect } from 'react'
2 import type { FC, ReactNode, Ref } from 'react' 2 import type { FC, ReactNode, Ref } from 'react'
3 import { Input, Modal, Upload } from 'antd' 3 import { Input, Modal, Upload } from 'antd'
4 import { MinusCircleOutlined, PlusCircleOutlined, PlusOutlined } from '@ant-design/icons' 4 import { MinusCircleOutlined, PlusCircleOutlined, PlusOutlined } from '@ant-design/icons'
@@ -7,10 +7,13 @@ import type { UploadFile } from 'antd/es/upload/interface' @@ -7,10 +7,13 @@ import type { UploadFile } from 'antd/es/upload/interface'
7 import { SendPrescriptionWrapper } from '../style' 7 import { SendPrescriptionWrapper } from '../style'
8 import { BASE_URL } from '@/service/config' 8 import { BASE_URL } from '@/service/config'
9 import type { Send_prescription_formType } from '@/types' 9 import type { Send_prescription_formType } from '@/types'
  10 +import GHandler from '@/utils/methods'
  11 +
10 // /sys/common/appUpload 12 // /sys/common/appUpload
11 const { TextArea } = Input 13 const { TextArea } = Input
12 14
13 interface IProps { 15 interface IProps {
  16 + id?: string | number
14 children?: ReactNode 17 children?: ReactNode
15 ref?: any 18 ref?: any
16 } 19 }
@@ -59,6 +62,22 @@ const SendPrescription: FC<IProps> = memo( @@ -59,6 +62,22 @@ const SendPrescription: FC<IProps> = memo(
59 setSend_prescription_formTypeData(setdata) 62 setSend_prescription_formTypeData(setdata)
60 } 63 }
61 64
  65 + useEffect(() => {
  66 + let prescriptionAmount = 0
  67 +
  68 + prescriptionAmount = Send_prescription_formData.drugList.reduce((accumulator, item) => {
  69 + const amount = item.amount ? parseFloat(item.amount) : 0
  70 +
  71 + const num = item.num ? parseFloat(item.num) : 0
  72 +
  73 + if (amount !== 0 && num !== 0) accumulator += amount * num
  74 +
  75 + return accumulator
  76 + }, 0)
  77 +
  78 + setSend_prescription_formTypeData({ ...Send_prescription_formData, prescriptionAmount })
  79 + }, [Send_prescription_formData.drugList])
  80 +
62 const handleCancel = () => setPreviewOpen(false) 81 const handleCancel = () => setPreviewOpen(false)
63 82
64 const handlePreview = async (file: UploadFile) => { 83 const handlePreview = async (file: UploadFile) => {
@@ -143,7 +162,7 @@ const SendPrescription: FC<IProps> = memo( @@ -143,7 +162,7 @@ const SendPrescription: FC<IProps> = memo(
143 {fileList.length >= 3 ? null : uploadButton} 162 {fileList.length >= 3 ? null : uploadButton}
144 </Upload> 163 </Upload>
145 <Modal open={previewOpen} title={previewTitle} footer={null} onCancel={handleCancel}> 164 <Modal open={previewOpen} title={previewTitle} footer={null} onCancel={handleCancel}>
146 - <img alt="example" style={{ width: '100%' }} src={previewImage} /> 165 + <img alt="example" style={{ width: '100%' }} src={GHandler.downFile(previewImage)} />
147 </Modal> 166 </Modal>
148 <div className="title">总金额:¥{Send_prescription_formData.prescriptionAmount}</div> 167 <div className="title">总金额:¥{Send_prescription_formData.prescriptionAmount}</div>
149 </SendPrescriptionWrapper> 168 </SendPrescriptionWrapper>
@@ -6,6 +6,7 @@ import { useAppDispatch, useAppSelector, shallowEqualApp } from '@/store' @@ -6,6 +6,7 @@ import { useAppDispatch, useAppSelector, shallowEqualApp } from '@/store'
6 import { fetchPrescriptionDetailAction } from '@/store/modules/order' 6 import { fetchPrescriptionDetailAction } from '@/store/modules/order'
7 import { ViewPrescriptionWrapper } from '../style' 7 import { ViewPrescriptionWrapper } from '../style'
8 import type { PrescriptionDetailType } from '@/types' 8 import type { PrescriptionDetailType } from '@/types'
  9 +import GHandler from '@/utils/methods'
9 10
10 interface IProps { 11 interface IProps {
11 children?: ReactNode 12 children?: ReactNode
@@ -13,14 +14,11 @@ interface IProps { @@ -13,14 +14,11 @@ interface IProps {
13 } 14 }
14 15
15 const ViewPrescription: FC<IProps> = memo((props) => { 16 const ViewPrescription: FC<IProps> = memo((props) => {
16 - console.log(props.id, 'id')  
17 -  
18 const dispatch = useAppDispatch() 17 const dispatch = useAppDispatch()
19 18
20 const [PrescriptionDetail, setPrescriptionDetail] = useState<PrescriptionDetailType>() 19 const [PrescriptionDetail, setPrescriptionDetail] = useState<PrescriptionDetailType>()
21 20
22 useEffect(() => { 21 useEffect(() => {
23 - console.log('first')  
24 dispatch(fetchPrescriptionDetailAction({ id: props.id })) 22 dispatch(fetchPrescriptionDetailAction({ id: props.id }))
25 }, [props.id]) 23 }, [props.id])
26 24
@@ -55,41 +53,36 @@ const ViewPrescription: FC<IProps> = memo((props) => { @@ -55,41 +53,36 @@ const ViewPrescription: FC<IProps> = memo((props) => {
55 </div> 53 </div>
56 )) 54 ))
57 ) : ( 55 ) : (
58 - <div className="itemo">  
59 - <div className="flexJ black">  
60 - <div>药品名称</div>  
61 - <div>¥0.00</div>  
62 - </div>  
63 - <div className="flexJ gray">  
64 - <div>描述</div>  
65 - <div>x0</div>  
66 - </div>  
67 - </div> 56 + <div className="title">暂无处方药</div>
68 )} 57 )}
69 </div> 58 </div>
70 <div className="title">处方单证明:</div> 59 <div className="title">处方单证明:</div>
71 - {Array.isArray(PrescriptionDetail?.image) && PrescriptionDetail?.image.length ? (  
72 - PrescriptionDetail.image.map((_) => ( 60 + {Array.isArray(PrescriptionDetail?.prescriptionFile) && PrescriptionDetail?.prescriptionFile.length ? (
  61 + PrescriptionDetail.prescriptionFile.map((_) => (
73 <Image 62 <Image
74 width={120} 63 width={120}
75 height={120} 64 height={120}
76 preview={{ 65 preview={{
77 mask: <EyeOutlined /> 66 mask: <EyeOutlined />
78 }} 67 }}
79 - src={_} 68 + src={GHandler.downFile(_)}
80 className="marbot" 69 className="marbot"
81 /> 70 />
82 )) 71 ))
83 - ) : ( 72 + ) : typeof PrescriptionDetail?.prescriptionFile === 'string' && PrescriptionDetail.prescriptionFile.length ? (
  73 + PrescriptionDetail.prescriptionFile.split(',').map((_) => (
84 <Image 74 <Image
85 width={120} 75 width={120}
86 height={120} 76 height={120}
87 preview={{ 77 preview={{
88 mask: <EyeOutlined /> 78 mask: <EyeOutlined />
89 }} 79 }}
90 - src="https://zos.alipayobjects.com/rmsportal/jkjgkEfvpUPVyRjUImniVslZfWPnJuuZ.png" 80 + src={GHandler.downFile(_)}
91 className="marbot" 81 className="marbot"
92 /> 82 />
  83 + ))
  84 + ) : (
  85 + <div className="title">暂无处方单证明</div>
93 )} 86 )}
94 87
95 <div className="black">总金额:¥{PrescriptionDetail?.award || 0}</div> 88 <div className="black">总金额:¥{PrescriptionDetail?.award || 0}</div>
@@ -23,9 +23,8 @@ const ViewSymptom: FC<IProps> = memo((props) => { @@ -23,9 +23,8 @@ const ViewSymptom: FC<IProps> = memo((props) => {
23 const [orderDetail, setOrderDetail] = useState<ConsultationOrderDetailType>() 23 const [orderDetail, setOrderDetail] = useState<ConsultationOrderDetailType>()
24 24
25 useEffect(() => { 25 useEffect(() => {
26 - console.log('id', id)  
27 - dispatch(fetchConsultationOrderDetailAction({ id: props.id }))  
28 - }, [props.id]) 26 + dispatch(fetchConsultationOrderDetailAction({ id: id }))
  27 + }, [id])
29 28
30 const { COrderDetail } = useAppSelector( 29 const { COrderDetail } = useAppSelector(
31 (state) => ({ 30 (state) => ({
@@ -43,7 +42,7 @@ const ViewSymptom: FC<IProps> = memo((props) => { @@ -43,7 +42,7 @@ const ViewSymptom: FC<IProps> = memo((props) => {
43 <ViewSymptomWrapper> 42 <ViewSymptomWrapper>
44 <div className="flexJ"> 43 <div className="flexJ">
45 <div className="flexA top"> 44 <div className="flexA top">
46 - <Avatar size="large" src={<img src={orderDetail?.user?.avatar} alt="avatar" />} /> 45 + <Avatar size="large" src={<img src={GHandler.downFile(orderDetail?.user?.avatar)} alt="avatar" />} />
47 <div className="username">{orderDetail?.user?.nickname}</div> 46 <div className="username">{orderDetail?.user?.nickname}</div>
48 <div className="tag">{GHandler.optObjectValue('consultationWay', orderDetail?.consultationWay || 10)}</div> 47 <div className="tag">{GHandler.optObjectValue('consultationWay', orderDetail?.consultationWay || 10)}</div>
49 </div> 48 </div>
@@ -52,9 +51,8 @@ const ViewSymptom: FC<IProps> = memo((props) => { @@ -52,9 +51,8 @@ const ViewSymptom: FC<IProps> = memo((props) => {
52 <div className="row"> 51 <div className="row">
53 就诊宠物: 52 就诊宠物:
54 <span> 53 <span>
55 - {GHandler.optObjectValue('petType', orderDetail?.petType || 30)}/{orderDetail?.age || '年龄未知'}/  
56 - {GHandler.optObjectValue('petSex', orderDetail?.petSex || 1)}/{GHandler.optObjectValue('symptom', orderDetail?.symptom || 10)}/  
57 - {orderDetail?.weight || '体重未知'} 54 + {orderDetail?.petClass}/{orderDetail?.age || '年龄未知'}/{GHandler.optObjectValue('petSex', orderDetail?.petSex as any)}/
  55 + {GHandler.optObjectValue('isSterilization', orderDetail?.isSterilization as any)}/{orderDetail?.weight ? orderDetail?.weight + 'kg' : '体重未知'}
58 </span> 56 </span>
59 </div> 57 </div>
60 <div className="row"> 58 <div className="row">
@@ -70,7 +68,14 @@ const ViewSymptom: FC<IProps> = memo((props) => { @@ -70,7 +68,14 @@ const ViewSymptom: FC<IProps> = memo((props) => {
70 洗澡频次:<span>{GHandler.optObjectValue('batheFrequency', orderDetail?.batheFrequency || 2)}</span> 68 洗澡频次:<span>{GHandler.optObjectValue('batheFrequency', orderDetail?.batheFrequency || 2)}</span>
71 </div> 69 </div>
72 <div className="row"> 70 <div className="row">
73 - 出现症状:<span>{GHandler.optObjectValue('symptom', orderDetail?.symptom || 10)}</span> 71 + 出现症状:
  72 + {orderDetail?.symptom?.length &&
  73 + orderDetail?.symptom?.split(',').map((_, index) => (
  74 + <span>
  75 + {GHandler.optObjectValue('symptom', _)}
  76 + {index !== (orderDetail.symptom as string).split(',').length - 1 ? ',' : ''}
  77 + </span>
  78 + ))}
74 </div> 79 </div>
75 <div className="row"> 80 <div className="row">
76 症状时间:<span>{GHandler.optObjectValue('timeFrame', orderDetail?.timeFrame || 1)}</span> 81 症状时间:<span>{GHandler.optObjectValue('timeFrame', orderDetail?.timeFrame || 1)}</span>
@@ -80,26 +85,19 @@ const ViewSymptom: FC<IProps> = memo((props) => { @@ -80,26 +85,19 @@ const ViewSymptom: FC<IProps> = memo((props) => {
80 </div> 85 </div>
81 <div> 86 <div>
82 <div className="row">症状图片</div> 87 <div className="row">症状图片</div>
83 - {Array.isArray(orderDetail?.image) && orderDetail?.image.length ? (  
84 - orderDetail?.image.map((_, index) => ( 88 + {orderDetail?.image ? (
  89 + orderDetail?.image.split(',').map((_, index) => (
85 <Image 90 <Image
86 width={120} 91 width={120}
87 height={120} 92 height={120}
88 preview={{ 93 preview={{
89 mask: <EyeOutlined /> 94 mask: <EyeOutlined />
90 }} 95 }}
91 - src={_} 96 + src={GHandler.downFile(_)}
92 /> 97 />
93 )) 98 ))
94 ) : ( 99 ) : (
95 - <Image  
96 - width={120}  
97 - height={120}  
98 - preview={{  
99 - mask: <EyeOutlined />  
100 - }}  
101 - src="https://zos.alipayobjects.com/rmsportal/jkjgkEfvpUPVyRjUImniVslZfWPnJuuZ.png"  
102 - /> 100 + <div className="row">暂无症状图片</div>
103 )} 101 )}
104 </div> 102 </div>
105 </ViewSymptomWrapper> 103 </ViewSymptomWrapper>
1 import React, { memo, useEffect, useState, useRef, ElementRef } from 'react' 1 import React, { memo, useEffect, useState, useRef, ElementRef } from 'react'
2 import type { FC, ReactNode } from 'react' 2 import type { FC, ReactNode } from 'react'
3 -import { Tabs, Avatar, Space, Divider, Button, Modal, Pagination, Carousel, Empty } from 'antd' 3 +import { Tabs, Avatar, Space, Divider, Button, Modal, Pagination, Carousel, Empty, message } from 'antd'
4 import type { TabsProps } from 'antd' 4 import type { TabsProps } from 'antd'
5 import { ConsultationOrderWrapper, ConsultationOrderItemWrapper } from './styled' 5 import { ConsultationOrderWrapper, ConsultationOrderItemWrapper } from './styled'
6 import { useAppDispatch, useAppSelector, shallowEqualApp } from '@/store' 6 import { useAppDispatch, useAppSelector, shallowEqualApp } from '@/store'
@@ -11,13 +11,18 @@ import SendPrescription from '../../com/SendPrescription' @@ -11,13 +11,18 @@ import SendPrescription from '../../com/SendPrescription'
11 import ViewPrescription from '../../com/ViewPrescription' 11 import ViewPrescription from '../../com/ViewPrescription'
12 import ViewSymptom from '../../com/ViewSymptom' 12 import ViewSymptom from '../../com/ViewSymptom'
13 import GHandler from '@/utils/methods' 13 import GHandler from '@/utils/methods'
  14 +import mAvatar from '@/assets/img/mAvatar.png'
14 15
15 interface IProps { 16 interface IProps {
16 children?: ReactNode 17 children?: ReactNode
17 orderList?: ConsultationOrderListItemType[] 18 orderList?: ConsultationOrderListItemType[]
18 } 19 }
19 20
20 -const url = 'https://p1.ssl.qhmsg.com/dr/270_500_/t010c2d50907f0a7b9c.png' 21 +const url = mAvatar
  22 +
  23 +message.config({
  24 + top: 1400
  25 +})
21 26
22 const ShowOrderComHandler: FC<IProps> = (props) => { 27 const ShowOrderComHandler: FC<IProps> = (props) => {
23 const { orderList } = props 28 const { orderList } = props
@@ -25,26 +30,58 @@ const ShowOrderComHandler: FC<IProps> = (props) => { @@ -25,26 +30,58 @@ const ShowOrderComHandler: FC<IProps> = (props) => {
25 const [confirmLoading, setConfirmLoading] = useState(false) 30 const [confirmLoading, setConfirmLoading] = useState(false)
26 const [modalTitle, setModalTitle] = useState<string>(' ') 31 const [modalTitle, setModalTitle] = useState<string>(' ')
27 const [modalFlag, setModalFlag] = useState<number>(0) 32 const [modalFlag, setModalFlag] = useState<number>(0)
  33 + const [orderId, setOrderId] = useState<string | number>('')
28 34
29 const SendPrescriptionRef = useRef<SendPrescriptionPropsType | null>(null) 35 const SendPrescriptionRef = useRef<SendPrescriptionPropsType | null>(null)
30 36
31 - const showModalHandler = (flag: number) => {  
32 - console.log(flag, '按钮状态') 37 + const [messageApi, contextHolder] = message.useMessage()
  38 +
  39 + const warning = (content: string) => messageApi.open({ type: 'warning', content: content })
  40 +
  41 + const success = (content: string) => messageApi.open({ type: 'success', content: content })
  42 +
  43 + const showModalHandler = (flag: number, orderId: string | number) => {
  44 + setOrderId(orderId)
  45 +
33 setModalFlag(flag) 46 setModalFlag(flag)
  47 +
34 setModalTitle({ 1: '查看症状', 2: '发送处方单', 3: '查看处方单' }[flag] as string) 48 setModalTitle({ 1: '查看症状', 2: '发送处方单', 3: '查看处方单' }[flag] as string)
  49 +
35 setOpenHandler(true) 50 setOpenHandler(true)
36 } 51 }
37 52
  53 + const closeSendPrescriptionHandler = () => {
  54 + setTimeout(() => {
  55 + setOpenHandler(false)
  56 +
  57 + setConfirmLoading(false)
  58 + }, 1300)
  59 + }
  60 +
38 const handleOk = async () => { 61 const handleOk = async () => {
39 if (modalFlag === 2) { 62 if (modalFlag === 2) {
  63 + setConfirmLoading(true)
  64 +
40 const instance = SendPrescriptionRef.current 65 const instance = SendPrescriptionRef.current
41 66
42 - await updateSend_prescription_form({ 67 + const ret = await updateSend_prescription_form({
43 ...instance?.Send_prescription_formData, 68 ...instance?.Send_prescription_formData,
44 - drugList: JSON.stringify(instance?.Send_prescription_formData.drugList), 69 + id: orderId,
45 prescriptionFile: instance?.fileList.map((_: any) => _.response.message).join() 70 prescriptionFile: instance?.fileList.map((_: any) => _.response.message).join()
46 }) 71 })
47 72
  73 + if ([200].includes(ret.code)) {
  74 + success('发送成功')
  75 +
  76 + closeSendPrescriptionHandler()
  77 + }
  78 +
  79 + if ([500, 401, 403].includes(ret.code)) {
  80 + warning(ret.message)
  81 +
  82 + closeSendPrescriptionHandler()
  83 + }
  84 +
48 typeof instance?.setSend_prescription_formTypeData === 'function' && 85 typeof instance?.setSend_prescription_formTypeData === 'function' &&
49 instance?.setSend_prescription_formTypeData({ 86 instance?.setSend_prescription_formTypeData({
50 drugList: [{ amount: '', des: '', name: '', num: '' }], 87 drugList: [{ amount: '', des: '', name: '', num: '' }],
@@ -54,15 +91,8 @@ const ShowOrderComHandler: FC<IProps> = (props) => { @@ -54,15 +91,8 @@ const ShowOrderComHandler: FC<IProps> = (props) => {
54 91
55 typeof instance?.setFileList === 'function' && instance.setFileList([]) 92 typeof instance?.setFileList === 'function' && instance.setFileList([])
56 93
57 - console.log(SendPrescriptionRef.current, 'SendPrescription 子组件实例')  
58 -  
59 - setConfirmLoading(true)  
60 -  
61 - setTimeout(() => {  
62 - setOpenHandler(false) 94 + // console.log(SendPrescriptionRef.current, 'SendPrescription 子组件实例')
63 95
64 - setConfirmLoading(false)  
65 - }, 2000)  
66 return 96 return
67 } 97 }
68 98
@@ -72,23 +102,22 @@ const ShowOrderComHandler: FC<IProps> = (props) => { @@ -72,23 +102,22 @@ const ShowOrderComHandler: FC<IProps> = (props) => {
72 } 102 }
73 103
74 const handleCancel = () => { 104 const handleCancel = () => {
75 - console.log('Clicked cancel button')  
76 -  
77 setOpenHandler(false) 105 setOpenHandler(false)
78 } 106 }
79 107
80 return ( 108 return (
81 <ConsultationOrderItemWrapper> 109 <ConsultationOrderItemWrapper>
  110 + {contextHolder}
82 <Modal title={modalTitle} open={open} onOk={handleOk} cancelText="关闭" okText="确认" confirmLoading={confirmLoading} onCancel={handleCancel}> 111 <Modal title={modalTitle} open={open} onOk={handleOk} cancelText="关闭" okText="确认" confirmLoading={confirmLoading} onCancel={handleCancel}>
83 - {{ 1: <ViewSymptom id={1} />, 2: <SendPrescription ref={SendPrescriptionRef} />, 3: <ViewPrescription id={1} /> }[modalFlag]} 112 + {{ 1: <ViewSymptom id={orderId} />, 2: <SendPrescription ref={SendPrescriptionRef} id={orderId} />, 3: <ViewPrescription id={orderId} /> }[modalFlag]}
84 </Modal> 113 </Modal>
85 {orderList?.length ? ( 114 {orderList?.length ? (
86 orderList.map((_, index) => ( 115 orderList.map((_, index) => (
87 <div className="orderItem " key={index}> 116 <div className="orderItem " key={index}>
88 <div className="topinfo flexJ"> 117 <div className="topinfo flexJ">
89 <div className=" flexA"> 118 <div className=" flexA">
90 - <Avatar size="large" src={<img src={_.user?.avatar || url} alt="avatar" />} />  
91 - <div className="username">{_.user?.nickname || '暂无用户名'}</div> 119 + <Avatar size="large" src={<img src={GHandler.downFile(_.user?.avatar) || url} alt="avatar" />} />
  120 + <div className="username">{_.user?.nickName || '暂无用户名'}</div>
92 <div className="statetag flexC">{GHandler.optObjectValue('consultationWay', _.consultationWay || 10)}</div> 121 <div className="statetag flexC">{GHandler.optObjectValue('consultationWay', _.consultationWay || 10)}</div>
93 <div className="time">{_.time}</div> 122 <div className="time">{_.time}</div>
94 </div> 123 </div>
@@ -96,12 +125,12 @@ const ShowOrderComHandler: FC<IProps> = (props) => { @@ -96,12 +125,12 @@ const ShowOrderComHandler: FC<IProps> = (props) => {
96 </div> 125 </div>
97 <div className="contenttext"> 126 <div className="contenttext">
98 <span>就诊宠物:</span> 127 <span>就诊宠物:</span>
99 - {GHandler.optObjectValue('petType', _?.petType || 30)}/{_?.age || '年龄未知'}/{GHandler.optObjectValue('petSex', _?.petSex || 1)}/  
100 - {GHandler.optObjectValue('symptom', _?.symptom as string)}/{_?.weight || '体重未知'} 128 + {_?.petName}/{_?.petClass}/{_?.age || '年龄未知'}/{GHandler.optObjectValue('petSex', _?.petSex || 1)}/
  129 + {GHandler.optObjectValue('isSterilization', _?.isSterilization || 0)}/{_?.weight ? _?.weight + 'kg' : '体重未知'}
101 </div> 130 </div>
102 <div className="contenttext"> 131 <div className="contenttext">
103 <span>病情描述:</span> 132 <span>病情描述:</span>
104 - {_.prescriptionForm || '暂无病情描述'} 133 + {_.supplement || '暂无病情描述'}
105 </div> 134 </div>
106 <Divider /> 135 <Divider />
107 <div className="flexJ"> 136 <div className="flexJ">
@@ -111,15 +140,32 @@ const ShowOrderComHandler: FC<IProps> = (props) => { @@ -111,15 +140,32 @@ const ShowOrderComHandler: FC<IProps> = (props) => {
111 </div> 140 </div>
112 <div className="flexA"> 141 <div className="flexA">
113 <Space wrap> 142 <Space wrap>
114 - <Button type="primary" shape="round" onClick={() => showModalHandler(1)}> 143 + <Button type="primary" shape="round" onClick={() => showModalHandler(1, _.id)}>
115 查看症状 144 查看症状
116 </Button> 145 </Button>
117 - <Button type="primary" shape="round" onClick={() => showModalHandler(2)}> 146 + {[30, '30'].includes(_.orderState as string | number) ? (
  147 + <Button type="primary" shape="round" onClick={() => showModalHandler(2, _.id)}>
118 发送处方单 148 发送处方单
119 </Button> 149 </Button>
120 - <Button type="primary" shape="round" onClick={() => showModalHandler(3)}> 150 + ) : (
  151 + ''
  152 + )}
  153 +
  154 + {[20, '20'].includes(_.orderState as string | number) ? (
  155 + <Button type="primary" shape="round" onClick={() => warning('请到app内进行接诊')}>
  156 + 接诊
  157 + </Button>
  158 + ) : (
  159 + ''
  160 + )}
  161 +
  162 + {[30, '30', 40, '40'].includes(_.orderState as string | number) ? (
  163 + <Button type="primary" shape="round" onClick={() => showModalHandler(3, _.id)}>
121 查看处方单 164 查看处方单
122 </Button> 165 </Button>
  166 + ) : (
  167 + ''
  168 + )}
123 </Space> 169 </Space>
124 </div> 170 </div>
125 </div> 171 </div>
@@ -139,14 +185,17 @@ const ConsultationOrder: FC<IProps> = memo(() => { @@ -139,14 +185,17 @@ const ConsultationOrder: FC<IProps> = memo(() => {
139 185
140 const [pageNo, setPageNo] = useState<number>(1) 186 const [pageNo, setPageNo] = useState<number>(1)
141 187
  188 + const [orderTotal, setOrderTotal] = useState<number>(0)
  189 +
142 useEffect(() => { 190 useEffect(() => {
143 // return 191 // return
144 dispatch(fetchOrderDataAction({ pageNo: pageNo })) 192 dispatch(fetchOrderDataAction({ pageNo: pageNo }))
145 }, []) 193 }, [])
146 194
147 - const { ConsultationOrder } = useAppSelector( 195 + const { ConsultationOrder, ConsultationOrderTotal } = useAppSelector(
148 (state) => ({ 196 (state) => ({
149 - ConsultationOrder: state.order.ConsultationOrderList 197 + ConsultationOrder: state.order.ConsultationOrderList,
  198 + ConsultationOrderTotal: state.order.total
150 }), 199 }),
151 shallowEqualApp 200 shallowEqualApp
152 ) 201 )
@@ -156,6 +205,7 @@ const ConsultationOrder: FC<IProps> = memo(() => { @@ -156,6 +205,7 @@ const ConsultationOrder: FC<IProps> = memo(() => {
156 if (!ConsultationOrder.length) return 205 if (!ConsultationOrder.length) return
157 // console.log(ConsultationOrder, '问诊订单列表数据') 206 // console.log(ConsultationOrder, '问诊订单列表数据')
158 setCOrderList(ConsultationOrder) 207 setCOrderList(ConsultationOrder)
  208 + setOrderTotal(ConsultationOrderTotal)
159 }, [ConsultationOrder]) 209 }, [ConsultationOrder])
160 210
161 const [COrderList, setCOrderList] = useState<ConsultationOrderListItemType[]>([]) 211 const [COrderList, setCOrderList] = useState<ConsultationOrderListItemType[]>([])
@@ -168,7 +218,13 @@ const ConsultationOrder: FC<IProps> = memo(() => { @@ -168,7 +218,13 @@ const ConsultationOrder: FC<IProps> = memo(() => {
168 { key: '50', label: '已取消', children: ShowOrderComHandler({ orderList: COrderList }) } 218 { key: '50', label: '已取消', children: ShowOrderComHandler({ orderList: COrderList }) }
169 ] 219 ]
170 220
171 - const onChange = (key: string) => dispatch(fetchOrderDataAction({ pageNo: 1, orderState: key })) 221 + const onChange = (key: string) => {
  222 + setCOrderList([])
  223 +
  224 + setOrderTotal(0)
  225 +
  226 + dispatch(fetchOrderDataAction({ pageNo: 1, orderState: key }))
  227 + }
172 228
173 const changeOrderListHandler = (e: number) => dispatch(fetchOrderDataAction({ pageNo: e })) 229 const changeOrderListHandler = (e: number) => dispatch(fetchOrderDataAction({ pageNo: e }))
174 230
@@ -177,7 +233,7 @@ const ConsultationOrder: FC<IProps> = memo(() => { @@ -177,7 +233,7 @@ const ConsultationOrder: FC<IProps> = memo(() => {
177 <div className="title">问诊订单</div> 233 <div className="title">问诊订单</div>
178 <Tabs defaultActiveKey="0" items={items} onChange={onChange} />; 234 <Tabs defaultActiveKey="0" items={items} onChange={onChange} />;
179 <div className="paginationBox flexD"> 235 <div className="paginationBox flexD">
180 - <Pagination defaultCurrent={1} total={50} onChange={(e) => changeOrderListHandler(e)} /> 236 + <Pagination defaultCurrent={1} total={orderTotal} onChange={(e) => changeOrderListHandler(e)} />
181 </div> 237 </div>
182 </ConsultationOrderWrapper> 238 </ConsultationOrderWrapper>
183 ) 239 )
@@ -14,9 +14,11 @@ export const ConsultationOrderWrapper = styled.div` @@ -14,9 +14,11 @@ export const ConsultationOrderWrapper = styled.div`
14 margin-bottom: 16px; 14 margin-bottom: 16px;
15 } 15 }
16 .paginationBox{ 16 .paginationBox{
17 - position: absolute;  
18 - bottom: 20px;  
19 - right: 20px; 17 + display: flex;
  18 + align-items: flex-end;
  19 + // position: absolute;
  20 + // bottom: 20px;
  21 + // right: 20px;
20 } 22 }
21 ` 23 `
22 24