试题管理-编辑、添加

pg_adapter
dshclm 10 months ago
parent 648c6a8510
commit 30a36615ae

@ -264,6 +264,33 @@
removeItem(index) { removeItem(index) {
this.postForm.answerList.splice(index, 1) 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() { submitForm() {
let rightCount = 0 let rightCount = 0
this.postForm.answerList.forEach(function(item) { this.postForm.answerList.forEach(function(item) {
@ -305,37 +332,16 @@
if (!valid) { if (!valid) {
return return
} }
// console.log(this.postForm) let that = this
// $.ajax({
// url: ctx + 'system/qu/add',
// type: "POST",
// data: this.postForm,
// dataType:'JSON',
// success: (res) => {
// console.log(res)
// },
// error: function() {
// // 请求失败时显示错误消息
// }
// });
axios.post(ctx + 'system/qu/add', this.postForm) axios.post(ctx + 'system/qu/add', this.postForm)
.then(function (response) { .then(function (response) {
console.log(response); if (response.data.code === 0) {
that.successTabCallback(response)
}
}) })
.catch(function (error) { .catch(function (error) {
console.log(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: { methods: {
//获取详情 //获取详情
getDetail(){ getDetail(){
console.log( [[${detailDTO.id}]]) let that = this
axios.get(ctx + 'system/qu/detail', {params: {quId: [[${detailDTO.id}]]}}) axios.get(ctx + 'system/qu/detail', {params: {quId: '[[${detailDTO.id}]]'}})
.then(function (response) { .then(function (res) {
console.log(response); that.postForm = res.data.data
console.log(that.postForm)
}) })
.catch(function (error) { .catch(function (error) {
console.log(error); console.log(error);
@ -274,6 +275,33 @@
removeItem(index) { removeItem(index) {
this.postForm.answerList.splice(index, 1) 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() { submitForm() {
let rightCount = 0 let rightCount = 0
this.postForm.answerList.forEach(function(item) { this.postForm.answerList.forEach(function(item) {
@ -315,24 +343,16 @@
if (!valid) { if (!valid) {
return return
} }
axios.post(ctx + 'system/qu/add', this.postForm) let that = this
axios.post(ctx + 'system/qu/edit', this.postForm)
.then(function (response) { .then(function (response) {
console.log(response); if (response.data.code === 0) {
that.successTabCallback(response)
}
}) })
.catch(function (error) { .catch(function (error) {
console.log(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