index.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542
  1. <template>
  2. <bgBox :tabChange="tabChange" class="bgBox" bgType="g-bg3">
  3. <div class="main">
  4. <div class="topBar">
  5. <div class="query">
  6. <img src="@/assets/img2/种植分析详情/编组 8.png" alt="" />
  7. <el-radio-group v-model="query.radio" class="radio-group">
  8. <el-radio class="date" :label="6">近一周</el-radio>
  9. <el-radio class="date" :label="30">近30天</el-radio>
  10. <el-radio class="date" :label="90">近90天</el-radio>
  11. </el-radio-group>
  12. <el-date-picker
  13. :pickerOptions="pickerOptions0"
  14. v-model="query.date[0]"
  15. type="date"
  16. placeholder="开始日期"
  17. class="mr-20px ml-20px date"
  18. >
  19. </el-date-picker>
  20. <el-date-picker
  21. class="date"
  22. :pickerOptions="pickerOptions1"
  23. v-model="query.date[1]"
  24. type="date"
  25. placeholder="结束日期"
  26. >
  27. </el-date-picker>
  28. </div>
  29. <img
  30. @click="backFn"
  31. src="@/assets/img2/种植分析详情/编组 16备份.png"
  32. alt=""
  33. />
  34. </div>
  35. <leftBox class="lefBox" />
  36. <leftBox2 class="lefBox2" />
  37. <cake
  38. id="`移栽数据`"
  39. barWidth="448px"
  40. style="position: absolute; top: 95px; right: 550px"
  41. title="移栽数据"
  42. :data="statisticsData"
  43. class="animated fadeInRight"
  44. v-if="isCake"
  45. />
  46. <weatherForecast
  47. :unit="`摄氏度`"
  48. barWidth="448px"
  49. style="position: absolute; right: 50px; top: 95px"
  50. class="animated fadeInRight"
  51. v-if="isWeather"
  52. title="实时天气"
  53. :area="Weatherarea"
  54. :dataArray="WeatherdataArray"
  55. :alertValue="30"
  56. />
  57. <wavyLineChart
  58. id="`月度移栽趋势`"
  59. barWidth="448px"
  60. style="position: absolute; right: 550px; top: 400px; z-index: 10"
  61. v-if="isMonthTrend"
  62. :lineName="monthName"
  63. title="月度移栽趋势"
  64. class="animated fadeInRight"
  65. :area.sync="monthTrendarea"
  66. :dataArray.sync="monthTrendDataArray"
  67. />
  68. <wavyLineChart
  69. id="`月度移栽面积分析`"
  70. barWidth="448px"
  71. style="position: absolute; right: 550px; top: 730px; z-index: 10"
  72. v-if="isAnalyseMonthTrend"
  73. :lineName="monthName"
  74. title="月度移栽面积分析"
  75. class="animated fadeInRight"
  76. :area.sync="monthTrendAnalysearea"
  77. :dataArray.sync="monthTrendAnalyseDataArray"
  78. />
  79. <wavyLineChart
  80. id="`年度移栽趋势`"
  81. barWidth="448px"
  82. style="position: absolute; right: 50px; top: 400px; z-index: 10"
  83. :lineName="yearName"
  84. title="年度移栽趋势"
  85. :area.sync="yearTrendarea"
  86. class="animated fadeInRight"
  87. :dataArray.sync="yearTrendDataArray"
  88. v-if="isYearTrend"
  89. />
  90. <wavyLineChart
  91. id="`年度移栽面积分析`"
  92. barWidth="448px"
  93. style="position: absolute; right: 50px; top: 730px; z-index: 10"
  94. :lineName="yearName"
  95. title="年度移栽面积分析"
  96. :area.sync="yearTrendAnalysearea"
  97. class="animated fadeInRight"
  98. :dataArray.sync="yearTrendAnalyseDataArray"
  99. v-if="isAnalyseYearTrend"
  100. />
  101. </div>
  102. </bgBox>
  103. </template>
  104. <script>
  105. import 'element-ui/lib/theme-chalk/index.css'
  106. import wavyLineChart from '@/components/Customize/wavyLineChart'
  107. import weatherForecast from '@/components/Customize/weatherForecast'
  108. import cake from '@/components/Customize/cake'
  109. import bgBox from '@/components/bgBox/index.vue'
  110. import leftBox from './leftBox.vue'
  111. import leftBox2 from './leftBox2.vue'
  112. import { Button, DatePicker, RadioGroup, Radio } from 'element-ui'
  113. import Vue from 'vue'
  114. import dayjs from 'dayjs'
  115. // 获取近一周的日期范围
  116. function getLastDay(day) {
  117. const end = dayjs() // 当前日期
  118. const start = end.subtract(day, `day`) // 前六天
  119. return { start: start.format(`YYYY-MM-DD`), end: end.format(`YYYY-MM-DD`) }
  120. }
  121. window.getLastDay = getLastDay
  122. window.dayjs = dayjs
  123. Vue.use(Button)
  124. Vue.use(RadioGroup)
  125. Vue.use(Radio)
  126. Vue.use(DatePicker)
  127. export default {
  128. components: {
  129. leftBox,
  130. leftBox2,
  131. bgBox,
  132. wavyLineChart,
  133. weatherForecast,
  134. cake,
  135. },
  136. data() {
  137. const vm = this
  138. return {
  139. pickerOptions0: {
  140. disabledDate(time) {
  141. return time.getTime() > Date.now()
  142. },
  143. },
  144. pickerOptions1: {
  145. disabledDate(time) {
  146. if (vm.query.date[0]) {
  147. return (
  148. time.getTime() < vm.query.date[0] || time.getTime() > Date.now()
  149. )
  150. } else {
  151. return time.getTime() > Date.now()
  152. }
  153. },
  154. },
  155. query: {
  156. radio: 6,
  157. date: [],
  158. },
  159. trendarea: [],
  160. trendDataArray: {
  161. LastYear: [],
  162. thisYear: [],
  163. },
  164. monthTrendarea: [],
  165. monthTrendDataArray: {
  166. LastYear: [],
  167. thisYear: [],
  168. },
  169. monthName: {
  170. lastName: `上月`,
  171. thisName: `本月`,
  172. },
  173. monthTrendAnalysearea: [],
  174. monthTrendAnalyseDataArray: [],
  175. yearTrendarea: [],
  176. yearTrendDataArray: {
  177. LastYear: [],
  178. thisYear: [],
  179. },
  180. isMonthTrend: false,
  181. isYearTrend: false,
  182. isAnalyseMonthTrend: false,
  183. isAnalyseYearTrend: false,
  184. yearName: {
  185. lastName: `去年`,
  186. thisName: `今年`,
  187. },
  188. yearTrendAnalysearea: [],
  189. yearTrendAnalyseDataArray: [],
  190. statisticsData: {
  191. title: `处理率`,
  192. value: 0,
  193. acrossList: [{ name: `今日种植数`, value: undefined }],
  194. verticalList: [
  195. { name: `目标移栽数`, value: undefined },
  196. { name: `累计移栽`, value: undefined },
  197. ],
  198. },
  199. Weatherarea: [],
  200. WeatherdataArray: [],
  201. isCake: false,
  202. isWeather: false,
  203. baseId: this.$route.query.id || 1,
  204. }
  205. },
  206. computed: {},
  207. async created() {
  208. this.$util.autoVueFn(
  209. [
  210. {
  211. time: 1000 * 3600,
  212. fn: this.getTrendOfTransplantQuantityThisMonth,
  213. },
  214. {
  215. time: 1000 * 3600,
  216. fn: this.getThisYearsTransplantingDataTrend,
  217. },
  218. {
  219. time: 1000 * 3600,
  220. fn: this.getMonthlyTransplantationAreaAnalysis,
  221. },
  222. {
  223. time: 1000 * 3600,
  224. fn: this.getAnalysisOfAnnualTransplantArea,
  225. },
  226. {
  227. time: 1000 * 3600,
  228. fn: this.getStatistics,
  229. },
  230. {
  231. time: 1000 * 3600,
  232. fn: this.getWeatherForecast,
  233. },
  234. ],
  235. this
  236. )
  237. },
  238. watch: {
  239. 'query.radio': {
  240. handler(val) {
  241. if (this.query.radio) {
  242. this.query.date = []
  243. const { start, end } = getLastDay(this.query.radio)
  244. this.getEchartData(start, end)
  245. }
  246. },
  247. immediate: true,
  248. },
  249. 'query.date'([a, b] = []) {
  250. if (a && b) {
  251. this.query.radio = 0
  252. const start = dayjs(a || Date.now()).format(`YYYY-MM-DD`)
  253. const end = dayjs(b || Date.now()).format(`YYYY-MM-DD`)
  254. this.getEchartData(start, end)
  255. } else if (!a && !b && !this.query.radio) {
  256. this.query.radio = 6
  257. }
  258. },
  259. },
  260. mounted() {},
  261. methods: {
  262. getEchartData(start, end) {
  263. console.log(`start, end`, start, end)
  264. },
  265. getWeatherForecast() {
  266. return this.$http
  267. .get(`/api/weatherForecast`, {
  268. params: {
  269. districtId: this.baseId,
  270. },
  271. })
  272. .then((res) => {
  273. if (res) {
  274. const area = []
  275. const dataArray = {
  276. temperature: [],
  277. Weather: [],
  278. }
  279. res.forEach((element) => {
  280. area.push(element.时间)
  281. dataArray.temperature.push(element.温度)
  282. dataArray.Weather.push(element.天气)
  283. })
  284. this.Weatherarea = area
  285. this.WeatherdataArray = dataArray
  286. this.isWeather = true
  287. }
  288. })
  289. },
  290. getTrendOfTransplantQuantityThisMonth() {
  291. this.$http
  292. .get(`/api/transplantTrendAnalysis`, {
  293. params: {
  294. districtId: this.baseId,
  295. },
  296. })
  297. .then((res) => {
  298. if (res) {
  299. const area = []
  300. const dataArray = {
  301. LastYear: [],
  302. thisYear: [],
  303. comparisonLastDay: [],
  304. comparisonLastYear: [],
  305. }
  306. res.forEach((element) => {
  307. area.push(element.时间)
  308. dataArray.LastYear.push(element.去年)
  309. dataArray.thisYear.push(element.今年)
  310. dataArray.comparisonLastDay.push(element.较上日)
  311. dataArray.comparisonLastYear.push(element.较去年)
  312. })
  313. this.monthTrendarea = area
  314. this.monthTrendDataArray = dataArray
  315. this.isMonthTrend = true
  316. }
  317. })
  318. },
  319. getMonthlyTransplantationAreaAnalysis() {
  320. this.$http
  321. .get(`/api/monthlyTransplantationAreaAnalysis`, {
  322. params: {
  323. districtId: this.baseId,
  324. },
  325. })
  326. .then((res) => {
  327. if (res) {
  328. const area = []
  329. const dataArray = {
  330. LastYear: [],
  331. thisYear: [],
  332. comparisonLastDay: [],
  333. comparisonLastYear: [],
  334. }
  335. res.forEach((element) => {
  336. area.push(element.时间)
  337. dataArray.LastYear.push(element.去年)
  338. dataArray.thisYear.push(element.今年)
  339. dataArray.comparisonLastDay.push(element.较上日)
  340. dataArray.comparisonLastYear.push(element.较去年)
  341. })
  342. this.monthTrendAnalysearea = area
  343. this.monthTrendAnalyseDataArray = dataArray
  344. this.isAnalyseMonthTrend = true
  345. }
  346. })
  347. },
  348. getThisYearsTransplantingDataTrend() {
  349. this.$http
  350. .get(`/api/thisYearsTransplantingDataTrend`, {
  351. params: {
  352. districtId: this.baseId,
  353. },
  354. })
  355. .then((res) => {
  356. if (res) {
  357. const area = []
  358. const dataArray = {
  359. LastYear: [],
  360. thisYear: [],
  361. comparisonLastDay: [],
  362. comparisonLastYear: [],
  363. }
  364. res.forEach((element) => {
  365. area.push(element.时间)
  366. dataArray.LastYear.push(element.去年)
  367. dataArray.thisYear.push(element.今年)
  368. dataArray.comparisonLastDay.push(element.较上日)
  369. dataArray.comparisonLastYear.push(element.较去年)
  370. })
  371. this.yearTrendarea = area
  372. this.yearTrendDataArray = dataArray
  373. this.isYearTrend = true
  374. }
  375. })
  376. },
  377. getAnalysisOfAnnualTransplantArea() {
  378. this.$http
  379. .get(`/api/analysisOfAnnualTransplantArea`, {
  380. params: {
  381. districtId: this.baseId,
  382. },
  383. })
  384. .then((res) => {
  385. if (res) {
  386. const area = []
  387. const dataArray = {
  388. LastYear: [],
  389. thisYear: [],
  390. comparisonLastDay: [],
  391. comparisonLastYear: [],
  392. }
  393. res.forEach((element) => {
  394. area.push(element.时间)
  395. dataArray.LastYear.push(element.去年)
  396. dataArray.thisYear.push(element.今年)
  397. dataArray.comparisonLastDay.push(element.较上日)
  398. dataArray.comparisonLastYear.push(element.较去年)
  399. })
  400. this.yearTrendAnalysearea = area
  401. this.yearTrendAnalyseDataArray = dataArray
  402. this.isAnalyseYearTrend = true
  403. }
  404. })
  405. },
  406. getStatistics() {
  407. return this.$http
  408. .get(`/api/transplantData`, {
  409. params: {
  410. districtId: this.baseId,
  411. },
  412. })
  413. .then((res) => {
  414. const obj = this.statisticsData
  415. // eslint-disable-next-line no-prototype-builtins
  416. if (res.hasOwnProperty(obj.title)) {
  417. obj.value = res[obj.title]
  418. }
  419. const list1 = this.statisticsData.acrossList
  420. this.statisticsData.acrossList = list1.map((item) => {
  421. // eslint-disable-next-line no-prototype-builtins
  422. if (res.hasOwnProperty(item.name)) {
  423. return { ...item, value: res[item.name] }
  424. }
  425. return item
  426. })
  427. const list2 = this.statisticsData.verticalList
  428. this.statisticsData.verticalList = list2.map((item) => {
  429. // eslint-disable-next-line no-prototype-builtins
  430. if (res.hasOwnProperty(item.name)) {
  431. return { ...item, value: res[item.name] }
  432. }
  433. return item
  434. })
  435. this.isCake = true
  436. })
  437. },
  438. backFn() {
  439. this.$router.back()
  440. },
  441. tabChange(val) {
  442. console.log(`val`, val)
  443. },
  444. },
  445. }
  446. </script>
  447. <style lang="less" scoped>
  448. .bgBox {
  449. .main {
  450. padding: 50px;
  451. padding-top: 45px;
  452. .topBar {
  453. display: flex;
  454. justify-content: space-between;
  455. align-items: center;
  456. }
  457. .lefBox,
  458. .lefBox2 {
  459. position: absolute;
  460. z-index: 10;
  461. top: 120px;
  462. }
  463. .lefBox {
  464. left: 458px;
  465. }
  466. .lefBox2 {
  467. left: 47px;
  468. }
  469. .query {
  470. font-size: 14px;
  471. display: flex;
  472. align-items: center;
  473. .radio-group {
  474. margin-top: -1px;
  475. margin-left: 20px;
  476. }
  477. .date {
  478. background: rgba(255, 255, 255, 0.2);
  479. border-radius: 10px;
  480. }
  481. ::v-deep {
  482. .el-radio__input.is-checked + .el-radio__label {
  483. color: rgba(255, 255, 255, 0.8);
  484. }
  485. .el-input__suffix {
  486. right: 0;
  487. }
  488. .el-radio {
  489. background: rgba(255, 255, 255, 0.2);
  490. box-sizing: border-box;
  491. height: 27px;
  492. padding: 0 10px;
  493. line-height: 27px;
  494. color: rgba(255, 255, 255, 0.8);
  495. margin-right: 5px;
  496. }
  497. .el-input--prefix .el-input__inner {
  498. padding: 0;
  499. }
  500. .el-input__prefix {
  501. display: none;
  502. }
  503. .el-date-editor.el-input {
  504. width: 120px;
  505. }
  506. .el-input__icon {
  507. line-height: 27px;
  508. height: 27px;
  509. }
  510. .el-input__inner {
  511. border-radius: 10px;
  512. width: 120px;
  513. height: 27px;
  514. box-sizing: border-box;
  515. line-height: 27px;
  516. color: rgba(255, 255, 255, 0.8);
  517. text-align: center;
  518. border-width: 0;
  519. }
  520. .el-input__inner,
  521. .el-radio__inner {
  522. background-color: transparent;
  523. }
  524. }
  525. }
  526. }
  527. ::v-deep {
  528. .top {
  529. display: none;
  530. }
  531. *[aria-hidden='true'] {
  532. display: none;
  533. }
  534. }
  535. }
  536. </style>