<template>
  <div>
    <span>
      <el-select v-model="attributeValue.value" :placeholder="placeholder">
        <el-option
          v-for="option in options"
          :key="option.value"
          :label="option.name"
          :value="option.value"
        >
        </el-option>
      </el-select>
    </span>
  </div>
</template>
<script lang="ts">
import { Options, Vue } from "vue-class-component";
import { Prop } from "vue-property-decorator";
import { Attribute } from "@/model/Element";
import { AttributeValue } from "@/model/Attribute";
import SwtionElement from "@/plugins/element";
import SwtionAttribute from "@/plugins/attribute";
@Options({})
export default class scCheckbox extends Vue {
  @Prop({
    default: new AttributeValue(),
  })
  public attributeValue?: any;
  @Prop({
    default: "0",
    type: String,
  })
  public elementId!: string;
  @Prop({
    default: "self",
    type: String,
  })
  public type!: keyof Attribute;
  @Prop({
    default: "请选择",
    type: String,
  })
  public placeholder?: string;
  public swtionEle = new SwtionElement();
  public swtionAttr = new SwtionAttribute();
  public options=[];
  // public value = [];
  created() {
    let node = this.swtionEle.findTreeNode(this.elementId);
    let attributeList = node.attribute[this.type];
    this.options = this.swtionAttr.findAttributeValueById(
      this.attributeValue ? this.attributeValue.id : "0",
      attributeList
    ).options;
  }
}
</script>
