<template>
  <el-dialog title="楼层贯通关系维护" :visible.sync="connectDialogVis" width="730px" id="messageDialog">
    <el-row>
      <div style="line-height:32px;">添加与{{floor.FloorLocalName}}层有贯通关系的楼层 : </div>
      <div style="width:70%">
        <bfCascader ref="bfCascader" :FloorID="floor.FloorID"></bfCascader>
      </div>
    </el-row>
    <span slot="footer" class="dialog-footer">
      <el-button size="small" @click="connectDialogVis=false">取消</el-button>
      <el-button size="small" type="primary" @click="save">确认</el-button>
    </span>
  </el-dialog>
</template>
<script>
import bfCascader from '@/components/ready/buildfloor/buildfloorCascader'
import { createRelationInFloor } from "@/api/scan/request";
export default {
  data() {
    return {
      buildName: '',
      connectDialogVis: false,
      floor: {}
    }
  },
  components: {
    bfCascader
  },
  methods: {
    showDialog() {
      this.connectDialogVis = true
      this.$nextTick(() => {
        this.$refs.bfCascader.getCascader()
        let arr = this.floor.FloorThroughList || [];
        let value = []
        if (arr.length) {
          arr.map(t => {
            value.push([t.BuildID, t.FloorID])
          })
        }
        this.$refs.bfCascader.value = value
      })
    },
    save() {
      let arr = this.$refs.bfCascader.value;
      let param = {
        FloorId: this.floor.FloorID,
        FloorOtherIdList: []
      }
      arr.map(t => {
        param.FloorOtherIdList.push(t[1])
      })
      createRelationInFloor(param, res => {
        this.connectDialogVis = false;
        this.$message.success('关联成功');
        this.$emit('refresh')
      })
    }
  }
}
</script>
<style lang="less" scoped>
#messageDialog {
  .el-row{
    height: 50px;
    max-height: 200px;
    overflow-y: auto;
    overflow-x: hidden;
  }
  .el-row > div {
    float: left;
  }
  .el-row > div + div {
    margin-left: 10px;
  }
  /deep/ .el-input__inner {
    vertical-align: baseline;
  }
}
</style>