cu-shop-invoice-selector
开票信息选择面板:发票类型(不开票 / 普票 / 专票)、抬头单选、收票人单选、开票内容与邮箱,自带 `none` / `normal` / `special` 三套校验;抬头与收票人只做选择,编辑位只发事件。
实时预览
演示页:/pages/shop-order/invoice-selector。右侧的预览由站点脚本把 H5 演示页装进 iframe;数据与交互在演示页内操作,不在此处留静态截图。
依赖
- 基础件:
cu-radio、cu-input、cu-button、cu-loading-icon - Shop 共享件:
locale/index.uts(cuShopT)
全量契约
props
| 参数 | 说明 | 类型 | 默认值 |
|---|---|---|---|
| value | 选择结果,按 ShopInvoiceSelection 读;type 认 none / normal / special | Object | { type: 'none', content: 'detail', titleId: '', receiveInvoiceId: '', email: '' } |
| titles | 抬头列表,元素读 id / title / titleType / type / isDefault | Array | [] |
| receives | 收票人列表,元素读 id / name / phone / province / city / district / detail / isDefault | Array | [] |
| contents | 开票内容选项;元素认枚举 detail / category,也认标签「商品明细」/「商品类别」 | Array | ['商品明细'] |
| loading | 加载中替换主体,只保留 header / footer 插槽 | boolean | false |
| customStyle | 根节点自定义样式 | Object | {} |
| customClass | 根节点自定义类名 | string | '' |
| url | 透传字段,本件未接线 | string | '' |
| linkType | 透传字段,本件未接线 | string | 'navigateTo' |
events
| 事件 | 说明 | 载荷 |
|---|---|---|
| @update:value | 切类型 / 选抬头 / 选收票人 / 选开票内容 / 改邮箱 | { type, content, titleId, receiveInvoiceId, email } |
| @click-title | 点抬头行尾「编辑」 | { item, index } |
| @click-receive | 点收票人行尾「编辑」 | { item, index } |
| @submit | 点提交;errors 为错误码数组,见注意事项 | { data, valid, errors } |
slots
| 插槽 | 作用域 | 说明 |
|---|---|---|
| header | 无 | 面板顶部 |
| footer | 无 | 面板底部 |
代码示例
<cu-shop-invoice-selector :value="selection" :titles="titles" :receives="receives"
:contents="['商品明细', '商品类别']" :loading="loading"
@update:value="onUpdateValue" @click-title="onClickTitle" @click-receive="onClickReceive"
@submit="onSubmit">
<template #header><text>开票信息仅在订单完成后开具</text></template>
<template #footer><text>电子发票将发送至所填邮箱</text></template>
</cu-shop-invoice-selector>
注意事项
type=none 时隐藏抬头 / 收票人 / 开票内容 / 邮箱四段;提交 valid=true、errors=[]。
special 须企业抬头(titleType=company):选中个人抬头记 titleCompany;企业抬头再逐项校验 taxNo / bankName / bankAccount / companyAddress / companyPhone,缺失分别记同名字段码。
未选抬头记 title;normal 邮箱 trim 后为空记 email,邮箱只校验非空、不校验格式。
contents 元素归一为枚举写进 content;认不出的字符串原样输出。
字段名以数据字典 ShopInvoiceSelection.receiveInvoiceId 为准(方案 §6.7 的 receiveId 不作准)。
抬头与收票人只做选择,行尾「编辑」只 emit click-title / click-receive,组件内不展开编辑表单。
错误只在提交后以汇总列表展示,字段旁无红点;切换类型与抬头会清空上一次错误。
不请求接口、不持久化、不弹 toast。
安装 colorui-shop 全量包与安装任意 cu-shop-* 单件包二选一,不要同时装。单件包的前提是已安装完整 colorui-x。