Blame view

src/components/org/scheduleClassesDay.vue 2.81 KB
03f63ab4   wuxw   优化到商户信息
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
  <template>
    <div>
      <el-form-item :label="$t('scheduleClassesDay.scheduleCycle')">
        <el-select v-model="scheduleCycle" :placeholder="$t('scheduleClassesDay.scheduleCyclePlaceholder')"
          @change="changeInspectionPeriod" style="width:100%">
          <el-option v-for="index in 31" :key="index" :label="`${index}${$t('scheduleClassesDay.day')}`" :value="index" />
        </el-select>
      </el-form-item>
  
      <el-form-item :label="$t('scheduleClassesDay.scheduleInfo')">
        <div class="schedule-days-container">
          <div v-for="(item, index) in days" :key="index" class="schedule-day-item" @click="changeWorkdayInfo(item)">
            <div class="day-number">{{ item.day }}</div>
            <div class="workday-name">{{ item.workdayName }}</div>
            <div v-for="(time, timeIndex) in item.times" :key="timeIndex" class="time-range">
              {{ time.startTime }}-{{ time.endTime }}
            </div>
          </div>
        </div>
      </el-form-item>
    </div>
  </template>
  
  <script>
  export default {
    name: 'ScheduleClassesDay',
    props: {
      initialData: {
        type: Object,
        default: () => ({})
      }
    },
    data() {
      return {
        scheduleCycle: 1,
        days: []
      }
    },
    created() {
      if (this.initialData.days && this.initialData.days.length > 0) {
        this.days = [...this.initialData.days]
        this.scheduleCycle = this.initialData.scheduleCycle
      } else {
        this.changeInspectionPeriod()
      }
    },
    methods: {
      notify(params) {
9fc8656f   wuxw   优化排版功能
49
50
51
52
53
        this.days = params.days;
        this.scheduleCycle = params.scheduleCycle;
  
        if (params.days && params.days.length > 0) {
          return;
03f63ab4   wuxw   优化到商户信息
54
        }
9fc8656f   wuxw   优化排版功能
55
56
  
        this.changeInspectionPeriod();
03f63ab4   wuxw   优化到商户信息
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
      },
      initData(scheduleCycle) {
        this.scheduleCycle = scheduleCycle
        this.changeInspectionPeriod()
      },
      changeInspectionPeriod() {
        this.days = []
        for (let cycleIndex = 0; cycleIndex < this.scheduleCycle; cycleIndex++) {
          this.days.push({
            day: cycleIndex + 1,
            workday: '2002',
            workdayName: this.$t('scheduleClassesDay.rest'),
            times: []
          })
        }
9fc8656f   wuxw   优化排版功能
72
        this.$emit('cycleChange', this.scheduleCycle)
03f63ab4   wuxw   优化到商户信息
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
      },
      changeWorkdayInfo(item) {
        this.$emit('editDay', item)
      },
      getDaysData() {
        return this.days
      }
    }
  }
  </script>
  
  <style lang="scss" scoped>
  .schedule-days-container {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
  }
  
  .schedule-day-item {
    width: calc(16.66% - 10px);
    padding: 10px;
    border: 1px solid #ebeef5;
    border-radius: 4px;
    cursor: pointer;
    text-align: center;
    transition: all 0.3s;
  
    &:hover {
      border-color: #409eff;
      box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.1);
    }
  
    .day-number {
      font-weight: bold;
      margin-bottom: 5px;
    }
  
    .workday-name {
      margin-bottom: 5px;
    }
  
    .time-range {
      font-size: 12px;
      color: #666;
    }
  }
  </style>