<template>
  <a-col :span="colSpan ? colSpan : defaultColSpan">
    <a-form-item :label="label" :name="name" :label-col="{ style: { width: textWidth || labelWidth } }"
      :wrapper-col="{ style: { flex: 1 } }">
      <paas-select :model-value="modelValue" @update:modelValue="$emit('update:modelValue', $event)"
        @change="$emit('change', $event)" :data="data" :params="params" :multiple="multiple" :disabled="see || disabled"
        :placeholder="placeholder" :style="style" v-bind="$attrs" />
    </a-form-item>
  </a-col>
</template>

<script>
export default {
  name: "FormSelect",
  inheritAttrs: false,
  inject: {
    labelWidth: { from: "labelWidth", default: "90px" },
    defaultColSpan: { from: "defaultColSpan", default: 12 }
  },
  props: {
    placeholder: { type: String, default: "" },
    colSpan: { type: Number },
    textWidth: { type: String, default: "" },
    data: { type: Array, default: () => [] }, // 原始数据，不修改
    multiple: { type: Boolean, default: false },
    modelValue: { type: [String, Number, Array], default: null },
    params: { type: String, default: "" },
    label: { type: String, default: "" },
    name: { type: String, default: "" },
    disabled: { type: Boolean, default: false },
    style: { type: Object, default: () => ({ width: "100%" }) }
  },
  emits: ["update:modelValue", "change"],
  computed: {
    see() {
      return this.$store?.forms?.see;
    }
  }
};
</script>