king
2018-09-29 31573a0912c1971a9043b3f9294f643c7d60a2aa
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
<template>
  <div class="simple-table">
    <table class="table" border="2">
        <thead>
          <tr role="row">
            <th v-for="column in columns" :key="column.type">
              <span v-html="column.name"></span>
              <span class="tip">{{column.tip}}</span>
            </th>
          </tr>
        </thead>
        <tbody>
          <tr role="row" v-for="(data, index) in store" :key="index">
            <td v-for="(column, index) in columns" :key="index" v-html="getData(data, column.type)"></td>
          </tr>
        </tbody>
      </table>
  </div>
</template>
 
<script>
export default {
  name: 'simple-table',
  props: {
    columns: {
      type: Array,
      required: true
    },
    store: {
      type: Array,
      required: true
    }
  },
  methods: {
    getData (data, type) {
      return data[type] ? data[type] : '-'
    }
  }
}
</script>
 
<style scoped>
.table {
  width: 100%;
  margin: 5px 0px 5px;
  text-align: center;
  font-size: 12px;
  color: #676767;
  border: 2px solid #ffffff;
  border-collapse: collapse;
}
.table th {
  background: #2D2D2D;
  color: #ffffff;
}
.table td {
  background: #F3F3F3;
}
.table tr {
  height: 30px;
}
.table .tip {
  color: #bcbcbc;
}
</style>