index.vue 7.9 KB

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