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

<script>
export default {
  name: "FormUpload",
  inheritAttrs: false,
  inject: {
    labelWidth: {
      from: 'labelWidth',
      default: '90px'
    },
    defaultColSpan: {
      from: 'defaultColSpan',
      default: 12
    }
  },
  props: {
    placeholder: {
      type: String,
      default: "",
    },
    textWidth: {
      type: String,
      default: ""
    },
    colSpan: { type: Number },
    modelValue: {
      type: [String, Object, Array],
      default: '',
    },
    closeButton: {
      type: Boolean,
      default: false,
    },
    icon: {
      type: String,
      default: "",
    },
    accept: {
      type: String,
      default: "",
    },
    multiple: {
      type: Boolean,
      default: false,
    },
    label: { type: String, default: "" },
    name: { type: String, default: "" },
    disabled: { type: Boolean, default: false },
    style: { type: Object, default: () => ({}) }
  },
  computed: {
    see() {
      return this.$store?.forms?.see;
    }
  },
  emits: ["update:modelValue"]
};
</script>
