export default (ctx) => {
  switch (ctx.type) {
    case 'input':
      return `<el-input v-model="${ctx.form}.${ctx.value}" clearable />`
    case 'textarea':
    case 'air_textarea':
      return `<el-input v-model="${ctx.form}.${ctx.value}" type="textarea" />`
    case 'number':
      return `<el-input-number v-model="${ctx.form}.${ctx.value}" :precision="0" :min="0" :max="Infinity" :controls="false" controls-position="right" />`
    case 'select':
      return `<el-select v-model="${ctx.form}.${ctx.value}" clearable filterable >${ctx.option.map(({ n, v }) => `<el-option label="${n}" value="${v}" />`).join('')}</el-select>`
    case 'checkbox':
      return `<el-checkbox-group v-model="${ctx.form}.${ctx.value}">${ctx.option.map(({ n, v }) => `<el-checkbox label="${v}">${n}</el-checkbox>`).join('')}</el-checkbox-group>`
    case 'radio':
      return `<el-radio-group v-model="${ctx.form}.${ctx.value}">${ctx.option.map(({ n, v }) => `<el-radio label="${v}">${n}</el-radio>`).join('')}</el-radio-group>`
    case 'datetime':
      return `<el-date-picker type="${ctx.type}" v-model="${ctx.form}.${ctx.value}" value-format="YYYY-MM-DD HH:mm:ss" clearable />`
    case 'date':
      return `<el-date-picker type="${ctx.type}" v-model="${ctx.form}.${ctx.value}" value-format="YYYY-MM-DD" clearable />`
    case 'month':
    case 'year':
      return `<el-date-picker type="${ctx.type}" v-model="${ctx.form}.${ctx.value}" value-format="YYYY-MM-DD HH:mm:ss" clearable />`
    case 'file':
    case 'mfile':
      return `<file-upload v-model:part="${ctx.form}.${ctx.value}" />`
    default:
      return `<span v-model="${ctx.form}.${ctx.value}"> ${ctx.type} 为不支持的格式</span>`
  }
}
