index.vue 1.1 KB

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