feat(clinic): 新增患者管理功能模块
- 新增患者管理页面,支持查看和管理患者信息 - 添加患者报备功能,支持新增和编辑患者资料- 实现患者列表展示,包含搜索、筛选和分页功能 - 支持患者状态跟踪和保护期计算- 集成电话拨打和号码复制功能 - 添加处方管理相关数据模型和接口定义 - 更新环境配置中的API地址指向新的生产环境- 优化医生端主页UI布局和功能导航 - 调整部分字段命名以提高代码一致性 -修复医生认证状态下的文案提示问题
This commit is contained in:
@@ -8,13 +8,13 @@ export const ENV_CONFIG = {
|
|||||||
},
|
},
|
||||||
// 生产环境
|
// 生产环境
|
||||||
production: {
|
production: {
|
||||||
API_BASE_URL: 'https://cms-api.websoft.top/api',
|
API_BASE_URL: 'https://mp-api.websoft.top/api',
|
||||||
APP_NAME: '通源堂健康生态平台',
|
APP_NAME: '通源堂健康生态平台',
|
||||||
DEBUG: 'false',
|
DEBUG: 'false',
|
||||||
},
|
},
|
||||||
// 测试环境
|
// 测试环境
|
||||||
test: {
|
test: {
|
||||||
API_BASE_URL: 'https://cms-api.s209.websoft.top/api',
|
API_BASE_URL: 'https://mp-api.websoft.top/api',
|
||||||
APP_NAME: '测试环境',
|
APP_NAME: '测试环境',
|
||||||
DEBUG: 'true',
|
DEBUG: 'true',
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ export interface ClinicPatientUser {
|
|||||||
// 姓名
|
// 姓名
|
||||||
realName?: string;
|
realName?: string;
|
||||||
// 手机号
|
// 手机号
|
||||||
mobile?: string;
|
phone?: string;
|
||||||
// 支付密码
|
// 支付密码
|
||||||
payPassword?: string;
|
payPassword?: string;
|
||||||
// 当前可提现佣金
|
// 当前可提现佣金
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import type { PageParam } from '@/api/index';
|
import type { PageParam } from '@/api/index';
|
||||||
|
import {ClinicPrescriptionItem} from "@/api/clinic/clinicPrescriptionItem/model";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 处方主表
|
* 处方主表
|
||||||
@@ -45,6 +46,8 @@ export interface ClinicPrescription {
|
|||||||
createTime?: string;
|
createTime?: string;
|
||||||
// 修改时间
|
// 修改时间
|
||||||
updateTime?: string;
|
updateTime?: string;
|
||||||
|
// 药方信息
|
||||||
|
items?: ClinicPrescriptionItem[];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -13,6 +13,10 @@ export interface ClinicPrescriptionItem {
|
|||||||
prescriptionNo?: string;
|
prescriptionNo?: string;
|
||||||
// 关联药品
|
// 关联药品
|
||||||
medicineId?: number;
|
medicineId?: number;
|
||||||
|
// 药品名称
|
||||||
|
medicineName?: string;
|
||||||
|
// 规格(如“10g”)
|
||||||
|
specification?: string;
|
||||||
// 剂量(如“10g”)
|
// 剂量(如“10g”)
|
||||||
dosage?: string;
|
dosage?: string;
|
||||||
// 用法频率(如“每日三次”)
|
// 用法频率(如“每日三次”)
|
||||||
|
|||||||
@@ -81,6 +81,8 @@ export default {
|
|||||||
"withdraw/index",
|
"withdraw/index",
|
||||||
"orders/index",
|
"orders/index",
|
||||||
"orders/add",
|
"orders/add",
|
||||||
|
"orders/selectPatient",
|
||||||
|
"orders/selectPrescription",
|
||||||
"team/index",
|
"team/index",
|
||||||
"qrcode/index",
|
"qrcode/index",
|
||||||
"invite-stats/index",
|
"invite-stats/index",
|
||||||
@@ -93,6 +95,7 @@ export default {
|
|||||||
{
|
{
|
||||||
"root": "clinic",
|
"root": "clinic",
|
||||||
"pages": [
|
"pages": [
|
||||||
|
"index",
|
||||||
"clinicPatientUser/add",
|
"clinicPatientUser/add",
|
||||||
"clinicDoctorUser/add"
|
"clinicDoctorUser/add"
|
||||||
]
|
]
|
||||||
|
|||||||
3
src/clinic/clinicPatientUser/index.config.ts
Normal file
3
src/clinic/clinicPatientUser/index.config.ts
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
export default definePageConfig({
|
||||||
|
navigationBarTitleText: '患者管理'
|
||||||
|
})
|
||||||
583
src/clinic/clinicPatientUser/index.tsx
Normal file
583
src/clinic/clinicPatientUser/index.tsx
Normal file
@@ -0,0 +1,583 @@
|
|||||||
|
import {useState, useEffect, useCallback} from 'react'
|
||||||
|
import {View, Text} from '@tarojs/components'
|
||||||
|
import Taro, {useDidShow} from '@tarojs/taro'
|
||||||
|
import {Loading, InfiniteLoading, Empty, Space, Tabs, TabPane, Tag, Button, SearchBar} from '@nutui/nutui-react-taro'
|
||||||
|
import {Phone, AngleDoubleLeft} from '@nutui/icons-react-taro'
|
||||||
|
import type {ShopDealerApply, ShopDealerApply as UserType} from "@/api/shop/shopDealerApply/model";
|
||||||
|
import {
|
||||||
|
CustomerStatus,
|
||||||
|
getStatusText,
|
||||||
|
getStatusTagType,
|
||||||
|
getStatusOptions,
|
||||||
|
mapApplyStatusToCustomerStatus,
|
||||||
|
mapCustomerStatusToApplyStatus
|
||||||
|
} from '@/utils/customerStatus';
|
||||||
|
import FixedButton from "@/components/FixedButton";
|
||||||
|
import navTo from "@/utils/common";
|
||||||
|
import {pageShopDealerApply, removeShopDealerApply, updateShopDealerApply} from "@/api/shop/shopDealerApply";
|
||||||
|
|
||||||
|
// 扩展User类型,添加客户状态和保护天数
|
||||||
|
interface CustomerUser extends UserType {
|
||||||
|
customerStatus?: CustomerStatus;
|
||||||
|
protectDays?: number; // 剩余保护天数
|
||||||
|
}
|
||||||
|
|
||||||
|
const CustomerIndex = () => {
|
||||||
|
const [list, setList] = useState<CustomerUser[]>([])
|
||||||
|
const [loading, setLoading] = useState<boolean>(false)
|
||||||
|
const [activeTab, setActiveTab] = useState<CustomerStatus>('all')
|
||||||
|
const [searchValue, setSearchValue] = useState<string>('')
|
||||||
|
const [displaySearchValue, setDisplaySearchValue] = useState<string>('')
|
||||||
|
const [page, setPage] = useState(1)
|
||||||
|
const [hasMore, setHasMore] = useState(true)
|
||||||
|
|
||||||
|
// Tab配置
|
||||||
|
const tabList = getStatusOptions();
|
||||||
|
|
||||||
|
// 复制手机号
|
||||||
|
const copyPhone = (phone: string) => {
|
||||||
|
Taro.setClipboardData({
|
||||||
|
data: phone,
|
||||||
|
success: () => {
|
||||||
|
Taro.showToast({
|
||||||
|
title: '手机号已复制',
|
||||||
|
icon: 'success',
|
||||||
|
duration: 1500
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
// 一键拨打
|
||||||
|
const makePhoneCall = (phone: string) => {
|
||||||
|
Taro.makePhoneCall({
|
||||||
|
phoneNumber: phone,
|
||||||
|
fail: () => {
|
||||||
|
Taro.showToast({
|
||||||
|
title: '拨打取消',
|
||||||
|
icon: 'error'
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
// 编辑跟进情况
|
||||||
|
const editComments = (customer: CustomerUser) => {
|
||||||
|
Taro.showModal({
|
||||||
|
title: '编辑跟进情况',
|
||||||
|
// @ts-ignore
|
||||||
|
editable: true,
|
||||||
|
placeholderText: '请输入跟进情况',
|
||||||
|
content: customer.comments || '',
|
||||||
|
success: async (res) => {
|
||||||
|
// @ts-ignore
|
||||||
|
if (res.confirm && res.content !== undefined) {
|
||||||
|
try {
|
||||||
|
// 更新跟进情况
|
||||||
|
await updateShopDealerApply({
|
||||||
|
...customer,
|
||||||
|
// @ts-ignore
|
||||||
|
comments: res.content.trim()
|
||||||
|
});
|
||||||
|
|
||||||
|
Taro.showToast({
|
||||||
|
title: '更新成功',
|
||||||
|
icon: 'success'
|
||||||
|
});
|
||||||
|
|
||||||
|
// 刷新列表
|
||||||
|
setList([]);
|
||||||
|
setPage(1);
|
||||||
|
setHasMore(true);
|
||||||
|
fetchCustomerData(activeTab, true);
|
||||||
|
} catch (error) {
|
||||||
|
console.error('更新跟进情况失败:', error);
|
||||||
|
Taro.showToast({
|
||||||
|
title: '更新失败,请重试',
|
||||||
|
icon: 'error'
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
// 计算剩余保护天数(基于过期时间)
|
||||||
|
const calculateProtectDays = (expirationTime?: string, applyTime?: string): number => {
|
||||||
|
try {
|
||||||
|
// 优先使用过期时间字段
|
||||||
|
if (expirationTime) {
|
||||||
|
const expDate = new Date(expirationTime.replace(' ', 'T'));
|
||||||
|
const now = new Date();
|
||||||
|
|
||||||
|
// 计算剩余毫秒数
|
||||||
|
const remainingMs = expDate.getTime() - now.getTime();
|
||||||
|
|
||||||
|
// 转换为天数,向上取整
|
||||||
|
const remainingDays = Math.ceil(remainingMs / (1000 * 60 * 60 * 24));
|
||||||
|
|
||||||
|
console.log('=== 基于过期时间计算 ===');
|
||||||
|
console.log('过期时间:', expirationTime);
|
||||||
|
console.log('当前时间:', now.toLocaleString());
|
||||||
|
console.log('剩余天数:', remainingDays);
|
||||||
|
console.log('======================');
|
||||||
|
|
||||||
|
return Math.max(0, remainingDays);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 如果没有过期时间,回退到基于申请时间计算
|
||||||
|
if (!applyTime) return 0;
|
||||||
|
|
||||||
|
const protectionPeriod = 7; // 保护期7天
|
||||||
|
|
||||||
|
// 解析申请时间
|
||||||
|
let applyDate: Date;
|
||||||
|
if (applyTime.includes('T')) {
|
||||||
|
applyDate = new Date(applyTime);
|
||||||
|
} else {
|
||||||
|
applyDate = new Date(applyTime.replace(' ', 'T'));
|
||||||
|
}
|
||||||
|
|
||||||
|
// 获取当前时间
|
||||||
|
const now = new Date();
|
||||||
|
|
||||||
|
// 只比较日期部分,忽略时间
|
||||||
|
const applyDateOnly = new Date(applyDate.getFullYear(), applyDate.getMonth(), applyDate.getDate());
|
||||||
|
const currentDateOnly = new Date(now.getFullYear(), now.getMonth(), now.getDate());
|
||||||
|
|
||||||
|
// 计算已经过去的天数
|
||||||
|
const timeDiff = currentDateOnly.getTime() - applyDateOnly.getTime();
|
||||||
|
const daysPassed = Math.floor(timeDiff / (1000 * 60 * 60 * 24));
|
||||||
|
|
||||||
|
// 计算剩余保护天数
|
||||||
|
const remainingDays = protectionPeriod - daysPassed;
|
||||||
|
|
||||||
|
console.log('=== 基于申请时间计算 ===');
|
||||||
|
console.log('申请时间:', applyTime);
|
||||||
|
console.log('已过去天数:', daysPassed);
|
||||||
|
console.log('剩余保护天数:', remainingDays);
|
||||||
|
console.log('======================');
|
||||||
|
|
||||||
|
return Math.max(0, remainingDays);
|
||||||
|
} catch (error) {
|
||||||
|
console.error('日期计算错误:', error);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
// 获取客户数据
|
||||||
|
const fetchCustomerData = useCallback(async (statusFilter?: CustomerStatus, resetPage = false, targetPage?: number) => {
|
||||||
|
setLoading(true);
|
||||||
|
try {
|
||||||
|
const currentPage = resetPage ? 1 : (targetPage || page);
|
||||||
|
|
||||||
|
// 构建API参数,根据状态筛选
|
||||||
|
const params: any = {
|
||||||
|
type: 4,
|
||||||
|
page: currentPage
|
||||||
|
};
|
||||||
|
const applyStatus = mapCustomerStatusToApplyStatus(statusFilter || activeTab);
|
||||||
|
if (applyStatus !== undefined) {
|
||||||
|
params.applyStatus = applyStatus;
|
||||||
|
}
|
||||||
|
|
||||||
|
const res = await pageShopDealerApply(params);
|
||||||
|
|
||||||
|
if (res?.list && res.list.length > 0) {
|
||||||
|
// 正确映射状态并计算保护天数
|
||||||
|
const mappedList = res.list.map(customer => ({
|
||||||
|
...customer,
|
||||||
|
customerStatus: mapApplyStatusToCustomerStatus(customer.applyStatus || 10),
|
||||||
|
protectDays: calculateProtectDays(customer.expirationTime, customer.applyTime || customer.createTime || '')
|
||||||
|
}));
|
||||||
|
|
||||||
|
// 如果是重置页面或第一页,直接设置新数据;否则追加数据
|
||||||
|
if (resetPage || currentPage === 1) {
|
||||||
|
setList(mappedList);
|
||||||
|
} else {
|
||||||
|
setList(prevList => prevList.concat(mappedList));
|
||||||
|
}
|
||||||
|
|
||||||
|
// 正确判断是否还有更多数据
|
||||||
|
const hasMoreData = res.list.length >= 10; // 假设每页10条数据
|
||||||
|
setHasMore(hasMoreData);
|
||||||
|
} else {
|
||||||
|
if (resetPage || currentPage === 1) {
|
||||||
|
setList([]);
|
||||||
|
}
|
||||||
|
setHasMore(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
setPage(currentPage);
|
||||||
|
} catch (error) {
|
||||||
|
console.error('获取客户数据失败:', error);
|
||||||
|
Taro.showToast({
|
||||||
|
title: '加载失败,请重试',
|
||||||
|
icon: 'none'
|
||||||
|
});
|
||||||
|
} finally {
|
||||||
|
setLoading(false);
|
||||||
|
}
|
||||||
|
}, [activeTab, page]);
|
||||||
|
|
||||||
|
const reloadMore = async () => {
|
||||||
|
if (loading || !hasMore) return; // 防止重复加载
|
||||||
|
const nextPage = page + 1;
|
||||||
|
await fetchCustomerData(activeTab, false, nextPage);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// 防抖搜索功能
|
||||||
|
useEffect(() => {
|
||||||
|
const timer = setTimeout(() => {
|
||||||
|
setDisplaySearchValue(searchValue);
|
||||||
|
}, 300); // 300ms 防抖
|
||||||
|
|
||||||
|
return () => clearTimeout(timer);
|
||||||
|
}, [searchValue]);
|
||||||
|
|
||||||
|
// 根据搜索条件筛选数据(状态筛选已在API层面处理)
|
||||||
|
const getFilteredList = () => {
|
||||||
|
let filteredList = list;
|
||||||
|
|
||||||
|
// 按搜索关键词筛选
|
||||||
|
if (displaySearchValue.trim()) {
|
||||||
|
const keyword = displaySearchValue.trim().toLowerCase();
|
||||||
|
filteredList = filteredList.filter(customer =>
|
||||||
|
(customer.realName && customer.realName.toLowerCase().includes(keyword)) ||
|
||||||
|
(customer.dealerName && customer.dealerName.toLowerCase().includes(keyword)) ||
|
||||||
|
(customer.dealerCode && customer.dealerCode.toLowerCase().includes(keyword)) ||
|
||||||
|
(customer.mobile && customer.mobile.includes(keyword)) ||
|
||||||
|
(customer.userId && customer.userId.toString().includes(keyword))
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
return filteredList;
|
||||||
|
};
|
||||||
|
|
||||||
|
// 获取各状态的统计数量
|
||||||
|
const [statusCounts, setStatusCounts] = useState({
|
||||||
|
all: 0,
|
||||||
|
pending: 0,
|
||||||
|
signed: 0,
|
||||||
|
cancelled: 0
|
||||||
|
});
|
||||||
|
|
||||||
|
// 获取所有状态的统计数量
|
||||||
|
const fetchStatusCounts = useCallback(async () => {
|
||||||
|
try {
|
||||||
|
// 并行获取各状态的数量
|
||||||
|
const [allRes, pendingRes, signedRes, cancelledRes] = await Promise.all([
|
||||||
|
pageShopDealerApply({type: 4}), // 全部
|
||||||
|
pageShopDealerApply({applyStatus: 10, type: 4}), // 跟进中
|
||||||
|
pageShopDealerApply({applyStatus: 20, type: 4}), // 已签约
|
||||||
|
pageShopDealerApply({applyStatus: 30, type: 4}) // 已取消
|
||||||
|
]);
|
||||||
|
|
||||||
|
setStatusCounts({
|
||||||
|
all: allRes?.count || 0,
|
||||||
|
pending: pendingRes?.count || 0,
|
||||||
|
signed: signedRes?.count || 0,
|
||||||
|
cancelled: cancelledRes?.count || 0
|
||||||
|
});
|
||||||
|
} catch (error) {
|
||||||
|
console.error('获取状态统计失败:', error);
|
||||||
|
}
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
const getStatusCounts = () => statusCounts;
|
||||||
|
|
||||||
|
// 取消操作
|
||||||
|
const handleCancel = (customer: ShopDealerApply) => {
|
||||||
|
updateShopDealerApply({
|
||||||
|
...customer,
|
||||||
|
applyStatus: 30
|
||||||
|
}).then(() => {
|
||||||
|
Taro.showToast({
|
||||||
|
title: '取消成功',
|
||||||
|
icon: 'success'
|
||||||
|
});
|
||||||
|
// 重新加载当前tab的数据
|
||||||
|
setList([]);
|
||||||
|
setPage(1);
|
||||||
|
setHasMore(true);
|
||||||
|
fetchCustomerData(activeTab, true).then();
|
||||||
|
fetchStatusCounts().then();
|
||||||
|
})
|
||||||
|
};
|
||||||
|
|
||||||
|
// 删除
|
||||||
|
const handleDelete = (customer: ShopDealerApply) => {
|
||||||
|
removeShopDealerApply(customer.applyId).then(() => {
|
||||||
|
Taro.showToast({
|
||||||
|
title: '删除成功',
|
||||||
|
icon: 'success'
|
||||||
|
});
|
||||||
|
// 刷新当前tab的数据
|
||||||
|
setList([]);
|
||||||
|
setPage(1);
|
||||||
|
setHasMore(true);
|
||||||
|
fetchCustomerData(activeTab, true).then();
|
||||||
|
fetchStatusCounts().then();
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// 初始化数据
|
||||||
|
useEffect(() => {
|
||||||
|
fetchCustomerData(activeTab, true).then();
|
||||||
|
fetchStatusCounts().then();
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
// 当activeTab变化时重新获取数据
|
||||||
|
useEffect(() => {
|
||||||
|
setList([]); // 清空列表
|
||||||
|
setPage(1); // 重置页码
|
||||||
|
setHasMore(true); // 重置加载状态
|
||||||
|
fetchCustomerData(activeTab, true);
|
||||||
|
}, [activeTab]);
|
||||||
|
|
||||||
|
// 监听页面显示,当从其他页面返回时刷新数据
|
||||||
|
useDidShow(() => {
|
||||||
|
// 刷新当前tab的数据和统计信息
|
||||||
|
setList([]);
|
||||||
|
setPage(1);
|
||||||
|
setHasMore(true);
|
||||||
|
fetchCustomerData(activeTab, true);
|
||||||
|
fetchStatusCounts();
|
||||||
|
});
|
||||||
|
|
||||||
|
// 渲染客户项
|
||||||
|
const renderCustomerItem = (customer: CustomerUser) => (
|
||||||
|
<View key={customer.userId} className="bg-white rounded-lg p-4 mb-3 shadow-sm">
|
||||||
|
<View className="flex items-center mb-3">
|
||||||
|
<View className="flex-1">
|
||||||
|
<View className="flex items-center justify-between mb-1">
|
||||||
|
<Text className="font-semibold text-gray-800 mr-2">
|
||||||
|
{customer.dealerName}
|
||||||
|
</Text>
|
||||||
|
{customer.customerStatus && (
|
||||||
|
<Tag type={getStatusTagType(customer.customerStatus)}>
|
||||||
|
{getStatusText(customer.customerStatus)}
|
||||||
|
</Tag>
|
||||||
|
)}
|
||||||
|
</View>
|
||||||
|
<View className="flex items-center mb-1">
|
||||||
|
<Space direction="vertical">
|
||||||
|
<Text className="text-xs text-gray-500">联系人:{customer.realName}</Text>
|
||||||
|
<View className="flex items-center">
|
||||||
|
<Text className="text-xs text-gray-500" onClick={(e) => {
|
||||||
|
e.stopPropagation();
|
||||||
|
makePhoneCall(customer.mobile || '');
|
||||||
|
}}>联系电话:{customer.mobile}</Text>
|
||||||
|
<View className="flex items-center ml-2">
|
||||||
|
<Phone
|
||||||
|
size={12}
|
||||||
|
className="text-green-500 mr-2"
|
||||||
|
onClick={(e) => {
|
||||||
|
e.stopPropagation();
|
||||||
|
makePhoneCall(customer.mobile || '');
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
<Text
|
||||||
|
className="text-xs text-blue-500 cursor-pointer"
|
||||||
|
onClick={(e) => {
|
||||||
|
e.stopPropagation();
|
||||||
|
copyPhone(customer.mobile || '');
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
复制
|
||||||
|
</Text>
|
||||||
|
</View>
|
||||||
|
</View>
|
||||||
|
<Text className="text-xs text-gray-500">
|
||||||
|
添加时间:{customer.createTime}
|
||||||
|
</Text>
|
||||||
|
</Space>
|
||||||
|
</View>
|
||||||
|
|
||||||
|
{/* 保护天数显示 */}
|
||||||
|
{customer.applyStatus === 10 && (
|
||||||
|
<View className="flex items-center my-1">
|
||||||
|
<Text className="text-xs text-gray-500 mr-2">保护期:</Text>
|
||||||
|
{customer.protectDays && customer.protectDays > 0 ? (
|
||||||
|
<Text className={`text-xs px-2 py-1 rounded ${
|
||||||
|
customer.protectDays <= 2
|
||||||
|
? 'bg-red-100 text-red-600'
|
||||||
|
: customer.protectDays <= 4
|
||||||
|
? 'bg-orange-100 text-orange-600'
|
||||||
|
: 'bg-green-100 text-green-600'
|
||||||
|
}`}>
|
||||||
|
剩余{customer.protectDays}天
|
||||||
|
</Text>
|
||||||
|
) : (
|
||||||
|
<Text className="text-xs px-2 py-1 rounded bg-gray-100 text-gray-500">
|
||||||
|
已过期
|
||||||
|
</Text>
|
||||||
|
)}
|
||||||
|
</View>
|
||||||
|
)}
|
||||||
|
|
||||||
|
<View className={'flex items-center gap-2'}>
|
||||||
|
<Text className="text-xs text-gray-500">报备人:{customer?.nickName}</Text>
|
||||||
|
<AngleDoubleLeft size={12} className={'text-blue-500'} />
|
||||||
|
<Text className={'text-xs text-gray-500'}>{customer?.refereeName}</Text>
|
||||||
|
</View>
|
||||||
|
|
||||||
|
{/* 显示 comments 字段 */}
|
||||||
|
<Space className="flex items-center">
|
||||||
|
<Text className="text-xs text-gray-500">跟进情况:{customer.comments || '暂无'}</Text>
|
||||||
|
<Text
|
||||||
|
className="text-xs text-blue-500 cursor-pointer"
|
||||||
|
onClick={(e) => {
|
||||||
|
e.stopPropagation();
|
||||||
|
editComments(customer);
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
编辑
|
||||||
|
</Text>
|
||||||
|
</Space>
|
||||||
|
</View>
|
||||||
|
</View>
|
||||||
|
|
||||||
|
{/* 跟进中状态显示操作按钮 */}
|
||||||
|
{(customer.applyStatus === 10 && customer.userId == Taro.getStorageSync('UserId')) && (
|
||||||
|
<Space className="flex justify-end">
|
||||||
|
<Button
|
||||||
|
size="small"
|
||||||
|
onClick={() => navTo(`/doctor/customer/add?id=${customer.applyId}`, true)}
|
||||||
|
style={{marginRight: '8px', backgroundColor: '#52c41a', color: 'white'}}
|
||||||
|
>
|
||||||
|
签约
|
||||||
|
</Button>
|
||||||
|
<Button
|
||||||
|
size="small"
|
||||||
|
onClick={() => handleCancel(customer)}
|
||||||
|
style={{backgroundColor: '#ff4d4f', color: 'white'}}
|
||||||
|
>
|
||||||
|
取消
|
||||||
|
</Button>
|
||||||
|
</Space>
|
||||||
|
)}
|
||||||
|
{(customer.applyStatus === 30 && customer.userId == Taro.getStorageSync('UserId')) && (
|
||||||
|
<Space className="flex justify-end">
|
||||||
|
<Button
|
||||||
|
size="small"
|
||||||
|
onClick={() => handleDelete(customer)}
|
||||||
|
style={{backgroundColor: '#ff4d4f', color: 'white'}}
|
||||||
|
>
|
||||||
|
删除
|
||||||
|
</Button>
|
||||||
|
</Space>
|
||||||
|
)}
|
||||||
|
</View>
|
||||||
|
);
|
||||||
|
|
||||||
|
// 渲染客户列表
|
||||||
|
const renderCustomerList = () => {
|
||||||
|
const filteredList = getFilteredList();
|
||||||
|
const isSearching = displaySearchValue.trim().length > 0;
|
||||||
|
|
||||||
|
return (
|
||||||
|
<View className="flex-1">
|
||||||
|
{/* 搜索结果统计 */}
|
||||||
|
{isSearching && (
|
||||||
|
<View className="bg-white px-4 py-2 border-b border-gray-100">
|
||||||
|
<Text className="text-sm text-gray-600">
|
||||||
|
搜索 "{displaySearchValue}" 的结果,共找到 {filteredList.length} 条记录
|
||||||
|
</Text>
|
||||||
|
</View>
|
||||||
|
)}
|
||||||
|
|
||||||
|
<View className="p-4" style={{
|
||||||
|
height: isSearching ? 'calc(90vh - 40px)' : '90vh',
|
||||||
|
overflowY: 'auto',
|
||||||
|
overflowX: 'hidden'
|
||||||
|
}}>
|
||||||
|
<InfiniteLoading
|
||||||
|
target="scroll"
|
||||||
|
hasMore={hasMore}
|
||||||
|
onLoadMore={reloadMore}
|
||||||
|
onScroll={() => {
|
||||||
|
// 滚动事件处理
|
||||||
|
}}
|
||||||
|
onScrollToUpper={() => {
|
||||||
|
// 滚动到顶部事件处理
|
||||||
|
}}
|
||||||
|
loadingText={
|
||||||
|
<>
|
||||||
|
加载中...
|
||||||
|
</>
|
||||||
|
}
|
||||||
|
loadMoreText={
|
||||||
|
filteredList.length === 0 ? (
|
||||||
|
<Empty
|
||||||
|
style={{backgroundColor: 'transparent'}}
|
||||||
|
description={loading ? "加载中..." : "暂无客户数据"}
|
||||||
|
/>
|
||||||
|
) : (
|
||||||
|
<View className={'h-3 flex items-center justify-center'}>
|
||||||
|
<Text className="text-gray-500 text-sm">没有更多了</Text>
|
||||||
|
</View>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
>
|
||||||
|
{loading && filteredList.length === 0 ? (
|
||||||
|
<View className="flex items-center justify-center py-8">
|
||||||
|
<Loading/>
|
||||||
|
<Text className="text-gray-500 mt-2 ml-2">加载中...</Text>
|
||||||
|
</View>
|
||||||
|
) : (
|
||||||
|
filteredList.map(renderCustomerItem)
|
||||||
|
)}
|
||||||
|
</InfiniteLoading>
|
||||||
|
</View>
|
||||||
|
</View>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
return (
|
||||||
|
<View className="min-h-screen bg-gray-50">
|
||||||
|
{/* 搜索栏 */}
|
||||||
|
<View className="bg-white py-2 border-b border-gray-100">
|
||||||
|
<SearchBar
|
||||||
|
value={searchValue}
|
||||||
|
placeholder="搜索客户名称、手机号"
|
||||||
|
onChange={(value) => setSearchValue(value)}
|
||||||
|
onClear={() => {
|
||||||
|
setSearchValue('');
|
||||||
|
setDisplaySearchValue('');
|
||||||
|
}}
|
||||||
|
clearable
|
||||||
|
/>
|
||||||
|
</View>
|
||||||
|
|
||||||
|
{/* 顶部Tabs */}
|
||||||
|
<View className="bg-white">
|
||||||
|
<Tabs
|
||||||
|
value={activeTab}
|
||||||
|
onChange={(value) => setActiveTab(value as CustomerStatus)}
|
||||||
|
>
|
||||||
|
{tabList.map(tab => {
|
||||||
|
const counts = getStatusCounts();
|
||||||
|
const count = counts[tab.value as keyof typeof counts] || 0;
|
||||||
|
return (
|
||||||
|
<TabPane
|
||||||
|
key={tab.value}
|
||||||
|
title={`${tab.label}${count > 0 ? `(${count})` : ''}`}
|
||||||
|
value={tab.value}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
})}
|
||||||
|
</Tabs>
|
||||||
|
</View>
|
||||||
|
|
||||||
|
{/* 客户列表 */}
|
||||||
|
{renderCustomerList()}
|
||||||
|
|
||||||
|
<FixedButton text={'客户报备'} onClick={() => Taro.navigateTo({url: '/doctor/customer/add'})}/>
|
||||||
|
</View>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default CustomerIndex;
|
||||||
3
src/clinic/index.config.ts
Normal file
3
src/clinic/index.config.ts
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
export default definePageConfig({
|
||||||
|
navigationBarTitleText: '医生端'
|
||||||
|
})
|
||||||
0
src/clinic/index.scss
Normal file
0
src/clinic/index.scss
Normal file
258
src/clinic/index.tsx
Normal file
258
src/clinic/index.tsx
Normal file
@@ -0,0 +1,258 @@
|
|||||||
|
import React from 'react'
|
||||||
|
import {View, Text} from '@tarojs/components'
|
||||||
|
import {ConfigProvider, Grid, Avatar} from '@nutui/nutui-react-taro'
|
||||||
|
import {
|
||||||
|
User,
|
||||||
|
UserAdd,
|
||||||
|
Edit,
|
||||||
|
Comment,
|
||||||
|
QrCode,
|
||||||
|
Notice,
|
||||||
|
Orderlist,
|
||||||
|
Health,
|
||||||
|
PickedUp
|
||||||
|
} from '@nutui/icons-react-taro'
|
||||||
|
import {useDealerUser} from '@/hooks/useDealerUser'
|
||||||
|
import { useThemeStyles } from '@/hooks/useTheme'
|
||||||
|
import {gradientUtils} from '@/styles/gradients'
|
||||||
|
import Taro from '@tarojs/taro'
|
||||||
|
|
||||||
|
const DealerIndex: React.FC = () => {
|
||||||
|
const {
|
||||||
|
dealerUser
|
||||||
|
} = useDealerUser()
|
||||||
|
|
||||||
|
// 使用主题样式
|
||||||
|
const themeStyles = useThemeStyles()
|
||||||
|
|
||||||
|
// 导航到各个功能页面
|
||||||
|
const navigateToPage = (url: string) => {
|
||||||
|
Taro.navigateTo({url})
|
||||||
|
}
|
||||||
|
|
||||||
|
// 格式化金额
|
||||||
|
// const formatMoney = (money?: string) => {
|
||||||
|
// if (!money) return '0.00'
|
||||||
|
// return parseFloat(money).toFixed(2)
|
||||||
|
// }
|
||||||
|
|
||||||
|
// 格式化时间
|
||||||
|
const formatTime = (time?: string) => {
|
||||||
|
if (!time) return '-'
|
||||||
|
return new Date(time).toLocaleDateString()
|
||||||
|
}
|
||||||
|
|
||||||
|
// 获取用户主题
|
||||||
|
const userTheme = gradientUtils.getThemeByUserId(dealerUser?.userId)
|
||||||
|
|
||||||
|
// 获取渐变背景
|
||||||
|
const getGradientBackground = (themeColor?: string) => {
|
||||||
|
if (themeColor) {
|
||||||
|
const darkerColor = gradientUtils.adjustColorBrightness(themeColor, -30)
|
||||||
|
return gradientUtils.createGradient(themeColor, darkerColor)
|
||||||
|
}
|
||||||
|
return userTheme.background
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log(getGradientBackground(),'getGradientBackground()')
|
||||||
|
|
||||||
|
// if (error) {
|
||||||
|
// return (
|
||||||
|
// <View className="p-4">
|
||||||
|
// <View className="bg-red-50 border border-red-200 rounded-lg p-4 mb-4">
|
||||||
|
// <Text className="text-red-600">{error}</Text>
|
||||||
|
// </View>
|
||||||
|
// <Button type="primary" onClick={refresh}>
|
||||||
|
// 重试
|
||||||
|
// </Button>
|
||||||
|
// </View>
|
||||||
|
// )
|
||||||
|
// }
|
||||||
|
|
||||||
|
return (
|
||||||
|
<View className="bg-gray-100 min-h-screen">
|
||||||
|
<View>
|
||||||
|
{/*头部信息*/}
|
||||||
|
{dealerUser && (
|
||||||
|
<View className="px-4 py-6 relative overflow-hidden" style={themeStyles.primaryBackground}>
|
||||||
|
{/* 装饰性背景元素 - 小程序兼容版本 */}
|
||||||
|
<View className="absolute w-32 h-32 rounded-full" style={{
|
||||||
|
backgroundColor: 'rgba(255, 255, 255, 0.1)',
|
||||||
|
top: '-16px',
|
||||||
|
right: '-16px'
|
||||||
|
}}></View>
|
||||||
|
<View className="absolute w-24 h-24 rounded-full" style={{
|
||||||
|
backgroundColor: 'rgba(255, 255, 255, 0.08)',
|
||||||
|
bottom: '-12px',
|
||||||
|
left: '-12px'
|
||||||
|
}}></View>
|
||||||
|
<View className="absolute w-16 h-16 rounded-full" style={{
|
||||||
|
backgroundColor: 'rgba(255, 255, 255, 0.05)',
|
||||||
|
top: '60px',
|
||||||
|
left: '120px'
|
||||||
|
}}></View>
|
||||||
|
<View className="flex items-center justify-between relative z-10 mb-4">
|
||||||
|
<Avatar
|
||||||
|
size="50"
|
||||||
|
src={dealerUser?.qrcode}
|
||||||
|
icon={<User/>}
|
||||||
|
className="mr-4"
|
||||||
|
style={{
|
||||||
|
border: '2px solid rgba(255, 255, 255, 0.3)'
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
<View className="flex-1 flex-col">
|
||||||
|
<View className="text-white text-lg font-bold mb-1" style={{
|
||||||
|
}}>
|
||||||
|
{dealerUser?.realName || '医生名称'}
|
||||||
|
</View>
|
||||||
|
<View className="text-sm" style={{
|
||||||
|
color: 'rgba(255, 255, 255, 0.8)'
|
||||||
|
}}>
|
||||||
|
医生编号: {dealerUser.userId}
|
||||||
|
</View>
|
||||||
|
</View>
|
||||||
|
<View className="text-right hidden">
|
||||||
|
<Text className="text-xs" style={{
|
||||||
|
color: 'rgba(255, 255, 255, 0.9)'
|
||||||
|
}}>加入时间</Text>
|
||||||
|
<Text className="text-xs" style={{
|
||||||
|
color: 'rgba(255, 255, 255, 0.7)'
|
||||||
|
}}>
|
||||||
|
{formatTime(dealerUser.createTime)}
|
||||||
|
</Text>
|
||||||
|
</View>
|
||||||
|
</View>
|
||||||
|
</View>
|
||||||
|
)}
|
||||||
|
|
||||||
|
{/* 功能导航 */}
|
||||||
|
<View className="bg-white mx-4 mt-4 rounded-xl p-4">
|
||||||
|
<View className="font-semibold mb-4 text-gray-800">管理工具</View>
|
||||||
|
<ConfigProvider>
|
||||||
|
<Grid
|
||||||
|
columns={4}
|
||||||
|
className="no-border-grid"
|
||||||
|
style={{
|
||||||
|
'--nutui-grid-border-color': 'transparent',
|
||||||
|
'--nutui-grid-item-border-width': '0px',
|
||||||
|
border: 'none'
|
||||||
|
} as React.CSSProperties}
|
||||||
|
>
|
||||||
|
<Grid.Item text="患者管理" onClick={() => navigateToPage('/clinic/clinicPatientUser/index')}>
|
||||||
|
<View className="text-center">
|
||||||
|
<View className="w-12 h-12 bg-blue-50 rounded-xl flex items-center justify-center mx-auto mb-2">
|
||||||
|
<PickedUp color="#3b82f6" size="20"/>
|
||||||
|
</View>
|
||||||
|
</View>
|
||||||
|
</Grid.Item>
|
||||||
|
|
||||||
|
<Grid.Item text={'在线开方'} onClick={() => navigateToPage('/doctor/orders/add')}>
|
||||||
|
<View className="text-center">
|
||||||
|
<View className="w-12 h-12 bg-green-50 rounded-xl flex items-center justify-center mx-auto mb-2">
|
||||||
|
<Edit color="#10b981" size="20"/>
|
||||||
|
</View>
|
||||||
|
</View>
|
||||||
|
</Grid.Item>
|
||||||
|
|
||||||
|
<Grid.Item text={'咨询管理'} onClick={() => navigateToPage('/doctor/team/index')}>
|
||||||
|
<View className="text-center">
|
||||||
|
<View className="w-12 h-12 bg-purple-50 rounded-xl flex items-center justify-center mx-auto mb-2">
|
||||||
|
<Comment color="#8b5cf6" size="20"/>
|
||||||
|
</View>
|
||||||
|
</View>
|
||||||
|
</Grid.Item>
|
||||||
|
|
||||||
|
<Grid.Item text={'处方管理'} onClick={() => navigateToPage('/doctor/orders/index')}>
|
||||||
|
<View className="text-center">
|
||||||
|
<View className="w-12 h-12 bg-orange-50 rounded-xl flex items-center justify-center mx-auto mb-2">
|
||||||
|
<Orderlist color="#f59e0b" size="20"/>
|
||||||
|
</View>
|
||||||
|
</View>
|
||||||
|
</Grid.Item>
|
||||||
|
|
||||||
|
<Grid.Item text={'复诊提醒'}>
|
||||||
|
<View className="text-center">
|
||||||
|
<View className="w-12 h-12 bg-gray-50 rounded-xl flex items-center justify-center mx-auto mb-2">
|
||||||
|
<Notice size="20"/>
|
||||||
|
</View>
|
||||||
|
</View>
|
||||||
|
</Grid.Item>
|
||||||
|
|
||||||
|
<Grid.Item text={'我的邀请'} onClick={() => navigateToPage('/doctor/team/index')}>
|
||||||
|
<View className="text-center">
|
||||||
|
<View className="w-12 h-12 bg-gray-50 rounded-xl flex items-center justify-center mx-auto mb-2">
|
||||||
|
<UserAdd size="20"/>
|
||||||
|
</View>
|
||||||
|
</View>
|
||||||
|
</Grid.Item>
|
||||||
|
|
||||||
|
<Grid.Item text={'我的邀请码'} onClick={() => navigateToPage('/doctor/qrcode/index')}>
|
||||||
|
<View className="text-center">
|
||||||
|
<View className="w-12 h-12 bg-gray-50 rounded-xl flex items-center justify-center mx-auto mb-2">
|
||||||
|
<QrCode size="20"/>
|
||||||
|
</View>
|
||||||
|
</View>
|
||||||
|
</Grid.Item>
|
||||||
|
|
||||||
|
<Grid.Item text={'医生认证'} onClick={() => navigateToPage('/doctor/apply/add')}>
|
||||||
|
<View className="text-center">
|
||||||
|
<View className="w-12 h-12 bg-gray-50 rounded-xl flex items-center justify-center mx-auto mb-2">
|
||||||
|
<Health size="20"/>
|
||||||
|
</View>
|
||||||
|
</View>
|
||||||
|
</Grid.Item>
|
||||||
|
|
||||||
|
</Grid>
|
||||||
|
|
||||||
|
{/* 第二行功能 */}
|
||||||
|
{/*<Grid*/}
|
||||||
|
{/* columns={4}*/}
|
||||||
|
{/* className="no-border-grid mt-4"*/}
|
||||||
|
{/* style={{*/}
|
||||||
|
{/* '--nutui-grid-border-color': 'transparent',*/}
|
||||||
|
{/* '--nutui-grid-item-border-width': '0px',*/}
|
||||||
|
{/* border: 'none'*/}
|
||||||
|
{/* } as React.CSSProperties}*/}
|
||||||
|
{/*>*/}
|
||||||
|
{/* <Grid.Item text={'邀请统计'} onClick={() => navigateToPage('/doctor/invite-stats/index')}>*/}
|
||||||
|
{/* <View className="text-center">*/}
|
||||||
|
{/* <View className="w-12 h-12 bg-indigo-50 rounded-xl flex items-center justify-center mx-auto mb-2">*/}
|
||||||
|
{/* <Presentation color="#6366f1" size="20"/>*/}
|
||||||
|
{/* </View>*/}
|
||||||
|
{/* </View>*/}
|
||||||
|
{/* </Grid.Item>*/}
|
||||||
|
|
||||||
|
{/* /!* 预留其他功能位置 *!/*/}
|
||||||
|
{/* <Grid.Item text={''}>*/}
|
||||||
|
{/* <View className="text-center">*/}
|
||||||
|
{/* <View className="w-12 h-12 bg-gray-50 rounded-xl flex items-center justify-center mx-auto mb-2">*/}
|
||||||
|
{/* </View>*/}
|
||||||
|
{/* </View>*/}
|
||||||
|
{/* </Grid.Item>*/}
|
||||||
|
|
||||||
|
{/* <Grid.Item text={''}>*/}
|
||||||
|
{/* <View className="text-center">*/}
|
||||||
|
{/* <View className="w-12 h-12 bg-gray-50 rounded-xl flex items-center justify-center mx-auto mb-2">*/}
|
||||||
|
{/* </View>*/}
|
||||||
|
{/* </View>*/}
|
||||||
|
{/* </Grid.Item>*/}
|
||||||
|
|
||||||
|
{/* <Grid.Item text={''}>*/}
|
||||||
|
{/* <View className="text-center">*/}
|
||||||
|
{/* <View className="w-12 h-12 bg-gray-50 rounded-xl flex items-center justify-center mx-auto mb-2">*/}
|
||||||
|
{/* </View>*/}
|
||||||
|
{/* </View>*/}
|
||||||
|
{/* </Grid.Item>*/}
|
||||||
|
{/*</Grid>*/}
|
||||||
|
</ConfigProvider>
|
||||||
|
</View>
|
||||||
|
</View>
|
||||||
|
|
||||||
|
{/* 底部安全区域 */}
|
||||||
|
<View className="h-20"></View>
|
||||||
|
</View>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
export default DealerIndex
|
||||||
@@ -405,7 +405,7 @@ const DealerTeam: React.FC = () => {
|
|||||||
if (!dealerUser) {
|
if (!dealerUser) {
|
||||||
return (
|
return (
|
||||||
<Space className="flex items-center justify-center">
|
<Space className="flex items-center justify-center">
|
||||||
<Empty description="您还不是业务人员" style={{
|
<Empty description="您还不是医生" style={{
|
||||||
backgroundColor: 'transparent'
|
backgroundColor: 'transparent'
|
||||||
}} actions={[{text: '立即申请', onClick: () => navTo(`/dealer/apply/add`, true)}]}
|
}} actions={[{text: '立即申请', onClick: () => navTo(`/dealer/apply/add`, true)}]}
|
||||||
/>
|
/>
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
export default definePageConfig({
|
export default definePageConfig({
|
||||||
navigationBarTitleText: '患者报备',
|
navigationBarTitleText: '添加患者',
|
||||||
navigationBarTextStyle: 'black'
|
navigationBarTextStyle: 'black'
|
||||||
})
|
})
|
||||||
@@ -1,78 +1,47 @@
|
|||||||
import {useEffect, useState, useRef} from "react";
|
import {useEffect, useState, useRef} from "react";
|
||||||
import {Loading, CellGroup, Cell, Input, Form, Calendar} from '@nutui/nutui-react-taro'
|
import {Loading, CellGroup, Input, Form, Calendar} from '@nutui/nutui-react-taro'
|
||||||
import {Edit, Calendar as CalendarIcon} from '@nutui/icons-react-taro'
|
import {Edit, Calendar as CalendarIcon} from '@nutui/icons-react-taro'
|
||||||
import Taro from '@tarojs/taro'
|
import Taro from '@tarojs/taro'
|
||||||
import {useRouter} from '@tarojs/taro'
|
import {useRouter} from '@tarojs/taro'
|
||||||
import {View, Text} from '@tarojs/components'
|
import {View, Text} from '@tarojs/components'
|
||||||
import FixedButton from "@/components/FixedButton";
|
import FixedButton from "@/components/FixedButton";
|
||||||
import {useUser} from "@/hooks/useUser";
|
import {useUser} from "@/hooks/useUser";
|
||||||
import {ShopDealerApply} from "@/api/shop/shopDealerApply/model";
|
import {ClinicPatientUser} from "@/api/clinic/clinicPatientUser/model";
|
||||||
import {
|
import {
|
||||||
addShopDealerApply, getShopDealerApply, pageShopDealerApply,
|
addClinicPatientUser,
|
||||||
updateShopDealerApply
|
getClinicPatientUser,
|
||||||
} from "@/api/shop/shopDealerApply";
|
updateClinicPatientUser
|
||||||
|
} from "@/api/clinic/clinicPatientUser";
|
||||||
import {
|
import {
|
||||||
formatDateForDatabase,
|
formatDateForDatabase,
|
||||||
extractDateForCalendar, formatDateForDisplay
|
extractDateForCalendar, formatDateForDisplay
|
||||||
} from "@/utils/dateUtils";
|
} from "@/utils/dateUtils";
|
||||||
|
|
||||||
const AddShopDealerApply = () => {
|
const AddPatient = () => {
|
||||||
const {user} = useUser()
|
const {user} = useUser()
|
||||||
const {params} = useRouter();
|
const {params} = useRouter();
|
||||||
const [loading, setLoading] = useState<boolean>(true)
|
const [loading, setLoading] = useState<boolean>(true)
|
||||||
const [FormData, setFormData] = useState<ShopDealerApply>()
|
const [formData, setFormData] = useState<ClinicPatientUser>()
|
||||||
const formRef = useRef<any>(null)
|
const formRef = useRef<any>(null)
|
||||||
const [isEditMode, setIsEditMode] = useState<boolean>(false)
|
const [isEditMode, setIsEditMode] = useState<boolean>(false)
|
||||||
const [existingApply, setExistingApply] = useState<ShopDealerApply | null>(null)
|
|
||||||
|
|
||||||
// 日期选择器状态
|
// 日期选择器状态
|
||||||
const [showApplyTimePicker, setShowApplyTimePicker] = useState<boolean>(false)
|
const [showCreateTimePicker, setShowCreateTimePicker] = useState<boolean>(false)
|
||||||
const [showContractTimePicker, setShowContractTimePicker] = useState<boolean>(false)
|
const [createTime, setCreateTime] = useState<string>('')
|
||||||
const [applyTime, setApplyTime] = useState<string>('')
|
|
||||||
const [contractTime, setContractTime] = useState<string>('')
|
|
||||||
|
|
||||||
// 获取审核状态文字
|
console.log('AddPatient Component Rendered');
|
||||||
const getApplyStatusText = (status?: number) => {
|
|
||||||
switch (status) {
|
|
||||||
case 10:
|
|
||||||
return '待审核'
|
|
||||||
case 20:
|
|
||||||
return '已签约'
|
|
||||||
case 30:
|
|
||||||
return '已取消'
|
|
||||||
default:
|
|
||||||
return '未知状态'
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
console.log(getApplyStatusText)
|
// 处理创建时间选择
|
||||||
|
const handleCreateTimeConfirm = (param: string) => {
|
||||||
// 处理签约时间选择
|
|
||||||
const handleApplyTimeConfirm = (param: string) => {
|
|
||||||
const selectedDate = param[3] // 选中的日期字符串 (YYYY-M-D)
|
const selectedDate = param[3] // 选中的日期字符串 (YYYY-M-D)
|
||||||
const formattedDate = formatDateForDatabase(selectedDate) // 转换为数据库格式
|
const formattedDate = formatDateForDatabase(selectedDate) // 转换为数据库格式
|
||||||
setApplyTime(selectedDate) // 保存原始格式用于显示
|
setCreateTime(selectedDate) // 保存原始格式用于显示
|
||||||
setShowApplyTimePicker(false)
|
setShowCreateTimePicker(false)
|
||||||
|
|
||||||
// 更新表单数据(使用数据库格式)
|
// 更新表单数据(使用数据库格式)
|
||||||
if (formRef.current) {
|
if (formRef.current) {
|
||||||
formRef.current.setFieldsValue({
|
formRef.current.setFieldsValue({
|
||||||
applyTime: formattedDate
|
createTime: formattedDate
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// 处理合同日期选择
|
|
||||||
const handleContractTimeConfirm = (param: string) => {
|
|
||||||
const selectedDate = param[3] // 选中的日期字符串 (YYYY-M-D)
|
|
||||||
const formattedDate = formatDateForDatabase(selectedDate) // 转换为数据库格式
|
|
||||||
setContractTime(selectedDate) // 保存原始格式用于显示
|
|
||||||
setShowContractTimePicker(false)
|
|
||||||
|
|
||||||
// 更新表单数据(使用数据库格式)
|
|
||||||
if (formRef.current) {
|
|
||||||
formRef.current.setFieldsValue({
|
|
||||||
contractTime: formattedDate
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -81,54 +50,32 @@ const AddShopDealerApply = () => {
|
|||||||
if (!params.id) {
|
if (!params.id) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
// 查询当前用户ID是否已有申请记录
|
// 查询患者信息
|
||||||
try {
|
try {
|
||||||
const dealerApply = await getShopDealerApply(Number(params.id));
|
const patient = await getClinicPatientUser(Number(params.id));
|
||||||
if (dealerApply) {
|
if (patient) {
|
||||||
setFormData(dealerApply)
|
setFormData(patient)
|
||||||
setIsEditMode(true);
|
setIsEditMode(true);
|
||||||
setExistingApply(dealerApply)
|
|
||||||
|
|
||||||
// 初始化日期数据(从数据库格式转换为Calendar组件格式)
|
// 初始化日期数据(从数据库格式转换为Calendar组件格式)
|
||||||
if (dealerApply.applyTime) {
|
if (patient.createTime) {
|
||||||
setApplyTime(extractDateForCalendar(dealerApply.applyTime))
|
setCreateTime(extractDateForCalendar(patient.createTime))
|
||||||
}
|
|
||||||
if (dealerApply.contractTime) {
|
|
||||||
setContractTime(extractDateForCalendar(dealerApply.contractTime))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Taro.setNavigationBarTitle({title: '签约'})
|
Taro.setNavigationBarTitle({title: '编辑患者'})
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
setLoading(true)
|
setLoading(true)
|
||||||
console.error('查询申请记录失败:', error);
|
console.error('查询患者信息失败:', error);
|
||||||
setIsEditMode(false);
|
setIsEditMode(false);
|
||||||
setExistingApply(null);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 提交表单
|
// 提交表单
|
||||||
// 计算保护期过期时间(7天后)
|
|
||||||
const calculateExpirationTime = (): string => {
|
|
||||||
const now = new Date();
|
|
||||||
const expirationDate = new Date(now);
|
|
||||||
expirationDate.setDate(now.getDate() + 7); // 7天后
|
|
||||||
|
|
||||||
// 格式化为数据库需要的格式:YYYY-MM-DD HH:mm:ss
|
|
||||||
const year = expirationDate.getFullYear();
|
|
||||||
const month = String(expirationDate.getMonth() + 1).padStart(2, '0');
|
|
||||||
const day = String(expirationDate.getDate()).padStart(2, '0');
|
|
||||||
const hours = String(expirationDate.getHours()).padStart(2, '0');
|
|
||||||
const minutes = String(expirationDate.getMinutes()).padStart(2, '0');
|
|
||||||
const seconds = String(expirationDate.getSeconds()).padStart(2, '0');
|
|
||||||
|
|
||||||
return `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`;
|
|
||||||
};
|
|
||||||
|
|
||||||
const submitSucceed = async (values: any) => {
|
const submitSucceed = async (values: any) => {
|
||||||
try {
|
try {
|
||||||
// 验证必填字段
|
// 验证必填字段
|
||||||
if (!values.mobile || values.mobile.trim() === '') {
|
if (!values.phone || values.phone.trim() === '') {
|
||||||
Taro.showToast({
|
Taro.showToast({
|
||||||
title: '请填写联系方式',
|
title: '请填写联系方式',
|
||||||
icon: 'error'
|
icon: 'error'
|
||||||
@@ -138,7 +85,7 @@ const AddShopDealerApply = () => {
|
|||||||
|
|
||||||
// 验证手机号格式
|
// 验证手机号格式
|
||||||
const phoneRegex = /^1[3-9]\d{9}$/;
|
const phoneRegex = /^1[3-9]\d{9}$/;
|
||||||
if (!phoneRegex.test(values.mobile)) {
|
if (!phoneRegex.test(values.phone)) {
|
||||||
Taro.showToast({
|
Taro.showToast({
|
||||||
title: '请填写正确的手机号',
|
title: '请填写正确的手机号',
|
||||||
icon: 'error'
|
icon: 'error'
|
||||||
@@ -146,96 +93,35 @@ const AddShopDealerApply = () => {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 检查客户是否已存在
|
|
||||||
const res = await pageShopDealerApply({dealerName: values.dealerName, type: 4, applyStatus: 10});
|
|
||||||
|
|
||||||
if (res && res.count > 0) {
|
|
||||||
const existingCustomer = res.list[0];
|
|
||||||
|
|
||||||
// 检查是否在7天保护期内
|
|
||||||
if (!isEditMode && existingCustomer.applyTime) {
|
|
||||||
// 将申请时间字符串转换为时间戳进行比较
|
|
||||||
const applyTimeStamp = new Date(existingCustomer.applyTime).getTime();
|
|
||||||
const currentTimeStamp = new Date().getTime();
|
|
||||||
const sevenDaysInMs = 7 * 24 * 60 * 60 * 1000; // 7天的毫秒数
|
|
||||||
|
|
||||||
// 如果在7天保护期内,不允许重复添加
|
|
||||||
if (currentTimeStamp - applyTimeStamp < sevenDaysInMs) {
|
|
||||||
const remainingDays = Math.ceil((sevenDaysInMs - (currentTimeStamp - applyTimeStamp)) / (24 * 60 * 60 * 1000));
|
|
||||||
|
|
||||||
Taro.showToast({
|
|
||||||
title: `该客户还在保护期,还需等待${remainingDays}天后才能重新添加`,
|
|
||||||
icon: 'none',
|
|
||||||
duration: 3000
|
|
||||||
});
|
|
||||||
return false;
|
|
||||||
} else {
|
|
||||||
// 超过7天保护期,可以重新添加,显示确认对话框
|
|
||||||
const modalResult = await new Promise<boolean>((resolve) => {
|
|
||||||
Taro.showModal({
|
|
||||||
title: '提示',
|
|
||||||
content: '该客户已超过7天保护期,是否重新添加跟进?',
|
|
||||||
showCancel: true,
|
|
||||||
cancelText: '取消',
|
|
||||||
confirmText: '确定',
|
|
||||||
success: (modalRes) => {
|
|
||||||
resolve(modalRes.confirm);
|
|
||||||
},
|
|
||||||
fail: () => {
|
|
||||||
resolve(false);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
if (!modalResult) {
|
|
||||||
return false; // 用户取消,不继续执行
|
|
||||||
}
|
|
||||||
// 用户确认后继续执行添加逻辑
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// 计算过期时间
|
|
||||||
const expirationTime = isEditMode ? existingApply?.expirationTime : calculateExpirationTime();
|
|
||||||
|
|
||||||
// 准备提交的数据
|
// 准备提交的数据
|
||||||
const submitData = {
|
const submitData: ClinicPatientUser = {
|
||||||
...values,
|
...values,
|
||||||
type: 4,
|
|
||||||
realName: values.realName || user?.nickname,
|
realName: values.realName || user?.nickname,
|
||||||
mobile: values.mobile,
|
phone: values.phone,
|
||||||
refereeId: 33534,
|
|
||||||
applyStatus: isEditMode ? 20 : 10,
|
|
||||||
auditTime: undefined,
|
|
||||||
// 设置保护期过期时间(7天后)
|
|
||||||
expirationTime: expirationTime,
|
|
||||||
// 确保日期数据正确提交(使用数据库格式)
|
// 确保日期数据正确提交(使用数据库格式)
|
||||||
applyTime: values.applyTime || (applyTime ? formatDateForDatabase(applyTime) : ''),
|
createTime: values.createTime || (createTime ? formatDateForDatabase(createTime) : new Date().toISOString().slice(0, 19).replace('T', ' '))
|
||||||
contractTime: values.contractTime || (contractTime ? formatDateForDatabase(contractTime) : '')
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// 调试信息
|
// 调试信息
|
||||||
console.log('=== 提交数据调试 ===');
|
console.log('=== 提交数据调试 ===');
|
||||||
console.log('是否编辑模式:', isEditMode);
|
console.log('是否编辑模式:', isEditMode);
|
||||||
console.log('计算的过期时间:', expirationTime);
|
|
||||||
console.log('提交的数据:', submitData);
|
console.log('提交的数据:', submitData);
|
||||||
console.log('==================');
|
console.log('==================');
|
||||||
|
|
||||||
// 如果是编辑模式,添加现有申请的id
|
// 如果是编辑模式,添加现有患者的id
|
||||||
if (isEditMode && existingApply?.applyId) {
|
if (isEditMode && formData?.id) {
|
||||||
submitData.applyId = existingApply.applyId;
|
submitData.id = formData.id;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 执行新增或更新操作
|
// 执行新增或更新操作
|
||||||
if (isEditMode) {
|
if (isEditMode) {
|
||||||
await updateShopDealerApply(submitData);
|
await updateClinicPatientUser(submitData);
|
||||||
} else {
|
} else {
|
||||||
await addShopDealerApply(submitData);
|
await addClinicPatientUser(submitData);
|
||||||
}
|
}
|
||||||
|
|
||||||
Taro.showToast({
|
Taro.showToast({
|
||||||
title: `${isEditMode ? '更新' : '提交'}成功`,
|
title: `${isEditMode ? '更新' : '添加'}成功`,
|
||||||
icon: 'success'
|
icon: 'success'
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -277,124 +163,55 @@ const AddShopDealerApply = () => {
|
|||||||
<Form
|
<Form
|
||||||
ref={formRef}
|
ref={formRef}
|
||||||
divider
|
divider
|
||||||
initialValues={FormData}
|
initialValues={formData}
|
||||||
labelPosition="left"
|
labelPosition="left"
|
||||||
onFinish={(values) => submitSucceed(values)}
|
onFinish={(values) => submitSucceed(values)}
|
||||||
onFinishFailed={(errors) => submitFailed(errors)}
|
onFinishFailed={(errors) => submitFailed(errors)}
|
||||||
>
|
>
|
||||||
<View className={'bg-gray-100 h-3'}></View>
|
<View className={'bg-gray-100 h-3'}></View>
|
||||||
<CellGroup style={{padding: '4px 0'}}>
|
<CellGroup style={{padding: '4px 0'}}>
|
||||||
<Form.Item name="dealerName" label="公司名称" initialValue={FormData?.dealerName} required>
|
<Form.Item name="realName" label="姓名" initialValue={formData?.realName} required>
|
||||||
<Input placeholder="公司名称" maxLength={10} disabled={isEditMode}/>
|
<Input placeholder="请输入患者姓名" />
|
||||||
</Form.Item>
|
</Form.Item>
|
||||||
<Form.Item name="realName" label="联系人" initialValue={FormData?.realName} required>
|
<Form.Item name="phone" label="联系方式" initialValue={formData?.phone} required>
|
||||||
<Input placeholder="请输入联系人" disabled={isEditMode}/>
|
<Input placeholder="请输入手机号" maxLength={11}/>
|
||||||
</Form.Item>
|
</Form.Item>
|
||||||
<Form.Item name="mobile" label="联系方式" initialValue={FormData?.mobile} required>
|
<Form.Item name="comments" label="备注" initialValue={formData?.comments}>
|
||||||
<Input placeholder="请输入手机号" disabled={isEditMode} maxLength={11}/>
|
<Input placeholder="请填写备注信息" />
|
||||||
</Form.Item>
|
</Form.Item>
|
||||||
<Form.Item name="address" label="公司地址" initialValue={FormData?.address} required>
|
<Form.Item name="createTime" label="创建时间" initialValue={formData?.createTime}>
|
||||||
<Input placeholder="请输入详细地址" disabled={isEditMode}/>
|
|
||||||
</Form.Item>
|
|
||||||
<Form.Item name="dealerCode" label="户号" initialValue={FormData?.dealerCode} required>
|
|
||||||
<Input placeholder="请填写户号" disabled={isEditMode}/>
|
|
||||||
</Form.Item>
|
|
||||||
<Form.Item name="comments" label="跟进情况" initialValue={FormData?.comments}>
|
|
||||||
<Input placeholder="请填写跟进情况" disabled={isEditMode}/>
|
|
||||||
</Form.Item>
|
|
||||||
{isEditMode && (
|
|
||||||
<>
|
|
||||||
<Form.Item name="money" label="签约价格" initialValue={FormData?.money} required>
|
|
||||||
<Input placeholder="(元/兆瓦时)" disabled={false}/>
|
|
||||||
</Form.Item>
|
|
||||||
<Form.Item name="applyTime" label="签约时间" initialValue={FormData?.applyTime}>
|
|
||||||
<View
|
<View
|
||||||
className="flex items-center justify-between py-2"
|
className="flex items-center justify-between py-2"
|
||||||
onClick={() => setShowApplyTimePicker(true)}
|
onClick={() => setShowCreateTimePicker(true)}
|
||||||
>
|
>
|
||||||
<View className="flex items-center">
|
<View className="flex items-center">
|
||||||
<CalendarIcon size={16} color="#999" className="mr-2"/>
|
<CalendarIcon size={16} color="#999" className="mr-2"/>
|
||||||
<Text style={{color: applyTime ? '#333' : '#999'}}>
|
<Text style={{color: createTime ? '#333' : '#999'}}>
|
||||||
{applyTime ? formatDateForDisplay(applyTime) : '请选择签约时间'}
|
{createTime ? formatDateForDisplay(createTime) : '请选择创建时间'}
|
||||||
</Text>
|
</Text>
|
||||||
</View>
|
</View>
|
||||||
</View>
|
</View>
|
||||||
</Form.Item>
|
</Form.Item>
|
||||||
<Form.Item name="contractTime" label="合同日期" initialValue={FormData?.contractTime}>
|
|
||||||
<View
|
|
||||||
className="flex items-center justify-between py-2"
|
|
||||||
onClick={() => setShowContractTimePicker(true)}
|
|
||||||
>
|
|
||||||
<View className="flex items-center">
|
|
||||||
<CalendarIcon size={16} color="#999" className="mr-2"/>
|
|
||||||
<Text style={{color: contractTime ? '#333' : '#999'}}>
|
|
||||||
{contractTime ? formatDateForDisplay(contractTime) : '请选择合同生效起止时间'}
|
|
||||||
</Text>
|
|
||||||
</View>
|
|
||||||
</View>
|
|
||||||
</Form.Item>
|
|
||||||
{/*<Form.Item name="refereeId" label="邀请人ID" initialValue={FormData?.refereeId} required>*/}
|
|
||||||
{/* <Input placeholder="邀请人ID"/>*/}
|
|
||||||
{/*</Form.Item>*/}
|
|
||||||
</>
|
|
||||||
)}
|
|
||||||
<Form.Item name="userId" label="报备人" initialValue={FormData?.userId} required>
|
|
||||||
选择
|
|
||||||
</Form.Item>
|
|
||||||
</CellGroup>
|
</CellGroup>
|
||||||
</Form>
|
</Form>
|
||||||
|
|
||||||
{/* 签约时间选择器 */}
|
{/* 创建时间选择器 */}
|
||||||
<Calendar
|
<Calendar
|
||||||
visible={showApplyTimePicker}
|
visible={showCreateTimePicker}
|
||||||
defaultValue={applyTime}
|
defaultValue={createTime}
|
||||||
onClose={() => setShowApplyTimePicker(false)}
|
onClose={() => setShowCreateTimePicker(false)}
|
||||||
onConfirm={handleApplyTimeConfirm}
|
onConfirm={handleCreateTimeConfirm}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
{/* 合同日期选择器 */}
|
|
||||||
<Calendar
|
|
||||||
visible={showContractTimePicker}
|
|
||||||
defaultValue={contractTime}
|
|
||||||
onClose={() => setShowContractTimePicker(false)}
|
|
||||||
onConfirm={handleContractTimeConfirm}
|
|
||||||
/>
|
|
||||||
|
|
||||||
{/* 审核状态显示(仅在编辑模式下显示) */}
|
|
||||||
{isEditMode && (
|
|
||||||
<CellGroup>
|
|
||||||
{/*<Cell*/}
|
|
||||||
{/* title={'审核状态'}*/}
|
|
||||||
{/* extra={*/}
|
|
||||||
{/* <span style={{*/}
|
|
||||||
{/* color: FormData?.applyStatus === 20 ? '#52c41a' :*/}
|
|
||||||
{/* FormData?.applyStatus === 30 ? '#ff4d4f' : '#faad14'*/}
|
|
||||||
{/* }}>*/}
|
|
||||||
{/* {getApplyStatusText(FormData?.applyStatus)}*/}
|
|
||||||
{/* </span>*/}
|
|
||||||
{/* }*/}
|
|
||||||
{/*/>*/}
|
|
||||||
{FormData?.applyStatus === 20 && (
|
|
||||||
<Cell title={'签约时间'} extra={FormData?.auditTime || '无'}/>
|
|
||||||
)}
|
|
||||||
{FormData?.applyStatus === 30 && (
|
|
||||||
<Cell title={'驳回原因'} extra={FormData?.rejectReason || '无'}/>
|
|
||||||
)}
|
|
||||||
</CellGroup>
|
|
||||||
)}
|
|
||||||
|
|
||||||
|
|
||||||
{/* 底部浮动按钮 */}
|
{/* 底部浮动按钮 */}
|
||||||
{(!isEditMode || FormData?.applyStatus === 10) && (
|
|
||||||
<FixedButton
|
<FixedButton
|
||||||
icon={<Edit/>}
|
icon={<Edit/>}
|
||||||
text={'立即提交'}
|
text={isEditMode ? '更新患者' : '添加患者'}
|
||||||
onClick={handleFixedButtonClick}
|
onClick={handleFixedButtonClick}
|
||||||
/>
|
/>
|
||||||
)}
|
|
||||||
|
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
export default AddShopDealerApply;
|
export default AddPatient;
|
||||||
|
|||||||
4
src/doctor/customer/addPatient.config.ts
Normal file
4
src/doctor/customer/addPatient.config.ts
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
export default definePageConfig({
|
||||||
|
navigationBarTitleText: '添加患者',
|
||||||
|
navigationBarTextStyle: 'black'
|
||||||
|
})
|
||||||
217
src/doctor/customer/addPatient.tsx
Normal file
217
src/doctor/customer/addPatient.tsx
Normal file
@@ -0,0 +1,217 @@
|
|||||||
|
import {useEffect, useState, useRef} from "react";
|
||||||
|
import {Loading, CellGroup, Cell, Input, Form, Calendar} from '@nutui/nutui-react-taro'
|
||||||
|
import {Edit, Calendar as CalendarIcon} from '@nutui/icons-react-taro'
|
||||||
|
import Taro from '@tarojs/taro'
|
||||||
|
import {useRouter} from '@tarojs/taro'
|
||||||
|
import {View, Text} from '@tarojs/components'
|
||||||
|
import FixedButton from "@/components/FixedButton";
|
||||||
|
import {useUser} from "@/hooks/useUser";
|
||||||
|
import {ClinicPatientUser} from "@/api/clinic/clinicPatientUser/model";
|
||||||
|
import {
|
||||||
|
addClinicPatientUser,
|
||||||
|
getClinicPatientUser,
|
||||||
|
updateClinicPatientUser
|
||||||
|
} from "@/api/clinic/clinicPatientUser";
|
||||||
|
import {
|
||||||
|
formatDateForDatabase,
|
||||||
|
extractDateForCalendar, formatDateForDisplay
|
||||||
|
} from "@/utils/dateUtils";
|
||||||
|
|
||||||
|
const AddPatient = () => {
|
||||||
|
const {user} = useUser()
|
||||||
|
const {params} = useRouter();
|
||||||
|
const [loading, setLoading] = useState<boolean>(true)
|
||||||
|
const [formData, setFormData] = useState<ClinicPatientUser>()
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
// 查询患者信息
|
||||||
|
try {
|
||||||
|
const patient = await getClinicPatientUser(Number(params.id));
|
||||||
|
if (patient) {
|
||||||
|
setFormData(patient)
|
||||||
|
setIsEditMode(true);
|
||||||
|
|
||||||
|
// 初始化日期数据(从数据库格式转换为Calendar组件格式)
|
||||||
|
if (patient.createTime) {
|
||||||
|
setCreateTime(extractDateForCalendar(patient.createTime))
|
||||||
|
}
|
||||||
|
|
||||||
|
Taro.setNavigationBarTitle({title: '编辑患者'})
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
setLoading(true)
|
||||||
|
console.error('查询患者信息失败:', error);
|
||||||
|
setIsEditMode(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 提交表单
|
||||||
|
const submitSucceed = async (values: any) => {
|
||||||
|
try {
|
||||||
|
// 验证必填字段
|
||||||
|
if (!values.mobile || values.mobile.trim() === '') {
|
||||||
|
Taro.showToast({
|
||||||
|
title: '请填写联系方式',
|
||||||
|
icon: 'error'
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 验证手机号格式
|
||||||
|
const phoneRegex = /^1[3-9]\d{9}$/;
|
||||||
|
if (!phoneRegex.test(values.mobile)) {
|
||||||
|
Taro.showToast({
|
||||||
|
title: '请填写正确的手机号',
|
||||||
|
icon: 'error'
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 准备提交的数据
|
||||||
|
const submitData: ClinicPatientUser = {
|
||||||
|
...values,
|
||||||
|
realName: values.realName || user?.nickname,
|
||||||
|
mobile: values.mobile,
|
||||||
|
// 确保日期数据正确提交(使用数据库格式)
|
||||||
|
createTime: values.createTime || (createTime ? formatDateForDatabase(createTime) : new Date().toISOString().slice(0, 19).replace('T', ' '))
|
||||||
|
};
|
||||||
|
|
||||||
|
// 调试信息
|
||||||
|
console.log('=== 提交数据调试 ===');
|
||||||
|
console.log('是否编辑模式:', isEditMode);
|
||||||
|
console.log('提交的数据:', submitData);
|
||||||
|
console.log('==================');
|
||||||
|
|
||||||
|
// 如果是编辑模式,添加现有患者的id
|
||||||
|
if (isEditMode && formData?.id) {
|
||||||
|
submitData.id = formData.id;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 执行新增或更新操作
|
||||||
|
if (isEditMode) {
|
||||||
|
await updateClinicPatientUser(submitData);
|
||||||
|
} else {
|
||||||
|
await addClinicPatientUser(submitData);
|
||||||
|
}
|
||||||
|
|
||||||
|
Taro.showToast({
|
||||||
|
title: `${isEditMode ? '更新' : '添加'}成功`,
|
||||||
|
icon: 'success'
|
||||||
|
});
|
||||||
|
|
||||||
|
setTimeout(() => {
|
||||||
|
Taro.navigateBack();
|
||||||
|
}, 1000);
|
||||||
|
|
||||||
|
} catch (error) {
|
||||||
|
console.error('提交失败:', error);
|
||||||
|
Taro.showToast({
|
||||||
|
title: '提交失败,请重试',
|
||||||
|
icon: 'error'
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 处理固定按钮点击事件
|
||||||
|
const handleFixedButtonClick = () => {
|
||||||
|
// 触发表单提交
|
||||||
|
formRef.current?.submit();
|
||||||
|
};
|
||||||
|
|
||||||
|
const submitFailed = (error: any) => {
|
||||||
|
console.log(error, 'err...')
|
||||||
|
}
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
reload().then(() => {
|
||||||
|
setLoading(false)
|
||||||
|
})
|
||||||
|
}, []); // 依赖用户ID,当用户变化时重新加载
|
||||||
|
|
||||||
|
if (loading) {
|
||||||
|
return <Loading className={'px-2'}>加载中</Loading>
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<Form
|
||||||
|
ref={formRef}
|
||||||
|
divider
|
||||||
|
initialValues={formData}
|
||||||
|
labelPosition="left"
|
||||||
|
onFinish={(values) => submitSucceed(values)}
|
||||||
|
onFinishFailed={(errors) => submitFailed(errors)}
|
||||||
|
>
|
||||||
|
<View className={'bg-gray-100 h-3'}></View>
|
||||||
|
<CellGroup style={{padding: '4px 0'}}>
|
||||||
|
<Form.Item name="realName" label="姓名" initialValue={formData?.realName} required>
|
||||||
|
<Input placeholder="请输入患者姓名" />
|
||||||
|
</Form.Item>
|
||||||
|
<Form.Item name="mobile" label="联系方式" initialValue={formData?.mobile} required>
|
||||||
|
<Input placeholder="请输入手机号" maxLength={11}/>
|
||||||
|
</Form.Item>
|
||||||
|
<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/>}
|
||||||
|
text={isEditMode ? '更新患者' : '添加患者'}
|
||||||
|
onClick={handleFixedButtonClick}
|
||||||
|
/>
|
||||||
|
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default AddPatient;
|
||||||
@@ -1,39 +1,29 @@
|
|||||||
import {useState, useEffect, useCallback} from 'react'
|
import {useState, useEffect, useCallback} from 'react'
|
||||||
import {View, Text} from '@tarojs/components'
|
import {View, Text} from '@tarojs/components'
|
||||||
import Taro, {useDidShow} from '@tarojs/taro'
|
import Taro, {useDidShow} from '@tarojs/taro'
|
||||||
import {Loading, InfiniteLoading, Empty, Space, Tabs, TabPane, Tag, Button, SearchBar} from '@nutui/nutui-react-taro'
|
import {Loading, InfiniteLoading, Empty, Space, Button, SearchBar} from '@nutui/nutui-react-taro'
|
||||||
import {Phone, AngleDoubleLeft} from '@nutui/icons-react-taro'
|
import {Phone} from '@nutui/icons-react-taro'
|
||||||
import type {ShopDealerApply, ShopDealerApply as UserType} from "@/api/shop/shopDealerApply/model";
|
import type {ClinicPatientUser as PatientUserType} from "@/api/clinic/clinicPatientUser/model";
|
||||||
import {
|
|
||||||
CustomerStatus,
|
|
||||||
getStatusText,
|
|
||||||
getStatusTagType,
|
|
||||||
getStatusOptions,
|
|
||||||
mapApplyStatusToCustomerStatus,
|
|
||||||
mapCustomerStatusToApplyStatus
|
|
||||||
} from '@/utils/customerStatus';
|
|
||||||
import FixedButton from "@/components/FixedButton";
|
import FixedButton from "@/components/FixedButton";
|
||||||
import navTo from "@/utils/common";
|
import navTo from "@/utils/common";
|
||||||
import {pageShopDealerApply, removeShopDealerApply, updateShopDealerApply} from "@/api/shop/shopDealerApply";
|
import {
|
||||||
|
pageClinicPatientUser,
|
||||||
|
removeClinicPatientUser,
|
||||||
|
updateClinicPatientUser
|
||||||
|
} from "@/api/clinic/clinicPatientUser";
|
||||||
|
|
||||||
// 扩展User类型,添加客户状态和保护天数
|
// 扩展患者类型
|
||||||
interface CustomerUser extends UserType {
|
interface PatientUser extends PatientUserType {
|
||||||
customerStatus?: CustomerStatus;
|
|
||||||
protectDays?: number; // 剩余保护天数
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const CustomerIndex = () => {
|
const PatientIndex = () => {
|
||||||
const [list, setList] = useState<CustomerUser[]>([])
|
const [list, setList] = useState<PatientUser[]>([])
|
||||||
const [loading, setLoading] = useState<boolean>(false)
|
const [loading, setLoading] = useState<boolean>(false)
|
||||||
const [activeTab, setActiveTab] = useState<CustomerStatus>('all')
|
|
||||||
const [searchValue, setSearchValue] = useState<string>('')
|
const [searchValue, setSearchValue] = useState<string>('')
|
||||||
const [displaySearchValue, setDisplaySearchValue] = useState<string>('')
|
const [displaySearchValue, setDisplaySearchValue] = useState<string>('')
|
||||||
const [page, setPage] = useState(1)
|
const [page, setPage] = useState(1)
|
||||||
const [hasMore, setHasMore] = useState(true)
|
const [hasMore, setHasMore] = useState(true)
|
||||||
|
|
||||||
// Tab配置
|
|
||||||
const tabList = getStatusOptions();
|
|
||||||
|
|
||||||
// 复制手机号
|
// 复制手机号
|
||||||
const copyPhone = (phone: string) => {
|
const copyPhone = (phone: string) => {
|
||||||
Taro.setClipboardData({
|
Taro.setClipboardData({
|
||||||
@@ -61,21 +51,21 @@ const CustomerIndex = () => {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
// 编辑跟进情况
|
// 编辑备注
|
||||||
const editComments = (customer: CustomerUser) => {
|
const editComments = (patient: PatientUser) => {
|
||||||
Taro.showModal({
|
Taro.showModal({
|
||||||
title: '编辑跟进情况',
|
title: '编辑备注',
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
editable: true,
|
editable: true,
|
||||||
placeholderText: '请输入跟进情况',
|
placeholderText: '请输入备注信息',
|
||||||
content: customer.comments || '',
|
content: patient.comments || '',
|
||||||
success: async (res) => {
|
success: async (res) => {
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
if (res.confirm && res.content !== undefined) {
|
if (res.confirm && res.content !== undefined) {
|
||||||
try {
|
try {
|
||||||
// 更新跟进情况
|
// 更新备注
|
||||||
await updateShopDealerApply({
|
await updateClinicPatientUser({
|
||||||
...customer,
|
...patient,
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
comments: res.content.trim()
|
comments: res.content.trim()
|
||||||
});
|
});
|
||||||
@@ -89,9 +79,9 @@ const CustomerIndex = () => {
|
|||||||
setList([]);
|
setList([]);
|
||||||
setPage(1);
|
setPage(1);
|
||||||
setHasMore(true);
|
setHasMore(true);
|
||||||
fetchCustomerData(activeTab, true);
|
fetchPatientData(true);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('更新跟进情况失败:', error);
|
console.error('更新备注失败:', error);
|
||||||
Taro.showToast({
|
Taro.showToast({
|
||||||
title: '更新失败,请重试',
|
title: '更新失败,请重试',
|
||||||
icon: 'error'
|
icon: 'error'
|
||||||
@@ -102,101 +92,30 @@ const CustomerIndex = () => {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
// 计算剩余保护天数(基于过期时间)
|
// 获取患者数据
|
||||||
const calculateProtectDays = (expirationTime?: string, applyTime?: string): number => {
|
const fetchPatientData = useCallback(async (resetPage = false, targetPage?: number) => {
|
||||||
try {
|
|
||||||
// 优先使用过期时间字段
|
|
||||||
if (expirationTime) {
|
|
||||||
const expDate = new Date(expirationTime.replace(' ', 'T'));
|
|
||||||
const now = new Date();
|
|
||||||
|
|
||||||
// 计算剩余毫秒数
|
|
||||||
const remainingMs = expDate.getTime() - now.getTime();
|
|
||||||
|
|
||||||
// 转换为天数,向上取整
|
|
||||||
const remainingDays = Math.ceil(remainingMs / (1000 * 60 * 60 * 24));
|
|
||||||
|
|
||||||
console.log('=== 基于过期时间计算 ===');
|
|
||||||
console.log('过期时间:', expirationTime);
|
|
||||||
console.log('当前时间:', now.toLocaleString());
|
|
||||||
console.log('剩余天数:', remainingDays);
|
|
||||||
console.log('======================');
|
|
||||||
|
|
||||||
return Math.max(0, remainingDays);
|
|
||||||
}
|
|
||||||
|
|
||||||
// 如果没有过期时间,回退到基于申请时间计算
|
|
||||||
if (!applyTime) return 0;
|
|
||||||
|
|
||||||
const protectionPeriod = 7; // 保护期7天
|
|
||||||
|
|
||||||
// 解析申请时间
|
|
||||||
let applyDate: Date;
|
|
||||||
if (applyTime.includes('T')) {
|
|
||||||
applyDate = new Date(applyTime);
|
|
||||||
} else {
|
|
||||||
applyDate = new Date(applyTime.replace(' ', 'T'));
|
|
||||||
}
|
|
||||||
|
|
||||||
// 获取当前时间
|
|
||||||
const now = new Date();
|
|
||||||
|
|
||||||
// 只比较日期部分,忽略时间
|
|
||||||
const applyDateOnly = new Date(applyDate.getFullYear(), applyDate.getMonth(), applyDate.getDate());
|
|
||||||
const currentDateOnly = new Date(now.getFullYear(), now.getMonth(), now.getDate());
|
|
||||||
|
|
||||||
// 计算已经过去的天数
|
|
||||||
const timeDiff = currentDateOnly.getTime() - applyDateOnly.getTime();
|
|
||||||
const daysPassed = Math.floor(timeDiff / (1000 * 60 * 60 * 24));
|
|
||||||
|
|
||||||
// 计算剩余保护天数
|
|
||||||
const remainingDays = protectionPeriod - daysPassed;
|
|
||||||
|
|
||||||
console.log('=== 基于申请时间计算 ===');
|
|
||||||
console.log('申请时间:', applyTime);
|
|
||||||
console.log('已过去天数:', daysPassed);
|
|
||||||
console.log('剩余保护天数:', remainingDays);
|
|
||||||
console.log('======================');
|
|
||||||
|
|
||||||
return Math.max(0, remainingDays);
|
|
||||||
} catch (error) {
|
|
||||||
console.error('日期计算错误:', error);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
// 获取客户数据
|
|
||||||
const fetchCustomerData = useCallback(async (statusFilter?: CustomerStatus, resetPage = false, targetPage?: number) => {
|
|
||||||
setLoading(true);
|
setLoading(true);
|
||||||
try {
|
try {
|
||||||
const currentPage = resetPage ? 1 : (targetPage || page);
|
const currentPage = resetPage ? 1 : (targetPage || page);
|
||||||
|
|
||||||
// 构建API参数,根据状态筛选
|
// 构建API参数
|
||||||
const params: any = {
|
const params: any = {
|
||||||
type: 4,
|
|
||||||
page: currentPage
|
page: currentPage
|
||||||
};
|
};
|
||||||
const applyStatus = mapCustomerStatusToApplyStatus(statusFilter || activeTab);
|
|
||||||
if (applyStatus !== undefined) {
|
// 添加搜索关键词
|
||||||
params.applyStatus = applyStatus;
|
if (displaySearchValue.trim()) {
|
||||||
|
params.keywords = displaySearchValue.trim();
|
||||||
}
|
}
|
||||||
|
|
||||||
const res = await pageShopDealerApply(params);
|
const res = await pageClinicPatientUser(params);
|
||||||
|
|
||||||
if (res?.list && res.list.length > 0) {
|
if (res?.list && res.list.length > 0) {
|
||||||
// 正确映射状态并计算保护天数
|
|
||||||
const mappedList = res.list.map(customer => ({
|
|
||||||
...customer,
|
|
||||||
customerStatus: mapApplyStatusToCustomerStatus(customer.applyStatus || 10),
|
|
||||||
protectDays: calculateProtectDays(customer.expirationTime, customer.applyTime || customer.createTime || '')
|
|
||||||
}));
|
|
||||||
|
|
||||||
// 如果是重置页面或第一页,直接设置新数据;否则追加数据
|
// 如果是重置页面或第一页,直接设置新数据;否则追加数据
|
||||||
if (resetPage || currentPage === 1) {
|
if (resetPage || currentPage === 1) {
|
||||||
setList(mappedList);
|
setList(res.list);
|
||||||
} else {
|
} else {
|
||||||
setList(prevList => prevList.concat(mappedList));
|
setList(prevList => prevList.concat(res.list));
|
||||||
}
|
}
|
||||||
|
|
||||||
// 正确判断是否还有更多数据
|
// 正确判断是否还有更多数据
|
||||||
@@ -211,7 +130,7 @@ const CustomerIndex = () => {
|
|||||||
|
|
||||||
setPage(currentPage);
|
setPage(currentPage);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('获取客户数据失败:', error);
|
console.error('获取患者数据失败:', error);
|
||||||
Taro.showToast({
|
Taro.showToast({
|
||||||
title: '加载失败,请重试',
|
title: '加载失败,请重试',
|
||||||
icon: 'none'
|
icon: 'none'
|
||||||
@@ -219,15 +138,14 @@ const CustomerIndex = () => {
|
|||||||
} finally {
|
} finally {
|
||||||
setLoading(false);
|
setLoading(false);
|
||||||
}
|
}
|
||||||
}, [activeTab, page]);
|
}, [page, displaySearchValue]);
|
||||||
|
|
||||||
const reloadMore = async () => {
|
const reloadMore = async () => {
|
||||||
if (loading || !hasMore) return; // 防止重复加载
|
if (loading || !hasMore) return; // 防止重复加载
|
||||||
const nextPage = page + 1;
|
const nextPage = page + 1;
|
||||||
await fetchCustomerData(activeTab, false, nextPage);
|
await fetchPatientData(false, nextPage);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// 防抖搜索功能
|
// 防抖搜索功能
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const timer = setTimeout(() => {
|
const timer = setTimeout(() => {
|
||||||
@@ -237,153 +155,66 @@ const CustomerIndex = () => {
|
|||||||
return () => clearTimeout(timer);
|
return () => clearTimeout(timer);
|
||||||
}, [searchValue]);
|
}, [searchValue]);
|
||||||
|
|
||||||
// 根据搜索条件筛选数据(状态筛选已在API层面处理)
|
// 删除患者
|
||||||
const getFilteredList = () => {
|
const handleDelete = (patient: PatientUser) => {
|
||||||
let filteredList = list;
|
removeClinicPatientUser(patient.id).then(() => {
|
||||||
|
|
||||||
// 按搜索关键词筛选
|
|
||||||
if (displaySearchValue.trim()) {
|
|
||||||
const keyword = displaySearchValue.trim().toLowerCase();
|
|
||||||
filteredList = filteredList.filter(customer =>
|
|
||||||
(customer.realName && customer.realName.toLowerCase().includes(keyword)) ||
|
|
||||||
(customer.dealerName && customer.dealerName.toLowerCase().includes(keyword)) ||
|
|
||||||
(customer.dealerCode && customer.dealerCode.toLowerCase().includes(keyword)) ||
|
|
||||||
(customer.mobile && customer.mobile.includes(keyword)) ||
|
|
||||||
(customer.userId && customer.userId.toString().includes(keyword))
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
return filteredList;
|
|
||||||
};
|
|
||||||
|
|
||||||
// 获取各状态的统计数量
|
|
||||||
const [statusCounts, setStatusCounts] = useState({
|
|
||||||
all: 0,
|
|
||||||
pending: 0,
|
|
||||||
signed: 0,
|
|
||||||
cancelled: 0
|
|
||||||
});
|
|
||||||
|
|
||||||
// 获取所有状态的统计数量
|
|
||||||
const fetchStatusCounts = useCallback(async () => {
|
|
||||||
try {
|
|
||||||
// 并行获取各状态的数量
|
|
||||||
const [allRes, pendingRes, signedRes, cancelledRes] = await Promise.all([
|
|
||||||
pageShopDealerApply({type: 4}), // 全部
|
|
||||||
pageShopDealerApply({applyStatus: 10, type: 4}), // 跟进中
|
|
||||||
pageShopDealerApply({applyStatus: 20, type: 4}), // 已签约
|
|
||||||
pageShopDealerApply({applyStatus: 30, type: 4}) // 已取消
|
|
||||||
]);
|
|
||||||
|
|
||||||
setStatusCounts({
|
|
||||||
all: allRes?.count || 0,
|
|
||||||
pending: pendingRes?.count || 0,
|
|
||||||
signed: signedRes?.count || 0,
|
|
||||||
cancelled: cancelledRes?.count || 0
|
|
||||||
});
|
|
||||||
} catch (error) {
|
|
||||||
console.error('获取状态统计失败:', error);
|
|
||||||
}
|
|
||||||
}, []);
|
|
||||||
|
|
||||||
const getStatusCounts = () => statusCounts;
|
|
||||||
|
|
||||||
// 取消操作
|
|
||||||
const handleCancel = (customer: ShopDealerApply) => {
|
|
||||||
updateShopDealerApply({
|
|
||||||
...customer,
|
|
||||||
applyStatus: 30
|
|
||||||
}).then(() => {
|
|
||||||
Taro.showToast({
|
|
||||||
title: '取消成功',
|
|
||||||
icon: 'success'
|
|
||||||
});
|
|
||||||
// 重新加载当前tab的数据
|
|
||||||
setList([]);
|
|
||||||
setPage(1);
|
|
||||||
setHasMore(true);
|
|
||||||
fetchCustomerData(activeTab, true).then();
|
|
||||||
fetchStatusCounts().then();
|
|
||||||
})
|
|
||||||
};
|
|
||||||
|
|
||||||
// 删除
|
|
||||||
const handleDelete = (customer: ShopDealerApply) => {
|
|
||||||
removeShopDealerApply(customer.applyId).then(() => {
|
|
||||||
Taro.showToast({
|
Taro.showToast({
|
||||||
title: '删除成功',
|
title: '删除成功',
|
||||||
icon: 'success'
|
icon: 'success'
|
||||||
});
|
});
|
||||||
// 刷新当前tab的数据
|
// 刷新数据
|
||||||
setList([]);
|
setList([]);
|
||||||
setPage(1);
|
setPage(1);
|
||||||
setHasMore(true);
|
setHasMore(true);
|
||||||
fetchCustomerData(activeTab, true).then();
|
fetchPatientData(true).then();
|
||||||
fetchStatusCounts().then();
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// 初始化数据
|
// 初始化数据
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
fetchCustomerData(activeTab, true).then();
|
fetchPatientData(true).then();
|
||||||
fetchStatusCounts().then();
|
}, [displaySearchValue]);
|
||||||
}, []);
|
|
||||||
|
|
||||||
// 当activeTab变化时重新获取数据
|
|
||||||
useEffect(() => {
|
|
||||||
setList([]); // 清空列表
|
|
||||||
setPage(1); // 重置页码
|
|
||||||
setHasMore(true); // 重置加载状态
|
|
||||||
fetchCustomerData(activeTab, true);
|
|
||||||
}, [activeTab]);
|
|
||||||
|
|
||||||
// 监听页面显示,当从其他页面返回时刷新数据
|
// 监听页面显示,当从其他页面返回时刷新数据
|
||||||
useDidShow(() => {
|
useDidShow(() => {
|
||||||
// 刷新当前tab的数据和统计信息
|
// 刷新数据
|
||||||
setList([]);
|
setList([]);
|
||||||
setPage(1);
|
setPage(1);
|
||||||
setHasMore(true);
|
setHasMore(true);
|
||||||
fetchCustomerData(activeTab, true);
|
fetchPatientData(true);
|
||||||
fetchStatusCounts();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
// 渲染客户项
|
// 渲染患者项
|
||||||
const renderCustomerItem = (customer: CustomerUser) => (
|
const renderPatientItem = (patient: PatientUser) => (
|
||||||
<View key={customer.userId} className="bg-white rounded-lg p-4 mb-3 shadow-sm">
|
<View key={patient.id} className="bg-white rounded-lg p-4 mb-3 shadow-sm">
|
||||||
<View className="flex items-center mb-3">
|
<View className="flex items-center mb-3">
|
||||||
<View className="flex-1">
|
<View className="flex-1">
|
||||||
<View className="flex items-center justify-between mb-1">
|
<View className="flex items-center justify-between mb-1">
|
||||||
<Text className="font-semibold text-gray-800 mr-2">
|
<Text className="font-semibold text-gray-800 mr-2">
|
||||||
{customer.dealerName}
|
{patient.realName || '未命名'}
|
||||||
</Text>
|
</Text>
|
||||||
{customer.customerStatus && (
|
|
||||||
<Tag type={getStatusTagType(customer.customerStatus)}>
|
|
||||||
{getStatusText(customer.customerStatus)}
|
|
||||||
</Tag>
|
|
||||||
)}
|
|
||||||
</View>
|
</View>
|
||||||
<View className="flex items-center mb-1">
|
<View className="flex items-center mb-1">
|
||||||
<Space direction="vertical">
|
<Space direction="vertical">
|
||||||
<Text className="text-xs text-gray-500">联系人:{customer.realName}</Text>
|
|
||||||
<View className="flex items-center">
|
<View className="flex items-center">
|
||||||
<Text className="text-xs text-gray-500" onClick={(e) => {
|
<Text className="text-xs text-gray-500" onClick={(e) => {
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
makePhoneCall(customer.mobile || '');
|
makePhoneCall(patient.phone || '');
|
||||||
}}>联系电话:{customer.mobile}</Text>
|
}}>联系电话:{patient.phone || '未提供'}</Text>
|
||||||
<View className="flex items-center ml-2">
|
<View className="flex items-center ml-2">
|
||||||
<Phone
|
<Phone
|
||||||
size={12}
|
size={12}
|
||||||
className="text-green-500 mr-2"
|
className="text-green-500 mr-2"
|
||||||
onClick={(e) => {
|
onClick={(e) => {
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
makePhoneCall(customer.mobile || '');
|
makePhoneCall(patient.phone || '');
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
<Text
|
<Text
|
||||||
className="text-xs text-blue-500 cursor-pointer"
|
className="text-xs text-blue-500 cursor-pointer"
|
||||||
onClick={(e) => {
|
onClick={(e) => {
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
copyPhone(customer.mobile || '');
|
copyPhone(patient.phone || '');
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
复制
|
复制
|
||||||
@@ -391,47 +222,19 @@ const CustomerIndex = () => {
|
|||||||
</View>
|
</View>
|
||||||
</View>
|
</View>
|
||||||
<Text className="text-xs text-gray-500">
|
<Text className="text-xs text-gray-500">
|
||||||
添加时间:{customer.createTime}
|
添加时间:{patient.createTime || '未知'}
|
||||||
</Text>
|
</Text>
|
||||||
</Space>
|
</Space>
|
||||||
</View>
|
</View>
|
||||||
|
|
||||||
{/* 保护天数显示 */}
|
|
||||||
{customer.applyStatus === 10 && (
|
|
||||||
<View className="flex items-center my-1">
|
|
||||||
<Text className="text-xs text-gray-500 mr-2">保护期:</Text>
|
|
||||||
{customer.protectDays && customer.protectDays > 0 ? (
|
|
||||||
<Text className={`text-xs px-2 py-1 rounded ${
|
|
||||||
customer.protectDays <= 2
|
|
||||||
? 'bg-red-100 text-red-600'
|
|
||||||
: customer.protectDays <= 4
|
|
||||||
? 'bg-orange-100 text-orange-600'
|
|
||||||
: 'bg-green-100 text-green-600'
|
|
||||||
}`}>
|
|
||||||
剩余{customer.protectDays}天
|
|
||||||
</Text>
|
|
||||||
) : (
|
|
||||||
<Text className="text-xs px-2 py-1 rounded bg-gray-100 text-gray-500">
|
|
||||||
已过期
|
|
||||||
</Text>
|
|
||||||
)}
|
|
||||||
</View>
|
|
||||||
)}
|
|
||||||
|
|
||||||
<View className={'flex items-center gap-2'}>
|
|
||||||
<Text className="text-xs text-gray-500">报备人:{customer?.nickName}</Text>
|
|
||||||
<AngleDoubleLeft size={12} className={'text-blue-500'} />
|
|
||||||
<Text className={'text-xs text-gray-500'}>{customer?.refereeName}</Text>
|
|
||||||
</View>
|
|
||||||
|
|
||||||
{/* 显示 comments 字段 */}
|
{/* 显示 comments 字段 */}
|
||||||
<Space className="flex items-center">
|
<Space className="flex items-center">
|
||||||
<Text className="text-xs text-gray-500">跟进情况:{customer.comments || '暂无'}</Text>
|
<Text className="text-xs text-gray-500">备注:{patient.comments || '暂无'}</Text>
|
||||||
<Text
|
<Text
|
||||||
className="text-xs text-blue-500 cursor-pointer"
|
className="text-xs text-blue-500 cursor-pointer"
|
||||||
onClick={(e) => {
|
onClick={(e) => {
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
editComments(customer);
|
editComments(patient);
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
编辑
|
编辑
|
||||||
@@ -440,42 +243,28 @@ const CustomerIndex = () => {
|
|||||||
</View>
|
</View>
|
||||||
</View>
|
</View>
|
||||||
|
|
||||||
{/* 跟进中状态显示操作按钮 */}
|
{/* 操作按钮 */}
|
||||||
{(customer.applyStatus === 10 && customer.userId == Taro.getStorageSync('UserId')) && (
|
|
||||||
<Space className="flex justify-end">
|
<Space className="flex justify-end">
|
||||||
<Button
|
<Button
|
||||||
size="small"
|
size="small"
|
||||||
onClick={() => navTo(`/doctor/customer/add?id=${customer.applyId}`, true)}
|
onClick={() => navTo(`/doctor/customer/add?id=${patient.id}`, true)}
|
||||||
style={{marginRight: '8px', backgroundColor: '#52c41a', color: 'white'}}
|
style={{marginRight: '8px', backgroundColor: '#1890ff', color: 'white'}}
|
||||||
>
|
>
|
||||||
签约
|
查看详情
|
||||||
</Button>
|
</Button>
|
||||||
<Button
|
<Button
|
||||||
size="small"
|
size="small"
|
||||||
onClick={() => handleCancel(customer)}
|
onClick={() => handleDelete(patient)}
|
||||||
style={{backgroundColor: '#ff4d4f', color: 'white'}}
|
|
||||||
>
|
|
||||||
取消
|
|
||||||
</Button>
|
|
||||||
</Space>
|
|
||||||
)}
|
|
||||||
{(customer.applyStatus === 30 && customer.userId == Taro.getStorageSync('UserId')) && (
|
|
||||||
<Space className="flex justify-end">
|
|
||||||
<Button
|
|
||||||
size="small"
|
|
||||||
onClick={() => handleDelete(customer)}
|
|
||||||
style={{backgroundColor: '#ff4d4f', color: 'white'}}
|
style={{backgroundColor: '#ff4d4f', color: 'white'}}
|
||||||
>
|
>
|
||||||
删除
|
删除
|
||||||
</Button>
|
</Button>
|
||||||
</Space>
|
</Space>
|
||||||
)}
|
|
||||||
</View>
|
</View>
|
||||||
);
|
);
|
||||||
|
|
||||||
// 渲染客户列表
|
// 渲染患者列表
|
||||||
const renderCustomerList = () => {
|
const renderPatientList = () => {
|
||||||
const filteredList = getFilteredList();
|
|
||||||
const isSearching = displaySearchValue.trim().length > 0;
|
const isSearching = displaySearchValue.trim().length > 0;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@@ -484,7 +273,7 @@ const CustomerIndex = () => {
|
|||||||
{isSearching && (
|
{isSearching && (
|
||||||
<View className="bg-white px-4 py-2 border-b border-gray-100">
|
<View className="bg-white px-4 py-2 border-b border-gray-100">
|
||||||
<Text className="text-sm text-gray-600">
|
<Text className="text-sm text-gray-600">
|
||||||
搜索 "{displaySearchValue}" 的结果,共找到 {filteredList.length} 条记录
|
搜索 "{displaySearchValue}" 的结果,共找到 {list.length} 条记录
|
||||||
</Text>
|
</Text>
|
||||||
</View>
|
</View>
|
||||||
)}
|
)}
|
||||||
@@ -510,10 +299,10 @@ const CustomerIndex = () => {
|
|||||||
</>
|
</>
|
||||||
}
|
}
|
||||||
loadMoreText={
|
loadMoreText={
|
||||||
filteredList.length === 0 ? (
|
list.length === 0 ? (
|
||||||
<Empty
|
<Empty
|
||||||
style={{backgroundColor: 'transparent'}}
|
style={{backgroundColor: 'transparent'}}
|
||||||
description={loading ? "加载中..." : "暂无客户数据"}
|
description={loading ? "加载中..." : "暂无患者数据"}
|
||||||
/>
|
/>
|
||||||
) : (
|
) : (
|
||||||
<View className={'h-3 flex items-center justify-center'}>
|
<View className={'h-3 flex items-center justify-center'}>
|
||||||
@@ -522,13 +311,13 @@ const CustomerIndex = () => {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
>
|
>
|
||||||
{loading && filteredList.length === 0 ? (
|
{loading && list.length === 0 ? (
|
||||||
<View className="flex items-center justify-center py-8">
|
<View className="flex items-center justify-center py-8">
|
||||||
<Loading/>
|
<Loading/>
|
||||||
<Text className="text-gray-500 mt-2 ml-2">加载中...</Text>
|
<Text className="text-gray-500 mt-2 ml-2">加载中...</Text>
|
||||||
</View>
|
</View>
|
||||||
) : (
|
) : (
|
||||||
filteredList.map(renderCustomerItem)
|
list.map(renderPatientItem)
|
||||||
)}
|
)}
|
||||||
</InfiniteLoading>
|
</InfiniteLoading>
|
||||||
</View>
|
</View>
|
||||||
@@ -542,7 +331,7 @@ const CustomerIndex = () => {
|
|||||||
<View className="bg-white py-2 border-b border-gray-100">
|
<View className="bg-white py-2 border-b border-gray-100">
|
||||||
<SearchBar
|
<SearchBar
|
||||||
value={searchValue}
|
value={searchValue}
|
||||||
placeholder="搜索客户名称、手机号"
|
placeholder="搜索患者姓名、手机号"
|
||||||
onChange={(value) => setSearchValue(value)}
|
onChange={(value) => setSearchValue(value)}
|
||||||
onClear={() => {
|
onClear={() => {
|
||||||
setSearchValue('');
|
setSearchValue('');
|
||||||
@@ -552,32 +341,12 @@ const CustomerIndex = () => {
|
|||||||
/>
|
/>
|
||||||
</View>
|
</View>
|
||||||
|
|
||||||
{/* 顶部Tabs */}
|
{/* 患者列表 */}
|
||||||
<View className="bg-white">
|
{renderPatientList()}
|
||||||
<Tabs
|
|
||||||
value={activeTab}
|
|
||||||
onChange={(value) => setActiveTab(value as CustomerStatus)}
|
|
||||||
>
|
|
||||||
{tabList.map(tab => {
|
|
||||||
const counts = getStatusCounts();
|
|
||||||
const count = counts[tab.value as keyof typeof counts] || 0;
|
|
||||||
return (
|
|
||||||
<TabPane
|
|
||||||
key={tab.value}
|
|
||||||
title={`${tab.label}${count > 0 ? `(${count})` : ''}`}
|
|
||||||
value={tab.value}
|
|
||||||
/>
|
|
||||||
);
|
|
||||||
})}
|
|
||||||
</Tabs>
|
|
||||||
</View>
|
|
||||||
|
|
||||||
{/* 客户列表 */}
|
<FixedButton text={'添加患者'} onClick={() => Taro.navigateTo({url: '/doctor/customer/add'})}/>
|
||||||
{renderCustomerList()}
|
|
||||||
|
|
||||||
<FixedButton text={'客户报备'} onClick={() => Taro.navigateTo({url: '/doctor/customer/add'})}/>
|
|
||||||
</View>
|
</View>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
export default CustomerIndex;
|
export default PatientIndex;
|
||||||
|
|||||||
@@ -1,23 +1,28 @@
|
|||||||
import {useEffect, useState, useRef} from "react";
|
import {useEffect, useState, useRef} from "react";
|
||||||
import {useRouter} from '@tarojs/taro'
|
import {useRouter} from '@tarojs/taro'
|
||||||
import {Loading, CellGroup, Input, Form, Cell, Avatar} from '@nutui/nutui-react-taro'
|
import {Loading, CellGroup, Input, Form, Cell, Avatar, Tag} from '@nutui/nutui-react-taro'
|
||||||
import {ArrowRight} from '@nutui/icons-react-taro'
|
import {ArrowRight} from '@nutui/icons-react-taro'
|
||||||
import {View, Text} from '@tarojs/components'
|
import {View, Text} from '@tarojs/components'
|
||||||
import Taro from '@tarojs/taro'
|
import Taro from '@tarojs/taro'
|
||||||
import FixedButton from "@/components/FixedButton";
|
import FixedButton from "@/components/FixedButton";
|
||||||
import {addShopChatMessage} from "@/api/shop/shopChatMessage";
|
import {addShopChatMessage} from "@/api/shop/shopChatMessage";
|
||||||
import {ShopChatMessage} from "@/api/shop/shopChatMessage/model";
|
|
||||||
import navTo from "@/utils/common";
|
import navTo from "@/utils/common";
|
||||||
import {getUser} from "@/api/system/user";
|
import {getUser} from "@/api/system/user";
|
||||||
import {User} from "@/api/system/user/model";
|
import {User} from "@/api/system/user/model";
|
||||||
|
import {ClinicPatientUser} from "@/api/clinic/clinicPatientUser/model";
|
||||||
|
import {ClinicPrescription} from "@/api/clinic/clinicPrescription/model";
|
||||||
|
|
||||||
const AddMessage = () => {
|
const AddMessage = () => {
|
||||||
const {params} = useRouter();
|
const {params} = useRouter();
|
||||||
const [toUser, setToUser] = useState<User>()
|
const [toUser, setToUser] = useState<User>()
|
||||||
const [loading, setLoading] = useState<boolean>(true)
|
const [loading, setLoading] = useState<boolean>(true)
|
||||||
const [FormData, _] = useState<ShopChatMessage>()
|
const [FormData, _] = useState<ClinicPrescription>()
|
||||||
const formRef = useRef<any>(null)
|
const formRef = useRef<any>(null)
|
||||||
|
|
||||||
|
// 患者和处方状态
|
||||||
|
const [selectedPatient, setSelectedPatient] = useState<ClinicPatientUser | null>(null)
|
||||||
|
const [selectedPrescription, setSelectedPrescription] = useState<ClinicPrescription | null>(null)
|
||||||
|
|
||||||
// 判断是编辑还是新增模式
|
// 判断是编辑还是新增模式
|
||||||
const isEditMode = !!params.id
|
const isEditMode = !!params.id
|
||||||
const toUserId = params.id ? Number(params.id) : undefined
|
const toUserId = params.id ? Number(params.id) : undefined
|
||||||
@@ -30,6 +35,20 @@ const AddMessage = () => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 设置选中的患者(供其他页面调用)
|
||||||
|
// @ts-ignore
|
||||||
|
const setSelectedPatientFunc = (patient: ClinicPatientUser) => {
|
||||||
|
console.log('患者:', patient)
|
||||||
|
setSelectedPatient(patient)
|
||||||
|
console.log(selectedPatient,'selectedPatient')
|
||||||
|
}
|
||||||
|
|
||||||
|
// 设置选中的处方(供其他页面调用)
|
||||||
|
// @ts-ignore
|
||||||
|
const setSelectedPrescriptionFunc = (prescription: ClinicPrescription) => {
|
||||||
|
setSelectedPrescription(prescription)
|
||||||
|
}
|
||||||
|
|
||||||
// 提交表单
|
// 提交表单
|
||||||
const submitSucceed = async (values: any) => {
|
const submitSucceed = async (values: any) => {
|
||||||
try {
|
try {
|
||||||
@@ -41,9 +60,9 @@ const AddMessage = () => {
|
|||||||
console.log('提交数据:', submitData)
|
console.log('提交数据:', submitData)
|
||||||
|
|
||||||
// 参数校验
|
// 参数校验
|
||||||
if(!toUser){
|
if(!toUser && !selectedPatient){
|
||||||
Taro.showToast({
|
Taro.showToast({
|
||||||
title: `请选择发送对象`,
|
title: `请选择发送对象或患者`,
|
||||||
icon: 'error'
|
icon: 'error'
|
||||||
});
|
});
|
||||||
return false;
|
return false;
|
||||||
@@ -57,12 +76,25 @@ const AddMessage = () => {
|
|||||||
});
|
});
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 如果选择了患者,在消息内容中添加患者信息
|
||||||
|
console.log(values,'vals.s..s.s.s.s.s')
|
||||||
|
let content = values.content;
|
||||||
|
if (selectedPatient) {
|
||||||
|
content = `[患者: ${selectedPatient.realName || '未知'}] ${content}`;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 如果选择了处方,在消息内容中添加处方信息
|
||||||
|
if (selectedPrescription) {
|
||||||
|
content = `[处方: ${selectedPrescription.orderNo || '未知'}] ${content}`;
|
||||||
|
}
|
||||||
|
|
||||||
// 执行新增或更新操作
|
// 执行新增或更新操作
|
||||||
await addShopChatMessage({
|
await addShopChatMessage({
|
||||||
toUserId: toUserId,
|
toUserId: toUserId || selectedPatient?.userId,
|
||||||
formUserId: Taro.getStorageSync('UserId'),
|
formUserId: Taro.getStorageSync('UserId'),
|
||||||
type: 'text',
|
type: 'text',
|
||||||
content: values.content
|
content: content
|
||||||
});
|
});
|
||||||
|
|
||||||
Taro.showToast({
|
Taro.showToast({
|
||||||
@@ -91,6 +123,12 @@ const AddMessage = () => {
|
|||||||
reload().then(() => {
|
reload().then(() => {
|
||||||
setLoading(false)
|
setLoading(false)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
// 设置页面实例的方法,供其他页面调用
|
||||||
|
// @ts-ignore
|
||||||
|
Taro.getCurrentInstance().page.setSelectedPatient = setSelectedPatientFunc;
|
||||||
|
// @ts-ignore
|
||||||
|
Taro.getCurrentInstance().page.setSelectedPrescription = setSelectedPrescriptionFunc;
|
||||||
}, [isEditMode]);
|
}, [isEditMode]);
|
||||||
|
|
||||||
if (loading) {
|
if (loading) {
|
||||||
@@ -99,7 +137,9 @@ const AddMessage = () => {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<Cell title={toUser ? (
|
{/* 显示已选择的用户(如果有的话) */}
|
||||||
|
{toUser && (
|
||||||
|
<Cell title={(
|
||||||
<View className={'flex items-center'}>
|
<View className={'flex items-center'}>
|
||||||
<Avatar src={toUser.avatar}/>
|
<Avatar src={toUser.avatar}/>
|
||||||
<View className={'ml-2 flex flex-col'}>
|
<View className={'ml-2 flex flex-col'}>
|
||||||
@@ -107,10 +147,68 @@ const AddMessage = () => {
|
|||||||
<Text className={'text-gray-300'}>{toUser.mobile}</Text>
|
<Text className={'text-gray-300'}>{toUser.mobile}</Text>
|
||||||
</View>
|
</View>
|
||||||
</View>
|
</View>
|
||||||
) : '选择患者'} extra={(
|
)} extra={(
|
||||||
<ArrowRight color="#cccccc" className={toUser ? 'mt-2' : ''} size={toUser ? 20 : 18}/>
|
<ArrowRight color="#cccccc" className={'mt-2'} size={20}/>
|
||||||
|
)}/>
|
||||||
)}
|
)}
|
||||||
onClick={() => navTo(`/doctor/customer/index`, true)}/>
|
|
||||||
|
{/* 选择患者 */}
|
||||||
|
{JSON.stringify(selectedPatient)}
|
||||||
|
<Cell
|
||||||
|
title="选择患者"
|
||||||
|
extra={selectedPatient ? (
|
||||||
|
<View className={'flex items-center'}>
|
||||||
|
<Text className={'mr-2'}>{selectedPatient.realName || '未知患者'}</Text>
|
||||||
|
<ArrowRight color="#cccccc" size={18}/>
|
||||||
|
</View>
|
||||||
|
) : (
|
||||||
|
<ArrowRight color="#cccccc" size={18}/>
|
||||||
|
)}
|
||||||
|
onClick={() => navTo(`/doctor/orders/selectPatient`, true)}
|
||||||
|
/>
|
||||||
|
|
||||||
|
<Cell
|
||||||
|
title="诊断结果"
|
||||||
|
extra={selectedPatient ? (
|
||||||
|
<Form.Item name="content" initialValue={FormData?.diagnosis} required>
|
||||||
|
<Input placeholder="填写诊断结果" maxLength={300}/>
|
||||||
|
</Form.Item>
|
||||||
|
) : (
|
||||||
|
<ArrowRight color="#cccccc" size={18}/>
|
||||||
|
)}
|
||||||
|
onClick={() => navTo(`/doctor/orders/selectPatient`, true)}
|
||||||
|
/>
|
||||||
|
|
||||||
|
{/* 选择处方 */}
|
||||||
|
<Cell
|
||||||
|
title="选择处方"
|
||||||
|
extra={selectedPrescription ? (
|
||||||
|
<View className={'flex items-center'}>
|
||||||
|
<Text className={'mr-2'}>{selectedPrescription.treatmentPlan || '未知处方'}</Text>
|
||||||
|
<ArrowRight color="#cccccc" size={18}/>
|
||||||
|
</View>
|
||||||
|
) : (
|
||||||
|
<ArrowRight color="#cccccc" size={18}/>
|
||||||
|
)}
|
||||||
|
onClick={() => navTo(`/doctor/orders/selectPrescription`, true)}
|
||||||
|
/>
|
||||||
|
|
||||||
|
<Cell
|
||||||
|
title="药方信息"
|
||||||
|
extra={selectedPrescription ? (
|
||||||
|
<View className={'flex items-center'}>
|
||||||
|
{selectedPrescription.items?.map(item => (
|
||||||
|
<Tag key={item.id} className={'mr-2'}>{item.medicineName}</Tag>
|
||||||
|
))}
|
||||||
|
</View>
|
||||||
|
) : (
|
||||||
|
<ArrowRight color="#cccccc" size={18}/>
|
||||||
|
)}
|
||||||
|
onClick={() => navTo(`/doctor/orders/selectPrescription`, true)}
|
||||||
|
/>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<Form
|
<Form
|
||||||
ref={formRef}
|
ref={formRef}
|
||||||
divider
|
divider
|
||||||
@@ -120,7 +218,7 @@ const AddMessage = () => {
|
|||||||
onFinishFailed={(errors) => submitFailed(errors)}
|
onFinishFailed={(errors) => submitFailed(errors)}
|
||||||
>
|
>
|
||||||
<CellGroup style={{padding: '4px 0'}}>
|
<CellGroup style={{padding: '4px 0'}}>
|
||||||
<Form.Item name="content" initialValue={FormData?.content} required>
|
<Form.Item name="content" initialValue={FormData?.decoctionInstructions} required>
|
||||||
<Input placeholder="填写消息内容" maxLength={300}/>
|
<Input placeholder="填写消息内容" maxLength={300}/>
|
||||||
</Form.Item>
|
</Form.Item>
|
||||||
</CellGroup>
|
</CellGroup>
|
||||||
|
|||||||
4
src/doctor/orders/selectPatient.config.ts
Normal file
4
src/doctor/orders/selectPatient.config.ts
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
export default definePageConfig({
|
||||||
|
navigationBarTitleText: '选择患者',
|
||||||
|
navigationBarTextStyle: 'black'
|
||||||
|
})
|
||||||
287
src/doctor/orders/selectPatient.tsx
Normal file
287
src/doctor/orders/selectPatient.tsx
Normal file
@@ -0,0 +1,287 @@
|
|||||||
|
import {useState, useEffect, useCallback} from 'react'
|
||||||
|
import {View, Text} from '@tarojs/components'
|
||||||
|
import Taro, {useDidShow} from '@tarojs/taro'
|
||||||
|
import {Loading, InfiniteLoading, Empty, Space, SearchBar, Button} from '@nutui/nutui-react-taro'
|
||||||
|
import {Phone} from '@nutui/icons-react-taro'
|
||||||
|
import type {ClinicPatientUser as PatientUserType} from "@/api/clinic/clinicPatientUser/model";
|
||||||
|
import {
|
||||||
|
pageClinicPatientUser
|
||||||
|
} from "@/api/clinic/clinicPatientUser";
|
||||||
|
|
||||||
|
// 患者类型
|
||||||
|
interface PatientUser extends PatientUserType {
|
||||||
|
}
|
||||||
|
|
||||||
|
const SelectPatient = () => {
|
||||||
|
const [list, setList] = useState<PatientUser[]>([])
|
||||||
|
const [loading, setLoading] = useState<boolean>(false)
|
||||||
|
const [searchValue, setSearchValue] = useState<string>('')
|
||||||
|
const [displaySearchValue, setDisplaySearchValue] = useState<string>('')
|
||||||
|
const [page, setPage] = useState(1)
|
||||||
|
const [hasMore, setHasMore] = useState(true)
|
||||||
|
|
||||||
|
// 复制手机号
|
||||||
|
const copyPhone = (phone: string) => {
|
||||||
|
Taro.setClipboardData({
|
||||||
|
data: phone,
|
||||||
|
success: () => {
|
||||||
|
Taro.showToast({
|
||||||
|
title: '手机号已复制',
|
||||||
|
icon: 'success',
|
||||||
|
duration: 1500
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
// 一键拨打
|
||||||
|
const makePhoneCall = (phone: string) => {
|
||||||
|
Taro.makePhoneCall({
|
||||||
|
phoneNumber: phone,
|
||||||
|
fail: () => {
|
||||||
|
Taro.showToast({
|
||||||
|
title: '拨打取消',
|
||||||
|
icon: 'error'
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
// 获取患者数据
|
||||||
|
const fetchPatientData = useCallback(async (resetPage = false, targetPage?: number) => {
|
||||||
|
setLoading(true);
|
||||||
|
try {
|
||||||
|
const currentPage = resetPage ? 1 : (targetPage || page);
|
||||||
|
|
||||||
|
// 构建API参数
|
||||||
|
const params: any = {
|
||||||
|
page: currentPage
|
||||||
|
};
|
||||||
|
|
||||||
|
// 添加搜索关键词
|
||||||
|
if (displaySearchValue.trim()) {
|
||||||
|
params.keywords = displaySearchValue.trim();
|
||||||
|
}
|
||||||
|
|
||||||
|
const res = await pageClinicPatientUser(params);
|
||||||
|
|
||||||
|
if (res?.list && res.list.length > 0) {
|
||||||
|
// 如果是重置页面或第一页,直接设置新数据;否则追加数据
|
||||||
|
if (resetPage || currentPage === 1) {
|
||||||
|
setList(res.list);
|
||||||
|
} else {
|
||||||
|
setList(prevList => prevList.concat(res.list));
|
||||||
|
}
|
||||||
|
|
||||||
|
// 正确判断是否还有更多数据
|
||||||
|
const hasMoreData = res.list.length >= 10; // 假设每页10条数据
|
||||||
|
setHasMore(hasMoreData);
|
||||||
|
} else {
|
||||||
|
if (resetPage || currentPage === 1) {
|
||||||
|
setList([]);
|
||||||
|
}
|
||||||
|
setHasMore(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
setPage(currentPage);
|
||||||
|
} catch (error) {
|
||||||
|
console.error('获取患者数据失败:', error);
|
||||||
|
Taro.showToast({
|
||||||
|
title: '加载失败,请重试',
|
||||||
|
icon: 'none'
|
||||||
|
});
|
||||||
|
} finally {
|
||||||
|
setLoading(false);
|
||||||
|
}
|
||||||
|
}, [page, displaySearchValue]);
|
||||||
|
|
||||||
|
const reloadMore = async () => {
|
||||||
|
if (loading || !hasMore) return; // 防止重复加载
|
||||||
|
const nextPage = page + 1;
|
||||||
|
await fetchPatientData(false, nextPage);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 防抖搜索功能
|
||||||
|
useEffect(() => {
|
||||||
|
const timer = setTimeout(() => {
|
||||||
|
setDisplaySearchValue(searchValue);
|
||||||
|
}, 300); // 300ms 防抖
|
||||||
|
|
||||||
|
return () => clearTimeout(timer);
|
||||||
|
}, [searchValue]);
|
||||||
|
|
||||||
|
// 初始化数据
|
||||||
|
useEffect(() => {
|
||||||
|
fetchPatientData(true).then();
|
||||||
|
}, [displaySearchValue]);
|
||||||
|
|
||||||
|
// 监听页面显示,当从其他页面返回时刷新数据
|
||||||
|
useDidShow(() => {
|
||||||
|
// 刷新数据
|
||||||
|
setList([]);
|
||||||
|
setPage(1);
|
||||||
|
setHasMore(true);
|
||||||
|
fetchPatientData(true);
|
||||||
|
});
|
||||||
|
|
||||||
|
// 选择患者
|
||||||
|
const selectPatient = (patient: PatientUser) => {
|
||||||
|
// 将选中的患者信息传递回上一个页面
|
||||||
|
const pages = Taro.getCurrentPages();
|
||||||
|
if (pages.length > 1) {
|
||||||
|
const prevPage = pages[pages.length - 2];
|
||||||
|
// @ts-ignore
|
||||||
|
if (prevPage && typeof prevPage.setSelectedPatient === 'function') {
|
||||||
|
// @ts-ignore
|
||||||
|
prevPage.setSelectedPatient(patient);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Taro.navigateBack();
|
||||||
|
};
|
||||||
|
|
||||||
|
// 渲染患者项
|
||||||
|
const renderPatientItem = (patient: PatientUser) => (
|
||||||
|
<View key={patient.id} className="bg-white rounded-lg p-4 mb-3 shadow-sm">
|
||||||
|
<View className="flex items-center mb-3">
|
||||||
|
<View className="flex-1">
|
||||||
|
<View className="flex items-center justify-between mb-1">
|
||||||
|
<Text className="font-semibold text-gray-800 mr-2">
|
||||||
|
{patient.realName || '未命名'}
|
||||||
|
</Text>
|
||||||
|
</View>
|
||||||
|
<View className="flex items-center mb-1">
|
||||||
|
<Space direction="vertical">
|
||||||
|
<View className="flex items-center">
|
||||||
|
<Text className="text-xs text-gray-500" onClick={(e) => {
|
||||||
|
e.stopPropagation();
|
||||||
|
makePhoneCall(patient.phone || '');
|
||||||
|
}}>联系电话:{patient.phone || '未提供'}</Text>
|
||||||
|
<View className="flex items-center ml-2">
|
||||||
|
<Phone
|
||||||
|
size={12}
|
||||||
|
className="text-green-500 mr-2"
|
||||||
|
onClick={(e) => {
|
||||||
|
e.stopPropagation();
|
||||||
|
makePhoneCall(patient.phone || '');
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
<Text
|
||||||
|
className="text-xs text-blue-500 cursor-pointer"
|
||||||
|
onClick={(e) => {
|
||||||
|
e.stopPropagation();
|
||||||
|
copyPhone(patient.phone || '');
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
复制
|
||||||
|
</Text>
|
||||||
|
</View>
|
||||||
|
</View>
|
||||||
|
<Text className="text-xs text-gray-500">
|
||||||
|
添加时间:{patient.createTime || '未知'}
|
||||||
|
</Text>
|
||||||
|
</Space>
|
||||||
|
</View>
|
||||||
|
|
||||||
|
{/* 显示 comments 字段 */}
|
||||||
|
<View className="flex items-center">
|
||||||
|
<Text className="text-xs text-gray-500">备注:{patient.comments || '暂无'}</Text>
|
||||||
|
</View>
|
||||||
|
</View>
|
||||||
|
</View>
|
||||||
|
|
||||||
|
{/* 选择按钮 */}
|
||||||
|
<Button
|
||||||
|
size="small"
|
||||||
|
onClick={() => selectPatient(patient)}
|
||||||
|
style={{backgroundColor: '#1890ff', color: 'white'}}
|
||||||
|
>
|
||||||
|
选择此患者
|
||||||
|
</Button>
|
||||||
|
</View>
|
||||||
|
);
|
||||||
|
|
||||||
|
// 渲染患者列表
|
||||||
|
const renderPatientList = () => {
|
||||||
|
const isSearching = displaySearchValue.trim().length > 0;
|
||||||
|
|
||||||
|
return (
|
||||||
|
<View className="flex-1">
|
||||||
|
{/* 搜索结果统计 */}
|
||||||
|
{isSearching && (
|
||||||
|
<View className="bg-white px-4 py-2 border-b border-gray-100">
|
||||||
|
<Text className="text-sm text-gray-600">
|
||||||
|
搜索 "{displaySearchValue}" 的结果,共找到 {list.length} 条记录
|
||||||
|
</Text>
|
||||||
|
</View>
|
||||||
|
)}
|
||||||
|
|
||||||
|
<View className="p-4" style={{
|
||||||
|
height: isSearching ? 'calc(90vh - 40px)' : '90vh',
|
||||||
|
overflowY: 'auto',
|
||||||
|
overflowX: 'hidden'
|
||||||
|
}}>
|
||||||
|
<InfiniteLoading
|
||||||
|
target="scroll"
|
||||||
|
hasMore={hasMore}
|
||||||
|
onLoadMore={reloadMore}
|
||||||
|
onScroll={() => {
|
||||||
|
// 滚动事件处理
|
||||||
|
}}
|
||||||
|
onScrollToUpper={() => {
|
||||||
|
// 滚动到顶部事件处理
|
||||||
|
}}
|
||||||
|
loadingText={
|
||||||
|
<>
|
||||||
|
加载中...
|
||||||
|
</>
|
||||||
|
}
|
||||||
|
loadMoreText={
|
||||||
|
list.length === 0 ? (
|
||||||
|
<Empty
|
||||||
|
style={{backgroundColor: 'transparent'}}
|
||||||
|
description={loading ? "加载中..." : "暂无患者数据"}
|
||||||
|
/>
|
||||||
|
) : (
|
||||||
|
<View className={'h-3 flex items-center justify-center'}>
|
||||||
|
<Text className="text-gray-500 text-sm">没有更多了</Text>
|
||||||
|
</View>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
>
|
||||||
|
{loading && list.length === 0 ? (
|
||||||
|
<View className="flex items-center justify-center py-8">
|
||||||
|
<Loading/>
|
||||||
|
<Text className="text-gray-500 mt-2 ml-2">加载中...</Text>
|
||||||
|
</View>
|
||||||
|
) : (
|
||||||
|
list.map(renderPatientItem)
|
||||||
|
)}
|
||||||
|
</InfiniteLoading>
|
||||||
|
</View>
|
||||||
|
</View>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
return (
|
||||||
|
<View className="min-h-screen bg-gray-50">
|
||||||
|
{/* 搜索栏 */}
|
||||||
|
<View className="bg-white py-2 border-b border-gray-100">
|
||||||
|
<SearchBar
|
||||||
|
value={searchValue}
|
||||||
|
placeholder="搜索患者姓名、手机号"
|
||||||
|
onChange={(value) => setSearchValue(value)}
|
||||||
|
onClear={() => {
|
||||||
|
setSearchValue('');
|
||||||
|
setDisplaySearchValue('');
|
||||||
|
}}
|
||||||
|
clearable
|
||||||
|
/>
|
||||||
|
</View>
|
||||||
|
|
||||||
|
{/* 患者列表 */}
|
||||||
|
{renderPatientList()}
|
||||||
|
</View>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default SelectPatient;
|
||||||
4
src/doctor/orders/selectPrescription.config.ts
Normal file
4
src/doctor/orders/selectPrescription.config.ts
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
export default definePageConfig({
|
||||||
|
navigationBarTitleText: '选择处方',
|
||||||
|
navigationBarTextStyle: 'black'
|
||||||
|
})
|
||||||
236
src/doctor/orders/selectPrescription.tsx
Normal file
236
src/doctor/orders/selectPrescription.tsx
Normal file
@@ -0,0 +1,236 @@
|
|||||||
|
import {useState, useEffect, useCallback} from 'react'
|
||||||
|
import {View, Text} from '@tarojs/components'
|
||||||
|
import Taro, {useDidShow} from '@tarojs/taro'
|
||||||
|
import {Loading, InfiniteLoading, Empty, Space, SearchBar, Button} from '@nutui/nutui-react-taro'
|
||||||
|
import {
|
||||||
|
pageClinicPrescription
|
||||||
|
} from "@/api/clinic/clinicPrescription";
|
||||||
|
import {ClinicPrescription} from "@/api/clinic/clinicPrescription/model";
|
||||||
|
|
||||||
|
const SelectPrescription = () => {
|
||||||
|
const [list, setList] = useState<ClinicPrescription[]>([])
|
||||||
|
const [loading, setLoading] = useState<boolean>(false)
|
||||||
|
const [searchValue, setSearchValue] = useState<string>('')
|
||||||
|
const [displaySearchValue, setDisplaySearchValue] = useState<string>('')
|
||||||
|
const [page, setPage] = useState(1)
|
||||||
|
const [hasMore, setHasMore] = useState(true)
|
||||||
|
|
||||||
|
// 获取处方数据
|
||||||
|
const fetchPrescriptionData = useCallback(async (resetPage = false, targetPage?: number) => {
|
||||||
|
setLoading(true);
|
||||||
|
try {
|
||||||
|
const currentPage = resetPage ? 1 : (targetPage || page);
|
||||||
|
|
||||||
|
// 构建API参数
|
||||||
|
const params: any = {
|
||||||
|
page: currentPage
|
||||||
|
};
|
||||||
|
|
||||||
|
// 添加搜索关键词
|
||||||
|
if (displaySearchValue.trim()) {
|
||||||
|
params.keywords = displaySearchValue.trim();
|
||||||
|
}
|
||||||
|
|
||||||
|
const res = await pageClinicPrescription(params);
|
||||||
|
|
||||||
|
if (res?.list && res.list.length > 0) {
|
||||||
|
// 如果是重置页面或第一页,直接设置新数据;否则追加数据
|
||||||
|
if (resetPage || currentPage === 1) {
|
||||||
|
setList(res.list);
|
||||||
|
} else {
|
||||||
|
setList(prevList => prevList.concat(res.list));
|
||||||
|
}
|
||||||
|
|
||||||
|
// 正确判断是否还有更多数据
|
||||||
|
const hasMoreData = res.list.length >= 10; // 假设每页10条数据
|
||||||
|
setHasMore(hasMoreData);
|
||||||
|
} else {
|
||||||
|
if (resetPage || currentPage === 1) {
|
||||||
|
setList([]);
|
||||||
|
}
|
||||||
|
setHasMore(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
setPage(currentPage);
|
||||||
|
} catch (error) {
|
||||||
|
console.error('获取处方数据失败:', error);
|
||||||
|
Taro.showToast({
|
||||||
|
title: '加载失败,请重试',
|
||||||
|
icon: 'none'
|
||||||
|
});
|
||||||
|
} finally {
|
||||||
|
setLoading(false);
|
||||||
|
}
|
||||||
|
}, [page, displaySearchValue]);
|
||||||
|
|
||||||
|
const reloadMore = async () => {
|
||||||
|
if (loading || !hasMore) return; // 防止重复加载
|
||||||
|
const nextPage = page + 1;
|
||||||
|
await fetchPrescriptionData(false, nextPage);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 防抖搜索功能
|
||||||
|
useEffect(() => {
|
||||||
|
const timer = setTimeout(() => {
|
||||||
|
setDisplaySearchValue(searchValue);
|
||||||
|
}, 300); // 300ms 防抖
|
||||||
|
|
||||||
|
return () => clearTimeout(timer);
|
||||||
|
}, [searchValue]);
|
||||||
|
|
||||||
|
// 初始化数据
|
||||||
|
useEffect(() => {
|
||||||
|
fetchPrescriptionData(true).then();
|
||||||
|
}, [displaySearchValue]);
|
||||||
|
|
||||||
|
// 监听页面显示,当从其他页面返回时刷新数据
|
||||||
|
useDidShow(() => {
|
||||||
|
// 刷新数据
|
||||||
|
setList([]);
|
||||||
|
setPage(1);
|
||||||
|
setHasMore(true);
|
||||||
|
fetchPrescriptionData(true);
|
||||||
|
});
|
||||||
|
|
||||||
|
// 选择处方
|
||||||
|
const selectPrescription = (prescription: ClinicPrescription) => {
|
||||||
|
// 将选中的处方信息传递回上一个页面
|
||||||
|
const pages = Taro.getCurrentPages();
|
||||||
|
if (pages.length > 1) {
|
||||||
|
const prevPage = pages[pages.length - 2];
|
||||||
|
// @ts-ignore
|
||||||
|
if (prevPage && typeof prevPage.setSelectedPrescription === 'function') {
|
||||||
|
// @ts-ignore
|
||||||
|
prevPage.setSelectedPrescription(prescription);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Taro.navigateBack();
|
||||||
|
};
|
||||||
|
|
||||||
|
// 渲染处方项
|
||||||
|
const renderPrescriptionItem = (prescription: ClinicPrescription) => (
|
||||||
|
<View key={prescription.id} className="bg-white rounded-lg p-4 mb-3 shadow-sm">
|
||||||
|
<View className="flex items-center mb-3">
|
||||||
|
<View className="flex-1">
|
||||||
|
<View className="flex items-center justify-between mb-1">
|
||||||
|
<Text className="font-semibold text-gray-800 mr-2">
|
||||||
|
处方编号: {prescription.orderNo || '无编号'}
|
||||||
|
</Text>
|
||||||
|
</View>
|
||||||
|
<View className="flex items-center mb-1">
|
||||||
|
<Space direction="vertical">
|
||||||
|
<Text className="text-xs text-gray-500">
|
||||||
|
处方类型: {prescription.prescriptionType === 0 ? '中药' : prescription.prescriptionType === 1 ? '西药' : '未知'}
|
||||||
|
</Text>
|
||||||
|
<Text className="text-xs text-gray-500">
|
||||||
|
诊断结果: {prescription.diagnosis || '无'}
|
||||||
|
</Text>
|
||||||
|
<Text className="text-xs text-gray-500">
|
||||||
|
创建时间: {prescription.createTime || '未知'}
|
||||||
|
</Text>
|
||||||
|
</Space>
|
||||||
|
</View>
|
||||||
|
|
||||||
|
{/* 显示备注字段 */}
|
||||||
|
<View className="flex items-center">
|
||||||
|
<Text className="text-xs text-gray-500">备注: {prescription.comments || '暂无'}</Text>
|
||||||
|
</View>
|
||||||
|
</View>
|
||||||
|
</View>
|
||||||
|
|
||||||
|
{/* 选择按钮 */}
|
||||||
|
<Button
|
||||||
|
size="small"
|
||||||
|
onClick={() => selectPrescription(prescription)}
|
||||||
|
style={{backgroundColor: '#1890ff', color: 'white'}}
|
||||||
|
>
|
||||||
|
选择此处方
|
||||||
|
</Button>
|
||||||
|
</View>
|
||||||
|
);
|
||||||
|
|
||||||
|
// 渲染处方列表
|
||||||
|
const renderPrescriptionList = () => {
|
||||||
|
const isSearching = displaySearchValue.trim().length > 0;
|
||||||
|
|
||||||
|
return (
|
||||||
|
<View className="flex-1">
|
||||||
|
{/* 搜索结果统计 */}
|
||||||
|
{isSearching && (
|
||||||
|
<View className="bg-white px-4 py-2 border-b border-gray-100">
|
||||||
|
<Text className="text-sm text-gray-600">
|
||||||
|
搜索 "{displaySearchValue}" 的结果,共找到 {list.length} 条记录
|
||||||
|
</Text>
|
||||||
|
</View>
|
||||||
|
)}
|
||||||
|
|
||||||
|
<View className="p-4" style={{
|
||||||
|
height: isSearching ? 'calc(90vh - 40px)' : '90vh',
|
||||||
|
overflowY: 'auto',
|
||||||
|
overflowX: 'hidden'
|
||||||
|
}}>
|
||||||
|
<InfiniteLoading
|
||||||
|
target="scroll"
|
||||||
|
hasMore={hasMore}
|
||||||
|
onLoadMore={reloadMore}
|
||||||
|
onScroll={() => {
|
||||||
|
// 滚动事件处理
|
||||||
|
}}
|
||||||
|
onScrollToUpper={() => {
|
||||||
|
// 滚动到顶部事件处理
|
||||||
|
}}
|
||||||
|
loadingText={
|
||||||
|
<>
|
||||||
|
加载中...
|
||||||
|
</>
|
||||||
|
}
|
||||||
|
loadMoreText={
|
||||||
|
list.length === 0 ? (
|
||||||
|
<Empty
|
||||||
|
style={{backgroundColor: 'transparent'}}
|
||||||
|
description={loading ? "加载中..." : "暂无处方数据"}
|
||||||
|
/>
|
||||||
|
) : (
|
||||||
|
<View className={'h-3 flex items-center justify-center'}>
|
||||||
|
<Text className="text-gray-500 text-sm">没有更多了</Text>
|
||||||
|
</View>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
>
|
||||||
|
{loading && list.length === 0 ? (
|
||||||
|
<View className="flex items-center justify-center py-8">
|
||||||
|
<Loading/>
|
||||||
|
<Text className="text-gray-500 mt-2 ml-2">加载中...</Text>
|
||||||
|
</View>
|
||||||
|
) : (
|
||||||
|
list.map(renderPrescriptionItem)
|
||||||
|
)}
|
||||||
|
</InfiniteLoading>
|
||||||
|
</View>
|
||||||
|
</View>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
return (
|
||||||
|
<View className="min-h-screen bg-gray-50">
|
||||||
|
{/* 搜索栏 */}
|
||||||
|
<View className="bg-white py-2 border-b border-gray-100">
|
||||||
|
<SearchBar
|
||||||
|
value={searchValue}
|
||||||
|
placeholder="搜索处方编号、诊断结果"
|
||||||
|
onChange={(value) => setSearchValue(value)}
|
||||||
|
onClear={() => {
|
||||||
|
setSearchValue('');
|
||||||
|
setDisplaySearchValue('');
|
||||||
|
}}
|
||||||
|
clearable
|
||||||
|
/>
|
||||||
|
</View>
|
||||||
|
|
||||||
|
{/* 处方列表 */}
|
||||||
|
{renderPrescriptionList()}
|
||||||
|
</View>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default SelectPrescription;
|
||||||
@@ -3,21 +3,21 @@ import {View, Text, Image} from '@tarojs/components'
|
|||||||
import {Button, Loading} from '@nutui/nutui-react-taro'
|
import {Button, Loading} from '@nutui/nutui-react-taro'
|
||||||
import {Download, QrCode} from '@nutui/icons-react-taro'
|
import {Download, QrCode} from '@nutui/icons-react-taro'
|
||||||
import Taro from '@tarojs/taro'
|
import Taro from '@tarojs/taro'
|
||||||
import {useDealerUser} from '@/hooks/useDealerUser'
|
|
||||||
import {generateInviteCode} from '@/api/invite'
|
import {generateInviteCode} from '@/api/invite'
|
||||||
// import type {InviteStats} from '@/api/invite'
|
// import type {InviteStats} from '@/api/invite'
|
||||||
import {businessGradients} from '@/styles/gradients'
|
import {businessGradients} from '@/styles/gradients'
|
||||||
|
import {useUser} from "@/hooks/useUser";
|
||||||
|
|
||||||
const DealerQrcode: React.FC = () => {
|
const DealerQrcode: React.FC = () => {
|
||||||
const [miniProgramCodeUrl, setMiniProgramCodeUrl] = useState<string>('')
|
const [miniProgramCodeUrl, setMiniProgramCodeUrl] = useState<string>('')
|
||||||
const [loading, setLoading] = useState<boolean>(false)
|
const [loading, setLoading] = useState<boolean>(false)
|
||||||
// const [inviteStats, setInviteStats] = useState<InviteStats | null>(null)
|
// const [inviteStats, setInviteStats] = useState<InviteStats | null>(null)
|
||||||
// const [statsLoading, setStatsLoading] = useState<boolean>(false)
|
// const [statsLoading, setStatsLoading] = useState<boolean>(false)
|
||||||
const {dealerUser} = useDealerUser()
|
const {user} = useUser()
|
||||||
|
|
||||||
// 生成小程序码
|
// 生成小程序码
|
||||||
const generateMiniProgramCode = async () => {
|
const generateMiniProgramCode = async () => {
|
||||||
if (!dealerUser?.userId) {
|
if (!user?.userId) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -25,7 +25,7 @@ const DealerQrcode: React.FC = () => {
|
|||||||
setLoading(true)
|
setLoading(true)
|
||||||
|
|
||||||
// 生成邀请小程序码
|
// 生成邀请小程序码
|
||||||
const codeUrl = await generateInviteCode(dealerUser.userId)
|
const codeUrl = await generateInviteCode(user?.userId)
|
||||||
|
|
||||||
if (codeUrl) {
|
if (codeUrl) {
|
||||||
setMiniProgramCodeUrl(codeUrl)
|
setMiniProgramCodeUrl(codeUrl)
|
||||||
@@ -61,11 +61,11 @@ const DealerQrcode: React.FC = () => {
|
|||||||
|
|
||||||
// 初始化生成小程序码和获取统计数据
|
// 初始化生成小程序码和获取统计数据
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (dealerUser?.userId) {
|
if (user?.userId) {
|
||||||
generateMiniProgramCode()
|
generateMiniProgramCode()
|
||||||
// fetchInviteStats()
|
// fetchInviteStats()
|
||||||
}
|
}
|
||||||
}, [dealerUser?.userId])
|
}, [user?.userId])
|
||||||
|
|
||||||
// 保存小程序码到相册
|
// 保存小程序码到相册
|
||||||
const saveMiniProgramCode = async () => {
|
const saveMiniProgramCode = async () => {
|
||||||
@@ -162,7 +162,7 @@ const DealerQrcode: React.FC = () => {
|
|||||||
// })
|
// })
|
||||||
// }
|
// }
|
||||||
|
|
||||||
if (!dealerUser) {
|
if (!user) {
|
||||||
return (
|
return (
|
||||||
<View className="bg-gray-50 min-h-screen flex items-center justify-center">
|
<View className="bg-gray-50 min-h-screen flex items-center justify-center">
|
||||||
<Loading/>
|
<Loading/>
|
||||||
@@ -312,84 +312,6 @@ const DealerQrcode: React.FC = () => {
|
|||||||
</View>
|
</View>
|
||||||
</View>
|
</View>
|
||||||
</View>
|
</View>
|
||||||
|
|
||||||
{/* 邀请统计数据 */}
|
|
||||||
{/*<View className="bg-white rounded-2xl p-4 mt-4 mb-6">*/}
|
|
||||||
{/* <Text className="font-semibold text-gray-800 mb-3">我的邀请数据</Text>*/}
|
|
||||||
{/* {statsLoading ? (*/}
|
|
||||||
{/* <View className="flex items-center justify-center py-8">*/}
|
|
||||||
{/* <Loading/>*/}
|
|
||||||
{/* <Text className="text-gray-500 mt-2">加载中...</Text>*/}
|
|
||||||
{/* </View>*/}
|
|
||||||
{/* ) : inviteStats ? (*/}
|
|
||||||
{/* <View className="space-y-4">*/}
|
|
||||||
{/* <View className="grid grid-cols-2 gap-4">*/}
|
|
||||||
{/* <View className="text-center">*/}
|
|
||||||
{/* <Text className="text-2xl font-bold text-blue-500">*/}
|
|
||||||
{/* {inviteStats.totalInvites || 0}*/}
|
|
||||||
{/* </Text>*/}
|
|
||||||
{/* <Text className="text-sm text-gray-500">总邀请数</Text>*/}
|
|
||||||
{/* </View>*/}
|
|
||||||
{/* <View className="text-center">*/}
|
|
||||||
{/* <Text className="text-2xl font-bold text-green-500">*/}
|
|
||||||
{/* {inviteStats.successfulRegistrations || 0}*/}
|
|
||||||
{/* </Text>*/}
|
|
||||||
{/* <Text className="text-sm text-gray-500">成功注册</Text>*/}
|
|
||||||
{/* </View>*/}
|
|
||||||
{/* </View>*/}
|
|
||||||
|
|
||||||
{/* <View className="grid grid-cols-2 gap-4">*/}
|
|
||||||
{/* <View className="text-center">*/}
|
|
||||||
{/* <Text className="text-2xl font-bold text-purple-500">*/}
|
|
||||||
{/* {inviteStats.conversionRate ? `${(inviteStats.conversionRate * 100).toFixed(1)}%` : '0%'}*/}
|
|
||||||
{/* </Text>*/}
|
|
||||||
{/* <Text className="text-sm text-gray-500">转化率</Text>*/}
|
|
||||||
{/* </View>*/}
|
|
||||||
{/* <View className="text-center">*/}
|
|
||||||
{/* <Text className="text-2xl font-bold text-orange-500">*/}
|
|
||||||
{/* {inviteStats.todayInvites || 0}*/}
|
|
||||||
{/* </Text>*/}
|
|
||||||
{/* <Text className="text-sm text-gray-500">今日邀请</Text>*/}
|
|
||||||
{/* </View>*/}
|
|
||||||
{/* </View>*/}
|
|
||||||
|
|
||||||
{/* /!* 邀请来源统计 *!/*/}
|
|
||||||
{/* {inviteStats.sourceStats && inviteStats.sourceStats.length > 0 && (*/}
|
|
||||||
{/* <View className="mt-4">*/}
|
|
||||||
{/* <Text className="text-sm font-medium text-gray-700 mb-2">邀请来源分布</Text>*/}
|
|
||||||
{/* <View className="space-y-2">*/}
|
|
||||||
{/* {inviteStats.sourceStats.map((source, index) => (*/}
|
|
||||||
{/* <View key={index} className="flex items-center justify-between py-2 px-3 bg-gray-50 rounded-lg">*/}
|
|
||||||
{/* <View className="flex items-center">*/}
|
|
||||||
{/* <View className="w-3 h-3 rounded-full bg-blue-500 mr-2"></View>*/}
|
|
||||||
{/* <Text className="text-sm text-gray-700">{source.source}</Text>*/}
|
|
||||||
{/* </View>*/}
|
|
||||||
{/* <View className="text-right">*/}
|
|
||||||
{/* <Text className="text-sm font-medium text-gray-800">{source.count}</Text>*/}
|
|
||||||
{/* <Text className="text-xs text-gray-500">*/}
|
|
||||||
{/* {source.conversionRate ? `${(source.conversionRate * 100).toFixed(1)}%` : '0%'}*/}
|
|
||||||
{/* </Text>*/}
|
|
||||||
{/* </View>*/}
|
|
||||||
{/* </View>*/}
|
|
||||||
{/* ))}*/}
|
|
||||||
{/* </View>*/}
|
|
||||||
{/* </View>*/}
|
|
||||||
{/* )}*/}
|
|
||||||
{/* </View>*/}
|
|
||||||
{/* ) : (*/}
|
|
||||||
{/* <View className="text-center py-8">*/}
|
|
||||||
{/* <View className="text-gray-500">暂无邀请数据</View>*/}
|
|
||||||
{/* <Button*/}
|
|
||||||
{/* size="small"*/}
|
|
||||||
{/* type="primary"*/}
|
|
||||||
{/* className="mt-2"*/}
|
|
||||||
{/* onClick={fetchInviteStats}*/}
|
|
||||||
{/* >*/}
|
|
||||||
{/* 刷新数据*/}
|
|
||||||
{/* </Button>*/}
|
|
||||||
{/* </View>*/}
|
|
||||||
{/* )}*/}
|
|
||||||
{/*</View>*/}
|
|
||||||
</View>
|
</View>
|
||||||
</View>
|
</View>
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -405,7 +405,7 @@ const DealerTeam: React.FC = () => {
|
|||||||
if (!dealerUser) {
|
if (!dealerUser) {
|
||||||
return (
|
return (
|
||||||
<Space className="flex items-center justify-center">
|
<Space className="flex items-center justify-center">
|
||||||
<Empty description="您还不是业务人员" style={{
|
<Empty description="您还不是医生" style={{
|
||||||
backgroundColor: 'transparent'
|
backgroundColor: 'transparent'
|
||||||
}} actions={[{text: '立即申请', onClick: () => navTo(`/doctor/apply/add`, true)}]}
|
}} actions={[{text: '立即申请', onClick: () => navTo(`/doctor/apply/add`, true)}]}
|
||||||
/>
|
/>
|
||||||
|
|||||||
@@ -64,7 +64,7 @@ const IsDealer = () => {
|
|||||||
<View style={{display: 'inline-flex', alignItems: 'center'}}>
|
<View style={{display: 'inline-flex', alignItems: 'center'}}>
|
||||||
<Reward className={'text-orange-100 '} size={16}/>
|
<Reward className={'text-orange-100 '} size={16}/>
|
||||||
<Text style={{fontSize: '16px'}}
|
<Text style={{fontSize: '16px'}}
|
||||||
className={'pl-3 text-orange-100 font-medium'}>A{config?.vipText || '入驻申请'}</Text>
|
className={'pl-3 text-orange-100 font-medium'}>{config?.vipText || '入驻申请'}</Text>
|
||||||
{/*<Text className={'text-white opacity-80 pl-3'}>门店核销</Text>*/}
|
{/*<Text className={'text-white opacity-80 pl-3'}>门店核销</Text>*/}
|
||||||
</View>
|
</View>
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user