import { elementAttributeType } from "@/enums/attribute";
import { CollectElement } from "./Element";
export class AttributeValue implements IAttributeValue {
  constructor(value?: IAttributeValue) {
    if (value) {
      this.name = value.name;
      this.id = value.id;
      this.options = value.options;
      this.type = value.type;
      this.value = value.value;
      this.prop = value.prop;
      this.ref = value.ref;
    }
  }
  private _name = "";
  private _type = elementAttributeType.input;
  private _ref = new CollectElement();
  private _value = "";
  private _id = "";
  private _options = new Array<IOption>();
  private _prop: any;
  private _parentId = "";
  /**编号 */
  get id() {
    return this._id;
  }
  set id(v: string) {
    this._id = v;
  }
  /**名称 */
  get name() {
    return this._name;
  }
  set name(v: string) {
    this._name = v;
  }
  /**值 */
  get value() {
    return this._value;
  }
  set value(v: any) {
    this._value = v;
  }
  /**值 */
  get prop() {
    return this._prop;
  }
  set prop(v: ITimeProp | IOptionProp) {
    this._prop = v;
  }
  // public value = [];
  /**类型 */
  get type() {
    return this._type;
  }
  set type(v: elementAttributeType) {
    this._type = v;
  }
  get options() {
    return this._options;
  }
  set options(v: Array<IOption>) {
    this._options = v;
  }
  get parentId() {
    return this._parentId;
  }
  set parentId(v: string) {
    this._parentId = v;
  }
  get ref() {
    return this._ref;
  }
  set ref(v: IBaseElement) {
    this._ref = v;
  }
  public static rules() {
    return {
      name: [
        {
          required: true,
          message: "请输入属性名称",
          trigger: "blur",
        },
      ],
      ref: [
        {
          required: true,
          message: "请选择引用",
          trigger: "change",
        },
      ],
    };
  }
}
export class Option implements IOption {
  constructor(value?: IOption) {
    if (value) {
      this.name = value.name;
      this.id = value.id;
      this.value = value.value;
    }
  }
  private _name = "";
  private _value = "";
  private _id = "";
  get name() {
    return this._name;
  }
  set name(v: string) {
    this._name = v;
  }
  get value() {
    return this._value;
  }
  set value(v: string) {
    this._value = v;
  }
  get id() {
    return this._id;
  }
  set id(v: string) {
    this._id = v;
  }
  public static rules() {
    return {
      value: [
        {
          required: true,
          message: "请输入实际值",
          trigger: "blur",
        },
      ],
      label: [
        {
          required: true,
          message: "请输入显示名称",
          trigger: "blur",
        },
      ],
    };
  }
}
