1
huanghongfeng
3 天以前 b1c2dd1869a51b8f0e4acb9ddeb148f796db147f
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
<template>
    <div class="table-container">
      <table class="data-table">
        <thead>
          <tr>
            <th v-for="(header, index) in headers" :key="index">
              {{ header }}
            </th>
          </tr>
        </thead>
        <tbody>
          <tr v-for="(row, rowIndex) in tableData" :key="rowIndex">
            <td v-for="(cell, cellIndex) in row" :key="cellIndex">
              {{ cell }}
            </td>
          </tr>
        </tbody>
      </table>
    </div>
  </template>
  
  <script>
import axios from 'axios';
 
export default {
  data() {
    return {
      headers: ['货位信息', '数量'],
      tableData: []
    };
  },
  created() {
    this.fetchData();
  },
  methods: {
    fetchData() {
      axios.post("http://172.21.1.139:5000/api/LocationInfo/LocationStatus", null)
        .then((response) => {
          this.tableData = [];
          response.forEach(item => {
            this.tableData.push([
              item.status,
              item.count
            ]);
          });
        })
        .catch((error) => {
          console.error("请求失败:", error);
          this.tableData = [
            ['空货位', 0],
            ['有货', 0],
            ['占用', 0]
          ];
        });
    }
  }
};
</script>
  
  <style scoped>
  .table-container {
    width: 100%;
    overflow-x: auto;
  }
  
  .data-table {
    width: 100%;
    border-collapse: collapse;
    margin: 20px 0;
    font-family: Arial, sans-serif;
  }
  
  .data-table th {
    font-weight: bold;
    padding: 12px 15px;
    text-align: left;
    border-bottom: 2px solid #c9aeae;
  }
  
  .data-table td {
    padding: 10px 15px;
    border-bottom: 1px solid #ddd;
  }
  </style>