@@ -26,6 +26,24 @@ const ACTION_ICONS = {
|
||||
|
||||
type EditDraft = UpsertInvoiceTitleRequest & { id?: string };
|
||||
|
||||
function FieldLabel({
|
||||
children,
|
||||
required,
|
||||
hint,
|
||||
}: {
|
||||
children: string;
|
||||
required?: boolean;
|
||||
hint?: string;
|
||||
}) {
|
||||
return (
|
||||
<Text className="invoice-title-label">
|
||||
{required ? <Text className="invoice-title-star">*</Text> : null}
|
||||
{children}
|
||||
{hint ? <Text className="invoice-title-label-hint">{hint}</Text> : null}
|
||||
</Text>
|
||||
);
|
||||
}
|
||||
|
||||
function TitleActionIcon({
|
||||
kind,
|
||||
label,
|
||||
@@ -120,6 +138,15 @@ export default function InvoiceTitlesPage() {
|
||||
toast('企业抬头须填写税号');
|
||||
return;
|
||||
}
|
||||
const email = draft.email?.trim() || '';
|
||||
if (!email) {
|
||||
toast('请填写接收邮箱(必填)');
|
||||
return;
|
||||
}
|
||||
if (!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(email)) {
|
||||
toast('邮箱格式不正确');
|
||||
return;
|
||||
}
|
||||
setSaving(true);
|
||||
try {
|
||||
const payload: UpsertInvoiceTitleRequest = {
|
||||
@@ -152,6 +179,10 @@ export default function InvoiceTitlesPage() {
|
||||
}
|
||||
|
||||
async function setDefault(t: UserInvoiceTitleDto) {
|
||||
if (!t.email?.trim()) {
|
||||
toast('请先补全接收邮箱后再设为默认');
|
||||
return;
|
||||
}
|
||||
try {
|
||||
await request(`/trade/invoice-titles/${t.id}`, {
|
||||
method: 'PUT',
|
||||
@@ -241,7 +272,7 @@ export default function InvoiceTitlesPage() {
|
||||
</Text>
|
||||
|
||||
<View className="invoice-title-field">
|
||||
<Text className="invoice-title-label">抬头类型</Text>
|
||||
<FieldLabel required>抬头类型</FieldLabel>
|
||||
<View className="invoice-title-type-row">
|
||||
{(['PERSONAL', 'ENTERPRISE'] as InvoiceTitleType[]).map((tp) => (
|
||||
<Text
|
||||
@@ -258,7 +289,7 @@ export default function InvoiceTitlesPage() {
|
||||
</View>
|
||||
|
||||
<View className="invoice-title-field">
|
||||
<Text className="invoice-title-label">抬头名称</Text>
|
||||
<FieldLabel required>抬头名称</FieldLabel>
|
||||
<Input
|
||||
className="invoice-title-input"
|
||||
maxlength={128}
|
||||
@@ -270,7 +301,7 @@ export default function InvoiceTitlesPage() {
|
||||
|
||||
{draft.titleType === 'ENTERPRISE' ? (
|
||||
<View className="invoice-title-field">
|
||||
<Text className="invoice-title-label">税号</Text>
|
||||
<FieldLabel required>税号</FieldLabel>
|
||||
<Input
|
||||
className="invoice-title-input"
|
||||
maxlength={32}
|
||||
@@ -282,11 +313,13 @@ export default function InvoiceTitlesPage() {
|
||||
) : null}
|
||||
|
||||
<View className="invoice-title-field">
|
||||
<Text className="invoice-title-label">接收邮箱</Text>
|
||||
<FieldLabel required hint="必填,电子发票将发送至此">
|
||||
接收邮箱
|
||||
</FieldLabel>
|
||||
<Input
|
||||
className="invoice-title-input"
|
||||
maxlength={128}
|
||||
placeholder="电子发票将发送至此邮箱"
|
||||
placeholder="请填写邮箱(必填)"
|
||||
value={draft.email || ''}
|
||||
onInput={(e) => setDraft({ ...draft, email: e.detail.value })}
|
||||
/>
|
||||
@@ -311,7 +344,7 @@ export default function InvoiceTitlesPage() {
|
||||
<Input
|
||||
className="invoice-title-input"
|
||||
maxlength={256}
|
||||
placeholder="专用发票需要,选填"
|
||||
placeholder="选填"
|
||||
value={draft.addressPhone || ''}
|
||||
onInput={(e) => setDraft({ ...draft, addressPhone: e.detail.value })}
|
||||
/>
|
||||
@@ -321,7 +354,7 @@ export default function InvoiceTitlesPage() {
|
||||
<Input
|
||||
className="invoice-title-input"
|
||||
maxlength={256}
|
||||
placeholder="专用发票需要,选填"
|
||||
placeholder="选填"
|
||||
value={draft.bankAccount || ''}
|
||||
onInput={(e) => setDraft({ ...draft, bankAccount: e.detail.value })}
|
||||
/>
|
||||
|
||||
Reference in New Issue
Block a user