index.vue 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. <!--
  2. * @Descripttion: 大屏设计器 -- 预览
  3. * @Author: lide1202@hotmail.com
  4. * @Date: 2021-3-13 11:04:24
  5. * @Last Modified by: lide1202@hotmail.com
  6. * @Last Modified time: 2021-3-13 11:04:24
  7. !-->
  8. <template>
  9. <div class="layout">
  10. <div :style="bigScreenStyle">
  11. <widget
  12. v-for="(widget, index) in widgets"
  13. :key="index"
  14. v-model="widget.value"
  15. :index="index"
  16. :type="widget.type"
  17. />
  18. </div>
  19. </div>
  20. </template>
  21. <script>
  22. import widget from "../designer/widget/temp";
  23. import { detailDashboard } from "@/api/bigscreen";
  24. export default {
  25. name: "Login",
  26. components: {
  27. widget
  28. },
  29. data() {
  30. return {
  31. bigScreenStyle: {},
  32. widgets: []
  33. };
  34. },
  35. mounted() {
  36. this.getData();
  37. },
  38. methods: {
  39. async getData() {
  40. const reportCode = this.$route.query.reportCode;
  41. const { code, data } = await detailDashboard(reportCode);
  42. if (code != 200) return;
  43. const equipment = document.body.clientWidth;
  44. const ratioEquipment = equipment / data.dashboard.width;
  45. this.bigScreenStyle = {
  46. width: data.dashboard.width + "px",
  47. height: data.dashboard.height + "px",
  48. "background-color": data.dashboard.backgroundColor,
  49. "background-image": "url(" + data.dashboard.backgroundImage + ")",
  50. "background-position": "0% 0%",
  51. "background-size": "100% 100%",
  52. "background-repeat": "initial",
  53. "background-attachment": "initial",
  54. "background-origin": "initial",
  55. "background-clip": "initial",
  56. transform: `scale(${ratioEquipment}, ${ratioEquipment})`,
  57. "transform-origin": "0 0"
  58. };
  59. data.dashboard.widgets.forEach((item, index) => {
  60. item.value.widgetId = item.value.setup.widgetId
  61. item.value.widgetCode = item.value.setup.widgetCode
  62. if (item.value.setup.componentLinkage && item.value.setup.componentLinkage.length) {
  63. this.$store.commit('SET_ALL_COMPONENT_LINKAGE', {
  64. index,
  65. widgetId: item.value.widgetId,
  66. linkageArr: item.value.setup.componentLinkage
  67. })
  68. }
  69. })
  70. this.widgets = data.dashboard.widgets;
  71. }
  72. }
  73. };
  74. </script>
  75. <style scoped lang="scss">
  76. .layout {
  77. width: 100%;
  78. height: 100%;
  79. text-align: center;
  80. }
  81. .bottom-text {
  82. width: 100%;
  83. color: #a0a0a0;
  84. position: fixed;
  85. bottom: 16px;
  86. z-index: 9999;
  87. }
  88. </style>