in packages/element/src/array-table/index.ts [241:319]
setup(props) {
const fieldRef = useField<ArrayField>()
const prefixCls = `${stylePrefix}-array-table`
return () => {
const field = fieldRef.value
const width = String(props.options?.length).length * 15
const errors = field.errors
const parseIndex = (address: string) => {
return Number(
address
.slice(address.indexOf(field.address.toString()) + 1)
.match(/(\d+)/)?.[1]
)
}
return h(
Select,
{
style: {
width: `${width < 60 ? 60 : width}px`,
},
class: [
`${prefixCls}-status-select`,
{
'has-error': errors?.length,
},
],
props: {
value: props.value,
popperClass: `${prefixCls}-status-select-dropdown`,
},
on: {
input: props.onChange,
},
},
{
default: () => {
return props.options?.map(({ label, value }) => {
const hasError = errors.some(({ address }) => {
const currentIndex = parseIndex(address)
const startIndex = (value - 1) * props.pageSize
const endIndex = value * props.pageSize
return currentIndex >= startIndex && currentIndex <= endIndex
})
return h(
Option,
{
key: value,
props: {
label,
value,
},
},
{
default: () => {
if (hasError) {
return h(
Badge,
{
props: {
isDot: true,
},
},
{ default: () => label }
)
}
return label
},
}
)
})
},
}
)
}
},