border.vue 3.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. <template>
  2. <div class="pcPages" :style="warpCss">
  3. <div :style="boxCss">
  4. <div :style="borderCss" class="w100%"></div>
  5. </div>
  6. </div>
  7. </template>
  8. <script setup lang="ts">
  9. interface Props {
  10. row?: any;
  11. }
  12. const props = defineProps<Props>();
  13. const componentData = props.row || {};
  14. const warpCss = computed(() => {
  15. let style = '';
  16. style += 'position:relative;';
  17. //背景颜色
  18. if (componentData.pageStartBgColor) {
  19. if (componentData.pageStartBgColor && componentData.pageEndBgColor)
  20. style += `background:linear-gradient(${componentData.pageGradientAngle},${componentData.pageStartBgColor},${componentData.pageEndBgColor});`;
  21. else if (componentData.pageStartBgColor) style += `background: ${componentData.pageStartBgColor};`;
  22. else if (componentData.pageEndBgColor) style += `background: ${componentData.pageEndBgColor};`;
  23. }
  24. //背景图片
  25. if (componentData.componentBgUrl) {
  26. style += `background-image:url('${componentData.componentBgUrl}');`;
  27. style += 'background-size: cover;background-repeat: no-repeat;';
  28. }
  29. //边距
  30. if (componentData.padding) {
  31. if (componentData.padding.top > 0) {
  32. style += 'padding-top:' + componentData.padding.top + 'px' + ';';
  33. }
  34. if (componentData.padding.bottom > 0) {
  35. style += 'padding-bottom:' + componentData.padding.bottom + 'px' + ';';
  36. }
  37. style += 'padding-right:' + componentData.padding.both + 'px' + ';';
  38. style += 'padding-left:' + componentData.padding.both + 'px' + ';';
  39. }
  40. //圆角
  41. if (componentData.topRounded) style += 'border-top-left-radius:' + componentData.topRounded + 'px;';
  42. if (componentData.topRounded) style += 'border-top-right-radius:' + componentData.topRounded + 'px;';
  43. if (componentData.bottomRounded) style += 'border-bottom-left-radius:' + componentData.bottomRounded + 'px;';
  44. if (componentData.bottomRounded) style += 'border-bottom-right-radius:' + componentData.bottomRounded + 'px;';
  45. //间距
  46. if (componentData.margin) {
  47. if (componentData.margin.top > 0) {
  48. style += 'margin-top:' + componentData.margin.top + 'px' + ';';
  49. }
  50. if (componentData.margin.bottom > 0) {
  51. style += 'margin-bottom:' + componentData.margin.bottom + 'px' + ';';
  52. }
  53. }
  54. return style;
  55. });
  56. //组件样式
  57. const boxCss = computed(() => {
  58. let style = '';
  59. if (componentData.componentStartBgColor && componentData.componentEndBgColor)
  60. style += `background:linear-gradient(${componentData.componentGradientAngle},${componentData.componentStartBgColor},${componentData.componentEndBgColor});`;
  61. else if (componentData.componentStartBgColor) style += 'background-color:' + componentData.componentStartBgColor + ';';
  62. else if (componentData.componentEndBgColor) style += 'background-color:' + componentData.componentEndBgColor + ';';
  63. if (componentData.number) style += 'flex:' + `0 0 calc((100% - ${(componentData.number - 1) * 10}px) / ${componentData.number})` + ';';
  64. if (componentData.boxHeight) style += 'height:' + componentData.boxHeight + 'px;';
  65. return style;
  66. });
  67. //组件样式
  68. const borderCss = computed(() => {
  69. let style = '';
  70. if (componentData.boxHeight) style += 'height:' + componentData.boxHeight + 'px;';
  71. if (componentData.boxColor) style += 'background-color:' + componentData.boxColor;
  72. return style;
  73. });
  74. </script>
  75. <style lang="scss" scoped>
  76. .pcPages {
  77. width: 100%;
  78. max-width: 1500px;
  79. min-width: 1200px;
  80. margin: 0 auto;
  81. .pcPages-html {
  82. :deep(img) {
  83. max-width: 100%;
  84. display: inline-block;
  85. }
  86. }
  87. }
  88. </style>