tags.jsx 783 B

12345678910111213141516171819202122232425262728293031323334
  1. import { ElTag } from 'element-plus'
  2. const SelectTags = (props, { emit }) => {
  3. const valueKey = props.optionProps.value
  4. const labelKey = props.optionProps.label
  5. const getLabel = (row) => typeof props.optionProps.getLabel === 'function'
  6. ? props.optionProps.getLabel(row)
  7. : row[labelKey]
  8. return <>
  9. {
  10. props.modelValue.map((v, index) => <ElTag
  11. class={'cip-select-table__tag'}
  12. type={'info'}
  13. key={v[valueKey]}
  14. closable={true}
  15. onClose={() => emit('remove', index)}
  16. >
  17. {getLabel(v)}
  18. </ElTag>)
  19. }
  20. </>
  21. }
  22. SelectTags.props = {
  23. modelValue: {
  24. type: Array,
  25. default: () => []
  26. },
  27. optionProps: {
  28. type: Object
  29. },
  30. multiple: Boolean
  31. }
  32. SelectTags.emits = ['remove']
  33. export default SelectTags