|
@@ -5,11 +5,9 @@
|
|
</n-space>
|
|
</n-space>
|
|
<div v-if="pageState">
|
|
<div v-if="pageState">
|
|
<table border="1" style="width: 100%">
|
|
<table border="1" style="width: 100%">
|
|
- <caption>
|
|
|
|
- 排课表
|
|
|
|
- </caption>
|
|
|
|
<tbody width="100">
|
|
<tbody width="100">
|
|
<tr>
|
|
<tr>
|
|
|
|
+ <th>时间</th>
|
|
<th>周一</th>
|
|
<th>周一</th>
|
|
<th>周二</th>
|
|
<th>周二</th>
|
|
<th>周三</th>
|
|
<th>周三</th>
|
|
@@ -18,22 +16,29 @@
|
|
<th>周六</th>
|
|
<th>周六</th>
|
|
<th>周日</th>
|
|
<th>周日</th>
|
|
</tr>
|
|
</tr>
|
|
- <tr class="text-center">
|
|
|
|
- <td>李四</td>
|
|
|
|
- <td>员工</td>
|
|
|
|
- <td>李四</td>
|
|
|
|
- <td>李四</td>
|
|
|
|
- <td>李四</td>
|
|
|
|
- <td>李四</td>
|
|
|
|
- <td>李四</td>
|
|
|
|
|
|
+ <tr v-for="key in timeKey" :key="key">
|
|
|
|
+ <td>{{ key }}</td>
|
|
|
|
+ <template v-for="index in [1, 2, 3, 4, 5, 6, 7]" :key="index">
|
|
|
|
+ <td
|
|
|
|
+ v-if="scheduleList[index][key]['empty'] === false && scheduleList[index][key]['break'] === false"
|
|
|
|
+ :rowspan="scheduleList[index][key]['colspan']"
|
|
|
|
+ >
|
|
|
|
+ {{ scheduleList[index][key]['startTime'] }} <br />
|
|
|
|
+ {{ scheduleList[index][key]['endTime'] }}
|
|
|
|
+ </td>
|
|
|
|
+ <td v-else-if="scheduleList[index][key]['empty'] === true">暂无</td>
|
|
|
|
+ </template>
|
|
</tr>
|
|
</tr>
|
|
</tbody>
|
|
</tbody>
|
|
</table>
|
|
</table>
|
|
</div>
|
|
</div>
|
|
<div v-if="!pageState" class="wh-full flex-col-center">
|
|
<div v-if="!pageState" class="wh-full flex-col-center">
|
|
<n-form ref="formRef" size="large" label-placement="left" style="margin-right: 5rem" :model="model">
|
|
<n-form ref="formRef" size="large" label-placement="left" style="margin-right: 5rem" :model="model">
|
|
- <n-form-item label="排课班级" path="inputValue">
|
|
|
|
- <n-input-number v-model:value="model.classId" type="number" disabled placeholder="请选择排课的班级" />
|
|
|
|
|
|
+ <n-form-item label="排课班级" path="groupList">
|
|
|
|
+ <n-select v-model:value="model.classId" :options="groupList" />
|
|
|
|
+ </n-form-item>
|
|
|
|
+ <n-form-item label="所在教室" path="classRoomList">
|
|
|
|
+ <n-select v-model:value="model.roomId" :options="classRoomList" />
|
|
</n-form-item>
|
|
</n-form-item>
|
|
<n-form-item label="任课老师" path="teacherId">
|
|
<n-form-item label="任课老师" path="teacherId">
|
|
<n-select
|
|
<n-select
|
|
@@ -70,9 +75,9 @@
|
|
</n-form-item>
|
|
</n-form-item>
|
|
<n-form-item label="上课时间" path="datetimeValue">
|
|
<n-form-item label="上课时间" path="datetimeValue">
|
|
<n-space>
|
|
<n-space>
|
|
- <n-date-picker v-model:value="dateValue" type="date" />
|
|
|
|
- <n-time-picker v-model:value="model.startTime" />
|
|
|
|
- <n-time-picker v-model:value="model.endTime" />
|
|
|
|
|
|
+ <n-date-picker v-model:value="dateValue" time-zone="Asia/Shanghai" type="date" />
|
|
|
|
+ <n-time-picker v-model:value="startTime" time-zone="Asia/Shanghai" />
|
|
|
|
+ <n-time-picker v-model:value="endTime" time-zone="Asia/Shanghai" />
|
|
</n-space>
|
|
</n-space>
|
|
</n-form-item>
|
|
</n-form-item>
|
|
<n-form-item label="是否连选" path="switchValue">
|
|
<n-form-item label="是否连选" path="switchValue">
|
|
@@ -93,9 +98,20 @@
|
|
</template>
|
|
</template>
|
|
<script setup lang="ts">
|
|
<script setup lang="ts">
|
|
import { ref, reactive } from 'vue';
|
|
import { ref, reactive } from 'vue';
|
|
|
|
+import { useRoute } from 'vue-router';
|
|
import type { CascaderOption } from 'naive-ui';
|
|
import type { CascaderOption } from 'naive-ui';
|
|
-import { queryByRealname, queryCategoryParams, querySubject } from './api';
|
|
|
|
|
|
+import { formatTimestamp } from '~/src/utils';
|
|
|
|
+import {
|
|
|
|
+ queryByRealname,
|
|
|
|
+ queryCategoryParams,
|
|
|
|
+ querySubject,
|
|
|
|
+ queryClassAll,
|
|
|
|
+ addSchedule,
|
|
|
|
+ queryClassRoomList,
|
|
|
|
+ querySchedule
|
|
|
|
+} from './api';
|
|
import type { ScheduleParams } from './api';
|
|
import type { ScheduleParams } from './api';
|
|
|
|
+const route = useRoute();
|
|
const model = reactive<ScheduleParams>({
|
|
const model = reactive<ScheduleParams>({
|
|
week: 0,
|
|
week: 0,
|
|
startTime: 0,
|
|
startTime: 0,
|
|
@@ -111,14 +127,53 @@ const model = reactive<ScheduleParams>({
|
|
createUid: 0,
|
|
createUid: 0,
|
|
disabled: 'N'
|
|
disabled: 'N'
|
|
});
|
|
});
|
|
-
|
|
|
|
-const dateValue = ref<number>();
|
|
|
|
|
|
+const classId = route.query.classId;
|
|
|
|
+const dateValue = ref<number>(0);
|
|
|
|
+const startTime = ref<number>(0);
|
|
|
|
+const endTime = ref<number>(0);
|
|
const isRepeatTime = ref<boolean>(true);
|
|
const isRepeatTime = ref<boolean>(true);
|
|
const repeatTime = ref<number>(1);
|
|
const repeatTime = ref<number>(1);
|
|
const pageState = ref<boolean>(true);
|
|
const pageState = ref<boolean>(true);
|
|
const categoryAndSubjectOptions = ref<any[]>([]);
|
|
const categoryAndSubjectOptions = ref<any[]>([]);
|
|
-
|
|
|
|
|
|
+const groupList = ref<any[]>([]);
|
|
|
|
+const classRoomList = ref<any[]>([]);
|
|
const teacherOptions = ref();
|
|
const teacherOptions = ref();
|
|
|
|
+const generalOptions = ref();
|
|
|
|
+
|
|
|
|
+const scheduleList = ref<{ [index: string]: any }>({
|
|
|
|
+ '1': {},
|
|
|
|
+ '2': {},
|
|
|
|
+ '3': {},
|
|
|
|
+ '4': {},
|
|
|
|
+ '5': {},
|
|
|
|
+ '6': {},
|
|
|
|
+ '7': {}
|
|
|
|
+});
|
|
|
|
+const timeKey = ref<string[]>([
|
|
|
|
+ '08:00',
|
|
|
|
+ '09:00',
|
|
|
|
+ '10:00',
|
|
|
|
+ '11:00',
|
|
|
|
+ '12:00',
|
|
|
|
+ '13:00',
|
|
|
|
+ '14:00',
|
|
|
|
+ '15:00',
|
|
|
|
+ '16:00',
|
|
|
|
+ '17:00',
|
|
|
|
+ '18:00',
|
|
|
|
+ '19:00',
|
|
|
|
+ '20:00',
|
|
|
|
+ '21:00',
|
|
|
|
+ '22:00',
|
|
|
|
+ '23:00'
|
|
|
|
+]);
|
|
|
|
+for (let i = 1; i <= 7; i += 1) {
|
|
|
|
+ scheduleList.value[i] = {};
|
|
|
|
+ for (let j = 0; j < timeKey.value.length; j += 1) {
|
|
|
|
+ scheduleList.value[i][timeKey.value[j]] = { empty: true, break: false };
|
|
|
|
+ }
|
|
|
|
+}
|
|
|
|
+
|
|
function teacherSearch(keyword: string) {
|
|
function teacherSearch(keyword: string) {
|
|
if (keyword.length <= 0 || !keyword.length) {
|
|
if (keyword.length <= 0 || !keyword.length) {
|
|
teacherOptions.value = [];
|
|
teacherOptions.value = [];
|
|
@@ -134,7 +189,6 @@ function teacherSearch(keyword: string) {
|
|
});
|
|
});
|
|
}
|
|
}
|
|
|
|
|
|
-const generalOptions = ref();
|
|
|
|
function assistantSearch(keyword: string) {
|
|
function assistantSearch(keyword: string) {
|
|
if (keyword.length <= 0 || !keyword.length) {
|
|
if (keyword.length <= 0 || !keyword.length) {
|
|
generalOptions.value = [];
|
|
generalOptions.value = [];
|
|
@@ -171,8 +225,16 @@ function categoryAndSubjectLoad(option: CascaderOption) {
|
|
});
|
|
});
|
|
}
|
|
}
|
|
|
|
|
|
-function handleValidateButtonClick() {
|
|
|
|
- // console.log(model);
|
|
|
|
|
|
+async function handleValidateButtonClick() {
|
|
|
|
+ model.startTime = formatTimestamp(dateValue.value + startTime.value);
|
|
|
|
+ model.endTime = formatTimestamp(dateValue.value + endTime.value);
|
|
|
|
+ model.week = new Date(dateValue.value + startTime.value).getDay() + 1;
|
|
|
|
+ const res = await addSchedule(repeatTime.value, model);
|
|
|
|
+ if (!res.status && res.msg !== null) {
|
|
|
|
+ return window.$message?.error(res.msg);
|
|
|
|
+ }
|
|
|
|
+ pageState.value = !pageState.value;
|
|
|
|
+ return window.$message?.success('操作成功!');
|
|
}
|
|
}
|
|
|
|
|
|
function loadData() {
|
|
function loadData() {
|
|
@@ -187,7 +249,63 @@ function loadData() {
|
|
return r;
|
|
return r;
|
|
});
|
|
});
|
|
});
|
|
});
|
|
|
|
+ queryClassAll().then(respone => {
|
|
|
|
+ respone.data?.map(r => {
|
|
|
|
+ groupList.value.push({
|
|
|
|
+ label: r.name,
|
|
|
|
+ value: r.id
|
|
|
|
+ });
|
|
|
|
+ return r;
|
|
|
|
+ });
|
|
|
|
+ });
|
|
|
|
+
|
|
|
|
+ queryClassRoomList(1, 100, {}).then(respone => {
|
|
|
|
+ respone.data?.map(r => {
|
|
|
|
+ classRoomList.value.push({
|
|
|
|
+ label: r.name,
|
|
|
|
+ value: r.id
|
|
|
|
+ });
|
|
|
|
+ return r;
|
|
|
|
+ });
|
|
|
|
+ if (classId) {
|
|
|
|
+ model.classId = Number(classId);
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+ querySchedule(1, 100, {}).then(response => {
|
|
|
|
+ response.data?.data.forEach(r => {
|
|
|
|
+ const time = r.startTime?.split(' ').pop();
|
|
|
|
+ const week = r.week;
|
|
|
|
+ if (week && time && r.endTime && r.startTime && scheduleList.value[week][time].empty) {
|
|
|
|
+ r.colspan = new Date(r.endTime).getHours() - new Date(r.startTime).getHours() + 1;
|
|
|
|
+ r.empty = false;
|
|
|
|
+ r.break = false;
|
|
|
|
+ scheduleList.value[week][time] = r;
|
|
|
|
+ let n = 1;
|
|
|
|
+ while (n < r.colspan) {
|
|
|
|
+ const index = timeKey.value.indexOf(time) + n;
|
|
|
|
+ scheduleList.value[week][timeKey.value[index]] = { empty: false, break: true };
|
|
|
|
+ n += 1;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+ });
|
|
}
|
|
}
|
|
|
|
+
|
|
loadData();
|
|
loadData();
|
|
</script>
|
|
</script>
|
|
-<style scoped></style>
|
|
|
|
|
|
+<style scoped>
|
|
|
|
+th {
|
|
|
|
+ color: rgb(141, 141, 141);
|
|
|
|
+ font-size: calc(var(--baseSize, 14px) * 1.1);
|
|
|
|
+ font-weight: bold;
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+th,
|
|
|
|
+td {
|
|
|
|
+ padding: 16px 12px;
|
|
|
|
+ font-size: var(--baseSize, 14px);
|
|
|
|
+ outline: 1px solid rgb(226, 226, 226);
|
|
|
|
+ text-align: center;
|
|
|
|
+ color: rgb(99, 99, 99);
|
|
|
|
+}
|
|
|
|
+</style>
|