ordinaryMenu.vue 8.61 KB
<!--
 * @Description: workFrame左侧菜单列表-普通
 * @Autor: renchao
 * @LastEditTime: 2024-02-01 09:41:06
-->
<template>
  <div class="leftmenu" :class="{ 'animation-map-drawer': isShowdrawer }">
    <el-menu :default-active="activeIndex" @select="batchUnitClick" class="title-batch" v-if="showBatch">
      <el-menu-item index="-1" key="-1" class="menus">
        <div>{{ batchButtonName }}</div>
      </el-menu-item>
    </el-menu>
    <div v-if="this.isShowdrawer">
      <div class="title">
        申请单元列表({{ unitData.length }})
        <el-button type="text" class="batchDel" @click="handleBatchDel" v-if="unitData.length > 1&& isDel">批量删除</el-button>
      </div>
      <el-menu v-model="activeIndex" :default-active="activeIndex" :key="key" @select="unitClick">
        <el-menu-item v-for="(item, index) in unitData" :index="index.toString()" :key="index">
          <p class="dot" v-if="item.issave == '0'"></p>
          <div class="menu-con">
            <p>{{ item.bdcdyh }}</p>
            <el-tooltip effect="dark" :content="item.zl" placement="top">
              <p v-if="item.sqfl=='1'" class="title-detail">{{ item.zl }}</p>
              <p v-else class="title-detail">{{ item.qllxmc }}</p>
            </el-tooltip>
          </div>
          <i class="el-icon-delete" v-if="unitData.length > 1 && item.sqfl=='1' && isDel" @click.stop="handleDel(item)"></i>
        </el-menu-item>
      </el-menu>
    </div>
    <div class="map-drawer-click map-drawer" v-if="!isShowdrawer" @click="
          () => {
            this.isShowdrawer = !this.isShowdrawer;
          }
        "></div>
    <div class="map-drawer-expand map-drawer" v-else @click="
          () => {
            this.isShowdrawer = !this.isShowdrawer;
          }
        "></div>
  </div>
</template>
<script>
  import { mapGetters } from 'vuex'
  import { leftMenu, deleteSlbdcdy, jdcxLeftMenu } from "@/api/workFlow.js"
  export default {
    props: {
      isDel: {
        type: Boolean,
        default: true
      }
    },
    data () {
      return {
        key: 0,
        //受理申请标识码
        bsmSlsq: this.$route.query.bsmSlsq,
        bestepid: this.$route.query.bestepid,
        bsmBusiness: this.$route.query.bsmBusiness,
        type: this.$route.query.type,
        // 默认选中
        activeIndex: '0',
        // 折叠
        isShowdrawer: true,
        // 批量操作
        showBatch: false,
        //批量操作按钮名称
        batchButtonName: '',
        //左侧菜单数据集合
        unitData: [],
        // 设置表单传递数据
        currentSelectProps: {}
      }
    },
    mounted () {
      this.loadBdcdylist();
    },
    computed: {
      ...mapGetters(['isRefresh'])
    },
    watch: {
      isRefresh: {
        handler (newVal, oldVal) {
          if (newVal) {
            this.loadBdcdylist(true)
          }
        },
        immediate: true
      }
    },
    methods: {
      /**
       * @description: 读取申请单元信息
       * @author: renchao
       */
      loadBdcdylist (status = false) {
        let that = this
        var formdata = new FormData();
        formdata.append("bsmSlsq", this.$route.query.bsmSlsq);
        formdata.append("bestepid", this.bestepid ? this.bestepid : '');
        formdata.append("bsmBusiness", this.bsmBusiness ? this.bsmBusiness : '');
        if (this.type) {
          jdcxLeftMenu(formdata).then((res) => {
            if (res.code === 200 && res.result) {
              that.unitData = res.result;
              window.unitData = res.result;
              that.currentSelectProps = res.result[0];
              that.$emit('getCurrentSelectProps', this.currentSelectProps);
              that.judgeBatchShow();
              if (!status) {
                if (sessionStorage.getItem('keyPath') && sessionStorage.getItem('keyPath') >= 0) {
                  that.unitClick(sessionStorage.getItem('keyPath') - 0)
                } else {
                  if (that.showBatch) {
                    //满足批量查封/批量抵押按钮出现 即先展示批量表单
                    that.batchUnitClick();
                  } else {
                    that.unitClick(0)
                  }
                }
              }
            }
          })
        } else {
          leftMenu(formdata).then((res) => {
            if (res.code === 200 && res.result) {
              that.unitData = res.result;
              window.unitData = res.result;
              this.currentSelectProps = res.result[0];
              this.$emit('getCurrentSelectProps', this.currentSelectProps);
              this.judgeBatchShow();
              if (!status) {
                if (sessionStorage.getItem('keyPath') && sessionStorage.getItem('keyPath') >= 0) {
                  that.unitClick(sessionStorage.getItem('keyPath') - 0)
                } else {
                  if (that.showBatch) {
                    //满足批量查封/批量抵押按钮出现 即先展示批量表单
                    that.batchUnitClick();
                  } else {
                    that.unitClick(0)
                  }
                }
              }
            }
          })
        }
      },
      /**
       * @description: 批量按钮判断
       * @author: renchao
       */
      judgeBatchShow () {
        this.showBatch = false;
        if (this.unitData.length > 1) {
          let qllx = this.$route.query?.djywbm?.substring(0, 3);
          switch (qllx) {
            case 'A04': case 'A06': case 'A08':
              this.showBatch = true;
              this.batchButtonName = '房屋批量操作';
              break;
            case 'B39':
              this.showBatch = true;
              this.batchButtonName = '查封批量操作';
              break;
            case 'A37':
              this.showBatch = true;
              this.batchButtonName = '抵押批量操作';
              break;
            case 'B37':
              this.showBatch = true;
              this.batchButtonName = '在建工程抵押批量操作';
              break;
          }
        }
      },
      /**
       * @description: 删除左侧列表
       * @param {*} item
       * @author: renchao
       */
      handleDel (item) {
        let that = this
        this.$confirm("确定要删除吗, 是否继续?", "提示", {
          confirmButtonText: "确定",
          cancelButtonText: "取消",
          type: "warning",
        })
          .then(() => {
            var formdata = new FormData();
            formdata.append("bsmSldyList", item.bsmSldy.split(","));
            deleteSlbdcdy(formdata).then((res) => {
              if (res.code == 200) {
                that.$message.success("删除成功");
                that.loadBdcdylist()
                if (that.activeIndex != '-1') {
                  that.activeIndex = '0'
                  sessionStorage.setItem('keyPath', '0');
                }
              } else {
                this.$message.error(res.message);
              }
            })
          })
          .catch(() => {
            this.$message({
              type: "info",
              message: "已取消删除",
            });
          });
      },
      /**
       * @description: 批量按钮点击事件
       * @author: renchao
       */
      batchUnitClick () {
        window.currentSelect = {}
        this.currentSelectProps.batchOperation = true;
        this.activeIndex = "-1";
        this.$parent.stepForm(0);
        sessionStorage.setItem('keyPath', this.activeIndex);
      },
      /**
       * @description: 批量操作
       * @author: renchao
       */
      handleBatchDel () {
        this.$popupDialog("批量删除", "workflow/components/batchDel", {
          bsmSlsq: this.bsmSlsq,
          dataList: this.unitData,
        }, '55%', true)
      },
      /**
       * @description: 申请单元点击事件
       * @param {*} index
       * @author: renchao
       */
      unitClick (index) {
        window.currentSelect = this.unitData[index]
        if (this.unitData.length == 0) return
        this.currentSelectProps = this.unitData[index];
        this.currentSelectProps.batchOperation = false;
        this.activeIndex = index.toString();
        sessionStorage.setItem('keyPath', this.activeIndex);
        this.key++
        //选中表单传递数据
        this.$emit('getCurrentSelectProps', this.currentSelectProps);
        this.$parent.stepForm(index);
        this.$store.dispatch('user/refreshPage', false);
      }
    },
    beforeDestroy () {
      sessionStorage.removeItem('keyPath')
    }
  }
</script>
<style scoped lang='scss'>
  @import "~@/styles/mixin.scss";
  @import "../../workFrame.scss";
  .leftmenu ul {
    height: calc(100vh - 120px);
  }
</style>