修复体检中心登录与表单

This commit is contained in:
xianyi
2026-02-02 10:06:20 +08:00
parent db6a8bc97f
commit e2158286be
2 changed files with 28 additions and 14 deletions

View File

@@ -101,7 +101,7 @@ export const ExamAddonPanel = ({ client, onGoToSign }: ExamAddonPanelProps) => {
const [customSettlementLoading, setCustomSettlementLoading] = useState(false);
const [customSettlementType, setCustomSettlementType] = useState<1 | 2>(1); // 1-按比例折扣 2-自定义结算价
const [customDiscountRatio, setCustomDiscountRatio] = useState<number | null>(null); // 折扣比例如100代表10折即原价
const [customFinalPrice, setCustomFinalPrice] = useState<number>(0); // 最终结算价
const [customFinalPrice, setCustomFinalPrice] = useState<number | null>(null); // 最终结算价
const [customApplyReason, setCustomApplyReason] = useState<string>(''); // 申请理由
const [waitingSeconds, setWaitingSeconds] = useState<number>(0); // 等待审核的秒数
const waitingTimerRef = useRef<number | null>(null); // 等待计时器
@@ -111,11 +111,15 @@ export const ExamAddonPanel = ({ client, onGoToSign }: ExamAddonPanelProps) => {
// 已通过(3) 或 已拒绝(4) 且 add_item_id 匹配才需要回显
if ((customSettlementStatus.apply_status === 3 || customSettlementStatus.apply_status === 4) &&
customSettlementStatus.add_item_id === currentAddItemId) {
if (customSettlementStatus.settlement_type === 1 || customSettlementStatus.settlement_type === 2) {
// 如果 discount_ratio 为 0说明是自定义结算价模式
if (customSettlementStatus.discount_ratio === 0) {
setCustomSettlementType(2);
} else if (customSettlementStatus.settlement_type === 1 || customSettlementStatus.settlement_type === 2) {
setCustomSettlementType(customSettlementStatus.settlement_type as 1 | 2);
}
if (typeof customSettlementStatus.discount_ratio === 'number') {
setCustomDiscountRatio(customSettlementStatus.discount_ratio);
setCustomDiscountRatio(customSettlementStatus.discount_ratio || null);
}
if (typeof customSettlementStatus.final_settlement_price === 'number') {
setCustomFinalPrice(customSettlementStatus.final_settlement_price);
@@ -127,7 +131,7 @@ export const ExamAddonPanel = ({ client, onGoToSign }: ExamAddonPanelProps) => {
// 其他状态(如取消后再点开)重置表单为默认值
setCustomSettlementType(1);
setCustomDiscountRatio(null);
setCustomFinalPrice(0);
setCustomFinalPrice(null);
setCustomApplyReason('');
}
}
@@ -529,7 +533,7 @@ export const ExamAddonPanel = ({ client, onGoToSign }: ExamAddonPanelProps) => {
setCustomSettlementStatus(null);
setCustomSettlementType(1);
setCustomDiscountRatio(null);
setCustomFinalPrice(0);
setCustomFinalPrice(null);
setCustomApplyReason('');
lastFetchStatusTimeRef.current = 0; // 强制立即发起新请求
@@ -605,6 +609,7 @@ export const ExamAddonPanel = ({ client, onGoToSign }: ExamAddonPanelProps) => {
// 提交自定义结算申请
const handleSubmitCustomSettlement = async () => {
const physical_exam_id = Number(client.id);
if (!physical_exam_id || selectedItems.length === 0) {
setPaymentMessage('请先选择加项项目');
@@ -641,7 +646,7 @@ export const ExamAddonPanel = ({ client, onGoToSign }: ExamAddonPanelProps) => {
settlementPrice = originalPrice * (discountRatioValue / 100);
} else {
// 自定义结算价
settlementPrice = customFinalPrice / selectedItems.length; // 平均分配
settlementPrice = (customFinalPrice ?? 0) / selectedItems.length; // 平均分配
}
return {
@@ -659,12 +664,12 @@ export const ExamAddonPanel = ({ client, onGoToSign }: ExamAddonPanelProps) => {
const final_settlement_price = customSettlementType === 1
? original_settlement_price * (discountRatioValue / 100)
: customFinalPrice;
: (customFinalPrice ?? 0);
const apply_user = localStorage.getItem('operatorName');
if (!apply_user) {
setPaymentMessage('请先登录');
alert('请先登录');
window.location.href = '/home';
return;
}
const res = await customSettlementApply({
@@ -673,7 +678,7 @@ export const ExamAddonPanel = ({ client, onGoToSign }: ExamAddonPanelProps) => {
original_settlement_price,
settlement_type: customSettlementType,
discount_ratio: customSettlementType === 1 ? discountRatioValue : undefined,
final_settlement_price,
final_settlement_price: final_settlement_price ?? undefined,
apply_reason: customApplyReason.trim(),
apply_user,
});
@@ -684,7 +689,7 @@ export const ExamAddonPanel = ({ client, onGoToSign }: ExamAddonPanelProps) => {
// 重置表单
setCustomSettlementType(1);
setCustomDiscountRatio(100);
setCustomFinalPrice(0);
setCustomFinalPrice(null);
setCustomApplyReason('');
// 重新获取审批状态并开始轮询
setTimeout(() => {
@@ -1198,7 +1203,7 @@ export const ExamAddonPanel = ({ client, onGoToSign }: ExamAddonPanelProps) => {
{/* 添加自定义结算 */}
{localStorage.getItem('authCode')?.includes('HisTijianPad_Btn_Tongji') && selectedItems.length > 0 && (
{localStorage.getItem('authCode')?.includes('HisTijian_Btn_JiesuanShenqing') && selectedItems.length > 0 && (
<div className='flex flex-col items-end gap-2 relative'>
<Button
onClick={() => setShowCustomSettlementModal(true)}
@@ -1502,9 +1507,16 @@ export const ExamAddonPanel = ({ client, onGoToSign }: ExamAddonPanelProps) => {
min='0'
step='0.01'
disabled={isApprovedOrRejected}
value={customFinalPrice || ''}
value={customFinalPrice ?? ''}
onChange={(e) => {
const val = Number(e.target.value);
const rawValue = e.target.value;
if (rawValue === '') {
setCustomFinalPrice(null);
return;
}
const val = Number(rawValue);
if (val >= 0) {
setCustomFinalPrice(val);
}

View File

@@ -22,6 +22,8 @@ export const ExamPage = () => {
useEffect(() => {
const token = localStorage.getItem('accessToken');
if (!token) {
// 跳转登录
window.location.href = '/home';
return;
}
getUserOwnedMenus({ app_id: APP_ID })