@@ -7,9 +7,9 @@ import SubPageHeader from '../../components/SubPageHeader';
|
||||
import { request, toast } from '../../lib/api';
|
||||
import { usePageView } from '../../lib/usePageView';
|
||||
import {
|
||||
INVOICE_KIND_LABELS,
|
||||
INVOICE_CATEGORY_LABELS,
|
||||
INVOICE_TITLE_TYPE_LABELS,
|
||||
type InvoiceKind,
|
||||
type InvoiceCategory,
|
||||
type UserInvoiceTitleDto,
|
||||
} from '@dukang/shared-types';
|
||||
|
||||
@@ -42,7 +42,8 @@ export default function InvoiceApplyPage() {
|
||||
|
||||
const [titles, setTitles] = useState<UserInvoiceTitleDto[]>([]);
|
||||
const [selectedId, setSelectedId] = useState('');
|
||||
const [invoiceKind, setInvoiceKind] = useState<InvoiceKind>('NORMAL');
|
||||
const [invoiceCategory, setInvoiceCategory] = useState<InvoiceCategory>('LIQUOR');
|
||||
const [remark, setRemark] = useState('');
|
||||
const [emailOverride, setEmailOverride] = useState('');
|
||||
const [phoneOverride, setPhoneOverride] = useState('');
|
||||
const [loading, setLoading] = useState(true);
|
||||
@@ -103,19 +104,17 @@ export default function InvoiceApplyPage() {
|
||||
toast('请填写联系电话');
|
||||
return;
|
||||
}
|
||||
if (invoiceKind === 'SPECIAL' && selected.titleType !== 'ENTERPRISE') {
|
||||
toast('专用发票仅支持企业抬头');
|
||||
return;
|
||||
}
|
||||
setSubmitting(true);
|
||||
try {
|
||||
await request(`/trade/orders/${orderId}/invoices`, {
|
||||
method: 'POST',
|
||||
data: {
|
||||
titleId: selectedId,
|
||||
invoiceKind,
|
||||
invoiceKind: 'NORMAL',
|
||||
invoiceCategory,
|
||||
email,
|
||||
phone,
|
||||
remark: remark.trim() || undefined,
|
||||
},
|
||||
});
|
||||
toast('发票申请已提交', 'success');
|
||||
@@ -192,20 +191,26 @@ export default function InvoiceApplyPage() {
|
||||
) : null}
|
||||
|
||||
{canApply ? (
|
||||
<View className="invoice-title-field" style={{ marginBottom: 16 }}>
|
||||
<Text className="invoice-title-label">发票类型</Text>
|
||||
<View className="invoice-title-type-row">
|
||||
{(['NORMAL', 'SPECIAL'] as InvoiceKind[]).map((k) => (
|
||||
<Text
|
||||
key={k}
|
||||
className={`invoice-title-type-chip${invoiceKind === k ? ' active' : ''}`}
|
||||
onClick={() => setInvoiceKind(k)}
|
||||
>
|
||||
{INVOICE_KIND_LABELS[k]}
|
||||
</Text>
|
||||
))}
|
||||
<>
|
||||
<View className="invoice-title-field" style={{ marginBottom: 16 }}>
|
||||
<Text className="invoice-title-label">发票类型</Text>
|
||||
<Text className="invoice-kind-static">增值税普通发票</Text>
|
||||
</View>
|
||||
</View>
|
||||
<View className="invoice-title-field" style={{ marginBottom: 16 }}>
|
||||
<Text className="invoice-title-label">类型</Text>
|
||||
<View className="invoice-title-type-row">
|
||||
{(['LIQUOR', 'CATERING'] as InvoiceCategory[]).map((k) => (
|
||||
<Text
|
||||
key={k}
|
||||
className={`invoice-title-type-chip${invoiceCategory === k ? ' active' : ''}`}
|
||||
onClick={() => setInvoiceCategory(k)}
|
||||
>
|
||||
{INVOICE_CATEGORY_LABELS[k]}
|
||||
</Text>
|
||||
))}
|
||||
</View>
|
||||
</View>
|
||||
</>
|
||||
) : null}
|
||||
|
||||
{canApply ? (
|
||||
@@ -258,7 +263,11 @@ export default function InvoiceApplyPage() {
|
||||
|
||||
{canApply && selected && !selected.email ? (
|
||||
<View className="invoice-title-field" style={{ marginTop: 16 }}>
|
||||
<Text className="invoice-title-label">接收邮箱</Text>
|
||||
<Text className="invoice-title-label">
|
||||
<Text className="invoice-title-star">*</Text>
|
||||
接收邮箱
|
||||
<Text className="invoice-title-label-hint">必填</Text>
|
||||
</Text>
|
||||
<Input
|
||||
className="invoice-title-input"
|
||||
placeholder="电子发票将发送至此邮箱"
|
||||
@@ -279,6 +288,19 @@ export default function InvoiceApplyPage() {
|
||||
/>
|
||||
</View>
|
||||
) : null}
|
||||
|
||||
{canApply ? (
|
||||
<View className="invoice-title-field" style={{ marginTop: 16 }}>
|
||||
<Text className="invoice-title-label">备注</Text>
|
||||
<Input
|
||||
className="invoice-title-input"
|
||||
maxlength={200}
|
||||
placeholder="选填,将显示在发票申请备注中"
|
||||
value={remark}
|
||||
onInput={(e) => setRemark(e.detail.value)}
|
||||
/>
|
||||
</View>
|
||||
) : null}
|
||||
</View>
|
||||
|
||||
{canApply && titles.length > 0 ? (
|
||||
|
||||
Reference in New Issue
Block a user