|
@@ -1,73 +1,132 @@
|
|
|
<template>
|
|
|
- <n-data-table :columns="columns" :data="data" :render-cell="renderCell" />
|
|
|
+ <div>
|
|
|
+ <n-date-picker v-model:value="range" :default-calendar-start-time="1686067200000" @update:value="upDate" type="daterange" />
|
|
|
+ </div>
|
|
|
+ <div>
|
|
|
+ <!-- 课表 -->
|
|
|
+ <table>
|
|
|
+ <thead>
|
|
|
+ <tr>
|
|
|
+ <th></th>
|
|
|
+ <th v-for="day in days">{{ day }}</th>
|
|
|
+ </tr>
|
|
|
+ </thead>
|
|
|
+ <tbody>
|
|
|
+ <tr v-for="timeSlot in timeSlots" :key="timeSlot">
|
|
|
+ <td>{{ timeSlot }}</td>
|
|
|
+ <td v-for="day in days" :key="day">
|
|
|
+ <!-- <input type="text" v-model="schedule[day][timeSlot]"> -->
|
|
|
+ {{ }}
|
|
|
+ </td>
|
|
|
+ </tr>
|
|
|
+ </tbody>
|
|
|
+ </table>
|
|
|
+ <button @click="saveSchedule">保存课表</button>
|
|
|
+ </div>
|
|
|
</template>
|
|
|
|
|
|
<script lang="ts">
|
|
|
-import { defineComponent, h } from 'vue'
|
|
|
-import { NText } from 'naive-ui'
|
|
|
-import type { DataTableColumns } from 'naive-ui'
|
|
|
-
|
|
|
-type Song = {
|
|
|
- no: number
|
|
|
- note: string
|
|
|
-}
|
|
|
+import { ref, onMounted } from 'vue';
|
|
|
+import { query_1 } from '~/src/service/api/curriculum'
|
|
|
+export default {
|
|
|
+ setup() {
|
|
|
+ const days = ['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday'];
|
|
|
+ const timeSlots = ['起始时间', '结束时间', '授课类别', '授课内容', '创建时间', '修改时间', '状态'];
|
|
|
|
|
|
-const createColumns = (): DataTableColumns<Song> => {
|
|
|
- return [
|
|
|
- {
|
|
|
- title: '星期',
|
|
|
- key: 'no',
|
|
|
- width: 120,
|
|
|
- render: (_, index) => {
|
|
|
- return `星期 ${index + 1}`
|
|
|
- }
|
|
|
- },
|
|
|
- {
|
|
|
- title: '起始时间',
|
|
|
- key: 'note'
|
|
|
- }, {
|
|
|
- title: '结束时间',
|
|
|
- key: 'ad'
|
|
|
- }, {
|
|
|
- title: '授课类别',
|
|
|
- key: 'note'
|
|
|
- }, {
|
|
|
- title: '授课内容',
|
|
|
- key: 'note'
|
|
|
- }, {
|
|
|
- title: '创建时间',
|
|
|
- key: 'note'
|
|
|
- }, {
|
|
|
- title: '修改时间',
|
|
|
- key: 'note'
|
|
|
- }, {
|
|
|
- title: '状态',
|
|
|
- key: 'note'
|
|
|
+ const saveWeekAndTime = ref([]);
|
|
|
+ const schedule = ref({
|
|
|
+ Monday: {},
|
|
|
+ Tuesday: {},
|
|
|
+ Wednesday: {},
|
|
|
+ Thursday: {},
|
|
|
+ Friday: {},
|
|
|
+ });
|
|
|
+ let range = ref<[number, number]>();
|
|
|
+ let queryTable = {
|
|
|
+ id: 0,
|
|
|
+ week: 0,
|
|
|
+ startTime: "",
|
|
|
+ endTime: "",
|
|
|
+ roomId: 0,
|
|
|
+ classId: 0,
|
|
|
+ assistantId: 0,
|
|
|
+ teacherId: 0,
|
|
|
+ categoryId: 0,
|
|
|
+ subjectsId: 0,
|
|
|
+ createTime: "",
|
|
|
+ modifyTime: "",
|
|
|
+ createUid: 0,
|
|
|
+ disabled: ""
|
|
|
}
|
|
|
- ]
|
|
|
-}
|
|
|
+ //点击日期确定触发事件
|
|
|
+ async function upDate() {
|
|
|
|
|
|
-const data: Song[] = [
|
|
|
- { no: 3, note: '23' },
|
|
|
- { no: 4, note: '' },
|
|
|
- { no: 12, note: '' },
|
|
|
- { no: 10, note: '' },
|
|
|
- { no: 19, note: '' }
|
|
|
-]
|
|
|
+ const startDate = range.value[0];
|
|
|
+ const endDate = range.value[1];
|
|
|
+ if (startDate && endDate) {
|
|
|
+ const diffInMilliseconds = Math.abs(endDate - startDate);
|
|
|
+ const diffInDays = Math.ceil(diffInMilliseconds / (1000 * 60 * 60 * 24));
|
|
|
|
|
|
-export default defineComponent({
|
|
|
- setup() {
|
|
|
- return {
|
|
|
- data,
|
|
|
- columns: createColumns(),
|
|
|
- pagination: false as const,
|
|
|
- renderCell: (value: string | number) => {
|
|
|
- if (!value) {
|
|
|
- return h(NText, { depth: 3 }, { default: () => '未填写' })
|
|
|
+ if (diffInDays > 6) {
|
|
|
+ range.value = [null, null]; // 清空日期范围
|
|
|
+ // console.log(222);
|
|
|
+ alert(111);
|
|
|
}
|
|
|
- return value
|
|
|
}
|
|
|
- }
|
|
|
- }
|
|
|
-})
|
|
|
-</script>
|
|
|
+ var timestr = new Date(parseInt(startDate));
|
|
|
+ var year = timestr.getFullYear();
|
|
|
+ var month = timestr.getMonth() + 1;
|
|
|
+ var date = timestr.getDate();
|
|
|
+ var hour = timestr.getHours();
|
|
|
+ var minute = timestr.getMinutes();
|
|
|
+ var second = timestr.getSeconds();
|
|
|
+ queryTable.startTime = year + "-" + month + "-" + date + " " + hour + ":" + minute + ":" + second;
|
|
|
+ console.log(queryTable);
|
|
|
+ query_1(1, 10, queryTable).then(r => {
|
|
|
+ // console.log(r.data.data);
|
|
|
+
|
|
|
+ let x=r.data.data;
|
|
|
+ x.map(r=>{
|
|
|
+ console.log(r);
|
|
|
+
|
|
|
+ })
|
|
|
+
|
|
|
+ })
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ onMounted(async () => {
|
|
|
+ // console.log(new Date('2023-6-7').getTime());
|
|
|
+
|
|
|
+
|
|
|
+ });
|
|
|
+
|
|
|
+ const saveSchedule = () => {
|
|
|
+ // 在这里处理保存课表的逻辑
|
|
|
+
|
|
|
+ };
|
|
|
+
|
|
|
+ return {
|
|
|
+ upDate,
|
|
|
+ range,
|
|
|
+ onMounted,
|
|
|
+ days,
|
|
|
+ timeSlots,
|
|
|
+ schedule,
|
|
|
+ saveSchedule,
|
|
|
+ };
|
|
|
+ },
|
|
|
+ };
|
|
|
+</script>
|
|
|
+
|
|
|
+<style>
|
|
|
+table {
|
|
|
+ border-collapse: collapse;
|
|
|
+}
|
|
|
+
|
|
|
+td,
|
|
|
+th {
|
|
|
+ border: 1px solid #ccc;
|
|
|
+ padding: 8px;
|
|
|
+}
|
|
|
+</style>
|