<template>
    <el-dialog
    :visible.sync="isShow.influence"
    :center="true"
    :width="width">
    <span slot="title">{{title}}</span>
    <div id="influenceDialog">
        <p class="influence-p">受元空间变化影响，部分业务空间需重新划分</p>
        <el-tabs type="border-card">
          <el-tab-pane v-for="(item,index) in tabsList" v-if="index == 0">
            <span slot="label">{{item.name}}</span>
            <p style="line-height:30px;font-size:20px;margin-bottom: 20px;">受影响的业务空间</p>
            <div v-for="i in mess">
              <p style="line-height:20px;margin-left:10px;">{{i.RoomLocalName || '--'}} - {{i.RoomLocalID || '--'}}</p>
            </div>
          </el-tab-pane>
        </el-tabs>
    </div>
    <span slot="footer" class="dialog-footer center">
        <el-button type="primary" @click="confirm">我知道了</el-button>
    </span>
    </el-dialog>
</template>
<script>
import { getAllMess, deleteNotice } from "@/api/request";
export default {
  props: {
    width: {
      type: String,
      default: "40%"
    },
    title: {
      type: String,
      default: "提示"
    },
    isShow: {
      type: Object
    },
    param: {
      type: Object
    },
    tabsList: {
      type: Array,
      default: []
    }
  },
  data() {
    return {
      data: null,
      proj: null,
      activeName: "1",
      allMess: [], //所有提示
      mess: [], //实际提示
      build: {}
    };
  },
  created() {
    this.getAllMess();
  },
  methods: {
    //我知道了
    confirm() {
      let ids = [];
      if (!!this.allMess[this.build.code]) {
        this.allMess[this.build.code].map(item => {
          ids.push(item.RoomID);
        });
      }
      let param = {
        data: {
          ids: ids
        },
        ProjId: this.$route.query.projId,
        secret: this.$route.query.secret
      };
      deleteNotice(param)
        .then(res => {
          if (res.data.Result == "success") {
            this.isShow.influence = false;
          } else {
            this.$message.error(res.data.ResultMsg);
          }
        })
        .catch(() => {
          this.$message.error("请求失败");
        });
    },
    getData(build) {
      this.build = build;
      this.mess = this.allMess[build.code];
    },
    getAllMess() {
      getAllMess({
        ProjId: this.$route.query.projId,
        secret: this.$route.query.secret
      })
        .then(res => {
          if (res.data.Result == "success") {
            // this.allMess = res.data.Content
            this.changeMsg(res.data.Content);
            console.log(this.allMess);
          } else {
            this.$message.error(res.data.ResultMsg);
          }
        })
        .catch(() => {
          this.$message.error("请求错误");
        });
    },

    //获取楼层信息
    changeMsg(arr) {
      arr.map(item => {
        if (!!this.allMess[item.location.floor]) {
          this.allMess[item.location.floor].push(item.infos);
        } else {
          this.allMess[item.location.floor] = [];
          this.allMess[item.location.floor].push(item.infos);
        }
      });
    },
    handleClick() {}
  }
};
</script>

<style lang="less">
#influenceDialog {
  .el-tabs__content {
    max-height: 200px;
    overflow-y: auto;
  }
  .influence-p {
    height: 40px;
    line-height: 40px;
    font-size: 17px;
    margin-bottom: 10px;
  }
}
</style>
