Blame view

src/views/lpb/lpbContent/index.vue 7.15 KB
任超 committed
1
<template>
2
  <div class="lpbContent-wrap" ref="lpbContentWrap">
yangwei committed
3
    <div class="lpbContent" ref="lpbContent" :style="{ 'height': 'calc(100% - '+ lpbContentHeight +'px)'}">
4 5 6
      <!-- 纵向倒序排列 逻辑幢位于独立幢单元和独立层户的上方 -->
      <div class="ch-zdy-wrap">
        <!-- 幢单元 -->
yangwei committed
7
        <zdy-cpn v-if="lpbData.zdys.length" :zdys="lpbData.zdys" :onlyShow="onlyShow"/>
8 9 10 11
        <!-- 独立层户 -->
        <ch-cpn v-if="lpbData.cs.length" :ch="lpbData.cs" />
      </div>
      <!-- 逻辑幢 -->
yangwei committed
12
      <ljzs-cpn v-if="lpbData.ljzs.length" :ljzs="lpbData.ljzs" :onlyShow="onlyShow"/>
13 14
    </div>
    <!-- 自然幢名称 -->
yangwei committed
15 16
    <p class="lpb-xmmc" :style="{ 'border-bottom':  onlyShow ? 0 : '1px solid #e6e6e6'}">
      <el-checkbox @change="zdySelectAll($event)" v-if="!onlyShow">{{
17
        lpbData.xmmc
yangwei committed
18 19
      }}</el-checkbox>
      <span v-else>{{lpbData.xmmc}}</span> 
20
    </p>
yangwei committed
21
    <el-button type="primary" class="save-btn" v-if="!onlyShow" @click="saveLpb">保存</el-button>
22 23 24
    <!-- 右键菜单 -->
    <ul
      v-show="lpbChVisible"
yangwei committed
25
      :style="{ left: lpbChLeft + 'px', top: lpbChTop + 'px' }" 
26 27 28 29 30 31
      class="contextmenu"
    >
      <li @click="menuClick">菜单一</li>
      <li @click="menuClick">菜单二</li>
    </ul>
  </div>
任超 committed
32 33
</template>
<script>
34
import { getLpb } from "@/api/lpcx.js";
35 36 37
import chCpn from "./ch.vue";
import zdyCpn from "./zdys.vue";
import ljzsCpn from "./ljzs.vue";
任超 committed
38
export default {
39 40 41 42
  provide() {
    return {
      openMenu: this.openMenu,
      selectAll: this.selectAllObj,
yangwei committed
43
      changeChoosedObj:this.changeChoosedObj,
yangwei committed
44 45
      clearChangeChoosedObj:this.clearChangeChoosedObj,
      getBsmList:this.getBsmList
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62
    };
  },
  name: "",
  components: { chCpn, zdyCpn, ljzsCpn },
  props: {
    zrzbsm: {
      type: String,
      default: "",
    },
    lpbParent: {
      type: String,
      default: "isLpb",
    },
    isHb: {
      type: Boolean,
      default: true,
    },
yangwei committed
63 64 65 66
    onlyShow:{
      type: Boolean,
      default: true,
    }
67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83
  },
  data() {
    return {
      lpbData: {
        ljzs: [],
        cs: [],
        zdys: [],
      },
      //户全选标识 由于依赖注入的绑定并不是可响应的,所以传入可监听的对象以获取其属性的响应
      selectAllObj: {
        selectAll: false,
      },
      //层户右键菜单显隐
      lpbChVisible: false,
      //右键菜单定位位置
      lpbChLeft: 100,
      lpbChTop: 100,
yangwei committed
84 85 86 87
      // 改变户选中状态
      changeChoosedObj:{
        bsms:[],
        color:''
yangwei committed
88 89 90
      },
      // 选中户bsm合集
      bsmList:[]
91 92 93
    };
  },
  mounted() {
yangwei committed
94 95
    this.getLpb(this.zrzbsm);
		window.lpbContent = this;
96 97
  },
  methods: {
yangwei committed
98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115
    /**
     * @description: 获取当前楼盘表选中户信息
     * @param {Array} bsmList
     * @author: renchao
     */
    getBsmList(bsmList){
      this.bsmList = bsmList;
    },
    /**
     * @description: 保存当前楼盘表
     * @author: renchao
     */ 
    saveLpb(){
      // todo 调用保存接口 传入参数待定
      console.log(this.bsmList,'this.bsmList');
      // 保存成功后关闭弹框
      this.$popupCacel()
    },
yangwei committed
116
    // 改变户选中状态
yuanbo committed
117 118 119 120 121 122
    /**
     * @description: 改变户选中状态
     * @param {*} bsms
     * @param {*} color
     * @author: renchao
     */
yangwei committed
123 124 125 126
    changeChoosed(bsms, color){
      this.changeChoosedObj.bsms = bsms;
      this.changeChoosedObj.color = color;
    },
yuanbo committed
127 128 129 130
    /**
     * @description: clearChangeChoosedObj
     * @author: renchao
     */
yangwei committed
131 132 133
    clearChangeChoosedObj(){
      this.changeChoosedObj.bsms = [];
    },
134
    //全选户
yuanbo committed
135 136 137 138 139
    /**
     * @description: 全选户
     * @param {*} val
     * @author: renchao
     */
140 141 142 143
    zdySelectAll(val) {
      this.selectAllObj.selectAll = val;
    },
    //获取楼盘表数据
yuanbo committed
144 145 146 147 148 149 150
    /**
     * @description: 获取楼盘表数据
     * @param {*} zrzbsm
     * @param {*} scyclx
     * @param {*} actual
     * @author: renchao
     */
151 152 153
    getLpb(zrzbsm, scyclx, actual) {
      getLpb(zrzbsm, scyclx).then((res) => {
        if (res.code == 200) {
yangwei committed
154 155
          res.result.lpb.ljzs = res.result.lpb.ljzs.sort(this.compare("place"));
          this.lpbData = res.result.lpb == null ? this.lpbData : res.result.lpb;
156 157 158 159 160 161 162 163 164 165 166 167 168 169
          //   this.$nextTick(() => {
          //     //渲染楼盘表
          //     this.dataChange();
          //   });
          console.log(this.lpbData, "this.lpbData");
        } else {
          this.$message({
            message: res.message,
            type: "warning",
          });
        }
      });
    },
    //户右键点击事件
yuanbo committed
170 171 172 173 174 175 176
    /**
     * @description: 户右键点击事件
     * @param {*} e
     * @param {*} item
     * @param {*} type
     * @author: renchao
     */
177 178 179
    openMenu(e, item, type) {
      this.lpbChLeft = e.pageX - 96;
      this.lpbChTop = e.pageY - 23;
yangwei committed
180
      // this.lpbChVisible = true;
181 182
    },
    //关闭户右键菜单
yuanbo committed
183 184 185 186
    /**
     * @description: 关闭户右键菜单
     * @author: renchao
     */
187 188 189 190
    closeMenu() {
      this.lpbChVisible = false;
    },
    //右键菜单点击
yuanbo committed
191 192 193 194
    /**
     * @description: 右键菜单点击
     * @author: renchao
     */
195 196 197
    menuClick() {
      this.closeMenu();
    },
yuanbo committed
198 199 200 201 202
    /**
     * @description: compare
     * @param {*} property
     * @author: renchao
     */
203 204 205 206 207 208 209 210
    compare(property) {
      return function (a, b) {
        var value1 = a[property];
        var value2 = b[property];
        return value1 - value2;
      };
    },
  },
yangwei committed
211 212 213 214 215
  computed:{
    lpbContentHeight(){
      return this.onlyShow ? 36 : 76
    }
  },
216 217 218 219 220 221 222 223
  watch: {
    //户右键菜单显示时,监听到鼠标点击时关闭户右键菜单
    lpbChVisible(value) {
      if (value) {
        document.body.addEventListener("click", this.closeMenu);
      } else {
        document.body.removeEventListener("click", this.closeMenu);
      }
yangwei committed
224
    }
225
  },
任超 committed
226 227 228 229
};
</script>
<style scoped lang="scss">
.lpbContent-wrap {
230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253
  width: 100%;
  height: 100%;
  overflow: hidden;
  .lpbContent {
    width: 100%;
    position: relative;
    overflow: scroll;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
    display: flex;
    flex-direction: column-reverse;
    box-sizing: border-box;
    padding-top: 20px;
    .ch-zdy-wrap {
      display: flex;
      flex-direction: row;
    }
  }
  .lpb-xmmc {
    border: 0;
    border-top: 1px solid #e6e6e6;
  }
yangwei committed
254 255 256 257
  .save-btn{
    display: block;
    margin: 5px auto;
  }
258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300
  // 自定义右键菜单样式
  .contextmenu {
    margin: 0;
    background: #fff;
    width: 92px;
    z-index: 3000;
    position: fixed;
    list-style-type: none;
    padding: 5px 0;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 400;
    color: #333;
    box-shadow: 2px 2px 3px 0 rgba(0, 0, 0, 0.3);
    li {
      margin: 0;
      padding: 7px 16px;
      cursor: pointer;
      position: relative;
      .childUl {
        display: none;
        position: absolute;
        left: 92px !important;
        top: 0 !important;
        li {
          width: 76px;
        }
      }
    }
    li:hover {
      background: #eee;
      > .childUl {
        display: block;
      }
    }
    .noEdit {
      color: #e6e6e6;
      cursor: not-allowed;
    }
    .noEdit:hover {
      background: #ffffff;
    }
  }
任超 committed
301 302
}
</style>