diff --git a/src/doctor/orders/add.tsx b/src/doctor/orders/add.tsx index b76e1dd..913a586 100644 --- a/src/doctor/orders/add.tsx +++ b/src/doctor/orders/add.tsx @@ -1,6 +1,6 @@ import {useEffect, useState, useRef} from "react"; import {useRouter} from '@tarojs/taro' -import {Loading, CellGroup, Input, Form, Cell, Avatar, Tag} from '@nutui/nutui-react-taro' +import {Loading, CellGroup, Input, Form, Cell, Avatar, Tag, TextArea} from '@nutui/nutui-react-taro' import {ArrowRight} from '@nutui/icons-react-taro' import {View, Text} from '@tarojs/components' import Taro from '@tarojs/taro' @@ -12,16 +12,23 @@ import {User} from "@/api/system/user/model"; import {ClinicPatientUser} from "@/api/clinic/clinicPatientUser/model"; import {ClinicPrescription} from "@/api/clinic/clinicPrescription/model"; -const AddMessage = () => { +const AddOrder = () => { const {params} = useRouter(); const [toUser, setToUser] = useState() const [loading, setLoading] = useState(true) - const [FormData, _] = useState() const formRef = useRef(null) // 患者和处方状态 const [selectedPatient, setSelectedPatient] = useState(null) const [selectedPrescription, setSelectedPrescription] = useState(null) + + // 表单数据 + const [formData, setFormData] = useState({ + diagnosis: '', + treatmentPlan: '', + decoctionInstructions: '', + content: '' + }) // 判断是编辑还是新增模式 const isEditMode = !!params.id @@ -38,9 +45,7 @@ const AddMessage = () => { // 设置选中的患者(供其他页面调用) // @ts-ignore const setSelectedPatientFunc = (patient: ClinicPatientUser) => { - console.log('患者:', patient) setSelectedPatient(patient) - console.log(selectedPatient,'selectedPatient') } // 设置选中的处方(供其他页面调用) @@ -48,16 +53,19 @@ const AddMessage = () => { const setSelectedPrescriptionFunc = (prescription: ClinicPrescription) => { setSelectedPrescription(prescription) } + + // 处理表单字段变化 + const handleFormChange = (field: string, value: string) => { + setFormData(prev => ({ + ...prev, + [field]: value + })) + } // 提交表单 const submitSucceed = async (values: any) => { try { - // 准备提交的数据 - const submitData = { - ...values - }; - - console.log('提交数据:', submitData) + console.log('提交数据:', values) // 参数校验 if(!toUser && !selectedPatient){ @@ -71,14 +79,13 @@ const AddMessage = () => { // 判断内容是否为空 if (!values.content) { Taro.showToast({ - title: `请输入内容`, + title: `请输入消息内容`, icon: 'error' }); return false; } // 如果选择了患者,在消息内容中添加患者信息 - console.log(values,'vals.s..s.s.s.s.s') let content = values.content; if (selectedPatient) { content = `[患者: ${selectedPatient.realName || '未知'}] ${content}`; @@ -88,6 +95,19 @@ const AddMessage = () => { if (selectedPrescription) { content = `[处方: ${selectedPrescription.orderNo || '未知'}] ${content}`; } + + // 添加诊断结果和治疗方案到消息内容 + if (values.diagnosis) { + content = `诊断结果: ${values.diagnosis}\n` + content; + } + + if (values.treatmentPlan) { + content = `治疗方案: ${values.treatmentPlan}\n` + content; + } + + if (values.decoctionInstructions) { + content = `煎药说明: ${values.decoctionInstructions}\n` + content; + } // 执行新增或更新操作 await addShopChatMessage({ @@ -129,6 +149,19 @@ const AddMessage = () => { Taro.getCurrentInstance().page.setSelectedPatient = setSelectedPatientFunc; // @ts-ignore Taro.getCurrentInstance().page.setSelectedPrescription = setSelectedPrescriptionFunc; + + // 从本地存储获取之前选择的患者和处方 + const storedPatient = Taro.getStorageSync('selectedPatient'); + if (storedPatient) { + setSelectedPatient(JSON.parse(storedPatient)); + Taro.removeStorageSync('selectedPatient'); + } + + const storedPrescription = Taro.getStorageSync('selectedPrescription'); + if (storedPrescription) { + setSelectedPrescription(JSON.parse(storedPrescription)); + Taro.removeStorageSync('selectedPrescription'); + } }, [isEditMode]); if (loading) { @@ -153,7 +186,6 @@ const AddMessage = () => { )} {/* 选择患者 */} - {JSON.stringify(selectedPatient)} { ) : ( - + 请选择患者 )} onClick={() => navTo(`/doctor/orders/selectPatient`, true)} /> - - - - ) : ( - - )} - onClick={() => navTo(`/doctor/orders/selectPatient`, true)} - /> + {/* 诊断结果 */} + + +