DrinkWater.vue 9.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419
  1. <template>
  2. <div class="drinkWater">
  3. <div class="reply" :style="{color: color}">全场饮水情况</div>
  4. <x-form :formItems="formItems" :day="day" @setDay="setDay" @onClickType="onClickType"></x-form>
  5. <div class="echarts" v-if="allWaterCount && allWaterList.length > 0">
  6. <div class="echarts-l">
  7. <chart-water-pie :waterCount="allWaterCount"></chart-water-pie>
  8. </div>
  9. <div class="echarts-r">
  10. <chart-water :dataValue="allWaterList"></chart-water>
  11. </div>
  12. </div>
  13. <div class="echarts" v-else>
  14. <el-empty description="暂无数据" style="width: 100%;"></el-empty>
  15. </div>
  16. <br/>
  17. <div class="reply" :style="{color: color}">饮用水详情</div>
  18. <div class="carousel">
  19. <swiper class="swiper" :options="swiperOption">
  20. <swiper-slide v-for="(item, i) in list" :key="i" style="padding-top: 10px">
  21. <div class="box">
  22. <p>{{item.room}}</p>
  23. <div class="flex">
  24. <div>
  25. <i class="icon1"></i>
  26. </div>
  27. <div>
  28. <span>{{item.water == null ? '设备暂无数据' : item.water + '吨'}}</span>
  29. </div>
  30. </div>
  31. </div>
  32. </swiper-slide>
  33. <div class="swiper-pagination" slot="pagination"></div>
  34. <div class="swiper-button-prev" slot="button-prev"></div>
  35. <div class="swiper-button-next" slot="button-next"></div>
  36. </swiper>
  37. </div>
  38. <br/>
  39. <div class="reply" :style="{color: color}">筛选查询</div>
  40. <x-form :formItems="selectItems" :day="day1" @setDay="setDay1" @setChange="setChange" @onClickType="onClickType1"></x-form>
  41. <div class="echarts" v-if=" waterList.length > 0">
  42. <div class="echarts-l">
  43. <chart-water-pie :id="'1'" :waterCount="waterCount"></chart-water-pie>
  44. </div>
  45. <div class="echarts-r">
  46. <chart-water :id="'1'" :dataValue="waterList" :room="waterRoom"></chart-water>
  47. </div>
  48. </div>
  49. <div class="echarts" v-else>
  50. <el-empty description="暂无数据" style="width: 100%;"></el-empty>
  51. </div>
  52. </div>
  53. </template>
  54. <script>
  55. import XForm from "@/components/XForm";
  56. import ChartWaterPie from "@/views/Env/chart/ChartWaterPie";
  57. import ChartWater from "@/views/dashboard/chart/ChartWater";
  58. import { swiper, swiperSlide } from 'vue-awesome-swiper';
  59. import 'swiper/css/swiper.css';
  60. import { mapState } from 'vuex';
  61. import {getAllDayWater, getByFloor, getListAllWater, getListWater, getSchool, getUid} from "../../utils/api";
  62. import {timeDate} from "../../utils";
  63. export default {
  64. name: "DrinkWater",
  65. components: {
  66. XForm,
  67. ChartWaterPie,
  68. ChartWater,
  69. swiper,
  70. swiperSlide
  71. },
  72. computed: {
  73. ...mapState(['color'])
  74. },
  75. data() {
  76. return {
  77. formItems: [
  78. {
  79. id: 1,
  80. type: 'text',
  81. text: '今日',
  82. value: 1,
  83. col: 1
  84. },
  85. {
  86. id: 2,
  87. type: 'text',
  88. text: '本周',
  89. value: 2,
  90. col: 1
  91. },
  92. {
  93. id: 3,
  94. type: 'text',
  95. text: '本月',
  96. value: 3,
  97. col: 1
  98. },
  99. {
  100. id: 4,
  101. type: 'datepicker',
  102. placeholder: [],
  103. field: 'value1',
  104. col: 6
  105. },
  106. {
  107. id: 6,
  108. type: 'button',
  109. text: '查询',
  110. col: 2,
  111. click: 'search'
  112. },
  113. {
  114. id: 5,
  115. type: 'button',
  116. text: '导出数据',
  117. col: 2,
  118. click: 'derive'
  119. }
  120. ],
  121. day: 1,
  122. swiperOption: {
  123. slidesPerView: 8,
  124. spaceBetween: 30,
  125. autoplay: {
  126. delay: 2500,
  127. disableOnInteraction: false
  128. },
  129. pagination: {
  130. el: '.swiper-pagination',
  131. type: 'progressbar'
  132. },
  133. navigation: {
  134. nextEl: '.swiper-button-next',
  135. prevEl: '.swiper-button-prev'
  136. }
  137. },
  138. selectItems: [
  139. {
  140. id: 1,
  141. type: 'select',
  142. label: '栋舍:',
  143. placeholder: '请选择栋舍',
  144. field: 'floorId',
  145. options: [],
  146. col: 4
  147. },
  148. {
  149. id: 2,
  150. type: 'select',
  151. label: '楼层:',
  152. placeholder: '请选择楼层',
  153. field: 'uid',
  154. options: [],
  155. col: 4
  156. },
  157. {
  158. id: 10,
  159. type: 'select',
  160. label: '单元:',
  161. placeholder: '请选择单元',
  162. field: 'unitId',
  163. options: [],
  164. col: 4
  165. },
  166. {
  167. id: 3,
  168. type: 'text',
  169. text: '今日',
  170. value: 1,
  171. col: 1
  172. },
  173. {
  174. id: 4,
  175. type: 'text',
  176. text: '本周',
  177. value: 2,
  178. col: 1
  179. },
  180. {
  181. id: 5,
  182. type: 'text',
  183. text: '本月',
  184. value: 3,
  185. col: 1
  186. },
  187. {
  188. id: 6,
  189. type: 'datepicker',
  190. placeholder: [],
  191. field: 'value1',
  192. col: 6
  193. },
  194. {
  195. id: 8,
  196. type: 'button',
  197. text: '查询',
  198. col: 1,
  199. click: 'search'
  200. },
  201. {
  202. id: 7,
  203. type: 'button',
  204. text: '导出数据',
  205. col: 2,
  206. click: 'derive'
  207. }
  208. ],
  209. day1: 2,
  210. dataValue: [12, 13, 10, 13, 9, 23, 21, 21, 24, 23, 14, 21, 21],
  211. list: [],
  212. allWaterList: [],
  213. allWaterCount: null,
  214. waterList: [],
  215. waterCount: null,
  216. waterRoom: '',
  217. }
  218. },
  219. methods: {
  220. init() {
  221. getAllDayWater().then(res => {
  222. if(res.code === 10000) {
  223. this.list = res.data
  224. }
  225. })
  226. },
  227. initAllWater() {
  228. getListAllWater({}).then(res => {
  229. if(res.code === 10000) {
  230. let that = this;
  231. that.allWaterList = res.data.data;
  232. that.allWaterCount = res.data.countWater;
  233. }
  234. })
  235. },
  236. initWater() {
  237. getListWater({}).then(res => {
  238. if(res.code === 10000) {
  239. this.waterList = res.data.data;
  240. this.waterCount = res.data.countWater;
  241. this.waterRoom = res.data.room;
  242. }
  243. })
  244. },
  245. getSchool() {
  246. getSchool().then(res => {
  247. if(res.code === 10000) {
  248. res.data.forEach(item => {
  249. item.value = item.id;
  250. item.label = item.floorName;
  251. })
  252. this.selectItems[0].options = res.data;
  253. }
  254. })
  255. },
  256. setChange(item) {
  257. if(item.type === 'floorId') {
  258. let params = {
  259. floorId: item.data
  260. }
  261. getByFloor(params).then(res => {
  262. res.data.forEach(item => {
  263. item.value = item.uid;
  264. item.label = item.alias
  265. })
  266. this.selectItems[1].options = res.data;
  267. })
  268. } else if(item.type === 'uid') {
  269. let params = {
  270. uid: item.data
  271. }
  272. getUid(params).then(res => {
  273. res.data.forEach(item => {
  274. item.value = item.id;
  275. item.label = item.roomName
  276. })
  277. this.selectItems[2].options = res.data
  278. })
  279. }
  280. },
  281. setDay(data) {
  282. this.day = data;
  283. },
  284. onClickType(data) {
  285. let params = {};
  286. if(data.data.value1) {
  287. params = {
  288. startDate: data.data.value1[0],
  289. endDate: data.data.value1[1],
  290. type: 4
  291. }
  292. } else {
  293. params = {
  294. endDate: timeDate(new Date().getTime()),
  295. type: this.day
  296. }
  297. }
  298. getListAllWater(params).then(res => {
  299. if(res.code === 10000) {
  300. let that = this;
  301. that.allWaterList = res.data.data;
  302. that.allWaterCount = res.data.countWater;
  303. }
  304. })
  305. },
  306. setDay1(data) {
  307. this.day1 = data;
  308. },
  309. onClickType1(data) {
  310. if(data.type === 'search') {
  311. let data1 = data.data;
  312. if(data1.unitId) {
  313. let params;
  314. if(data1.value1) {
  315. params = {
  316. roomId: data1.unitId,
  317. startDate: data1.value1[0],
  318. endDate: data1.value1[1],
  319. type: 4,
  320. }
  321. } else {
  322. let end = timeDate(new Date().getTime())
  323. params = {
  324. roomId: data1.unitId,
  325. endDate: end,
  326. type: this.day1
  327. }
  328. }
  329. getListWater(params).then(res => {
  330. if(res.code === 10000) {
  331. this.waterList = res.data.data;
  332. this.waterCount = res.data.countWater;
  333. this.waterRoom = res.data.room;
  334. }
  335. })
  336. } else {
  337. console.log(222)
  338. this.$message.error('请选择栋舍楼层单元查询');
  339. }
  340. }
  341. }
  342. },
  343. mounted() {
  344. this.initAllWater()
  345. this.initWater()
  346. this.init()
  347. this.getSchool()
  348. }
  349. }
  350. </script>
  351. <style scoped>
  352. .drinkWater {
  353. width: 100%;
  354. height: 100%;
  355. padding: 20px 20px 0 20px;
  356. }
  357. .reply {
  358. width: 100%;
  359. border: 1px solid #ddd;
  360. border-bottom: 0;
  361. height: 50px;
  362. background-color: #F3F3F3;
  363. line-height: 50px;
  364. font-size: 18px;
  365. box-sizing: border-box;
  366. padding-left: 20px;
  367. }
  368. .echarts {
  369. width: 100%;
  370. height: 401px;
  371. box-sizing: border-box;
  372. border: 1px solid #ddd;
  373. border-top: 0;
  374. display: flex;
  375. }
  376. .echarts-l {
  377. width: 30%;
  378. height: 100%;
  379. }
  380. .echarts-r {
  381. width: 70%;
  382. height: 100%;
  383. }
  384. .carousel {
  385. width: 100%;
  386. height: 150px;
  387. border-top: 1px solid #ddd;
  388. }
  389. .swiper {
  390. width: 100%;
  391. height: 100%;
  392. }
  393. .box {
  394. width: 100%;
  395. height: 100%;
  396. border: 1px solid #ddd;
  397. box-sizing: border-box;
  398. padding: 30px 0;
  399. text-align: center;
  400. cursor: pointer;
  401. }
  402. .flex {
  403. width: 100%;
  404. height: 32px;
  405. display: flex;
  406. justify-content: center;
  407. align-items: center;
  408. }
  409. .icon1 {
  410. width: 32px;
  411. height: 32px;
  412. background: url('../../assets/images/u3077.svg') no-repeat;
  413. display: inline-block;
  414. background-size: 100% 100%;
  415. }
  416. </style>