getsabuildingstruct.vue 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248
  1. <template>
  2. <div>
  3. <van-nav-bar
  4. @click-left="onClickLeft"
  5. @click-right="onClickRight"
  6. style="background-color: #1989fa"
  7. >
  8. <template #title>
  9. <van-col style="color: #ffffff">楼栋详情</van-col>
  10. </template>
  11. <template #left>
  12. <i
  13. class="fa fa-arrow-circle-left"
  14. aria-hidden="true"
  15. style="color: #ffffff; font-size: 18px"
  16. ></i>
  17. </template>
  18. <template #right>
  19. <van-icon name="replay" size="18" color="#ffffff" />
  20. </template>
  21. </van-nav-bar>
  22. <van-row>
  23. <van-col span="24" class="title1">
  24. <van-image
  25. :src="require('@/assets/img/query.jpg')"
  26. width="30"
  27. height="30"
  28. />
  29. <span >{{keyValue}}</span>
  30. </van-col>
  31. </van-row>
  32. <div ref="wrapper" :style="'width:'+width+'px;'">
  33. <table border="1" cellspacing="0" :style="'width:'+getWidth+'px;'">
  34. <tr>
  35. <td rowspan="2" class="width">楼层</td>
  36. <td class="width">单元</td>
  37. <td>
  38. <template v-if="data!=null&&data.Chambers!=null&&data.Chambers.length>1">
  39. <van-col class="border3" :span="span" v-for="item in data.Chambers" :key="item.cName" >{{item.cName}}</van-col>
  40. </template>
  41. </td>
  42. </tr>
  43. <tr>
  44. <td>室号</td>
  45. <td >
  46. <template v-if="data!=null&&data.Chambers!=null">
  47. <van-col class="border3" :span="span" v-for="item in data.Chambers" :key="item.cName" >
  48. <div :style="'width:'+CountSpan(data.Chambers.length,item.SubChambers.length)+'px;display:inline-block;'" class="border3" v-for="item1 in item.SubChambers" :key="item1.subcName">{{item1.subcName}}</div>
  49. </van-col>
  50. </template>
  51. </td>
  52. </tr>
  53. <template v-if="data!=null&&data.Rooms!=null">
  54. <tr v-for="item1 in data.Floors" :key="item1.fName">
  55. <td colspan="2">{{item1.fName}}</td>
  56. <td >
  57. <template v-if="data!=null&&data.Rooms!=null">
  58. <van-col class="border3" :span="span2" v-for="item in filterArray(data.Rooms,item1.fName)" :key="item.rID" :style="'background:'+item.rColor+';'">
  59. <router-link :to="{path:'/getsaroominfo',query:{id:item.rID}}" class="blackColor">{{item.rName}}</router-link>
  60. </van-col>
  61. </template>
  62. </td>
  63. </tr>
  64. </template>
  65. </table>
  66. </div>
  67. </div>
  68. </template>
  69. <script>
  70. import { GetSaBuildingStruct } from "@/common/api/loginApi.js";
  71. import BetterScroll from 'better-scroll'
  72. import Swiper from 'swiper';
  73. import 'swiper/swiper.min.css';
  74. export default {
  75. name: "login",
  76. data() {
  77. return {
  78. data: {},
  79. keyId:0,
  80. keyValue:'',
  81. width:'',
  82. width1:"",
  83. span:"24",
  84. span2:"",
  85. span3:""
  86. };
  87. },
  88. created: function () {
  89. console.info("created");
  90. //console.info(this.$util);
  91. this.$util.persistLogin(this);
  92. //console.info('created id start',this.$route.query.id);
  93. this.keyId=this.$route.query.id;
  94. //console.info('created id end');
  95. this.keyValue=this.$route.query.name;
  96. this.GetSaBuildingStruct();
  97. console.info('getViewportSize',this.$util.getViewportSize());
  98. this.width=this.$util.getViewportSize().width;
  99. console.info('width',this.width);
  100. },
  101. computed: {
  102. // 计算属性的 getter
  103. getWidth:function(){
  104. if(this.data!=null&&this.data.Chambers!=null){
  105. if(this.data.Chambers[0].SubChambers.length>0){
  106. let width=this.data.Chambers[0].SubChambers.length*40+70;
  107. if(this.width>width){
  108. return this.width;
  109. }
  110. else{
  111. return width;
  112. }
  113. }
  114. }
  115. return this.width;
  116. }
  117. },
  118. mounted() {
  119. this.$nextTick(() => {
  120. this.scroll = new BetterScroll(this.$refs.wrapper, {scrollX: true,scrollY:false,click:true})
  121. })
  122. },
  123. methods: {
  124. GetSaBuildingStruct: function () {
  125. var that = this;
  126. var data = {
  127. userCode: that.$store.state.data.userCode,
  128. projectId: that.$store.state.projectId,
  129. buildingId:that.keyId
  130. };
  131. console.info("data", data);
  132. GetSaBuildingStruct(data).then((res) => {
  133. console.info("GetSaBuildingStruct", res);
  134. if (!res.result) {
  135. that.$toast(res.msg);
  136. return;
  137. }
  138. //console.info('data.Chambers',res.data.Chambers[0].SubChambers)
  139. that.data=res.data;
  140. if(that.data.Chambers.length>=1){
  141. this.span=24/that.data.Chambers.length;
  142. }
  143. });
  144. },
  145. CountSpan:function(chlen,col){ //计算行宽
  146. let count=chlen*col;
  147. let width2=this.width/count;
  148. console.info('width2',width2);
  149. return width2;
  150. },
  151. // 单选按钮点击事件
  152. click1: function (event, id) {
  153. //console.info("click1 event", event);
  154. //console.info("click1 value", id);
  155. //console.info("click1", e.target.innerText);
  156. },
  157. onClickLeft() {
  158. // this.$toast('返回')
  159. console.info("left");
  160. this.$router.go(-1);
  161. },
  162. onClickRight() {
  163. this.$router.go(0);
  164. },
  165. filterArray: function (arr,name) {
  166. //console.info('filterArray',arr);
  167. //console.info('filterArray name',name);
  168. var r=arr.filter(function(item,index,self){
  169. return item.rCoordinateY==name;
  170. });
  171. this.span2=24/r.length;
  172. //console.info('filterArray r',r);
  173. return r;
  174. }
  175. },
  176. };
  177. </script>
  178. <!-- Add "scoped" attribute to limit CSS to this component only -->
  179. <style lang="less" scoped>
  180. @import 'vue-easytable/libs/themes-base/index.css';
  181. @import "../assets/css/swiper_table.less";
  182. .title1 {
  183. color: #1989fa;
  184. text-align: left;
  185. font-size:18px;
  186. font-weight:900;
  187. margin-left:15px;
  188. margin-top:15px;
  189. height:50px;
  190. border-bottom:#999 solid 1px;
  191. }
  192. .height25{
  193. height: 25px;
  194. border:#999 solid 1px;
  195. padding: 5px;
  196. }
  197. .height25_1{
  198. height: 25px;
  199. border:#999 solid 1px;
  200. margin-top: -5px;
  201. padding-top:2px;
  202. width:35px;
  203. }
  204. .height25_2{
  205. height: 25px;
  206. border:#999 solid 1px;
  207. margin-top: -5px;
  208. padding-top:2px;
  209. background: #1989fa;
  210. }
  211. .border1{
  212. border:#999 solid 1px;
  213. height:50px;
  214. padding-top:15px;
  215. }
  216. .border2{
  217. border:#999 solid 1px;
  218. padding:0;
  219. }
  220. .border3{
  221. border:#999 solid 1px;
  222. }
  223. .blackColor{
  224. color: #000;
  225. }
  226. .box{
  227. color:#000;
  228. width:600px;
  229. }
  230. .width{
  231. width:50px;
  232. }
  233. </style>