<template>
  <div v-if="modalFlag">
    <div class="vehicle_servies_modal" @mousewheel="mousewheel">
      <div class="modal_content">
        <div class="time">
          <p>选择时间</p>
          <input type="month" v-model="time" />
        </div>
        <div class="plate">
          <p>选择平台</p>
          <div>{{selectedplateForm.platformName}}</div>
        </div>
        <div class="num">
          <p>设置上传数量</p>
          <input type="text" v-model="num" />
        </div>
        <div class="btn">
          <button @click="submit" style="margin: 0">保存</button>
          <button @click="hideModal" style="margin: 0">取消</button>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  props: {
    modalFlag: {
      type: Boolean,
      default: false,
    },
    selectedplateForm: {
      type: Object,
      default: () => {
        return {};
      },
    },
  },
  data() {
    return {
      time: "",
      num: 0,
    };
  },
  methods: {
    submit: function () {
      if (!this.num) {
        alert("请选择上传数量");
        return;
      }
      let num = +this.num;
      if (typeof num !== "number") {
        alert("请输入大于零的数字");
      } else if (num <= 0) {
        alert("请输入大于零的整数");
      } else if (Math.ceil(num) !== num) {
        alert("请输入大于零的整数");
      } else {
        this.$emit("submit", this.time, this.num, this.selectedplateForm);
      }
    },
    hideModal: function () {
      this.$emit("hide_modal");
    },
    mousewheel: function (e) {
      e.preventDefault();
    },
  },
  created() {
    console.log(this.selectedplateForm);
  }
};
</script>

<style scoped lang="less">
.vehicle_servies_modal {
  position: fixed;
  left: 0;
  top: 0;
  height: 100vh;
  width: 100vw;
  background-color: rgba(127, 127, 127, 0.7);
  display: flex;
  justify-content: center;
  align-items: center;
  .modal_content {
    width: 600px;
    height: 400px;
    background-color: #fff;
    transform: translateY(-80px);
    padding-left: 240px;
    .time {
      margin-top: 80px;
      display: flex;
      height: 28px;
      p {
        width: 80px;
        height: 28px;
        line-height: 28px;
        margin-right: 20px;
      }
      input {
        height: 28px;
        width: 200px;
        border: 1px solid #ccc;
        color: #555;
      }
    }
    .plate {
      margin-top: 20px;
      margin-right: 20px;
      display: flex;
      p {
        width: 100px;
      }
    }
    .num {
      display: flex;
      margin-top: 20px;
      p {
        height: 28px;
        line-height: 28px;
        width: 100px;
      }
      input {
        color: #555;
        height: 28px;
        width: 200px;
        border: 1px solid #ccc;
      }
    }
    .btn {
      width: 200px;
      margin-top: 30px;
      display: flex;
      justify-content: space-between;
    }
  }
}
</style>
