index.vue 8.9 KB

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