|
@@ -121,7 +121,7 @@
|
|
|
import StepBar from '@/components/StepBar';
|
|
|
import SelectTeacher from '@/components/select/SelectTeacher.vue';
|
|
|
import { fileUpload } from '@/api/app';
|
|
|
-import { CreateCourse } from '@/api/course';
|
|
|
+import { CreateCourse, GetCourseInfo_ContainCSItem, UpdateCourse } from '@/api/course';
|
|
|
import { twoDecimal } from '@/utils/validate';
|
|
|
import { getMyOrgList } from '@/api/list';
|
|
|
import { GetUserListByIDList } from '@/api/user';
|
|
@@ -131,6 +131,7 @@ export default {
|
|
|
components: { StepBar, SelectTeacher },
|
|
|
data() {
|
|
|
return {
|
|
|
+ id: this.$route.query.id,
|
|
|
form: {
|
|
|
imageUrl: '',
|
|
|
picture_id: '',
|
|
@@ -160,6 +161,43 @@ export default {
|
|
|
getMyOrgList().then(({ org_list }) => {
|
|
|
this.orgList = org_list;
|
|
|
});
|
|
|
+ if (this.id) {
|
|
|
+ GetCourseInfo_ContainCSItem({ id: this.id }).then(
|
|
|
+ ({
|
|
|
+ name,
|
|
|
+ org_id,
|
|
|
+ picture_id,
|
|
|
+ picture_url,
|
|
|
+ intro,
|
|
|
+ begin_date,
|
|
|
+ end_date,
|
|
|
+ student_count_start,
|
|
|
+ is_auto_close,
|
|
|
+ student_enter_control_type,
|
|
|
+ price,
|
|
|
+ is_enable_KHPJ,
|
|
|
+ is_enable_XYZP,
|
|
|
+ teacher_list
|
|
|
+ }) => {
|
|
|
+ this.form.name = name;
|
|
|
+ this.form.org_id = org_id;
|
|
|
+ this.form.picture_id = picture_id;
|
|
|
+ this.form.imageUrl = picture_url;
|
|
|
+ this.form.intro = intro;
|
|
|
+ this.form.date = [begin_date, end_date];
|
|
|
+ this.form.student_count_start = student_count_start;
|
|
|
+ this.form.is_auto_close = is_auto_close === 'true';
|
|
|
+ this.form.student_enter_control_type = student_enter_control_type;
|
|
|
+ this.form.price = price;
|
|
|
+ this.form.is_enable_KHPJ = is_enable_KHPJ === 'true';
|
|
|
+ this.form.is_enable_XYZP = is_enable_XYZP === 'true';
|
|
|
+ teacher_list.forEach(item => {
|
|
|
+ this.form.teacher_id_list.push(item.teacher_id);
|
|
|
+ this.user_list.push({ id: item.teacher_id, real_name: item.teacher_name });
|
|
|
+ });
|
|
|
+ }
|
|
|
+ );
|
|
|
+ }
|
|
|
},
|
|
|
methods: {
|
|
|
nextStep() {
|
|
@@ -168,10 +206,18 @@ export default {
|
|
|
this.form.begin_date = this.form.date[0];
|
|
|
this.form.end_date = this.form.date[1];
|
|
|
|
|
|
- CreateCourse(this.form).then(response => {
|
|
|
- this.$message.success('创建课程成功!');
|
|
|
- this.$router.push({ path: `/create_course_step_table/select_book/${response.id}` });
|
|
|
- });
|
|
|
+ if (this.id) {
|
|
|
+ this.form.id = this.id;
|
|
|
+ UpdateCourse(this.form).then(() => {
|
|
|
+ this.$message.success('修改课程成功!');
|
|
|
+ this.$router.push({ path: `/create_course_step_table/select_book/${this.id}` });
|
|
|
+ });
|
|
|
+ } else {
|
|
|
+ CreateCourse(this.form).then(res => {
|
|
|
+ this.$message.success('创建课程成功!');
|
|
|
+ this.$router.push({ path: `/create_course_step_table/select_book/${res.id}` });
|
|
|
+ });
|
|
|
+ }
|
|
|
} else {
|
|
|
return false;
|
|
|
}
|
|
@@ -208,8 +254,8 @@ export default {
|
|
|
dialogClose() {
|
|
|
this.dialogVisible = false;
|
|
|
},
|
|
|
- selectTeaher(orgList) {
|
|
|
- this.form.teacher_id_list = this.form.teacher_id_list.concat(orgList);
|
|
|
+ selectTeaher(teacherList) {
|
|
|
+ this.form.teacher_id_list = this.form.teacher_id_list.concat(teacherList);
|
|
|
this.dialogVisible = false;
|
|
|
this.getUserList();
|
|
|
},
|
|
@@ -220,8 +266,7 @@ export default {
|
|
|
},
|
|
|
// 授课教师 tag 删除事件
|
|
|
tagClose(id, index) {
|
|
|
- let list = this.user_list;
|
|
|
- list.splice(index, 1);
|
|
|
+ this.user_list.splice(index, 1);
|
|
|
|
|
|
let teacherList = this.form.teacher_id_list;
|
|
|
teacherList.splice(teacherList.indexOf(id), 1);
|