|
|
@@ -2,12 +2,12 @@
|
|
|
<tab-side-component>
|
|
|
<back-title>新建课程</back-title>
|
|
|
<div class="sub-title">课程名称:</div>
|
|
|
- <c-input placeholder="请勿与已有课程名称重名"/>
|
|
|
+ <c-input placeholder="不能与已有课程名称重名" v-model="name"/>
|
|
|
<div class="sub-title">课程简介:</div>
|
|
|
- <c-input textarea="true" placeholder="请勿与已有课程名称重名"/>
|
|
|
+ <c-input textarea="true" maxlength="65" v-model="bio" placeholder="课程简要介绍,少于 65 字"/>
|
|
|
<div class="sub-title">选课码:</div>
|
|
|
- <c-input placeholder="学生将通过选课码注册课程"/>
|
|
|
- <c-button>确认创建</c-button>
|
|
|
+ <c-input placeholder="学生将通过选课码注册课程" v-model="code"/>
|
|
|
+ <c-button class="secondary full-width" @click="handleCreate" :disabled="!formChecked()">确认创建</c-button>
|
|
|
</tab-side-component>
|
|
|
</template>
|
|
|
|
|
|
@@ -16,9 +16,50 @@ import TabSideComponent from '@/components/TabSideComponent'
|
|
|
import CInput from '@/components/CInput'
|
|
|
import CButton from '@/components/CButton'
|
|
|
import BackTitle from '@/components/BackTitle'
|
|
|
+import { createCourse } from '@/server/course'
|
|
|
|
|
|
export default {
|
|
|
- components: { BackTitle, CButton, CInput, TabSideComponent }
|
|
|
+ components: { BackTitle, CButton, CInput, TabSideComponent },
|
|
|
+ data () {
|
|
|
+ return {
|
|
|
+ name: '',
|
|
|
+ bio: '',
|
|
|
+ code: '',
|
|
|
+ message: ''
|
|
|
+ }
|
|
|
+ },
|
|
|
+ methods: {
|
|
|
+ formChecked () {
|
|
|
+ if (!this.name) {
|
|
|
+ this.message = '课程名称不能为空'
|
|
|
+ return false
|
|
|
+ }
|
|
|
+ if (!this.bio) {
|
|
|
+ this.message = '请为课程添加一个简短的介绍'
|
|
|
+ return false
|
|
|
+ }
|
|
|
+ if (!this.code) {
|
|
|
+ this.message = '请为课程添加一个选课码,便于您班级管理'
|
|
|
+ return false
|
|
|
+ }
|
|
|
+
|
|
|
+ return true
|
|
|
+ },
|
|
|
+ handleCreate () {
|
|
|
+ if (!this.formChecked()) {
|
|
|
+ this.$showMessage({
|
|
|
+ message: this.message
|
|
|
+ })
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ createCourse({ name: this.name, bio: this.bio, code: this.code }).then(res => {
|
|
|
+ if (res) {
|
|
|
+ // todo
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
</script>
|
|
|
|