You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

186 lines
7.4 KiB
JavaScript

$(function () {
//列表
GetList("");
//搜索
$("#btnSearch").unbind("click").click(function () {
//获取查询条件
var KeyWord = "";
var type = $("#selectFinancialType").val();
var key = $.trim($("#txtKeyWord").val());
if (key != null && key != "" && key.length > 0) {
KeyWord = key;
}
if (KeyWord == "试卷名称") { KeyWord = ""; }
GetList(KeyWord);
});
$("#txtKeyWord").unbind("focus").focus(function () {
$(this).val("").css("color", "black")
});
})
/**
* @name 获取试卷列表
*/
function GetList(KeyWord) {
pageHelper.Init({
url: "/Teacher/TheoryQuestion/TestPapersList",
type: "POST",
pageDiv: "#PapersPage",
data:
{
Keyword: KeyWord,
rId: Math.random()
},
bind: function (data) {
var html = "";
if (data.Data.length > 0) {
$(data.Data).each(function (index, dom) {
//每行html
var trHtml = "";
trHtml += "<tr>";
trHtml += "<td><div title=\"{0}\" class=\"ellipsis\" >{0}</div></td>";
trHtml += "<td><span title=\"{1}\">{1}</span></td>";
trHtml += "<td><span title=\"{2}\">{2}</span></td>";
trHtml += "<td><div title=\"{3}\" class=\"ellipsis\" >{3}</div></td>";
trHtml += "<td class=\"time\"><span>{4}</span></td>";
trHtml += "<td class=\"operate\">";
if (dom.StatusName != "已开始") {
if (dom.Status == EnumList.ExamPaperStatus.UnPublish)//未发布
{
trHtml += "<a class=\"spr spr-publish\" title=\"发布\" href=\"javascript:PublishPapers({5},{6});\"></a>";
trHtml += "<a class=\"spr spr-edit\" title=\"编辑\" href=\"javascript:EditPapers({5},{6});\"></a>";
}
if (dom.StatusName == "已结束" || dom.Status == EnumList.ExamPaperStatus.UnPublish) {
trHtml += "<a class=\"spr spr-del\" title=\"删除\" href=\"javascript:DelPapers({5});\"></a>";
}
if (dom.StatusName == "未开始")//已发布
{
trHtml += "<a class=\"spr spr-recall\" title=\"撤销\" href=\"javascript:CancelPapers({5},{6});\"></a>";
trHtml += "<a class=\"spr spr-del\" title=\"删除\" href=\"javascript:DelPapers({5},{6});\"></a>";
}
}
trHtml += "</td>";
trHtml += "</tr>";
//拼接tbody
html += StringHelper.FormatStr(trHtml,
dom.ExamPaperName, //1 试卷名称
dom.strStartDate, //2 开始时间
dom.strEndDate, //3 截止时间
dom.ClassName, //4 班级
dom.StatusName, //5 发布状态
dom.Id, //6 Id
dom.Status //7试卷状态
);
});
} else {
html = "<tr><td colspan='6'>无相关记录!</td></tr>";
}
$("#TestPaperList").html(html);
}
});
}
//发布
function PublishPapers(PapersId,Status) {
if (Status != EnumList.ExamPaperStatus.UnPublish) {
dialogHelper.Error({
content: "发布失败!只能对未发布的试卷做发布。",
success: function () {
location.href = location.href;
}
});
return;
}
dialogHelper.Confirm({
content: "确认是否发布?",
success: function () {
$.ajax({
url: "/Teacher/TheoryQuestion/ReleasePaper",
async: false,
type: "POST",
data: {
PaperID: PapersId,
},
success: function (data) {
dialogHelper.Success({
content: "发布成功!",
success: function () {
location.href = location.href;
}
});
}
});
}
});
}
//撤回
function CancelPapers(PapersId, Status) {
if (Status != EnumList.ExamPaperStatus.Publish) {
dialogHelper.Error({
content: "撤销失败!只能对已发布的试卷做撤销。",
success: function () {
location.href = location.href;
}
});
return;
}
dialogHelper.Confirm({
content: "确认是否撤销?",
success: function () {
$.ajax({
url: "/Teacher/TheoryQuestion/CancelPapers",
async: false,
type: "POST",
data: {
PapersId: PapersId,
},
success: function (data) {
dialogHelper.Success({
content: "撤销成功!",
success: function () {
location.href = location.href;
}
});
}
});
}
});
}
//编辑
function EditPapers(PapersId, Status) {
if (Status != EnumList.ExamPaperStatus.UnPublish) {
dialogHelper.Error({
content: "修改失败!只能对未发布的试卷做修改。",
success: function () {
location.href = location.href;
}
});
return;
}
location.href = "/Teacher/TheoryQuestion/TestPapers?Status=Edit&PapersId=" + PapersId;
}
//删除
function DelPapers(PapersId) {
dialogHelper.Confirm({
content: "确认是否删除?",
success: function () {
$.ajax({
url: "/Teacher/TheoryQuestion/DelPapers",
async: false,
type: "POST",
data: {
PapersId: PapersId
},
success: function (data) {
dialogHelper.Success({
content: "删除成功!",
success: function () {
location.href = location.href;
}
});
}
});
}
});
}