取消默认挂账公司
This commit is contained in:
@@ -50,7 +50,7 @@ export const ExamAddonPanel = ({ client, onGoToSign }: ExamAddonPanelProps) => {
|
||||
const [isPaymentMethodDropdownOpen, setIsPaymentMethodDropdownOpen] = useState(false);
|
||||
const paymentMethodDropdownRef = useRef<HTMLDivElement>(null);
|
||||
// 挂账公司
|
||||
const [accountCompany, setAccountCompany] = useState<string>('圆和');
|
||||
const [accountCompany, setAccountCompany] = useState<string>('');
|
||||
const [isAccountCompanyDropdownOpen, setIsAccountCompanyDropdownOpen] = useState(false);
|
||||
const [accountCompanySearch, setAccountCompanySearch] = useState('');
|
||||
const accountCompanyDropdownRef = useRef<HTMLDivElement>(null);
|
||||
@@ -139,11 +139,6 @@ export const ExamAddonPanel = ({ client, onGoToSign }: ExamAddonPanelProps) => {
|
||||
const res = await getChannelCompanyList({});
|
||||
if (res.Status === 200 && Array.isArray(res.Data) && res.Data.length > 0) {
|
||||
setAccountCompanyList(res.Data);
|
||||
// 设置默认值为第一个公司
|
||||
const firstCompany = res.Data[0];
|
||||
if (firstCompany?.company_name) {
|
||||
setAccountCompany(firstCompany.company_name);
|
||||
}
|
||||
} else {
|
||||
setAccountCompanyList([]);
|
||||
}
|
||||
@@ -156,16 +151,14 @@ export const ExamAddonPanel = ({ client, onGoToSign }: ExamAddonPanelProps) => {
|
||||
fetchCompanyList();
|
||||
}, []);
|
||||
|
||||
// 当挂账公司列表更新时,确保当前选中的公司在列表中
|
||||
// 当挂账公司列表更新时,如果当前选中的公司不在列表中,清空选择
|
||||
useEffect(() => {
|
||||
if (accountCompanyList.length > 0) {
|
||||
if (accountCompany && accountCompanyList.length > 0) {
|
||||
const companyNames = accountCompanyList.map((c) => c.company_name).filter(Boolean) as string[];
|
||||
if (!companyNames.includes(accountCompany)) {
|
||||
// 如果当前选中的公司不在列表中,更新为第一个公司
|
||||
const firstCompany = accountCompanyList[0];
|
||||
if (firstCompany?.company_name) {
|
||||
setAccountCompany(firstCompany.company_name);
|
||||
}
|
||||
// 如果当前选中的公司不在列表中,清空选择
|
||||
setAccountCompany('');
|
||||
setAccountCompanySearch('');
|
||||
}
|
||||
}
|
||||
}, [accountCompanyList, accountCompany]);
|
||||
@@ -543,6 +536,15 @@ export const ExamAddonPanel = ({ client, onGoToSign }: ExamAddonPanelProps) => {
|
||||
}
|
||||
} else {
|
||||
// 挂账模式:直接查询
|
||||
// 验证是否选择了挂账公司
|
||||
console.log('accountCompany', accountCompany);
|
||||
|
||||
if (!accountCompany || accountCompany.trim() === '') {
|
||||
setPaymentMessage('请选择挂账公司');
|
||||
setPaymentLoading(false);
|
||||
return;
|
||||
}
|
||||
|
||||
const selectedCompany = accountCompanyList.find(
|
||||
(c) => c.company_name === accountCompany
|
||||
);
|
||||
@@ -834,7 +836,7 @@ export const ExamAddonPanel = ({ client, onGoToSign }: ExamAddonPanelProps) => {
|
||||
setAccountCompanySearch(e.target.value);
|
||||
setIsAccountCompanyDropdownOpen(true);
|
||||
}}
|
||||
placeholder={accountCompany || '请输入公司名称'}
|
||||
placeholder={'请输入公司名称'}
|
||||
className='w-full outline-none text-xs bg-transparent'
|
||||
/>
|
||||
<span className={cls('text-gray-400 transition-transform text-[10px]', isAccountCompanyDropdownOpen && 'rotate-180')}>
|
||||
|
||||
Reference in New Issue
Block a user