index.vue 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179
  1. <template>
  2. <div class="home-container">
  3. <div class="wrap" ref="editor">
  4. <div class="top"></div>
  5. <cylindricalHistogram
  6. style="left: 50px; top: 425px"
  7. v-if="isGetData"
  8. title="各区域移栽产量分析"
  9. titleEn="Tongren Tobacco Planting Digital Management Platform"
  10. :area="Transplantarea"
  11. :dataArray="TransplantdataArray"
  12. ></cylindricalHistogram>
  13. <weatherForecast
  14. style="left: 50px; top: 750px"
  15. v-if="isWeather"
  16. title="天气预报"
  17. titleEn="Tongren Tobacco Planting Digital Management Platform"
  18. :area="Weatherarea"
  19. :dataArray="WeatherdataArray"
  20. :alertValue="30"
  21. >
  22. </weatherForecast>
  23. <wavyLineChart
  24. id="`wavyLineChart`"
  25. style="left: 1350px; top: 105px"
  26. v-if="isWavyLine"
  27. title="各区域移栽面积"
  28. :area="wavyLineArea"
  29. :dataArray="wavyLinedataArray"
  30. smooth="true"
  31. >
  32. </wavyLineChart>
  33. <HorizontalHistogram
  34. style="left: 1350px; top: 425px"
  35. v-if="isHorizontal"
  36. title="移栽情况分析"
  37. :area="HorizontalArea"
  38. :dataArray="HorizontalArray"
  39. ></HorizontalHistogram>
  40. <wavyLineChart
  41. id="`移栽趋势分析`"
  42. style="left: 1350px; top: 750px"
  43. v-if="isWavyLine"
  44. title="移栽趋势分析"
  45. :area="wavyLineArea"
  46. :dataArray="wavyLinedataArray"
  47. >
  48. </wavyLineChart>
  49. </div>
  50. </div>
  51. </template>
  52. <script>
  53. import { screenSize } from '@/assets/js/utils'
  54. import cylindricalHistogram from '@/components/Customize/cylindricalHistogram'
  55. import weatherForecast from '@/components/Customize/weatherForecast'
  56. import wavyLineChart from '@/components/Customize/wavyLineChart'
  57. import HorizontalHistogram from '@/components/Customize/HorizontalHistogram'
  58. export default {
  59. name: `Home`,
  60. components: {
  61. cylindricalHistogram,
  62. weatherForecast,
  63. wavyLineChart,
  64. HorizontalHistogram,
  65. },
  66. data() {
  67. return {
  68. TransplantdataArray: [],
  69. Transplantarea: [],
  70. Weatherarea: [],
  71. WeatherdataArray: [],
  72. wavyLineArea: [],
  73. wavyLinedataArray: {
  74. LastYear: [],
  75. thisYear: [],
  76. },
  77. HorizontalArea: [],
  78. HorizontalArray: {
  79. Done: [],
  80. Percentage: [],
  81. },
  82. isGetData: false,
  83. isWeather: false,
  84. isWavyLine: false,
  85. isHorizontal: false,
  86. }
  87. },
  88. computed: {},
  89. created() {
  90. this.getAnalysisOfTransplantYieldInVariousRegions()
  91. this.getWeatherForecast()
  92. this.getTransplantAreaInEachRegion()
  93. this.getAnalysisOfTransplantingSituation()
  94. this.$http.get(`https://httpbin.org/get`)
  95. },
  96. mounted() {
  97. screenSize(this.$refs.editor)
  98. },
  99. methods: {
  100. getAnalysisOfTransplantYieldInVariousRegions() {
  101. this.$http
  102. .get(`/api/analysisOfTransplantYieldInVariousRegions`)
  103. .then((res) => {
  104. res.forEach((element) => {
  105. this.Transplantarea.push(element.名称.slice(0, 2))
  106. this.TransplantdataArray.push(element.值)
  107. })
  108. this.isGetData = true
  109. })
  110. },
  111. getWeatherForecast() {
  112. this.$http.get(`/api/weatherForecast`).then((res) => {
  113. res.forEach((element) => {
  114. this.Weatherarea.push(element.时间)
  115. this.WeatherdataArray.push(element.温度)
  116. })
  117. this.isWeather = true
  118. })
  119. },
  120. getTransplantAreaInEachRegion() {
  121. this.$http.get(`/api/transplantAreaInEachRegion`).then((res) => {
  122. res.forEach((element) => {
  123. this.wavyLineArea.push(element.名称.slice(0, 2))
  124. this.wavyLinedataArray.LastYear.push(element.去年)
  125. this.wavyLinedataArray.thisYear.push(element.今年)
  126. })
  127. this.isWavyLine = true
  128. })
  129. },
  130. getAnalysisOfTransplantingSituation() {
  131. this.$http.get(`/api/analysisOfTransplantingSituation`).then((res) => {
  132. const date = res.sort((a, b) => b.已移载 - a.已移载)
  133. date.forEach((element) => {
  134. this.HorizontalArea.push(element.名称.slice(0, 2))
  135. this.HorizontalArray.Done.push(element.已移载)
  136. this.HorizontalArray.Percentage.push(element.比率.toFixed(0))
  137. })
  138. this.isHorizontal = true
  139. })
  140. },
  141. },
  142. }
  143. </script>
  144. <style lang="less" scoped>
  145. .home-container {
  146. position: absolute;
  147. left: 0;
  148. top: 0;
  149. width: 100%;
  150. height: 100%;
  151. .wrap {
  152. transform-origin: 0px 0px 0px;
  153. background: url(../../assets/img/bj.jpg) no-repeat;
  154. background-size: contain;
  155. background-position: 50% 0;
  156. background-color: rgb(0, 0, 0);
  157. min-width: auto;
  158. width: 1920px;
  159. min-height: auto;
  160. height: 1080px;
  161. overflow: auto;
  162. .top {
  163. position: absolute;
  164. left: 0;
  165. top: 0;
  166. width: 100%;
  167. height: 80px;
  168. background-color: transparent;
  169. background: url(../../assets/img/top_nav.png) no-repeat;
  170. background-position: 65% 0;
  171. border: none;
  172. overflow: hidden;
  173. }
  174. }
  175. }
  176. </style>