[前端]修复问题管理(后台)页面的avalon重复定义的问题[CI SKIP]

This commit is contained in:
esp
2015-08-24 18:39:11 +08:00
parent 53e82136e4
commit 2ed22c3bce
3 changed files with 76 additions and 40 deletions

View File

@@ -1,7 +1,7 @@
require(["jquery", "avalon", "editor", "uploader", "bsAlert", "csrfToken", "tagEditor", "validator", "jqueryUI"],
function ($, avalon, editor, uploader, bsAlert, csrfTokenHeader) {
avalon.ready(function () {
avalon.vmodels.addProblem = null;
$("#add-problem-form").validator()
.on('submit', function (e) {
if (!e.isDefaultPrevented()){
@@ -63,6 +63,7 @@ require(["jquery", "avalon", "editor", "uploader", "bsAlert", "csrfToken", "tagE
success: function (data) {
if (!data.code) {
bsAlert("题目添加成功!");
location.hash = "problem/problem_list";
}
else {
bsAlert(data.data);
@@ -92,7 +93,27 @@ require(["jquery", "avalon", "editor", "uploader", "bsAlert", "csrfToken", "tagE
var hintEditor = editor("#hint");
var problemDescription = editor("#problemDescription");
if (avalon.vmodels.addProblem) {
var vm = avalon.vmodels.addProblem;
vm.title = "";
vm.description = "";
vm.timeLimit = 1000;
vm.memoryLimit = 256;
vm.samples = [{input: "", output: "", "visible": true}];
vm.hint = "";
vm.visible = true;
vm.difficulty = 0;
vm.tags = [];
vm.inputDescription = "";
vm.outputDescription = "";
vm.testCaseId = "";
vm.testCaseList = [];
vm.uploadSuccess = false;
vm.source = "";
hintEditor.setValue("");
problemDescription.setValue("");
}
else
var vm = avalon.define({
$id: "addProblem",
title: "",

View File

@@ -2,7 +2,6 @@ require(["jquery", "avalon", "editor", "uploader", "bsAlert", "csrfToken", "tagE
function ($, avalon, editor, uploader, bsAlert, csrfTokenHeader) {
avalon.ready(function () {
avalon.vmodels.editProblem = null;
$("#edit-problem-form").validator()
.on('submit', function (e) {
@@ -65,6 +64,7 @@ require(["jquery", "avalon", "editor", "uploader", "bsAlert", "csrfToken", "tagE
success: function (data) {
if (!data.code) {
bsAlert("题目编辑成功!");
vm.showProblemListPage();
}
else {
bsAlert(data.data);
@@ -75,7 +75,24 @@ require(["jquery", "avalon", "editor", "uploader", "bsAlert", "csrfToken", "tagE
return false;
}
});
if (avalon.vmodels.editProblem) {
var vm = avalon.vmodels.editProblem;
title: "",
description= "";
timeLimit= -1;
memoryLimit= -1;
samples= [];
hint= "";
visible= true;
difficulty= 0;
inputDescription= "";
outputDescription= "";
testCaseIdd= "";
uploadSuccess= false;
source= "";
testCaseList= [];
}
else
var vm = avalon.define({
$id: "editProblem",
title: "",

View File

@@ -41,10 +41,8 @@ require(["jquery", "avalon", "csrfToken", "bsAlert"], function ($, avalon, csrfT
vm.$fire("up!showProblemSubmissionPage", problemId);
}
});
getPageData(1);
}
getPageData(1);
function getPageData(page) {
var url = "/api/admin/problem/?paging=true&page=" + page + "&page_size=10";
if (vm.keyword != "")