index.vue 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301
  1. <template>
  2. <bgBox :tabChange="tabChange" class="bgBox" :tabIndex="0">
  3. <cake
  4. style="position: absolute; top: 115px; left: 50px"
  5. title="实时统计"
  6. :data="statisticsData"
  7. class="animated fadeInLeft"
  8. v-if="isCake"
  9. />
  10. <cylindricalHistogram
  11. style="position: absolute; left: 50px; top: 430px"
  12. class="animated fadeInLeft"
  13. v-if="isGetData"
  14. :unit="`公斤/产量`"
  15. title="各区域移栽产量分析"
  16. :area="Transplantarea"
  17. :dataArray="TransplantdataArray"
  18. />
  19. <weatherForecast
  20. :unit="`摄氏度`"
  21. style="position: absolute; left: 50px; top: 760px"
  22. class="animated fadeInLeft"
  23. v-if="isWeather"
  24. title="天气预报"
  25. :area="Weatherarea"
  26. :dataArray="WeatherdataArray"
  27. :alertValue="30"
  28. />
  29. <wavyLineChart
  30. :unit="`平方米/面积`"
  31. id="`wavyLineChart`"
  32. style="position: absolute; right: 50px; top: 115px"
  33. class="animated fadeInRight"
  34. v-if="isWavyLine"
  35. title="各区域移栽面积"
  36. :area.sync="wavyLineArea"
  37. :dataArray.sync="wavyLinedataArray"
  38. smooth="true"
  39. />
  40. <HorizontalHistogram
  41. style="position: absolute; right: 50px; top: 430px"
  42. class="animated fadeInRight"
  43. v-if="isHorizontal"
  44. id="`移栽情况分析`"
  45. title="移栽情况分析"
  46. :area="HorizontalArea"
  47. :dataArray="HorizontalArray"
  48. />
  49. <wavyLineChart
  50. id="`移栽趋势分析`"
  51. style="position: absolute; right: 50px; top: 760px"
  52. class="animated fadeInRight"
  53. v-if="isWavyLine"
  54. title="移栽趋势分析"
  55. :area.sync="trendarea"
  56. :dataArray.sync="trendDataArray"
  57. />
  58. <threeMap
  59. style="
  60. position: absolute;
  61. top: 50%;
  62. left: 50%;
  63. transform: translate(-55%, 20%);
  64. "
  65. v-if="hasGetJson"
  66. :getJson="getJson"
  67. ></threeMap>
  68. </bgBox>
  69. </template>
  70. <script>
  71. import bgBox from '@/components/bgBox/index.vue'
  72. import { screenSize } from '@/assets/js/utils'
  73. import cake from '@/components/Customize/cake'
  74. import cylindricalHistogram from '@/components/Customize/cylindricalHistogram'
  75. import weatherForecast from '@/components/Customize/weatherForecast'
  76. import wavyLineChart from '@/components/Customize/wavyLineChart'
  77. import HorizontalHistogram from '@/components/Customize/HorizontalHistogram'
  78. import threeMap from '@/components/Customize/map/index'
  79. export default {
  80. name: `Home`,
  81. components: {
  82. cylindricalHistogram,
  83. weatherForecast,
  84. wavyLineChart,
  85. HorizontalHistogram,
  86. bgBox,
  87. threeMap,
  88. cake,
  89. },
  90. data() {
  91. return {
  92. autoVueFnInit: false,
  93. statisticsData: {
  94. title: `目标完成率`,
  95. value: 0,
  96. acrossList: [
  97. { name: `年移栽数量`, value: undefined },
  98. { name: `年移栽面积`, value: undefined },
  99. ],
  100. verticalList: [
  101. { name: `移栽区域数`, value: undefined },
  102. { name: `烟农数量`, value: undefined },
  103. ],
  104. },
  105. TransplantdataArray: [],
  106. Transplantarea: [],
  107. Weatherarea: [],
  108. WeatherdataArray: [],
  109. wavyLineArea: [],
  110. wavyLinedataArray: {
  111. LastYear: [],
  112. thisYear: [],
  113. },
  114. trendarea: [],
  115. trendDataArray: {
  116. LastYear: [],
  117. thisYear: [],
  118. },
  119. HorizontalArea: [],
  120. HorizontalArray: {
  121. Done: [],
  122. Percentage: [],
  123. },
  124. getJson: {},
  125. isGetData: false,
  126. isWeather: false,
  127. isWavyLine: false,
  128. isHorizontal: false,
  129. isTrend: false,
  130. hasGetJson: false,
  131. isCake: false,
  132. }
  133. },
  134. computed: {},
  135. created() {
  136. this.$util.autoVueFn(
  137. [
  138. {
  139. time: 1000 * 5,
  140. fn: this.getWeatherForecast,
  141. },
  142. {
  143. time: 1000 * 5,
  144. fn: this.getAnalysisOfTransplantYieldInVariousRegions,
  145. },
  146. {
  147. time: 1000 * 5,
  148. fn: this.getTransplantAreaInEachRegion,
  149. },
  150. {
  151. time: 1000 * 5,
  152. fn: this.getAnalysisOfTransplantingSituation,
  153. },
  154. {
  155. time: 1000 * 5,
  156. fn: this.getStatistics,
  157. },
  158. {
  159. time: 1000 * 5,
  160. fn: this.getTrendAnalysis,
  161. },
  162. ],
  163. {
  164. vm: this,
  165. batEnd() {
  166. this.autoVueFnInit = true
  167. },
  168. }
  169. )
  170. this.getJSON()
  171. // this.$http.get(`https://httpbin.org/get`)
  172. },
  173. mounted() {},
  174. methods: {
  175. tabChange(val) {
  176. if (val === 0) {
  177. this.$router.push(`/page1`)
  178. } else if (val === 1) {
  179. this.$router.push(`/page2`)
  180. }
  181. console.log(`val`, val)
  182. },
  183. getAnalysisOfTransplantYieldInVariousRegions() {
  184. return this.$http
  185. .get(`/api/analysisOfTransplantYieldInVariousRegions`)
  186. .then((res) => {
  187. const area = []
  188. const dataArray = []
  189. res.forEach((element) => {
  190. area.push(element.名称.slice(0, 2))
  191. dataArray.push(element.值)
  192. })
  193. this.Transplantarea = area
  194. this.TransplantdataArray = dataArray
  195. this.isGetData = true
  196. })
  197. },
  198. getWeatherForecast() {
  199. return this.$http.get(`/api/weatherForecast`).then((res) => {
  200. const area = []
  201. const dataArray = []
  202. res.forEach((element) => {
  203. area.push(element.时间)
  204. dataArray.push(element.温度)
  205. })
  206. this.Weatherarea = area
  207. this.WeatherdataArray = dataArray
  208. this.isWeather = true
  209. })
  210. },
  211. getTransplantAreaInEachRegion() {
  212. return this.$http.get(`/api/transplantAreaInEachRegion`).then((res) => {
  213. const area = []
  214. const dataArray = {
  215. LastYear: [],
  216. thisYear: [],
  217. }
  218. res.forEach((element) => {
  219. area.push(element.名称.slice(0, 2))
  220. dataArray.LastYear.push(element.去年)
  221. dataArray.thisYear.push(element.今年)
  222. })
  223. this.wavyLineArea = area
  224. this.wavyLinedataArray = dataArray
  225. this.isWavyLine = true
  226. })
  227. },
  228. getAnalysisOfTransplantingSituation() {
  229. return this.$http
  230. .get(`/api/analysisOfTransplantingSituation`)
  231. .then((res) => {
  232. const area = []
  233. const dataArray = {
  234. Done: [],
  235. Percentage: [],
  236. }
  237. const date = res.sort((a, b) => b.已移载 - a.已移载)
  238. date.forEach((element) => {
  239. area.push(element.名称.slice(0, 2))
  240. dataArray.Done.push(element.已移载)
  241. dataArray.Percentage.push(element.比率.toFixed(0))
  242. })
  243. this.HorizontalArea = area
  244. this.HorizontalArray = dataArray
  245. this.isHorizontal = true
  246. })
  247. },
  248. getStatistics() {
  249. return this.$http.get(`/api/realTimeStatistics`).then((res) => {
  250. const obj = this.statisticsData
  251. // eslint-disable-next-line no-prototype-builtins
  252. if (res.hasOwnProperty(obj.title)) {
  253. obj.value = res[obj.title]
  254. }
  255. const list1 = this.statisticsData.acrossList
  256. this.statisticsData.acrossList = list1.map((item) => {
  257. // eslint-disable-next-line no-prototype-builtins
  258. if (res.hasOwnProperty(item.name)) {
  259. return { ...item, value: res[item.name] }
  260. }
  261. return item
  262. })
  263. const list2 = this.statisticsData.verticalList
  264. this.statisticsData.verticalList = list2.map((item) => {
  265. // eslint-disable-next-line no-prototype-builtins
  266. if (res.hasOwnProperty(item.name)) {
  267. return { ...item, value: res[item.name] }
  268. }
  269. return item
  270. })
  271. this.isCake = true
  272. })
  273. },
  274. getTrendAnalysis() {
  275. return this.$http.get(`/api/transplantTrendAnalysis`).then((res) => {
  276. const area = []
  277. const dataArray = {
  278. LastYear: [],
  279. thisYear: [],
  280. }
  281. res.forEach((element) => {
  282. area.push(element.时间)
  283. dataArray.LastYear.push(element.去年)
  284. dataArray.thisYear.push(element.今年)
  285. })
  286. this.trendarea = area
  287. this.trendDataArray = dataArray
  288. this.isTrend = true
  289. })
  290. },
  291. async getJSON() {
  292. console.log(`获取JSOn`)
  293. this.getJson = await this.$http.get(`/api/mapOfTongren`)
  294. this.hasGetJson = true
  295. },
  296. },
  297. }
  298. </script>