Components
BaseLineItemsEditor
An editable list of invoice or quote lines with amounts, add and remove, and total rows.
components/ui/BaseLineItemsEditor.vue
View in the demo
Example
Put it inside the v-form of an editor: the description is required and the price must be positive, so the form's validate() covers every line. Prices take the default currency's symbol and amounts are formatted with it. The totals are yours to compute (discount, tax, shipping) and pass already formatted; a control.<id> slot adds a field to that row, as the invoice editor does with its discount and VAT selects. When the container is narrower than 520px each line stacks: the description on its own row, then quantity, price, amount and remove. Pair it with BaseDocument for a live preview of the same lines.
API
Props
Name | Type | Default | Description |
|---|---|---|---|
v-modelrequired | BaseLineItem[] | — | The lines, each { description, quantity, price } (BaseLineItem). Bind it with v-model; the amount of a line is quantity × price. |
totals | BaseLineItemsTotal[] | [] | Rows under the lines, each { id, label, value, strong? } with the value already formatted. strong sets the final total apart with a divider. |
description-label | string | — | The label and placeholder of the description field. Defaults to "Description". |
add-text | string | — | The text of the add button. Defaults to "Add item". |
min-lines | number | 1 | The fewest lines the list keeps; the remove button is disabled at that count. |
Events
Name | Payload | Description |
|---|---|---|
@update:modelValue | [value: BaseLineItem[]] | — |