SourceTabForm.vue 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. <template>
  2. <el-tabs id="source-edit">
  3. <el-tab-pane
  4. v-for="{ name, children } in Object.values(config)"
  5. :label="name"
  6. :key="name"
  7. >
  8. <el-form label-position="right" label-width="auto">
  9. <el-form-item
  10. v-for="{
  11. type,
  12. title,
  13. namespace,
  14. id,
  15. array,
  16. hint,
  17. required = false,
  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
  38. v-if="(type as string) === 'Boolean'"
  39. v-model="currentSource[id]"
  40. />
  41. <el-input-number
  42. v-if="(type as string) === 'Number'"
  43. v-model="currentSource[id]"
  44. :min="0"
  45. />
  46. <el-select
  47. v-if="(type as string) === 'Array'"
  48. v-model="currentSource[id]"
  49. >
  50. <el-option
  51. v-for="(optionName, index) in array"
  52. :value="index"
  53. :key="optionName"
  54. :label="optionName"
  55. />
  56. </el-select>
  57. </el-form-item>
  58. </el-form>
  59. </el-tab-pane>
  60. </el-tabs>
  61. </template>
  62. <script setup lang="ts">
  63. import type { SourceConfig } from '@/config/sourceConfig'
  64. const store = useSourceStore()
  65. defineProps<{ config: SourceConfig }>()
  66. const currentSource = computed(() => store.currentSource)
  67. /*
  68. 修改currentSource的属性 没有直接修改本身
  69. const { currentSource } = storeToRefs(store);
  70. */
  71. </script>
  72. <style lang="scss" scoped>
  73. :deep(.el-tab-pane) {
  74. height: calc(100vh - 55px);
  75. padding-top: 15px;
  76. padding-right: 5px;
  77. overflow-y: auto;
  78. }
  79. :deep(.el-tabs__header) {
  80. margin: 0;
  81. }
  82. </style>