试题管理-编辑、添加

pg_adapter
dshclm 9 months ago
parent 648c6a8510
commit 30a36615ae

@ -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' })
// })
})
},
},

@ -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' })
// })
})
},
},

Loading…
Cancel
Save