
<template>
  <div>
    <template v-for="(item, index) in options">
      <template v-if="values.includes(item.value)">
        <span :style="{ color: color, background: bgc }" v-if="item.elTagType == 'default' || item.elTagType == '' || tag == false
        " :key="item.value" :index="index" :class="item.elTagType">{{ item.label }}</span>
        <el-tag v-else :style="{ color: color, background: bgc }" :disable-transitions="true" :key="item.value + ''"
          :index="index" :type="item.elTagType === 'primary' ? '' : item.elTagType" :class="item.elTagType">{{
            item.label
          }}</el-tag>
      </template>
    </template>
  </div>
</template>

<script setup>
import { computed } from "vue";

const props = defineProps({
  // 数据
  options: {
    type: Array,
    default: null
  },
  tag: false,
  value: [Number, String, Array],
  color: {
    type: String,
    default: '#000'
  },
  bgc: {
    type: String,
    default: 'rgba(0,0,0,0)'
  },
});
const values = computed(() => {
  if (props.value !== null && typeof props.value !== "undefined") {
    return Array.isArray(props.value) ? props.value : [String(props.value)];
  } else {
    return [];
  }
});
</script>