HorFloorSpace.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396
  1. <template>
  2. <div class="floorSpace">
  3. <div class="leftChange">
  4. <!-- <div class="allIndicator">
  5. <div
  6. class="eachItem"
  7. v-for="item in allIndicator"
  8. @click="clickIndicator(item)"
  9. v-bind:class="{'select':item.id==selIndicator.id}"
  10. ><span>{{item.name}}</span><span class="bar"></span></div>
  11. </div>
  12. <div class="imageDiv">
  13. <img :src="selIndicator.img" />
  14. </div>
  15. <div class="textCont">
  16. 平均<span>{{selIndicator.name}}</span><span class="value">234</span><span>
  17. {{selIndicator.unit}}
  18. </span>
  19. </div> -->
  20. <div class="allIndicator">
  21. <div
  22. class="eachItem "
  23. v-for="item in allIndicator"
  24. @click="clickIndicator(item)"
  25. v-bind:class="{'select':item.id==selIndicator.id}"
  26. >
  27. <div class="title">{{item.name}}</div>
  28. <div
  29. class="textCont"
  30. v-show="item.id==selIndicator.id"
  31. >22{{selIndicator.unit}}<br /><span class="name">平均{{selIndicator.name}}</span></div>
  32. <img
  33. v-show="item.id==selIndicator.id"
  34. class="img"
  35. :src="selIndicator.img"
  36. ></img>
  37. </div>
  38. </div>
  39. </div>
  40. <div class="floorWrap">
  41. <div
  42. class="floor-item"
  43. v-for="(item,index) in floorData"
  44. :key="index"
  45. >
  46. <div class="floor-num"><span>{{item.floorName}}</span></div>
  47. <div class="floor-space">
  48. <div
  49. class="space-box"
  50. v-for="(childItem,id) in item.data"
  51. :key="id"
  52. >
  53. <div class="space-name">{{childItem.name}}</div>
  54. </div>
  55. </div>
  56. </div>
  57. </div>
  58. </div>
  59. </template>
  60. <script>
  61. export default {
  62. name: 'FloorSpace',
  63. data() {
  64. return {
  65. selIndicator: {},
  66. allIndicator: [{
  67. id: 'temp',
  68. name: '温度',
  69. img: require('../../assets/horImg/wendu.png'),
  70. unit: '℃'
  71. }, {
  72. id: 'humidity',
  73. name: '湿度',
  74. img: require('../../assets/horImg/shidu.png'),
  75. unit: '%'
  76. }, {
  77. id: 'co2',
  78. name: 'CO₂',
  79. img: require('../../assets/horImg/co2.png'),
  80. unit: 'ppm'
  81. }, {
  82. id: 'methanal',
  83. name: '甲醛',
  84. img: require('../../assets/horImg/jiaquan.png'),
  85. unit: 'mg/m³'
  86. }, {
  87. id: 'pm25',
  88. name: 'PM2.5',
  89. img: require('../../assets/horImg/pm25.png'),
  90. unit: 'ug/m³'
  91. }],
  92. floorData: [
  93. {
  94. floorName: '8F',
  95. data: [
  96. { id: 1, name: '空间1' },
  97. { id: 2, name: '空间2' },
  98. { id: 3, name: '空间3' },
  99. { id: 1, name: '空间4' },
  100. { id: 2, name: '空间5' },
  101. { id: 3, name: '空间6' },
  102. { id: 1, name: '空间1' },
  103. { id: 2, name: '空间2' },
  104. { id: 3, name: '空间3' },
  105. { id: 1, name: '空间4' },
  106. { id: 2, name: '空间5' },
  107. { id: 3, name: '空间6' },
  108. ]
  109. },
  110. {
  111. floorName: '7F',
  112. data: [
  113. { id: 1, name: '空间1' },
  114. { id: 2, name: '空间2' },
  115. { id: 3, name: '空间3' },
  116. ]
  117. },
  118. ],
  119. firstPageParams: [],
  120. secondPageParams: [],
  121. nowPage: 1, //当前哪一屏幕
  122. }
  123. },
  124. mounted() {
  125. this.selIndicator = this.allIndicator[0];
  126. },
  127. methods: {
  128. clickIndicator(item) {
  129. this.selIndicator = item;
  130. },
  131. queryFs() {
  132. //let loadingInstance = Loading.service({ fullscreen: true });
  133. var loading = this.$loading({ fullscreen: true });
  134. this.$axios
  135. .post(this.$api.queryFs, {
  136. criteria: {
  137. projectId: "Pj1101020002",
  138. },
  139. size: 14,
  140. page: 1,
  141. orders: [
  142. {
  143. column: "floorSequenceId",
  144. asc: true,
  145. },
  146. ],
  147. })
  148. .then((res) => {
  149. // loadingInstance.close();
  150. loading.close();
  151. console.log("queryFs", res);
  152. var allFloor = res.data.content || [];
  153. var allFloorNum = allFloor.length;
  154. //如果超过7层 就显示两屏幕 第一屏 firstPageNum
  155. //如果超过7层 就显示两屏幕 第二屏 secondPageNum
  156. var firstPageNum, secondPageNum;
  157. if (allFloorNum <= 7) {
  158. firstPageNum = allFloorNum;
  159. secondPageNum = 0;
  160. } else {
  161. firstPageNum = Math.ceil(allFloorNum / 2);
  162. secondPageNum = Math.floor(allFloorNum / 2);
  163. }
  164. //this.nowPage = 1; //取第一屏
  165. var firstMaxSpace = this.floorHandle(firstPageNum); //第一屏 一层最多空间
  166. var sendMaxSpace = this.floorHandle(secondPageNum);
  167. var firstPageFloors = allFloor.slice(0, firstPageNum); //第一屏 所有楼层
  168. var secondPageFloors = allFloor.slice(firstPageNum);
  169. this.firstPageParams = firstPageFloors.map((item) => {
  170. var obj = {};
  171. obj.id = item.id;
  172. obj.projectId = "Pj1101020002";
  173. obj.spaceNum = firstMaxSpace;
  174. return obj;
  175. });
  176. this.secondPageParams = secondPageFloors.map((item) => {
  177. var obj = {};
  178. obj.id = item.id;
  179. obj.projectId = "Pj1101020002";
  180. obj.spaceNum = sendMaxSpace;
  181. return obj;
  182. });
  183. this.queryParam(this.firstPageParams);
  184. });
  185. },
  186. queryParam(param) {
  187. var loading = this.$loading({ fullscreen: true });
  188. this.$axios.post(this.$api.queryParam, param).then((res) => {
  189. loading.close();
  190. debugger;
  191. });
  192. },
  193. spaceHandle(floorNum, spaceNum){//返回一层 的每一行 几个房间
  194. if (floorNum == 1) {//最多一层时
  195. if (spaceNum > 2 && spaceNum <= 24 ) {
  196. lineNum = spaceNum / 2;
  197. }else if (spaceNum > 24 && spaceNum <= 36) {
  198. lineNum = Math.ceil(spaceNum / 3);
  199. } else if (spaceNum > 36 && spaceNum <= 48) {
  200. lineNum = Math.ceil(spaceNum / 4);
  201. } else if (spaceNum > 48 && spaceNum <= 60) {//48-60个 5行
  202. lineNum = Math.ceil(spaceNum / 5);
  203. }
  204. }else{
  205. var floorline = Math.ceil(spaceNum / 16); //20-30 3排 30-40个 4排 一层排数
  206. lineNum = Math.ceil(spaceNum / floorline);
  207. }
  208. },
  209. floorHandle(floorNum, spaceNum) {
  210. var lineNum = spaceNum;//一行的房间数
  211. var maxFloorSpace = 0;//一层 最多显示房间数
  212. switch (floorNum) {
  213. case 1:
  214. maxFloorSpace = 60;
  215. break;
  216. case 2:
  217. maxFloorSpace = 48;
  218. break;
  219. case 3:
  220. case 4:
  221. maxFloorSpace = 32;
  222. break;
  223. case 5:
  224. case 6:
  225. case 7:
  226. maxFloorSpace = 16;
  227. break;
  228. }
  229. // if(floorNum == 2) {
  230. // if (spaceNum > 16 && spaceNum < = 32 ) {
  231. // lineNum = Math.ceil(spaceNum / 2);
  232. // }else if (spaceNum > 32 && spaceNum < = 48 ) {
  233. // lineNum = Math.ceil(spaceNum / 3);
  234. // }
  235. // maxFloorSpace=48;
  236. // }
  237. // if(floorNum ==3||floorNum ==4) {
  238. // if (spaceNum > 16 && spaceNum < = 32 ) {
  239. // lineNum = Math.ceil(spaceNum / 2);
  240. // }
  241. // maxFloorSpace=32;
  242. // }
  243. }
  244. }
  245. }
  246. </script>
  247. <style lang="less" scoped>
  248. .floorSpace {
  249. width: 100%;
  250. height: 910px;
  251. display: flex;
  252. }
  253. .leftChange {
  254. height: 100%;
  255. width: 154px;
  256. margin: 0 auto;
  257. background: #ffffff;
  258. .allIndicator {
  259. padding-top: 32px;
  260. padding-bottom: 20px;
  261. // display: flex;
  262. // align-items: center;
  263. // justify-content: center;
  264. .eachItem {
  265. cursor: pointer;
  266. margin-bottom: 60px;
  267. padding: 0;
  268. text-align: center;
  269. .title {
  270. color: #9b98ad;
  271. font-size: 24px;
  272. }
  273. &.select {
  274. border-left: 4px solid #46ccf6;
  275. .title {
  276. color: #3b3558;
  277. font-size: 24px;
  278. }
  279. .textCont {
  280. color: #3b3558;
  281. font-size: 20px;
  282. padding-top: 16px;
  283. padding-bottom: 20px;
  284. line-height: 20px;
  285. .name {
  286. font-size: 14px;
  287. }
  288. }
  289. .img {
  290. height: 196px;
  291. padding: 0;
  292. margin: 0;
  293. }
  294. }
  295. }
  296. }
  297. // .allIndicator {
  298. // padding-top: 32px;
  299. // padding-bottom: 20px;
  300. // display: flex;
  301. // align-items: center;
  302. // justify-content: center;
  303. // .eachItem {
  304. // font-size: 24px;
  305. // color: #9b98ad;
  306. // margin-right: 60px;
  307. // display: flex;
  308. // flex-direction: column;
  309. // align-items: center;
  310. // .bar {
  311. // width: 24px;
  312. // height: 6px;
  313. // display: inline-block;
  314. // }
  315. // &.select {
  316. // color: #3b3558;
  317. // .bar {
  318. // background: #46ccf6;
  319. // }
  320. // }
  321. // }
  322. // }
  323. // .imageDiv {
  324. // height: 32px;
  325. // margin: 0 32px;
  326. // }
  327. // .textCont {
  328. // color: #3b3558;
  329. // font-size: 20px;
  330. // font-weight: 600;
  331. // text-align: center;
  332. // padding-top: 16px;
  333. // .value {
  334. // margin-left: 4px;
  335. // }
  336. // }
  337. }
  338. .floorWrap {
  339. // width: 1000px;
  340. flex: 1;
  341. margin: 0 auto;
  342. background: #ffffff;
  343. .floor-item {
  344. display: flex;
  345. padding: 18px 0;
  346. box-sizing: border-box;
  347. background: linear-gradient(
  348. 161.44deg,
  349. rgba(50, 129, 246, 0.1) 6.16%,
  350. rgba(50, 129, 246, 0) 81.03%
  351. );
  352. }
  353. .floor-num {
  354. display: flex;
  355. justify-content: center;
  356. align-items: center;
  357. font-family: Persagy;
  358. font-size: 36px;
  359. font-weight: 700;
  360. line-height: 43px;
  361. color: #3b3558;
  362. width: 80px;
  363. flex-shrink: 0;
  364. }
  365. .floor-space {
  366. display: flex;
  367. flex: 1;
  368. flex-wrap: wrap;
  369. .space-box {
  370. padding: 4px;
  371. .space-name {
  372. display: flex;
  373. justify-content: center;
  374. align-items: center;
  375. height: 86px;
  376. width: 90px;
  377. border-radius: 8px;
  378. background: #d9f5d6;
  379. }
  380. }
  381. }
  382. }
  383. </style>