<template>
  <div class="home">
    <el-row style="width: 100%">
      <h1 style="margin-left: auto; margin-right: auto">成品仓智能仓 {{route.query.standId}}&nbsp;号线出库状态一览表</h1>
    </el-row>
    <el-divider style="margin-top: 0" />
    <el-row style="margin-right: 20px;margin-left: 20px;">
      <el-table :data="tableData" :border="true" :header-cell-style="headerStyle" :row-style="dataStyle">
        <el-table-column prop="plcid" label="任务号" width="150" align="center"></el-table-column>
        <el-table-column prop="customer_id" label="客户代码" align="center"></el-table-column>
        <el-table-column prop="good_id" label="产品编号" align="center"></el-table-column>
        <el-table-column prop="loc_id" label="库位" align="center"></el-table-column>
        <el-table-column prop="docctnumber" label="周期" align="center"></el-table-column>
        <el-table-column prop="mistock_num" label="数量" align="center"></el-table-column>
        <el-table-column prop="status" label="出库状态位置" align="center"></el-table-column>
      </el-table>
    </el-row>
    <div style="font-size: 1.5rem; color: #ab0a07;position: fixed;left: 10px; bottom:10px">精心·精品</div>
    <img src="@/assets/img.png" alt="logo" style="position: fixed;bottom: 10px; right: 10px"/>
    <img src="@/assets/img.png" alt="logo" style="position: fixed;top: 20px; left: 10px"/>
    <button class="hidBtn" style="position: fixed;top: 10px; right: 10px;" @click="fullScreenFuc">全屏</button>
    <button class="hidBtn" style="position: fixed;top: 10px; right: 70px;" @click="outScreenFuc">退出</button>
  </div>
</template>

<script setup>

import {onMounted, ref} from "vue";
import {useRoute} from 'vue-router';
import getData from "@/http/get-data";

// 获取路由对象
const route = useRoute();

const standId = ref("50");
let tableData = ref([]);
const headerStyle = ref((row, index) => {
  return {
    fontSize: "1.5rem",
    color: "#fff",
    backgroundColor: "#1f2964",
    marginTop: "10px",
    paddingTop: "10px",
    paddingBottom: "10px",
    textAlign: "center",
  }
});

const dataStyle = ref((row, index) => {
  return {
    fontSize: "1.5rem",
    color: "#454444",
  }
});

const fullScreenFuc = () => {
  document.documentElement.requestFullscreen();
}
const outScreenFuc = () => {
  document.exitFullscreen();
}
// 解析url获取站台
const resolveStand = () => {
  standId.value = route.query.standId.toString();
}

onMounted(() => {
  tableData.value = [];
  //resolveStand();
  setInterval(() => {
    getData.getData({ PORT: route.query.standId }).then(res => {
      const response = res.data;
      if(response.code === 0) {
        tableData.value = response.data;
        return;
      }
      console.log(response);
    }).catch(err => {
      console.log(err);
    })
  }, 5000)
});


</script>

<style scoped>
.hidBtn {
  width: 60px;height: 30px;
  border: transparent;
  background: white;
  color: transparent;
}

.hidBtn:hover {
  background: #30f1e6;
  border: #2c3e50 solid 2px;
  color: #2c3e50;
}
</style>
