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