黄何裕
2024-07-23 ef5339794e21c4905518c6b8fba013a9c32aa1ab
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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
<template>
  <div class="app-container">
    <el-tabs v-model="activeName" @tab-click="handleClick">
      <el-tab-pane label="课程" name="first" />
      <el-tab-pane label="教师" name="fourth" />
      <el-tab-pane label="场地" name="xxx" />
    </el-tabs>
    <div>
      <div style="width: 300px">
        <el-date-picker v-model="timeData" type="date" placeholder="选择日期">
        </el-date-picker>
      </div>
      <div style="display: flex">
        <div class="timetable-b w100">
          <table class="timetable-content w100">
            <thead>
              <tr>
                <th></th>
                <th v-for="(item1, index1) in weeks" :key="index1">
                  xxx
                </th>
              </tr>
            </thead>
            <tbody>
              <tr v-for="(item2, index2) in maxCourseLength" :key="index2">
                <td>
                  <p>{{ xxx }}</p>
                </td>
                <template v-for="(item3, index3) in weeks">
                  <td
                    :key="index3"
                    :rowspan="
                      showData(index3, index2 + 1).subject &&
                      showData(index3, index2).subject ===
                        showData(index3, index2 + 1).subject
                        ? 2
                        : ''
                    "
                    :style="[
                      {
                        display:
                          showData(index3, index2 - 1).subject &&
                          showData(index3, index2 - 1).subject ===
                            showData(index3, index2).subject
                            ? 'none'
                            : '',
                      },
                    ]"
                  >
                    <div
                      class="dmsjandjs-b"
                      :style="[
                        {
                          background: showData(index3, index2).index
                            ? getRandomColor()
                            : '#FFFFFF',
                        },
                        { color: '#fff' },
                        { borderRadius: '15px' },
                        { padding: '12px' },
                        { height: '100%' },
                      ]"
                    >
                      <p>
                        {{ showData(index3, index2).startTime }}
                        {{ showData(index3, index2).startTime ? "-" : "" }}
                        {{ showData(index3, index2).endTime }}
                      </p>
                      <p>{{ showData(index3, index2).subject }}</p>
                      <p>{{ showData(index3, index2).major }}</p>
                      <p>{{ showData(index3, index2).class }}</p>
                    </div>
                  </td>
                </template>
              </tr>
            </tbody>
          </table>
        </div>
      </div>
    </div>
  </div>
</template>
 
<script>
import { getList } from "@/api/table";
 
export default {
  filters: {
    statusFilter(status) {
      const statusMap = {
        published: "success",
        draft: "gray",
        deleted: "danger",
      };
      return statusMap[status];
    },
  },
  data() {
    return {
      list: null,
      listLoading: true,
      activeName: "first",
      timeData: new Date(),
    };
  },
  created() {
    this.fetchData();
  },
  methods: {
    fetchData() {
      this.listLoading = true;
      getList().then((response) => {
        this.list = response.data.items;
        this.listLoading = false;
      });
    },
     //随机获取颜色
     getRandomColor() {
      let colorList = this.colorList;
      let colorRandom = Math.floor(Math.random() * colorList.length + 1) - 1;
      let color;
      for (let i = 0; colorList.length > i; i++) {
        if (i == colorRandom) {
          color = colorList[i];
        }
      }
      return color;
    },
  },
};
</script>