|
|
@@ -1,12 +1,119 @@
|
|
|
<template>
|
|
|
<div class="tab-wrapper">
|
|
|
- add
|
|
|
+ <div class="title">新建幻灯片</div>
|
|
|
+ <div class="sub-title">所属课程:</div>
|
|
|
+ <div class="select-wrapper">
|
|
|
+ <select v-model="selectedCourseId">
|
|
|
+ <option value="">[ 未填写 ]</option>
|
|
|
+ <option v-for="course of courses" :value="course.id" :key="course.id">
|
|
|
+ {{ course.name }}
|
|
|
+ </option>
|
|
|
+ </select>
|
|
|
+ </div>
|
|
|
+ <div class="sub-title">幻灯片名称:</div>
|
|
|
+ <input
|
|
|
+ type="text"
|
|
|
+ v-model="userInput"
|
|
|
+ placeholder="请勿与同课程幻灯片重名"
|
|
|
+ />
|
|
|
+ <button class="submit-button" @click.prevent="handleSubmit">
|
|
|
+ 添加
|
|
|
+ </button>
|
|
|
</div>
|
|
|
</template>
|
|
|
|
|
|
<script>
|
|
|
-export default {}
|
|
|
+import { getTeacherCourse } from '@/server/course'
|
|
|
+import { createSlide } from '@/server/slide'
|
|
|
+import { INIT_BY_DEFAULT } from '../../../store/types/editor-types'
|
|
|
+export default {
|
|
|
+ data() {
|
|
|
+ return {
|
|
|
+ courses: [],
|
|
|
+ selectedCourseId: '',
|
|
|
+ userInput: ''
|
|
|
+ }
|
|
|
+ },
|
|
|
+ mounted() {
|
|
|
+ getTeacherCourse().then(res => {
|
|
|
+ this.courses = res
|
|
|
+ })
|
|
|
+ },
|
|
|
+ methods: {
|
|
|
+ handleSubmit() {
|
|
|
+ createSlide(this.selectedCourseId, this.userInput).then(res => {
|
|
|
+ this.$store.commit(INIT_BY_DEFAULT, res)
|
|
|
+ this.$router.push('/editor')
|
|
|
+ })
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
</script>
|
|
|
<style lang="scss" scoped>
|
|
|
@import './tab-common.scss';
|
|
|
+$input-background-color: #ebf0f5;
|
|
|
+$submit-button-color: #5a7fa5;
|
|
|
+
|
|
|
+.title {
|
|
|
+ margin-bottom: 32px;
|
|
|
+}
|
|
|
+
|
|
|
+.submit-button {
|
|
|
+ display: block;
|
|
|
+ width: 120px;
|
|
|
+ height: 40px;
|
|
|
+ margin-top: 36px;
|
|
|
+ background: $submit-button-color;
|
|
|
+ color: white;
|
|
|
+ border-radius: 8px;
|
|
|
+ border: none;
|
|
|
+ outline: none;
|
|
|
+ font-size: 14px;
|
|
|
+ font-weight: 500;
|
|
|
+ &:hover {
|
|
|
+ background: darken($submit-button-color, 5);
|
|
|
+ }
|
|
|
+
|
|
|
+ &:active {
|
|
|
+ background: darken($submit-button-color, 10);
|
|
|
+ }
|
|
|
+}
|
|
|
+.select-wrapper {
|
|
|
+ width: 100%;
|
|
|
+ height: 40px;
|
|
|
+ margin-bottom: 36 px;
|
|
|
+}
|
|
|
+
|
|
|
+select,
|
|
|
+input {
|
|
|
+ box-sizing: border-box;
|
|
|
+ font-size: 16px;
|
|
|
+ font-weight: 500;
|
|
|
+ color: #3a4a5a;
|
|
|
+ background: $input-background-color;
|
|
|
+ border-radius: 8px;
|
|
|
+ border: none;
|
|
|
+ outline: none;
|
|
|
+ width: 100%;
|
|
|
+ height: 48px;
|
|
|
+ line-height: 40px;
|
|
|
+ padding: 0;
|
|
|
+ padding-left: 12px;
|
|
|
+}
|
|
|
+
|
|
|
+select {
|
|
|
+ //隐藏select的下拉图标
|
|
|
+ appearance: none;
|
|
|
+ -webkit-appearance: none;
|
|
|
+ -moz-appearance: none;
|
|
|
+ //通过padding-left的值让文字居中
|
|
|
+}
|
|
|
+
|
|
|
+input {
|
|
|
+ border: none;
|
|
|
+ border-radius: 8px;
|
|
|
+
|
|
|
+ outline: none;
|
|
|
+ background: $input-background-color;
|
|
|
+}
|
|
|
</style>
|