FormItem.mjs 1.7 KB

123456789101112131415161718192021222324252627282930
  1. export default (ctx) => {
  2. switch (ctx.type) {
  3. case 'input':
  4. return `<el-input v-model="${ctx.form}.${ctx.value}" clearable />`
  5. case 'textarea':
  6. case 'air_textarea':
  7. return `<el-input v-model="${ctx.form}.${ctx.value}" type="textarea" />`
  8. case 'number':
  9. return `<el-input-number v-model="${ctx.form}.${ctx.value}" :precision="0" :min="0" :max="Infinity" :controls="false" controls-position="right" />`
  10. case 'select':
  11. 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>`
  12. case 'checkbox':
  13. 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>`
  14. case 'radio':
  15. 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>`
  16. case 'datetime':
  17. return `<el-date-picker type="${ctx.type}" v-model="${ctx.form}.${ctx.value}" value-format="YYYY-MM-DD HH:mm:ss" clearable />`
  18. case 'date':
  19. return `<el-date-picker type="${ctx.type}" v-model="${ctx.form}.${ctx.value}" value-format="YYYY-MM-DD" clearable />`
  20. case 'month':
  21. case 'year':
  22. return `<el-date-picker type="${ctx.type}" v-model="${ctx.form}.${ctx.value}" value-format="YYYY-MM-DD HH:mm:ss" clearable />`
  23. case 'file':
  24. case 'mfile':
  25. return `<file-upload v-model:part="${ctx.form}.${ctx.value}" />`
  26. default:
  27. return `<span v-model="${ctx.form}.${ctx.value}"> ${ctx.type} 为不支持的格式</span>`
  28. }
  29. }