index.vue 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. <template>
  2. <div>
  3. <template v-for="(item, index) in options">
  4. <template v-if="values.includes(item.value)">
  5. <el-tag
  6. v-if="item.raw.listClass == 'default' || item.raw.listClass == ''"
  7. type="primary"
  8. :size="size"
  9. :key="item.value"
  10. :index="index"
  11. :class="item.raw.cssClass"
  12. >{{ item.label }}</el-tag
  13. >
  14. <el-tag
  15. v-else
  16. :disable-transitions="true"
  17. :key="item.value"
  18. :index="index"
  19. :size="size"
  20. :type="item.raw.listClass == 'primary' ? '' : item.raw.listClass"
  21. :class="item.raw.cssClass"
  22. >
  23. {{ item.label }}
  24. </el-tag>
  25. </template>
  26. </template>
  27. </div>
  28. </template>
  29. <script>
  30. export default {
  31. name: "DictTag",
  32. props: {
  33. options: {
  34. type: Array,
  35. default: null,
  36. },
  37. value: [Number, String, Array,Boolean],
  38. size: String,
  39. },
  40. computed: {
  41. values() {
  42. if (this.value !== null && typeof this.value !== "undefined") {
  43. return Array.isArray(this.value) ? this.value : [String(this.value)];
  44. } else {
  45. return [];
  46. }
  47. },
  48. },
  49. };
  50. </script>
  51. <style scoped>
  52. .el-tag + .el-tag {
  53. margin-left: 10px;
  54. }
  55. </style>