|
@@ -8,7 +8,7 @@
|
|
|
<img
|
|
<img
|
|
|
class="newSubject"
|
|
class="newSubject"
|
|
|
src="../../../assets/white.png"
|
|
src="../../../assets/white.png"
|
|
|
- @click="isCardModalActive = true"
|
|
|
|
|
|
|
+ @click="joinCouseActive = true"
|
|
|
/>
|
|
/>
|
|
|
</div>
|
|
</div>
|
|
|
</div>
|
|
</div>
|
|
@@ -22,23 +22,101 @@
|
|
|
</div>
|
|
</div>
|
|
|
</div>
|
|
</div>
|
|
|
</div>
|
|
</div>
|
|
|
|
|
+ <!-- 新建课程模态框 -->
|
|
|
|
|
+ <b-modal :active.sync="joinCouseActive" :width="320" scroll="keep">
|
|
|
|
|
+ <div class="card">
|
|
|
|
|
+ <div class="title">加入课程</div>
|
|
|
|
|
+ <div class="content">
|
|
|
|
|
+ <b-field
|
|
|
|
|
+ label="选课码"
|
|
|
|
|
+ :type="$v.coursenum.$error ? 'is-danger' : ''"
|
|
|
|
|
+ :message="
|
|
|
|
|
+ $v.coursenum.$error
|
|
|
|
|
+ ? [
|
|
|
|
|
+ !$v.coursenum.minLength ? '选课码不少于4个字符' : undefined,
|
|
|
|
|
+ !$v.coursenum.maxLength
|
|
|
|
|
+ ? '选课码不多于10个字符'
|
|
|
|
|
+ : undefined,
|
|
|
|
|
+ !$v.coursenum.required ? '请填写选课码' : undefined,
|
|
|
|
|
+ !$v.coursenum.alphaNum ? '选课码应为字母或数字' : undefined
|
|
|
|
|
+ ]
|
|
|
|
|
+ : ''
|
|
|
|
|
+ "
|
|
|
|
|
+ >
|
|
|
|
|
+ <b-input
|
|
|
|
|
+ v-model="$v.coursenum.$model"
|
|
|
|
|
+ placeholder="请输入选课码"
|
|
|
|
|
+ ></b-input>
|
|
|
|
|
+ </b-field>
|
|
|
|
|
+ <a
|
|
|
|
|
+ :class="['button', 'is-link', { 'is-loading': submitting }]"
|
|
|
|
|
+ @click="joinSubject"
|
|
|
|
|
+ >加入课程</a
|
|
|
|
|
+ >
|
|
|
|
|
+ </div>
|
|
|
|
|
+ </div>
|
|
|
|
|
+ </b-modal>
|
|
|
</div>
|
|
</div>
|
|
|
</template>
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
|
<script>
|
|
|
import Card from "@/components/Card";
|
|
import Card from "@/components/Card";
|
|
|
-import { getStudentCourses } from "@/api/course";
|
|
|
|
|
|
|
+import { getStudentCourses, postStudentCourse } from "@/api/course";
|
|
|
|
|
+import {
|
|
|
|
|
+ required,
|
|
|
|
|
+ minLength,
|
|
|
|
|
+ maxLength,
|
|
|
|
|
+ alphaNum
|
|
|
|
|
+} from "vuelidate/lib/validators";
|
|
|
|
|
+
|
|
|
export default {
|
|
export default {
|
|
|
components: {
|
|
components: {
|
|
|
Card
|
|
Card
|
|
|
},
|
|
},
|
|
|
|
|
+ validations: {
|
|
|
|
|
+ coursenum: {
|
|
|
|
|
+ required,
|
|
|
|
|
+ minLength: minLength(4),
|
|
|
|
|
+ maxLength: maxLength(10),
|
|
|
|
|
+ alphaNum
|
|
|
|
|
+ }
|
|
|
|
|
+ },
|
|
|
data() {
|
|
data() {
|
|
|
return {
|
|
return {
|
|
|
- courses: []
|
|
|
|
|
|
|
+ courses: [],
|
|
|
|
|
+ joinCouseActive: false,
|
|
|
|
|
+ coursenum: "",
|
|
|
|
|
+ submitting: false
|
|
|
};
|
|
};
|
|
|
},
|
|
},
|
|
|
mounted() {
|
|
mounted() {
|
|
|
getStudentCourses().then(value => (this.courses = value.data));
|
|
getStudentCourses().then(value => (this.courses = value.data));
|
|
|
|
|
+ },
|
|
|
|
|
+ methods: {
|
|
|
|
|
+ //加入课程
|
|
|
|
|
+ joinSubject() {
|
|
|
|
|
+ this.$v.$touch();
|
|
|
|
|
+ this.submitting = true;
|
|
|
|
|
+ if (!this.$v.$invalid) {
|
|
|
|
|
+ postStudentCourse(this.coursenum)
|
|
|
|
|
+ .then(res => {
|
|
|
|
|
+ this.submitting = false;
|
|
|
|
|
+ this.joinCouseActive = false;
|
|
|
|
|
+ console.log(res);
|
|
|
|
|
+ this.$toast.open({
|
|
|
|
|
+ message: `${res.data.name} 选课成功`,
|
|
|
|
|
+ type: "is-success"
|
|
|
|
|
+ });
|
|
|
|
|
+ })
|
|
|
|
|
+ .catch(e => {
|
|
|
|
|
+ this.submitting = false;
|
|
|
|
|
+ this.$toast.open({
|
|
|
|
|
+ message: e.message,
|
|
|
|
|
+ type: "is-danger"
|
|
|
|
|
+ });
|
|
|
|
|
+ });
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
};
|
|
};
|
|
|
</script>
|
|
</script>
|
|
@@ -62,6 +140,22 @@ export default {
|
|
|
color: #ffffff;
|
|
color: #ffffff;
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
+.card {
|
|
|
|
|
+ padding: 30px;
|
|
|
|
|
+ .title {
|
|
|
|
|
+ font-size: 1.25rem;
|
|
|
|
|
+ small {
|
|
|
|
|
+ color: gray;
|
|
|
|
|
+ font-size: 1rem;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ .content {
|
|
|
|
|
+ a {
|
|
|
|
|
+ margin-top: 30px;
|
|
|
|
|
+ width: 100%;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+}
|
|
|
.newSubject {
|
|
.newSubject {
|
|
|
height: 80px;
|
|
height: 80px;
|
|
|
width: 80px;
|
|
width: 80px;
|