|
|
@@ -14,7 +14,7 @@
|
|
|
>
|
|
|
</el-option>
|
|
|
</el-select>
|
|
|
- <el-button plain type="primary ml-16" @click="dialogVisible=true">{{ dialogTitle }}</el-button>
|
|
|
+ <el-button class="ml-16" plain type="primary" @click="dialogVisible=true">{{ dialogTitle }}</el-button>
|
|
|
</div>
|
|
|
</div>
|
|
|
<div class="courseList">
|
|
|
@@ -75,6 +75,15 @@
|
|
|
<el-button @click="handleFormCancel">取消</el-button>
|
|
|
</div>
|
|
|
</el-dialog>
|
|
|
+ <div class="confirm-cancel-dialog">
|
|
|
+ <el-dialog v-model="confirmFormCancel" center top="25vh" width="20%">
|
|
|
+ <p>是否退出?退出将不保存信息</p>
|
|
|
+ <div style="margin: auto;width: fit-content">
|
|
|
+ <el-button plain size="small" type="warning" @click="handleConfirmFormCancel">退出</el-button>
|
|
|
+ <el-button plain size="small" type="primary" @click="confirmFormCancel=false">取消</el-button>
|
|
|
+ </div>
|
|
|
+ </el-dialog>
|
|
|
+ </div>
|
|
|
|
|
|
</template>
|
|
|
|
|
|
@@ -93,7 +102,7 @@ const dialogTitle = ref("新增课程");
|
|
|
const form = reactive({
|
|
|
name: "",
|
|
|
semester: {
|
|
|
- year: null,
|
|
|
+ year: "",
|
|
|
season: "",
|
|
|
},
|
|
|
description: "",
|
|
|
@@ -102,7 +111,7 @@ const form = reactive({
|
|
|
null,
|
|
|
],
|
|
|
invitationCode: "",
|
|
|
- price: 0,
|
|
|
+ price: "",//input均会将Number类型转化成为字符串类型
|
|
|
moocUrl: null,
|
|
|
imageUrl: null,
|
|
|
});
|
|
|
@@ -261,15 +270,42 @@ const handleFormConfirm = async () => {
|
|
|
const value = ref("");
|
|
|
const options = ref("");
|
|
|
|
|
|
+
|
|
|
+//取消新增课程,弹窗确认
|
|
|
+const confirmFormCancel = ref(false);
|
|
|
const handleFormCancel = function () {
|
|
|
- console.log(form);
|
|
|
+ confirmFormCancel.value = true;
|
|
|
};
|
|
|
|
|
|
-const checkForm = function () {
|
|
|
- console.log("check form");
|
|
|
+//确认取消新增课程
|
|
|
+const handleConfirmFormCancel = function () {
|
|
|
+ confirmFormCancel.value = false;
|
|
|
+ dialogVisible.value = false;
|
|
|
+ clearForm();
|
|
|
};
|
|
|
|
|
|
+//点击确定新增课程按钮时检查填写内容是否合法
|
|
|
+const checkForm = function () {
|
|
|
+ const nameValid = form.name.length > 0;
|
|
|
+ const semesterValid = (form.semester.season != null && form.semester.season.length > 0) && (form.semester.year != null && form.semester.year.length > 0);
|
|
|
+ const descriptionValid = form.description.length > 0;
|
|
|
+ const courseTimeValid = form.courseTime[0] !== null && form.courseTime[1] !== null;
|
|
|
+ const invitationCodeValid = form.invitationCode.length > 0;
|
|
|
+ const priceValid = form.price.length > 0 && (parseInt(form.price) > 0);
|
|
|
+ //moocUrl和imgUrl可以为null
|
|
|
+ return nameValid && semesterValid && descriptionValid && courseTimeValid && priceValid && invitationCodeValid;
|
|
|
+};
|
|
|
+//
|
|
|
const clearForm = function () {
|
|
|
+ form.name = "";
|
|
|
+ form.semester.year = "";
|
|
|
+ form.semester.season = "";
|
|
|
+ form.description = "";
|
|
|
+ form.courseTime[0] = form.courseTime[1] = null;
|
|
|
+ form.invitationCode = "";
|
|
|
+ form.price = "";
|
|
|
+ form.moocUrl = null;
|
|
|
+ form.imageUrl = null;
|
|
|
};
|
|
|
|
|
|
</script>
|
|
|
@@ -315,6 +351,17 @@ const clearForm = function () {
|
|
|
display: block;
|
|
|
}
|
|
|
|
|
|
+.confirm-cancel-dialog :deep(.el-dialog) {
|
|
|
+ display: flex;
|
|
|
+ align-items: center;
|
|
|
+ justify-content: center;
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+.confirm-cancel-dialog:deep(.el-dialog__header) {
|
|
|
+ display: none;
|
|
|
+}
|
|
|
+
|
|
|
.saveNewCourse .el-button {
|
|
|
width: 88px;
|
|
|
}
|