index.vue 9.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319
  1. <template>
  2. <div style="padding: 20px">
  3. <el-card>
  4. <div style="display:flex">
  5. <select-tree
  6. :placeholder="'年份'"
  7. style="width:200px"
  8. :treeData="treeData"
  9. @handlerClick="handlerClick"
  10. :checkVal="cusareaName"
  11. ></select-tree>
  12. <el-select
  13. style="width: 200px;margin-left:16px;"
  14. laceholder="请选择您的年份"
  15. v-model="waterrightYear"
  16. >
  17. <el-option
  18. v-for="item in options"
  19. :key="item.value"
  20. :label="item.label"
  21. :value="item.value">
  22. </el-option>
  23. </el-select>
  24. <el-button
  25. style="margin-left: 16px;"
  26. type="primary"
  27. size="small"
  28. @click="handleSearch"
  29. >查询</el-button
  30. >
  31. </div>
  32. </el-card>
  33. <div
  34. v-loading="loading"
  35. >
  36. <el-card style="margin: 16px 0">
  37. <el-skeleton v-if="isSkeleton"/>
  38. <el-row v-else :gutter="20"
  39. v-for="(item,index) in list"
  40. :key="index"
  41. >
  42. <el-col :span="4"
  43. v-for="(i,index) in item"
  44. :key="index"
  45. >
  46. <div class="card">
  47. <img :src="i.imageSrc"/>
  48. <div class="card_content_right">
  49. <span>{{i.title}}</span>
  50. <div>{{i.number}}</div>
  51. </div>
  52. </div>
  53. </el-col>
  54. </el-row>
  55. </el-card>
  56. <el-row :gutter="20">
  57. <el-col :span="10">
  58. <el-card class="pie-container">
  59. <echartsPieVue
  60. :useWaterNumTotal="useWaterNumTotal"
  61. :waterNum="waterNum"
  62. />
  63. <div class="pie-right">
  64. <div class="pie-item">
  65. <span>额定水量:</span>
  66. <span>{{ waterNum || 0 }} m³</span>
  67. </div>
  68. <div class="pie-item">
  69. <span>剩余水量:</span>
  70. <span>{{ waterBalance || 0 }} m³</span>
  71. </div>
  72. <div class="pie-item last-year">
  73. <span>去年同期节水:</span>
  74. <span>{{ waterSave || 0 }} m³</span>
  75. <svg
  76. xmlns="http://www.w3.org/2000/svg"
  77. width="16"
  78. height="16"
  79. viewBox="0 0 16 16"
  80. fill="none"
  81. >
  82. <path
  83. d="M6.66797 9.33335V3.16668C6.66797 2.79668 6.96931 2.50002 7.34131 2.50002H8.66131C8.74941 2.49914 8.83682 2.51573 8.91848 2.54884C9.00013 2.58195 9.07441 2.63091 9.13703 2.69291C9.19964 2.7549 9.24934 2.82869 9.28326 2.91001C9.31718 2.99133 9.33464 3.07857 9.33464 3.16668V9.33335H10.662C11.4 9.33335 11.6433 9.81068 11.202 10.4L8.80131 13.6C8.35597 14.1934 7.64331 14.1894 7.20131 13.6L4.80131 10.4C4.35597 9.80668 4.60131 9.33335 5.34064 9.33335H6.66797Z"
  84. fill="#14A478"
  85. />
  86. </svg>
  87. </div>
  88. <div class="pie-item">
  89. <span>节水率:</span>
  90. <span>{{ waterSaveProportion || 0}} m³</span>
  91. </div>
  92. </div>
  93. </el-card>
  94. </el-col>
  95. <el-col :span="14">
  96. <el-card>
  97. <echartsGradient
  98. :byMonthList="byMonthList"
  99. />
  100. </el-card>
  101. </el-col>
  102. </el-row>
  103. </div>
  104. </div>
  105. </template>
  106. <script>
  107. import { getTree } from '@/api/tree.js'
  108. import SelectTree from '@/components/SelectTree';
  109. import { getHomeList } from '@/api/home/index.js'
  110. import numberWells from './assets/number_wells.svg'
  111. import electricity from './assets/electricity.svg'
  112. import moneyIcon from './assets/money_icon.svg'
  113. import waterYield from './assets/water_yield.svg'
  114. import person from './assets/person.svg'
  115. import area from './assets/area.svg'
  116. import water from './assets/water.svg'
  117. import time from './assets/time.svg'
  118. import echartsPieVue from './components/echartsPie.vue'
  119. import echartsGradient from './components/echartsGradient.vue'
  120. export default {
  121. name: "Home",
  122. props: {},
  123. components:{
  124. echartsPieVue,
  125. echartsGradient,
  126. SelectTree,
  127. },
  128. data() {
  129. return {
  130. loading: true,
  131. options: [],
  132. byMonthList: [],
  133. treeData:[],
  134. cusareaName:'',
  135. areaId: '',
  136. area: '',
  137. isSkeleton: true,
  138. areaSelect: '',
  139. elecNumTotal: 0,
  140. farmerNum: 0,
  141. rechargeAmountTotal: 0,
  142. useMoneyPerMu: 0,
  143. useMoneyTotal: 0,
  144. useTimeTotal: 0,
  145. useWaterNumTotal: 0,
  146. useWaterPerMu: 0,
  147. waterBalance: 0,
  148. waterNum: 0,
  149. waterNumTotal: 0,
  150. waterSave: 0,
  151. waterSaveProportion: 0,
  152. waterrightYear: new Date().getFullYear(),
  153. list: [[{
  154. imageSrc: electricity,
  155. title: '水井数目(口)',
  156. number: 551
  157. },{
  158. imageSrc: numberWells,
  159. title: '使用电量(度)',
  160. number: 551
  161. },{
  162. imageSrc: waterYield,
  163. title: '使用水量(方)',
  164. number: 551
  165. },{
  166. imageSrc: moneyIcon,
  167. title: '使用金额(元)',
  168. number: 551
  169. },{
  170. imageSrc: person,
  171. title: '用户数量(人)',
  172. number: 551
  173. }],[{
  174. imageSrc: moneyIcon,
  175. title: '充值金额(元)',
  176. number: 551
  177. },{
  178. imageSrc: area,
  179. title: '灌溉面积(亩)',
  180. number: 551
  181. },{
  182. imageSrc: water,
  183. title: '亩均用水量(方)',
  184. number: 551
  185. },{
  186. imageSrc: moneyIcon,
  187. title: '亩均用金额(元)',
  188. number: 551
  189. },{
  190. imageSrc: time,
  191. title: '累计使用时间(H)',
  192. number: 551
  193. }]]
  194. }
  195. },
  196. methods: {
  197. setYear() {
  198. this.options = []
  199. let date = new Date
  200. let currentYear = date.getFullYear()
  201. this.currentYear = currentYear
  202. for (let i = 0; i < 5; i++) {
  203. this.options.push({
  204. label: currentYear - i,
  205. value: currentYear - i
  206. })
  207. }
  208. },
  209. handlerClick(value) {
  210. this.areaId = value?.cusareaId
  211. },
  212. handleSearch() {
  213. this.getHomeListHandler()
  214. },
  215. async getArea() {
  216. this.setYear()
  217. const treeList = this.$store.state.tree.treeList
  218. let res = []
  219. if (treeList.code === '000000') {
  220. res = treeList
  221. } else {
  222. res = await getTree()
  223. this.$store.dispatch('tree/setTree', res)
  224. }
  225. this.treeData = res?.data
  226. let tflag = true
  227. this.treeData.forEach(t => {
  228. if (t?.cusareaName == '全部') {
  229. tflag = false
  230. }
  231. })
  232. if (tflag) {
  233. this.treeData.unshift({
  234. id: '',
  235. cusareaId: '',
  236. cusareaName: '全部'
  237. })
  238. }
  239. this.cusareaName ||= this.treeData[0].cusareaName
  240. this.areaId = this.treeData[0].cusareaId
  241. this.getHomeListHandler()
  242. },
  243. async getHomeListHandler() {
  244. const params = {
  245. areaId: this.areaId,
  246. year: this.waterrightYear
  247. }
  248. this.loading = true
  249. const res = await getHomeList(params)
  250. this.loading = false
  251. this.isSkeleton = false
  252. this.requestData = res?.data
  253. this.elecNumTotal = this.requestData.elecNumTotal
  254. this.farmerNum = this.requestData.farmerNum
  255. this.rechargeAmountTotal = this.requestData.rechargeAmountTotal
  256. this.useMoneyPerMu = this.requestData.useMoneyPerMu
  257. this.useMoneyTotal = this.requestData.useMoneyTotal
  258. this.useTimeTotal = this.requestData.useTimeTotal
  259. this.useWaterNumTotal = this.requestData.useWaterNumTotal
  260. this.useWaterPerMu = this.requestData.useWaterPerMu
  261. this.waterBalance = this.requestData.waterBalance
  262. this.waterNum = this.requestData.waterNum
  263. this.waterNumTotal = this.requestData.waterNumTotal
  264. this.waterSave = this.requestData.waterSave
  265. this.waterSaveProportion = this.requestData.waterSaveProportion
  266. this.byMonthList = this.requestData.byMonthList
  267. this.list = [[{
  268. imageSrc: numberWells,
  269. title: '水井数目(口)',
  270. number: this.waterNumTotal || 0
  271. }, {
  272. imageSrc: electricity,
  273. title: '使用电量(度)',
  274. number: this.elecNumTotal || 0
  275. }, {
  276. imageSrc: waterYield,
  277. title: '使用水量(m³)',
  278. number: this.useWaterNumTotal || 0
  279. }, {
  280. imageSrc: moneyIcon,
  281. title: '使用金额(元)',
  282. number: this.useMoneyTotal || 0
  283. }, {
  284. imageSrc: person,
  285. title: '用户数量(人)',
  286. number: this.farmerNum || 0
  287. }], [{
  288. imageSrc: moneyIcon,
  289. title: '充值金额(元)',
  290. number: this.rechargeAmountTotal || 0
  291. }, {
  292. imageSrc: area,
  293. title: '灌溉面积(亩)',
  294. number: this.areaSize || 0
  295. }, {
  296. imageSrc: water,
  297. title: '亩均用水量(m³)',
  298. number: this.useWaterPerMu || 0
  299. }, {
  300. imageSrc: moneyIcon,
  301. title: '亩均用金额(元)',
  302. number: this.useMoneyPerMu || 0
  303. }, {
  304. imageSrc: time,
  305. title: '累计使用时间(H)',
  306. number: this.useTimeTotal || 0
  307. }]]
  308. }
  309. },
  310. mounted() {
  311. this.getArea()
  312. }
  313. };
  314. </script>
  315. <style lang="scss" scoped>
  316. @import './assets/home.scss'
  317. </style>