ModuleBase.vue 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. <template>
  2. <div class="module">
  3. <div class="module-top">
  4. <span class="title">{{ componentNameList[type] }}</span>
  5. <div class="module-icon">
  6. <span><SvgIcon icon-class="copy" size="10" /></span>
  7. <span :class="[{ active: getCurSettingId() === id }]" @click="showSetting">
  8. <SvgIcon icon-class="setup" size="10" />
  9. </span>
  10. <span @click="deleteComponent"><SvgIcon icon-class="delete" size="10" /></span>
  11. </div>
  12. </div>
  13. <div class="module-content">
  14. <slot name="content"></slot>
  15. </div>
  16. </div>
  17. </template>
  18. <script>
  19. import { componentNameList } from '@/views/book/courseware/data/bookType.js';
  20. export default {
  21. name: 'ModuleBase',
  22. inject: ['id', 'showSetting', 'getCurSettingId'],
  23. props: {
  24. type: {
  25. type: String,
  26. default: 'text',
  27. },
  28. },
  29. data() {
  30. return {
  31. componentNameList,
  32. };
  33. },
  34. methods: {
  35. deleteComponent() {
  36. this.$emit('deleteComponent');
  37. },
  38. },
  39. };
  40. </script>
  41. <style lang="scss" scoped>
  42. .module {
  43. padding: 8px;
  44. background-color: #fff;
  45. border: 1px solid #ebebeb;
  46. &-top {
  47. display: flex;
  48. justify-content: space-between;
  49. margin-bottom: 3px;
  50. .title {
  51. font-size: 12px;
  52. color: $label-color;
  53. }
  54. }
  55. &-icon {
  56. display: flex;
  57. column-gap: 8px;
  58. span {
  59. display: flex;
  60. align-items: center;
  61. justify-content: center;
  62. width: 16px;
  63. height: 16px;
  64. cursor: pointer;
  65. background-color: #fff;
  66. border-radius: 20px;
  67. &.active {
  68. background-color: #c9c9c9;
  69. }
  70. .svg-icon.setup {
  71. color: #000;
  72. }
  73. .svg-icon.delete {
  74. color: #ed4646;
  75. }
  76. }
  77. }
  78. &-content {
  79. padding: 8px;
  80. background-color: #fff;
  81. }
  82. }
  83. </style>