ExternalNotifyEditor.vue 1012 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. <script setup lang="ts">
  2. import type { Column } from '@/components/StdDesign/types'
  3. import type { ExternalNotifyConfig } from './types'
  4. import StdDataEntry, { input } from '@/components/StdDesign/StdDataEntry'
  5. import configMap from './index'
  6. const props = defineProps<{
  7. type?: string
  8. }>()
  9. const modelValue = defineModel<Record<string, string>>({ default: reactive({}) })
  10. const currentConfig = computed<ExternalNotifyConfig | undefined>(() => {
  11. return configMap[props.type?.toLowerCase() ?? '']
  12. })
  13. const columns = computed<Column[]>(() => {
  14. if (!currentConfig.value)
  15. return []
  16. return currentConfig.value.config.map(item => ({
  17. title: item.label,
  18. dataIndex: item.key,
  19. key: item.key,
  20. edit: {
  21. type: input,
  22. config: {
  23. label: item.label,
  24. required: true,
  25. },
  26. },
  27. }))
  28. })
  29. </script>
  30. <template>
  31. <StdDataEntry
  32. v-if="currentConfig"
  33. v-model:data-source="modelValue"
  34. :data-list="columns"
  35. />
  36. </template>
  37. <style scoped lang="less">
  38. </style>