|
@@ -1,106 +1,294 @@
|
|
|
<template>
|
|
|
- <!-- 学期多选框 -->
|
|
|
- <el-select
|
|
|
- v-model="selectedTerms"
|
|
|
- multiple
|
|
|
- :placeholder="select"
|
|
|
- size="large"
|
|
|
- @change="changeTerm"
|
|
|
- style="width: 240px; margin-left: 1300px; margin-top: 10px"
|
|
|
- >
|
|
|
- <el-option
|
|
|
- v-for="(term, index) in terms"
|
|
|
- :key="index"
|
|
|
- :label="term.label"
|
|
|
- :value="index"
|
|
|
- ></el-option>
|
|
|
- </el-select>
|
|
|
- <FullCalendar :options="calendarOptions" class="calendar" id="calendar" />
|
|
|
-
|
|
|
- <!-- 备注修改框 -->
|
|
|
- <el-dialog title="添加备注" center v-model="Visible">
|
|
|
- <el-form :model="form" label-width="auto" style="max-width: 600px">
|
|
|
- <el-form-item label="备注名称">
|
|
|
- <el-input v-model="form.name" />
|
|
|
- </el-form-item>
|
|
|
- <el-form-item label="时间">
|
|
|
- <el-date-picker
|
|
|
- :span="11"
|
|
|
- v-model="form.date"
|
|
|
- type="daterange"
|
|
|
- range-separator="To"
|
|
|
- start-placeholder="开始日期"
|
|
|
- end-placeholder="结束"
|
|
|
- style="width: 100%"
|
|
|
- format="YYYY/MM/DD"
|
|
|
- value-format="YYYY-MM-DD"
|
|
|
- />
|
|
|
- <!--
|
|
|
- <el-col>
|
|
|
- <el-date-picker
|
|
|
- v-model="form.date1"
|
|
|
- type="date"
|
|
|
- placeholder="日期"
|
|
|
- style="width: 100%"
|
|
|
- format="YYYY/MM/DD"
|
|
|
- value-format="YYYY-MM-DD"
|
|
|
+ <div class="main">
|
|
|
+ <!-- 学期多选框 -->
|
|
|
+ <div class="content">
|
|
|
+ <div class="term">
|
|
|
+ <div class="term_content">
|
|
|
+ <el-select
|
|
|
+ v-if="tmp"
|
|
|
+ v-model="selectedTermIndex"
|
|
|
+ :placeholder="select"
|
|
|
+ size="large"
|
|
|
+ @change="handleTermSelection"
|
|
|
+ style="width: 240px"
|
|
|
+ :disabled="isYearSelecting"
|
|
|
+ >
|
|
|
+ <el-option
|
|
|
+ v-for="(term, index) in terms"
|
|
|
+ :key="index"
|
|
|
+ :label="term.label"
|
|
|
+ :value="index"
|
|
|
+ ></el-option>
|
|
|
+ </el-select>
|
|
|
+ <el-button type="primary" @click="showActionsDialog('term')"
|
|
|
+ >修改学期</el-button
|
|
|
+ >
|
|
|
+ </div>
|
|
|
+
|
|
|
+ <div class="term_content">
|
|
|
+ <el-select
|
|
|
+ v-if="yearTmp"
|
|
|
+ v-model="selectedAcademicYear"
|
|
|
+ :placeholder="selectYear"
|
|
|
+ size="large"
|
|
|
+ @change="handleSelectionYear"
|
|
|
+ style="width: 240px; margin-top: 10px"
|
|
|
+ :disabled="isTermSelecting"
|
|
|
+ >
|
|
|
+ <el-option
|
|
|
+ v-for="(year, index) in academicYears"
|
|
|
+ :key="index"
|
|
|
+ :label="year.label"
|
|
|
+ :value="index"
|
|
|
+ ></el-option>
|
|
|
+ </el-select>
|
|
|
+
|
|
|
+ <!-- 确保调用正确的对话框显示方法 -->
|
|
|
+ <el-button type="primary" @click="showAcademicYearActionsDialog"
|
|
|
+ >修改学年</el-button
|
|
|
+ >
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+
|
|
|
+ <el-dialog title="学期管理" v-model="actionsVisible" width="30%">
|
|
|
+ <!-- 操作选项 -->
|
|
|
+ <el-radio-group v-model="selectedAction" @change="onActionSelected">
|
|
|
+ <el-radio :value="'add'">添加学期</el-radio>
|
|
|
+ <el-radio :value="'edit'">更改学期</el-radio>
|
|
|
+ <el-radio :value="'delete'">删除学期</el-radio>
|
|
|
+ </el-radio-group>
|
|
|
+
|
|
|
+ <!-- 添加/编辑表单 -->
|
|
|
+ <el-form
|
|
|
+ v-if="selectedAction !== 'delete'"
|
|
|
+ :model="termForm"
|
|
|
+ label-width="80px"
|
|
|
+ >
|
|
|
+ <el-form-item label="学期名称">
|
|
|
+ <el-input v-model="termForm.label" />
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="开始日期">
|
|
|
+ <el-date-picker
|
|
|
+ v-model="termForm.startDate"
|
|
|
+ type="date"
|
|
|
+ placeholder="选择开始日期"
|
|
|
+ value-format="YYYY-MM-DD"
|
|
|
+ />
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="结束日期">
|
|
|
+ <el-date-picker
|
|
|
+ v-model="termForm.endDate"
|
|
|
+ type="date"
|
|
|
+ placeholder="选择结束日期"
|
|
|
+ value-format="YYYY-MM-DD"
|
|
|
+ />
|
|
|
+ </el-form-item>
|
|
|
+ </el-form>
|
|
|
+
|
|
|
+ <!-- 仅在编辑时显示学期选择器 -->
|
|
|
+ <el-select
|
|
|
+ v-if="selectedAction === 'edit'"
|
|
|
+ v-model="selectedTermIndex"
|
|
|
+ placeholder="请选择学期"
|
|
|
+ @change="loadTermDetails"
|
|
|
+ >
|
|
|
+ <el-option
|
|
|
+ v-for="(term, index) in terms"
|
|
|
+ :key="index"
|
|
|
+ :label="term.label"
|
|
|
+ :value="index"
|
|
|
/>
|
|
|
- </el-col>
|
|
|
-
|
|
|
- <el-col>
|
|
|
- <el-time-select
|
|
|
- v-model="form.date2"
|
|
|
- placeholder="详细时刻"
|
|
|
- style="width: 100%"
|
|
|
- start="00:00"
|
|
|
- step="01:00"
|
|
|
- end="24:00"
|
|
|
+ </el-select>
|
|
|
+
|
|
|
+ <template #footer>
|
|
|
+ <span class="dialog-footer">
|
|
|
+ <el-button @click="actionsVisible = false">取消</el-button>
|
|
|
+ <el-button
|
|
|
+ type="primary"
|
|
|
+ :disabled="!canExecuteAction"
|
|
|
+ @click="executeAction"
|
|
|
+ >{{ getActionButtonText }}</el-button
|
|
|
+ >
|
|
|
+ </span>
|
|
|
+ </template>
|
|
|
+ </el-dialog>
|
|
|
+
|
|
|
+ <!-- 学年修改框 -->
|
|
|
+ <el-dialog
|
|
|
+ title="学年管理"
|
|
|
+ v-model="academicYearActionsVisible"
|
|
|
+ width="30%"
|
|
|
+ >
|
|
|
+ <el-radio-group
|
|
|
+ v-model="selectedAcademicAction"
|
|
|
+ @change="onAcademicActionSelected"
|
|
|
+ >
|
|
|
+ <el-radio :value="'add'">添加学年</el-radio>
|
|
|
+ <el-radio :value="'edit'">更改学年</el-radio>
|
|
|
+ <el-radio :value="'delete'">删除学年</el-radio>
|
|
|
+ </el-radio-group>
|
|
|
+
|
|
|
+ <el-form
|
|
|
+ v-if="selectedAcademicAction !== 'delete'"
|
|
|
+ :model="academicYearForm"
|
|
|
+ label-width="80px"
|
|
|
+ >
|
|
|
+ <el-form-item label="学年名称">
|
|
|
+ <el-input v-model="academicYearForm.name" />
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="开始日期">
|
|
|
+ <el-date-picker
|
|
|
+ v-model="academicYearForm.startDate"
|
|
|
+ type="date"
|
|
|
+ placeholder="选择开始日期"
|
|
|
+ value-format="YYYY-MM-DD"
|
|
|
+ />
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="结束日期">
|
|
|
+ <el-date-picker
|
|
|
+ v-model="academicYearForm.endDate"
|
|
|
+ type="date"
|
|
|
+ placeholder="选择结束日期"
|
|
|
+ value-format="YYYY-MM-DD"
|
|
|
+ />
|
|
|
+ </el-form-item>
|
|
|
+ </el-form>
|
|
|
+
|
|
|
+ <!-- 仅在编辑时显示学年选择器 -->
|
|
|
+ <el-select
|
|
|
+ v-if="selectedAcademicAction === 'edit'"
|
|
|
+ v-model="selectedAcademicYearIndex"
|
|
|
+ placeholder="请选择学年"
|
|
|
+ @change="loadAcademicYearDetails"
|
|
|
+ >
|
|
|
+ <el-option
|
|
|
+ v-for="(year, index) in academicYears"
|
|
|
+ :key="index"
|
|
|
+ :label="year.label"
|
|
|
+ :value="index"
|
|
|
/>
|
|
|
- </el-col> -->
|
|
|
- </el-form-item>
|
|
|
-
|
|
|
- <el-upload
|
|
|
- class="upload-demo"
|
|
|
- ref="picture"
|
|
|
- drag
|
|
|
- action="/api/uploads"
|
|
|
- accept=".png,.jpe,.jpeg"
|
|
|
- :on-success="uploadSuccess"
|
|
|
- :limit="1"
|
|
|
- :on-exceed="exceedRange"
|
|
|
+ </el-select>
|
|
|
+
|
|
|
+ <template #footer>
|
|
|
+ <span class="dialog-footer">
|
|
|
+ <el-button @click="academicYearActionsVisible = false"
|
|
|
+ >取消</el-button
|
|
|
+ >
|
|
|
+ <el-button
|
|
|
+ type="primary"
|
|
|
+ :disabled="!canExecuteAcademicAction"
|
|
|
+ @click="executeAcademicAction"
|
|
|
+ >{{ getAcademicActionButtonText }}</el-button
|
|
|
+ >
|
|
|
+ </span>
|
|
|
+ </template>
|
|
|
+ </el-dialog>
|
|
|
+
|
|
|
+ <FullCalendar :options="calendarOptions" class="calendar" id="calendar" />
|
|
|
+
|
|
|
+ <!-- 备注修改框 -->
|
|
|
+ <el-dialog title="添加备注" center v-model="Visible" :show-close="false">
|
|
|
+ <el-form :model="form" label-width="auto" style="max-width: 600px">
|
|
|
+ <el-form-item label="备注名称">
|
|
|
+ <el-input v-model="form.name" />
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="时间">
|
|
|
+ <el-date-picker
|
|
|
+ :span="11"
|
|
|
+ v-model="form.date"
|
|
|
+ type="daterange"
|
|
|
+ range-separator="To"
|
|
|
+ start-placeholder="开始日期"
|
|
|
+ end-placeholder="结束"
|
|
|
+ style="width: 100%"
|
|
|
+ format="YYYY/MM/DD"
|
|
|
+ value-format="YYYY-MM-DD"
|
|
|
+ />
|
|
|
+ </el-form-item>
|
|
|
+
|
|
|
+ <el-upload
|
|
|
+ class="upload-demo"
|
|
|
+ ref="picture"
|
|
|
+ drag
|
|
|
+ action="/api/uploads"
|
|
|
+ accept=".png,.jpe,.jpeg"
|
|
|
+ :on-success="uploadSuccess"
|
|
|
+ :limit="1"
|
|
|
+ :on-exceed="exceedRange"
|
|
|
+ >
|
|
|
+ <i class="el-icon-upload"></i>
|
|
|
+ <div class="el-upload__text"><em>可选</em></div>
|
|
|
+ <div class="el-upload__text">
|
|
|
+ 将文件拖到此处,或<em>点击上传</em>
|
|
|
+ </div>
|
|
|
+ <div class="el-upload__tip" slot="tip">
|
|
|
+ 只能上传jpg/png/jpeg文件,且不超过500kb,最多只能上传一张图片
|
|
|
+ </div>
|
|
|
+ </el-upload>
|
|
|
+ <el-form-item label="详细信息">
|
|
|
+ <el-input v-model="form.desc" type="textarea" />
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item>
|
|
|
+ <el-button type="primary" @click="confirm">确定</el-button>
|
|
|
+ <el-button @click="cancel">取消</el-button>
|
|
|
+ </el-form-item>
|
|
|
+ </el-form>
|
|
|
+ </el-dialog>
|
|
|
+
|
|
|
+ <!-- 对备注进行操作 -->
|
|
|
+ <el-dialog
|
|
|
+ title="备注信息修改"
|
|
|
+ center
|
|
|
+ v-model="changeInfo"
|
|
|
+ :show-close="false"
|
|
|
>
|
|
|
- <i class="el-icon-upload"></i>
|
|
|
- <div class="el-upload__text"><em>可选</em></div>
|
|
|
- <div class="el-upload__text">将文件拖到此处,或<em>点击上传</em></div>
|
|
|
- <div class="el-upload__tip" slot="tip">
|
|
|
- 只能上传jpg/png/jpeg文件,且不超过500kb,最多只能上传一张图片
|
|
|
- </div>
|
|
|
- </el-upload>
|
|
|
- <el-form-item label="详细信息">
|
|
|
- <el-input v-model="form.desc" type="textarea" />
|
|
|
- </el-form-item>
|
|
|
- <el-form-item>
|
|
|
- <el-button type="primary" @click="confirm">确定</el-button>
|
|
|
- <el-button @click="cancel">取消</el-button>
|
|
|
- </el-form-item>
|
|
|
- </el-form>
|
|
|
- </el-dialog>
|
|
|
-
|
|
|
- <!-- 对备注进行操作 -->
|
|
|
- <el-dialog title="备注信息修改" center v-model="changeInfo">
|
|
|
- <el-form-item label="操作">
|
|
|
- <el-radio-group v-model="operateSelect">
|
|
|
- <el-radio value="delete">删除备注</el-radio>
|
|
|
- <el-radio value="edit">修改备注</el-radio>
|
|
|
- </el-radio-group>
|
|
|
- </el-form-item>
|
|
|
- <el-form-item>
|
|
|
- <el-button type="primary" @click="operate(this.operateSelect)"
|
|
|
- >确定</el-button
|
|
|
+ <el-form-item label="操作">
|
|
|
+ <el-radio-group v-model="operateSelect">
|
|
|
+ <el-radio value="delete">删除备注</el-radio>
|
|
|
+ <el-radio value="edit">修改备注</el-radio>
|
|
|
+ <el-radio value="copy">复制备注</el-radio>
|
|
|
+ </el-radio-group>
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item>
|
|
|
+ <el-button type="primary" @click="operate(this.operateSelect)"
|
|
|
+ >确定</el-button
|
|
|
+ >
|
|
|
+ <el-button @click="operateCancel">取消</el-button>
|
|
|
+ </el-form-item>
|
|
|
+ </el-dialog>
|
|
|
+
|
|
|
+ <!-- 复制备注对话框 -->
|
|
|
+ <el-dialog
|
|
|
+ title="复制备注至指定日期"
|
|
|
+ center
|
|
|
+ v-model="chooseCopy"
|
|
|
+ :show-close="false"
|
|
|
>
|
|
|
- <el-button @click="operateCancel">取消</el-button>
|
|
|
- </el-form-item>
|
|
|
- </el-dialog>
|
|
|
+ <el-form :model="form" label-width="auto" style="max-width: 600px">
|
|
|
+ <el-form-item label="备注名称">
|
|
|
+ <el-input v-model="form.name" />
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="时间">
|
|
|
+ <el-date-picker
|
|
|
+ :span="11"
|
|
|
+ v-model="form.date"
|
|
|
+ type="daterange"
|
|
|
+ range-separator="To"
|
|
|
+ start-placeholder="开始日期"
|
|
|
+ end-placeholder="结束"
|
|
|
+ style="width: 100%"
|
|
|
+ format="YYYY/MM/DD"
|
|
|
+ value-format="YYYY-MM-DD"
|
|
|
+ />
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item>
|
|
|
+ <el-button type="primary" @click="certainCopy">确定</el-button>
|
|
|
+ <el-button @click="clearForm, (chooseCopy = false)">取消</el-button>
|
|
|
+ </el-form-item>
|
|
|
+ </el-form>
|
|
|
+ </el-dialog>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
</template>
|
|
|
<script>
|
|
|
import FullCalendar from "@fullcalendar/vue3";
|
|
@@ -133,6 +321,52 @@ export default {
|
|
|
},
|
|
|
data() {
|
|
|
return {
|
|
|
+ isTermSelecting: false, // 标记学期选择器是否在操作中
|
|
|
+ isYearSelecting: false, // 标记学年选择器是否在操作中
|
|
|
+ selectedAcademicYear: "", // 确保初始值为空字符串
|
|
|
+ // 学年修改属性
|
|
|
+ yearTmp: true,
|
|
|
+ selectYear: "请选择学年",
|
|
|
+
|
|
|
+ academicYears: [
|
|
|
+ // 可供选择的学年选项
|
|
|
+ {
|
|
|
+ label: "2022-2023学年",
|
|
|
+ startDate: "2022-09-01",
|
|
|
+ endDate: "2023-08-31",
|
|
|
+ },
|
|
|
+ {
|
|
|
+ label: "2023-2024学年",
|
|
|
+ startDate: "2023-09-01",
|
|
|
+ endDate: "2024-08-31",
|
|
|
+ },
|
|
|
+ {
|
|
|
+ label: "2024-2025学年",
|
|
|
+ startDate: "2024-09-01",
|
|
|
+ endDate: "2025-08-31",
|
|
|
+ },
|
|
|
+ ],
|
|
|
+ academicYearActionsVisible: false, // 控制学年对话框显示
|
|
|
+ selectedAcademicAction: "", // 当前选择的操作类型
|
|
|
+ academicYearForm: {
|
|
|
+ name: "",
|
|
|
+ startDate: "",
|
|
|
+ endDate: "",
|
|
|
+ },
|
|
|
+ selectedAcademicYearIndex: null, // 选中学年的索引
|
|
|
+ canExecuteAcademicAction: false, // 控制操作按钮是否可用
|
|
|
+
|
|
|
+ // 学期修改属性
|
|
|
+ tmp: true,
|
|
|
+ actionsVisible: false,
|
|
|
+ selectedAction: "",
|
|
|
+ termForm: {
|
|
|
+ label: "",
|
|
|
+ startDate: "",
|
|
|
+ endDate: "",
|
|
|
+ },
|
|
|
+ selectedTermIndex: null,
|
|
|
+
|
|
|
// 多选框数据
|
|
|
selectedTerms: [], // 用于存储选中的学期索引数组
|
|
|
select: "请选择学期",
|
|
@@ -181,6 +415,7 @@ export default {
|
|
|
desc: "",
|
|
|
url: "",
|
|
|
},
|
|
|
+ chooseCopy: false, //是否显示复制对话框
|
|
|
|
|
|
// 日历数据
|
|
|
calendarOptions: {
|
|
@@ -200,7 +435,7 @@ export default {
|
|
|
editable: true, // 确定是否可以修改日历上的事件。
|
|
|
dayMaxEventRows: 2, // 允许事件堆叠,但不超过设定的行数
|
|
|
navLinks: true, // 可以单击日/周名称来导航视图
|
|
|
- timeZone: 'none' , //时区关闭
|
|
|
+ timeZone: "none", //时区关闭
|
|
|
|
|
|
buttonText: {
|
|
|
prev: "上一页",
|
|
@@ -254,38 +489,180 @@ export default {
|
|
|
aspectRatio: 1.2, //宽高比
|
|
|
},
|
|
|
validRange: {
|
|
|
- start: "2022-08-26",
|
|
|
- end: "2023-02-16",
|
|
|
+ start: "2020-08-26",
|
|
|
+ end: "2025-02-16",
|
|
|
},
|
|
|
};
|
|
|
},
|
|
|
|
|
|
+ // 判断 学期学年修改的确认按钮
|
|
|
+ computed: {
|
|
|
+ canExecuteAction() {
|
|
|
+ return (
|
|
|
+ this.selectedAction !== "" &&
|
|
|
+ (this.selectedAction !== "edit" || this.selectedTermIndex !== null)
|
|
|
+ );
|
|
|
+ },
|
|
|
+ getActionButtonText() {
|
|
|
+ return this.selectedAction === "delete" ? "删除" : "确认";
|
|
|
+ },
|
|
|
+ getAcademicActionButtonText() {
|
|
|
+ if (this.selectedAcademicAction === "add") return "添加";
|
|
|
+ if (this.selectedAcademicAction === "edit") return "保存更改";
|
|
|
+ if (this.selectedAcademicAction === "delete") return "删除";
|
|
|
+ else return "确认";
|
|
|
+ },
|
|
|
+ },
|
|
|
methods: {
|
|
|
- eventChangeEdit() {
|
|
|
- this.calendarOptions.events[0].editable = true
|
|
|
- console.log(this.calendarOptions.events);
|
|
|
+ // 修改学期
|
|
|
+ showActionsDialog(dialogType) {
|
|
|
+ this.actionsVisible = true;
|
|
|
+ this.selectedAction = ""; // 清空之前的选择
|
|
|
+ if (dialogType === "term") {
|
|
|
+ this.$nextTick(() => {
|
|
|
+ // 确保dialog完全打开后再执行,如果有必要的话
|
|
|
+ });
|
|
|
+ }
|
|
|
+ },
|
|
|
+ onActionSelected() {
|
|
|
+ // 重置表单
|
|
|
+ if (this.selectedAction === "add") {
|
|
|
+ this.termForm = { label: "", startDate: "", endDate: "" };
|
|
|
+ } else if (this.selectedAction === "edit") {
|
|
|
+ this.selectedTermIndex = null; // 重置学期选择
|
|
|
+ }
|
|
|
+ },
|
|
|
+ loadTermDetails(index) {
|
|
|
+ if (index !== null) {
|
|
|
+ const selectedTerm = this.terms[index];
|
|
|
+ this.termForm = { ...selectedTerm };
|
|
|
+ }
|
|
|
+ },
|
|
|
+ executeAction() {
|
|
|
+ if (this.selectedAction === "add") {
|
|
|
+ this.addTerm();
|
|
|
+ } else if (this.selectedAction === "edit") {
|
|
|
+ this.editTerm();
|
|
|
+ } else if (this.selectedAction === "delete") {
|
|
|
+ this.deleteTerm();
|
|
|
+ }
|
|
|
+ this.actionsVisible = false;
|
|
|
+ this.selectedAction = ""; // 重置操作
|
|
|
+ },
|
|
|
+ addTerm() {
|
|
|
+ console.log("Adding term:", this.termForm);
|
|
|
+ // 确保使用termForm.label作为label,如果没有则可能需要处理错误情况
|
|
|
+ if (this.termForm.label == "" || this.termForm.label == null) {
|
|
|
+ ElMessage.error("名字不能为空");
|
|
|
+ return; // 或者提示用户名称是必填项
|
|
|
+ } else {
|
|
|
+ this.terms.push({
|
|
|
+ label: this.termForm.label, // 使用用户输入的名称
|
|
|
+ startDate: this.termForm.startDate,
|
|
|
+ endDate: this.termForm.endDate,
|
|
|
+ });
|
|
|
+ this.select = this.termForm.label;
|
|
|
+ ElMessage.success("添加成功");
|
|
|
+ this.calendarOptions.validRange = {
|
|
|
+ start: this.termForm.startDate,
|
|
|
+ end: this.termForm.endDate,
|
|
|
+ };
|
|
|
+
|
|
|
+ // 清空表单以便下一次输入
|
|
|
+ this.termForm.label = "";
|
|
|
+ this.termForm.startDate = "";
|
|
|
+ this.termForm.endDate = "";
|
|
|
+ }
|
|
|
+ },
|
|
|
+ editTerm() {
|
|
|
+ // 编辑学期逻辑
|
|
|
+ if (this.selectedTermIndex !== null) {
|
|
|
+ this.terms[this.selectedTermIndex] = {
|
|
|
+ startDate: this.termForm.startDate,
|
|
|
+ endDate: this.termForm.startDate,
|
|
|
+ label: this.name,
|
|
|
+ };
|
|
|
+ this.terms[this.selectedTermIndex] = { ...this.termForm };
|
|
|
+
|
|
|
+ this.calendarOptions.validRange = {
|
|
|
+ start: this.termForm.startDate,
|
|
|
+ end: this.termForm.endDate,
|
|
|
+ };
|
|
|
+ console.log(this.calendarOptions.validRange);
|
|
|
+ ElMessage.success("学期编辑成功");
|
|
|
+ } else {
|
|
|
+ ElMessage.error("无法编辑空学期");
|
|
|
+ }
|
|
|
+ },
|
|
|
+ handleTermSelection(index) {
|
|
|
+ if (index !== null && this.terms[index]) {
|
|
|
+ this.selectedTermIndex = index;
|
|
|
+ const selectedTerm = this.terms[index];
|
|
|
+ this.calendarOptions.validRange = {
|
|
|
+ start: selectedTerm.startDate + " 00:00:00",
|
|
|
+ end: selectedTerm.endDate + " 23:59:59",
|
|
|
+ };
|
|
|
+ // 如果需要,可以在这里添加其他逻辑,比如加载学期详情等
|
|
|
+ this.isTermSelecting = true;
|
|
|
+ this.isYearSelecting = false;
|
|
|
+ }
|
|
|
+ },
|
|
|
+
|
|
|
+ deleteTerm() {
|
|
|
+ if (
|
|
|
+ this.selectedTermIndex !== null &&
|
|
|
+ this.selectedTermIndex >= 0 &&
|
|
|
+ this.selectedTermIndex < this.terms.length
|
|
|
+ ) {
|
|
|
+ this.$nextTick(() => {
|
|
|
+ this.terms.splice(this.selectedTermIndex, 1);
|
|
|
+ // 重置selectedTermIndex为无效值
|
|
|
+ this.selectedTermIndex = "";
|
|
|
+ // 更新占位符文本
|
|
|
+ this.select = "请选择学期";
|
|
|
+ this.tmp = false; // 如果tmp用于控制显示,确保其值更新
|
|
|
+ this.tmp = true;
|
|
|
+ });
|
|
|
+ ElMessage.success("学期删除成功");
|
|
|
+ console.log("删除成功", this.select);
|
|
|
+ this.resetToDefaultTermRange();
|
|
|
+ } else {
|
|
|
+ ElMessage.error("请选择具体学期,无法删除空学期");
|
|
|
+ }
|
|
|
+ this.isTermSelecting = false;
|
|
|
+ this.isYearSelecting = false;
|
|
|
+ },
|
|
|
+ resetToDefaultTermRange() {
|
|
|
+ console.log("重置", this.placeholder);
|
|
|
+ this.calendarOptions.validRange = {
|
|
|
+ start: "2020-08-26",
|
|
|
+ end: "2025-02-16",
|
|
|
+ };
|
|
|
+ this.select = "请选择";
|
|
|
+ if (this.calendar) {
|
|
|
+ this.calendar.setOption("validRange", this.calendarOptions.validRange);
|
|
|
+
|
|
|
+ this.calendar.render();
|
|
|
+ }
|
|
|
},
|
|
|
+
|
|
|
// 多选框变换
|
|
|
changeTerm() {
|
|
|
let minStartDate = null;
|
|
|
let maxEndDate = null;
|
|
|
|
|
|
- // 遍历选中的学期
|
|
|
- this.selectedTerms.forEach((index) => {
|
|
|
- const term = this.terms[index];
|
|
|
- if (!term) return; // 确保term存在
|
|
|
-
|
|
|
- // 更新最小开始日期和最大结束日期
|
|
|
- if (
|
|
|
- !minStartDate ||
|
|
|
- new Date(term.startDate) < new Date(minStartDate)
|
|
|
- ) {
|
|
|
- minStartDate = term.startDate;
|
|
|
- }
|
|
|
- if (!maxEndDate || new Date(term.endDate) > new Date(maxEndDate)) {
|
|
|
- maxEndDate = term.endDate;
|
|
|
- }
|
|
|
- });
|
|
|
+ console.log(this.selectedTerms);
|
|
|
+ console.log(this.terms);
|
|
|
+
|
|
|
+ const term = this.terms[this.selectedTerms];
|
|
|
+ if (!term) return; // 确保term存在
|
|
|
+ //更新最小开始日期和最大结束日期
|
|
|
+ if (!minStartDate || new Date(term.startDate) < new Date(minStartDate)) {
|
|
|
+ minStartDate = term.startDate;
|
|
|
+ }
|
|
|
+ if (!maxEndDate || new Date(term.endDate) > new Date(maxEndDate)) {
|
|
|
+ maxEndDate = term.endDate;
|
|
|
+ }
|
|
|
|
|
|
// 如果有选中的学期,更新validRange
|
|
|
if (minStartDate && maxEndDate) {
|
|
@@ -304,10 +681,231 @@ export default {
|
|
|
// 应用更新
|
|
|
if (this.calendar) {
|
|
|
this.calendar.setOption("validRange", this.calendarOptions.validRange);
|
|
|
+
|
|
|
this.calendar.render();
|
|
|
}
|
|
|
},
|
|
|
|
|
|
+ // 学年选择
|
|
|
+ // 修改changeAcademicYear方法,整合handleSelectionYear逻辑
|
|
|
+ changeAcademicYear(value) {
|
|
|
+ // 找到选中的学年对象
|
|
|
+ const selectedYear = this.academicYears.find(
|
|
|
+ (year) => year.value === value
|
|
|
+ );
|
|
|
+
|
|
|
+ if (selectedYear) {
|
|
|
+ // 更新索引
|
|
|
+ this.selectedAcademicYearIndex = this.academicYears.findIndex(
|
|
|
+ (year) => year.value === value
|
|
|
+ );
|
|
|
+ // 更新绑定的学年值
|
|
|
+ this.selectedAcademicYear = selectedYear.value;
|
|
|
+ // 更新日历的有效日期范围
|
|
|
+ this.calendarOptions.validRange = {
|
|
|
+ start: selectedYear.startDate + " 00:00:00",
|
|
|
+ end: selectedYear.endDate + " 23:59:59",
|
|
|
+ };
|
|
|
+
|
|
|
+ if (this.calendar) {
|
|
|
+ this.calendar.setOption(
|
|
|
+ "validRange",
|
|
|
+ this.calendarOptions.validRange
|
|
|
+ );
|
|
|
+ this.calendar.render();
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ // 如果没有找到匹配的学年,可以重置或处理异常情况
|
|
|
+ this.selectedAcademicYear = ""; // 或者其他默认值
|
|
|
+ this.selectedAcademicYearIndex = null;
|
|
|
+ // 重置日历范围为默认值
|
|
|
+ this.updateCalendarRange({
|
|
|
+ start: "2022-01-01 00:00:00",
|
|
|
+ end: "2025-12-31 23:59:59",
|
|
|
+ });
|
|
|
+ }
|
|
|
+ },
|
|
|
+
|
|
|
+ // 新增方法
|
|
|
+ showAcademicYearActionsDialog() {
|
|
|
+ this.academicYearActionsVisible = true;
|
|
|
+ this.selectedAcademicAction = "";
|
|
|
+ this.academicYearForm = { name: "", startDate: "", endDate: "" }; // 重置表单
|
|
|
+ },
|
|
|
+
|
|
|
+ onAcademicActionSelected() {
|
|
|
+ // 重置表单或逻辑
|
|
|
+ if (this.selectedAcademicAction === "add") {
|
|
|
+ this.academicYearForm = { name: "", startDate: "", endDate: "" };
|
|
|
+ } else if (this.selectedAcademicAction === "edit") {
|
|
|
+ this.selectedAcademicYearIndex = null; // 重置学年选择
|
|
|
+ }
|
|
|
+ this.canExecuteAcademicAction = this.selectedAcademicAction !== ""; // 允许操作
|
|
|
+ },
|
|
|
+
|
|
|
+ loadAcademicYearDetails(index) {
|
|
|
+ if (index !== null && this.academicYears[index]) {
|
|
|
+ this.academicYearForm = {
|
|
|
+ name: this.academicYears[index].label,
|
|
|
+ startDate: this.academicYears[index].startDate.split(" ")[0],
|
|
|
+ endDate: this.academicYears[index].endDate.split(" ")[0],
|
|
|
+ };
|
|
|
+ this.selectedAcademicYearIndex = index;
|
|
|
+ }
|
|
|
+ },
|
|
|
+
|
|
|
+ executeAcademicAction() {
|
|
|
+ if (this.selectedAcademicAction === "add") {
|
|
|
+ this.addAcademicYear();
|
|
|
+ } else if (this.selectedAcademicAction === "edit") {
|
|
|
+ this.editAcademicYear();
|
|
|
+ } else if (this.selectedAcademicAction === "delete") {
|
|
|
+ this.deleteAcademicYear();
|
|
|
+ }
|
|
|
+ this.academicYearActionsVisible = false;
|
|
|
+ this.selectedAcademicAction = ""; // 重置操作
|
|
|
+ },
|
|
|
+
|
|
|
+ // 确保在用户界面交互中正确调用此方法来设置选中学年索引
|
|
|
+ handleSelectionYear(index) {
|
|
|
+ if (index !== null && this.academicYears[index]) {
|
|
|
+ // 更新选中学年索引
|
|
|
+ this.selectedAcademicYearIndex = index;
|
|
|
+ // 直接根据索引获取学年对象并更新selectedAcademicYear
|
|
|
+ this.selectedAcademicYear = this.academicYears[index].label; // 假定label作为展示值,根据实际需求调整
|
|
|
+ // 更新日历的有效日期范围
|
|
|
+ this.updateCalendarRange({
|
|
|
+ start: this.academicYears[index].startDate + " 00:00:00",
|
|
|
+ end: this.academicYears[index].endDate + " 23:59:59",
|
|
|
+ });
|
|
|
+ }
|
|
|
+ },
|
|
|
+
|
|
|
+ // 新增学年
|
|
|
+ addAcademicYear() {
|
|
|
+ if (this.validateAcademicYearForm()) {
|
|
|
+ const newYear = {
|
|
|
+ label: this.academicYearForm.name,
|
|
|
+ startDate: this.academicYearForm.startDate,
|
|
|
+ endDate: this.academicYearForm.endDate,
|
|
|
+ };
|
|
|
+ this.academicYears.push(newYear);
|
|
|
+
|
|
|
+ // 更新UI
|
|
|
+ this.selectYear = newYear.label; // 更新占位符文本
|
|
|
+ this.updateCalendarRange({
|
|
|
+ start: newYear.startDate,
|
|
|
+ end: newYear.endDate,
|
|
|
+ });
|
|
|
+
|
|
|
+ // 清空表单
|
|
|
+ this.resetAcademicYearForm();
|
|
|
+
|
|
|
+ // 提示信息
|
|
|
+ ElMessage.success("添加学年成功");
|
|
|
+ this.academicYearActionsVisible = false;
|
|
|
+ this.selectedAcademicAction = "";
|
|
|
+ } else {
|
|
|
+ ElMessage.error("表单验证未通过,请检查输入信息。");
|
|
|
+ }
|
|
|
+ this.selectedAcademicYearIndex = null; // 如果适用,重置选中的学年索引
|
|
|
+ },
|
|
|
+
|
|
|
+ editAcademicYear() {
|
|
|
+ if (this.selectedAcademicYearIndex !== null) {
|
|
|
+ if (this.validateAcademicYearForm()) {
|
|
|
+ const updatedYear = {
|
|
|
+ label: this.academicYearForm.name,
|
|
|
+ startDate: this.academicYearForm.startDate,
|
|
|
+ endDate: this.academicYearForm.endDate,
|
|
|
+ };
|
|
|
+ this.academicYears[this.selectedAcademicYearIndex] = updatedYear;
|
|
|
+
|
|
|
+ // 更新UI
|
|
|
+ this.$nextTick(() => {
|
|
|
+ this.updateCalendarRange({
|
|
|
+ start: updatedYear.startDate,
|
|
|
+ end: updatedYear.endDate,
|
|
|
+ });
|
|
|
+ this.selectYear = updatedYear.label; // 更新占位符文本
|
|
|
+ });
|
|
|
+
|
|
|
+ // 重置表单
|
|
|
+ this.resetAcademicYearForm();
|
|
|
+
|
|
|
+ // 关闭对话框并重置操作
|
|
|
+ this.academicYearActionsVisible = false;
|
|
|
+ this.selectedAcademicAction = "";
|
|
|
+ ElMessage.success("编辑学年成功");
|
|
|
+ } else {
|
|
|
+ ElMessage.error("表单验证未通过,请检查输入信息。");
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ ElMessage.error("没有选中学年进行编辑。");
|
|
|
+ }
|
|
|
+ this.selectedAcademicYearIndex = null; // 如果适用,重置选中的学年索引
|
|
|
+ },
|
|
|
+
|
|
|
+ // 确保删除功能的打印语句在正确的位置执行
|
|
|
+ deleteAcademicYear() {
|
|
|
+ if (
|
|
|
+ this.selectedAcademicYearIndex !== null &&
|
|
|
+ this.selectedAcademicYearIndex >= 0 &&
|
|
|
+ this.selectedAcademicYearIndex < this.academicYears.length
|
|
|
+ ) {
|
|
|
+ this.academicYears.splice(this.selectedAcademicYearIndex, 1);
|
|
|
+ this.selectedAcademicYearIndex = null;
|
|
|
+
|
|
|
+ // 重置UI
|
|
|
+ this.selectYear = "请选择学年";
|
|
|
+ this.updateCalendarRange({
|
|
|
+ start: "2022-01-01 00:00:00",
|
|
|
+ end: "2025-12-31 23:59:59",
|
|
|
+ });
|
|
|
+
|
|
|
+ // 重置表单
|
|
|
+ this.resetAcademicYearForm();
|
|
|
+
|
|
|
+ ElMessage.error("学年删除成功");
|
|
|
+
|
|
|
+ this.academicYearActionsVisible = false;
|
|
|
+ this.selectedAcademicAction = "";
|
|
|
+ } else {
|
|
|
+ ElMessage.error("无法删除不存在的学年");
|
|
|
+ }
|
|
|
+ this.selectedAcademicYear = "";
|
|
|
+ this.selectedAcademicYearIndex = null; // 如果适用,重置选中的学年索引
|
|
|
+ },
|
|
|
+ validateAcademicYearForm() {
|
|
|
+ return (
|
|
|
+ this.academicYearForm.name.trim() !== "" &&
|
|
|
+ this.academicYearForm.startDate &&
|
|
|
+ this.academicYearForm.endDate
|
|
|
+ );
|
|
|
+ },
|
|
|
+
|
|
|
+ resetAcademicYearForm() {
|
|
|
+ this.academicYearForm.name = "";
|
|
|
+ this.academicYearForm.startDate = "";
|
|
|
+ this.academicYearForm.endDate = "";
|
|
|
+ },
|
|
|
+
|
|
|
+ updateCalendarRange(range = {}) {
|
|
|
+ if (range.start && range.end) {
|
|
|
+ this.calendarOptions.validRange = {
|
|
|
+ start: range.start,
|
|
|
+ end: range.end,
|
|
|
+ };
|
|
|
+ if (this.calendar) {
|
|
|
+ this.calendar.setOption(
|
|
|
+ "validRange",
|
|
|
+ this.calendarOptions.validRange
|
|
|
+ );
|
|
|
+ this.calendar.render();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ },
|
|
|
+
|
|
|
// 文件上传成功
|
|
|
uploadSuccess(data, a) {
|
|
|
this.form.url = data.data[0];
|
|
@@ -330,7 +928,11 @@ export default {
|
|
|
end: e.event.endStr,
|
|
|
};
|
|
|
editCalendarInfo(obj).then((response) => {
|
|
|
- ElMessage.success("拖拽修改备注成功");
|
|
|
+ if ((response.data.status = 500)) {
|
|
|
+ ElMessage.error("没有权限,无法操作");
|
|
|
+ } else {
|
|
|
+ ElMessage.success("拖拽修改备注成功");
|
|
|
+ }
|
|
|
// 更新数据
|
|
|
this.InfoCalGet();
|
|
|
});
|
|
@@ -384,7 +986,8 @@ export default {
|
|
|
this.Visible = true;
|
|
|
},
|
|
|
// 确认添加备注事件 或者确认修改备注时间
|
|
|
- confirm() {
|
|
|
+ confirm(a) {
|
|
|
+ console.log(a);
|
|
|
if (this.form.name == null || this.form.name == "") {
|
|
|
ElMessage.error("备注名称不能为空");
|
|
|
return;
|
|
@@ -462,13 +1065,17 @@ export default {
|
|
|
});
|
|
|
}
|
|
|
// 打开编辑备注框
|
|
|
- else {
|
|
|
+ else if (value == "edit") {
|
|
|
this.Visible = true;
|
|
|
this.form.name = this.GetInfo.event.title;
|
|
|
this.form.date = [
|
|
|
this.GetInfo.event.startStr,
|
|
|
this.GetInfo.event.endStr,
|
|
|
];
|
|
|
+ } else {
|
|
|
+ ElMessage.warning("复制数据");
|
|
|
+ this.chooseCopy = true;
|
|
|
+ this.form.name = this.GetInfo.event.title + "副本";
|
|
|
}
|
|
|
},
|
|
|
// 获取备注数据
|
|
@@ -493,16 +1100,54 @@ export default {
|
|
|
url: "",
|
|
|
};
|
|
|
},
|
|
|
+ certainCopy() {
|
|
|
+ var obj = {
|
|
|
+ title: this.form.name,
|
|
|
+ detail: this.form.desc,
|
|
|
+ start: this.form.date[0],
|
|
|
+ end: this.form.date[1],
|
|
|
+ overlap: 1,
|
|
|
+ editable: 1,
|
|
|
+ color: "#ffcc99",
|
|
|
+ file: "",
|
|
|
+ fileType: "",
|
|
|
+ };
|
|
|
+ addCalendarsInfo(obj).then(() => {
|
|
|
+ this.InfoCalGet();
|
|
|
+ }); // 更新数据
|
|
|
+ this.clearForm();
|
|
|
+ this.chooseCopy = false;
|
|
|
+ },
|
|
|
},
|
|
|
};
|
|
|
</script>
|
|
|
|
|
|
<style scoped>
|
|
|
-.calendar {
|
|
|
- width: 70%;
|
|
|
- height: 100%;
|
|
|
- margin-left: 250px;
|
|
|
- margin-top: 70px;
|
|
|
- margin-bottom: 70px;
|
|
|
+.main {
|
|
|
+ margin: 30px;
|
|
|
+ display: flex;
|
|
|
+ justify-content: center;
|
|
|
+ align-items: center;
|
|
|
+}
|
|
|
+
|
|
|
+.content {
|
|
|
+ width: 1450px;
|
|
|
+}
|
|
|
+
|
|
|
+.term {
|
|
|
+ /* margin-top: 30px; */
|
|
|
+ margin-bottom: 30px;
|
|
|
+ display: flex;
|
|
|
+ justify-content: right;
|
|
|
+ align-items: end;
|
|
|
+ flex-direction: column;
|
|
|
+}
|
|
|
+
|
|
|
+.term_content {
|
|
|
+ margin-top: 10px;
|
|
|
+ display: flex;
|
|
|
+ justify-content: space-between;
|
|
|
+ align-items: center;
|
|
|
+ width: 350px;
|
|
|
}
|
|
|
</style>
|