borderRadius.vue 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. <template>
  2. <section class="config" :key="displayName">
  3. <div class="config-label">
  4. <el-tooltip :content="displayName" placement="top">
  5. <span>{{displayKeyName}}</span>
  6. </el-tooltip>
  7. </div>
  8. <div class="config-content">
  9. <theme-input
  10. v-if="isGlobal"
  11. :val="value"
  12. @change="onChange"
  13. ></theme-input>
  14. <el-select
  15. size="medium"
  16. v-if="!isGlobal"
  17. v-model="value"
  18. class="select"
  19. @change="onSelectChange"
  20. >
  21. <el-option
  22. v-for="item in options"
  23. :key="item.value"
  24. :label="item.label"
  25. :value="item.value">
  26. </el-option>
  27. </el-select>
  28. </div>
  29. </section>
  30. </template>
  31. <style>
  32. .select {
  33. width: 100%;
  34. }
  35. </style>
  36. <script>
  37. import Mixin from './mixin';
  38. import Input from './input';
  39. import { getStyleDisplayName } from '../utils/utils.js';
  40. export default {
  41. data() {
  42. return {
  43. options: [],
  44. value: ''
  45. };
  46. },
  47. components: {
  48. themeInput: Input
  49. },
  50. mixins: [Mixin],
  51. computed: {
  52. isGlobalInputValue() {
  53. return this.config.value.startsWith('$');
  54. }
  55. },
  56. methods: {
  57. onSelectChange(e) {
  58. this.onChange(e);
  59. },
  60. initSelectOption() {
  61. this.options = [];
  62. const golbalV = this.golbalValue.border;
  63. if (golbalV) {
  64. Object.keys(golbalV).forEach((font) => {
  65. if (font.includes('border-radius')) {
  66. const size = golbalV[font];
  67. this.options.push({
  68. value: size.key,
  69. label: getStyleDisplayName(size)
  70. });
  71. }
  72. });
  73. }
  74. }
  75. },
  76. watch: {
  77. 'mergedValue': {
  78. immediate: true,
  79. handler(value) {
  80. this.initSelectOption();
  81. this.value = this.mergedValue;
  82. }
  83. }
  84. }
  85. };
  86. </script>