From 30a36615ae53b21c765fb08e8b8fb71b46a359b2 Mon Sep 17 00:00:00 2001 From: dshclm <3321914460@qq.com> Date: Wed, 3 Jul 2024 10:55:53 +0800 Subject: [PATCH] =?UTF-8?q?=E8=AF=95=E9=A2=98=E7=AE=A1=E7=90=86-=E7=BC=96?= =?UTF-8?q?=E8=BE=91=E3=80=81=E6=B7=BB=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../templates/system/elExam/qu/add.html | 56 ++++++++++--------- .../templates/system/elExam/qu/edit.html | 54 ++++++++++++------ 2 files changed, 68 insertions(+), 42 deletions(-) diff --git a/ruoyi-admin/src/main/resources/templates/system/elExam/qu/add.html b/ruoyi-admin/src/main/resources/templates/system/elExam/qu/add.html index ec1ad7e..3d72caf 100644 --- a/ruoyi-admin/src/main/resources/templates/system/elExam/qu/add.html +++ b/ruoyi-admin/src/main/resources/templates/system/elExam/qu/add.html @@ -264,6 +264,33 @@ removeItem(index) { this.postForm.answerList.splice(index, 1) }, + // 选项卡成功回调执行事件(父窗体静默更新) + successTabCallback(result) { + if (result.data.code == web_status.SUCCESS) { + var topWindow = $(window.parent.document); + var currentId = $('.page-tabs-content', topWindow).find('.active').attr('data-panel'); + var topWindow = $('.RuoYi_iframe[data-id="' + currentId + '"]', topWindow)[0]; + if ($.common.isNotEmpty(topWindow) && $.common.isNotEmpty(currentId)) { + var $contentWindow = topWindow.contentWindow; + $contentWindow.$.modal.msgSuccess(result.data.msg); + $contentWindow.$(".layui-layer-padding").removeAttr("style"); + if ($contentWindow.table.options.type == table_type.bootstrapTable) { + $contentWindow.$.table.refresh(); + } else if ($contentWindow.table.options.type == table_type.bootstrapTreeTable) { + $contentWindow.$.treeTable.refresh(); + } + } else { + $.modal.msgSuccess(result.data.msg); + } + $.modal.close(); + $.modal.closeTab(); + } else if (result.data.code == web_status.WARNING) { + $.modal.alertWarning(result.data.msg) + } else { + $.modal.alertError(result.data.msg); + } + $.modal.closeLoading(); + }, submitForm() { let rightCount = 0 this.postForm.answerList.forEach(function(item) { @@ -305,37 +332,16 @@ if (!valid) { return } - // console.log(this.postForm) - // $.ajax({ - // url: ctx + 'system/qu/add', - // type: "POST", - // data: this.postForm, - // dataType:'JSON', - // success: (res) => { - // console.log(res) - // }, - // error: function() { - // // 请求失败时显示错误消息 - // } - // }); + let that = this axios.post(ctx + 'system/qu/add', this.postForm) .then(function (response) { - console.log(response); + if (response.data.code === 0) { + that.successTabCallback(response) + } }) .catch(function (error) { console.log(error); }); - // saveData(this.postForm).then(response => { - // this.postForm = response.data - // this.$notify({ - // title: '成功', - // message: '试题保存成功!', - // type: 'success', - // duration: 2000 - // }) - // - // this.$router.push({ name: 'ListQu' }) - // }) }) }, }, diff --git a/ruoyi-admin/src/main/resources/templates/system/elExam/qu/edit.html b/ruoyi-admin/src/main/resources/templates/system/elExam/qu/edit.html index e700d2f..08f0fef 100644 --- a/ruoyi-admin/src/main/resources/templates/system/elExam/qu/edit.html +++ b/ruoyi-admin/src/main/resources/templates/system/elExam/qu/edit.html @@ -188,10 +188,11 @@ methods: { //获取详情 getDetail(){ - console.log( [[${detailDTO.id}]]) - axios.get(ctx + 'system/qu/detail', {params: {quId: [[${detailDTO.id}]]}}) - .then(function (response) { - console.log(response); + let that = this + axios.get(ctx + 'system/qu/detail', {params: {quId: '[[${detailDTO.id}]]'}}) + .then(function (res) { + that.postForm = res.data.data + console.log(that.postForm) }) .catch(function (error) { console.log(error); @@ -274,6 +275,33 @@ removeItem(index) { this.postForm.answerList.splice(index, 1) }, + // 选项卡成功回调执行事件(父窗体静默更新) + successTabCallback(result) { + if (result.data.code == web_status.SUCCESS) { + var topWindow = $(window.parent.document); + var currentId = $('.page-tabs-content', topWindow).find('.active').attr('data-panel'); + var topWindow = $('.RuoYi_iframe[data-id="' + currentId + '"]', topWindow)[0]; + if ($.common.isNotEmpty(topWindow) && $.common.isNotEmpty(currentId)) { + var $contentWindow = topWindow.contentWindow; + $contentWindow.$.modal.msgSuccess(result.data.msg); + $contentWindow.$(".layui-layer-padding").removeAttr("style"); + if ($contentWindow.table.options.type == table_type.bootstrapTable) { + $contentWindow.$.table.refresh(); + } else if ($contentWindow.table.options.type == table_type.bootstrapTreeTable) { + $contentWindow.$.treeTable.refresh(); + } + } else { + $.modal.msgSuccess(result.data.msg); + } + $.modal.close(); + $.modal.closeTab(); + } else if (result.data.code == web_status.WARNING) { + $.modal.alertWarning(result.data.msg) + } else { + $.modal.alertError(result.data.msg); + } + $.modal.closeLoading(); + }, submitForm() { let rightCount = 0 this.postForm.answerList.forEach(function(item) { @@ -315,24 +343,16 @@ if (!valid) { return } - axios.post(ctx + 'system/qu/add', this.postForm) + let that = this + axios.post(ctx + 'system/qu/edit', this.postForm) .then(function (response) { - console.log(response); + if (response.data.code === 0) { + that.successTabCallback(response) + } }) .catch(function (error) { console.log(error); }); - // saveData(this.postForm).then(response => { - // this.postForm = response.data - // this.$notify({ - // title: '成功', - // message: '试题保存成功!', - // type: 'success', - // duration: 2000 - // }) - // - // this.$router.push({ name: 'ListQu' }) - // }) }) }, },