SourceTabForm.vue 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. <template>
  2. <el-tabs id="source-edit">
  3. <el-tab-pane
  4. v-for="{ name, children } in tabsData"
  5. :label="name"
  6. :key="name"
  7. >
  8. <el-form label-position="right" label-width="5em">
  9. <el-form-item
  10. v-for="{
  11. type,
  12. title,
  13. namespace,
  14. id,
  15. array,
  16. hint,
  17. required,
  18. } in children"
  19. :label="title"
  20. :key="title"
  21. :required="required"
  22. >
  23. <el-input
  24. v-if="type == 'String' && typeof namespace == 'undefined'"
  25. type="textarea"
  26. v-model="currentSource[id]"
  27. :placeholder="hint"
  28. autosize
  29. />
  30. <el-input
  31. v-if="type == 'String' && typeof namespace != 'undefined'"
  32. type="textarea"
  33. v-model="currentSource[namespace][id]"
  34. :placeholder="hint"
  35. autosize
  36. />
  37. <el-switch v-if="type == 'Boolean'" v-model="currentSource[id]" />
  38. <el-input-number
  39. v-if="type == 'Number'"
  40. v-model="currentSource[id]"
  41. :min="0"
  42. />
  43. <el-select v-if="type == 'Array'" v-model="currentSource[id]">
  44. <el-option
  45. v-for="(name, index) in array"
  46. :value="index"
  47. :key="name"
  48. :label="name"
  49. />
  50. </el-select>
  51. </el-form-item>
  52. </el-form>
  53. </el-tab-pane>
  54. </el-tabs>
  55. </template>
  56. <script setup>
  57. const store = useSourceStore();
  58. const props = defineProps(["config"]);
  59. const tabsData = Object.values(props.config);
  60. const { currentSource } = storeToRefs(store);
  61. </script>
  62. <style lang="scss" scoped>
  63. :deep(.el-tab-pane) {
  64. height: calc(100vh - 40px);
  65. overflow-y: auto;
  66. }
  67. </style>