PreviewMixin.js 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. import SerialNumberPosition from './SerialNumberPosition.vue';
  2. import { GetCoursewareComponentContent_View } from '@/api/book';
  3. const mixin = {
  4. data() {
  5. return {};
  6. },
  7. props: {
  8. id: {
  9. type: String,
  10. required: true,
  11. },
  12. coursewareId: {
  13. type: String,
  14. required: true,
  15. },
  16. },
  17. components: {
  18. SerialNumberPosition,
  19. },
  20. created() {
  21. this.getCoursewareComponentContent_View();
  22. },
  23. methods: {
  24. getCoursewareComponentContent_View() {
  25. GetCoursewareComponentContent_View({ courseware_id: this.coursewareId, component_id: this.id }).then(
  26. ({ content }) => {
  27. if (content) this.data = JSON.parse(content);
  28. },
  29. );
  30. },
  31. /**
  32. * 得到序号外部样式
  33. */
  34. getAreaStyle() {
  35. const position = this.data.property.sn_position;
  36. let grid = '';
  37. if (position.includes('right')) {
  38. grid = `"main position" / 1fr auto`;
  39. } else if (position.includes('left')) {
  40. grid = `"position main" / auto 1fr`;
  41. } else if (position.includes('top')) {
  42. grid = `"position" auto "main" 1fr`;
  43. } else if (position.includes('bottom')) {
  44. grid = `"main" 1fr "position" auto`;
  45. }
  46. return {
  47. grid,
  48. };
  49. },
  50. },
  51. };
  52. export default mixin;