|
@@ -6,20 +6,20 @@
|
|
|
<label>
|
|
<label>
|
|
|
<select v-model="selectedCourseId">
|
|
<select v-model="selectedCourseId">
|
|
|
<option disabled value="">[ 未填写 ]</option>
|
|
<option disabled value="">[ 未填写 ]</option>
|
|
|
- <option v-for="course of courses" :value="course.id" :key="course.id">
|
|
|
|
|
|
|
+ <option v-for="course in courses" :value="course.id" :key="course.id">
|
|
|
{{ course.name }}
|
|
{{ course.name }}
|
|
|
</option>
|
|
</option>
|
|
|
</select>
|
|
</select>
|
|
|
</label>
|
|
</label>
|
|
|
</div>
|
|
</div>
|
|
|
- <div class="sub-title">幻灯片名称:</div>
|
|
|
|
|
|
|
+ <div class="sub-title">课件名称:</div>
|
|
|
<c-input
|
|
<c-input
|
|
|
- v-model="userInput"
|
|
|
|
|
- placeholder="请勿与同课程幻灯片重名"
|
|
|
|
|
|
|
+ v-model="slideName"
|
|
|
|
|
+ placeholder="请勿与同课程课件重名"
|
|
|
/>
|
|
/>
|
|
|
- <div class="sub-title">幻灯片文件 <span class="tag">目前支持 PDF 格式</span></div>
|
|
|
|
|
- <file-uploader v-model="file"/>
|
|
|
|
|
- <c-button class="my-button" @click.prevent="handleSubmit">
|
|
|
|
|
|
|
+ <div class="sub-title">课件文件 <span class="tag">目前支持 PDF 格式</span></div>
|
|
|
|
|
+ <file-uploader accept="application/pdf" class="mb-24" @change="handleFileChanged"/>
|
|
|
|
|
+ <c-button class="secondary full-width" :disabled="!formChecked()" @click="handleSubmit">
|
|
|
添加
|
|
添加
|
|
|
</c-button>
|
|
</c-button>
|
|
|
</div>
|
|
</div>
|
|
@@ -30,6 +30,7 @@ import CInput from '@/components/CInput'
|
|
|
import CButton from '@/components/CButton'
|
|
import CButton from '@/components/CButton'
|
|
|
import FileUploader from '@/components/FileUploader'
|
|
import FileUploader from '@/components/FileUploader'
|
|
|
import { teacherGetCourses } from '@/server/course'
|
|
import { teacherGetCourses } from '@/server/course'
|
|
|
|
|
+import { createSlide } from '@/server/slide'
|
|
|
|
|
|
|
|
export default {
|
|
export default {
|
|
|
components: { FileUploader, CButton, CInput },
|
|
components: { FileUploader, CButton, CInput },
|
|
@@ -37,20 +38,44 @@ export default {
|
|
|
return {
|
|
return {
|
|
|
courses: [],
|
|
courses: [],
|
|
|
selectedCourseId: '',
|
|
selectedCourseId: '',
|
|
|
- userInput: '',
|
|
|
|
|
- file: null
|
|
|
|
|
|
|
+ slideName: '',
|
|
|
|
|
+ file: null,
|
|
|
|
|
+ message: ''
|
|
|
}
|
|
}
|
|
|
},
|
|
},
|
|
|
mounted () {
|
|
mounted () {
|
|
|
- // todo
|
|
|
|
|
teacherGetCourses({ sort: 'name' }).then(res => {
|
|
teacherGetCourses({ sort: 'name' }).then(res => {
|
|
|
- if (res) {
|
|
|
|
|
- this.courses = res
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ this.courses = res.data
|
|
|
|
|
+ }).catch(err => {
|
|
|
|
|
+ this.$setErrorMessage('获取课件列表过程中:' + err.response.data.msg)
|
|
|
})
|
|
})
|
|
|
},
|
|
},
|
|
|
|
|
+ computed: {},
|
|
|
methods: {
|
|
methods: {
|
|
|
|
|
+ formChecked () {
|
|
|
|
|
+ if (!this.selectedCourseId) {
|
|
|
|
|
+ this.message = '请选择所属课程'
|
|
|
|
|
+ return false
|
|
|
|
|
+ }
|
|
|
|
|
+ if (!this.slideName) {
|
|
|
|
|
+ this.message = '请输入课件的名称'
|
|
|
|
|
+ return false
|
|
|
|
|
+ }
|
|
|
|
|
+ if (!this.file) {
|
|
|
|
|
+ this.message = '请上传课件文件'
|
|
|
|
|
+ return false
|
|
|
|
|
+ }
|
|
|
|
|
+ return true
|
|
|
|
|
+ },
|
|
|
handleSubmit () {
|
|
handleSubmit () {
|
|
|
|
|
+ if (!this.formChecked) {
|
|
|
|
|
+ this.$setInfoMessage(this.message)
|
|
|
|
|
+ return
|
|
|
|
|
+ }
|
|
|
|
|
+ createSlide({ courseId: this.selectedCourseId, name: this.slideName, file: this.file })
|
|
|
|
|
+ },
|
|
|
|
|
+ handleFileChanged (file) {
|
|
|
|
|
+ this.file = file || null
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
@@ -88,8 +113,4 @@ select {
|
|
|
.select-wrapper, .c-input {
|
|
.select-wrapper, .c-input {
|
|
|
margin-bottom: 24px;
|
|
margin-bottom: 24px;
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
-.my-button {
|
|
|
|
|
- margin-top: 24px;
|
|
|
|
|
-}
|
|
|
|
|
</style>
|
|
</style>
|