<!--
 * @Author: zwq
 * @Date: 2020-12-29 16:37:56
 * @LastEditors: zwq
 * @LastEditTime: 2022-03-04 16:54:51
 * @Description:
-->
<template>
  <el-dialog
    :title="$t('module.basicData.visual.stock') | i18nFilter"
    :visible.sync="visible"
    top="5vh"
  >
    <div>
      <div class="mainDiv" style="margin:10px 0 100px">
        <div class="title">货架一</div>
        <div class="flexDiv">
          <div
            v-for="count in 5"
            :key="count"
            class="wareBox"
            :class="[
              count > Math.round(Math.random() * 10) ? 'enableBox' : 'disableBox',
              { active: count === isActive }
            ]"
            @click="selectBox(count)"
          >
            <div class="plat">库位{{ count }}</div>
          </div>
        </div>
        <div class="flexDiv">
          <div
            v-for="count in 5"
            :key="count"
            class="wareBox"
            :class="[
              count > Math.round(Math.random() * 10) ? 'enableBox' : 'disableBox',
              { active: count + 5 === isActive }
            ]"
            @click="selectBox(count + 5)"
          >
            <div class="plat">库位{{ count + 5 }}</div>
          </div>
        </div>
      </div>
      <div class="line" />
      <div class="mainDiv" style="margin:100px 0 10px">
        <div class="title">货架二</div>
        <div class="flexDiv">
          <div
            v-for="count in 5"
            :key="count"
            class="wareBox"
            :class="[
              count > Math.round(Math.random() * 10) ? 'enableBox' : 'disableBox',
              { active: count+10 === isActive }
            ]"
            @click="selectBox(count+10)"
          >
            <div class="plat">库位{{ count+10 }}</div>
          </div>
        </div>
        <div class="flexDiv">
          <div
            v-for="count in 5"
            :key="count"
            class="wareBox"
            :class="[
              count > Math.round(Math.random() * 10) ? 'enableBox' : 'disableBox',
              { active: count+15 === isActive }
            ]"
            @click="selectBox(count+15)"
          >
            <div class="plat">库位{{ count+15 }}</div>
          </div>
        </div>
      </div>
    </div>
    <span slot="footer" class="dialog-footer">
      <el-button @click="visible = false">{{ 'btn.cancel' | i18nFilter }}</el-button>
      <el-button type="primary" @click="dataFormSubmit()">{{ 'btn.confirm' | i18nFilter }}</el-button>
    </span>
  </el-dialog>
</template>

<script>

export default {
  data() {
    return {
      visible: false,
      isActiveArr: []
    }
  },
  methods: {
    init() {
      this.visible = true
    },
    selectBox(count) {
      this.isActive.push(count)
    },
    // 表单提交
    dataFormSubmit() {
      this.visible = false
    }
  }
}
</script>

<style scoped>
.mainDiv {
  border: 2px solid rgb(145, 174, 255);
  padding: 20px 0;
}
.flexDiv {
  display: -webkit-flex;
  display: flex;
  -webkit-justify-content: space-around;
  justify-content: space-around;
}
.title {
  float: left;
  width: 50px;
  font-size: 40px;
  line-height: 45px;
}
/* 边框特效 */
.wareBox:hover {
  background: linear-gradient(to left, deepskyblue, deepskyblue) left top
      no-repeat,
    linear-gradient(to bottom, deepskyblue, deepskyblue) left top no-repeat,
    linear-gradient(to left, deepskyblue, deepskyblue) right top no-repeat,
    linear-gradient(to bottom, deepskyblue, deepskyblue) right top no-repeat,
    linear-gradient(to left, deepskyblue, deepskyblue) left bottom no-repeat,
    linear-gradient(to bottom, deepskyblue, deepskyblue) left bottom no-repeat,
    linear-gradient(to left, deepskyblue, deepskyblue) right bottom no-repeat,
    linear-gradient(to left, deepskyblue, deepskyblue) right bottom no-repeat;
  background-size: 5px 30px, 30px 5px;
  color: black;
  border-radius: 5px;
  background-color: rgb(190, 224, 241);
}
.wareBox {
  cursor: pointer;
  margin: 10px;
  height: 80px;
  line-height: 70px;
  text-align: center;
  border: 2px solid #cdcdc5;
  border-radius: 5px;
}
.plat {
  min-width: 80px;
}
.line {
  margin: 20px 0;
  height: 2px;
  background-color: gray;
  border-left: 200px solid #ddd;
  border-right: 200px solid #ddd;
}
.enableBox {
  background: rgb(0, 189, 16);
}
.disableBox {
  background: #ddd;
  cursor: not-allowed;
}
.end-plat {
  background-color: rgb(195, 246, 255);
}
.active {
  border: 2px solid red;
}
</style>
