<template>
  <div>
    <template v-if="optionType === 'input'">
      <el-input v-model="model" placeholder="请输入内容" v-bind="props"></el-input>
    </template>
    <template v-if="optionType === 'input-number'">
      <amis-sdk :amis-json="amisJson" v-model="model" />
    </template>
    <template v-if="optionType === 'color'">
      <div class="flex">
        <el-input v-model="model" placeholder="请输入颜色值" v-bind="props"></el-input>
        <el-color-picker v-model="model" v-bind="props" show-alpha :predefine="predefineColors"></el-color-picker>
      </div>
    </template>
  </div>
</template>
<script>
export default {
  name: 'YangForm'
}
</script>
<script setup>
import { ref, useAttrs } from 'vue'
import AmisSdk from '@/components/AmisSdk.vue'
const attrs = useAttrs()
console.log(attrs)
const props = defineProps({
  modelValue: null,
  optionType: {
    type: String,
    default: 'input'
  }
})
console.log(props)
const predefineColors = ref([
  '#ff4500',
  '#ff8c00',
  '#ffd700',
  '#90ee90',
  '#00ced1',
  '#1e90ff',
  '#c71585',
  'rgba(255, 69, 0, 0.68)',
  'rgb(255, 120, 0)',
  'hsv(51, 100, 98)',
  'hsva(120, 40, 94, 0.5)',
  'hsl(181, 100%, 37%)',
  'hsla(209, 100%, 56%, 0.73)',
  '#c7158577'
])
const model = ref(props.modelValue)
const emit = defineEmits(['update:modelValue'])
emit('update:modelValue', model.value)

const amisJson = {
  type: props.optionType,
  value: 1,
  step: 1,
  min: 1,
  max: 10
}
</script>

<style scoped lang="scss"></style>
