|
|
@@ -48,7 +48,8 @@
|
|
|
</div>
|
|
|
</template>
|
|
|
<div class="course-card-list-container">
|
|
|
- <CourseCard v-for="(item,index) in filterCourses" :key="index" :ref="'courseCard'+item.id" :courseVO="item" @delete="deleteCourse(item)" @update="beforeUpdateCourse(item)"/>
|
|
|
+ <CourseCard v-for="(item,index) in filterCourses" :key="index" :ref="'courseCard'+item.id" :courseVO="item"
|
|
|
+ @delete="deleteCourse(item)" @update="beforeUpdateCourse(item)"/>
|
|
|
</div>
|
|
|
</el-card>
|
|
|
|
|
|
@@ -60,16 +61,16 @@
|
|
|
<span style="font-weight: bold; font-size: larger">
|
|
|
全部测试
|
|
|
</span>
|
|
|
-<!-- <div class="course-type-selector">-->
|
|
|
-<!-- <el-select v-model="examType" class="m-2" placeholder="测试类型">-->
|
|
|
-<!-- <el-option-->
|
|
|
-<!-- v-for="item in examTypeOptions"-->
|
|
|
-<!-- :key="item.value"-->
|
|
|
-<!-- :label="item.label"-->
|
|
|
-<!-- :value="item.value"-->
|
|
|
-<!-- />-->
|
|
|
-<!-- </el-select>-->
|
|
|
-<!-- </div>-->
|
|
|
+ <!-- <div class="course-type-selector">-->
|
|
|
+ <!-- <el-select v-model="examType" class="m-2" placeholder="测试类型">-->
|
|
|
+ <!-- <el-option-->
|
|
|
+ <!-- v-for="item in examTypeOptions"-->
|
|
|
+ <!-- :key="item.value"-->
|
|
|
+ <!-- :label="item.label"-->
|
|
|
+ <!-- :value="item.value"-->
|
|
|
+ <!-- />-->
|
|
|
+ <!-- </el-select>-->
|
|
|
+ <!-- </div>-->
|
|
|
</div>
|
|
|
</template>
|
|
|
<el-tabs v-model="activeTestPaneName">
|
|
|
@@ -176,9 +177,9 @@
|
|
|
|
|
|
<script>
|
|
|
import CourseCard from "@/components/CourseCard";
|
|
|
-import { ElMessage, ElMessageBox } from "element-plus";
|
|
|
-import client from "@/utils/oss";
|
|
|
-import { Back, Document } from "@element-plus/icons-vue";
|
|
|
+import {ElMessage, ElMessageBox} from "element-plus";
|
|
|
+// import client from "@/utils/oss";
|
|
|
+import {Back, Document} from "@element-plus/icons-vue";
|
|
|
import TestCard from "@/components/TestCard";
|
|
|
|
|
|
export default {
|
|
|
@@ -278,19 +279,19 @@ export default {
|
|
|
myCourseList: [],
|
|
|
courseType: "all",
|
|
|
courseTypeOptions: [
|
|
|
- { value: "all", label: "全部课程" },
|
|
|
- { value: "pending", label: "未开始" },
|
|
|
- { value: "start", label: "正在进行" },
|
|
|
- { value: "end", label: "已结束" },
|
|
|
+ {value: "all", label: "全部课程"},
|
|
|
+ {value: "pending", label: "未开始"},
|
|
|
+ {value: "start", label: "正在进行"},
|
|
|
+ {value: "end", label: "已结束"},
|
|
|
],
|
|
|
evalExamList: [],
|
|
|
coderExamList: [],
|
|
|
examType: "all",
|
|
|
examTypeOptions: [
|
|
|
- { value: "all", label: "全部测试" },
|
|
|
- { value: "pending", label: "未开始" },
|
|
|
- { value: "start", label: "正在进行" },
|
|
|
- { value: "end", label: "已结束" },
|
|
|
+ {value: "all", label: "全部测试"},
|
|
|
+ {value: "pending", label: "未开始"},
|
|
|
+ {value: "start", label: "正在进行"},
|
|
|
+ {value: "end", label: "已结束"},
|
|
|
],
|
|
|
};
|
|
|
},
|
|
|
@@ -330,98 +331,91 @@ export default {
|
|
|
this.$router.push("portal");
|
|
|
}
|
|
|
if (index === "1") {
|
|
|
- document.getElementById("app").scrollIntoView({ behavior: "smooth" });
|
|
|
+ document.getElementById("app").scrollIntoView({behavior: "smooth"});
|
|
|
}
|
|
|
if (index === "2") {
|
|
|
- document.querySelector("#manage-page-divider").scrollIntoView({ behavior: "smooth" });
|
|
|
+ document.querySelector("#manage-page-divider").scrollIntoView({behavior: "smooth"});
|
|
|
}
|
|
|
this.activeIndex = index;
|
|
|
},
|
|
|
handleFormConfirm() {
|
|
|
const _this = this;
|
|
|
- // 上传oss图片
|
|
|
- this.$refs.formRef.validate((valid) => {
|
|
|
+ _this.form.imageUrl = null;
|
|
|
+ _this.$refs.formRef.validate((valid) => {
|
|
|
if (valid) {
|
|
|
- if (this.form.fileList.length === 0) {
|
|
|
- this.form.imageUrl = null;
|
|
|
- createOrUpdateCourse();
|
|
|
- } else {
|
|
|
- if (this.form.fileList[0].raw) {
|
|
|
- client.put("/seecoder/image-" + this.form.name + ".jpg", this.form.fileList[0].raw)
|
|
|
- .then(res => {
|
|
|
- this.form.imageUrl = res.res.requestUrls[0];
|
|
|
- createOrUpdateCourse();
|
|
|
- })
|
|
|
- .catch(err => {
|
|
|
- console.log(err);
|
|
|
- ElMessage.error(err);
|
|
|
- });
|
|
|
- } else {
|
|
|
- createOrUpdateCourse();
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- });
|
|
|
-
|
|
|
- function createOrUpdateCourse() {
|
|
|
- console.log(_this.form);
|
|
|
- if (_this.form.id === null) {
|
|
|
- _this.$apis.createCourse({
|
|
|
- name: _this.form.name,
|
|
|
- teacher: {
|
|
|
- id: _this.$store.state.user.id,
|
|
|
- },
|
|
|
- semester: _this.form.year + _this.form.season,
|
|
|
- imageUrl: _this.form.imageUrl,
|
|
|
- description: _this.form.description,
|
|
|
- startTime: _this.form.courseTime[0],
|
|
|
- endTime: _this.form.courseTime[1],
|
|
|
- invitationCode: _this.form.invitationCode,
|
|
|
- moocUrl: _this.form.moocUrl,
|
|
|
- createdTime: new Date(),
|
|
|
- price: Number(_this.form.price),
|
|
|
- coderId: _this.form.coderLink ? -1 : null,
|
|
|
- evalId: _this.form.evalLink ? -1 : null,
|
|
|
- })
|
|
|
- .then((res) => {
|
|
|
- _this.myCourseList.push(res.data.data);
|
|
|
- _this.dialogVisible = false;
|
|
|
- _this.clearForm();
|
|
|
- ElMessage.success("新建课程成功");
|
|
|
- })
|
|
|
- .catch(err => {
|
|
|
- ElMessage.error(err);
|
|
|
+ if (_this.form.id === null) {
|
|
|
+ // 首先创建课程
|
|
|
+ // 之后上传课程图片
|
|
|
+ _this.$apis.createCourse({
|
|
|
+ name: _this.form.name,
|
|
|
+ teacher: {
|
|
|
+ id: _this.$store.state.user.id,
|
|
|
+ },
|
|
|
+ semester: _this.form.year + _this.form.season,
|
|
|
+ imageUrl: null,
|
|
|
+ description: _this.form.description,
|
|
|
+ startTime: _this.form.courseTime[0],
|
|
|
+ endTime: _this.form.courseTime[1],
|
|
|
+ invitationCode: _this.form.invitationCode,
|
|
|
+ moocUrl: _this.form.moocUrl,
|
|
|
+ createdTime: new Date(),
|
|
|
+ price: Number(_this.form.price),
|
|
|
+ coderId: _this.form.coderLink ? -1 : null,
|
|
|
+ evalId: _this.form.evalLink ? -1 : null,
|
|
|
+ }).then(async (res) => {
|
|
|
+ const createdCourse = res.data.data;
|
|
|
+ if (createdCourse) {
|
|
|
+ if (_this.form.fileList.length !== 0) {
|
|
|
+ const imageUrl = (await _this.$apis.uploadCourseImage(createdCourse.name, this.form.fileList[0].raw)).data.data;
|
|
|
+ if (imageUrl) {
|
|
|
+ createdCourse.imageUrl = imageUrl;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ _this.myCourseList.push(createdCourse);
|
|
|
+ _this.dialogVisible = false;
|
|
|
+ _this.clearForm();
|
|
|
+ ElMessage.success("新建课程成功");
|
|
|
+ } else {
|
|
|
+ console.log(res);
|
|
|
+ }
|
|
|
});
|
|
|
- } else {
|
|
|
- _this.$apis.updateCourse({
|
|
|
- id: _this.form.id,
|
|
|
- name: _this.form.name,
|
|
|
- semester: _this.form.year + _this.form.season,
|
|
|
- imageUrl: _this.form.imageUrl,
|
|
|
- description: _this.form.description,
|
|
|
- startTime: _this.form.courseTime[0],
|
|
|
- endTime: _this.form.courseTime[1],
|
|
|
- invitationCode: _this.form.invitationCode,
|
|
|
- moocUrl: _this.form.moocUrl,
|
|
|
- price: Number(_this.form.price),
|
|
|
- })
|
|
|
- .then((res) => {
|
|
|
- for (let i = 0; i < _this.myCourseList.length; i++) {
|
|
|
- if (_this.myCourseList[i].id === _this.form.id) {
|
|
|
- _this.myCourseList[i] = res.data.data;
|
|
|
+ } else {
|
|
|
+ // 首先更新课程
|
|
|
+ // 之后更新课程图片
|
|
|
+ _this.$apis.updateCourse({
|
|
|
+ id: _this.form.id,
|
|
|
+ name: _this.form.name,
|
|
|
+ semester: _this.form.year + _this.form.season,
|
|
|
+ imageUrl: _this.form.imageUrl,
|
|
|
+ description: _this.form.description,
|
|
|
+ startTime: _this.form.courseTime[0],
|
|
|
+ endTime: _this.form.courseTime[1],
|
|
|
+ invitationCode: _this.form.invitationCode,
|
|
|
+ moocUrl: _this.form.moocUrl,
|
|
|
+ price: Number(_this.form.price),
|
|
|
+ }).then(async (res) => {
|
|
|
+ const updatedCourse = res.data.data;
|
|
|
+ if (updatedCourse) {
|
|
|
+ if (_this.form.fileList.length !== 0) {
|
|
|
+ const imageUrl = (await _this.$apis.uploadCourseImage(createdCourse.name, this.form.fileList[0].raw)).data.data;
|
|
|
+ if (imageUrl) {
|
|
|
+ updatedCourse.imageUrl = imageUrl;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ for (let i = 0; i < _this.myCourseList.length; i++) {
|
|
|
+ if (_this.myCourseList[i].id === _this.form.id) {
|
|
|
+ _this.myCourseList[i] = createdCourse;
|
|
|
+ }
|
|
|
}
|
|
|
+ _this.$refs["courseCard" + _this.form.id][0].$props.courseVO = createdCourse;
|
|
|
+ _this.dialogVisible = false;
|
|
|
+ _this.clearForm();
|
|
|
+ ElMessage.success("更新课程成功");
|
|
|
}
|
|
|
- _this.$refs["courseCard" + _this.form.id][0].$props.courseVO = res.data.data;
|
|
|
- _this.dialogVisible = false;
|
|
|
- _this.clearForm();
|
|
|
- ElMessage.success("更新课程成功");
|
|
|
- })
|
|
|
- .catch(err => {
|
|
|
- console.log(err);
|
|
|
- ElMessage.error(err);
|
|
|
});
|
|
|
+ }
|
|
|
}
|
|
|
- }
|
|
|
+ });
|
|
|
},
|
|
|
handleFormCancel() {
|
|
|
ElMessageBox.confirm("是否确认退出?退出后将不保存表格信息。", "提示", {
|