fix(doctor):优化患者和订单相关功能
- 移除患者添加页面中冗余的日期选择器相关代码和逻辑 - 修复订单页面图片上传接口的Content-Type配置 - 增强订单页面上传响应数据校验和错误提示 - 完善订单页面患者和处方数据传递及本地存储逻辑 - 优化选择患者和处方页面的数据加载和滚动列表实现 - 改进页面间数据通信的稳定性和容错处理
This commit is contained in:
@@ -1,9 +1,9 @@
|
||||
import {useEffect, useState, useRef} from "react";
|
||||
import {Loading, CellGroup, Input, Form, Calendar} from '@nutui/nutui-react-taro'
|
||||
import {Edit, Calendar as CalendarIcon} from '@nutui/icons-react-taro'
|
||||
import {Loading, CellGroup, Input, Form} from '@nutui/nutui-react-taro'
|
||||
import {Edit} from '@nutui/icons-react-taro'
|
||||
import Taro from '@tarojs/taro'
|
||||
import {useRouter} from '@tarojs/taro'
|
||||
import {View, Text} from '@tarojs/components'
|
||||
import {View} from '@tarojs/components'
|
||||
import FixedButton from "@/components/FixedButton";
|
||||
import {useUser} from "@/hooks/useUser";
|
||||
import {ClinicPatientUser} from "@/api/clinic/clinicPatientUser/model";
|
||||
@@ -12,10 +12,6 @@ import {
|
||||
getClinicPatientUser,
|
||||
updateClinicPatientUser
|
||||
} from "@/api/clinic/clinicPatientUser";
|
||||
import {
|
||||
formatDateForDatabase,
|
||||
extractDateForCalendar, formatDateForDisplay
|
||||
} from "@/utils/dateUtils";
|
||||
|
||||
const AddPatient = () => {
|
||||
const {user} = useUser()
|
||||
@@ -25,27 +21,8 @@ const AddPatient = () => {
|
||||
const formRef = useRef<any>(null)
|
||||
const [isEditMode, setIsEditMode] = useState<boolean>(false)
|
||||
|
||||
// 日期选择器状态
|
||||
const [showCreateTimePicker, setShowCreateTimePicker] = useState<boolean>(false)
|
||||
const [createTime, setCreateTime] = useState<string>('')
|
||||
|
||||
console.log('AddPatient Component Rendered');
|
||||
|
||||
// 处理创建时间选择
|
||||
const handleCreateTimeConfirm = (param: string) => {
|
||||
const selectedDate = param[3] // 选中的日期字符串 (YYYY-M-D)
|
||||
const formattedDate = formatDateForDatabase(selectedDate) // 转换为数据库格式
|
||||
setCreateTime(selectedDate) // 保存原始格式用于显示
|
||||
setShowCreateTimePicker(false)
|
||||
|
||||
// 更新表单数据(使用数据库格式)
|
||||
if (formRef.current) {
|
||||
formRef.current.setFieldsValue({
|
||||
createTime: formattedDate
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
const reload = async () => {
|
||||
if (!params.id) {
|
||||
return false;
|
||||
@@ -57,11 +34,6 @@ const AddPatient = () => {
|
||||
setFormData(patient)
|
||||
setIsEditMode(true);
|
||||
|
||||
// 初始化日期数据(从数据库格式转换为Calendar组件格式)
|
||||
if (patient.createTime) {
|
||||
setCreateTime(extractDateForCalendar(patient.createTime))
|
||||
}
|
||||
|
||||
Taro.setNavigationBarTitle({title: '编辑患者'})
|
||||
}
|
||||
} catch (error) {
|
||||
@@ -98,8 +70,6 @@ const AddPatient = () => {
|
||||
...values,
|
||||
realName: values.realName || user?.nickname,
|
||||
phone: values.phone,
|
||||
// 确保日期数据正确提交(使用数据库格式)
|
||||
createTime: values.createTime || (createTime ? formatDateForDatabase(createTime) : new Date().toISOString().slice(0, 19).replace('T', ' '))
|
||||
};
|
||||
|
||||
// 调试信息
|
||||
@@ -179,30 +149,9 @@ const AddPatient = () => {
|
||||
<Form.Item name="comments" label="备注" initialValue={formData?.comments}>
|
||||
<Input placeholder="请填写备注信息" />
|
||||
</Form.Item>
|
||||
<Form.Item name="createTime" label="创建时间" initialValue={formData?.createTime}>
|
||||
<View
|
||||
className="flex items-center justify-between py-2"
|
||||
onClick={() => setShowCreateTimePicker(true)}
|
||||
>
|
||||
<View className="flex items-center">
|
||||
<CalendarIcon size={16} color="#999" className="mr-2"/>
|
||||
<Text style={{color: createTime ? '#333' : '#999'}}>
|
||||
{createTime ? formatDateForDisplay(createTime) : '请选择创建时间'}
|
||||
</Text>
|
||||
</View>
|
||||
</View>
|
||||
</Form.Item>
|
||||
</CellGroup>
|
||||
</Form>
|
||||
|
||||
{/* 创建时间选择器 */}
|
||||
<Calendar
|
||||
visible={showCreateTimePicker}
|
||||
defaultValue={createTime}
|
||||
onClose={() => setShowCreateTimePicker(false)}
|
||||
onConfirm={handleCreateTimeConfirm}
|
||||
/>
|
||||
|
||||
{/* 底部浮动按钮 */}
|
||||
<FixedButton
|
||||
icon={<Edit/>}
|
||||
|
||||
Reference in New Issue
Block a user