From cd6e6091bdb761b4963911bee58b6f3e81b0ca39 Mon Sep 17 00:00:00 2001 From: lion <120344285@qq.com> Date: Wed, 11 Sep 2024 17:45:07 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=84=8F=E8=A7=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/course/form.js | 8 +++ src/views/course/components/applyForm.vue | 77 ++++++++++++++++++++--- src/views/course/components/editClass.vue | 2 +- 3 files changed, 76 insertions(+), 11 deletions(-) diff --git a/src/api/course/form.js b/src/api/course/form.js index 2deacc1..6e4c222 100644 --- a/src/api/course/form.js +++ b/src/api/course/form.js @@ -54,4 +54,12 @@ export function destroy(params) { }) } +export function cloneForm(params) { + return request({ + method: "get", + url: "/api/admin/course-forms/clone", + params + }) +} + diff --git a/src/views/course/components/applyForm.vue b/src/views/course/components/applyForm.vue index cf9257a..c66eb20 100644 --- a/src/views/course/components/applyForm.vue +++ b/src/views/course/components/applyForm.vue @@ -3,12 +3,14 @@ + + + +
是否确认克隆{{hasCourseName}}的报名表单,克隆后将覆盖原有课程的报名表单,请谨慎操作。
+ + 取 消 + 确 定 +
@@ -92,8 +105,12 @@ import { index, save, - destroy - } from "@/api/course/form"; + destroy, + cloneForm + } from "@/api/course/form"; + import { + index as courseIndex + } from "@/api/course/index.js" import { deepCopy } from "@/utils"; @@ -114,7 +131,11 @@ sort_name: 'sort', sort_type: 'ASC' }, - dialogVisible: false, + dialogVisible: false, + showTips:false, + hasCourseId:'', + hasCourseName:'', + hasCourseList:[], formList: [], types: [], rules: {}, @@ -126,9 +147,45 @@ } }, created() { - this.getConfig() + this.getConfig() + this.getCourseList() }, - methods: { + methods: { + // 获取有 自定义表单的 课程 + async getCourseList(){ + const res = await courseIndex({ + page:1, + page_size:999, + has_course_forms:1, + sort_name:'id', + sort_type:'ASC', + }) + + this.hasCourseList = res.data.filter((item)=>{return item.id!=this.course_id}) + }, + changeCourse(e){ + console.log("course-e",e) + if(e){ + this.hasCourseList.map(item=>{ + if(item.id===e){ + this.hasCourseId = e + this.hasCourseName = item.name + this.showTips = true + } + }) + } + }, + // 复制表单数据 + copyForms(){ + cloneForm({ + from_course_id:this.hasCourseId, + to_course_id:this.course_id + }).then(res=>{ + this.$Message.success('克隆成功') + this.showTips = false + this.getFormList() + }) + }, //获取 左侧 formitem类型 async getConfig() { const { diff --git a/src/views/course/components/editClass.vue b/src/views/course/components/editClass.vue index f071af9..df298c3 100644 --- a/src/views/course/components/editClass.vue +++ b/src/views/course/components/editClass.vue @@ -146,7 +146,7 @@ id: this.id, show_relation: ['teacher'] }).then(res => { - this.form = this.base.requestToForm(res, this.form) + this.form = this.base.deepCopy(res) this.form.introduce = res.teacher.introduce }) },