Blame view

src/views/lpb/lpbContent/index.vue 9.57 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">
        <!-- 幢单元 -->
7
        <zdy-cpn v-if="lpbData.zdys.length"  :zdys="lpbData.zdys" :onlyShow="onlyShow"/>
8
        <!-- 独立层户 -->
9
        <ch-cpn v-if="lpbData.cs.length" :ch="lpbData.cs" :onlyShow="onlyShow"/>
10 11
      </div>
      <!-- 逻辑幢 -->
yangwei committed
12
      <ljzs-cpn v-if="lpbData.ljzs.length" :ljzs="lpbData.ljzs" :onlyShow="onlyShow"/>
13 14
    </div>
    <!-- 自然幢名称 -->
15 16
    <p class="lpb-xmmc" v-if="onlyShow" style="border-bottom: 1px solid #e6e6e6">{{ lpbData.xmmc }}</p>
    <p class="lpb-xmmc" v-else :style="{ 'border-bottom':'1px solid #e6e6e6'}">
17
      <el-checkbox @change="zdySelectAll($event)">{{
18
        lpbData.xmmc
yangwei committed
19
      }}</el-checkbox>
20
    </p>
21
    <el-button type="primary" class="save-btn" v-if="!onlyShow && showSave" @click="saveLpb">保存</el-button>
22
    <el-button type="primary" class="save-btn" v-if="!onlyShow && !showSave" @click="submitForm" :loading="loading">发起申请</el-button>
23 24 25
    <!-- 右键菜单 -->
    <ul
      v-show="lpbChVisible"
yangwei committed
26
      :style="{ left: lpbChLeft + 'px', top: lpbChTop + 'px' }" 
27 28 29 30 31 32
      class="contextmenu"
    >
      <li @click="menuClick">菜单一</li>
      <li @click="menuClick">菜单二</li>
    </ul>
  </div>
任超 committed
33 34
</template>
<script>
35
import { getLpb } from "@/api/lpcx.js";
36 37 38
import chCpn from "./ch.vue";
import zdyCpn from "./zdys.vue";
import ljzsCpn from "./ljzs.vue";
39
import { startBusinessFlow, choiceBdcdy } from "@/api/workFlow.js";
yangwei committed
40 41 42
import jump from "../../ywbl/ywsq/components/mixin/jump";
import store from '@/store/index.js'
import { ywPopupCacel } from "@/utils/popup.js";
任超 committed
43
export default {
yangwei committed
44
  mixins: [jump],
45 46 47 48
  provide() {
    return {
      openMenu: this.openMenu,
      selectAll: this.selectAllObj,
yangwei committed
49
      changeChoosedObj:this.changeChoosedObj,
yangwei committed
50 51
      clearChangeChoosedObj:this.clearChangeChoosedObj,
      getBsmList:this.getBsmList
52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68
    };
  },
  name: "",
  components: { chCpn, zdyCpn, ljzsCpn },
  props: {
    zrzbsm: {
      type: String,
      default: "",
    },
    lpbParent: {
      type: String,
      default: "isLpb",
    },
    isHb: {
      type: Boolean,
      default: true,
    },
yangwei committed
69 70 71
    onlyShow:{
      type: Boolean,
      default: true,
72
    },
73 74 75 76
    showSave:{
      type: Boolean,
      default: false,
    },
77 78 79 80 81 82 83 84
    scyclx: {
      type: Number,
      default: 0,
    },
    sqywInfo: { 
      type: Object,
       default: () => { } 
    },
yangwei committed
85
    isJump: { type: Boolean, default: false },
86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102
  },
  data() {
    return {
      lpbData: {
        ljzs: [],
        cs: [],
        zdys: [],
      },
      //户全选标识 由于依赖注入的绑定并不是可响应的,所以传入可监听的对象以获取其属性的响应
      selectAllObj: {
        selectAll: false,
      },
      //层户右键菜单显隐
      lpbChVisible: false,
      //右键菜单定位位置
      lpbChLeft: 100,
      lpbChTop: 100,
yangwei committed
103 104 105 106
      // 改变户选中状态
      changeChoosedObj:{
        bsms:[],
        color:''
yangwei committed
107 108
      },
      // 选中户bsm合集
109 110
      bsmList:[],
      loading: false,
111 112 113
    };
  },
  mounted() {
114
    this.scyclx ? this.getLpb(this.zrzbsm,this.scyclx):this.getLpb(this.zrzbsm);
yangwei committed
115
		window.lpbContent = this;
116 117
  },
  methods: {
yangwei committed
118 119 120 121 122
    /**
     * @description: 获取当前楼盘表选中户信息
     * @param {Array} bsmList
     * @author: renchao
     */
yangwei committed
123 124 125 126 127 128
    getBsmList(bsmList,compFlag){
      // 根据本次传入的组件标识删除之前对应组件标识存入hbsmList的数据
      this.bsmList = this.bsmList.filter((i) => i.flag != compFlag)
      // 合并本次数据
      this.bsmList = this.bsmList.concat([...new Map(bsmList.map(item => [item.bdcdyh, item])).values()]);
      // })
yangwei committed
129 130 131 132 133 134 135 136 137 138 139
    },
    /**
     * @description: 保存当前楼盘表
     * @author: renchao
     */ 
    saveLpb(){
      // todo 调用保存接口 传入参数待定
      console.log(this.bsmList,'this.bsmList');
      // 保存成功后关闭弹框
      this.$popupCacel()
    },
yangwei committed
140
    // 改变户选中状态
yuanbo committed
141 142 143 144 145 146
    /**
     * @description: 改变户选中状态
     * @param {*} bsms
     * @param {*} color
     * @author: renchao
     */
yangwei committed
147 148 149 150
    changeChoosed(bsms, color){
      this.changeChoosedObj.bsms = bsms;
      this.changeChoosedObj.color = color;
    },
yuanbo committed
151 152 153 154
    /**
     * @description: clearChangeChoosedObj
     * @author: renchao
     */
yangwei committed
155 156 157
    clearChangeChoosedObj(){
      this.changeChoosedObj.bsms = [];
    },
158
    //全选户
yuanbo committed
159 160 161 162 163
    /**
     * @description: 全选户
     * @param {*} val
     * @author: renchao
     */
164 165 166 167
    zdySelectAll(val) {
      this.selectAllObj.selectAll = val;
    },
    //获取楼盘表数据
yuanbo committed
168 169 170 171 172 173 174
    /**
     * @description: 获取楼盘表数据
     * @param {*} zrzbsm
     * @param {*} scyclx
     * @param {*} actual
     * @author: renchao
     */
175 176 177
    getLpb(zrzbsm, scyclx, actual) {
      getLpb(zrzbsm, scyclx).then((res) => {
        if (res.code == 200) {
178 179 180 181 182 183 184 185 186
          if(scyclx){
            if(res.result.syclx == "1") {
              res.result.lpb.ljzs = res.result.lpb.ljzs.sort(this.compare("place"));
              this.lpbData = res.result.lpb == null ? this.lpbData : res.result.lpb;
            }
          }else{
              res.result.lpb.ljzs = res.result.lpb.ljzs.sort(this.compare("place"));
              this.lpbData = res.result.lpb == null ? this.lpbData : res.result.lpb;
          }
187 188 189 190 191 192 193 194 195
        } else {
          this.$message({
            message: res.message,
            type: "warning",
          });
        }
      });
    },
    //户右键点击事件
yuanbo committed
196 197 198 199 200 201 202
    /**
     * @description: 户右键点击事件
     * @param {*} e
     * @param {*} item
     * @param {*} type
     * @author: renchao
     */
203 204 205
    openMenu(e, item, type) {
      this.lpbChLeft = e.pageX - 96;
      this.lpbChTop = e.pageY - 23;
yangwei committed
206
      // this.lpbChVisible = true;
207 208
    },
    //关闭户右键菜单
yuanbo committed
209 210 211 212
    /**
     * @description: 关闭户右键菜单
     * @author: renchao
     */
213 214 215 216
    closeMenu() {
      this.lpbChVisible = false;
    },
    //右键菜单点击
yuanbo committed
217 218 219 220
    /**
     * @description: 右键菜单点击
     * @author: renchao
     */
221 222 223
    menuClick() {
      this.closeMenu();
    },
yuanbo committed
224 225 226 227 228
    /**
     * @description: compare
     * @param {*} property
     * @author: renchao
     */
229 230 231 232 233 234 235
    compare(property) {
      return function (a, b) {
        var value1 = a[property];
        var value2 = b[property];
        return value1 - value2;
      };
    },
236 237 238 239 240 241 242 243 244
    /**
     * @description: submitForm
     * @author: renchao
     */
    submitForm () {
      if (this.bsmList.length == 0) {
          this.$message.error("请至少选择一条数据");
          return;
        }
yangwei committed
245
      this.loading = true;
246 247 248 249 250 251 252 253 254 255 256 257 258
      startBusinessFlow({
        bsmSqyw: this.sqywInfo.bsmSqyw,
        bdcdysz: this.bsmList,
      }).then((res) => {
        this.loading = false
        if (res.code == 200) {
          this.$message({
            showClose: true,
            message: '发起申请成功',
            type: 'success'
          })
          if (!this.isJump) {
            this.jump(res.result, this.sqywInfo.djywbm)
259
          } else {
260
            store.dispatch('user/refreshPage', true);
261
          }
yangwei committed
262
          this.close()
263 264 265 266 267 268 269 270 271 272
        } else {
          if (res.result && res.result.length > 0) {
            this.$popup("申请错误明细", "components/ywdialog", { width:'36%', formData:{result: res.result} })
          } else {
            this.$popup("申请错误明细", "components/ywdialog", { width:'36%', formData:{message: res.message} })
          }
        }
      }).catch(() => {
        this.loading = false
      })
273
    },
yangwei committed
274 275 276 277 278 279 280 281
    /**
     * @description: close
     * @param {*} val
     * @author: renchao
     */
    close(){
      ywPopupCacel()
    },
282
  },
yangwei committed
283 284
  computed:{
    lpbContentHeight(){
285 286
      return this.onlyShow ? 32 : 76
      // return 76
yangwei committed
287 288
    }
  },
289 290 291 292 293 294 295 296
  watch: {
    //户右键菜单显示时,监听到鼠标点击时关闭户右键菜单
    lpbChVisible(value) {
      if (value) {
        document.body.addEventListener("click", this.closeMenu);
      } else {
        document.body.removeEventListener("click", this.closeMenu);
      }
yangwei committed
297
    }
298
  },
任超 committed
299 300 301 302
};
</script>
<style scoped lang="scss">
.lpbContent-wrap {
303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326
  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
327 328 329 330
  .save-btn{
    display: block;
    margin: 5px auto;
  }
331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373
  // 自定义右键菜单样式
  .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
374 375
}
</style>