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
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
|
<template>
<el-dialog :title="$t('editScheduleClassesDay.title')" :visible.sync="visible" width="60%" @close="handleClose">
<el-form label-position="right" label-width="120px">
<el-form-item :label="$t('editScheduleClassesDay.status')">
<el-select v-model="workday" @change="changeScheduleClassesDayState" style="width:100%">
<el-option :label="$t('editScheduleClassesDay.rest')" value="2002" />
<el-option v-for="(item, index) in classess" :key="index" :label="`${item.name}${getClassTime(item)}`"
:value="item.classesId" />
</el-select>
</el-form-item>
<div v-if="workday !== '2002'">
<el-form-item v-for="(item, index) in times" :key="index">
<el-col :span="11">
<el-form-item :label="$t('editScheduleClassesDay.startTime')">
<el-input v-model="item.startTime" :placeholder="$t('editScheduleClassesDay.startTimePlaceholder')" />
</el-form-item>
</el-col>
<el-col :span="11" :offset="2">
<el-form-item :label="$t('editScheduleClassesDay.endTime')">
<el-input v-model="item.endTime" :placeholder="$t('editScheduleClassesDay.endTimePlaceholder')" />
</el-form-item>
</el-col>
</el-form-item>
</div>
</el-form>
<span slot="footer" class="dialog-footer">
<el-button @click="visible = false">{{ $t('common.cancel') }}</el-button>
<el-button type="primary" @click="submitEditScheduleClassesDay">
{{ $t('common.submit') }}
</el-button>
</span>
</el-dialog>
</template>
<script>
import { listClasses } from '@/api/org/addScheduleClassesApi'
export default {
name: 'EditScheduleClassesDay',
data() {
return {
visible: false,
workday: '',
workdayName: '',
times: [],
classess: [],
currentItem: null
}
},
methods: {
open(item) {
this.currentItem = item
this.workday = item.workday
this.workdayName = item.workdayName
this.times = item.times ? [...item.times] : []
this.listClassess()
this.visible = true
},
handleClose() {
this.workday = ''
this.workdayName = ''
this.times = []
this.currentItem = null
},
async listClassess() {
try {
const params = {
page: 1,
row: 100,
state: '1001'
}
const res = await listClasses(params)
this.classess = res.data || []
} catch (error) {
console.error('获取班次列表失败:', error)
}
},
changeScheduleClassesDayState() {
this.times = []
if (this.workday === '2002') {
this.workdayName = this.$t('editScheduleClassesDay.rest')
return
}
const selectedClass = this.classess.find(item => item.classesId === this.workday)
if (selectedClass) {
this.workdayName = selectedClass.name
if (selectedClass.times) {
this.times = [...selectedClass.times]
}
}
},
getClassTime(item) {
if (!item.times || item.times.length === 0) return ''
let timeStr = ''
item.times.forEach(timeItem => {
timeStr += `${timeItem.startTime}-${timeItem.endTime};`
})
return `(${timeStr})`
},
submitEditScheduleClassesDay() {
if (this.currentItem) {
this.currentItem.workday = this.workday
this.currentItem.workdayName = this.workdayName
this.currentItem.times = [...this.times]
this.visible = false
}
}
}
}
</script>
<style lang="scss" scoped>
.el-form-item {
margin-bottom: 20px;
}
</style>
|