action.vue 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  1. <template>
  2. <div class="configurator-action">
  3. <div class="action-group">
  4. <el-tooltip :content="getActionDisplayName('undo')">
  5. <img
  6. src="../../assets/images/icon-undo.svg"
  7. @click="onUndo"
  8. :class="{ 'active': userConfigHistory.length > 0 }"
  9. />
  10. </el-tooltip>
  11. <el-tooltip :content="getActionDisplayName('redo')">
  12. <img
  13. src="../../assets/images/icon-redo.svg"
  14. @click="onRedo"
  15. :class="{ 'active': userConfigRedoHistory.length > 0 }"
  16. />
  17. </el-tooltip>
  18. <div class="button-group">
  19. <el-button
  20. class="reset"
  21. type="primary"
  22. round
  23. size="mini"
  24. :disabled="isOfficial"
  25. @click="onReset"
  26. >
  27. {{getActionDisplayName('reset-theme')}}
  28. </el-button>
  29. <el-button
  30. class="download"
  31. type="primary"
  32. round
  33. size="mini"
  34. :disabled="downloadDisabled"
  35. @click="onDownload"
  36. >
  37. {{getActionDisplayName('download-theme')}}
  38. </el-button>
  39. </div>
  40. </div>
  41. <el-select v-model="selectedComponent" class="selector">
  42. <el-option
  43. v-for="item in selectOptions"
  44. :key="item.value"
  45. :label="item.label"
  46. :value="item.value">
  47. </el-option>
  48. </el-select>
  49. <div class="line"></div>
  50. </div>
  51. </template>
  52. <style lang="scss">
  53. .configurator-action {
  54. padding: 15px 18px 0;
  55. .action-group {
  56. padding: 5px 0;
  57. img {
  58. cursor: not-allowed;
  59. width: 16px;
  60. height: 16px;
  61. padding: 7px 0;
  62. margin-left: 5px;
  63. opacity: .5;
  64. &.active {
  65. opacity: 1;
  66. cursor: pointer;
  67. }
  68. &:last-of-type {
  69. margin-left: 10px;
  70. }
  71. }
  72. .button-group {
  73. float: right;
  74. .el-button {
  75. padding: 6px 15px;
  76. &.is-disabled {
  77. color: #C0C4CC;
  78. background-color: #fff;
  79. border-color: #EBEEF5;
  80. }
  81. }
  82. .reset {
  83. background: #E6F1FC;
  84. color: #1989FA;
  85. border-color: #A2CFFC;
  86. }
  87. .download {
  88. background: #1989FA;
  89. color: #FFF;
  90. border-color: #1989FA
  91. }
  92. }
  93. }
  94. .selector {
  95. width: 100%;
  96. input {
  97. background: #f5f7fa;
  98. border: none;
  99. font-size: 18px;
  100. padding-left: 0;
  101. color: #606266;
  102. }
  103. }
  104. .line {
  105. width: 100%;
  106. height: 0;
  107. border-bottom: 1px solid #DCDFE6;
  108. }
  109. }
  110. </style>
  111. <script>
  112. import { getActionDisplayName } from './utils/utils';
  113. export default {
  114. props: {
  115. selectOptions: Array,
  116. userConfigHistory: Array,
  117. userConfigRedoHistory: Array,
  118. isOfficial: Boolean,
  119. onUndo: Function,
  120. onRedo: Function
  121. },
  122. data() {
  123. return {
  124. selectedComponent: 'color',
  125. downloadDisabled: false
  126. };
  127. },
  128. watch: {
  129. selectedComponent: {
  130. handler(val) {
  131. this.$emit('select', val);
  132. }
  133. }
  134. },
  135. methods: {
  136. getActionDisplayName(key) {
  137. return getActionDisplayName(key);
  138. },
  139. onReset() {
  140. this.$parent.onReset();
  141. },
  142. onDownload() {
  143. this.downloadDisabled = true;
  144. this.$parent.onDownload();
  145. setTimeout(() => {
  146. this.downloadDisabled = false;
  147. }, 2500);
  148. }
  149. }
  150. };
  151. </script>