/*Workench*/
<template>
  <div>
    <transition name="marsk-fade">
      <div v-show="workbenchConfig.isShow" class="marsk" />
    </transition>
    <transition name="slide-fade">
      <div v-show="workbenchConfig.isShow" class="action-view">
        <div class="header">
          <p>请选择工作台：</p>
          <div class="operation">
            <i class="el-icon-close" @click="close" />
          </div>
        </div>
        <div class="content">
          <div
            v-for="(item, index) in workbenchConfig.dataList"
            :key="index"
            class="list"
            @click="
              toPage(
                item.platformNumber,
                item.platformId,
                item.preprocessDisplayStyle,
                item.cfdDisplayStyle
              )
            "
          >
            <img
              :src="getImage(item.platformPicId)"
              :class="[
                workbenchConfig.currentPage == item.platformNumber
                  ? 'nogray'
                  : '',
              ]"
            />
          </div>
        </div>
      </div>
    </transition>
  </div>
</template>

<script>
import { getImage } from '@/utils/request'
import { Message } from "element-ui";
export default {
  name: 'Workench',
  props: {
    workbenchConfig: {
      isShow: {
        type: Boolean,
        default: () => false,
      },
      currentPage: {
        type: String,
        default: () => '',
      },
      dataList: {
        type: Array,
        default: () => [],
      },
    },
  },
  methods: {
    // 点击关闭
    close() {
      this.$emit('putWorkbench', false)
    },
    toPage(type, id, pretreatment, solver) {
      if (pretreatment == 0 && solver == 0)
        return this.$message.error('还未接入数据！')
      this.$store.dispatch('user/changeState', {
        key: 'workbench',
        value: type,
      })
      this.close()
      if(id=="ed4f8bb6257344878d9d68783787fc3d"){
     let routeUrl=  this.$router.replace({
        path: '/indexLayout/workbench',
       query: { id, pretreatment, solver },
      })
      //  window.open(routeUrl.href, '_blank');
      }else{
          return  Message({
          message: "还未接入数据！",
          type: "warning",
          center: true,
          offset:"200"
        });
      }
    
    },
    getImage(id) {
      return getImage(id)
    },
  },
}
</script>

<style lang="scss" scoped>
@import '@/styles/variables.scss';
@import '@/styles/mixin.scss';

.marsk-fade-enter-active,
.marsk-fade-leave-active {
  transition: all 0.5s;
}
.marsk-fade-enter,
.marsk-fade-leave-to {
  opacity: 0;
}
.marsk {
  @include position(fixed, 0, 0, 0, 0, 1000);
  background: rgba(4, 112, 204, 0.05);
}

.slide-fade-enter-active {
  transition: all 0.3s ease;
}
.slide-fade-leave-active {
  transition: all 0.3s cubic-bezier(1, 0.5, 0.8, 1);
}
.slide-fade-enter,
.slide-fade-leave-to {
  transform: translateY(7.48rem);
}
.action-view {
  @include position(fixed, 50%, auto, 50%, auto, 1001);
  @include w_h(600px);
  transform: translate(-50%, -50%);
  background: $color_e;
  text-align: left;
  box-shadow: 0 0 7px 7px rgba(0, 0, 0, 0.04);
  .header {
    @include w_h();
    position: relative;
    padding: 5px 30px;
    color: $color_f;
    background: #004694;
    p {
      margin: 10px auto;
      font-size: 14px;
    }
    .operation {
      @include position(absolute, 10px, auto, auto, 20px, 1);
      font-size: 22px;
      color: $color_f;
    }
    .operation:hover {
      cursor: pointer;
      color: $color_f5;
    }
  }
  .content {
    @include w_h(100%, 220px);
    padding: 20px 30px;
    color: $color_3;
    overflow-y: auto;
    .list {
      float: left;
      margin: 5px;
      @include w_h(125px, 50px);
      @include flex(center);
      background: $color_f;
      &:hover {
        cursor: pointer;
        & > img {
          filter: none;
        }
      }
      img {
        height: 30px;
        filter: grayscale(100%);
        filter: gray;
        &.nogray {
          filter: none;
        }
      }
    }
  }
}
</style>
