NameSetting.vue 937 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. <template>
  2. <setting-item-box name="名称" :alone="true">
  3. <n-input
  4. type="text"
  5. maxlength="12"
  6. minlength="1"
  7. placeholder="请输入图表名称"
  8. size="small"
  9. clearable
  10. show-count
  11. v-model:value="chartConfig.title"
  12. @focus="handleFocus"
  13. @blur="handleBlur"
  14. ></n-input>
  15. </setting-item-box>
  16. </template>
  17. <script setup lang="ts">
  18. import { PropType } from 'vue'
  19. import { SettingItemBox } from '@/components/ChartItemSetting/index'
  20. import { ConfigType } from '@/packages/index.d'
  21. const props = defineProps({
  22. chartConfig: {
  23. type: Object as PropType<ConfigType>,
  24. required: true
  25. },
  26. })
  27. let valueCatch = ''
  28. const handleFocus = () => {
  29. valueCatch = props.chartConfig.title
  30. }
  31. const handleBlur = () => {
  32. if(!props.chartConfig.title.length) {
  33. window['$message'].warning('请输入至少一个字符!')
  34. props.chartConfig.title = valueCatch
  35. }
  36. }
  37. </script>