LastAllEnergy.vue 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182
  1. <template>
  2. <div
  3. class="lastMonth"
  4. :class="[screenType === 'hor' ? 'horizontalClass ' : 'verLastClass ']"
  5. >
  6. <div class="subhead-title">
  7. <span>上月总能耗</span>
  8. </div>
  9. <div class="saveEnergy">
  10. <span class="backImage">节能<span class="value">{{ lastAllComputed.energyCompare }}%</span></span>
  11. </div>
  12. <div class="energySave">
  13. <div class="textDiv">
  14. <span>项目能耗</span><span class="value">{{ lastAllComputed.energySaving }}kWh</span>
  15. </div>
  16. <div
  17. class="saveBack"
  18. :style="{ width: lastAllComputed.energyCompare + '%' }"
  19. ></div>
  20. </div>
  21. <div class="energyTotal">
  22. <div class="textDiv">
  23. <span>基准能耗</span><span class="value">{{ lastAllComputed.energyTotal }}kWh</span>
  24. </div>
  25. <div
  26. class="totalBack"
  27. :style="{ width: widthBase }"
  28. ></div>
  29. </div>
  30. </div>
  31. </template>
  32. <script lang="ts">
  33. import {
  34. ref,
  35. defineComponent,
  36. reactive,
  37. toRefs,
  38. onMounted,
  39. computed,
  40. } from "vue";
  41. import { queryLastEnergy } from "@/api/index";
  42. import useProjectStore from "@/store/useProjectStore";
  43. import { storeToRefs, mapState } from "pinia";
  44. //import { lastGold, lastGray } from "@/utils/dapingImage";
  45. export default defineComponent({
  46. props: {
  47. screenType: {
  48. type: String,
  49. },
  50. },
  51. setup(props, contx) {
  52. // console.log("props", props, contx);
  53. const projectStore = useProjectStore();
  54. /// const { lastAllEnergy22 } = storeToRefs(projectStore);
  55. const allData = reactive({
  56. widthBase: "0%",
  57. });
  58. const lastAllComputed = computed(() => {
  59. const lastAllEnergy = projectStore.lastAllEnergy;
  60. var lastObj = {
  61. energySaving: lastAllEnergy.energySaving
  62. ? lastAllEnergy.energySaving.toFixed(1)
  63. : lastAllEnergy.energySaving,
  64. energyTotal: lastAllEnergy.energyTotal
  65. ? lastAllEnergy.energyTotal.toFixed(1)
  66. : lastAllEnergy.energyTotal,
  67. energyCompare: lastAllEnergy.energyCompare
  68. ? (lastAllEnergy.energyCompare * 100).toFixed(0)
  69. : lastAllEnergy.energyCompare,
  70. };
  71. return lastObj;
  72. });
  73. projectStore.$subscribe((mutation, state) => {
  74. //debugger;
  75. allData.widthBase = "100%";
  76. });
  77. onMounted(() => {
  78. projectStore.setLastAllEnergy();
  79. });
  80. return { ...toRefs(allData), lastAllComputed, projectStore };
  81. },
  82. computed: {
  83. // ...mapState(useProjectStore, {
  84. // lastAllEnergy2: (store) => {
  85. // debugger;
  86. // return store.lastAllEnergy.energyCompare
  87. // ? (store.lastAllEnergy.energyCompare * 100).toFixed(1)
  88. // : store.lastAllEnergy.energyCompare;
  89. // },
  90. // }),
  91. // lastAllEnergy2() {
  92. // debugger;
  93. // if (this.projectStore) {
  94. // return this.projectStore.lastAllEnergy.energyCompare
  95. // ? (
  96. // this.projectStore.lastAllEnergy.energyCompare * 100
  97. // ).toFixed(1)
  98. // : this.projectStore.lastAllEnergy.energyCompare;
  99. // } else {
  100. // return 122;
  101. // }
  102. // },
  103. },
  104. });
  105. </script>
  106. <style scoped lang="scss">
  107. .lastMonth {
  108. height: 100%;
  109. backdrop-filter: blur(20px);
  110. background: rgba(100, 108, 130, 0.06);
  111. border-radius: 20px;
  112. .saveEnergy {
  113. color: #f7e6cd;
  114. font-size: 46px;
  115. height: calc(100% - 195px);
  116. display: flex;
  117. justify-content: center;
  118. align-items: center;
  119. font-weight: 600;
  120. font-family: Persagy;
  121. .backImage {
  122. background-image: url("@/assets/image/horImg/lastAllLight.png");
  123. background-repeat: no-repeat;
  124. background-position: center bottom;
  125. background-size: 100%;
  126. padding-bottom: 5px;
  127. text-shadow: 0px 0px 8px rgba(255, 255, 255, 0.4);
  128. .value {
  129. font-weight: 700;
  130. font-size: 48px;
  131. margin-left: 2px;
  132. }
  133. }
  134. }
  135. .energySave {
  136. color: #e0c29b;
  137. font-size: 20px;
  138. padding-bottom: 32px;
  139. padding-left: 24px;
  140. padding-right: 24px;
  141. height: 85px;
  142. box-sizing: border-box;
  143. }
  144. .energyTotal {
  145. color: #cbcdda;
  146. font-size: 20px;
  147. height: 50px;
  148. padding-left: 24px;
  149. padding-right: 24px;
  150. box-sizing: border-box;
  151. }
  152. .textDiv {
  153. display: flex;
  154. justify-content: space-between;
  155. padding-bottom: 8px;
  156. font-family: Persagy;
  157. }
  158. .saveBack {
  159. height: 15px;
  160. background-image: url("@/assets/image/horImg/lastGold.svg");
  161. transition: width 0.8s linear;
  162. width: 0;
  163. }
  164. .totalBack {
  165. height: 15px;
  166. background-image: url("@/assets/image/horImg/lastGray.svg");
  167. transition: width 0.8s linear;
  168. width: 0;
  169. }
  170. }
  171. .verLastClass {
  172. //height: 420px;
  173. height: 28%;
  174. box-sizing: border-box;
  175. padding: 0 36px 40px;
  176. }
  177. </style>