<template>
  <div class="select-prop">
    <FormItem label="默认值">
      <Input
        v-model="defaultArr"
        placeholder="请输入默认值"
        :readonly="info.form.multiple"
        :disabled="!info.isNew"></Input>
    </FormItem>
    <FormItem label="占位提示">
      <Input v-model="info.form.placeholder" placeholder="请输入占位提示"></Input>
    </FormItem>
    <FormItem label="是否清空">
      <i-switch v-model="info.form.clearable" />
    </FormItem>
    <FormItem label="是否多选">
      <i-switch v-model="info.form.multiple" />
    </FormItem>
    <!-- 远程 filterable 必开启 -->
    <FormItem label="是否搜索" v-if="info.formType=='Select'">
      <i-switch v-model="info.form.filterable" />
    </FormItem>
  </div>
</template>
<script>
export default {
  name: 'SelectProp',
  props: {
    info: Object,
  },
  data() {
    return {
      defaultArr: null,
    }
  },
  watch: {
    defaultArr(v) {
      if (!this.info.form.multiple) {
        this.info.defaultValue = v
      }
    },
    'info.defaultValue': {
      handler(v) {
        if (this.info.form.multiple) {
          this.defaultArr = v.join()
        } else {
          this.defaultArr = v
        }
      },
      immediate: true,
    },
  },
}
</script>